nterminal 1.2.77 → 1.2.79
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/client/assets/MarkdownPreview-BBppqaO6.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BkGu6YVq.js → TranscriptMarkdownBody-9-cPRj-d.js} +1 -1
- package/dist/client/assets/{index-gSePR0Ob.js → index-DAjEhbeV.js} +35 -35
- package/dist/client/assets/{index-Bgqck-vt.js → index-bffyLU7T.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/scripts/onboarding.js +4 -1
- package/dist/scripts/onboarding.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-D5NthhhG.js +0 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-
|
|
2
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function uE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xp={exports:{}},uc={};var CS;function dE(){if(CS)return uc;CS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var m in o)m!=="key"&&(c[m]=o[m])}else c=o;return o=c.ref,{$$typeof:e,type:s,key:d,ref:o!==void 0?o:null,props:c}}return uc.Fragment=t,uc.jsx=n,uc.jsxs=n,uc}var xS;function hE(){return xS||(xS=1,Xp.exports=dE()),Xp.exports}var p=hE(),Gp={exports:{}},tt={};var kS;function fE(){if(kS)return tt;kS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),C=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=C&&M[C]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,B={};function L(M,V,le){this.props=M,this.context=V,this.refs=B,this.updater=le||x}L.prototype.isReactComponent={},L.prototype.setState=function(M,V){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,V,"setState")},L.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function O(){}O.prototype=L.prototype;function X(M,V,le){this.props=M,this.context=V,this.refs=B,this.updater=le||x}var U=X.prototype=new O;U.constructor=X,D(U,L.prototype),U.isPureReactComponent=!0;var G=Array.isArray;function F(){}var W={H:null,A:null,T:null,S:null},ve=Object.prototype.hasOwnProperty;function Se(M,V,le){var _e=le.ref;return{$$typeof:e,type:M,key:V,ref:_e!==void 0?_e:null,props:le}}function xe(M,V){return Se(M.type,V,M.props)}function ie(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function q(M){var V={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(le){return V[le]})}var J=/\/+/g;function K(M,V){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):V.toString(36)}function re(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(F,F):(M.status="pending",M.then(function(V){M.status==="pending"&&(M.status="fulfilled",M.value=V)},function(V){M.status==="pending"&&(M.status="rejected",M.reason=V)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function A(M,V,le,_e,be){var Ee=typeof M;(Ee==="undefined"||Ee==="boolean")&&(M=null);var Me=!1;if(M===null)Me=!0;else switch(Ee){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(M.$$typeof){case e:case t:Me=!0;break;case y:return Me=M._init,A(Me(M._payload),V,le,_e,be)}}if(Me)return be=be(M),Me=_e===""?"."+K(M,0):_e,G(be)?(le="",Me!=null&&(le=Me.replace(J,"$&/")+"/"),A(be,V,le,"",function(Be){return Be})):be!=null&&(ie(be)&&(be=xe(be,le+(be.key==null||M&&M.key===be.key?"":(""+be.key).replace(J,"$&/")+"/")+Me)),V.push(be)),1;Me=0;var Re=_e===""?".":_e+":";if(G(M))for(var Pe=0;Pe<M.length;Pe++)_e=M[Pe],Ee=Re+K(_e,Pe),Me+=A(_e,V,le,Ee,be);else if(Pe=w(M),typeof Pe=="function")for(M=Pe.call(M),Pe=0;!(_e=M.next()).done;)_e=_e.value,Ee=Re+K(_e,Pe++),Me+=A(_e,V,le,Ee,be);else if(Ee==="object"){if(typeof M.then=="function")return A(re(M),V,le,_e,be);throw V=String(M),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return Me}function R(M,V,le){if(M==null)return M;var _e=[],be=0;return A(M,_e,"","",function(Ee){return V.call(le,Ee,be++)}),_e}function P(M){if(M._status===-1){var V=M._result;V=V(),V.then(function(le){(M._status===0||M._status===-1)&&(M._status=1,M._result=le)},function(le){(M._status===0||M._status===-1)&&(M._status=2,M._result=le)}),M._status===-1&&(M._status=0,M._result=V)}if(M._status===1)return M._result.default;throw M._result}var ne=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ge={map:R,forEach:function(M,V,le){R(M,function(){V.apply(this,arguments)},le)},count:function(M){var V=0;return R(M,function(){V++}),V},toArray:function(M){return R(M,function(V){return V})||[]},only:function(M){if(!ie(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return tt.Activity=b,tt.Children=ge,tt.Component=L,tt.Fragment=n,tt.Profiler=o,tt.PureComponent=X,tt.StrictMode=s,tt.Suspense=g,tt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=W,tt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return W.H.useMemoCache(M)}},tt.cache=function(M){return function(){return M.apply(null,arguments)}},tt.cacheSignal=function(){return null},tt.cloneElement=function(M,V,le){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var _e=D({},M.props),be=M.key;if(V!=null)for(Ee in V.key!==void 0&&(be=""+V.key),V)!ve.call(V,Ee)||Ee==="key"||Ee==="__self"||Ee==="__source"||Ee==="ref"&&V.ref===void 0||(_e[Ee]=V[Ee]);var Ee=arguments.length-2;if(Ee===1)_e.children=le;else if(1<Ee){for(var Me=Array(Ee),Re=0;Re<Ee;Re++)Me[Re]=arguments[Re+2];_e.children=Me}return Se(M.type,be,_e)},tt.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},tt.createElement=function(M,V,le){var _e,be={},Ee=null;if(V!=null)for(_e in V.key!==void 0&&(Ee=""+V.key),V)ve.call(V,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(be[_e]=V[_e]);var Me=arguments.length-2;if(Me===1)be.children=le;else if(1<Me){for(var Re=Array(Me),Pe=0;Pe<Me;Pe++)Re[Pe]=arguments[Pe+2];be.children=Re}if(M&&M.defaultProps)for(_e in Me=M.defaultProps,Me)be[_e]===void 0&&(be[_e]=Me[_e]);return Se(M,Ee,be)},tt.createRef=function(){return{current:null}},tt.forwardRef=function(M){return{$$typeof:m,render:M}},tt.isValidElement=ie,tt.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:P}},tt.memo=function(M,V){return{$$typeof:f,type:M,compare:V===void 0?null:V}},tt.startTransition=function(M){var V=W.T,le={};W.T=le;try{var _e=M(),be=W.S;be!==null&&be(le,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(F,ne)}catch(Ee){ne(Ee)}finally{V!==null&&le.types!==null&&(V.types=le.types),W.T=V}},tt.unstable_useCacheRefresh=function(){return W.H.useCacheRefresh()},tt.use=function(M){return W.H.use(M)},tt.useActionState=function(M,V,le){return W.H.useActionState(M,V,le)},tt.useCallback=function(M,V){return W.H.useCallback(M,V)},tt.useContext=function(M){return W.H.useContext(M)},tt.useDebugValue=function(){},tt.useDeferredValue=function(M,V){return W.H.useDeferredValue(M,V)},tt.useEffect=function(M,V){return W.H.useEffect(M,V)},tt.useEffectEvent=function(M){return W.H.useEffectEvent(M)},tt.useId=function(){return W.H.useId()},tt.useImperativeHandle=function(M,V,le){return W.H.useImperativeHandle(M,V,le)},tt.useInsertionEffect=function(M,V){return W.H.useInsertionEffect(M,V)},tt.useLayoutEffect=function(M,V){return W.H.useLayoutEffect(M,V)},tt.useMemo=function(M,V){return W.H.useMemo(M,V)},tt.useOptimistic=function(M,V){return W.H.useOptimistic(M,V)},tt.useReducer=function(M,V,le){return W.H.useReducer(M,V,le)},tt.useRef=function(M){return W.H.useRef(M)},tt.useState=function(M){return W.H.useState(M)},tt.useSyncExternalStore=function(M,V,le){return W.H.useSyncExternalStore(M,V,le)},tt.useTransition=function(){return W.H.useTransition()},tt.version="19.2.6",tt}var ES;function _v(){return ES||(ES=1,Gp.exports=fE()),Gp.exports}var v=_v();const Li=uE(v);var Zp={exports:{}},dc={},Qp={exports:{}},Jp={};var TS;function pE(){return TS||(TS=1,(function(e){function t(A,R){var P=A.length;A.push(R);e:for(;0<P;){var ne=P-1>>>1,ge=A[ne];if(0<o(ge,R))A[ne]=R,A[P]=ge,P=ne;else break e}}function n(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var R=A[0],P=A.pop();if(P!==R){A[0]=P;e:for(var ne=0,ge=A.length,M=ge>>>1;ne<M;){var V=2*(ne+1)-1,le=A[V],_e=V+1,be=A[_e];if(0>o(le,P))_e<ge&&0>o(be,le)?(A[ne]=be,A[_e]=P,ne=_e):(A[ne]=le,A[V]=P,ne=V);else if(_e<ge&&0>o(be,P))A[ne]=be,A[_e]=P,ne=_e;else break e}}return R}function o(A,R){var P=A.sortIndex-R.sortIndex;return P!==0?P:A.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var g=[],f=[],y=1,b=null,C=3,w=!1,x=!1,D=!1,B=!1,L=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,X=typeof setImmediate<"u"?setImmediate:null;function U(A){for(var R=n(f);R!==null;){if(R.callback===null)s(f);else if(R.startTime<=A)s(f),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(f)}}function G(A){if(D=!1,U(A),!x)if(n(g)!==null)x=!0,F||(F=!0,q());else{var R=n(f);R!==null&&re(G,R.startTime-A)}}var F=!1,W=-1,ve=5,Se=-1;function xe(){return B?!0:!(e.unstable_now()-Se<ve)}function ie(){if(B=!1,F){var A=e.unstable_now();Se=A;var R=!0;try{e:{x=!1,D&&(D=!1,O(W),W=-1),w=!0;var P=C;try{t:{for(U(A),b=n(g);b!==null&&!(b.expirationTime>A&&xe());){var ne=b.callback;if(typeof ne=="function"){b.callback=null,C=b.priorityLevel;var ge=ne(b.expirationTime<=A);if(A=e.unstable_now(),typeof ge=="function"){b.callback=ge,U(A),R=!0;break t}b===n(g)&&s(g),U(A)}else s(g);b=n(g)}if(b!==null)R=!0;else{var M=n(f);M!==null&&re(G,M.startTime-A),R=!1}}break e}finally{b=null,C=P,w=!1}R=void 0}}finally{R?q():F=!1}}}var q;if(typeof X=="function")q=function(){X(ie)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,K=J.port2;J.port1.onmessage=ie,q=function(){K.postMessage(null)}}else q=function(){L(ie,0)};function re(A,R){W=L(function(){A(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ve=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(A){switch(C){case 1:case 2:case 3:var R=3;break;default:R=C}var P=C;C=R;try{return A()}finally{C=P}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(A,R){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var P=C;C=A;try{return R()}finally{C=P}},e.unstable_scheduleCallback=function(A,R,P){var ne=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?ne+P:ne):P=ne,A){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=P+ge,A={id:y++,callback:R,priorityLevel:A,startTime:P,expirationTime:ge,sortIndex:-1},P>ne?(A.sortIndex=P,t(f,A),n(g)===null&&A===n(f)&&(D?(O(W),W=-1):D=!0,re(G,P-ne))):(A.sortIndex=ge,t(g,A),x||w||(x=!0,F||(F=!0,q()))),A},e.unstable_shouldYield=xe,e.unstable_wrapCallback=function(A){var R=C;return function(){var P=C;C=R;try{return A.apply(this,arguments)}finally{C=P}}}})(Jp)),Jp}var DS;function mE(){return DS||(DS=1,Qp.exports=pE()),Qp.exports}var em={exports:{}},rn={};var RS;function gE(){if(RS)return rn;RS=1;var e=_v();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,f,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:f,implementation:y}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,rn.createPortal=function(g,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,y)},rn.flushSync=function(g){var f=d.T,y=s.p;try{if(d.T=null,s.p=2,g)return g()}finally{d.T=f,s.p=y,s.d.f()}},rn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},rn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},rn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin),C=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;y==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:b,integrity:C,fetchPriority:w}):y==="script"&&s.d.X(g,{crossOrigin:b,integrity:C,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},rn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var y=m(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},rn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin);s.d.L(g,y,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},rn.preloadModule=function(g,f){if(typeof g=="string")if(f){var y=m(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},rn.requestFormReset=function(g){s.d.r(g)},rn.unstable_batchedUpdates=function(g,f){return g(f)},rn.useFormState=function(g,f,y){return d.H.useFormState(g,f,y)},rn.useFormStatus=function(){return d.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var MS;function Vw(){if(MS)return em.exports;MS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),em.exports=gE(),em.exports}var NS;function vE(){if(NS)return dc;NS=1;var e=mE(),t=_v(),n=Vw();function s(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function d(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function m(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var r=i.alternate;if(!r){if(r=c(i),r===null)throw Error(s(188));return r!==i?null:i}for(var a=i,l=r;;){var u=a.return;if(u===null)break;var h=u.alternate;if(h===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===a)return g(u),i;if(h===l)return g(u),r;h=h.sibling}throw Error(s(188))}if(a.return!==l.return)a=u,l=h;else{for(var _=!1,E=u.child;E;){if(E===a){_=!0,a=u,l=h;break}if(E===l){_=!0,l=u,a=h;break}E=E.sibling}if(!_){for(E=h.child;E;){if(E===a){_=!0,a=h,l=u;break}if(E===l){_=!0,l=h,a=u;break}E=E.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==l)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:r}function y(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=y(i),r!==null)return r;i=i.sibling}return null}var b=Object.assign,C=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),X=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),Se=Symbol.for("react.activity"),xe=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function q(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var J=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===J?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case L:return"Profiler";case B:return"StrictMode";case G:return"Suspense";case F:return"SuspenseList";case Se:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case X:return i.displayName||"Context";case O:return(i._context.displayName||"Context")+".Consumer";case U:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case W:return r=i.displayName||null,r!==null?r:K(i.type)||"Memo";case ve:r=i._payload,i=i._init;try{return K(i(r))}catch{}}return null}var re=Array.isArray,A=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},ne=[],ge=-1;function M(i){return{current:i}}function V(i){0>ge||(i.current=ne[ge],ne[ge]=null,ge--)}function le(i,r){ge++,ne[ge]=i.current,i.current=r}var _e=M(null),be=M(null),Ee=M(null),Me=M(null);function Re(i,r){switch(le(Ee,r),le(be,i),le(_e,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?$y(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=$y(r),i=Vy(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(_e),le(_e,i)}function Pe(){V(_e),V(be),V(Ee)}function Be(i){i.memoizedState!==null&&le(Me,i);var r=_e.current,a=Vy(r,i.type);r!==a&&(le(be,i),le(_e,a))}function oe(i){be.current===i&&(V(_e),V(be)),Me.current===i&&(V(Me),ac._currentValue=P)}var he,ye;function Oe(i){if(he===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);he=r&&r[1]||"",ye=-1<a.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-BBppqaO6.js","assets/index-bffyLU7T.js","assets/TranscriptMarkdownBody-9-cPRj-d.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();function uE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xp={exports:{}},uc={};var CS;function dE(){if(CS)return uc;CS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,l,c){var d=null;if(c!==void 0&&(d=""+c),l.key!==void 0&&(d=""+l.key),"key"in l){c={};for(var m in l)m!=="key"&&(c[m]=l[m])}else c=l;return l=c.ref,{$$typeof:e,type:s,key:d,ref:l!==void 0?l:null,props:c}}return uc.Fragment=t,uc.jsx=n,uc.jsxs=n,uc}var xS;function hE(){return xS||(xS=1,Xp.exports=dE()),Xp.exports}var p=hE(),Gp={exports:{}},tt={};var kS;function fE(){if(kS)return tt;kS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),C=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=C&&M[C]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,B={};function L(M,F,ie){this.props=M,this.context=F,this.refs=B,this.updater=ie||x}L.prototype.isReactComponent={},L.prototype.setState=function(M,F){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,F,"setState")},L.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function O(){}O.prototype=L.prototype;function X(M,F,ie){this.props=M,this.context=F,this.refs=B,this.updater=ie||x}var U=X.prototype=new O;U.constructor=X,D(U,L.prototype),U.isPureReactComponent=!0;var G=Array.isArray;function W(){}var q={H:null,A:null,T:null,S:null},ge=Object.prototype.hasOwnProperty;function Se(M,F,ie){var ve=ie.ref;return{$$typeof:e,type:M,key:F,ref:ve!==void 0?ve:null,props:ie}}function xe(M,F){return Se(M.type,F,M.props)}function re(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function $(M){var F={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ie){return F[ie]})}var J=/\/+/g;function K(M,F){return typeof M=="object"&&M!==null&&M.key!=null?$(""+M.key):F.toString(36)}function se(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(W,W):(M.status="pending",M.then(function(F){M.status==="pending"&&(M.status="fulfilled",M.value=F)},function(F){M.status==="pending"&&(M.status="rejected",M.reason=F)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function A(M,F,ie,ve,be){var Ee=typeof M;(Ee==="undefined"||Ee==="boolean")&&(M=null);var Me=!1;if(M===null)Me=!0;else switch(Ee){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(M.$$typeof){case e:case t:Me=!0;break;case y:return Me=M._init,A(Me(M._payload),F,ie,ve,be)}}if(Me)return be=be(M),Me=ve===""?"."+K(M,0):ve,G(be)?(ie="",Me!=null&&(ie=Me.replace(J,"$&/")+"/"),A(be,F,ie,"",function(Be){return Be})):be!=null&&(re(be)&&(be=xe(be,ie+(be.key==null||M&&M.key===be.key?"":(""+be.key).replace(J,"$&/")+"/")+Me)),F.push(be)),1;Me=0;var Re=ve===""?".":ve+":";if(G(M))for(var Pe=0;Pe<M.length;Pe++)ve=M[Pe],Ee=Re+K(ve,Pe),Me+=A(ve,F,ie,Ee,be);else if(Pe=w(M),typeof Pe=="function")for(M=Pe.call(M),Pe=0;!(ve=M.next()).done;)ve=ve.value,Ee=Re+K(ve,Pe++),Me+=A(ve,F,ie,Ee,be);else if(Ee==="object"){if(typeof M.then=="function")return A(se(M),F,ie,ve,be);throw F=String(M),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return Me}function R(M,F,ie){if(M==null)return M;var ve=[],be=0;return A(M,ve,"","",function(Ee){return F.call(ie,Ee,be++)}),ve}function z(M){if(M._status===-1){var F=M._result;F=F(),F.then(function(ie){(M._status===0||M._status===-1)&&(M._status=1,M._result=ie)},function(ie){(M._status===0||M._status===-1)&&(M._status=2,M._result=ie)}),M._status===-1&&(M._status=0,M._result=F)}if(M._status===1)return M._result.default;throw M._result}var ne=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var F=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},_e={map:R,forEach:function(M,F,ie){R(M,function(){F.apply(this,arguments)},ie)},count:function(M){var F=0;return R(M,function(){F++}),F},toArray:function(M){return R(M,function(F){return F})||[]},only:function(M){if(!re(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return tt.Activity=b,tt.Children=_e,tt.Component=L,tt.Fragment=n,tt.Profiler=l,tt.PureComponent=X,tt.StrictMode=s,tt.Suspense=g,tt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=q,tt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return q.H.useMemoCache(M)}},tt.cache=function(M){return function(){return M.apply(null,arguments)}},tt.cacheSignal=function(){return null},tt.cloneElement=function(M,F,ie){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ve=D({},M.props),be=M.key;if(F!=null)for(Ee in F.key!==void 0&&(be=""+F.key),F)!ge.call(F,Ee)||Ee==="key"||Ee==="__self"||Ee==="__source"||Ee==="ref"&&F.ref===void 0||(ve[Ee]=F[Ee]);var Ee=arguments.length-2;if(Ee===1)ve.children=ie;else if(1<Ee){for(var Me=Array(Ee),Re=0;Re<Ee;Re++)Me[Re]=arguments[Re+2];ve.children=Me}return Se(M.type,be,ve)},tt.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},tt.createElement=function(M,F,ie){var ve,be={},Ee=null;if(F!=null)for(ve in F.key!==void 0&&(Ee=""+F.key),F)ge.call(F,ve)&&ve!=="key"&&ve!=="__self"&&ve!=="__source"&&(be[ve]=F[ve]);var Me=arguments.length-2;if(Me===1)be.children=ie;else if(1<Me){for(var Re=Array(Me),Pe=0;Pe<Me;Pe++)Re[Pe]=arguments[Pe+2];be.children=Re}if(M&&M.defaultProps)for(ve in Me=M.defaultProps,Me)be[ve]===void 0&&(be[ve]=Me[ve]);return Se(M,Ee,be)},tt.createRef=function(){return{current:null}},tt.forwardRef=function(M){return{$$typeof:m,render:M}},tt.isValidElement=re,tt.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:z}},tt.memo=function(M,F){return{$$typeof:f,type:M,compare:F===void 0?null:F}},tt.startTransition=function(M){var F=q.T,ie={};q.T=ie;try{var ve=M(),be=q.S;be!==null&&be(ie,ve),typeof ve=="object"&&ve!==null&&typeof ve.then=="function"&&ve.then(W,ne)}catch(Ee){ne(Ee)}finally{F!==null&&ie.types!==null&&(F.types=ie.types),q.T=F}},tt.unstable_useCacheRefresh=function(){return q.H.useCacheRefresh()},tt.use=function(M){return q.H.use(M)},tt.useActionState=function(M,F,ie){return q.H.useActionState(M,F,ie)},tt.useCallback=function(M,F){return q.H.useCallback(M,F)},tt.useContext=function(M){return q.H.useContext(M)},tt.useDebugValue=function(){},tt.useDeferredValue=function(M,F){return q.H.useDeferredValue(M,F)},tt.useEffect=function(M,F){return q.H.useEffect(M,F)},tt.useEffectEvent=function(M){return q.H.useEffectEvent(M)},tt.useId=function(){return q.H.useId()},tt.useImperativeHandle=function(M,F,ie){return q.H.useImperativeHandle(M,F,ie)},tt.useInsertionEffect=function(M,F){return q.H.useInsertionEffect(M,F)},tt.useLayoutEffect=function(M,F){return q.H.useLayoutEffect(M,F)},tt.useMemo=function(M,F){return q.H.useMemo(M,F)},tt.useOptimistic=function(M,F){return q.H.useOptimistic(M,F)},tt.useReducer=function(M,F,ie){return q.H.useReducer(M,F,ie)},tt.useRef=function(M){return q.H.useRef(M)},tt.useState=function(M){return q.H.useState(M)},tt.useSyncExternalStore=function(M,F,ie){return q.H.useSyncExternalStore(M,F,ie)},tt.useTransition=function(){return q.H.useTransition()},tt.version="19.2.6",tt}var ES;function _v(){return ES||(ES=1,Gp.exports=fE()),Gp.exports}var v=_v();const Li=uE(v);var Zp={exports:{}},dc={},Qp={exports:{}},Jp={};var TS;function pE(){return TS||(TS=1,(function(e){function t(A,R){var z=A.length;A.push(R);e:for(;0<z;){var ne=z-1>>>1,_e=A[ne];if(0<l(_e,R))A[ne]=R,A[z]=_e,z=ne;else break e}}function n(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var R=A[0],z=A.pop();if(z!==R){A[0]=z;e:for(var ne=0,_e=A.length,M=_e>>>1;ne<M;){var F=2*(ne+1)-1,ie=A[F],ve=F+1,be=A[ve];if(0>l(ie,z))ve<_e&&0>l(be,ie)?(A[ne]=be,A[ve]=z,ne=ve):(A[ne]=ie,A[F]=z,ne=F);else if(ve<_e&&0>l(be,z))A[ne]=be,A[ve]=z,ne=ve;else break e}}return R}function l(A,R){var z=A.sortIndex-R.sortIndex;return z!==0?z:A.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var g=[],f=[],y=1,b=null,C=3,w=!1,x=!1,D=!1,B=!1,L=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,X=typeof setImmediate<"u"?setImmediate:null;function U(A){for(var R=n(f);R!==null;){if(R.callback===null)s(f);else if(R.startTime<=A)s(f),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(f)}}function G(A){if(D=!1,U(A),!x)if(n(g)!==null)x=!0,W||(W=!0,$());else{var R=n(f);R!==null&&se(G,R.startTime-A)}}var W=!1,q=-1,ge=5,Se=-1;function xe(){return B?!0:!(e.unstable_now()-Se<ge)}function re(){if(B=!1,W){var A=e.unstable_now();Se=A;var R=!0;try{e:{x=!1,D&&(D=!1,O(q),q=-1),w=!0;var z=C;try{t:{for(U(A),b=n(g);b!==null&&!(b.expirationTime>A&&xe());){var ne=b.callback;if(typeof ne=="function"){b.callback=null,C=b.priorityLevel;var _e=ne(b.expirationTime<=A);if(A=e.unstable_now(),typeof _e=="function"){b.callback=_e,U(A),R=!0;break t}b===n(g)&&s(g),U(A)}else s(g);b=n(g)}if(b!==null)R=!0;else{var M=n(f);M!==null&&se(G,M.startTime-A),R=!1}}break e}finally{b=null,C=z,w=!1}R=void 0}}finally{R?$():W=!1}}}var $;if(typeof X=="function")$=function(){X(re)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,K=J.port2;J.port1.onmessage=re,$=function(){K.postMessage(null)}}else $=function(){L(re,0)};function se(A,R){q=L(function(){A(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ge=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(A){switch(C){case 1:case 2:case 3:var R=3;break;default:R=C}var z=C;C=R;try{return A()}finally{C=z}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(A,R){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var z=C;C=A;try{return R()}finally{C=z}},e.unstable_scheduleCallback=function(A,R,z){var ne=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?ne+z:ne):z=ne,A){case 1:var _e=-1;break;case 2:_e=250;break;case 5:_e=1073741823;break;case 4:_e=1e4;break;default:_e=5e3}return _e=z+_e,A={id:y++,callback:R,priorityLevel:A,startTime:z,expirationTime:_e,sortIndex:-1},z>ne?(A.sortIndex=z,t(f,A),n(g)===null&&A===n(f)&&(D?(O(q),q=-1):D=!0,se(G,z-ne))):(A.sortIndex=_e,t(g,A),x||w||(x=!0,W||(W=!0,$()))),A},e.unstable_shouldYield=xe,e.unstable_wrapCallback=function(A){var R=C;return function(){var z=C;C=R;try{return A.apply(this,arguments)}finally{C=z}}}})(Jp)),Jp}var DS;function mE(){return DS||(DS=1,Qp.exports=pE()),Qp.exports}var em={exports:{}},rn={};var RS;function gE(){if(RS)return rn;RS=1;var e=_v();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(g,f,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:b==null?null:""+b,children:g,containerInfo:f,implementation:y}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,rn.createPortal=function(g,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,y)},rn.flushSync=function(g){var f=d.T,y=s.p;try{if(d.T=null,s.p=2,g)return g()}finally{d.T=f,s.p=y,s.d.f()}},rn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},rn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},rn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin),C=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;y==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:b,integrity:C,fetchPriority:w}):y==="script"&&s.d.X(g,{crossOrigin:b,integrity:C,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},rn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var y=m(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},rn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin);s.d.L(g,y,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},rn.preloadModule=function(g,f){if(typeof g=="string")if(f){var y=m(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},rn.requestFormReset=function(g){s.d.r(g)},rn.unstable_batchedUpdates=function(g,f){return g(f)},rn.useFormState=function(g,f,y){return d.H.useFormState(g,f,y)},rn.useFormStatus=function(){return d.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var MS;function Vw(){if(MS)return em.exports;MS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),em.exports=gE(),em.exports}var NS;function vE(){if(NS)return dc;NS=1;var e=mE(),t=_v(),n=Vw();function s(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function d(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function m(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var r=i.alternate;if(!r){if(r=c(i),r===null)throw Error(s(188));return r!==i?null:i}for(var a=i,o=r;;){var u=a.return;if(u===null)break;var h=u.alternate;if(h===null){if(o=u.return,o!==null){a=o;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===a)return g(u),i;if(h===o)return g(u),r;h=h.sibling}throw Error(s(188))}if(a.return!==o.return)a=u,o=h;else{for(var _=!1,E=u.child;E;){if(E===a){_=!0,a=u,o=h;break}if(E===o){_=!0,o=u,a=h;break}E=E.sibling}if(!_){for(E=h.child;E;){if(E===a){_=!0,a=h,o=u;break}if(E===o){_=!0,o=h,a=u;break}E=E.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==o)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:r}function y(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=y(i),r!==null)return r;i=i.sibling}return null}var b=Object.assign,C=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),X=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),ge=Symbol.for("react.lazy"),Se=Symbol.for("react.activity"),xe=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function $(i){return i===null||typeof i!="object"?null:(i=re&&i[re]||i["@@iterator"],typeof i=="function"?i:null)}var J=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===J?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case L:return"Profiler";case B:return"StrictMode";case G:return"Suspense";case W:return"SuspenseList";case Se:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case X:return i.displayName||"Context";case O:return(i._context.displayName||"Context")+".Consumer";case U:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case q:return r=i.displayName||null,r!==null?r:K(i.type)||"Memo";case ge:r=i._payload,i=i._init;try{return K(i(r))}catch{}}return null}var se=Array.isArray,A=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z={pending:!1,data:null,method:null,action:null},ne=[],_e=-1;function M(i){return{current:i}}function F(i){0>_e||(i.current=ne[_e],ne[_e]=null,_e--)}function ie(i,r){_e++,ne[_e]=i.current,i.current=r}var ve=M(null),be=M(null),Ee=M(null),Me=M(null);function Re(i,r){switch(ie(Ee,r),ie(be,i),ie(ve,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?$y(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=$y(r),i=Vy(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}F(ve),ie(ve,i)}function Pe(){F(ve),F(be),F(Ee)}function Be(i){i.memoizedState!==null&&ie(Me,i);var r=ve.current,a=Vy(r,i.type);r!==a&&(ie(be,i),ie(ve,a))}function oe(i){be.current===i&&(F(ve),F(be)),Me.current===i&&(F(Me),ac._currentValue=z)}var he,ye;function Oe(i){if(he===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);he=r&&r[1]||"",ye=-1<a.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+he+i+ye}var Ke=!1;function je(i,r){if(!i||Ke)return"";Ke=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var
|
|
4
|
+
`+he+i+ye}var Ke=!1;function je(i,r){if(!i||Ke)return"";Ke=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(te){var Q=te}Reflect.construct(i,[],fe)}else{try{fe.call()}catch(te){Q=te}i.call(fe.prototype)}}else{try{throw Error()}catch(te){Q=te}(fe=i())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(te){if(te&&Q&&typeof te.stack=="string")return[te.stack,Q.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=o.DetermineComponentFrameRoot(),_=h[0],E=h[1];if(_&&E){var N=_.split(`
|
|
5
5
|
`),Y=E.split(`
|
|
6
|
-
`);for(u=
|
|
7
|
-
`+N[
|
|
8
|
-
Error generating stack: `+
|
|
9
|
-
`+l.stack}}var we=Object.prototype.hasOwnProperty,ze=e.unstable_scheduleCallback,Ue=e.unstable_cancelCallback,nt=e.unstable_shouldYield,ht=e.unstable_requestPaint,Dt=e.unstable_now,Ei=e.unstable_getCurrentPriorityLevel,ni=e.unstable_ImmediatePriority,di=e.unstable_UserBlockingPriority,ae=e.unstable_NormalPriority,Ne=e.unstable_LowPriority,Qe=e.unstable_IdlePriority,it=e.log,jt=e.unstable_setDisableYieldValue,xt=null,gt=null;function Ht(i){if(typeof it=="function"&&jt(i),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(xt,i)}catch{}}var kt=Math.clz32?Math.clz32:Z,Rn=Math.log,Mn=Math.LN2;function Z(i){return i>>>=0,i===0?32:31-(Rn(i)/Mn|0)|0}var We=256,st=262144,et=4194304;function wt(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Et(i,r,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var E=l&134217727;return E!==0?(l=E&~h,l!==0?u=wt(l):(_&=E,_!==0?u=wt(_):a||(a=E&~i,a!==0&&(u=wt(a))))):(E=l&~h,E!==0?u=wt(E):_!==0?u=wt(_):a||(a=l&~i,a!==0&&(u=wt(a)))),u===0?0:r!==0&&r!==u&&(r&h)===0&&(h=u&-u,a=r&-r,h>=a||h===32&&(a&4194048)!==0)?r:u}function Ut(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function ri(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=et;return et<<=1,(et&62914560)===0&&(et=4194304),i}function Zt(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function Kt(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Qt(i,r,a,l,u,h){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var E=i.entanglements,N=i.expirationTimes,Y=i.hiddenUpdates;for(a=_&~a;0<a;){var ce=31-kt(a),fe=1<<ce;E[ce]=0,N[ce]=-1;var Q=Y[ce];if(Q!==null)for(Y[ce]=null,ce=0;ce<Q.length;ce++){var te=Q[ce];te!==null&&(te.lane&=-536870913)}a&=~fe}l!==0&&ji(i,l,0),h!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~r))}function ji(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var l=31-kt(r);i.entangledLanes|=r,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function hi(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var l=31-kt(a),u=1<<l;u&r|i[l]&r&&(i[l]|=r),a&=~u}}function zi(i,r){var a=r&-r;return a=(a&42)!==0?1:gn(a),(a&(i.suspendedLanes|r))!==0?0:a}function gn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Yi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Ti(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:gS(i.type))}function on(i,r){var a=R.p;try{return R.p=i,r()}finally{R.p=a}}var Di=Math.random().toString(36).slice(2),si="__reactFiber$"+Di,Pi="__reactProps$"+Di,$n="__reactContainer$"+Di,ya="__reactEvents$"+Di,Vn="__reactListeners$"+Di,bl="__reactHandles$"+Di,Ss="__reactResources$"+Di,It="__reactMarker$"+Di;function ln(i){delete i[si],delete i[Pi],delete i[ya],delete i[Vn],delete i[bl]}function vi(i){var r=i[si];if(r)return r;for(var a=i.parentNode;a;){if(r=a[$n]||a[si]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=eS(i);i!==null;){if(a=i[si])return a;i=eS(i)}return r}i=a,a=i.parentNode}return null}function Yn(i){if(i=i[si]||i[$n]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function wr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function vn(i){var r=i[Ss];return r||(r=i[Ss]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function $t(i){i[It]=!0}var ho=new Set,ws={};function Nn(i,r){_n(i,r),_n(i+"Capture",r)}function _n(i,r){for(ws[i]=r,i=0;i<r.length;i++)ho.add(r[i])}var Xi=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ur={},fo={};function Sa(i){return we.call(fo,i)?!0:we.call(Ur,i)?!1:Xi.test(i)?fo[i]=!0:(Ur[i]=!0,!1)}function Cr(i,r,a){if(Sa(r))if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+a)}}function dr(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function An(i,r,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(r,a,""+l)}}function fi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function wa(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function po(i,r,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,h=l.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,h.call(this,_)}}),Object.defineProperty(i,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Ln(i){if(!i._valueTracker){var r=wa(i)?"checked":"value";i._valueTracker=po(i,r,""+i[r])}}function Cs(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return i&&(l=wa(i)?i.checked?"true":"false":i.value),i=l,i!==a?(r.setValue(i),!0):!1}function xr(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var hr=/[\n"\\]/g;function Ii(i){return i.replace(hr,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function dt(i,r,a,l,u,h,_,E){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),r!=null?_==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+fi(r)):i.value!==""+fi(r)&&(i.value=""+fi(r)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),r!=null?xs(i,_,fi(r)):a!=null?xs(i,_,fi(a)):l!=null&&i.removeAttribute("value"),u==null&&h!=null&&(i.defaultChecked=!!h),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?i.name=""+fi(E):i.removeAttribute("name")}function fr(i,r,a,l,u,h,_,E){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),r!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||r!=null)){Ln(i);return}a=a!=null?""+fi(a):"",r=r!=null?""+fi(r):a,E||r===i.value||(i.value=r),i.defaultValue=r}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=E?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),Ln(i)}function xs(i,r,a){r==="number"&&xr(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function ai(i,r,a,l){if(i=i.options,r){r={};for(var u=0;u<a.length;u++)r["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=r.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+fi(a),r=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}r!==null||i[u].disabled||(r=i[u])}r!==null&&(r.selected=!0)}}function Ca(i,r,a){if(r!=null&&(r=""+fi(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+fi(a):""}function xa(i,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(s(92));if(re(l)){if(1<l.length)throw Error(s(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=fi(r),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),Ln(i)}function pr(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var ks=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Es(i,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":l?i.setProperty(r,a):typeof a!="number"||a===0||ks.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function kr(i,r,a){if(r!=null&&typeof r!="object")throw Error(s(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in r)l=r[u],r.hasOwnProperty(u)&&a[u]!==l&&Es(i,u,l)}else for(var h in r)r.hasOwnProperty(h)&&Es(i,h,r[h])}function bn(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var mo=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),yl=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Kr(i){return yl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function cn(){}var Er=null;function Fr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Hi=null,tn=null;function ka(i){var r=Yn(i);if(r&&(i=r.stateNode)){var a=i[Pi]||null;e:switch(i=r.stateNode,r.type){case"input":if(dt(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Ii(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==i&&l.form===i.form){var u=l[Pi]||null;if(!u)throw Error(s(90));dt(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===i.form&&Cs(l)}break e;case"textarea":Ca(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&ai(i,!!a.multiple,r,!1)}}}var Ts=!1;function Wr(i,r,a){if(Ts)return i(r,a);Ts=!0;try{var l=i(r);return l}finally{if(Ts=!1,(Hi!==null||tn!==null)&&(ud(),Hi&&(r=Hi,i=tn,tn=Hi=null,ka(r),i)))for(r=0;r<i.length;r++)ka(i[r])}}function qr(i,r){var a=i.stateNode;if(a===null)return null;var l=a[Pi]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,r,typeof a));return a}var Bn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ea=!1;if(Bn)try{var Tr={};Object.defineProperty(Tr,"passive",{get:function(){Ea=!0}}),window.addEventListener("test",Tr,Tr),window.removeEventListener("test",Tr,Tr)}catch{Ea=!1}var yn=null,Ta=null,Ds=null;function Rs(){if(Ds)return Ds;var i,r=Ta,a=r.length,l,u="value"in yn?yn.value:yn.textContent,h=u.length;for(i=0;i<a&&r[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&r[a-l]===u[h-l];l++);return Ds=u.slice(i,1<l?1-l:void 0)}function Dr(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Ms(){return!0}function On(){return!1}function Jt(i){function r(a,l,u,h,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var E in i)i.hasOwnProperty(E)&&(a=i[E],this[E]=a?a(h):h[E]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ms:On,this.isPropagationStopped=On,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ms)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ms)},persist:function(){},isPersistent:Ms}),r}var nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},S=Jt(nn),T=b({},nn,{view:0,detail:0}),j=Jt(T),ee,pe,ue,Ce=b({},T,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Da,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ue&&(ue&&i.type==="mousemove"?(ee=i.screenX-ue.screenX,pe=i.screenY-ue.screenY):pe=ee=0,ue=i),ee)},movementY:function(i){return"movementY"in i?i.movementY:pe}}),qe=Jt(Ce),Ye=b({},Ce,{dataTransfer:0}),_i=Jt(Ye),Vt=b({},T,{relatedTarget:0}),$r=Jt(Vt),du=b({},nn,{animationName:0,elapsedTime:0,pseudoElement:0}),Zh=Jt(du),hu=b({},nn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Vr=Jt(hu),Sl=b({},nn,{data:0}),fu=Jt(Sl),pu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qh={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},mu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wl(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=mu[i])?!!r[i]:!1}function Da(){return wl}var go=b({},T,{key:function(i){if(i.key){var r=pu[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Dr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Qh[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Da,charCode:function(i){return i.type==="keypress"?Dr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Dr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Jh=Jt(go),gu=b({},Ce,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vu=Jt(gu),_u=b({},T,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Da}),ef=Jt(_u),tf=b({},nn,{propertyName:0,elapsedTime:0,pseudoElement:0}),nf=Jt(tf),bu=b({},Ce,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Cl=Jt(bu),vo=b({},nn,{newState:0,oldState:0}),yu=Jt(vo),Su=[9,13,27,32],xl=Bn&&"CompositionEvent"in window,Ns=null;Bn&&"documentMode"in document&&(Ns=document.documentMode);var wu=Bn&&"TextEvent"in window&&!Ns,kl=Bn&&(!xl||Ns&&8<Ns&&11>=Ns),Cu=" ",El=!1;function Rr(i,r){switch(i){case"keyup":return Su.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xu(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var As=!1;function ku(i,r){switch(i){case"compositionend":return xu(r);case"keypress":return r.which!==32?null:(El=!0,Cu);case"textInput":return i=r.data,i===Cu&&El?null:i;default:return null}}function rf(i,r){if(As)return i==="compositionend"||!xl&&Rr(i,r)?(i=Rs(),Ds=Ta=yn=null,As=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return kl&&r.locale!=="ko"?null:r.data;default:return null}}var sf={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mr(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!sf[i.type]:r==="textarea"}function Eu(i,r,a,l){Hi?tn?tn.push(l):tn=[l]:Hi=l,r=vd(r,"onChange"),0<r.length&&(a=new S("onChange","change",null,a,l),i.push({event:a,listeners:r}))}var Ra=null,Ma=null;function Tu(i){Hy(i,0)}function jn(i){var r=wr(i);if(Cs(r))return i}function Du(i,r){if(i==="change")return r}var Ru=!1;if(Bn){var Na;if(Bn){var Tl="oninput"in document;if(!Tl){var Dl=document.createElement("div");Dl.setAttribute("oninput","return;"),Tl=typeof Dl.oninput=="function"}Na=Tl}else Na=!1;Ru=Na&&(!document.documentMode||9<document.documentMode)}function k(){Ra&&(Ra.detachEvent("onpropertychange",I),Ma=Ra=null)}function I(i){if(i.propertyName==="value"&&jn(Ma)){var r=[];Eu(r,Ma,i,Fr(i)),Wr(Tu,r)}}function Ae(i,r,a){i==="focusin"?(k(),Ra=r,Ma=a,Ra.attachEvent("onpropertychange",I)):i==="focusout"&&k()}function Fe(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return jn(Ma)}function Ve(i,r){if(i==="click")return jn(r)}function Je(i,r){if(i==="input"||i==="change")return jn(r)}function ft(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var lt=typeof Object.is=="function"?Object.is:ft;function Tt(i,r){if(lt(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!we.call(r,u)||!lt(i[u],r[u]))return!1}return!0}function ei(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Sn(i,r){var a=ei(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=r&&l>=r)return{node:a,offset:r-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=ei(a)}}function un(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?un(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Rl(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=xr(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=xr(i.document)}return r}function Ml(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Mr=Bn&&"documentMode"in document&&11>=document.documentMode,Yr=null,_o=null,Nl=null,af=!1;function p_(i,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;af||Yr==null||Yr!==xr(l)||(l=Yr,"selectionStart"in l&&Ml(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Nl&&Tt(Nl,l)||(Nl=l,l=vd(_o,"onSelect"),0<l.length&&(r=new S("onSelect","select",null,r,a),i.push({event:r,listeners:l}),r.target=Yr)))}function Aa(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var bo={animationend:Aa("Animation","AnimationEnd"),animationiteration:Aa("Animation","AnimationIteration"),animationstart:Aa("Animation","AnimationStart"),transitionrun:Aa("Transition","TransitionRun"),transitionstart:Aa("Transition","TransitionStart"),transitioncancel:Aa("Transition","TransitionCancel"),transitionend:Aa("Transition","TransitionEnd")},of={},m_={};Bn&&(m_=document.createElement("div").style,"AnimationEvent"in window||(delete bo.animationend.animation,delete bo.animationiteration.animation,delete bo.animationstart.animation),"TransitionEvent"in window||delete bo.transitionend.transition);function La(i){if(of[i])return of[i];if(!bo[i])return i;var r=bo[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in m_)return of[i]=r[a];return i}var g_=La("animationend"),v_=La("animationiteration"),__=La("animationstart"),Wx=La("transitionrun"),qx=La("transitionstart"),$x=La("transitioncancel"),b_=La("transitionend"),y_=new Map,lf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");lf.push("scrollEnd");function gr(i,r){y_.set(i,r),Nn(r,[i])}var Mu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Xn=[],yo=0,cf=0;function Nu(){for(var i=yo,r=cf=yo=0;r<i;){var a=Xn[r];Xn[r++]=null;var l=Xn[r];Xn[r++]=null;var u=Xn[r];Xn[r++]=null;var h=Xn[r];if(Xn[r++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}h!==0&&S_(a,u,h)}}function Au(i,r,a,l){Xn[yo++]=i,Xn[yo++]=r,Xn[yo++]=a,Xn[yo++]=l,cf|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function uf(i,r,a,l){return Au(i,r,a,l),Lu(i)}function Ba(i,r){return Au(i,null,null,r),Lu(i)}function S_(i,r,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,h=i.return;h!==null;)h.childLanes|=a,l=h.alternate,l!==null&&(l.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(u=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,u&&r!==null&&(u=31-kt(a),i=h.hiddenUpdates,l=i[u],l===null?i[u]=[r]:l.push(r),r.lane=a|536870912),h):null}function Lu(i){if(50<Jl)throw Jl=0,bp=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var So={};function Vx(i,r,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(i,r,a,l){return new Vx(i,r,a,l)}function df(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Xr(i,r){var a=i.alternate;return a===null?(a=zn(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function w_(i,r){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,r=a.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function Bu(i,r,a,l,u,h){var _=0;if(l=i,typeof i=="function")df(i)&&(_=1);else if(typeof i=="string")_=Qk(i,a,_e.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case Se:return i=zn(31,a,r,u),i.elementType=Se,i.lanes=h,i;case D:return Oa(a.children,u,h,r);case B:_=8,u|=24;break;case L:return i=zn(12,a,r,u|2),i.elementType=L,i.lanes=h,i;case G:return i=zn(13,a,r,u),i.elementType=G,i.lanes=h,i;case F:return i=zn(19,a,r,u),i.elementType=F,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case X:_=10;break e;case O:_=9;break e;case U:_=11;break e;case W:_=14;break e;case ve:_=16,l=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),l=null}return r=zn(_,a,r,u),r.elementType=i,r.type=l,r.lanes=h,r}function Oa(i,r,a,l){return i=zn(7,i,l,r),i.lanes=a,i}function hf(i,r,a){return i=zn(6,i,null,r),i.lanes=a,i}function C_(i){var r=zn(18,null,null,0);return r.stateNode=i,r}function ff(i,r,a){return r=zn(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var x_=new WeakMap;function Gn(i,r){if(typeof i=="object"&&i!==null){var a=x_.get(i);return a!==void 0?a:(r={value:i,source:r,stack:Te(r)},x_.set(i,r),r)}return{value:i,source:r,stack:Te(r)}}var wo=[],Co=0,Ou=null,Al=0,Zn=[],Qn=0,Ls=null,Nr=1,Ar="";function Gr(i,r){wo[Co++]=Al,wo[Co++]=Ou,Ou=i,Al=r}function k_(i,r,a){Zn[Qn++]=Nr,Zn[Qn++]=Ar,Zn[Qn++]=Ls,Ls=i;var l=Nr;i=Ar;var u=32-kt(l)-1;l&=~(1<<u),a+=1;var h=32-kt(r)+u;if(30<h){var _=u-u%5;h=(l&(1<<_)-1).toString(32),l>>=_,u-=_,Nr=1<<32-kt(r)+u|a<<u|l,Ar=h+i}else Nr=1<<h|a<<u|l,Ar=i}function pf(i){i.return!==null&&(Gr(i,1),k_(i,1,0))}function mf(i){for(;i===Ou;)Ou=wo[--Co],wo[Co]=null,Al=wo[--Co],wo[Co]=null;for(;i===Ls;)Ls=Zn[--Qn],Zn[Qn]=null,Ar=Zn[--Qn],Zn[Qn]=null,Nr=Zn[--Qn],Zn[Qn]=null}function E_(i,r){Zn[Qn++]=Nr,Zn[Qn++]=Ar,Zn[Qn++]=Ls,Nr=r.id,Ar=r.overflow,Ls=i}var Gi=null,Ft=null,bt=!1,Bs=null,Jn=!1,gf=Error(s(519));function Os(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ll(Gn(r,i)),gf}function T_(i){var r=i.stateNode,a=i.type,l=i.memoizedProps;switch(r[si]=i,r[Pi]=l,a){case"dialog":mt("cancel",r),mt("close",r);break;case"iframe":case"object":case"embed":mt("load",r);break;case"video":case"audio":for(a=0;a<tc.length;a++)mt(tc[a],r);break;case"source":mt("error",r);break;case"img":case"image":case"link":mt("error",r),mt("load",r);break;case"details":mt("toggle",r);break;case"input":mt("invalid",r),fr(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":mt("invalid",r);break;case"textarea":mt("invalid",r),xa(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Wy(r.textContent,a)?(l.popover!=null&&(mt("beforetoggle",r),mt("toggle",r)),l.onScroll!=null&&mt("scroll",r),l.onScrollEnd!=null&&mt("scrollend",r),l.onClick!=null&&(r.onclick=cn),r=!0):r=!1,r||Os(i,!0)}function D_(i){for(Gi=i.return;Gi;)switch(Gi.tag){case 5:case 31:case 13:Jn=!1;return;case 27:case 3:Jn=!0;return;default:Gi=Gi.return}}function xo(i){if(i!==Gi)return!1;if(!bt)return D_(i),bt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Bp(i.type,i.memoizedProps)),a=!a),a&&Ft&&Os(i),D_(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ft=Jy(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ft=Jy(i)}else r===27?(r=Ft,Xs(i.type)?(i=Ip,Ip=null,Ft=i):Ft=r):Ft=Gi?tr(i.stateNode.nextSibling):null;return!0}function ja(){Ft=Gi=null,bt=!1}function vf(){var i=Bs;return i!==null&&(kn===null?kn=i:kn.push.apply(kn,i),Bs=null),i}function Ll(i){Bs===null?Bs=[i]:Bs.push(i)}var _f=M(null),za=null,Zr=null;function js(i,r,a){le(_f,r._currentValue),r._currentValue=a}function Qr(i){i._currentValue=_f.current,V(_f)}function bf(i,r,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),i===a)break;i=i.return}}function yf(i,r,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var h=u.dependencies;if(h!==null){var _=u.child;h=h.firstContext;e:for(;h!==null;){var E=h;h=u;for(var N=0;N<r.length;N++)if(E.context===r[N]){h.lanes|=a,E=h.alternate,E!==null&&(E.lanes|=a),bf(h.return,a,i),l||(_=null);break e}h=E.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),bf(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function ko(i,r,a,l){i=null;for(var u=r,h=!1;u!==null;){if(!h){if((u.flags&524288)!==0)h=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var E=u.type;lt(u.pendingProps.value,_.value)||(i!==null?i.push(E):i=[E])}}else if(u===Me.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(ac):i=[ac])}u=u.return}i!==null&&yf(r,i,a,l),r.flags|=262144}function ju(i){for(i=i.firstContext;i!==null;){if(!lt(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Pa(i){za=i,Zr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Zi(i){return R_(za,i)}function zu(i,r){return za===null&&Pa(i),R_(i,r)}function R_(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Zr===null){if(i===null)throw Error(s(308));Zr=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Zr=Zr.next=r;return a}var Yx=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){r.aborted=!0,i.forEach(function(a){return a()})}},Xx=e.unstable_scheduleCallback,Gx=e.unstable_NormalPriority,bi={$$typeof:X,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Sf(){return{controller:new Yx,data:new Map,refCount:0}}function Bl(i){i.refCount--,i.refCount===0&&Xx(Gx,function(){i.controller.abort()})}var Ol=null,wf=0,Eo=0,To=null;function Zx(i,r){if(Ol===null){var a=Ol=[];wf=0,Eo=kp(),To={status:"pending",value:void 0,then:function(l){a.push(l)}}}return wf++,r.then(M_,M_),r}function M_(){if(--wf===0&&Ol!==null){To!==null&&(To.status="fulfilled");var i=Ol;Ol=null,Eo=0,To=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function Qx(i,r){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=r;for(var u=0;u<a.length;u++)(0,a[u])(r)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var N_=A.S;A.S=function(i,r){py=Dt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Zx(i,r),N_!==null&&N_(i,r)};var Ia=M(null);function Cf(){var i=Ia.current;return i!==null?i:zt.pooledCache}function Pu(i,r){r===null?le(Ia,Ia.current):le(Ia,r.pool)}function A_(){var i=Cf();return i===null?null:{parent:bi._currentValue,pool:i}}var Do=Error(s(460)),xf=Error(s(474)),Iu=Error(s(542)),Hu={then:function(){}};function L_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function B_(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(cn,cn),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,j_(i),i;default:if(typeof r.status=="string")r.then(cn,cn);else{if(i=zt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=r,i.status="pending",i.then(function(l){if(r.status==="pending"){var u=r;u.status="fulfilled",u.value=l}},function(l){if(r.status==="pending"){var u=r;u.status="rejected",u.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,j_(i),i}throw Ua=r,Do}}function Ha(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Ua=a,Do):a}}var Ua=null;function O_(){if(Ua===null)throw Error(s(459));var i=Ua;return Ua=null,i}function j_(i){if(i===Do||i===Iu)throw Error(s(483))}var Ro=null,jl=0;function Uu(i){var r=jl;return jl+=1,Ro===null&&(Ro=[]),B_(Ro,i,r)}function zl(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Ku(i,r){throw r.$$typeof===C?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function z_(i){function r(H,z){if(i){var $=H.deletions;$===null?(H.deletions=[z],H.flags|=16):$.push(z)}}function a(H,z){if(!i)return null;for(;z!==null;)r(H,z),z=z.sibling;return null}function l(H){for(var z=new Map;H!==null;)H.key!==null?z.set(H.key,H):z.set(H.index,H),H=H.sibling;return z}function u(H,z){return H=Xr(H,z),H.index=0,H.sibling=null,H}function h(H,z,$){return H.index=$,i?($=H.alternate,$!==null?($=$.index,$<z?(H.flags|=67108866,z):$):(H.flags|=67108866,z)):(H.flags|=1048576,z)}function _(H){return i&&H.alternate===null&&(H.flags|=67108866),H}function E(H,z,$,de){return z===null||z.tag!==6?(z=hf($,H.mode,de),z.return=H,z):(z=u(z,$),z.return=H,z)}function N(H,z,$,de){var $e=$.type;return $e===D?ce(H,z,$.props.children,de,$.key):z!==null&&(z.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ve&&Ha($e)===z.type)?(z=u(z,$.props),zl(z,$),z.return=H,z):(z=Bu($.type,$.key,$.props,null,H.mode,de),zl(z,$),z.return=H,z)}function Y(H,z,$,de){return z===null||z.tag!==4||z.stateNode.containerInfo!==$.containerInfo||z.stateNode.implementation!==$.implementation?(z=ff($,H.mode,de),z.return=H,z):(z=u(z,$.children||[]),z.return=H,z)}function ce(H,z,$,de,$e){return z===null||z.tag!==7?(z=Oa($,H.mode,de,$e),z.return=H,z):(z=u(z,$),z.return=H,z)}function fe(H,z,$){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=hf(""+z,H.mode,$),z.return=H,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case w:return $=Bu(z.type,z.key,z.props,null,H.mode,$),zl($,z),$.return=H,$;case x:return z=ff(z,H.mode,$),z.return=H,z;case ve:return z=Ha(z),fe(H,z,$)}if(re(z)||q(z))return z=Oa(z,H.mode,$,null),z.return=H,z;if(typeof z.then=="function")return fe(H,Uu(z),$);if(z.$$typeof===X)return fe(H,zu(H,z),$);Ku(H,z)}return null}function Q(H,z,$,de){var $e=z!==null?z.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $e!==null?null:E(H,z,""+$,de);if(typeof $=="object"&&$!==null){switch($.$$typeof){case w:return $.key===$e?N(H,z,$,de):null;case x:return $.key===$e?Y(H,z,$,de):null;case ve:return $=Ha($),Q(H,z,$,de)}if(re($)||q($))return $e!==null?null:ce(H,z,$,de,null);if(typeof $.then=="function")return Q(H,z,Uu($),de);if($.$$typeof===X)return Q(H,z,zu(H,$),de);Ku(H,$)}return null}function te(H,z,$,de,$e){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return H=H.get($)||null,E(z,H,""+de,$e);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case w:return H=H.get(de.key===null?$:de.key)||null,N(z,H,de,$e);case x:return H=H.get(de.key===null?$:de.key)||null,Y(z,H,de,$e);case ve:return de=Ha(de),te(H,z,$,de,$e)}if(re(de)||q(de))return H=H.get($)||null,ce(z,H,de,$e,null);if(typeof de.then=="function")return te(H,z,$,Uu(de),$e);if(de.$$typeof===X)return te(H,z,$,zu(z,de),$e);Ku(z,de)}return null}function Ie(H,z,$,de){for(var $e=null,yt=null,He=z,at=z=0,_t=null;He!==null&&at<$.length;at++){He.index>at?(_t=He,He=null):_t=He.sibling;var St=Q(H,He,$[at],de);if(St===null){He===null&&(He=_t);break}i&&He&&St.alternate===null&&r(H,He),z=h(St,z,at),yt===null?$e=St:yt.sibling=St,yt=St,He=_t}if(at===$.length)return a(H,He),bt&&Gr(H,at),$e;if(He===null){for(;at<$.length;at++)He=fe(H,$[at],de),He!==null&&(z=h(He,z,at),yt===null?$e=He:yt.sibling=He,yt=He);return bt&&Gr(H,at),$e}for(He=l(He);at<$.length;at++)_t=te(He,H,at,$[at],de),_t!==null&&(i&&_t.alternate!==null&&He.delete(_t.key===null?at:_t.key),z=h(_t,z,at),yt===null?$e=_t:yt.sibling=_t,yt=_t);return i&&He.forEach(function(ea){return r(H,ea)}),bt&&Gr(H,at),$e}function Xe(H,z,$,de){if($==null)throw Error(s(151));for(var $e=null,yt=null,He=z,at=z=0,_t=null,St=$.next();He!==null&&!St.done;at++,St=$.next()){He.index>at?(_t=He,He=null):_t=He.sibling;var ea=Q(H,He,St.value,de);if(ea===null){He===null&&(He=_t);break}i&&He&&ea.alternate===null&&r(H,He),z=h(ea,z,at),yt===null?$e=ea:yt.sibling=ea,yt=ea,He=_t}if(St.done)return a(H,He),bt&&Gr(H,at),$e;if(He===null){for(;!St.done;at++,St=$.next())St=fe(H,St.value,de),St!==null&&(z=h(St,z,at),yt===null?$e=St:yt.sibling=St,yt=St);return bt&&Gr(H,at),$e}for(He=l(He);!St.done;at++,St=$.next())St=te(He,H,at,St.value,de),St!==null&&(i&&St.alternate!==null&&He.delete(St.key===null?at:St.key),z=h(St,z,at),yt===null?$e=St:yt.sibling=St,yt=St);return i&&He.forEach(function(cE){return r(H,cE)}),bt&&Gr(H,at),$e}function Lt(H,z,$,de){if(typeof $=="object"&&$!==null&&$.type===D&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case w:e:{for(var $e=$.key;z!==null;){if(z.key===$e){if($e=$.type,$e===D){if(z.tag===7){a(H,z.sibling),de=u(z,$.props.children),de.return=H,H=de;break e}}else if(z.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ve&&Ha($e)===z.type){a(H,z.sibling),de=u(z,$.props),zl(de,$),de.return=H,H=de;break e}a(H,z);break}else r(H,z);z=z.sibling}$.type===D?(de=Oa($.props.children,H.mode,de,$.key),de.return=H,H=de):(de=Bu($.type,$.key,$.props,null,H.mode,de),zl(de,$),de.return=H,H=de)}return _(H);case x:e:{for($e=$.key;z!==null;){if(z.key===$e)if(z.tag===4&&z.stateNode.containerInfo===$.containerInfo&&z.stateNode.implementation===$.implementation){a(H,z.sibling),de=u(z,$.children||[]),de.return=H,H=de;break e}else{a(H,z);break}else r(H,z);z=z.sibling}de=ff($,H.mode,de),de.return=H,H=de}return _(H);case ve:return $=Ha($),Lt(H,z,$,de)}if(re($))return Ie(H,z,$,de);if(q($)){if($e=q($),typeof $e!="function")throw Error(s(150));return $=$e.call($),Xe(H,z,$,de)}if(typeof $.then=="function")return Lt(H,z,Uu($),de);if($.$$typeof===X)return Lt(H,z,zu(H,$),de);Ku(H,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,z!==null&&z.tag===6?(a(H,z.sibling),de=u(z,$),de.return=H,H=de):(a(H,z),de=hf($,H.mode,de),de.return=H,H=de),_(H)):a(H,z)}return function(H,z,$,de){try{jl=0;var $e=Lt(H,z,$,de);return Ro=null,$e}catch(He){if(He===Do||He===Iu)throw He;var yt=zn(29,He,null,H.mode);return yt.lanes=de,yt.return=H,yt}}}var Ka=z_(!0),P_=z_(!1),zs=!1;function kf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ef(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Ps(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Is(i,r,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Ct&2)!==0){var u=l.pending;return u===null?r.next=r:(r.next=u.next,u.next=r),l.pending=r,r=Lu(i),S_(i,null,a),r}return Au(i,l,r,a),Lu(i)}function Pl(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=i.pendingLanes,a|=l,r.lanes=a,hi(i,a)}}function Tf(i,r){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?u=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?u=h=r:h=h.next=r}else u=h=r;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}var Df=!1;function Il(){if(Df){var i=To;if(i!==null)throw i}}function Hl(i,r,a,l){Df=!1;var u=i.updateQueue;zs=!1;var h=u.firstBaseUpdate,_=u.lastBaseUpdate,E=u.shared.pending;if(E!==null){u.shared.pending=null;var N=E,Y=N.next;N.next=null,_===null?h=Y:_.next=Y,_=N;var ce=i.alternate;ce!==null&&(ce=ce.updateQueue,E=ce.lastBaseUpdate,E!==_&&(E===null?ce.firstBaseUpdate=Y:E.next=Y,ce.lastBaseUpdate=N))}if(h!==null){var fe=u.baseState;_=0,ce=Y=N=null,E=h;do{var Q=E.lane&-536870913,te=Q!==E.lane;if(te?(vt&Q)===Q:(l&Q)===Q){Q!==0&&Q===Eo&&(Df=!0),ce!==null&&(ce=ce.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ie=i,Xe=E;Q=r;var Lt=a;switch(Xe.tag){case 1:if(Ie=Xe.payload,typeof Ie=="function"){fe=Ie.call(Lt,fe,Q);break e}fe=Ie;break e;case 3:Ie.flags=Ie.flags&-65537|128;case 0:if(Ie=Xe.payload,Q=typeof Ie=="function"?Ie.call(Lt,fe,Q):Ie,Q==null)break e;fe=b({},fe,Q);break e;case 2:zs=!0}}Q=E.callback,Q!==null&&(i.flags|=64,te&&(i.flags|=8192),te=u.callbacks,te===null?u.callbacks=[Q]:te.push(Q))}else te={lane:Q,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ce===null?(Y=ce=te,N=fe):ce=ce.next=te,_|=Q;if(E=E.next,E===null){if(E=u.shared.pending,E===null)break;te=E,E=te.next,te.next=null,u.lastBaseUpdate=te,u.shared.pending=null}}while(!0);ce===null&&(N=fe),u.baseState=N,u.firstBaseUpdate=Y,u.lastBaseUpdate=ce,h===null&&(u.shared.lanes=0),Ws|=_,i.lanes=_,i.memoizedState=fe}}function I_(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function H_(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)I_(a[i],r)}var Mo=M(null),Fu=M(0);function U_(i,r){i=os,le(Fu,i),le(Mo,r),os=i|r.baseLanes}function Rf(){le(Fu,os),le(Mo,Mo.current)}function Mf(){os=Fu.current,V(Mo),V(Fu)}var Pn=M(null),er=null;function Hs(i){var r=i.alternate;le(pi,pi.current&1),le(Pn,i),er===null&&(r===null||Mo.current!==null||r.memoizedState!==null)&&(er=i)}function Nf(i){le(pi,pi.current),le(Pn,i),er===null&&(er=i)}function K_(i){i.tag===22?(le(pi,pi.current),le(Pn,i),er===null&&(er=i)):Us()}function Us(){le(pi,pi.current),le(Pn,Pn.current)}function In(i){V(Pn),er===i&&(er=null),V(pi)}var pi=M(0);function Wu(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||zp(a)||Pp(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Jr=0,rt=null,Nt=null,yi=null,qu=!1,No=!1,Fa=!1,$u=0,Ul=0,Ao=null,Jx=0;function oi(){throw Error(s(321))}function Af(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!lt(i[a],r[a]))return!1;return!0}function Lf(i,r,a,l,u,h){return Jr=h,rt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,A.H=i===null||i.memoizedState===null?kb:Yf,Fa=!1,h=a(l,u),Fa=!1,No&&(h=W_(r,a,l,u)),F_(i),h}function F_(i){A.H=Wl;var r=Nt!==null&&Nt.next!==null;if(Jr=0,yi=Nt=rt=null,qu=!1,Ul=0,Ao=null,r)throw Error(s(300));i===null||Si||(i=i.dependencies,i!==null&&ju(i)&&(Si=!0))}function W_(i,r,a,l){rt=i;var u=0;do{if(No&&(Ao=null),Ul=0,No=!1,25<=u)throw Error(s(301));if(u+=1,yi=Nt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}A.H=Eb,h=r(a,l)}while(No);return h}function ek(){var i=A.H,r=i.useState()[0];return r=typeof r.then=="function"?Kl(r):r,i=i.useState()[0],(Nt!==null?Nt.memoizedState:null)!==i&&(rt.flags|=1024),r}function Bf(){var i=$u!==0;return $u=0,i}function Of(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function jf(i){if(qu){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}qu=!1}Jr=0,yi=Nt=rt=null,No=!1,Ul=$u=0,Ao=null}function dn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yi===null?rt.memoizedState=yi=i:yi=yi.next=i,yi}function mi(){if(Nt===null){var i=rt.alternate;i=i!==null?i.memoizedState:null}else i=Nt.next;var r=yi===null?rt.memoizedState:yi.next;if(r!==null)yi=r,Nt=i;else{if(i===null)throw rt.alternate===null?Error(s(467)):Error(s(310));Nt=i,i={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},yi===null?rt.memoizedState=yi=i:yi=yi.next=i}return yi}function Vu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Kl(i){var r=Ul;return Ul+=1,Ao===null&&(Ao=[]),i=B_(Ao,i,r),r=rt,(yi===null?r.memoizedState:yi.next)===null&&(r=r.alternate,A.H=r===null||r.memoizedState===null?kb:Yf),i}function Yu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Kl(i);if(i.$$typeof===X)return Zi(i)}throw Error(s(438,String(i)))}function zf(i){var r=null,a=rt.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=rt.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(u){return u.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=Vu(),rt.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(i),l=0;l<i;l++)a[l]=xe;return r.index++,a}function es(i,r){return typeof r=="function"?r(i):r}function Xu(i){var r=mi();return Pf(r,Nt,i)}function Pf(i,r,a){var l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=a;var u=i.baseQueue,h=l.pending;if(h!==null){if(u!==null){var _=u.next;u.next=h.next,h.next=_}r.baseQueue=u=h,l.pending=null}if(h=i.baseState,u===null)i.memoizedState=h;else{r=u.next;var E=_=null,N=null,Y=r,ce=!1;do{var fe=Y.lane&-536870913;if(fe!==Y.lane?(vt&fe)===fe:(Jr&fe)===fe){var Q=Y.revertLane;if(Q===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),fe===Eo&&(ce=!0);else if((Jr&Q)===Q){Y=Y.next,Q===Eo&&(ce=!0);continue}else fe={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},N===null?(E=N=fe,_=h):N=N.next=fe,rt.lanes|=Q,Ws|=Q;fe=Y.action,Fa&&a(h,fe),h=Y.hasEagerState?Y.eagerState:a(h,fe)}else Q={lane:fe,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},N===null?(E=N=Q,_=h):N=N.next=Q,rt.lanes|=fe,Ws|=fe;Y=Y.next}while(Y!==null&&Y!==r);if(N===null?_=h:N.next=E,!lt(h,i.memoizedState)&&(Si=!0,ce&&(a=To,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=N,l.lastRenderedState=h}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function If(i){var r=mi(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,h=r.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do h=i(h,_.action),_=_.next;while(_!==u);lt(h,r.memoizedState)||(Si=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),a.lastRenderedState=h}return[h,l]}function q_(i,r,a){var l=rt,u=mi(),h=bt;if(h){if(a===void 0)throw Error(s(407));a=a()}else a=r();var _=!lt((Nt||u).memoizedState,a);if(_&&(u.memoizedState=a,Si=!0),u=u.queue,Kf(Y_.bind(null,l,u,i),[i]),u.getSnapshot!==r||_||yi!==null&&yi.memoizedState.tag&1){if(l.flags|=2048,Lo(9,{destroy:void 0},V_.bind(null,l,u,a,r),null),zt===null)throw Error(s(349));h||(Jr&127)!==0||$_(l,r,a)}return a}function $_(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=rt.updateQueue,r===null?(r=Vu(),rt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function V_(i,r,a,l){r.value=a,r.getSnapshot=l,X_(r)&&G_(i)}function Y_(i,r,a){return a(function(){X_(r)&&G_(i)})}function X_(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!lt(i,a)}catch{return!0}}function G_(i){var r=Ba(i,2);r!==null&&En(r,i,2)}function Hf(i){var r=dn();if(typeof i=="function"){var a=i;if(i=a(),Fa){Ht(!0);try{a()}finally{Ht(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:i},r}function Z_(i,r,a,l){return i.baseState=a,Pf(i,Nt,typeof l=="function"?l:es)}function tk(i,r,a,l,u){if(Qu(i))throw Error(s(485));if(i=r.action,i!==null){var h={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){h.listeners.push(_)}};A.T!==null?a(!0):h.isTransition=!1,l(h),a=r.pending,a===null?(h.next=r.pending=h,Q_(r,h)):(h.next=a.next,r.pending=a.next=h)}}function Q_(i,r){var a=r.action,l=r.payload,u=i.state;if(r.isTransition){var h=A.T,_={};A.T=_;try{var E=a(u,l),N=A.S;N!==null&&N(_,E),J_(i,r,E)}catch(Y){Uf(i,r,Y)}finally{h!==null&&_.types!==null&&(h.types=_.types),A.T=h}}else try{h=a(u,l),J_(i,r,h)}catch(Y){Uf(i,r,Y)}}function J_(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){eb(i,r,l)},function(l){return Uf(i,r,l)}):eb(i,r,a)}function eb(i,r,a){r.status="fulfilled",r.value=a,tb(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,Q_(i,a)))}function Uf(i,r,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,tb(r),r=r.next;while(r!==l)}i.action=null}function tb(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function ib(i,r){return r}function nb(i,r){if(bt){var a=zt.formState;if(a!==null){e:{var l=rt;if(bt){if(Ft){t:{for(var u=Ft,h=Jn;u.nodeType!==8;){if(!h){u=null;break t}if(u=tr(u.nextSibling),u===null){u=null;break t}}h=u.data,u=h==="F!"||h==="F"?u:null}if(u){Ft=tr(u.nextSibling),l=u.data==="F!";break e}}Os(l)}l=!1}l&&(r=a[0])}}return a=dn(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ib,lastRenderedState:r},a.queue=l,a=wb.bind(null,rt,l),l.dispatch=a,l=Hf(!1),h=Vf.bind(null,rt,!1,l.queue),l=dn(),u={state:r,dispatch:null,action:i,pending:null},l.queue=u,a=tk.bind(null,rt,u,h,a),u.dispatch=a,l.memoizedState=i,[r,a,!1]}function rb(i){var r=mi();return sb(r,Nt,i)}function sb(i,r,a){if(r=Pf(i,r,ib)[0],i=Xu(es)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=Kl(r)}catch(_){throw _===Do?Iu:_}else l=r;r=mi();var u=r.queue,h=u.dispatch;return a!==r.memoizedState&&(rt.flags|=2048,Lo(9,{destroy:void 0},ik.bind(null,u,a),null)),[l,h,i]}function ik(i,r){i.action=r}function ab(i){var r=mi(),a=Nt;if(a!==null)return sb(r,a,i);mi(),r=r.memoizedState,a=mi();var l=a.queue.dispatch;return a.memoizedState=i,[r,l,!1]}function Lo(i,r,a,l){return i={tag:i,create:a,deps:l,inst:r,next:null},r=rt.updateQueue,r===null&&(r=Vu(),rt.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,r.lastEffect=i),i}function ob(){return mi().memoizedState}function Gu(i,r,a,l){var u=dn();rt.flags|=i,u.memoizedState=Lo(1|r,{destroy:void 0},a,l===void 0?null:l)}function Zu(i,r,a,l){var u=mi();l=l===void 0?null:l;var h=u.memoizedState.inst;Nt!==null&&l!==null&&Af(l,Nt.memoizedState.deps)?u.memoizedState=Lo(r,h,a,l):(rt.flags|=i,u.memoizedState=Lo(1|r,h,a,l))}function lb(i,r){Gu(8390656,8,i,r)}function Kf(i,r){Zu(2048,8,i,r)}function nk(i){rt.flags|=4;var r=rt.updateQueue;if(r===null)r=Vu(),rt.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function cb(i){var r=mi().memoizedState;return nk({ref:r,nextImpl:i}),function(){if((Ct&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function ub(i,r){return Zu(4,2,i,r)}function db(i,r){return Zu(4,4,i,r)}function hb(i,r){if(typeof r=="function"){i=i();var a=r(i);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function fb(i,r,a){a=a!=null?a.concat([i]):null,Zu(4,4,hb.bind(null,r,i),a)}function Ff(){}function pb(i,r){var a=mi();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&Af(r,l[1])?l[0]:(a.memoizedState=[i,r],i)}function mb(i,r){var a=mi();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&Af(r,l[1]))return l[0];if(l=i(),Fa){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[l,r],l}function Wf(i,r,a){return a===void 0||(Jr&1073741824)!==0&&(vt&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=gy(),rt.lanes|=i,Ws|=i,a)}function gb(i,r,a,l){return lt(a,r)?a:Mo.current!==null?(i=Wf(i,a,l),lt(i,r)||(Si=!0),i):(Jr&42)===0||(Jr&1073741824)!==0&&(vt&261930)===0?(Si=!0,i.memoizedState=a):(i=gy(),rt.lanes|=i,Ws|=i,r)}function vb(i,r,a,l,u){var h=R.p;R.p=h!==0&&8>h?h:8;var _=A.T,E={};A.T=E,Vf(i,!1,r,a);try{var N=u(),Y=A.S;if(Y!==null&&Y(E,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ce=Qx(N,l);Fl(i,r,ce,Kn(i))}else Fl(i,r,l,Kn(i))}catch(fe){Fl(i,r,{then:function(){},status:"rejected",reason:fe},Kn())}finally{R.p=h,_!==null&&E.types!==null&&(_.types=E.types),A.T=_}}function rk(){}function qf(i,r,a,l){if(i.tag!==5)throw Error(s(476));var u=_b(i).queue;vb(i,u,r,P,a===null?rk:function(){return bb(i),a(l)})}function _b(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:P},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function bb(i){var r=_b(i);r.next===null&&(r=i.alternate.memoizedState),Fl(i,r.next.queue,{},Kn())}function $f(){return Zi(ac)}function yb(){return mi().memoizedState}function Sb(){return mi().memoizedState}function sk(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=Kn();i=Ps(a);var l=Is(r,i,a);l!==null&&(En(l,r,a),Pl(l,r,a)),r={cache:Sf()},i.payload=r;return}r=r.return}}function ak(i,r,a){var l=Kn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Qu(i)?Cb(r,a):(a=uf(i,r,a,l),a!==null&&(En(a,i,l),xb(a,r,l)))}function wb(i,r,a){var l=Kn();Fl(i,r,a,l)}function Fl(i,r,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Qu(i))Cb(r,u);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var _=r.lastRenderedState,E=h(_,a);if(u.hasEagerState=!0,u.eagerState=E,lt(E,_))return Au(i,r,u,0),zt===null&&Nu(),!1}catch{}if(a=uf(i,r,u,l),a!==null)return En(a,i,l),xb(a,r,l),!0}return!1}function Vf(i,r,a,l){if(l={lane:2,revertLane:kp(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Qu(i)){if(r)throw Error(s(479))}else r=uf(i,a,l,2),r!==null&&En(r,i,2)}function Qu(i){var r=i.alternate;return i===rt||r!==null&&r===rt}function Cb(i,r){No=qu=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function xb(i,r,a){if((a&4194048)!==0){var l=r.lanes;l&=i.pendingLanes,a|=l,r.lanes=a,hi(i,a)}}var Wl={readContext:Zi,use:Yu,useCallback:oi,useContext:oi,useEffect:oi,useImperativeHandle:oi,useLayoutEffect:oi,useInsertionEffect:oi,useMemo:oi,useReducer:oi,useRef:oi,useState:oi,useDebugValue:oi,useDeferredValue:oi,useTransition:oi,useSyncExternalStore:oi,useId:oi,useHostTransitionStatus:oi,useFormState:oi,useActionState:oi,useOptimistic:oi,useMemoCache:oi,useCacheRefresh:oi};Wl.useEffectEvent=oi;var kb={readContext:Zi,use:Yu,useCallback:function(i,r){return dn().memoizedState=[i,r===void 0?null:r],i},useContext:Zi,useEffect:lb,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,Gu(4194308,4,hb.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Gu(4194308,4,i,r)},useInsertionEffect:function(i,r){Gu(4,2,i,r)},useMemo:function(i,r){var a=dn();r=r===void 0?null:r;var l=i();if(Fa){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[l,r],l},useReducer:function(i,r,a){var l=dn();if(a!==void 0){var u=a(r);if(Fa){Ht(!0);try{a(r)}finally{Ht(!1)}}}else u=r;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=ak.bind(null,rt,i),[l.memoizedState,i]},useRef:function(i){var r=dn();return i={current:i},r.memoizedState=i},useState:function(i){i=Hf(i);var r=i.queue,a=wb.bind(null,rt,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:Ff,useDeferredValue:function(i,r){var a=dn();return Wf(a,i,r)},useTransition:function(){var i=Hf(!1);return i=vb.bind(null,rt,i.queue,!0,!1),dn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var l=rt,u=dn();if(bt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),zt===null)throw Error(s(349));(vt&127)!==0||$_(l,r,a)}u.memoizedState=a;var h={value:a,getSnapshot:r};return u.queue=h,lb(Y_.bind(null,l,h,i),[i]),l.flags|=2048,Lo(9,{destroy:void 0},V_.bind(null,l,h,a,r),null),a},useId:function(){var i=dn(),r=zt.identifierPrefix;if(bt){var a=Ar,l=Nr;a=(l&~(1<<32-kt(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=$u++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=Jx++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:$f,useFormState:nb,useActionState:nb,useOptimistic:function(i){var r=dn();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Vf.bind(null,rt,!0,a),a.dispatch=r,[i,r]},useMemoCache:zf,useCacheRefresh:function(){return dn().memoizedState=sk.bind(null,rt)},useEffectEvent:function(i){var r=dn(),a={impl:i};return r.memoizedState=a,function(){if((Ct&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Yf={readContext:Zi,use:Yu,useCallback:pb,useContext:Zi,useEffect:Kf,useImperativeHandle:fb,useInsertionEffect:ub,useLayoutEffect:db,useMemo:mb,useReducer:Xu,useRef:ob,useState:function(){return Xu(es)},useDebugValue:Ff,useDeferredValue:function(i,r){var a=mi();return gb(a,Nt.memoizedState,i,r)},useTransition:function(){var i=Xu(es)[0],r=mi().memoizedState;return[typeof i=="boolean"?i:Kl(i),r]},useSyncExternalStore:q_,useId:yb,useHostTransitionStatus:$f,useFormState:rb,useActionState:rb,useOptimistic:function(i,r){var a=mi();return Z_(a,Nt,i,r)},useMemoCache:zf,useCacheRefresh:Sb};Yf.useEffectEvent=cb;var Eb={readContext:Zi,use:Yu,useCallback:pb,useContext:Zi,useEffect:Kf,useImperativeHandle:fb,useInsertionEffect:ub,useLayoutEffect:db,useMemo:mb,useReducer:If,useRef:ob,useState:function(){return If(es)},useDebugValue:Ff,useDeferredValue:function(i,r){var a=mi();return Nt===null?Wf(a,i,r):gb(a,Nt.memoizedState,i,r)},useTransition:function(){var i=If(es)[0],r=mi().memoizedState;return[typeof i=="boolean"?i:Kl(i),r]},useSyncExternalStore:q_,useId:yb,useHostTransitionStatus:$f,useFormState:ab,useActionState:ab,useOptimistic:function(i,r){var a=mi();return Nt!==null?Z_(a,Nt,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:zf,useCacheRefresh:Sb};Eb.useEffectEvent=cb;function Xf(i,r,a,l){r=i.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Gf={enqueueSetState:function(i,r,a){i=i._reactInternals;var l=Kn(),u=Ps(l);u.payload=r,a!=null&&(u.callback=a),r=Is(i,u,l),r!==null&&(En(r,i,l),Pl(r,i,l))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var l=Kn(),u=Ps(l);u.tag=1,u.payload=r,a!=null&&(u.callback=a),r=Is(i,u,l),r!==null&&(En(r,i,l),Pl(r,i,l))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Kn(),l=Ps(a);l.tag=2,r!=null&&(l.callback=r),r=Is(i,l,a),r!==null&&(En(r,i,a),Pl(r,i,a))}};function Tb(i,r,a,l,u,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):r.prototype&&r.prototype.isPureReactComponent?!Tt(a,l)||!Tt(u,h):!0}function Db(i,r,a,l){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==i&&Gf.enqueueReplaceState(r,r.state,null)}function Wa(i,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(i=i.defaultProps){a===r&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Rb(i){Mu(i)}function Mb(i){console.error(i)}function Nb(i){Mu(i)}function Ju(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Ab(i,r,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Zf(i,r,a){return a=Ps(a),a.tag=3,a.payload={element:null},a.callback=function(){Ju(i,r)},a}function Lb(i){return i=Ps(i),i.tag=3,i}function Bb(i,r,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var h=l.value;i.payload=function(){return u(h)},i.callback=function(){Ab(r,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Ab(r,a,l),typeof u!="function"&&(qs===null?qs=new Set([this]):qs.add(this));var E=l.stack;this.componentDidCatch(l.value,{componentStack:E!==null?E:""})})}function ok(i,r,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&ko(r,a,u,!0),a=Pn.current,a!==null){switch(a.tag){case 31:case 13:return er===null?dd():a.alternate===null&&li===0&&(li=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Hu?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),wp(i,l,u)),!1;case 22:return a.flags|=65536,l===Hu?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),wp(i,l,u)),!1}throw Error(s(435,a.tag))}return wp(i,l,u),dd(),!1}if(bt)return r=Pn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=u,l!==gf&&(i=Error(s(422),{cause:l}),Ll(Gn(i,a)))):(l!==gf&&(r=Error(s(423),{cause:l}),Ll(Gn(r,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=Gn(l,a),u=Zf(i.stateNode,l,u),Tf(i,u),li!==4&&(li=2)),!1;var h=Error(s(520),{cause:l});if(h=Gn(h,a),Ql===null?Ql=[h]:Ql.push(h),li!==4&&(li=2),r===null)return!0;l=Gn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Zf(a.stateNode,l,i),Tf(a,i),!1;case 1:if(r=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(qs===null||!qs.has(h))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Lb(u),Bb(u,i,a,l),Tf(a,u),!1}a=a.return}while(a!==null);return!1}var Qf=Error(s(461)),Si=!1;function Qi(i,r,a,l){r.child=i===null?P_(r,null,a,l):Ka(r,i.child,a,l)}function Ob(i,r,a,l,u){a=a.render;var h=r.ref;if("ref"in l){var _={};for(var E in l)E!=="ref"&&(_[E]=l[E])}else _=l;return Pa(r),l=Lf(i,r,a,_,h,u),E=Bf(),i!==null&&!Si?(Of(i,r,u),ts(i,r,u)):(bt&&E&&pf(r),r.flags|=1,Qi(i,r,l,u),r.child)}function jb(i,r,a,l,u){if(i===null){var h=a.type;return typeof h=="function"&&!df(h)&&h.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=h,zb(i,r,h,l,u)):(i=Bu(a.type,null,l,r,r.mode,u),i.ref=r.ref,i.return=r,r.child=i)}if(h=i.child,!ap(i,u)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Tt,a(_,l)&&i.ref===r.ref)return ts(i,r,u)}return r.flags|=1,i=Xr(h,l),i.ref=r.ref,i.return=r,r.child=i}function zb(i,r,a,l,u){if(i!==null){var h=i.memoizedProps;if(Tt(h,l)&&i.ref===r.ref)if(Si=!1,r.pendingProps=l=h,ap(i,u))(i.flags&131072)!==0&&(Si=!0);else return r.lanes=i.lanes,ts(i,r,u)}return Jf(i,r,a,l,u)}function Pb(i,r,a,l){var u=l.children,h=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(l=r.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~h}else l=0,r.child=null;return Ib(i,r,h,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Pu(r,h!==null?h.cachePool:null),h!==null?U_(r,h):Rf(),K_(r);else return l=r.lanes=536870912,Ib(i,r,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(Pu(r,h.cachePool),U_(r,h),Us(),r.memoizedState=null):(i!==null&&Pu(r,null),Rf(),Us());return Qi(i,r,u,a),r.child}function ql(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Ib(i,r,a,l,u){var h=Cf();return h=h===null?null:{parent:bi._currentValue,pool:h},r.memoizedState={baseLanes:a,cachePool:h},i!==null&&Pu(r,null),Rf(),K_(r),i!==null&&ko(i,r,l,!0),r.childLanes=u,null}function ed(i,r){return r=id({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function Hb(i,r,a){return Ka(r,i.child,null,a),i=ed(r,r.pendingProps),i.flags|=2,In(r),r.memoizedState=null,i}function lk(i,r,a){var l=r.pendingProps,u=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(bt){if(l.mode==="hidden")return i=ed(r,l),r.lanes=536870912,ql(null,i);if(Nf(r),(i=Ft)?(i=Qy(i,Jn),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ls!==null?{id:Nr,overflow:Ar}:null,retryLane:536870912,hydrationErrors:null},a=C_(i),a.return=r,r.child=a,Gi=r,Ft=null)):i=null,i===null)throw Os(r);return r.lanes=536870912,null}return ed(r,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(Nf(r),u)if(r.flags&256)r.flags&=-257,r=Hb(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(Si||ko(i,r,a,!1),u=(a&i.childLanes)!==0,Si||u){if(l=zt,l!==null&&(_=zi(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,Ba(i,_),En(l,i,_),Qf;dd(),r=Hb(i,r,a)}else i=h.treeContext,Ft=tr(_.nextSibling),Gi=r,bt=!0,Bs=null,Jn=!1,i!==null&&E_(r,i),r=ed(r,l),r.flags|=4096;return r}return i=Xr(i.child,{mode:l.mode,children:l.children}),i.ref=r.ref,r.child=i,i.return=r,i}function td(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function Jf(i,r,a,l,u){return Pa(r),a=Lf(i,r,a,l,void 0,u),l=Bf(),i!==null&&!Si?(Of(i,r,u),ts(i,r,u)):(bt&&l&&pf(r),r.flags|=1,Qi(i,r,a,u),r.child)}function Ub(i,r,a,l,u,h){return Pa(r),r.updateQueue=null,a=W_(r,l,a,u),F_(i),l=Bf(),i!==null&&!Si?(Of(i,r,h),ts(i,r,h)):(bt&&l&&pf(r),r.flags|=1,Qi(i,r,a,h),r.child)}function Kb(i,r,a,l,u){if(Pa(r),r.stateNode===null){var h=So,_=a.contextType;typeof _=="object"&&_!==null&&(h=Zi(_)),h=new a(l,h),r.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Gf,r.stateNode=h,h._reactInternals=r,h=r.stateNode,h.props=l,h.state=r.memoizedState,h.refs={},kf(r),_=a.contextType,h.context=typeof _=="object"&&_!==null?Zi(_):So,h.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Xf(r,a,_,l),h.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(_=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),_!==h.state&&Gf.enqueueReplaceState(h,h.state,null),Hl(r,l,h,u),Il(),h.state=r.memoizedState),typeof h.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(i===null){h=r.stateNode;var E=r.memoizedProps,N=Wa(a,E);h.props=N;var Y=h.context,ce=a.contextType;_=So,typeof ce=="object"&&ce!==null&&(_=Zi(ce));var fe=a.getDerivedStateFromProps;ce=typeof fe=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=r.pendingProps!==E,ce||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||Y!==_)&&Db(r,h,l,_),zs=!1;var Q=r.memoizedState;h.state=Q,Hl(r,l,h,u),Il(),Y=r.memoizedState,E||Q!==Y||zs?(typeof fe=="function"&&(Xf(r,a,fe,l),Y=r.memoizedState),(N=zs||Tb(r,a,N,l,Q,Y,_))?(ce||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(r.flags|=4194308)):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=Y),h.props=l,h.state=Y,h.context=_,l=N):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{h=r.stateNode,Ef(i,r),_=r.memoizedProps,ce=Wa(a,_),h.props=ce,fe=r.pendingProps,Q=h.context,Y=a.contextType,N=So,typeof Y=="object"&&Y!==null&&(N=Zi(Y)),E=a.getDerivedStateFromProps,(Y=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==fe||Q!==N)&&Db(r,h,l,N),zs=!1,Q=r.memoizedState,h.state=Q,Hl(r,l,h,u),Il();var te=r.memoizedState;_!==fe||Q!==te||zs||i!==null&&i.dependencies!==null&&ju(i.dependencies)?(typeof E=="function"&&(Xf(r,a,E,l),te=r.memoizedState),(ce=zs||Tb(r,a,ce,l,Q,te,N)||i!==null&&i.dependencies!==null&&ju(i.dependencies))?(Y||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(l,te,N),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(l,te,N)),typeof h.componentDidUpdate=="function"&&(r.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=te),h.props=l,h.state=te,h.context=N,l=ce):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=1024),l=!1)}return h=l,td(i,r),l=(r.flags&128)!==0,h||l?(h=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:h.render(),r.flags|=1,i!==null&&l?(r.child=Ka(r,i.child,null,u),r.child=Ka(r,null,a,u)):Qi(i,r,a,u),r.memoizedState=h.state,i=r.child):i=ts(i,r,u),i}function Fb(i,r,a,l){return ja(),r.flags|=256,Qi(i,r,a,l),r.child}var ep={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tp(i){return{baseLanes:i,cachePool:A_()}}function ip(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=Un),i}function Wb(i,r,a){var l=r.pendingProps,u=!1,h=(r.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(pi.current&2)!==0),_&&(u=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,i===null){if(bt){if(u?Hs(r):Us(),(i=Ft)?(i=Qy(i,Jn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ls!==null?{id:Nr,overflow:Ar}:null,retryLane:536870912,hydrationErrors:null},a=C_(i),a.return=r,r.child=a,Gi=r,Ft=null)):i=null,i===null)throw Os(r);return Pp(i)?r.lanes=32:r.lanes=536870912,null}var E=l.children;return l=l.fallback,u?(Us(),u=r.mode,E=id({mode:"hidden",children:E},u),l=Oa(l,u,a,null),E.return=r,l.return=r,E.sibling=l,r.child=E,l=r.child,l.memoizedState=tp(a),l.childLanes=ip(i,_,a),r.memoizedState=ep,ql(null,l)):(Hs(r),np(r,E))}var N=i.memoizedState;if(N!==null&&(E=N.dehydrated,E!==null)){if(h)r.flags&256?(Hs(r),r.flags&=-257,r=rp(i,r,a)):r.memoizedState!==null?(Us(),r.child=i.child,r.flags|=128,r=null):(Us(),E=l.fallback,u=r.mode,l=id({mode:"visible",children:l.children},u),E=Oa(E,u,a,null),E.flags|=2,l.return=r,E.return=r,l.sibling=E,r.child=l,Ka(r,i.child,null,a),l=r.child,l.memoizedState=tp(a),l.childLanes=ip(i,_,a),r.memoizedState=ep,r=ql(null,l));else if(Hs(r),Pp(E)){if(_=E.nextSibling&&E.nextSibling.dataset,_)var Y=_.dgst;_=Y,l=Error(s(419)),l.stack="",l.digest=_,Ll({value:l,source:null,stack:null}),r=rp(i,r,a)}else if(Si||ko(i,r,a,!1),_=(a&i.childLanes)!==0,Si||_){if(_=zt,_!==null&&(l=zi(_,a),l!==0&&l!==N.retryLane))throw N.retryLane=l,Ba(i,l),En(_,i,l),Qf;zp(E)||dd(),r=rp(i,r,a)}else zp(E)?(r.flags|=192,r.child=i.child,r=null):(i=N.treeContext,Ft=tr(E.nextSibling),Gi=r,bt=!0,Bs=null,Jn=!1,i!==null&&E_(r,i),r=np(r,l.children),r.flags|=4096);return r}return u?(Us(),E=l.fallback,u=r.mode,N=i.child,Y=N.sibling,l=Xr(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,Y!==null?E=Xr(Y,E):(E=Oa(E,u,a,null),E.flags|=2),E.return=r,l.return=r,l.sibling=E,r.child=l,ql(null,l),l=r.child,E=i.child.memoizedState,E===null?E=tp(a):(u=E.cachePool,u!==null?(N=bi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=A_(),E={baseLanes:E.baseLanes|a,cachePool:u}),l.memoizedState=E,l.childLanes=ip(i,_,a),r.memoizedState=ep,ql(i.child,l)):(Hs(r),a=i.child,i=a.sibling,a=Xr(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,i!==null&&(_=r.deletions,_===null?(r.deletions=[i],r.flags|=16):_.push(i)),r.child=a,r.memoizedState=null,a)}function np(i,r){return r=id({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function id(i,r){return i=zn(22,i,null,r),i.lanes=0,i}function rp(i,r,a){return Ka(r,i.child,null,a),i=np(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function qb(i,r,a){i.lanes|=r;var l=i.alternate;l!==null&&(l.lanes|=r),bf(i.return,r,a)}function sp(i,r,a,l,u,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:h}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=h)}function $b(i,r,a){var l=r.pendingProps,u=l.revealOrder,h=l.tail;l=l.children;var _=pi.current,E=(_&2)!==0;if(E?(_=_&1|2,r.flags|=128):_&=1,le(pi,_),Qi(i,r,l,a),l=bt?Al:0,!E&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&qb(i,a,r);else if(i.tag===19)qb(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=r.child,u=null;a!==null;)i=a.alternate,i!==null&&Wu(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=r.child,r.child=null):(u=a.sibling,a.sibling=null),sp(r,!1,u,a,h,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=r.child,r.child=null;u!==null;){if(i=u.alternate,i!==null&&Wu(i)===null){r.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}sp(r,!0,a,null,h,l);break;case"together":sp(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function ts(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Ws|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(ko(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=Xr(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Xr(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function ap(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&ju(i)))}function ck(i,r,a){switch(r.tag){case 3:Re(r,r.stateNode.containerInfo),js(r,bi,i.memoizedState.cache),ja();break;case 27:case 5:Be(r);break;case 4:Re(r,r.stateNode.containerInfo);break;case 10:js(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Nf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(Hs(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Wb(i,r,a):(Hs(r),i=ts(i,r,a),i!==null?i.sibling:null);Hs(r);break;case 19:var u=(i.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(ko(i,r,a,!1),l=(a&r.childLanes)!==0),u){if(l)return $b(i,r,a);r.flags|=128}if(u=r.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),le(pi,pi.current),l)break;return null;case 22:return r.lanes=0,Pb(i,r,a,r.pendingProps);case 24:js(r,bi,i.memoizedState.cache)}return ts(i,r,a)}function Vb(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)Si=!0;else{if(!ap(i,a)&&(r.flags&128)===0)return Si=!1,ck(i,r,a);Si=(i.flags&131072)!==0}else Si=!1,bt&&(r.flags&1048576)!==0&&k_(r,Al,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(i=Ha(r.elementType),r.type=i,typeof i=="function")df(i)?(l=Wa(i,l),r.tag=1,r=Kb(null,r,i,l,a)):(r.tag=0,r=Jf(null,r,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===U){r.tag=11,r=Ob(null,r,i,l,a);break e}else if(u===W){r.tag=14,r=jb(null,r,i,l,a);break e}}throw r=K(i)||i,Error(s(306,r,""))}}return r;case 0:return Jf(i,r,r.type,r.pendingProps,a);case 1:return l=r.type,u=Wa(l,r.pendingProps),Kb(i,r,l,u,a);case 3:e:{if(Re(r,r.stateNode.containerInfo),i===null)throw Error(s(387));l=r.pendingProps;var h=r.memoizedState;u=h.element,Ef(i,r),Hl(r,l,null,a);var _=r.memoizedState;if(l=_.cache,js(r,bi,l),l!==h.cache&&yf(r,[bi],a,!0),Il(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){r=Fb(i,r,l,a);break e}else if(l!==u){u=Gn(Error(s(424)),r),Ll(u),r=Fb(i,r,l,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Ft=tr(i.firstChild),Gi=r,bt=!0,Bs=null,Jn=!0,a=P_(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ja(),l===u){r=ts(i,r,a);break e}Qi(i,r,l,a)}r=r.child}return r;case 26:return td(i,r),i===null?(a=rS(r.type,null,r.pendingProps,null))?r.memoizedState=a:bt||(a=r.type,i=r.pendingProps,l=_d(Ee.current).createElement(a),l[si]=r,l[Pi]=i,Ji(l,a,i),$t(l),r.stateNode=l):r.memoizedState=rS(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Be(r),i===null&&bt&&(l=r.stateNode=tS(r.type,r.pendingProps,Ee.current),Gi=r,Jn=!0,u=Ft,Xs(r.type)?(Ip=u,Ft=tr(l.firstChild)):Ft=u),Qi(i,r,r.pendingProps.children,a),td(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&bt&&((u=l=Ft)&&(l=Ik(l,r.type,r.pendingProps,Jn),l!==null?(r.stateNode=l,Gi=r,Ft=tr(l.firstChild),Jn=!1,u=!0):u=!1),u||Os(r)),Be(r),u=r.type,h=r.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,Bp(u,h)?l=null:_!==null&&Bp(u,_)&&(r.flags|=32),r.memoizedState!==null&&(u=Lf(i,r,ek,null,null,a),ac._currentValue=u),td(i,r),Qi(i,r,l,a),r.child;case 6:return i===null&&bt&&((i=a=Ft)&&(a=Hk(a,r.pendingProps,Jn),a!==null?(r.stateNode=a,Gi=r,Ft=null,i=!0):i=!1),i||Os(r)),null;case 13:return Wb(i,r,a);case 4:return Re(r,r.stateNode.containerInfo),l=r.pendingProps,i===null?r.child=Ka(r,null,l,a):Qi(i,r,l,a),r.child;case 11:return Ob(i,r,r.type,r.pendingProps,a);case 7:return Qi(i,r,r.pendingProps,a),r.child;case 8:return Qi(i,r,r.pendingProps.children,a),r.child;case 12:return Qi(i,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,js(r,r.type,l.value),Qi(i,r,l.children,a),r.child;case 9:return u=r.type._context,l=r.pendingProps.children,Pa(r),u=Zi(u),l=l(u),r.flags|=1,Qi(i,r,l,a),r.child;case 14:return jb(i,r,r.type,r.pendingProps,a);case 15:return zb(i,r,r.type,r.pendingProps,a);case 19:return $b(i,r,a);case 31:return lk(i,r,a);case 22:return Pb(i,r,a,r.pendingProps);case 24:return Pa(r),l=Zi(bi),i===null?(u=Cf(),u===null&&(u=zt,h=Sf(),u.pooledCache=h,h.refCount++,h!==null&&(u.pooledCacheLanes|=a),u=h),r.memoizedState={parent:l,cache:u},kf(r),js(r,bi,u)):((i.lanes&a)!==0&&(Ef(i,r),Hl(r,null,null,a),Il()),u=i.memoizedState,h=r.memoizedState,u.parent!==l?(u={parent:l,cache:l},r.memoizedState=u,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=u),js(r,bi,l)):(l=h.cache,js(r,bi,l),l!==u.cache&&yf(r,[bi],a,!0))),Qi(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function is(i){i.flags|=4}function op(i,r,a,l,u){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(yy())i.flags|=8192;else throw Ua=Hu,xf}else i.flags&=-16777217}function Yb(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!cS(r))if(yy())i.flags|=8192;else throw Ua=Hu,xf}function nd(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?Gt():536870912,i.lanes|=r,zo|=r)}function $l(i,r){if(!bt)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function Wt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(r)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,r}function uk(i,r,a){var l=r.pendingProps;switch(mf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wt(r),null;case 1:return Wt(r),null;case 3:return a=r.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Qr(bi),Pe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(xo(r)?is(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,vf())),Wt(r),null;case 26:var u=r.type,h=r.memoizedState;return i===null?(is(r),h!==null?(Wt(r),Yb(r,h)):(Wt(r),op(r,u,null,l,a))):h?h!==i.memoizedState?(is(r),Wt(r),Yb(r,h)):(Wt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==l&&is(r),Wt(r),op(r,u,i,l,a)),null;case 27:if(oe(r),a=Ee.current,u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==l&&is(r);else{if(!l){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}i=_e.current,xo(r)?T_(r):(i=tS(u,l,a),r.stateNode=i,is(r))}return Wt(r),null;case 5:if(oe(r),u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==l&&is(r);else{if(!l){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}if(h=_e.current,xo(r))T_(r);else{var _=_d(Ee.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":h=_.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?h.multiple=!0:l.size&&(h.size=l.size);break;default:h=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}h[si]=r,h[Pi]=l;e:for(_=r.child;_!==null;){if(_.tag===5||_.tag===6)h.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===r)break e;for(;_.sibling===null;){if(_.return===null||_.return===r)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}r.stateNode=h;e:switch(Ji(h,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&is(r)}}return Wt(r),op(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==l&&is(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(s(166));if(i=Ee.current,xo(r)){if(i=r.stateNode,a=r.memoizedProps,l=null,u=Gi,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[si]=r,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Wy(i.nodeValue,a)),i||Os(r,!0)}else i=_d(i).createTextNode(l),i[si]=r,r.stateNode=i}return Wt(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(l=xo(r),a!==null){if(i===null){if(!l)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[si]=r}else ja(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),i=!1}else a=vf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(In(r),r):(In(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Wt(r),null;case 13:if(l=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=xo(r),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=r.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[si]=r}else ja(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),u=!1}else u=vf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return r.flags&256?(In(r),r):(In(r),null)}return In(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=r.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),h=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(h=l.memoizedState.cachePool.pool),h!==u&&(l.flags|=2048)),a!==i&&a&&(r.child.flags|=8192),nd(r,r.updateQueue),Wt(r),null);case 4:return Pe(),i===null&&Rp(r.stateNode.containerInfo),Wt(r),null;case 10:return Qr(r.type),Wt(r),null;case 19:if(V(pi),l=r.memoizedState,l===null)return Wt(r),null;if(u=(r.flags&128)!==0,h=l.rendering,h===null)if(u)$l(l,!1);else{if(li!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(h=Wu(i),h!==null){for(r.flags|=128,$l(l,!1),i=h.updateQueue,r.updateQueue=i,nd(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)w_(a,i),a=a.sibling;return le(pi,pi.current&1|2),bt&&Gr(r,l.treeForkCount),r.child}i=i.sibling}l.tail!==null&&Dt()>ld&&(r.flags|=128,u=!0,$l(l,!1),r.lanes=4194304)}else{if(!u)if(i=Wu(h),i!==null){if(r.flags|=128,u=!0,i=i.updateQueue,r.updateQueue=i,nd(r,i),$l(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!bt)return Wt(r),null}else 2*Dt()-l.renderingStartTime>ld&&a!==536870912&&(r.flags|=128,u=!0,$l(l,!1),r.lanes=4194304);l.isBackwards?(h.sibling=r.child,r.child=h):(i=l.last,i!==null?i.sibling=h:r.child=h,l.last=h)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=Dt(),i.sibling=null,a=pi.current,le(pi,u?a&1|2:a&1),bt&&Gr(r,l.treeForkCount),i):(Wt(r),null);case 22:case 23:return In(r),Mf(),l=r.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(Wt(r),r.subtreeFlags&6&&(r.flags|=8192)):Wt(r),a=r.updateQueue,a!==null&&nd(r,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),i!==null&&V(Ia),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),Qr(bi),Wt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function dk(i,r){switch(mf(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Qr(bi),Pe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return oe(r),null;case 31:if(r.memoizedState!==null){if(In(r),r.alternate===null)throw Error(s(340));ja()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(In(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));ja()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return V(pi),null;case 4:return Pe(),null;case 10:return Qr(r.type),null;case 22:case 23:return In(r),Mf(),i!==null&&V(Ia),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return Qr(bi),null;case 25:return null;default:return null}}function Xb(i,r){switch(mf(r),r.tag){case 3:Qr(bi),Pe();break;case 26:case 27:case 5:oe(r);break;case 4:Pe();break;case 31:r.memoizedState!==null&&In(r);break;case 13:In(r);break;case 19:V(pi);break;case 10:Qr(r.type);break;case 22:case 23:In(r),Mf(),i!==null&&V(Ia);break;case 24:Qr(bi)}}function Vl(i,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var h=a.create,_=a.inst;l=h(),_.destroy=l}a=a.next}while(a!==u)}}catch(E){Mt(r,r.return,E)}}function Ks(i,r,a){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var h=u.next;l=h;do{if((l.tag&i)===i){var _=l.inst,E=_.destroy;if(E!==void 0){_.destroy=void 0,u=r;var N=a,Y=E;try{Y()}catch(ce){Mt(u,N,ce)}}}l=l.next}while(l!==h)}}catch(ce){Mt(r,r.return,ce)}}function Gb(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{H_(r,a)}catch(l){Mt(i,i.return,l)}}}function Zb(i,r,a){a.props=Wa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){Mt(i,r,l)}}function Yl(i,r){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){Mt(i,r,u)}}function Lr(i,r){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){Mt(i,r,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){Mt(i,r,u)}else a.current=null}function Qb(i){var r=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){Mt(i,i.return,u)}}function lp(i,r,a){try{var l=i.stateNode;Lk(l,i.type,a,r),l[Pi]=r}catch(u){Mt(i,i.return,u)}}function Jb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Xs(i.type)||i.tag===4}function cp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Jb(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Xs(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function up(i,r,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(i),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=cn));else if(l!==4&&(l===27&&Xs(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(up(i,r,a),i=i.sibling;i!==null;)up(i,r,a),i=i.sibling}function rd(i,r,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(l!==4&&(l===27&&Xs(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(rd(i,r,a),i=i.sibling;i!==null;)rd(i,r,a),i=i.sibling}function ey(i){var r=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=r.attributes;u.length;)r.removeAttributeNode(u[0]);Ji(r,l,a),r[si]=i,r[Pi]=a}catch(h){Mt(i,i.return,h)}}var ns=!1,wi=!1,dp=!1,ty=typeof WeakSet=="function"?WeakSet:Set,Ui=null;function hk(i,r){if(i=i.containerInfo,Ap=kd,i=Rl(i),Ml(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,E=-1,N=-1,Y=0,ce=0,fe=i,Q=null;t:for(;;){for(var te;fe!==a||u!==0&&fe.nodeType!==3||(E=_+u),fe!==h||l!==0&&fe.nodeType!==3||(N=_+l),fe.nodeType===3&&(_+=fe.nodeValue.length),(te=fe.firstChild)!==null;)Q=fe,fe=te;for(;;){if(fe===i)break t;if(Q===a&&++Y===u&&(E=_),Q===h&&++ce===l&&(N=_),(te=fe.nextSibling)!==null)break;fe=Q,Q=fe.parentNode}fe=te}a=E===-1||N===-1?null:{start:E,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(Lp={focusedElem:i,selectionRange:a},kd=!1,Ui=r;Ui!==null;)if(r=Ui,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ui=i;else for(;Ui!==null;){switch(r=Ui,h=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=r,u=h.memoizedProps,h=h.memoizedState,l=a.stateNode;try{var Ie=Wa(a.type,u);i=l.getSnapshotBeforeUpdate(Ie,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Xe){Mt(a,a.return,Xe)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)jp(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":jp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=r.sibling,i!==null){i.return=r.return,Ui=i;break}Ui=r.return}}function iy(i,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:ss(i,a),l&4&&Vl(5,a);break;case 1:if(ss(i,a),l&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(_){Mt(a,a.return,_)}else{var u=Wa(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(u,r,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Mt(a,a.return,_)}}l&64&&Gb(a),l&512&&Yl(a,a.return);break;case 3:if(ss(i,a),l&64&&(i=a.updateQueue,i!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{H_(i,r)}catch(_){Mt(a,a.return,_)}}break;case 27:r===null&&l&4&&ey(a);case 26:case 5:ss(i,a),r===null&&l&4&&Qb(a),l&512&&Yl(a,a.return);break;case 12:ss(i,a);break;case 31:ss(i,a),l&4&&sy(i,a);break;case 13:ss(i,a),l&4&&ay(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Sk.bind(null,a),Uk(i,a))));break;case 22:if(l=a.memoizedState!==null||ns,!l){r=r!==null&&r.memoizedState!==null||wi,u=ns;var h=wi;ns=l,(wi=r)&&!h?as(i,a,(a.subtreeFlags&8772)!==0):ss(i,a),ns=u,wi=h}break;case 30:break;default:ss(i,a)}}function ny(i){var r=i.alternate;r!==null&&(i.alternate=null,ny(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&ln(r)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Yt=null,wn=!1;function rs(i,r,a){for(a=a.child;a!==null;)ry(i,r,a),a=a.sibling}function ry(i,r,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(xt,a)}catch{}switch(a.tag){case 26:wi||Lr(a,r),rs(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:wi||Lr(a,r);var l=Yt,u=wn;Xs(a.type)&&(Yt=a.stateNode,wn=!1),rs(i,r,a),nc(a.stateNode),Yt=l,wn=u;break;case 5:wi||Lr(a,r);case 6:if(l=Yt,u=wn,Yt=null,rs(i,r,a),Yt=l,wn=u,Yt!==null)if(wn)try{(Yt.nodeType===9?Yt.body:Yt.nodeName==="HTML"?Yt.ownerDocument.body:Yt).removeChild(a.stateNode)}catch(h){Mt(a,r,h)}else try{Yt.removeChild(a.stateNode)}catch(h){Mt(a,r,h)}break;case 18:Yt!==null&&(wn?(i=Yt,Gy(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),qo(i)):Gy(Yt,a.stateNode));break;case 4:l=Yt,u=wn,Yt=a.stateNode.containerInfo,wn=!0,rs(i,r,a),Yt=l,wn=u;break;case 0:case 11:case 14:case 15:Ks(2,a,r),wi||Ks(4,a,r),rs(i,r,a);break;case 1:wi||(Lr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Zb(a,r,l)),rs(i,r,a);break;case 21:rs(i,r,a);break;case 22:wi=(l=wi)||a.memoizedState!==null,rs(i,r,a),wi=l;break;default:rs(i,r,a)}}function sy(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{qo(i)}catch(a){Mt(r,r.return,a)}}}function ay(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{qo(i)}catch(a){Mt(r,r.return,a)}}function fk(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new ty),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new ty),r;default:throw Error(s(435,i.tag))}}function sd(i,r){var a=fk(i);r.forEach(function(l){if(!a.has(l)){a.add(l);var u=wk.bind(null,i,l);l.then(u,u)}})}function Cn(i,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],h=i,_=r,E=_;e:for(;E!==null;){switch(E.tag){case 27:if(Xs(E.type)){Yt=E.stateNode,wn=!1;break e}break;case 5:Yt=E.stateNode,wn=!1;break e;case 3:case 4:Yt=E.stateNode.containerInfo,wn=!0;break e}E=E.return}if(Yt===null)throw Error(s(160));ry(h,_,u),Yt=null,wn=!1,h=u.alternate,h!==null&&(h.return=null),u.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)oy(r,i),r=r.sibling}var vr=null;function oy(i,r){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Cn(r,i),xn(i),l&4&&(Ks(3,i,i.return),Vl(3,i),Ks(5,i,i.return));break;case 1:Cn(r,i),xn(i),l&512&&(wi||a===null||Lr(a,a.return)),l&64&&ns&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=vr;if(Cn(r,i),xn(i),l&512&&(wi||a===null||Lr(a,a.return)),l&4){var h=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":h=u.getElementsByTagName("title")[0],(!h||h[It]||h[si]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=u.createElement(l),u.head.insertBefore(h,u.querySelector("head > title"))),Ji(h,l,a),h[si]=i,$t(h),l=h;break e;case"link":var _=oS("link","href",u).get(l+(a.href||""));if(_){for(var E=0;E<_.length;E++)if(h=_[E],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(E,1);break t}}h=u.createElement(l),Ji(h,l,a),u.head.appendChild(h);break;case"meta":if(_=oS("meta","content",u).get(l+(a.content||""))){for(E=0;E<_.length;E++)if(h=_[E],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(E,1);break t}}h=u.createElement(l),Ji(h,l,a),u.head.appendChild(h);break;default:throw Error(s(468,l))}h[si]=i,$t(h),l=h}i.stateNode=l}else lS(u,i.type,i.stateNode);else i.stateNode=aS(u,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?lS(u,i.type,i.stateNode):aS(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&lp(i,i.memoizedProps,a.memoizedProps)}break;case 27:Cn(r,i),xn(i),l&512&&(wi||a===null||Lr(a,a.return)),a!==null&&l&4&&lp(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Cn(r,i),xn(i),l&512&&(wi||a===null||Lr(a,a.return)),i.flags&32){u=i.stateNode;try{pr(u,"")}catch(Ie){Mt(i,i.return,Ie)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,lp(i,u,a!==null?a.memoizedProps:u)),l&1024&&(dp=!0);break;case 6:if(Cn(r,i),xn(i),l&4){if(i.stateNode===null)throw Error(s(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ie){Mt(i,i.return,Ie)}}break;case 3:if(Sd=null,u=vr,vr=bd(r.containerInfo),Cn(r,i),vr=u,xn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{qo(r.containerInfo)}catch(Ie){Mt(i,i.return,Ie)}dp&&(dp=!1,ly(i));break;case 4:l=vr,vr=bd(i.stateNode.containerInfo),Cn(r,i),xn(i),vr=l;break;case 12:Cn(r,i),xn(i);break;case 31:Cn(r,i),xn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sd(i,l)));break;case 13:Cn(r,i),xn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(od=Dt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sd(i,l)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,Y=ns,ce=wi;if(ns=Y||u,wi=ce||N,Cn(r,i),wi=ce,ns=Y,xn(i),l&8192)e:for(r=i.stateNode,r._visibility=u?r._visibility&-2:r._visibility|1,u&&(a===null||N||ns||wi||qa(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){N=a=r;try{if(h=N.stateNode,u)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{E=N.stateNode;var fe=N.memoizedProps.style,Q=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;E.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(Ie){Mt(N,N.return,Ie)}}}else if(r.tag===6){if(a===null){N=r;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Ie){Mt(N,N.return,Ie)}}}else if(r.tag===18){if(a===null){N=r;try{var te=N.stateNode;u?Zy(te,!0):Zy(N.stateNode,!1)}catch(Ie){Mt(N,N.return,Ie)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,sd(i,a))));break;case 19:Cn(r,i),xn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sd(i,l)));break;case 30:break;case 21:break;default:Cn(r,i),xn(i)}}function xn(i){var r=i.flags;if(r&2){try{for(var a,l=i.return;l!==null;){if(Jb(l)){a=l;break}l=l.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,h=cp(i);rd(i,h,u);break;case 5:var _=a.stateNode;a.flags&32&&(pr(_,""),a.flags&=-33);var E=cp(i);rd(i,E,_);break;case 3:case 4:var N=a.stateNode.containerInfo,Y=cp(i);up(i,Y,N);break;default:throw Error(s(161))}}catch(ce){Mt(i,i.return,ce)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function ly(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;ly(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function ss(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)iy(i,r.alternate,r),r=r.sibling}function qa(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Ks(4,r,r.return),qa(r);break;case 1:Lr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&Zb(r,r.return,a),qa(r);break;case 27:nc(r.stateNode);case 26:case 5:Lr(r,r.return),qa(r);break;case 22:r.memoizedState===null&&qa(r);break;case 30:qa(r);break;default:qa(r)}i=i.sibling}}function as(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,u=i,h=r,_=h.flags;switch(h.tag){case 0:case 11:case 15:as(u,h,a),Vl(4,h);break;case 1:if(as(u,h,a),l=h,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(Y){Mt(l,l.return,Y)}if(l=h,u=l.updateQueue,u!==null){var E=l.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)I_(N[u],E)}catch(Y){Mt(l,l.return,Y)}}a&&_&64&&Gb(h),Yl(h,h.return);break;case 27:ey(h);case 26:case 5:as(u,h,a),a&&l===null&&_&4&&Qb(h),Yl(h,h.return);break;case 12:as(u,h,a);break;case 31:as(u,h,a),a&&_&4&&sy(u,h);break;case 13:as(u,h,a),a&&_&4&&ay(u,h);break;case 22:h.memoizedState===null&&as(u,h,a),Yl(h,h.return);break;case 30:break;default:as(u,h,a)}r=r.sibling}}function hp(i,r){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Bl(a))}function fp(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Bl(i))}function _r(i,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)cy(i,r,a,l),r=r.sibling}function cy(i,r,a,l){var u=r.flags;switch(r.tag){case 0:case 11:case 15:_r(i,r,a,l),u&2048&&Vl(9,r);break;case 1:_r(i,r,a,l);break;case 3:_r(i,r,a,l),u&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Bl(i)));break;case 12:if(u&2048){_r(i,r,a,l),i=r.stateNode;try{var h=r.memoizedProps,_=h.id,E=h.onPostCommit;typeof E=="function"&&E(_,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){Mt(r,r.return,N)}}else _r(i,r,a,l);break;case 31:_r(i,r,a,l);break;case 13:_r(i,r,a,l);break;case 23:break;case 22:h=r.stateNode,_=r.alternate,r.memoizedState!==null?h._visibility&2?_r(i,r,a,l):Xl(i,r):h._visibility&2?_r(i,r,a,l):(h._visibility|=2,Bo(i,r,a,l,(r.subtreeFlags&10256)!==0||!1)),u&2048&&hp(_,r);break;case 24:_r(i,r,a,l),u&2048&&fp(r.alternate,r);break;default:_r(i,r,a,l)}}function Bo(i,r,a,l,u){for(u=u&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var h=i,_=r,E=a,N=l,Y=_.flags;switch(_.tag){case 0:case 11:case 15:Bo(h,_,E,N,u),Vl(8,_);break;case 23:break;case 22:var ce=_.stateNode;_.memoizedState!==null?ce._visibility&2?Bo(h,_,E,N,u):Xl(h,_):(ce._visibility|=2,Bo(h,_,E,N,u)),u&&Y&2048&&hp(_.alternate,_);break;case 24:Bo(h,_,E,N,u),u&&Y&2048&&fp(_.alternate,_);break;default:Bo(h,_,E,N,u)}r=r.sibling}}function Xl(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=i,l=r,u=l.flags;switch(l.tag){case 22:Xl(a,l),u&2048&&hp(l.alternate,l);break;case 24:Xl(a,l),u&2048&&fp(l.alternate,l);break;default:Xl(a,l)}r=r.sibling}}var Gl=8192;function Oo(i,r,a){if(i.subtreeFlags&Gl)for(i=i.child;i!==null;)uy(i,r,a),i=i.sibling}function uy(i,r,a){switch(i.tag){case 26:Oo(i,r,a),i.flags&Gl&&i.memoizedState!==null&&Jk(a,vr,i.memoizedState,i.memoizedProps);break;case 5:Oo(i,r,a);break;case 3:case 4:var l=vr;vr=bd(i.stateNode.containerInfo),Oo(i,r,a),vr=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Gl,Gl=16777216,Oo(i,r,a),Gl=l):Oo(i,r,a));break;default:Oo(i,r,a)}}function dy(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function Zl(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Ui=l,fy(l,i)}dy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)hy(i),i=i.sibling}function hy(i){switch(i.tag){case 0:case 11:case 15:Zl(i),i.flags&2048&&Ks(9,i,i.return);break;case 3:Zl(i);break;case 12:Zl(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,ad(i)):Zl(i);break;default:Zl(i)}}function ad(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Ui=l,fy(l,i)}dy(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Ks(8,r,r.return),ad(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,ad(r));break;default:ad(r)}i=i.sibling}}function fy(i,r){for(;Ui!==null;){var a=Ui;switch(a.tag){case 0:case 11:case 15:Ks(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Bl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Ui=l;else e:for(a=i;Ui!==null;){l=Ui;var u=l.sibling,h=l.return;if(ny(l),l===a){Ui=null;break e}if(u!==null){u.return=h,Ui=u;break e}Ui=h}}}var pk={getCacheForType:function(i){var r=Zi(bi),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Zi(bi).controller.signal}},mk=typeof WeakMap=="function"?WeakMap:Map,Ct=0,zt=null,pt=null,vt=0,Rt=0,Hn=null,Fs=!1,jo=!1,pp=!1,os=0,li=0,Ws=0,$a=0,mp=0,Un=0,zo=0,Ql=null,kn=null,gp=!1,od=0,py=0,ld=1/0,cd=null,qs=null,Ri=0,$s=null,Po=null,ls=0,vp=0,_p=null,my=null,Jl=0,bp=null;function Kn(){return(Ct&2)!==0&&vt!==0?vt&-vt:A.T!==null?kp():Ti()}function gy(){if(Un===0)if((vt&536870912)===0||bt){var i=st;st<<=1,(st&3932160)===0&&(st=262144),Un=i}else Un=536870912;return i=Pn.current,i!==null&&(i.flags|=32),Un}function En(i,r,a){(i===zt&&(Rt===2||Rt===9)||i.cancelPendingCommit!==null)&&(Io(i,0),Vs(i,vt,Un,!1)),Kt(i,a),((Ct&2)===0||i!==zt)&&(i===zt&&((Ct&2)===0&&($a|=a),li===4&&Vs(i,vt,Un,!1)),Br(i))}function vy(i,r,a){if((Ct&6)!==0)throw Error(s(327));var l=!a&&(r&127)===0&&(r&i.expiredLanes)===0||Ut(i,r),u=l?_k(i,r):Sp(i,r,!0),h=l;do{if(u===0){jo&&!l&&Vs(i,r,0,!1);break}else{if(a=i.current.alternate,h&&!gk(a)){u=Sp(i,r,!1),h=!1;continue}if(u===2){if(h=r,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){r=_;e:{var E=i;u=Ql;var N=E.current.memoizedState.isDehydrated;if(N&&(Io(E,_).flags|=256),_=Sp(E,_,!1),_!==2){if(pp&&!N){E.errorRecoveryDisabledLanes|=h,$a|=h,u=4;break e}h=kn,kn=u,h!==null&&(kn===null?kn=h:kn.push.apply(kn,h))}u=_}if(h=!1,u!==2)continue}}if(u===1){Io(i,0),Vs(i,r,0,!0);break}e:{switch(l=i,h=u,h){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:Vs(l,r,Un,!Fs);break e;case 2:kn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(u=od+300-Dt(),10<u)){if(Vs(l,r,Un,!Fs),Et(l,0,!0)!==0)break e;ls=r,l.timeoutHandle=Yy(_y.bind(null,l,a,kn,cd,gp,r,Un,$a,zo,Fs,h,"Throttled",-0,0),u);break e}_y(l,a,kn,cd,gp,r,Un,$a,zo,Fs,h,null,-0,0)}}break}while(!0);Br(i)}function _y(i,r,a,l,u,h,_,E,N,Y,ce,fe,Q,te){if(i.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cn},uy(r,h,fe);var Ie=(h&62914560)===h?od-Dt():(h&4194048)===h?py-Dt():0;if(Ie=eE(fe,Ie),Ie!==null){ls=h,i.cancelPendingCommit=Ie(Ey.bind(null,i,r,h,a,l,u,_,E,N,ce,fe,null,Q,te)),Vs(i,h,_,!Y);return}}Ey(i,r,h,a,l,u,_,E,N)}function gk(i){for(var r=i;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],h=u.getSnapshot;u=u.value;try{if(!lt(h(),u))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Vs(i,r,a,l){r&=~mp,r&=~$a,i.suspendedLanes|=r,i.pingedLanes&=~r,l&&(i.warmLanes|=r),l=i.expirationTimes;for(var u=r;0<u;){var h=31-kt(u),_=1<<h;l[h]=-1,u&=~_}a!==0&&ji(i,a,r)}function ud(){return(Ct&6)===0?(ec(0),!1):!0}function yp(){if(pt!==null){if(Rt===0)var i=pt.return;else i=pt,Zr=za=null,jf(i),Ro=null,jl=0,i=pt;for(;i!==null;)Xb(i.alternate,i),i=i.return;pt=null}}function Io(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,jk(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),ls=0,yp(),zt=i,pt=a=Xr(i.current,null),vt=r,Rt=0,Hn=null,Fs=!1,jo=Ut(i,r),pp=!1,zo=Un=mp=$a=Ws=li=0,kn=Ql=null,gp=!1,(r&8)!==0&&(r|=r&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=r;0<l;){var u=31-kt(l),h=1<<u;r|=i[u],l&=~h}return os=r,Nu(),a}function by(i,r){rt=null,A.H=Wl,r===Do||r===Iu?(r=O_(),Rt=3):r===xf?(r=O_(),Rt=4):Rt=r===Qf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Hn=r,pt===null&&(li=1,Ju(i,Gn(r,i.current)))}function yy(){var i=Pn.current;return i===null?!0:(vt&4194048)===vt?er===null:(vt&62914560)===vt||(vt&536870912)!==0?i===er:!1}function Sy(){var i=A.H;return A.H=Wl,i===null?Wl:i}function wy(){var i=A.A;return A.A=pk,i}function dd(){li=4,Fs||(vt&4194048)!==vt&&Pn.current!==null||(jo=!0),(Ws&134217727)===0&&($a&134217727)===0||zt===null||Vs(zt,vt,Un,!1)}function Sp(i,r,a){var l=Ct;Ct|=2;var u=Sy(),h=wy();(zt!==i||vt!==r)&&(cd=null,Io(i,r)),r=!1;var _=li;e:do try{if(Rt!==0&&pt!==null){var E=pt,N=Hn;switch(Rt){case 8:yp(),_=6;break e;case 3:case 2:case 9:case 6:Pn.current===null&&(r=!0);var Y=Rt;if(Rt=0,Hn=null,Ho(i,E,N,Y),a&&jo){_=0;break e}break;default:Y=Rt,Rt=0,Hn=null,Ho(i,E,N,Y)}}vk(),_=li;break}catch(ce){by(i,ce)}while(!0);return r&&i.shellSuspendCounter++,Zr=za=null,Ct=l,A.H=u,A.A=h,pt===null&&(zt=null,vt=0,Nu()),_}function vk(){for(;pt!==null;)Cy(pt)}function _k(i,r){var a=Ct;Ct|=2;var l=Sy(),u=wy();zt!==i||vt!==r?(cd=null,ld=Dt()+500,Io(i,r)):jo=Ut(i,r);e:do try{if(Rt!==0&&pt!==null){r=pt;var h=Hn;t:switch(Rt){case 1:Rt=0,Hn=null,Ho(i,r,h,1);break;case 2:case 9:if(L_(h)){Rt=0,Hn=null,xy(r);break}r=function(){Rt!==2&&Rt!==9||zt!==i||(Rt=7),Br(i)},h.then(r,r);break e;case 3:Rt=7;break e;case 4:Rt=5;break e;case 7:L_(h)?(Rt=0,Hn=null,xy(r)):(Rt=0,Hn=null,Ho(i,r,h,7));break;case 5:var _=null;switch(pt.tag){case 26:_=pt.memoizedState;case 5:case 27:var E=pt;if(_?cS(_):E.stateNode.complete){Rt=0,Hn=null;var N=E.sibling;if(N!==null)pt=N;else{var Y=E.return;Y!==null?(pt=Y,hd(Y)):pt=null}break t}}Rt=0,Hn=null,Ho(i,r,h,5);break;case 6:Rt=0,Hn=null,Ho(i,r,h,6);break;case 8:yp(),li=6;break e;default:throw Error(s(462))}}bk();break}catch(ce){by(i,ce)}while(!0);return Zr=za=null,A.H=l,A.A=u,Ct=a,pt!==null?0:(zt=null,vt=0,Nu(),li)}function bk(){for(;pt!==null&&!nt();)Cy(pt)}function Cy(i){var r=Vb(i.alternate,i,os);i.memoizedProps=i.pendingProps,r===null?hd(i):pt=r}function xy(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=Ub(a,r,r.pendingProps,r.type,void 0,vt);break;case 11:r=Ub(a,r,r.pendingProps,r.type.render,r.ref,vt);break;case 5:jf(r);default:Xb(a,r),r=pt=w_(r,os),r=Vb(a,r,os)}i.memoizedProps=i.pendingProps,r===null?hd(i):pt=r}function Ho(i,r,a,l){Zr=za=null,jf(r),Ro=null,jl=0;var u=r.return;try{if(ok(i,u,r,a,vt)){li=1,Ju(i,Gn(a,i.current)),pt=null;return}}catch(h){if(u!==null)throw pt=u,h;li=1,Ju(i,Gn(a,i.current)),pt=null;return}r.flags&32768?(bt||l===1?i=!0:jo||(vt&536870912)!==0?i=!1:(Fs=i=!0,(l===2||l===9||l===3||l===6)&&(l=Pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),ky(r,i)):hd(r)}function hd(i){var r=i;do{if((r.flags&32768)!==0){ky(r,Fs);return}i=r.return;var a=uk(r.alternate,r,os);if(a!==null){pt=a;return}if(r=r.sibling,r!==null){pt=r;return}pt=r=i}while(r!==null);li===0&&(li=5)}function ky(i,r){do{var a=dk(i.alternate,i);if(a!==null){a.flags&=32767,pt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){pt=i;return}pt=i=a}while(i!==null);li=6,pt=null}function Ey(i,r,a,l,u,h,_,E,N){i.cancelPendingCommit=null;do fd();while(Ri!==0);if((Ct&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(h=r.lanes|r.childLanes,h|=cf,Qt(i,a,h,_,E,N),i===zt&&(pt=zt=null,vt=0),Po=r,$s=i,ls=a,vp=h,_p=u,my=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Ck(ae,function(){return Ny(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=A.T,A.T=null,u=R.p,R.p=2,_=Ct,Ct|=4;try{hk(i,r,a)}finally{Ct=_,R.p=u,A.T=l}}Ri=1,Ty(),Dy(),Ry()}}function Ty(){if(Ri===1){Ri=0;var i=$s,r=Po,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=A.T,A.T=null;var l=R.p;R.p=2;var u=Ct;Ct|=4;try{oy(r,i);var h=Lp,_=Rl(i.containerInfo),E=h.focusedElem,N=h.selectionRange;if(_!==E&&E&&E.ownerDocument&&un(E.ownerDocument.documentElement,E)){if(N!==null&&Ml(E)){var Y=N.start,ce=N.end;if(ce===void 0&&(ce=Y),"selectionStart"in E)E.selectionStart=Y,E.selectionEnd=Math.min(ce,E.value.length);else{var fe=E.ownerDocument||document,Q=fe&&fe.defaultView||window;if(Q.getSelection){var te=Q.getSelection(),Ie=E.textContent.length,Xe=Math.min(N.start,Ie),Lt=N.end===void 0?Xe:Math.min(N.end,Ie);!te.extend&&Xe>Lt&&(_=Lt,Lt=Xe,Xe=_);var H=Sn(E,Xe),z=Sn(E,Lt);if(H&&z&&(te.rangeCount!==1||te.anchorNode!==H.node||te.anchorOffset!==H.offset||te.focusNode!==z.node||te.focusOffset!==z.offset)){var $=fe.createRange();$.setStart(H.node,H.offset),te.removeAllRanges(),Xe>Lt?(te.addRange($),te.extend(z.node,z.offset)):($.setEnd(z.node,z.offset),te.addRange($))}}}}for(fe=[],te=E;te=te.parentNode;)te.nodeType===1&&fe.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<fe.length;E++){var de=fe[E];de.element.scrollLeft=de.left,de.element.scrollTop=de.top}}kd=!!Ap,Lp=Ap=null}finally{Ct=u,R.p=l,A.T=a}}i.current=r,Ri=2}}function Dy(){if(Ri===2){Ri=0;var i=$s,r=Po,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=A.T,A.T=null;var l=R.p;R.p=2;var u=Ct;Ct|=4;try{iy(i,r.alternate,r)}finally{Ct=u,R.p=l,A.T=a}}Ri=3}}function Ry(){if(Ri===4||Ri===3){Ri=0,ht();var i=$s,r=Po,a=ls,l=my;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ri=5:(Ri=0,Po=$s=null,My(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(qs=null),Yi(a),r=r.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(xt,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=A.T,u=R.p,R.p=2,A.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var E=l[_];h(E.value,{componentStack:E.stack})}}finally{A.T=r,R.p=u}}(ls&3)!==0&&fd(),Br(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===bp?Jl++:(Jl=0,bp=i):Jl=0,ec(0)}}function My(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Bl(r)))}function fd(){return Ty(),Dy(),Ry(),Ny()}function Ny(){if(Ri!==5)return!1;var i=$s,r=vp;vp=0;var a=Yi(ls),l=A.T,u=R.p;try{R.p=32>a?32:a,A.T=null,a=_p,_p=null;var h=$s,_=ls;if(Ri=0,Po=$s=null,ls=0,(Ct&6)!==0)throw Error(s(331));var E=Ct;if(Ct|=4,hy(h.current),cy(h,h.current,_,a),Ct=E,ec(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(xt,h)}catch{}return!0}finally{R.p=u,A.T=l,My(i,r)}}function Ay(i,r,a){r=Gn(a,r),r=Zf(i.stateNode,r,2),i=Is(i,r,2),i!==null&&(Kt(i,2),Br(i))}function Mt(i,r,a){if(i.tag===3)Ay(i,i,a);else for(;r!==null;){if(r.tag===3){Ay(r,i,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(qs===null||!qs.has(l))){i=Gn(a,i),a=Lb(2),l=Is(r,a,2),l!==null&&(Bb(a,l,r,i),Kt(l,2),Br(l));break}}r=r.return}}function wp(i,r,a){var l=i.pingCache;if(l===null){l=i.pingCache=new mk;var u=new Set;l.set(r,u)}else u=l.get(r),u===void 0&&(u=new Set,l.set(r,u));u.has(a)||(pp=!0,u.add(a),i=yk.bind(null,i,r,a),r.then(i,i))}function yk(i,r,a){var l=i.pingCache;l!==null&&l.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,zt===i&&(vt&a)===a&&(li===4||li===3&&(vt&62914560)===vt&&300>Dt()-od?(Ct&2)===0&&Io(i,0):mp|=a,zo===vt&&(zo=0)),Br(i)}function Ly(i,r){r===0&&(r=Gt()),i=Ba(i,r),i!==null&&(Kt(i,r),Br(i))}function Sk(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Ly(i,a)}function wk(i,r){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(s(314))}l!==null&&l.delete(r),Ly(i,a)}function Ck(i,r){return ze(i,r)}var pd=null,Uo=null,Cp=!1,md=!1,xp=!1,Ys=0;function Br(i){i!==Uo&&i.next===null&&(Uo===null?pd=Uo=i:Uo=Uo.next=i),md=!0,Cp||(Cp=!0,kk())}function ec(i,r){if(!xp&&md){xp=!0;do for(var a=!1,l=pd;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var h=0;else{var _=l.suspendedLanes,E=l.pingedLanes;h=(1<<31-kt(42|i)+1)-1,h&=u&~(_&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,zy(l,h))}else h=vt,h=Et(l,l===zt?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||Ut(l,h)||(a=!0,zy(l,h));l=l.next}while(a);xp=!1}}function xk(){By()}function By(){md=Cp=!1;var i=0;Ys!==0&&Ok()&&(i=Ys);for(var r=Dt(),a=null,l=pd;l!==null;){var u=l.next,h=Oy(l,r);h===0?(l.next=null,a===null?pd=u:a.next=u,u===null&&(Uo=a)):(a=l,(i!==0||(h&3)!==0)&&(md=!0)),l=u}Ri!==0&&Ri!==5||ec(i),Ys!==0&&(Ys=0)}function Oy(i,r){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-kt(h),E=1<<_,N=u[_];N===-1?((E&a)===0||(E&l)!==0)&&(u[_]=ri(E,r)):N<=r&&(i.expiredLanes|=E),h&=~E}if(r=zt,a=vt,a=Et(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===r&&(Rt===2||Rt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ue(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Ut(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(l!==null&&Ue(l),Yi(a)){case 2:case 8:a=di;break;case 32:a=ae;break;case 268435456:a=Qe;break;default:a=ae}return l=jy.bind(null,i),a=ze(a,l),i.callbackPriority=r,i.callbackNode=a,r}return l!==null&&l!==null&&Ue(l),i.callbackPriority=2,i.callbackNode=null,2}function jy(i,r){if(Ri!==0&&Ri!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(fd()&&i.callbackNode!==a)return null;var l=vt;return l=Et(i,i===zt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(vy(i,l,r),Oy(i,Dt()),i.callbackNode!=null&&i.callbackNode===a?jy.bind(null,i):null)}function zy(i,r){if(fd())return null;vy(i,r,!0)}function kk(){zk(function(){(Ct&6)!==0?ze(ni,xk):By()})}function kp(){if(Ys===0){var i=Eo;i===0&&(i=We,We<<=1,(We&261888)===0&&(We=256)),Ys=i}return Ys}function Py(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Kr(""+i)}function Iy(i,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,i.id&&a.setAttribute("form",i.id),r.parentNode.insertBefore(a,r),i=new FormData(i),a.parentNode.removeChild(a),i}function Ek(i,r,a,l,u){if(r==="submit"&&a&&a.stateNode===u){var h=Py((u[Pi]||null).action),_=l.submitter;_&&(r=(r=_[Pi]||null)?Py(r.formAction):_.getAttribute("formAction"),r!==null&&(h=r,_=null));var E=new S("action","action",null,l,u);i.push({event:E,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ys!==0){var N=_?Iy(u,_):new FormData(u);qf(a,{pending:!0,data:N,method:u.method,action:h},null,N)}}else typeof h=="function"&&(E.preventDefault(),N=_?Iy(u,_):new FormData(u),qf(a,{pending:!0,data:N,method:u.method,action:h},h,N))},currentTarget:u}]})}}for(var Ep=0;Ep<lf.length;Ep++){var Tp=lf[Ep],Tk=Tp.toLowerCase(),Dk=Tp[0].toUpperCase()+Tp.slice(1);gr(Tk,"on"+Dk)}gr(g_,"onAnimationEnd"),gr(v_,"onAnimationIteration"),gr(__,"onAnimationStart"),gr("dblclick","onDoubleClick"),gr("focusin","onFocus"),gr("focusout","onBlur"),gr(Wx,"onTransitionRun"),gr(qx,"onTransitionStart"),gr($x,"onTransitionCancel"),gr(b_,"onTransitionEnd"),_n("onMouseEnter",["mouseout","mouseover"]),_n("onMouseLeave",["mouseout","mouseover"]),_n("onPointerEnter",["pointerout","pointerover"]),_n("onPointerLeave",["pointerout","pointerover"]),Nn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Nn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Nn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Nn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Nn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Nn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var tc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Rk=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(tc));function Hy(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var h=void 0;if(r)for(var _=l.length-1;0<=_;_--){var E=l[_],N=E.instance,Y=E.currentTarget;if(E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Y;try{h(u)}catch(ce){Mu(ce)}u.currentTarget=null,h=N}else for(_=0;_<l.length;_++){if(E=l[_],N=E.instance,Y=E.currentTarget,E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Y;try{h(u)}catch(ce){Mu(ce)}u.currentTarget=null,h=N}}}}function mt(i,r){var a=r[ya];a===void 0&&(a=r[ya]=new Set);var l=i+"__bubble";a.has(l)||(Uy(r,i,2,!1),a.add(l))}function Dp(i,r,a){var l=0;r&&(l|=4),Uy(a,i,l,r)}var gd="_reactListening"+Math.random().toString(36).slice(2);function Rp(i){if(!i[gd]){i[gd]=!0,ho.forEach(function(a){a!=="selectionchange"&&(Rk.has(a)||Dp(a,!1,i),Dp(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[gd]||(r[gd]=!0,Dp("selectionchange",!1,r))}}function Uy(i,r,a,l){switch(gS(r)){case 2:var u=nE;break;case 8:u=rE;break;default:u=Wp}a=u.bind(null,r,a,i),u=void 0,!Ea||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(r,a,{capture:!0,passive:u}):i.addEventListener(r,a,!0):u!==void 0?i.addEventListener(r,a,{passive:u}):i.addEventListener(r,a,!1)}function Mp(i,r,a,l,u){var h=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var E=l.stateNode.containerInfo;if(E===u)break;if(_===4)for(_=l.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;E!==null;){if(_=vi(E),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){l=h=_;continue e}E=E.parentNode}}l=l.return}Wr(function(){var Y=h,ce=Fr(a),fe=[];e:{var Q=y_.get(i);if(Q!==void 0){var te=S,Ie=i;switch(i){case"keypress":if(Dr(a)===0)break e;case"keydown":case"keyup":te=Jh;break;case"focusin":Ie="focus",te=$r;break;case"focusout":Ie="blur",te=$r;break;case"beforeblur":case"afterblur":te=$r;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":te=qe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":te=_i;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":te=ef;break;case g_:case v_:case __:te=Zh;break;case b_:te=nf;break;case"scroll":case"scrollend":te=j;break;case"wheel":te=Cl;break;case"copy":case"cut":case"paste":te=Vr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":te=vu;break;case"toggle":case"beforetoggle":te=yu}var Xe=(r&4)!==0,Lt=!Xe&&(i==="scroll"||i==="scrollend"),H=Xe?Q!==null?Q+"Capture":null:Q;Xe=[];for(var z=Y,$;z!==null;){var de=z;if($=de.stateNode,de=de.tag,de!==5&&de!==26&&de!==27||$===null||H===null||(de=qr(z,H),de!=null&&Xe.push(ic(z,de,$))),Lt)break;z=z.return}0<Xe.length&&(Q=new te(Q,Ie,null,a,ce),fe.push({event:Q,listeners:Xe}))}}if((r&7)===0){e:{if(Q=i==="mouseover"||i==="pointerover",te=i==="mouseout"||i==="pointerout",Q&&a!==Er&&(Ie=a.relatedTarget||a.fromElement)&&(vi(Ie)||Ie[$n]))break e;if((te||Q)&&(Q=ce.window===ce?ce:(Q=ce.ownerDocument)?Q.defaultView||Q.parentWindow:window,te?(Ie=a.relatedTarget||a.toElement,te=Y,Ie=Ie?vi(Ie):null,Ie!==null&&(Lt=c(Ie),Xe=Ie.tag,Ie!==Lt||Xe!==5&&Xe!==27&&Xe!==6)&&(Ie=null)):(te=null,Ie=Y),te!==Ie)){if(Xe=qe,de="onMouseLeave",H="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(Xe=vu,de="onPointerLeave",H="onPointerEnter",z="pointer"),Lt=te==null?Q:wr(te),$=Ie==null?Q:wr(Ie),Q=new Xe(de,z+"leave",te,a,ce),Q.target=Lt,Q.relatedTarget=$,de=null,vi(ce)===Y&&(Xe=new Xe(H,z+"enter",Ie,a,ce),Xe.target=$,Xe.relatedTarget=Lt,de=Xe),Lt=de,te&&Ie)t:{for(Xe=Mk,H=te,z=Ie,$=0,de=H;de;de=Xe(de))$++;de=0;for(var $e=z;$e;$e=Xe($e))de++;for(;0<$-de;)H=Xe(H),$--;for(;0<de-$;)z=Xe(z),de--;for(;$--;){if(H===z||z!==null&&H===z.alternate){Xe=H;break t}H=Xe(H),z=Xe(z)}Xe=null}else Xe=null;te!==null&&Ky(fe,Q,te,Xe,!1),Ie!==null&&Lt!==null&&Ky(fe,Lt,Ie,Xe,!0)}}e:{if(Q=Y?wr(Y):window,te=Q.nodeName&&Q.nodeName.toLowerCase(),te==="select"||te==="input"&&Q.type==="file")var yt=Du;else if(mr(Q))if(Ru)yt=Je;else{yt=Fe;var He=Ae}else te=Q.nodeName,!te||te.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?Y&&bn(Y.elementType)&&(yt=Du):yt=Ve;if(yt&&(yt=yt(i,Y))){Eu(fe,yt,a,ce);break e}He&&He(i,Q,Y),i==="focusout"&&Y&&Q.type==="number"&&Y.memoizedProps.value!=null&&xs(Q,"number",Q.value)}switch(He=Y?wr(Y):window,i){case"focusin":(mr(He)||He.contentEditable==="true")&&(Yr=He,_o=Y,Nl=null);break;case"focusout":Nl=_o=Yr=null;break;case"mousedown":af=!0;break;case"contextmenu":case"mouseup":case"dragend":af=!1,p_(fe,a,ce);break;case"selectionchange":if(Mr)break;case"keydown":case"keyup":p_(fe,a,ce)}var at;if(xl)e:{switch(i){case"compositionstart":var _t="onCompositionStart";break e;case"compositionend":_t="onCompositionEnd";break e;case"compositionupdate":_t="onCompositionUpdate";break e}_t=void 0}else As?Rr(i,a)&&(_t="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(_t="onCompositionStart");_t&&(kl&&a.locale!=="ko"&&(As||_t!=="onCompositionStart"?_t==="onCompositionEnd"&&As&&(at=Rs()):(yn=ce,Ta="value"in yn?yn.value:yn.textContent,As=!0)),He=vd(Y,_t),0<He.length&&(_t=new fu(_t,i,null,a,ce),fe.push({event:_t,listeners:He}),at?_t.data=at:(at=xu(a),at!==null&&(_t.data=at)))),(at=wu?ku(i,a):rf(i,a))&&(_t=vd(Y,"onBeforeInput"),0<_t.length&&(He=new fu("onBeforeInput","beforeinput",null,a,ce),fe.push({event:He,listeners:_t}),He.data=at)),Ek(fe,i,Y,a,ce)}Hy(fe,r)})}function ic(i,r,a){return{instance:i,listener:r,currentTarget:a}}function vd(i,r){for(var a=r+"Capture",l=[];i!==null;){var u=i,h=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||h===null||(u=qr(i,a),u!=null&&l.unshift(ic(i,u,h)),u=qr(i,r),u!=null&&l.push(ic(i,u,h))),i.tag===3)return l;i=i.return}return[]}function Mk(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Ky(i,r,a,l,u){for(var h=r._reactName,_=[];a!==null&&a!==l;){var E=a,N=E.alternate,Y=E.stateNode;if(E=E.tag,N!==null&&N===l)break;E!==5&&E!==26&&E!==27||Y===null||(N=Y,u?(Y=qr(a,h),Y!=null&&_.unshift(ic(a,Y,N))):u||(Y=qr(a,h),Y!=null&&_.push(ic(a,Y,N)))),a=a.return}_.length!==0&&i.push({event:r,listeners:_})}var Nk=/\r\n?/g,Ak=/\u0000|\uFFFD/g;function Fy(i){return(typeof i=="string"?i:""+i).replace(Nk,`
|
|
10
|
-
`).replace(Ak,"")}function Wy(i,r){return r=Fy(r),Fy(i)===r}function At(i,r,a,l,u,h){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||pr(i,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&pr(i,""+l);break;case"className":dr(i,"class",l);break;case"tabIndex":dr(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":dr(i,a,l);break;case"style":kr(i,l,h);break;case"data":if(r!=="object"){dr(i,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Kr(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(r!=="input"&&At(i,r,"name",u.name,u,null),At(i,r,"formEncType",u.formEncType,u,null),At(i,r,"formMethod",u.formMethod,u,null),At(i,r,"formTarget",u.formTarget,u,null)):(At(i,r,"encType",u.encType,u,null),At(i,r,"method",u.method,u,null),At(i,r,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Kr(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=cn);break;case"onScroll":l!=null&&mt("scroll",i);break;case"onScrollEnd":l!=null&&mt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=Kr(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":mt("beforetoggle",i),mt("toggle",i),Cr(i,"popover",l);break;case"xlinkActuate":An(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":An(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":An(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":An(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":An(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":An(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":An(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":An(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":An(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Cr(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=mo.get(a)||a,Cr(i,a,l))}}function Np(i,r,a,l,u,h){switch(a){case"style":kr(i,l,h);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof l=="string"?pr(i,l):(typeof l=="number"||typeof l=="bigint")&&pr(i,""+l);break;case"onScroll":l!=null&&mt("scroll",i);break;case"onScrollEnd":l!=null&&mt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ws.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),r=a.slice(2,u?a.length-7:void 0),h=i[Pi]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(r,h,u),typeof l=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(r,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Cr(i,a,l)}}}function Ji(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mt("error",i),mt("load",i);var l=!1,u=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:At(i,r,h,_,a,null)}}u&&At(i,r,"srcSet",a.srcSet,a,null),l&&At(i,r,"src",a.src,a,null);return;case"input":mt("invalid",i);var E=h=_=u=null,N=null,Y=null;for(l in a)if(a.hasOwnProperty(l)){var ce=a[l];if(ce!=null)switch(l){case"name":u=ce;break;case"type":_=ce;break;case"checked":N=ce;break;case"defaultChecked":Y=ce;break;case"value":h=ce;break;case"defaultValue":E=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,r));break;default:At(i,r,l,ce,a,null)}}fr(i,h,E,N,Y,_,u,!1);return;case"select":mt("invalid",i),l=_=h=null;for(u in a)if(a.hasOwnProperty(u)&&(E=a[u],E!=null))switch(u){case"value":h=E;break;case"defaultValue":_=E;break;case"multiple":l=E;default:At(i,r,u,E,a,null)}r=h,a=_,i.multiple=!!l,r!=null?ai(i,!!l,r,!1):a!=null&&ai(i,!!l,a,!0);return;case"textarea":mt("invalid",i),h=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(E=a[_],E!=null))switch(_){case"value":l=E;break;case"defaultValue":u=E;break;case"children":h=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(s(91));break;default:At(i,r,_,E,a,null)}xa(i,l,u,h);return;case"option":for(N in a)a.hasOwnProperty(N)&&(l=a[N],l!=null)&&(N==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":At(i,r,N,l,a,null));return;case"dialog":mt("beforetoggle",i),mt("toggle",i),mt("cancel",i),mt("close",i);break;case"iframe":case"object":mt("load",i);break;case"video":case"audio":for(l=0;l<tc.length;l++)mt(tc[l],i);break;case"image":mt("error",i),mt("load",i);break;case"details":mt("toggle",i);break;case"embed":case"source":case"link":mt("error",i),mt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Y in a)if(a.hasOwnProperty(Y)&&(l=a[Y],l!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:At(i,r,Y,l,a,null)}return;default:if(bn(r)){for(ce in a)a.hasOwnProperty(ce)&&(l=a[ce],l!==void 0&&Np(i,r,ce,l,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(l=a[E],l!=null&&At(i,r,E,l,a,null))}function Lk(i,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,h=null,_=null,E=null,N=null,Y=null,ce=null;for(te in a){var fe=a[te];if(a.hasOwnProperty(te)&&fe!=null)switch(te){case"checked":break;case"value":break;case"defaultValue":N=fe;default:l.hasOwnProperty(te)||At(i,r,te,null,l,fe)}}for(var Q in l){var te=l[Q];if(fe=a[Q],l.hasOwnProperty(Q)&&(te!=null||fe!=null))switch(Q){case"type":h=te;break;case"name":u=te;break;case"checked":Y=te;break;case"defaultChecked":ce=te;break;case"value":_=te;break;case"defaultValue":E=te;break;case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(s(137,r));break;default:te!==fe&&At(i,r,Q,te,l,fe)}}dt(i,_,E,N,Y,ce,h,u);return;case"select":te=_=E=Q=null;for(h in a)if(N=a[h],a.hasOwnProperty(h)&&N!=null)switch(h){case"value":break;case"multiple":te=N;default:l.hasOwnProperty(h)||At(i,r,h,null,l,N)}for(u in l)if(h=l[u],N=a[u],l.hasOwnProperty(u)&&(h!=null||N!=null))switch(u){case"value":Q=h;break;case"defaultValue":E=h;break;case"multiple":_=h;default:h!==N&&At(i,r,u,h,l,N)}r=E,a=_,l=te,Q!=null?ai(i,!!a,Q,!1):!!l!=!!a&&(r!=null?ai(i,!!a,r,!0):ai(i,!!a,a?[]:"",!1));return;case"textarea":te=Q=null;for(E in a)if(u=a[E],a.hasOwnProperty(E)&&u!=null&&!l.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:At(i,r,E,null,l,u)}for(_ in l)if(u=l[_],h=a[_],l.hasOwnProperty(_)&&(u!=null||h!=null))switch(_){case"value":Q=u;break;case"defaultValue":te=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==h&&At(i,r,_,u,l,h)}Ca(i,Q,te);return;case"option":for(var Ie in a)Q=a[Ie],a.hasOwnProperty(Ie)&&Q!=null&&!l.hasOwnProperty(Ie)&&(Ie==="selected"?i.selected=!1:At(i,r,Ie,null,l,Q));for(N in l)Q=l[N],te=a[N],l.hasOwnProperty(N)&&Q!==te&&(Q!=null||te!=null)&&(N==="selected"?i.selected=Q&&typeof Q!="function"&&typeof Q!="symbol":At(i,r,N,Q,l,te));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Xe in a)Q=a[Xe],a.hasOwnProperty(Xe)&&Q!=null&&!l.hasOwnProperty(Xe)&&At(i,r,Xe,null,l,Q);for(Y in l)if(Q=l[Y],te=a[Y],l.hasOwnProperty(Y)&&Q!==te&&(Q!=null||te!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(s(137,r));break;default:At(i,r,Y,Q,l,te)}return;default:if(bn(r)){for(var Lt in a)Q=a[Lt],a.hasOwnProperty(Lt)&&Q!==void 0&&!l.hasOwnProperty(Lt)&&Np(i,r,Lt,void 0,l,Q);for(ce in l)Q=l[ce],te=a[ce],!l.hasOwnProperty(ce)||Q===te||Q===void 0&&te===void 0||Np(i,r,ce,Q,l,te);return}}for(var H in a)Q=a[H],a.hasOwnProperty(H)&&Q!=null&&!l.hasOwnProperty(H)&&At(i,r,H,null,l,Q);for(fe in l)Q=l[fe],te=a[fe],!l.hasOwnProperty(fe)||Q===te||Q==null&&te==null||At(i,r,fe,Q,l,te)}function qy(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Bk(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],h=u.transferSize,_=u.initiatorType,E=u.duration;if(h&&E&&qy(_)){for(_=0,E=u.responseEnd,l+=1;l<a.length;l++){var N=a[l],Y=N.startTime;if(Y>E)break;var ce=N.transferSize,fe=N.initiatorType;ce&&qy(fe)&&(N=N.responseEnd,_+=ce*(N<E?1:(E-Y)/(N-Y)))}if(--l,r+=8*(h+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Ap=null,Lp=null;function _d(i){return i.nodeType===9?i:i.ownerDocument}function $y(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Vy(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function Bp(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Op=null;function Ok(){var i=window.event;return i&&i.type==="popstate"?i===Op?!1:(Op=i,!0):(Op=null,!1)}var Yy=typeof setTimeout=="function"?setTimeout:void 0,jk=typeof clearTimeout=="function"?clearTimeout:void 0,Xy=typeof Promise=="function"?Promise:void 0,zk=typeof queueMicrotask=="function"?queueMicrotask:typeof Xy<"u"?function(i){return Xy.resolve(null).then(i).catch(Pk)}:Yy;function Pk(i){setTimeout(function(){throw i})}function Xs(i){return i==="head"}function Gy(i,r){var a=r,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),qo(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")nc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,nc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,E=h.nodeName;h[It]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&nc(i.ownerDocument.body);a=u}while(a);qo(r)}function Zy(i,r){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function jp(i){var r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":jp(a),ln(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Ik(i,r,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[It])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var h=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=tr(i.nextSibling),i===null)break}return null}function Hk(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=tr(i.nextSibling),i===null))return null;return i}function Qy(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=tr(i.nextSibling),i===null))return null;return i}function zp(i){return i.data==="$?"||i.data==="$~"}function Pp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Uk(i,r){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function tr(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var Ip=null;function Jy(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return tr(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function eS(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return i;r--}else a!=="/$"&&a!=="/&"||r++}i=i.previousSibling}return null}function tS(i,r,a){switch(r=_d(a),i){case"html":if(i=r.documentElement,!i)throw Error(s(452));return i;case"head":if(i=r.head,!i)throw Error(s(453));return i;case"body":if(i=r.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function nc(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);ln(i)}var ir=new Map,iS=new Set;function bd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var cs=R.d;R.d={f:Kk,r:Fk,D:Wk,C:qk,L:$k,m:Vk,X:Xk,S:Yk,M:Gk};function Kk(){var i=cs.f(),r=ud();return i||r}function Fk(i){var r=Yn(i);r!==null&&r.tag===5&&r.type==="form"?bb(r):cs.r(i)}var Ko=typeof document>"u"?null:document;function nS(i,r,a){var l=Ko;if(l&&typeof r=="string"&&r){var u=Ii(r);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),iS.has(u)||(iS.add(u),i={rel:i,crossOrigin:a,href:r},l.querySelector(u)===null&&(r=l.createElement("link"),Ji(r,"link",i),$t(r),l.head.appendChild(r)))}}function Wk(i){cs.D(i),nS("dns-prefetch",i,null)}function qk(i,r){cs.C(i,r),nS("preconnect",i,r)}function $k(i,r,a){cs.L(i,r,a);var l=Ko;if(l&&i&&r){var u='link[rel="preload"][as="'+Ii(r)+'"]';r==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Ii(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Ii(a.imageSizes)+'"]')):u+='[href="'+Ii(i)+'"]';var h=u;switch(r){case"style":h=Fo(i);break;case"script":h=Wo(i)}ir.has(h)||(i=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),ir.set(h,i),l.querySelector(u)!==null||r==="style"&&l.querySelector(rc(h))||r==="script"&&l.querySelector(sc(h))||(r=l.createElement("link"),Ji(r,"link",i),$t(r),l.head.appendChild(r)))}}function Vk(i,r){cs.m(i,r);var a=Ko;if(a&&i){var l=r&&typeof r.as=="string"?r.as:"script",u='link[rel="modulepreload"][as="'+Ii(l)+'"][href="'+Ii(i)+'"]',h=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Wo(i)}if(!ir.has(h)&&(i=b({rel:"modulepreload",href:i},r),ir.set(h,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(sc(h)))return}l=a.createElement("link"),Ji(l,"link",i),$t(l),a.head.appendChild(l)}}}function Yk(i,r,a){cs.S(i,r,a);var l=Ko;if(l&&i){var u=vn(l).hoistableStyles,h=Fo(i);r=r||"default";var _=u.get(h);if(!_){var E={loading:0,preload:null};if(_=l.querySelector(rc(h)))E.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":r},a),(a=ir.get(h))&&Hp(i,a);var N=_=l.createElement("link");$t(N),Ji(N,"link",i),N._p=new Promise(function(Y,ce){N.onload=Y,N.onerror=ce}),N.addEventListener("load",function(){E.loading|=1}),N.addEventListener("error",function(){E.loading|=2}),E.loading|=4,yd(_,r,l)}_={type:"stylesheet",instance:_,count:1,state:E},u.set(h,_)}}}function Xk(i,r){cs.X(i,r);var a=Ko;if(a&&i){var l=vn(a).hoistableScripts,u=Wo(i),h=l.get(u);h||(h=a.querySelector(sc(u)),h||(i=b({src:i,async:!0},r),(r=ir.get(u))&&Up(i,r),h=a.createElement("script"),$t(h),Ji(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function Gk(i,r){cs.M(i,r);var a=Ko;if(a&&i){var l=vn(a).hoistableScripts,u=Wo(i),h=l.get(u);h||(h=a.querySelector(sc(u)),h||(i=b({src:i,async:!0,type:"module"},r),(r=ir.get(u))&&Up(i,r),h=a.createElement("script"),$t(h),Ji(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function rS(i,r,a,l){var u=(u=Ee.current)?bd(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Fo(a.href),a=vn(u).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Fo(a.href);var h=vn(u).hoistableStyles,_=h.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=u.querySelector(rc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),ir.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ir.set(i,a),h||Zk(u,i,a,_.state))),r&&l===null)throw Error(s(528,""));return _}if(r&&l!==null)throw Error(s(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Wo(a),a=vn(u).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Fo(i){return'href="'+Ii(i)+'"'}function rc(i){return'link[rel="stylesheet"]['+i+"]"}function sS(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function Zk(i,r,a,l){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=i.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),Ji(r,"link",a),$t(r),i.head.appendChild(r))}function Wo(i){return'[src="'+Ii(i)+'"]'}function sc(i){return"script[async]"+i}function aS(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=i.querySelector('style[data-href~="'+Ii(a.href)+'"]');if(l)return r.instance=l,$t(l),l;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),$t(l),Ji(l,"style",u),yd(l,a.precedence,i),r.instance=l;case"stylesheet":u=Fo(a.href);var h=i.querySelector(rc(u));if(h)return r.state.loading|=4,r.instance=h,$t(h),h;l=sS(a),(u=ir.get(u))&&Hp(l,u),h=(i.ownerDocument||i).createElement("link"),$t(h);var _=h;return _._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),Ji(h,"link",l),r.state.loading|=4,yd(h,a.precedence,i),r.instance=h;case"script":return h=Wo(a.src),(u=i.querySelector(sc(h)))?(r.instance=u,$t(u),u):(l=a,(u=ir.get(h))&&(l=b({},a),Up(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),$t(u),Ji(u,"link",l),i.head.appendChild(u),r.instance=u);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,yd(l,a.precedence,i));return r.instance}function yd(i,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,h=u,_=0;_<l.length;_++){var E=l[_];if(E.dataset.precedence===r)h=E;else if(h!==u)break}h?h.parentNode.insertBefore(i,h.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function Hp(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Up(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var Sd=null;function oS(i,r,a){if(Sd===null){var l=new Map,u=Sd=new Map;u.set(a,l)}else u=Sd,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var h=a[u];if(!(h[It]||h[si]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(r)||"";_=i+_;var E=l.get(_);E?E.push(h):l.set(_,[h])}}return l}function lS(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function Qk(i,r,a){if(a===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(i=r.disabled,typeof r.precedence=="string"&&i==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function cS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Jk(i,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=Fo(l.href),h=r.querySelector(rc(u));if(h){r=h._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=wd.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=h,$t(h);return}h=r.ownerDocument||r,l=sS(l),(u=ir.get(u))&&Hp(l,u),h=h.createElement("link"),$t(h);var _=h;_._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),Ji(h,"link",l),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=wd.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Kp=0;function eE(i,r){return i.stylesheets&&i.count===0&&xd(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&xd(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+r);0<i.imgBytes&&Kp===0&&(Kp=62500*Bk());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&xd(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>Kp?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function wd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Cd=null;function xd(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Cd=new Map,r.forEach(tE,i),Cd=null,wd.call(i))}function tE(i,r){if(!(r.state.loading&4)){var a=Cd.get(i);if(a)var l=a.get(null);else{a=new Map,Cd.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<u.length;h++){var _=u[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=r.instance,_=u.getAttribute("data-precedence"),h=a.get(_)||l,h===l&&a.set(null,u),a.set(_,u),this.count++,l=wd.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),h?h.parentNode.insertBefore(u,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),r.state.loading|=4}}var ac={$$typeof:X,Provider:null,Consumer:null,_currentValue:P,_currentValue2:P,_threadCount:0};function iE(i,r,a,l,u,h,_,E,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Zt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zt(0),this.hiddenUpdates=Zt(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function uS(i,r,a,l,u,h,_,E,N,Y,ce,fe){return i=new iE(i,r,a,_,N,Y,ce,fe,E),r=1,h===!0&&(r|=24),h=zn(3,null,null,r),i.current=h,h.stateNode=i,r=Sf(),r.refCount++,i.pooledCache=r,r.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:r},kf(h),i}function dS(i){return i?(i=So,i):So}function hS(i,r,a,l,u,h){u=dS(u),l.context===null?l.context=u:l.pendingContext=u,l=Ps(r),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=Is(i,l,r),a!==null&&(En(a,i,r),Pl(a,i,r))}function fS(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Fp(i,r){fS(i,r),(i=i.alternate)&&fS(i,r)}function pS(i){if(i.tag===13||i.tag===31){var r=Ba(i,67108864);r!==null&&En(r,i,67108864),Fp(i,67108864)}}function mS(i){if(i.tag===13||i.tag===31){var r=Kn();r=gn(r);var a=Ba(i,r);a!==null&&En(a,i,r),Fp(i,r)}}var kd=!0;function nE(i,r,a,l){var u=A.T;A.T=null;var h=R.p;try{R.p=2,Wp(i,r,a,l)}finally{R.p=h,A.T=u}}function rE(i,r,a,l){var u=A.T;A.T=null;var h=R.p;try{R.p=8,Wp(i,r,a,l)}finally{R.p=h,A.T=u}}function Wp(i,r,a,l){if(kd){var u=qp(l);if(u===null)Mp(i,r,l,Ed,a),vS(i,l);else if(aE(u,i,r,a,l))l.stopPropagation();else if(vS(i,l),r&4&&-1<sE.indexOf(i)){for(;u!==null;){var h=Yn(u);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=wt(h.pendingLanes);if(_!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;_;){var N=1<<31-kt(_);E.entanglements[1]|=N,_&=~N}Br(h),(Ct&6)===0&&(ld=Dt()+500,ec(0))}}break;case 31:case 13:E=Ba(h,2),E!==null&&En(E,h,2),ud(),Fp(h,2)}if(h=qp(l),h===null&&Mp(i,r,l,Ed,a),h===u)break;u=h}u!==null&&l.stopPropagation()}else Mp(i,r,l,null,a)}}function qp(i){return i=Fr(i),$p(i)}var Ed=null;function $p(i){if(Ed=null,i=vi(i),i!==null){var r=c(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=d(r),i!==null)return i;i=null}else if(a===31){if(i=m(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return Ed=i,null}function gS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ei()){case ni:return 2;case di:return 8;case ae:case Ne:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var Vp=!1,Gs=null,Zs=null,Qs=null,oc=new Map,lc=new Map,Js=[],sE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function vS(i,r){switch(i){case"focusin":case"focusout":Gs=null;break;case"dragenter":case"dragleave":Zs=null;break;case"mouseover":case"mouseout":Qs=null;break;case"pointerover":case"pointerout":oc.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":lc.delete(r.pointerId)}}function cc(i,r,a,l,u,h){return i===null||i.nativeEvent!==h?(i={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[u]},r!==null&&(r=Yn(r),r!==null&&pS(r)),i):(i.eventSystemFlags|=l,r=i.targetContainers,u!==null&&r.indexOf(u)===-1&&r.push(u),i)}function aE(i,r,a,l,u){switch(r){case"focusin":return Gs=cc(Gs,i,r,a,l,u),!0;case"dragenter":return Zs=cc(Zs,i,r,a,l,u),!0;case"mouseover":return Qs=cc(Qs,i,r,a,l,u),!0;case"pointerover":var h=u.pointerId;return oc.set(h,cc(oc.get(h)||null,i,r,a,l,u)),!0;case"gotpointercapture":return h=u.pointerId,lc.set(h,cc(lc.get(h)||null,i,r,a,l,u)),!0}return!1}function _S(i){var r=vi(i.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=d(a),r!==null){i.blockedOn=r,on(i.priority,function(){mS(a)});return}}else if(r===31){if(r=m(a),r!==null){i.blockedOn=r,on(i.priority,function(){mS(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Td(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=qp(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Er=l,a.target.dispatchEvent(l),Er=null}else return r=Yn(a),r!==null&&pS(r),i.blockedOn=a,!1;r.shift()}return!0}function bS(i,r,a){Td(i)&&a.delete(r)}function oE(){Vp=!1,Gs!==null&&Td(Gs)&&(Gs=null),Zs!==null&&Td(Zs)&&(Zs=null),Qs!==null&&Td(Qs)&&(Qs=null),oc.forEach(bS),lc.forEach(bS)}function Dd(i,r){i.blockedOn===r&&(i.blockedOn=null,Vp||(Vp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,oE)))}var Rd=null;function yS(i){Rd!==i&&(Rd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Rd===i&&(Rd=null);for(var r=0;r<i.length;r+=3){var a=i[r],l=i[r+1],u=i[r+2];if(typeof l!="function"){if($p(l||a)===null)continue;break}var h=Yn(a);h!==null&&(i.splice(r,3),r-=3,qf(h,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function qo(i){function r(N){return Dd(N,i)}Gs!==null&&Dd(Gs,i),Zs!==null&&Dd(Zs,i),Qs!==null&&Dd(Qs,i),oc.forEach(r),lc.forEach(r);for(var a=0;a<Js.length;a++){var l=Js[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Js.length&&(a=Js[0],a.blockedOn===null);)_S(a),a.blockedOn===null&&Js.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],h=a[l+1],_=u[Pi]||null;if(typeof h=="function")_||yS(a);else if(_){var E=null;if(h&&h.hasAttribute("formAction")){if(u=h,_=h[Pi]||null)E=_.formAction;else if($p(u)!==null)continue}else E=_.action;typeof E=="function"?a[l+1]=E:(a.splice(l,3),l-=3),yS(a)}}}function SS(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function r(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),u!==null&&(u(),u=null)}}}function Yp(i){this._internalRoot=i}Md.prototype.render=Yp.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,l=Kn();hS(a,l,i,r,null,null)},Md.prototype.unmount=Yp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;hS(i.current,2,null,i,null,null),ud(),r[$n]=null}};function Md(i){this._internalRoot=i}Md.prototype.unstable_scheduleHydration=function(i){if(i){var r=Ti();i={blockedOn:null,target:i,priority:r};for(var a=0;a<Js.length&&r!==0&&r<Js[a].priority;a++);Js.splice(a,0,i),a===0&&_S(i)}};var wS=t.version;if(wS!=="19.2.6")throw Error(s(527,wS,"19.2.6"));R.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(r),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var lE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nd.isDisabled&&Nd.supportsFiber)try{xt=Nd.inject(lE),gt=Nd}catch{}}return dc.createRoot=function(i,r){if(!o(i))throw Error(s(299));var a=!1,l="",u=Rb,h=Mb,_=Nb;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(u=r.onUncaughtError),r.onCaughtError!==void 0&&(h=r.onCaughtError),r.onRecoverableError!==void 0&&(_=r.onRecoverableError)),r=uS(i,1,!1,null,null,a,l,null,u,h,_,SS),i[$n]=r.current,Rp(i),new Yp(r)},dc.hydrateRoot=function(i,r,a){if(!o(i))throw Error(s(299));var l=!1,u="",h=Rb,_=Mb,E=Nb,N=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(E=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),r=uS(i,1,!0,r,a??null,l,u,N,h,_,E,SS),r.context=dS(null),a=r.current,l=Kn(),l=gn(l),u=Ps(l),u.callback=null,Is(a,u,l),a=l,r.current.lanes=a,Kt(r,a),Br(r),i[$n]=r.current,Rp(i),new Md(r)},dc.version="19.2.6",dc}var AS;function _E(){if(AS)return Zp.exports;AS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Zp.exports=vE(),Zp.exports}var bE=_E();class or extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Mh(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${ca(t)}`),setupPassword:t=>De(e,"/api/auth/password",Ge("POST",t)),login:t=>De(e,"/api/auth/login",Ge("POST",t)),reauth:t=>De(e,"/api/auth/reauth",Ge("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",Ge("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",Ge("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Xo(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",Ge("POST",t)),removeNetwork:async t=>{await Xo(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",Ge("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",Ge("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,Ge("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",Ge("PATCH",{name:t})),removeAgent:async t=>{await Xo(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${ca(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",Ge("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",Ge("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",Ge("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",Ge("POST",t)),listFiles:t=>De(e,"/api/files/list",Ge("POST",t)),readFile:t=>De(e,"/api/files/read",Ge("POST",t)),writeFile:t=>De(e,"/api/files/write",Ge("POST",t)),createFileEntry:t=>De(e,"/api/files/create",Ge("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",Ge("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",Ge("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",Ge("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",Ge("POST",t)),previewFile:t=>Yw(e,"/api/files/preview",Ge("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",Ge("POST",t)),closeTerminal:async t=>{await Xo(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,Ge("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${ca(n)}`),getTerminalTranscriptHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${ca(n)}`),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",Ge("PUT",t)),deleteNotificationAsset:async t=>{await Xo(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?ca({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",Ge("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",Ge("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",Ge("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",Ge("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",Ge("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",Ge("POST",t))}}function rl(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(s={})=>De(t,n("terminals"),Ge("POST",s)),closeTerminal:async s=>{await Xo(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>De(t,n(`terminals/${encodeURIComponent(s)}`),Ge("PATCH",{title:o})),getTerminalHistory:(s,o={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${ca(o)}`),getTerminalTranscriptHistory:(s,o={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${ca(o)}`),getTerminalTranscriptSource:s=>De(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:s=>De(t,n("terminal-layout"),Ge("PUT",s)),createFileRoot:s=>De(t,n("files/root"),Ge("POST",s)),listFiles:s=>De(t,n("files/list"),Ge("POST",s)),readFile:s=>De(t,n("files/read"),Ge("POST",s)),writeFile:s=>De(t,n("files/write"),Ge("POST",s)),createFileEntry:s=>De(t,n("files/create"),Ge("POST",s)),moveFileEntry:s=>De(t,n("files/move"),Ge("POST",s)),previewDeleteFileEntry:s=>De(t,n("files/delete-preview"),Ge("POST",s)),deleteFileEntry:s=>De(t,n("files/delete"),Ge("POST",s)),openFileInTerminal:s=>De(t,n("files/open"),Ge("POST",s)),previewFile:s=>Yw(t,n("files/preview"),Ge("POST",s)),getCodeServerStatus:(s={})=>De(t,`${n("code-server/status")}${ca(s)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>De(t,n("code-server/open"),Ge("POST",s)),stopCodeServer:(s={})=>De(t,n("code-server/stop"),Ge("POST",s)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,o=window.location.href)=>yE(n(`terminals/${encodeURIComponent(s)}/ws`),o)}}function yE(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function Ge(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function ca(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function De(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await bv(s);try{return await s.json()}catch{throw new or(s.status,"invalid_json_response")}}async function Xo(e,t,n){const s=await e(t,n);await bv(s)}async function Yw(e,t,n){const s=await e(t,n);return await bv(s),s.blob()}async function bv(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),s=typeof n.error=="string"?n.error:n.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new or(e.status,t)}const yv="nterminal.theme.id",Xw="nterminal.theme.accent",zm="nterminal:theme",lh=[{id:"midnight",label:"Midnight",description:"Current dark terminal look with aqua focus.",mode:"dark",tokens:{bg:"#0a0d10",bg2:"#0d1216",bgSidebar:"#08090b",line:"#1a2128",line2:"#2a3340",fg:"#e2e8ee",fg2:"#8896a3",fg3:"#54616d",fg4:"#3f4a54",accent:"#5eead4",accentSoft:"rgba(94, 234, 212, 0.10)",accentGlow:"rgba(94, 234, 212, 0.55)",onAccent:"#062423",ok:"#34d399",danger:"#f87171",onDanger:"#190607",dangerSoft:"rgba(248, 113, 113, 0.08)",dangerLine:"rgba(248, 113, 113, 0.30)",warning:"#fbbf24",warningSoft:"rgba(247, 217, 119, 0.075)",warningGlow:"rgba(245, 158, 11, 0.55)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.35)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(10, 13, 16, 0.86)",floatingBgStrong:"rgba(10, 13, 16, 0.96)",floatingBgHover:"rgba(15, 23, 27, 0.94)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.015)",scrollbarThumb:"rgba(148, 163, 184, 0.50)",scrollbarThumbHover:"rgba(148, 163, 184, 0.70)",transcriptUser:"#f7d977",transcriptAssistant:"#5eead4",transcriptTool:"#9aa7b4",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f7d977",transcriptOnSearch:"#121417",qrBg:"#ffffff"},xterm:{background:"#0a0d10",foreground:"#e2e8ee",cursor:"#5eead4",selectionBackground:"#1f3f45"}},{id:"daylight",label:"Daylight",description:"Light workspace with dark terminal contrast.",mode:"light",tokens:{bg:"#f7f9fc",bg2:"#ffffff",bgSidebar:"#eef2f7",line:"#dbe3ec",line2:"#c3cedb",fg:"#17212b",fg2:"#526170",fg3:"#7b8794",fg4:"#a1acb8",accent:"#0f8f83",accentSoft:"rgba(15, 143, 131, 0.11)",accentGlow:"rgba(15, 143, 131, 0.24)",onAccent:"#021918",ok:"#16835c",danger:"#c03545",onDanger:"#fff7f8",dangerSoft:"rgba(192, 53, 69, 0.10)",dangerLine:"rgba(192, 53, 69, 0.30)",warning:"#b7791f",warningSoft:"rgba(183, 121, 31, 0.12)",warningGlow:"rgba(183, 121, 31, 0.26)",scrim:"rgba(15, 23, 42, 0.34)",scrimSoft:"rgba(15, 23, 42, 0.20)",shadow:"rgba(15, 23, 42, 0.18)",shadowStrong:"rgba(15, 23, 42, 0.28)",floatingBg:"rgba(255, 255, 255, 0.92)",floatingBgStrong:"rgba(255, 255, 255, 0.98)",floatingBgHover:"rgba(239, 246, 249, 0.96)",subtleFill:"rgba(15, 23, 42, 0.025)",hoverFill:"rgba(15, 23, 42, 0.035)",scrollbarThumb:"rgba(82, 97, 112, 0.38)",scrollbarThumbHover:"rgba(82, 97, 112, 0.58)",transcriptUser:"#8b3f75",transcriptAssistant:"#0f8f83",transcriptTool:"#66717d",transcriptCommand:"#0b6fa4",transcriptCode:"#075985",transcriptSearch:"#f0c14b",transcriptOnSearch:"#1f1a10",qrBg:"#ffffff"},xterm:{background:"#ffffff",foreground:"#17212b",cursor:"#0f8f83",selectionBackground:"#cdeee9",...LS({foreground:"#17212b",foregroundMuted:"#526170",line:"#dbe3ec",red:"#b4232f",green:"#16794f",yellow:"#9a6700",blue:"#0b6fa4",magenta:"#8f3f85",cyan:"#0f766e"})}},{id:"signal-red",label:"Signal",description:"Dark control-room surface with red alerts.",mode:"dark",tokens:{bg:"#100d0f",bg2:"#171113",bgSidebar:"#0b080a",line:"#2a1b20",line2:"#452b32",fg:"#f1e7e9",fg2:"#a58d93",fg3:"#765f66",fg4:"#55434a",accent:"#ff2a3d",accentSoft:"rgba(255, 42, 61, 0.12)",accentGlow:"rgba(255, 42, 61, 0.52)",onAccent:"#210407",ok:"#34d399",danger:"#ff4d5f",onDanger:"#210407",dangerSoft:"rgba(255, 77, 95, 0.10)",dangerLine:"rgba(255, 77, 95, 0.32)",warning:"#fbbf24",warningSoft:"rgba(251, 191, 36, 0.10)",warningGlow:"rgba(245, 158, 11, 0.50)",scrim:"rgba(0, 0, 0, 0.58)",scrimSoft:"rgba(0, 0, 0, 0.30)",shadow:"rgba(0, 0, 0, 0.36)",shadowStrong:"rgba(0, 0, 0, 0.52)",floatingBg:"rgba(16, 13, 15, 0.88)",floatingBgStrong:"rgba(16, 13, 15, 0.96)",floatingBgHover:"rgba(25, 16, 19, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(165, 141, 147, 0.45)",scrollbarThumbHover:"rgba(165, 141, 147, 0.65)",transcriptUser:"#f8d36f",transcriptAssistant:"#ff2a3d",transcriptTool:"#ad9ca2",transcriptCommand:"#ff9ca6",transcriptCode:"#ffd1d6",transcriptSearch:"#f8d36f",transcriptOnSearch:"#1b0e10",qrBg:"#ffffff"},xterm:{background:"#100d0f",foreground:"#f1e7e9",cursor:"#ff2a3d",selectionBackground:"#4a1b22"}},{id:"graphite",label:"Graphite",description:"Neutral dark theme with blue command focus.",mode:"dark",tokens:{bg:"#101214",bg2:"#171a1d",bgSidebar:"#0c0e10",line:"#262b30",line2:"#39414a",fg:"#eceff3",fg2:"#9aa4af",fg3:"#6c7680",fg4:"#4d5660",accent:"#7dd3fc",accentSoft:"rgba(125, 211, 252, 0.11)",accentGlow:"rgba(125, 211, 252, 0.38)",onAccent:"#071c26",ok:"#4ade80",danger:"#fb7185",onDanger:"#26070d",dangerSoft:"rgba(251, 113, 133, 0.09)",dangerLine:"rgba(251, 113, 133, 0.30)",warning:"#facc15",warningSoft:"rgba(250, 204, 21, 0.09)",warningGlow:"rgba(250, 204, 21, 0.42)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.34)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(16, 18, 20, 0.88)",floatingBgStrong:"rgba(16, 18, 20, 0.96)",floatingBgHover:"rgba(22, 28, 33, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(154, 164, 175, 0.45)",scrollbarThumbHover:"rgba(154, 164, 175, 0.65)",transcriptUser:"#f2d675",transcriptAssistant:"#7dd3fc",transcriptTool:"#aab4bf",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f2d675",transcriptOnSearch:"#141513",qrBg:"#ffffff"},xterm:{background:"#101214",foreground:"#eceff3",cursor:"#7dd3fc",selectionBackground:"#263d4b"}},{id:"paper",label:"Paper",description:"Warm light surface with restrained amber accent.",mode:"light",tokens:{bg:"#fbfaf7",bg2:"#ffffff",bgSidebar:"#f2f0ea",line:"#e2ddd4",line2:"#cbc3b6",fg:"#25211d",fg2:"#62584e",fg3:"#8d8275",fg4:"#afa69b",accent:"#a35d00",accentSoft:"rgba(163, 93, 0, 0.11)",accentGlow:"rgba(163, 93, 0, 0.24)",onAccent:"#fffaf2",ok:"#26744d",danger:"#b23a48",onDanger:"#fff8f8",dangerSoft:"rgba(178, 58, 72, 0.10)",dangerLine:"rgba(178, 58, 72, 0.30)",warning:"#a35d00",warningSoft:"rgba(163, 93, 0, 0.12)",warningGlow:"rgba(163, 93, 0, 0.26)",scrim:"rgba(37, 33, 29, 0.32)",scrimSoft:"rgba(37, 33, 29, 0.18)",shadow:"rgba(37, 33, 29, 0.18)",shadowStrong:"rgba(37, 33, 29, 0.28)",floatingBg:"rgba(255, 253, 249, 0.92)",floatingBgStrong:"rgba(255, 253, 249, 0.98)",floatingBgHover:"rgba(250, 247, 240, 0.96)",subtleFill:"rgba(37, 33, 29, 0.025)",hoverFill:"rgba(37, 33, 29, 0.035)",scrollbarThumb:"rgba(98, 88, 78, 0.35)",scrollbarThumbHover:"rgba(98, 88, 78, 0.55)",transcriptUser:"#7b3f8c",transcriptAssistant:"#a35d00",transcriptTool:"#776d63",transcriptCommand:"#176a94",transcriptCode:"#6f4b00",transcriptSearch:"#e9c46a",transcriptOnSearch:"#241b0a",qrBg:"#ffffff"},xterm:{background:"#fffdf9",foreground:"#25211d",cursor:"#a35d00",selectionBackground:"#f2dfc5",...LS({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],sl="midnight";function Nh(e){return lh.some(t=>t.id===e)?e:sl}function Sv(e){return lh.find(t=>t.id===e)??lh[0]}function pa(){if(typeof window>"u")return sl;try{const e=window.localStorage.getItem(yv);return e?Nh(e):kE(window.localStorage.getItem(Xw))}catch{return sl}}function SE(e){const t=Nh(e);if(typeof window<"u"){try{window.localStorage.setItem(yv,t)}catch{}wv(t),window.dispatchEvent(new CustomEvent(zm,{detail:t}))}return t}function wv(e=pa()){if(typeof document>"u")return;const t=Sv(Nh(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),ot(n,"--nt-bg",t.tokens.bg),ot(n,"--nt-bg-2",t.tokens.bg2),ot(n,"--nt-bg-sidebar",t.tokens.bgSidebar),ot(n,"--nt-line",t.tokens.line),ot(n,"--nt-line-2",t.tokens.line2),ot(n,"--nt-fg",t.tokens.fg),ot(n,"--nt-fg-2",t.tokens.fg2),ot(n,"--nt-fg-3",t.tokens.fg3),ot(n,"--nt-fg-4",t.tokens.fg4),ot(n,"--nt-accent",t.tokens.accent),ot(n,"--nt-accent-soft",t.tokens.accentSoft),ot(n,"--nt-accent-glow",t.tokens.accentGlow),ot(n,"--nt-on-accent",t.tokens.onAccent),ot(n,"--nt-ok",t.tokens.ok),ot(n,"--nt-danger",t.tokens.danger),ot(n,"--nt-on-danger",t.tokens.onDanger),ot(n,"--nt-danger-soft",t.tokens.dangerSoft),ot(n,"--nt-danger-line",t.tokens.dangerLine),ot(n,"--nt-warning",t.tokens.warning),ot(n,"--nt-warn",t.tokens.warning),ot(n,"--nt-warning-soft",t.tokens.warningSoft),ot(n,"--nt-warning-glow",t.tokens.warningGlow),ot(n,"--nt-scrim",t.tokens.scrim),ot(n,"--nt-scrim-soft",t.tokens.scrimSoft),ot(n,"--nt-shadow",t.tokens.shadow),ot(n,"--nt-shadow-strong",t.tokens.shadowStrong),ot(n,"--nt-floating-bg",t.tokens.floatingBg),ot(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),ot(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),ot(n,"--nt-subtle-fill",t.tokens.subtleFill),ot(n,"--nt-hover-fill",t.tokens.hoverFill),ot(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),ot(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),ot(n,"--nt-transcript-user",t.tokens.transcriptUser),ot(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),ot(n,"--nt-transcript-tool",t.tokens.transcriptTool),ot(n,"--nt-transcript-command",t.tokens.transcriptCommand),ot(n,"--nt-transcript-code",t.tokens.transcriptCode),ot(n,"--nt-transcript-search",t.tokens.transcriptSearch),ot(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),ot(n,"--nt-qr-bg",t.tokens.qrBg)}function wE(e=pa()){return Sv(Nh(e)).xterm}function Cv(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===yv||n.key===Xw)&&(wv(pa()),e())};return window.addEventListener(zm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zm,e),window.removeEventListener("storage",t)}}function ot(e,t,n){e.style.setProperty(t,n)}function LS(e){const t=CE(237);return t[215]=e.foreground,t[221]=e.line,{black:e.foreground,red:e.red,green:e.green,yellow:e.yellow,blue:e.blue,magenta:e.magenta,cyan:e.cyan,white:e.foregroundMuted,brightBlack:e.foregroundMuted,brightRed:e.red,brightGreen:e.green,brightYellow:e.yellow,brightBlue:e.blue,brightMagenta:e.magenta,brightCyan:e.cyan,brightWhite:e.foreground,extendedAnsi:t}}function CE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(xE(n));return t}function xE(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],s=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return BS(s,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return BS(t,t,t)}return"#000000"}function BS(e,t,n){return`#${tm(e)}${tm(t)}${tm(n)}`}function tm(e){return e.toString(16).padStart(2,"0")}function kE(e){return e==="signal-red"?"signal-red":sl}function Gw(){const e=v.useSyncExternalStore(Cv,pa,()=>sl);return Sv(e).mode==="light"?"-light":""}function Zw({size:e=22}){const t=Gw();return p.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function Qw({height:e=18}){const t=Gw(),n=Math.round(243/34*e);return p.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var wc=Vw();const Ah=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function dl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function xv(e){return"nodeType"in e}function Dn(e){var t,n;return e?dl(e)?e:xv(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function kv(e){const{Document:t}=Dn(e);return e instanceof t}function iu(e){return dl(e)?!1:e instanceof Dn(e).HTMLElement}function Jw(e){return e instanceof Dn(e).SVGElement}function hl(e){return e?dl(e)?e.document:xv(e)?kv(e)?e:iu(e)||Jw(e)?e.ownerDocument:document:document:document}const ma=Ah?v.useLayoutEffect:v.useEffect;function Ev(e){const t=v.useRef(e);return ma(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}function EE(){const e=v.useRef(null),t=v.useCallback((s,o)=>{e.current=setInterval(s,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Uc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ma(()=>{n.current!==e&&(n.current=e)},t),n}function nu(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function ch(e){const t=Ev(e),n=v.useRef(null),s=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,s]}function Pm(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let im={};function Lh(e,t){return v.useMemo(()=>{if(t)return t;const n=im[e]==null?0:im[e]+1;return im[e]=n,e+"-"+n},[e,t])}function e1(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return s.reduce((c,d)=>{const m=Object.entries(d);for(const[g,f]of m){const y=c[g];y!=null&&(c[g]=y+e*f)}return c},{...t})}}const il=e1(1),uh=e1(-1);function TE(e){return"clientX"in e&&"clientY"in e}function t1(e){if(!e)return!1;const{KeyboardEvent:t}=Dn(e.target);return t&&e instanceof t}function DE(e){if(!e)return!1;const{TouchEvent:t}=Dn(e.target);return t&&e instanceof t}function Im(e){if(DE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return TE(e)?{x:e.clientX,y:e.clientY}:null}const Hm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Hm.Translate.toString(e),Hm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),OS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function RE(e){return e.matches(OS)?e:e.querySelector(OS)}const ME={display:"none"};function NE(e){let{id:t,value:n}=e;return Li.createElement("div",{id:t,style:ME},n)}function AE(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Li.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},n)}function LE(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const i1=v.createContext(null);function BE(e){const t=v.useContext(i1);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function OE(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:o,event:c}=s;e.forEach(d=>{var m;return(m=d[o])==null?void 0:m.call(d,c)})},[e]),t]}const jE={draggable:`
|
|
6
|
+
`);for(u=o=0;o<N.length&&!N[o].includes("DetermineComponentFrameRoot");)o++;for(;u<Y.length&&!Y[u].includes("DetermineComponentFrameRoot");)u++;if(o===N.length||u===Y.length)for(o=N.length-1,u=Y.length-1;1<=o&&0<=u&&N[o]!==Y[u];)u--;for(;1<=o&&0<=u;o--,u--)if(N[o]!==Y[u]){if(o!==1||u!==1)do if(o--,u--,0>u||N[o]!==Y[u]){var ce=`
|
|
7
|
+
`+N[o].replace(" at new "," at ");return i.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",i.displayName)),ce}while(1<=o&&0<=u);break}}}finally{Ke=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Oe(a):""}function ae(i,r){switch(i.tag){case 26:case 27:case 5:return Oe(i.type);case 16:return Oe("Lazy");case 13:return i.child!==r&&r!==null?Oe("Suspense Fallback"):Oe("Suspense");case 19:return Oe("SuspenseList");case 0:case 15:return je(i.type,!1);case 11:return je(i.type.render,!1);case 1:return je(i.type,!0);case 31:return Oe("Activity");default:return""}}function Te(i){try{var r="",a=null;do r+=ae(i,a),a=i,i=i.return;while(i);return r}catch(o){return`
|
|
8
|
+
Error generating stack: `+o.message+`
|
|
9
|
+
`+o.stack}}var we=Object.prototype.hasOwnProperty,ze=e.unstable_scheduleCallback,Ue=e.unstable_cancelCallback,nt=e.unstable_shouldYield,ht=e.unstable_requestPaint,Dt=e.unstable_now,Ei=e.unstable_getCurrentPriorityLevel,ni=e.unstable_ImmediatePriority,di=e.unstable_UserBlockingPriority,le=e.unstable_NormalPriority,Ne=e.unstable_LowPriority,Qe=e.unstable_IdlePriority,it=e.log,jt=e.unstable_setDisableYieldValue,xt=null,gt=null;function Ht(i){if(typeof it=="function"&&jt(i),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(xt,i)}catch{}}var kt=Math.clz32?Math.clz32:Z,Mn=Math.log,Nn=Math.LN2;function Z(i){return i>>>=0,i===0?32:31-(Mn(i)/Nn|0)|0}var We=256,st=262144,et=4194304;function wt(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Et(i,r,a){var o=i.pendingLanes;if(o===0)return 0;var u=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var E=o&134217727;return E!==0?(o=E&~h,o!==0?u=wt(o):(_&=E,_!==0?u=wt(_):a||(a=E&~i,a!==0&&(u=wt(a))))):(E=o&~h,E!==0?u=wt(E):_!==0?u=wt(_):a||(a=o&~i,a!==0&&(u=wt(a)))),u===0?0:r!==0&&r!==u&&(r&h)===0&&(h=u&-u,a=r&-r,h>=a||h===32&&(a&4194048)!==0)?r:u}function Ut(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function ri(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=et;return et<<=1,(et&62914560)===0&&(et=4194304),i}function Zt(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function Kt(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Qt(i,r,a,o,u,h){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var E=i.entanglements,N=i.expirationTimes,Y=i.hiddenUpdates;for(a=_&~a;0<a;){var ce=31-kt(a),fe=1<<ce;E[ce]=0,N[ce]=-1;var Q=Y[ce];if(Q!==null)for(Y[ce]=null,ce=0;ce<Q.length;ce++){var te=Q[ce];te!==null&&(te.lane&=-536870913)}a&=~fe}o!==0&&ji(i,o,0),h!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~r))}function ji(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var o=31-kt(r);i.entangledLanes|=r,i.entanglements[o]=i.entanglements[o]|1073741824|a&261930}function hi(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var o=31-kt(a),u=1<<o;u&r|i[o]&r&&(i[o]|=r),a&=~u}}function zi(i,r){var a=r&-r;return a=(a&42)!==0?1:gn(a),(a&(i.suspendedLanes|r))!==0?0:a}function gn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Yi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Ti(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:gS(i.type))}function ln(i,r){var a=R.p;try{return R.p=i,r()}finally{R.p=a}}var Di=Math.random().toString(36).slice(2),si="__reactFiber$"+Di,Pi="__reactProps$"+Di,Vn="__reactContainer$"+Di,Sa="__reactEvents$"+Di,Yn="__reactListeners$"+Di,bo="__reactHandles$"+Di,ws="__reactResources$"+Di,It="__reactMarker$"+Di;function on(i){delete i[si],delete i[Pi],delete i[Sa],delete i[Yn],delete i[bo]}function vi(i){var r=i[si];if(r)return r;for(var a=i.parentNode;a;){if(r=a[Vn]||a[si]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=eS(i);i!==null;){if(a=i[si])return a;i=eS(i)}return r}i=a,a=i.parentNode}return null}function Xn(i){if(i=i[si]||i[Vn]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function wr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function vn(i){var r=i[ws];return r||(r=i[ws]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function $t(i){i[It]=!0}var dl=new Set,Cs={};function An(i,r){_n(i,r),_n(i+"Capture",r)}function _n(i,r){for(Cs[i]=r,i=0;i<r.length;i++)dl.add(r[i])}var Xi=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ur={},hl={};function wa(i){return we.call(hl,i)?!0:we.call(Ur,i)?!1:Xi.test(i)?hl[i]=!0:(Ur[i]=!0,!1)}function Cr(i,r,a){if(wa(r))if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var o=r.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+a)}}function dr(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function Ln(i,r,a,o){if(o===null)i.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(r,a,""+o)}}function fi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Ca(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function fl(i,r,a){var o=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,h=o.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,h.call(this,_)}}),Object.defineProperty(i,r,{enumerable:o.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Bn(i){if(!i._valueTracker){var r=Ca(i)?"checked":"value";i._valueTracker=fl(i,r,""+i[r])}}function xs(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),o="";return i&&(o=Ca(i)?i.checked?"true":"false":i.value),i=o,i!==a?(r.setValue(i),!0):!1}function xr(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var hr=/[\n"\\]/g;function Ii(i){return i.replace(hr,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function dt(i,r,a,o,u,h,_,E){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),r!=null?_==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+fi(r)):i.value!==""+fi(r)&&(i.value=""+fi(r)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),r!=null?ks(i,_,fi(r)):a!=null?ks(i,_,fi(a)):o!=null&&i.removeAttribute("value"),u==null&&h!=null&&(i.defaultChecked=!!h),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?i.name=""+fi(E):i.removeAttribute("name")}function fr(i,r,a,o,u,h,_,E){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),r!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||r!=null)){Bn(i);return}a=a!=null?""+fi(a):"",r=r!=null?""+fi(r):a,E||r===i.value||(i.value=r),i.defaultValue=r}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,i.checked=E?i.checked:!!o,i.defaultChecked=!!o,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),Bn(i)}function ks(i,r,a){r==="number"&&xr(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function ai(i,r,a,o){if(i=i.options,r){r={};for(var u=0;u<a.length;u++)r["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=r.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&o&&(i[a].defaultSelected=!0)}else{for(a=""+fi(a),r=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,o&&(i[u].defaultSelected=!0);return}r!==null||i[u].disabled||(r=i[u])}r!==null&&(r.selected=!0)}}function xa(i,r,a){if(r!=null&&(r=""+fi(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+fi(a):""}function ka(i,r,a,o){if(r==null){if(o!=null){if(a!=null)throw Error(s(92));if(se(o)){if(1<o.length)throw Error(s(93));o=o[0]}a=o}a==null&&(a=""),r=a}a=fi(r),i.defaultValue=a,o=i.textContent,o===a&&o!==""&&o!==null&&(i.value=o),Bn(i)}function pr(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var Es=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ts(i,r,a){var o=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?o?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":o?i.setProperty(r,a):typeof a!="number"||a===0||Es.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function kr(i,r,a){if(r!=null&&typeof r!="object")throw Error(s(62));if(i=i.style,a!=null){for(var o in a)!a.hasOwnProperty(o)||r!=null&&r.hasOwnProperty(o)||(o.indexOf("--")===0?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="");for(var u in r)o=r[u],r.hasOwnProperty(u)&&a[u]!==o&&Ts(i,u,o)}else for(var h in r)r.hasOwnProperty(h)&&Ts(i,h,r[h])}function bn(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var pl=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),yo=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Kr(i){return yo.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function cn(){}var Er=null;function Fr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Hi=null,tn=null;function Ea(i){var r=Xn(i);if(r&&(i=r.stateNode)){var a=i[Pi]||null;e:switch(i=r.stateNode,r.type){case"input":if(dt(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Ii(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var o=a[r];if(o!==i&&o.form===i.form){var u=o[Pi]||null;if(!u)throw Error(s(90));dt(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(r=0;r<a.length;r++)o=a[r],o.form===i.form&&xs(o)}break e;case"textarea":xa(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&ai(i,!!a.multiple,r,!1)}}}var Ds=!1;function Wr(i,r,a){if(Ds)return i(r,a);Ds=!0;try{var o=i(r);return o}finally{if(Ds=!1,(Hi!==null||tn!==null)&&(ud(),Hi&&(r=Hi,i=tn,tn=Hi=null,Ea(r),i)))for(r=0;r<i.length;r++)Ea(i[r])}}function qr(i,r){var a=i.stateNode;if(a===null)return null;var o=a[Pi]||null;if(o===null)return null;a=o[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(i=i.type,o=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!o;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,r,typeof a));return a}var On=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ta=!1;if(On)try{var Tr={};Object.defineProperty(Tr,"passive",{get:function(){Ta=!0}}),window.addEventListener("test",Tr,Tr),window.removeEventListener("test",Tr,Tr)}catch{Ta=!1}var yn=null,Da=null,Rs=null;function Ms(){if(Rs)return Rs;var i,r=Da,a=r.length,o,u="value"in yn?yn.value:yn.textContent,h=u.length;for(i=0;i<a&&r[i]===u[i];i++);var _=a-i;for(o=1;o<=_&&r[a-o]===u[h-o];o++);return Rs=u.slice(i,1<o?1-o:void 0)}function Dr(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Ns(){return!0}function jn(){return!1}function Jt(i){function r(a,o,u,h,_){this._reactName=a,this._targetInst=u,this.type=o,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var E in i)i.hasOwnProperty(E)&&(a=i[E],this[E]=a?a(h):h[E]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ns:jn,this.isPropagationStopped=jn,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ns)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ns)},persist:function(){},isPersistent:Ns}),r}var nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},S=Jt(nn),T=b({},nn,{view:0,detail:0}),j=Jt(T),ee,pe,ue,Ce=b({},T,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ra,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ue&&(ue&&i.type==="mousemove"?(ee=i.screenX-ue.screenX,pe=i.screenY-ue.screenY):pe=ee=0,ue=i),ee)},movementY:function(i){return"movementY"in i?i.movementY:pe}}),qe=Jt(Ce),Ye=b({},Ce,{dataTransfer:0}),_i=Jt(Ye),Vt=b({},T,{relatedTarget:0}),$r=Jt(Vt),du=b({},nn,{animationName:0,elapsedTime:0,pseudoElement:0}),Zh=Jt(du),hu=b({},nn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Vr=Jt(hu),So=b({},nn,{data:0}),fu=Jt(So),pu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qh={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},mu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wo(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=mu[i])?!!r[i]:!1}function Ra(){return wo}var ml=b({},T,{key:function(i){if(i.key){var r=pu[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Dr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Qh[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ra,charCode:function(i){return i.type==="keypress"?Dr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Dr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Jh=Jt(ml),gu=b({},Ce,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vu=Jt(gu),_u=b({},T,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ra}),ef=Jt(_u),tf=b({},nn,{propertyName:0,elapsedTime:0,pseudoElement:0}),nf=Jt(tf),bu=b({},Ce,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Co=Jt(bu),gl=b({},nn,{newState:0,oldState:0}),yu=Jt(gl),Su=[9,13,27,32],xo=On&&"CompositionEvent"in window,As=null;On&&"documentMode"in document&&(As=document.documentMode);var wu=On&&"TextEvent"in window&&!As,ko=On&&(!xo||As&&8<As&&11>=As),Cu=" ",Eo=!1;function Rr(i,r){switch(i){case"keyup":return Su.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xu(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ls=!1;function ku(i,r){switch(i){case"compositionend":return xu(r);case"keypress":return r.which!==32?null:(Eo=!0,Cu);case"textInput":return i=r.data,i===Cu&&Eo?null:i;default:return null}}function rf(i,r){if(Ls)return i==="compositionend"||!xo&&Rr(i,r)?(i=Ms(),Rs=Da=yn=null,Ls=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return ko&&r.locale!=="ko"?null:r.data;default:return null}}var sf={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mr(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!sf[i.type]:r==="textarea"}function Eu(i,r,a,o){Hi?tn?tn.push(o):tn=[o]:Hi=o,r=vd(r,"onChange"),0<r.length&&(a=new S("onChange","change",null,a,o),i.push({event:a,listeners:r}))}var Ma=null,Na=null;function Tu(i){Hy(i,0)}function zn(i){var r=wr(i);if(xs(r))return i}function Du(i,r){if(i==="change")return r}var Ru=!1;if(On){var Aa;if(On){var To="oninput"in document;if(!To){var Do=document.createElement("div");Do.setAttribute("oninput","return;"),To=typeof Do.oninput=="function"}Aa=To}else Aa=!1;Ru=Aa&&(!document.documentMode||9<document.documentMode)}function k(){Ma&&(Ma.detachEvent("onpropertychange",I),Na=Ma=null)}function I(i){if(i.propertyName==="value"&&zn(Na)){var r=[];Eu(r,Na,i,Fr(i)),Wr(Tu,r)}}function Ae(i,r,a){i==="focusin"?(k(),Ma=r,Na=a,Ma.attachEvent("onpropertychange",I)):i==="focusout"&&k()}function Fe(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return zn(Na)}function Ve(i,r){if(i==="click")return zn(r)}function Je(i,r){if(i==="input"||i==="change")return zn(r)}function ft(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var ot=typeof Object.is=="function"?Object.is:ft;function Tt(i,r){if(ot(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),o=Object.keys(r);if(a.length!==o.length)return!1;for(o=0;o<a.length;o++){var u=a[o];if(!we.call(r,u)||!ot(i[u],r[u]))return!1}return!0}function ei(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Sn(i,r){var a=ei(i);i=0;for(var o;a;){if(a.nodeType===3){if(o=i+a.textContent.length,i<=r&&o>=r)return{node:a,offset:r-i};i=o}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=ei(a)}}function un(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?un(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Ro(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=xr(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=xr(i.document)}return r}function Mo(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Mr=On&&"documentMode"in document&&11>=document.documentMode,Yr=null,vl=null,No=null,af=!1;function p_(i,r,a){var o=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;af||Yr==null||Yr!==xr(o)||(o=Yr,"selectionStart"in o&&Mo(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),No&&Tt(No,o)||(No=o,o=vd(vl,"onSelect"),0<o.length&&(r=new S("onSelect","select",null,r,a),i.push({event:r,listeners:o}),r.target=Yr)))}function La(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var _l={animationend:La("Animation","AnimationEnd"),animationiteration:La("Animation","AnimationIteration"),animationstart:La("Animation","AnimationStart"),transitionrun:La("Transition","TransitionRun"),transitionstart:La("Transition","TransitionStart"),transitioncancel:La("Transition","TransitionCancel"),transitionend:La("Transition","TransitionEnd")},lf={},m_={};On&&(m_=document.createElement("div").style,"AnimationEvent"in window||(delete _l.animationend.animation,delete _l.animationiteration.animation,delete _l.animationstart.animation),"TransitionEvent"in window||delete _l.transitionend.transition);function Ba(i){if(lf[i])return lf[i];if(!_l[i])return i;var r=_l[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in m_)return lf[i]=r[a];return i}var g_=Ba("animationend"),v_=Ba("animationiteration"),__=Ba("animationstart"),Wx=Ba("transitionrun"),qx=Ba("transitionstart"),$x=Ba("transitioncancel"),b_=Ba("transitionend"),y_=new Map,of="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");of.push("scrollEnd");function gr(i,r){y_.set(i,r),An(r,[i])}var Mu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Gn=[],bl=0,cf=0;function Nu(){for(var i=bl,r=cf=bl=0;r<i;){var a=Gn[r];Gn[r++]=null;var o=Gn[r];Gn[r++]=null;var u=Gn[r];Gn[r++]=null;var h=Gn[r];if(Gn[r++]=null,o!==null&&u!==null){var _=o.pending;_===null?u.next=u:(u.next=_.next,_.next=u),o.pending=u}h!==0&&S_(a,u,h)}}function Au(i,r,a,o){Gn[bl++]=i,Gn[bl++]=r,Gn[bl++]=a,Gn[bl++]=o,cf|=o,i.lanes|=o,i=i.alternate,i!==null&&(i.lanes|=o)}function uf(i,r,a,o){return Au(i,r,a,o),Lu(i)}function Oa(i,r){return Au(i,null,null,r),Lu(i)}function S_(i,r,a){i.lanes|=a;var o=i.alternate;o!==null&&(o.lanes|=a);for(var u=!1,h=i.return;h!==null;)h.childLanes|=a,o=h.alternate,o!==null&&(o.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(u=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,u&&r!==null&&(u=31-kt(a),i=h.hiddenUpdates,o=i[u],o===null?i[u]=[r]:o.push(r),r.lane=a|536870912),h):null}function Lu(i){if(50<Jo)throw Jo=0,bp=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var yl={};function Vx(i,r,a,o){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(i,r,a,o){return new Vx(i,r,a,o)}function df(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Xr(i,r){var a=i.alternate;return a===null?(a=Pn(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function w_(i,r){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,r=a.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function Bu(i,r,a,o,u,h){var _=0;if(o=i,typeof i=="function")df(i)&&(_=1);else if(typeof i=="string")_=Qk(i,a,ve.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case Se:return i=Pn(31,a,r,u),i.elementType=Se,i.lanes=h,i;case D:return ja(a.children,u,h,r);case B:_=8,u|=24;break;case L:return i=Pn(12,a,r,u|2),i.elementType=L,i.lanes=h,i;case G:return i=Pn(13,a,r,u),i.elementType=G,i.lanes=h,i;case W:return i=Pn(19,a,r,u),i.elementType=W,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case X:_=10;break e;case O:_=9;break e;case U:_=11;break e;case q:_=14;break e;case ge:_=16,o=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),o=null}return r=Pn(_,a,r,u),r.elementType=i,r.type=o,r.lanes=h,r}function ja(i,r,a,o){return i=Pn(7,i,o,r),i.lanes=a,i}function hf(i,r,a){return i=Pn(6,i,null,r),i.lanes=a,i}function C_(i){var r=Pn(18,null,null,0);return r.stateNode=i,r}function ff(i,r,a){return r=Pn(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var x_=new WeakMap;function Zn(i,r){if(typeof i=="object"&&i!==null){var a=x_.get(i);return a!==void 0?a:(r={value:i,source:r,stack:Te(r)},x_.set(i,r),r)}return{value:i,source:r,stack:Te(r)}}var Sl=[],wl=0,Ou=null,Ao=0,Qn=[],Jn=0,Bs=null,Nr=1,Ar="";function Gr(i,r){Sl[wl++]=Ao,Sl[wl++]=Ou,Ou=i,Ao=r}function k_(i,r,a){Qn[Jn++]=Nr,Qn[Jn++]=Ar,Qn[Jn++]=Bs,Bs=i;var o=Nr;i=Ar;var u=32-kt(o)-1;o&=~(1<<u),a+=1;var h=32-kt(r)+u;if(30<h){var _=u-u%5;h=(o&(1<<_)-1).toString(32),o>>=_,u-=_,Nr=1<<32-kt(r)+u|a<<u|o,Ar=h+i}else Nr=1<<h|a<<u|o,Ar=i}function pf(i){i.return!==null&&(Gr(i,1),k_(i,1,0))}function mf(i){for(;i===Ou;)Ou=Sl[--wl],Sl[wl]=null,Ao=Sl[--wl],Sl[wl]=null;for(;i===Bs;)Bs=Qn[--Jn],Qn[Jn]=null,Ar=Qn[--Jn],Qn[Jn]=null,Nr=Qn[--Jn],Qn[Jn]=null}function E_(i,r){Qn[Jn++]=Nr,Qn[Jn++]=Ar,Qn[Jn++]=Bs,Nr=r.id,Ar=r.overflow,Bs=i}var Gi=null,Ft=null,bt=!1,Os=null,er=!1,gf=Error(s(519));function js(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Lo(Zn(r,i)),gf}function T_(i){var r=i.stateNode,a=i.type,o=i.memoizedProps;switch(r[si]=i,r[Pi]=o,a){case"dialog":mt("cancel",r),mt("close",r);break;case"iframe":case"object":case"embed":mt("load",r);break;case"video":case"audio":for(a=0;a<tc.length;a++)mt(tc[a],r);break;case"source":mt("error",r);break;case"img":case"image":case"link":mt("error",r),mt("load",r);break;case"details":mt("toggle",r);break;case"input":mt("invalid",r),fr(r,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":mt("invalid",r);break;case"textarea":mt("invalid",r),ka(r,o.value,o.defaultValue,o.children)}a=o.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||o.suppressHydrationWarning===!0||Wy(r.textContent,a)?(o.popover!=null&&(mt("beforetoggle",r),mt("toggle",r)),o.onScroll!=null&&mt("scroll",r),o.onScrollEnd!=null&&mt("scrollend",r),o.onClick!=null&&(r.onclick=cn),r=!0):r=!1,r||js(i,!0)}function D_(i){for(Gi=i.return;Gi;)switch(Gi.tag){case 5:case 31:case 13:er=!1;return;case 27:case 3:er=!0;return;default:Gi=Gi.return}}function Cl(i){if(i!==Gi)return!1;if(!bt)return D_(i),bt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Bp(i.type,i.memoizedProps)),a=!a),a&&Ft&&js(i),D_(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ft=Jy(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ft=Jy(i)}else r===27?(r=Ft,Gs(i.type)?(i=Ip,Ip=null,Ft=i):Ft=r):Ft=Gi?ir(i.stateNode.nextSibling):null;return!0}function za(){Ft=Gi=null,bt=!1}function vf(){var i=Os;return i!==null&&(kn===null?kn=i:kn.push.apply(kn,i),Os=null),i}function Lo(i){Os===null?Os=[i]:Os.push(i)}var _f=M(null),Pa=null,Zr=null;function zs(i,r,a){ie(_f,r._currentValue),r._currentValue=a}function Qr(i){i._currentValue=_f.current,F(_f)}function bf(i,r,a){for(;i!==null;){var o=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,o!==null&&(o.childLanes|=r)):o!==null&&(o.childLanes&r)!==r&&(o.childLanes|=r),i===a)break;i=i.return}}function yf(i,r,a,o){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var h=u.dependencies;if(h!==null){var _=u.child;h=h.firstContext;e:for(;h!==null;){var E=h;h=u;for(var N=0;N<r.length;N++)if(E.context===r[N]){h.lanes|=a,E=h.alternate,E!==null&&(E.lanes|=a),bf(h.return,a,i),o||(_=null);break e}h=E.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),bf(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function xl(i,r,a,o){i=null;for(var u=r,h=!1;u!==null;){if(!h){if((u.flags&524288)!==0)h=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var E=u.type;ot(u.pendingProps.value,_.value)||(i!==null?i.push(E):i=[E])}}else if(u===Me.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(ac):i=[ac])}u=u.return}i!==null&&yf(r,i,a,o),r.flags|=262144}function ju(i){for(i=i.firstContext;i!==null;){if(!ot(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ia(i){Pa=i,Zr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Zi(i){return R_(Pa,i)}function zu(i,r){return Pa===null&&Ia(i),R_(i,r)}function R_(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Zr===null){if(i===null)throw Error(s(308));Zr=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Zr=Zr.next=r;return a}var Yx=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(a,o){i.push(o)}};this.abort=function(){r.aborted=!0,i.forEach(function(a){return a()})}},Xx=e.unstable_scheduleCallback,Gx=e.unstable_NormalPriority,bi={$$typeof:X,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Sf(){return{controller:new Yx,data:new Map,refCount:0}}function Bo(i){i.refCount--,i.refCount===0&&Xx(Gx,function(){i.controller.abort()})}var Oo=null,wf=0,kl=0,El=null;function Zx(i,r){if(Oo===null){var a=Oo=[];wf=0,kl=kp(),El={status:"pending",value:void 0,then:function(o){a.push(o)}}}return wf++,r.then(M_,M_),r}function M_(){if(--wf===0&&Oo!==null){El!==null&&(El.status="fulfilled");var i=Oo;Oo=null,kl=0,El=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function Qx(i,r){var a=[],o={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){o.status="fulfilled",o.value=r;for(var u=0;u<a.length;u++)(0,a[u])(r)},function(u){for(o.status="rejected",o.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),o}var N_=A.S;A.S=function(i,r){py=Dt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Zx(i,r),N_!==null&&N_(i,r)};var Ha=M(null);function Cf(){var i=Ha.current;return i!==null?i:zt.pooledCache}function Pu(i,r){r===null?ie(Ha,Ha.current):ie(Ha,r.pool)}function A_(){var i=Cf();return i===null?null:{parent:bi._currentValue,pool:i}}var Tl=Error(s(460)),xf=Error(s(474)),Iu=Error(s(542)),Hu={then:function(){}};function L_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function B_(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(cn,cn),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,j_(i),i;default:if(typeof r.status=="string")r.then(cn,cn);else{if(i=zt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=r,i.status="pending",i.then(function(o){if(r.status==="pending"){var u=r;u.status="fulfilled",u.value=o}},function(o){if(r.status==="pending"){var u=r;u.status="rejected",u.reason=o}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,j_(i),i}throw Ka=r,Tl}}function Ua(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Ka=a,Tl):a}}var Ka=null;function O_(){if(Ka===null)throw Error(s(459));var i=Ka;return Ka=null,i}function j_(i){if(i===Tl||i===Iu)throw Error(s(483))}var Dl=null,jo=0;function Uu(i){var r=jo;return jo+=1,Dl===null&&(Dl=[]),B_(Dl,i,r)}function zo(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Ku(i,r){throw r.$$typeof===C?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function z_(i){function r(H,P){if(i){var V=H.deletions;V===null?(H.deletions=[P],H.flags|=16):V.push(P)}}function a(H,P){if(!i)return null;for(;P!==null;)r(H,P),P=P.sibling;return null}function o(H){for(var P=new Map;H!==null;)H.key!==null?P.set(H.key,H):P.set(H.index,H),H=H.sibling;return P}function u(H,P){return H=Xr(H,P),H.index=0,H.sibling=null,H}function h(H,P,V){return H.index=V,i?(V=H.alternate,V!==null?(V=V.index,V<P?(H.flags|=67108866,P):V):(H.flags|=67108866,P)):(H.flags|=1048576,P)}function _(H){return i&&H.alternate===null&&(H.flags|=67108866),H}function E(H,P,V,de){return P===null||P.tag!==6?(P=hf(V,H.mode,de),P.return=H,P):(P=u(P,V),P.return=H,P)}function N(H,P,V,de){var $e=V.type;return $e===D?ce(H,P,V.props.children,de,V.key):P!==null&&(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ge&&Ua($e)===P.type)?(P=u(P,V.props),zo(P,V),P.return=H,P):(P=Bu(V.type,V.key,V.props,null,H.mode,de),zo(P,V),P.return=H,P)}function Y(H,P,V,de){return P===null||P.tag!==4||P.stateNode.containerInfo!==V.containerInfo||P.stateNode.implementation!==V.implementation?(P=ff(V,H.mode,de),P.return=H,P):(P=u(P,V.children||[]),P.return=H,P)}function ce(H,P,V,de,$e){return P===null||P.tag!==7?(P=ja(V,H.mode,de,$e),P.return=H,P):(P=u(P,V),P.return=H,P)}function fe(H,P,V){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=hf(""+P,H.mode,V),P.return=H,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case w:return V=Bu(P.type,P.key,P.props,null,H.mode,V),zo(V,P),V.return=H,V;case x:return P=ff(P,H.mode,V),P.return=H,P;case ge:return P=Ua(P),fe(H,P,V)}if(se(P)||$(P))return P=ja(P,H.mode,V,null),P.return=H,P;if(typeof P.then=="function")return fe(H,Uu(P),V);if(P.$$typeof===X)return fe(H,zu(H,P),V);Ku(H,P)}return null}function Q(H,P,V,de){var $e=P!==null?P.key:null;if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return $e!==null?null:E(H,P,""+V,de);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case w:return V.key===$e?N(H,P,V,de):null;case x:return V.key===$e?Y(H,P,V,de):null;case ge:return V=Ua(V),Q(H,P,V,de)}if(se(V)||$(V))return $e!==null?null:ce(H,P,V,de,null);if(typeof V.then=="function")return Q(H,P,Uu(V),de);if(V.$$typeof===X)return Q(H,P,zu(H,V),de);Ku(H,V)}return null}function te(H,P,V,de,$e){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return H=H.get(V)||null,E(P,H,""+de,$e);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case w:return H=H.get(de.key===null?V:de.key)||null,N(P,H,de,$e);case x:return H=H.get(de.key===null?V:de.key)||null,Y(P,H,de,$e);case ge:return de=Ua(de),te(H,P,V,de,$e)}if(se(de)||$(de))return H=H.get(V)||null,ce(P,H,de,$e,null);if(typeof de.then=="function")return te(H,P,V,Uu(de),$e);if(de.$$typeof===X)return te(H,P,V,zu(P,de),$e);Ku(P,de)}return null}function Ie(H,P,V,de){for(var $e=null,yt=null,He=P,at=P=0,_t=null;He!==null&&at<V.length;at++){He.index>at?(_t=He,He=null):_t=He.sibling;var St=Q(H,He,V[at],de);if(St===null){He===null&&(He=_t);break}i&&He&&St.alternate===null&&r(H,He),P=h(St,P,at),yt===null?$e=St:yt.sibling=St,yt=St,He=_t}if(at===V.length)return a(H,He),bt&&Gr(H,at),$e;if(He===null){for(;at<V.length;at++)He=fe(H,V[at],de),He!==null&&(P=h(He,P,at),yt===null?$e=He:yt.sibling=He,yt=He);return bt&&Gr(H,at),$e}for(He=o(He);at<V.length;at++)_t=te(He,H,at,V[at],de),_t!==null&&(i&&_t.alternate!==null&&He.delete(_t.key===null?at:_t.key),P=h(_t,P,at),yt===null?$e=_t:yt.sibling=_t,yt=_t);return i&&He.forEach(function(ta){return r(H,ta)}),bt&&Gr(H,at),$e}function Xe(H,P,V,de){if(V==null)throw Error(s(151));for(var $e=null,yt=null,He=P,at=P=0,_t=null,St=V.next();He!==null&&!St.done;at++,St=V.next()){He.index>at?(_t=He,He=null):_t=He.sibling;var ta=Q(H,He,St.value,de);if(ta===null){He===null&&(He=_t);break}i&&He&&ta.alternate===null&&r(H,He),P=h(ta,P,at),yt===null?$e=ta:yt.sibling=ta,yt=ta,He=_t}if(St.done)return a(H,He),bt&&Gr(H,at),$e;if(He===null){for(;!St.done;at++,St=V.next())St=fe(H,St.value,de),St!==null&&(P=h(St,P,at),yt===null?$e=St:yt.sibling=St,yt=St);return bt&&Gr(H,at),$e}for(He=o(He);!St.done;at++,St=V.next())St=te(He,H,at,St.value,de),St!==null&&(i&&St.alternate!==null&&He.delete(St.key===null?at:St.key),P=h(St,P,at),yt===null?$e=St:yt.sibling=St,yt=St);return i&&He.forEach(function(cE){return r(H,cE)}),bt&&Gr(H,at),$e}function Lt(H,P,V,de){if(typeof V=="object"&&V!==null&&V.type===D&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case w:e:{for(var $e=V.key;P!==null;){if(P.key===$e){if($e=V.type,$e===D){if(P.tag===7){a(H,P.sibling),de=u(P,V.props.children),de.return=H,H=de;break e}}else if(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===ge&&Ua($e)===P.type){a(H,P.sibling),de=u(P,V.props),zo(de,V),de.return=H,H=de;break e}a(H,P);break}else r(H,P);P=P.sibling}V.type===D?(de=ja(V.props.children,H.mode,de,V.key),de.return=H,H=de):(de=Bu(V.type,V.key,V.props,null,H.mode,de),zo(de,V),de.return=H,H=de)}return _(H);case x:e:{for($e=V.key;P!==null;){if(P.key===$e)if(P.tag===4&&P.stateNode.containerInfo===V.containerInfo&&P.stateNode.implementation===V.implementation){a(H,P.sibling),de=u(P,V.children||[]),de.return=H,H=de;break e}else{a(H,P);break}else r(H,P);P=P.sibling}de=ff(V,H.mode,de),de.return=H,H=de}return _(H);case ge:return V=Ua(V),Lt(H,P,V,de)}if(se(V))return Ie(H,P,V,de);if($(V)){if($e=$(V),typeof $e!="function")throw Error(s(150));return V=$e.call(V),Xe(H,P,V,de)}if(typeof V.then=="function")return Lt(H,P,Uu(V),de);if(V.$$typeof===X)return Lt(H,P,zu(H,V),de);Ku(H,V)}return typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint"?(V=""+V,P!==null&&P.tag===6?(a(H,P.sibling),de=u(P,V),de.return=H,H=de):(a(H,P),de=hf(V,H.mode,de),de.return=H,H=de),_(H)):a(H,P)}return function(H,P,V,de){try{jo=0;var $e=Lt(H,P,V,de);return Dl=null,$e}catch(He){if(He===Tl||He===Iu)throw He;var yt=Pn(29,He,null,H.mode);return yt.lanes=de,yt.return=H,yt}}}var Fa=z_(!0),P_=z_(!1),Ps=!1;function kf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ef(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Is(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Hs(i,r,a){var o=i.updateQueue;if(o===null)return null;if(o=o.shared,(Ct&2)!==0){var u=o.pending;return u===null?r.next=r:(r.next=u.next,u.next=r),o.pending=r,r=Lu(i),S_(i,null,a),r}return Au(i,o,r,a),Lu(i)}function Po(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,hi(i,a)}}function Tf(i,r){var a=i.updateQueue,o=i.alternate;if(o!==null&&(o=o.updateQueue,a===o)){var u=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?u=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?u=h=r:h=h.next=r}else u=h=r;a={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:o.shared,callbacks:o.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}var Df=!1;function Io(){if(Df){var i=El;if(i!==null)throw i}}function Ho(i,r,a,o){Df=!1;var u=i.updateQueue;Ps=!1;var h=u.firstBaseUpdate,_=u.lastBaseUpdate,E=u.shared.pending;if(E!==null){u.shared.pending=null;var N=E,Y=N.next;N.next=null,_===null?h=Y:_.next=Y,_=N;var ce=i.alternate;ce!==null&&(ce=ce.updateQueue,E=ce.lastBaseUpdate,E!==_&&(E===null?ce.firstBaseUpdate=Y:E.next=Y,ce.lastBaseUpdate=N))}if(h!==null){var fe=u.baseState;_=0,ce=Y=N=null,E=h;do{var Q=E.lane&-536870913,te=Q!==E.lane;if(te?(vt&Q)===Q:(o&Q)===Q){Q!==0&&Q===kl&&(Df=!0),ce!==null&&(ce=ce.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ie=i,Xe=E;Q=r;var Lt=a;switch(Xe.tag){case 1:if(Ie=Xe.payload,typeof Ie=="function"){fe=Ie.call(Lt,fe,Q);break e}fe=Ie;break e;case 3:Ie.flags=Ie.flags&-65537|128;case 0:if(Ie=Xe.payload,Q=typeof Ie=="function"?Ie.call(Lt,fe,Q):Ie,Q==null)break e;fe=b({},fe,Q);break e;case 2:Ps=!0}}Q=E.callback,Q!==null&&(i.flags|=64,te&&(i.flags|=8192),te=u.callbacks,te===null?u.callbacks=[Q]:te.push(Q))}else te={lane:Q,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ce===null?(Y=ce=te,N=fe):ce=ce.next=te,_|=Q;if(E=E.next,E===null){if(E=u.shared.pending,E===null)break;te=E,E=te.next,te.next=null,u.lastBaseUpdate=te,u.shared.pending=null}}while(!0);ce===null&&(N=fe),u.baseState=N,u.firstBaseUpdate=Y,u.lastBaseUpdate=ce,h===null&&(u.shared.lanes=0),qs|=_,i.lanes=_,i.memoizedState=fe}}function I_(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function H_(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)I_(a[i],r)}var Rl=M(null),Fu=M(0);function U_(i,r){i=ls,ie(Fu,i),ie(Rl,r),ls=i|r.baseLanes}function Rf(){ie(Fu,ls),ie(Rl,Rl.current)}function Mf(){ls=Fu.current,F(Rl),F(Fu)}var In=M(null),tr=null;function Us(i){var r=i.alternate;ie(pi,pi.current&1),ie(In,i),tr===null&&(r===null||Rl.current!==null||r.memoizedState!==null)&&(tr=i)}function Nf(i){ie(pi,pi.current),ie(In,i),tr===null&&(tr=i)}function K_(i){i.tag===22?(ie(pi,pi.current),ie(In,i),tr===null&&(tr=i)):Ks()}function Ks(){ie(pi,pi.current),ie(In,In.current)}function Hn(i){F(In),tr===i&&(tr=null),F(pi)}var pi=M(0);function Wu(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||zp(a)||Pp(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Jr=0,rt=null,Nt=null,yi=null,qu=!1,Ml=!1,Wa=!1,$u=0,Uo=0,Nl=null,Jx=0;function li(){throw Error(s(321))}function Af(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!ot(i[a],r[a]))return!1;return!0}function Lf(i,r,a,o,u,h){return Jr=h,rt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,A.H=i===null||i.memoizedState===null?kb:Yf,Wa=!1,h=a(o,u),Wa=!1,Ml&&(h=W_(r,a,o,u)),F_(i),h}function F_(i){A.H=Wo;var r=Nt!==null&&Nt.next!==null;if(Jr=0,yi=Nt=rt=null,qu=!1,Uo=0,Nl=null,r)throw Error(s(300));i===null||Si||(i=i.dependencies,i!==null&&ju(i)&&(Si=!0))}function W_(i,r,a,o){rt=i;var u=0;do{if(Ml&&(Nl=null),Uo=0,Ml=!1,25<=u)throw Error(s(301));if(u+=1,yi=Nt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}A.H=Eb,h=r(a,o)}while(Ml);return h}function ek(){var i=A.H,r=i.useState()[0];return r=typeof r.then=="function"?Ko(r):r,i=i.useState()[0],(Nt!==null?Nt.memoizedState:null)!==i&&(rt.flags|=1024),r}function Bf(){var i=$u!==0;return $u=0,i}function Of(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function jf(i){if(qu){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}qu=!1}Jr=0,yi=Nt=rt=null,Ml=!1,Uo=$u=0,Nl=null}function dn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yi===null?rt.memoizedState=yi=i:yi=yi.next=i,yi}function mi(){if(Nt===null){var i=rt.alternate;i=i!==null?i.memoizedState:null}else i=Nt.next;var r=yi===null?rt.memoizedState:yi.next;if(r!==null)yi=r,Nt=i;else{if(i===null)throw rt.alternate===null?Error(s(467)):Error(s(310));Nt=i,i={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},yi===null?rt.memoizedState=yi=i:yi=yi.next=i}return yi}function Vu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ko(i){var r=Uo;return Uo+=1,Nl===null&&(Nl=[]),i=B_(Nl,i,r),r=rt,(yi===null?r.memoizedState:yi.next)===null&&(r=r.alternate,A.H=r===null||r.memoizedState===null?kb:Yf),i}function Yu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Ko(i);if(i.$$typeof===X)return Zi(i)}throw Error(s(438,String(i)))}function zf(i){var r=null,a=rt.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var o=rt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(r={data:o.data.map(function(u){return u.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=Vu(),rt.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(i),o=0;o<i;o++)a[o]=xe;return r.index++,a}function es(i,r){return typeof r=="function"?r(i):r}function Xu(i){var r=mi();return Pf(r,Nt,i)}function Pf(i,r,a){var o=i.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=a;var u=i.baseQueue,h=o.pending;if(h!==null){if(u!==null){var _=u.next;u.next=h.next,h.next=_}r.baseQueue=u=h,o.pending=null}if(h=i.baseState,u===null)i.memoizedState=h;else{r=u.next;var E=_=null,N=null,Y=r,ce=!1;do{var fe=Y.lane&-536870913;if(fe!==Y.lane?(vt&fe)===fe:(Jr&fe)===fe){var Q=Y.revertLane;if(Q===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),fe===kl&&(ce=!0);else if((Jr&Q)===Q){Y=Y.next,Q===kl&&(ce=!0);continue}else fe={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},N===null?(E=N=fe,_=h):N=N.next=fe,rt.lanes|=Q,qs|=Q;fe=Y.action,Wa&&a(h,fe),h=Y.hasEagerState?Y.eagerState:a(h,fe)}else Q={lane:fe,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},N===null?(E=N=Q,_=h):N=N.next=Q,rt.lanes|=fe,qs|=fe;Y=Y.next}while(Y!==null&&Y!==r);if(N===null?_=h:N.next=E,!ot(h,i.memoizedState)&&(Si=!0,ce&&(a=El,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=N,o.lastRenderedState=h}return u===null&&(o.lanes=0),[i.memoizedState,o.dispatch]}function If(i){var r=mi(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var o=a.dispatch,u=a.pending,h=r.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do h=i(h,_.action),_=_.next;while(_!==u);ot(h,r.memoizedState)||(Si=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),a.lastRenderedState=h}return[h,o]}function q_(i,r,a){var o=rt,u=mi(),h=bt;if(h){if(a===void 0)throw Error(s(407));a=a()}else a=r();var _=!ot((Nt||u).memoizedState,a);if(_&&(u.memoizedState=a,Si=!0),u=u.queue,Kf(Y_.bind(null,o,u,i),[i]),u.getSnapshot!==r||_||yi!==null&&yi.memoizedState.tag&1){if(o.flags|=2048,Al(9,{destroy:void 0},V_.bind(null,o,u,a,r),null),zt===null)throw Error(s(349));h||(Jr&127)!==0||$_(o,r,a)}return a}function $_(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=rt.updateQueue,r===null?(r=Vu(),rt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function V_(i,r,a,o){r.value=a,r.getSnapshot=o,X_(r)&&G_(i)}function Y_(i,r,a){return a(function(){X_(r)&&G_(i)})}function X_(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!ot(i,a)}catch{return!0}}function G_(i){var r=Oa(i,2);r!==null&&En(r,i,2)}function Hf(i){var r=dn();if(typeof i=="function"){var a=i;if(i=a(),Wa){Ht(!0);try{a()}finally{Ht(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:i},r}function Z_(i,r,a,o){return i.baseState=a,Pf(i,Nt,typeof o=="function"?o:es)}function tk(i,r,a,o,u){if(Qu(i))throw Error(s(485));if(i=r.action,i!==null){var h={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){h.listeners.push(_)}};A.T!==null?a(!0):h.isTransition=!1,o(h),a=r.pending,a===null?(h.next=r.pending=h,Q_(r,h)):(h.next=a.next,r.pending=a.next=h)}}function Q_(i,r){var a=r.action,o=r.payload,u=i.state;if(r.isTransition){var h=A.T,_={};A.T=_;try{var E=a(u,o),N=A.S;N!==null&&N(_,E),J_(i,r,E)}catch(Y){Uf(i,r,Y)}finally{h!==null&&_.types!==null&&(h.types=_.types),A.T=h}}else try{h=a(u,o),J_(i,r,h)}catch(Y){Uf(i,r,Y)}}function J_(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(o){eb(i,r,o)},function(o){return Uf(i,r,o)}):eb(i,r,a)}function eb(i,r,a){r.status="fulfilled",r.value=a,tb(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,Q_(i,a)))}function Uf(i,r,a){var o=i.pending;if(i.pending=null,o!==null){o=o.next;do r.status="rejected",r.reason=a,tb(r),r=r.next;while(r!==o)}i.action=null}function tb(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function ib(i,r){return r}function nb(i,r){if(bt){var a=zt.formState;if(a!==null){e:{var o=rt;if(bt){if(Ft){t:{for(var u=Ft,h=er;u.nodeType!==8;){if(!h){u=null;break t}if(u=ir(u.nextSibling),u===null){u=null;break t}}h=u.data,u=h==="F!"||h==="F"?u:null}if(u){Ft=ir(u.nextSibling),o=u.data==="F!";break e}}js(o)}o=!1}o&&(r=a[0])}}return a=dn(),a.memoizedState=a.baseState=r,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ib,lastRenderedState:r},a.queue=o,a=wb.bind(null,rt,o),o.dispatch=a,o=Hf(!1),h=Vf.bind(null,rt,!1,o.queue),o=dn(),u={state:r,dispatch:null,action:i,pending:null},o.queue=u,a=tk.bind(null,rt,u,h,a),u.dispatch=a,o.memoizedState=i,[r,a,!1]}function rb(i){var r=mi();return sb(r,Nt,i)}function sb(i,r,a){if(r=Pf(i,r,ib)[0],i=Xu(es)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var o=Ko(r)}catch(_){throw _===Tl?Iu:_}else o=r;r=mi();var u=r.queue,h=u.dispatch;return a!==r.memoizedState&&(rt.flags|=2048,Al(9,{destroy:void 0},ik.bind(null,u,a),null)),[o,h,i]}function ik(i,r){i.action=r}function ab(i){var r=mi(),a=Nt;if(a!==null)return sb(r,a,i);mi(),r=r.memoizedState,a=mi();var o=a.queue.dispatch;return a.memoizedState=i,[r,o,!1]}function Al(i,r,a,o){return i={tag:i,create:a,deps:o,inst:r,next:null},r=rt.updateQueue,r===null&&(r=Vu(),rt.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=i.next=i:(o=a.next,a.next=i,i.next=o,r.lastEffect=i),i}function lb(){return mi().memoizedState}function Gu(i,r,a,o){var u=dn();rt.flags|=i,u.memoizedState=Al(1|r,{destroy:void 0},a,o===void 0?null:o)}function Zu(i,r,a,o){var u=mi();o=o===void 0?null:o;var h=u.memoizedState.inst;Nt!==null&&o!==null&&Af(o,Nt.memoizedState.deps)?u.memoizedState=Al(r,h,a,o):(rt.flags|=i,u.memoizedState=Al(1|r,h,a,o))}function ob(i,r){Gu(8390656,8,i,r)}function Kf(i,r){Zu(2048,8,i,r)}function nk(i){rt.flags|=4;var r=rt.updateQueue;if(r===null)r=Vu(),rt.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function cb(i){var r=mi().memoizedState;return nk({ref:r,nextImpl:i}),function(){if((Ct&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function ub(i,r){return Zu(4,2,i,r)}function db(i,r){return Zu(4,4,i,r)}function hb(i,r){if(typeof r=="function"){i=i();var a=r(i);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function fb(i,r,a){a=a!=null?a.concat([i]):null,Zu(4,4,hb.bind(null,r,i),a)}function Ff(){}function pb(i,r){var a=mi();r=r===void 0?null:r;var o=a.memoizedState;return r!==null&&Af(r,o[1])?o[0]:(a.memoizedState=[i,r],i)}function mb(i,r){var a=mi();r=r===void 0?null:r;var o=a.memoizedState;if(r!==null&&Af(r,o[1]))return o[0];if(o=i(),Wa){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[o,r],o}function Wf(i,r,a){return a===void 0||(Jr&1073741824)!==0&&(vt&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=gy(),rt.lanes|=i,qs|=i,a)}function gb(i,r,a,o){return ot(a,r)?a:Rl.current!==null?(i=Wf(i,a,o),ot(i,r)||(Si=!0),i):(Jr&42)===0||(Jr&1073741824)!==0&&(vt&261930)===0?(Si=!0,i.memoizedState=a):(i=gy(),rt.lanes|=i,qs|=i,r)}function vb(i,r,a,o,u){var h=R.p;R.p=h!==0&&8>h?h:8;var _=A.T,E={};A.T=E,Vf(i,!1,r,a);try{var N=u(),Y=A.S;if(Y!==null&&Y(E,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ce=Qx(N,o);Fo(i,r,ce,Fn(i))}else Fo(i,r,o,Fn(i))}catch(fe){Fo(i,r,{then:function(){},status:"rejected",reason:fe},Fn())}finally{R.p=h,_!==null&&E.types!==null&&(_.types=E.types),A.T=_}}function rk(){}function qf(i,r,a,o){if(i.tag!==5)throw Error(s(476));var u=_b(i).queue;vb(i,u,r,z,a===null?rk:function(){return bb(i),a(o)})}function _b(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:z,baseState:z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:z},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function bb(i){var r=_b(i);r.next===null&&(r=i.alternate.memoizedState),Fo(i,r.next.queue,{},Fn())}function $f(){return Zi(ac)}function yb(){return mi().memoizedState}function Sb(){return mi().memoizedState}function sk(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=Fn();i=Is(a);var o=Hs(r,i,a);o!==null&&(En(o,r,a),Po(o,r,a)),r={cache:Sf()},i.payload=r;return}r=r.return}}function ak(i,r,a){var o=Fn();a={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Qu(i)?Cb(r,a):(a=uf(i,r,a,o),a!==null&&(En(a,i,o),xb(a,r,o)))}function wb(i,r,a){var o=Fn();Fo(i,r,a,o)}function Fo(i,r,a,o){var u={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Qu(i))Cb(r,u);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var _=r.lastRenderedState,E=h(_,a);if(u.hasEagerState=!0,u.eagerState=E,ot(E,_))return Au(i,r,u,0),zt===null&&Nu(),!1}catch{}if(a=uf(i,r,u,o),a!==null)return En(a,i,o),xb(a,r,o),!0}return!1}function Vf(i,r,a,o){if(o={lane:2,revertLane:kp(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Qu(i)){if(r)throw Error(s(479))}else r=uf(i,a,o,2),r!==null&&En(r,i,2)}function Qu(i){var r=i.alternate;return i===rt||r!==null&&r===rt}function Cb(i,r){Ml=qu=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function xb(i,r,a){if((a&4194048)!==0){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,hi(i,a)}}var Wo={readContext:Zi,use:Yu,useCallback:li,useContext:li,useEffect:li,useImperativeHandle:li,useLayoutEffect:li,useInsertionEffect:li,useMemo:li,useReducer:li,useRef:li,useState:li,useDebugValue:li,useDeferredValue:li,useTransition:li,useSyncExternalStore:li,useId:li,useHostTransitionStatus:li,useFormState:li,useActionState:li,useOptimistic:li,useMemoCache:li,useCacheRefresh:li};Wo.useEffectEvent=li;var kb={readContext:Zi,use:Yu,useCallback:function(i,r){return dn().memoizedState=[i,r===void 0?null:r],i},useContext:Zi,useEffect:ob,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,Gu(4194308,4,hb.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Gu(4194308,4,i,r)},useInsertionEffect:function(i,r){Gu(4,2,i,r)},useMemo:function(i,r){var a=dn();r=r===void 0?null:r;var o=i();if(Wa){Ht(!0);try{i()}finally{Ht(!1)}}return a.memoizedState=[o,r],o},useReducer:function(i,r,a){var o=dn();if(a!==void 0){var u=a(r);if(Wa){Ht(!0);try{a(r)}finally{Ht(!1)}}}else u=r;return o.memoizedState=o.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},o.queue=i,i=i.dispatch=ak.bind(null,rt,i),[o.memoizedState,i]},useRef:function(i){var r=dn();return i={current:i},r.memoizedState=i},useState:function(i){i=Hf(i);var r=i.queue,a=wb.bind(null,rt,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:Ff,useDeferredValue:function(i,r){var a=dn();return Wf(a,i,r)},useTransition:function(){var i=Hf(!1);return i=vb.bind(null,rt,i.queue,!0,!1),dn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var o=rt,u=dn();if(bt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),zt===null)throw Error(s(349));(vt&127)!==0||$_(o,r,a)}u.memoizedState=a;var h={value:a,getSnapshot:r};return u.queue=h,ob(Y_.bind(null,o,h,i),[i]),o.flags|=2048,Al(9,{destroy:void 0},V_.bind(null,o,h,a,r),null),a},useId:function(){var i=dn(),r=zt.identifierPrefix;if(bt){var a=Ar,o=Nr;a=(o&~(1<<32-kt(o)-1)).toString(32)+a,r="_"+r+"R_"+a,a=$u++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=Jx++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:$f,useFormState:nb,useActionState:nb,useOptimistic:function(i){var r=dn();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Vf.bind(null,rt,!0,a),a.dispatch=r,[i,r]},useMemoCache:zf,useCacheRefresh:function(){return dn().memoizedState=sk.bind(null,rt)},useEffectEvent:function(i){var r=dn(),a={impl:i};return r.memoizedState=a,function(){if((Ct&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Yf={readContext:Zi,use:Yu,useCallback:pb,useContext:Zi,useEffect:Kf,useImperativeHandle:fb,useInsertionEffect:ub,useLayoutEffect:db,useMemo:mb,useReducer:Xu,useRef:lb,useState:function(){return Xu(es)},useDebugValue:Ff,useDeferredValue:function(i,r){var a=mi();return gb(a,Nt.memoizedState,i,r)},useTransition:function(){var i=Xu(es)[0],r=mi().memoizedState;return[typeof i=="boolean"?i:Ko(i),r]},useSyncExternalStore:q_,useId:yb,useHostTransitionStatus:$f,useFormState:rb,useActionState:rb,useOptimistic:function(i,r){var a=mi();return Z_(a,Nt,i,r)},useMemoCache:zf,useCacheRefresh:Sb};Yf.useEffectEvent=cb;var Eb={readContext:Zi,use:Yu,useCallback:pb,useContext:Zi,useEffect:Kf,useImperativeHandle:fb,useInsertionEffect:ub,useLayoutEffect:db,useMemo:mb,useReducer:If,useRef:lb,useState:function(){return If(es)},useDebugValue:Ff,useDeferredValue:function(i,r){var a=mi();return Nt===null?Wf(a,i,r):gb(a,Nt.memoizedState,i,r)},useTransition:function(){var i=If(es)[0],r=mi().memoizedState;return[typeof i=="boolean"?i:Ko(i),r]},useSyncExternalStore:q_,useId:yb,useHostTransitionStatus:$f,useFormState:ab,useActionState:ab,useOptimistic:function(i,r){var a=mi();return Nt!==null?Z_(a,Nt,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:zf,useCacheRefresh:Sb};Eb.useEffectEvent=cb;function Xf(i,r,a,o){r=i.memoizedState,a=a(o,r),a=a==null?r:b({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Gf={enqueueSetState:function(i,r,a){i=i._reactInternals;var o=Fn(),u=Is(o);u.payload=r,a!=null&&(u.callback=a),r=Hs(i,u,o),r!==null&&(En(r,i,o),Po(r,i,o))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var o=Fn(),u=Is(o);u.tag=1,u.payload=r,a!=null&&(u.callback=a),r=Hs(i,u,o),r!==null&&(En(r,i,o),Po(r,i,o))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Fn(),o=Is(a);o.tag=2,r!=null&&(o.callback=r),r=Hs(i,o,a),r!==null&&(En(r,i,a),Po(r,i,a))}};function Tb(i,r,a,o,u,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(o,h,_):r.prototype&&r.prototype.isPureReactComponent?!Tt(a,o)||!Tt(u,h):!0}function Db(i,r,a,o){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,o),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,o),r.state!==i&&Gf.enqueueReplaceState(r,r.state,null)}function qa(i,r){var a=r;if("ref"in r){a={};for(var o in r)o!=="ref"&&(a[o]=r[o])}if(i=i.defaultProps){a===r&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Rb(i){Mu(i)}function Mb(i){console.error(i)}function Nb(i){Mu(i)}function Ju(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(o){setTimeout(function(){throw o})}}function Ab(i,r,a){try{var o=i.onCaughtError;o(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Zf(i,r,a){return a=Is(a),a.tag=3,a.payload={element:null},a.callback=function(){Ju(i,r)},a}function Lb(i){return i=Is(i),i.tag=3,i}function Bb(i,r,a,o){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var h=o.value;i.payload=function(){return u(h)},i.callback=function(){Ab(r,a,o)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Ab(r,a,o),typeof u!="function"&&($s===null?$s=new Set([this]):$s.add(this));var E=o.stack;this.componentDidCatch(o.value,{componentStack:E!==null?E:""})})}function lk(i,r,a,o,u){if(a.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(r=a.alternate,r!==null&&xl(r,a,u,!0),a=In.current,a!==null){switch(a.tag){case 31:case 13:return tr===null?dd():a.alternate===null&&oi===0&&(oi=3),a.flags&=-257,a.flags|=65536,a.lanes=u,o===Hu?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([o]):r.add(o),wp(i,o,u)),!1;case 22:return a.flags|=65536,o===Hu?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([o])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([o]):a.add(o)),wp(i,o,u)),!1}throw Error(s(435,a.tag))}return wp(i,o,u),dd(),!1}if(bt)return r=In.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=u,o!==gf&&(i=Error(s(422),{cause:o}),Lo(Zn(i,a)))):(o!==gf&&(r=Error(s(423),{cause:o}),Lo(Zn(r,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,o=Zn(o,a),u=Zf(i.stateNode,o,u),Tf(i,u),oi!==4&&(oi=2)),!1;var h=Error(s(520),{cause:o});if(h=Zn(h,a),Qo===null?Qo=[h]:Qo.push(h),oi!==4&&(oi=2),r===null)return!0;o=Zn(o,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Zf(a.stateNode,o,i),Tf(a,i),!1;case 1:if(r=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&($s===null||!$s.has(h))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Lb(u),Bb(u,i,a,o),Tf(a,u),!1}a=a.return}while(a!==null);return!1}var Qf=Error(s(461)),Si=!1;function Qi(i,r,a,o){r.child=i===null?P_(r,null,a,o):Fa(r,i.child,a,o)}function Ob(i,r,a,o,u){a=a.render;var h=r.ref;if("ref"in o){var _={};for(var E in o)E!=="ref"&&(_[E]=o[E])}else _=o;return Ia(r),o=Lf(i,r,a,_,h,u),E=Bf(),i!==null&&!Si?(Of(i,r,u),ts(i,r,u)):(bt&&E&&pf(r),r.flags|=1,Qi(i,r,o,u),r.child)}function jb(i,r,a,o,u){if(i===null){var h=a.type;return typeof h=="function"&&!df(h)&&h.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=h,zb(i,r,h,o,u)):(i=Bu(a.type,null,o,r,r.mode,u),i.ref=r.ref,i.return=r,r.child=i)}if(h=i.child,!ap(i,u)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Tt,a(_,o)&&i.ref===r.ref)return ts(i,r,u)}return r.flags|=1,i=Xr(h,o),i.ref=r.ref,i.return=r,r.child=i}function zb(i,r,a,o,u){if(i!==null){var h=i.memoizedProps;if(Tt(h,o)&&i.ref===r.ref)if(Si=!1,r.pendingProps=o=h,ap(i,u))(i.flags&131072)!==0&&(Si=!0);else return r.lanes=i.lanes,ts(i,r,u)}return Jf(i,r,a,o,u)}function Pb(i,r,a,o){var u=o.children,h=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((r.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(o=r.child=i.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~h}else o=0,r.child=null;return Ib(i,r,h,a,o)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Pu(r,h!==null?h.cachePool:null),h!==null?U_(r,h):Rf(),K_(r);else return o=r.lanes=536870912,Ib(i,r,h!==null?h.baseLanes|a:a,a,o)}else h!==null?(Pu(r,h.cachePool),U_(r,h),Ks(),r.memoizedState=null):(i!==null&&Pu(r,null),Rf(),Ks());return Qi(i,r,u,a),r.child}function qo(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Ib(i,r,a,o,u){var h=Cf();return h=h===null?null:{parent:bi._currentValue,pool:h},r.memoizedState={baseLanes:a,cachePool:h},i!==null&&Pu(r,null),Rf(),K_(r),i!==null&&xl(i,r,o,!0),r.childLanes=u,null}function ed(i,r){return r=id({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function Hb(i,r,a){return Fa(r,i.child,null,a),i=ed(r,r.pendingProps),i.flags|=2,Hn(r),r.memoizedState=null,i}function ok(i,r,a){var o=r.pendingProps,u=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(bt){if(o.mode==="hidden")return i=ed(r,o),r.lanes=536870912,qo(null,i);if(Nf(r),(i=Ft)?(i=Qy(i,er),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Bs!==null?{id:Nr,overflow:Ar}:null,retryLane:536870912,hydrationErrors:null},a=C_(i),a.return=r,r.child=a,Gi=r,Ft=null)):i=null,i===null)throw js(r);return r.lanes=536870912,null}return ed(r,o)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(Nf(r),u)if(r.flags&256)r.flags&=-257,r=Hb(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(Si||xl(i,r,a,!1),u=(a&i.childLanes)!==0,Si||u){if(o=zt,o!==null&&(_=zi(o,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,Oa(i,_),En(o,i,_),Qf;dd(),r=Hb(i,r,a)}else i=h.treeContext,Ft=ir(_.nextSibling),Gi=r,bt=!0,Os=null,er=!1,i!==null&&E_(r,i),r=ed(r,o),r.flags|=4096;return r}return i=Xr(i.child,{mode:o.mode,children:o.children}),i.ref=r.ref,r.child=i,i.return=r,i}function td(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function Jf(i,r,a,o,u){return Ia(r),a=Lf(i,r,a,o,void 0,u),o=Bf(),i!==null&&!Si?(Of(i,r,u),ts(i,r,u)):(bt&&o&&pf(r),r.flags|=1,Qi(i,r,a,u),r.child)}function Ub(i,r,a,o,u,h){return Ia(r),r.updateQueue=null,a=W_(r,o,a,u),F_(i),o=Bf(),i!==null&&!Si?(Of(i,r,h),ts(i,r,h)):(bt&&o&&pf(r),r.flags|=1,Qi(i,r,a,h),r.child)}function Kb(i,r,a,o,u){if(Ia(r),r.stateNode===null){var h=yl,_=a.contextType;typeof _=="object"&&_!==null&&(h=Zi(_)),h=new a(o,h),r.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Gf,r.stateNode=h,h._reactInternals=r,h=r.stateNode,h.props=o,h.state=r.memoizedState,h.refs={},kf(r),_=a.contextType,h.context=typeof _=="object"&&_!==null?Zi(_):yl,h.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Xf(r,a,_,o),h.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(_=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),_!==h.state&&Gf.enqueueReplaceState(h,h.state,null),Ho(r,o,h,u),Io(),h.state=r.memoizedState),typeof h.componentDidMount=="function"&&(r.flags|=4194308),o=!0}else if(i===null){h=r.stateNode;var E=r.memoizedProps,N=qa(a,E);h.props=N;var Y=h.context,ce=a.contextType;_=yl,typeof ce=="object"&&ce!==null&&(_=Zi(ce));var fe=a.getDerivedStateFromProps;ce=typeof fe=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=r.pendingProps!==E,ce||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||Y!==_)&&Db(r,h,o,_),Ps=!1;var Q=r.memoizedState;h.state=Q,Ho(r,o,h,u),Io(),Y=r.memoizedState,E||Q!==Y||Ps?(typeof fe=="function"&&(Xf(r,a,fe,o),Y=r.memoizedState),(N=Ps||Tb(r,a,N,o,Q,Y,_))?(ce||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(r.flags|=4194308)):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=o,r.memoizedState=Y),h.props=o,h.state=Y,h.context=_,o=N):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),o=!1)}else{h=r.stateNode,Ef(i,r),_=r.memoizedProps,ce=qa(a,_),h.props=ce,fe=r.pendingProps,Q=h.context,Y=a.contextType,N=yl,typeof Y=="object"&&Y!==null&&(N=Zi(Y)),E=a.getDerivedStateFromProps,(Y=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==fe||Q!==N)&&Db(r,h,o,N),Ps=!1,Q=r.memoizedState,h.state=Q,Ho(r,o,h,u),Io();var te=r.memoizedState;_!==fe||Q!==te||Ps||i!==null&&i.dependencies!==null&&ju(i.dependencies)?(typeof E=="function"&&(Xf(r,a,E,o),te=r.memoizedState),(ce=Ps||Tb(r,a,ce,o,Q,te,N)||i!==null&&i.dependencies!==null&&ju(i.dependencies))?(Y||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,te,N),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,te,N)),typeof h.componentDidUpdate=="function"&&(r.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=1024),r.memoizedProps=o,r.memoizedState=te),h.props=o,h.state=te,h.context=N,o=ce):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Q===i.memoizedState||(r.flags|=1024),o=!1)}return h=o,td(i,r),o=(r.flags&128)!==0,h||o?(h=r.stateNode,a=o&&typeof a.getDerivedStateFromError!="function"?null:h.render(),r.flags|=1,i!==null&&o?(r.child=Fa(r,i.child,null,u),r.child=Fa(r,null,a,u)):Qi(i,r,a,u),r.memoizedState=h.state,i=r.child):i=ts(i,r,u),i}function Fb(i,r,a,o){return za(),r.flags|=256,Qi(i,r,a,o),r.child}var ep={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tp(i){return{baseLanes:i,cachePool:A_()}}function ip(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=Kn),i}function Wb(i,r,a){var o=r.pendingProps,u=!1,h=(r.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(pi.current&2)!==0),_&&(u=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,i===null){if(bt){if(u?Us(r):Ks(),(i=Ft)?(i=Qy(i,er),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Bs!==null?{id:Nr,overflow:Ar}:null,retryLane:536870912,hydrationErrors:null},a=C_(i),a.return=r,r.child=a,Gi=r,Ft=null)):i=null,i===null)throw js(r);return Pp(i)?r.lanes=32:r.lanes=536870912,null}var E=o.children;return o=o.fallback,u?(Ks(),u=r.mode,E=id({mode:"hidden",children:E},u),o=ja(o,u,a,null),E.return=r,o.return=r,E.sibling=o,r.child=E,o=r.child,o.memoizedState=tp(a),o.childLanes=ip(i,_,a),r.memoizedState=ep,qo(null,o)):(Us(r),np(r,E))}var N=i.memoizedState;if(N!==null&&(E=N.dehydrated,E!==null)){if(h)r.flags&256?(Us(r),r.flags&=-257,r=rp(i,r,a)):r.memoizedState!==null?(Ks(),r.child=i.child,r.flags|=128,r=null):(Ks(),E=o.fallback,u=r.mode,o=id({mode:"visible",children:o.children},u),E=ja(E,u,a,null),E.flags|=2,o.return=r,E.return=r,o.sibling=E,r.child=o,Fa(r,i.child,null,a),o=r.child,o.memoizedState=tp(a),o.childLanes=ip(i,_,a),r.memoizedState=ep,r=qo(null,o));else if(Us(r),Pp(E)){if(_=E.nextSibling&&E.nextSibling.dataset,_)var Y=_.dgst;_=Y,o=Error(s(419)),o.stack="",o.digest=_,Lo({value:o,source:null,stack:null}),r=rp(i,r,a)}else if(Si||xl(i,r,a,!1),_=(a&i.childLanes)!==0,Si||_){if(_=zt,_!==null&&(o=zi(_,a),o!==0&&o!==N.retryLane))throw N.retryLane=o,Oa(i,o),En(_,i,o),Qf;zp(E)||dd(),r=rp(i,r,a)}else zp(E)?(r.flags|=192,r.child=i.child,r=null):(i=N.treeContext,Ft=ir(E.nextSibling),Gi=r,bt=!0,Os=null,er=!1,i!==null&&E_(r,i),r=np(r,o.children),r.flags|=4096);return r}return u?(Ks(),E=o.fallback,u=r.mode,N=i.child,Y=N.sibling,o=Xr(N,{mode:"hidden",children:o.children}),o.subtreeFlags=N.subtreeFlags&65011712,Y!==null?E=Xr(Y,E):(E=ja(E,u,a,null),E.flags|=2),E.return=r,o.return=r,o.sibling=E,r.child=o,qo(null,o),o=r.child,E=i.child.memoizedState,E===null?E=tp(a):(u=E.cachePool,u!==null?(N=bi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=A_(),E={baseLanes:E.baseLanes|a,cachePool:u}),o.memoizedState=E,o.childLanes=ip(i,_,a),r.memoizedState=ep,qo(i.child,o)):(Us(r),a=i.child,i=a.sibling,a=Xr(a,{mode:"visible",children:o.children}),a.return=r,a.sibling=null,i!==null&&(_=r.deletions,_===null?(r.deletions=[i],r.flags|=16):_.push(i)),r.child=a,r.memoizedState=null,a)}function np(i,r){return r=id({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function id(i,r){return i=Pn(22,i,null,r),i.lanes=0,i}function rp(i,r,a){return Fa(r,i.child,null,a),i=np(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function qb(i,r,a){i.lanes|=r;var o=i.alternate;o!==null&&(o.lanes|=r),bf(i.return,r,a)}function sp(i,r,a,o,u,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:o,tail:a,tailMode:u,treeForkCount:h}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=o,_.tail=a,_.tailMode=u,_.treeForkCount=h)}function $b(i,r,a){var o=r.pendingProps,u=o.revealOrder,h=o.tail;o=o.children;var _=pi.current,E=(_&2)!==0;if(E?(_=_&1|2,r.flags|=128):_&=1,ie(pi,_),Qi(i,r,o,a),o=bt?Ao:0,!E&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&qb(i,a,r);else if(i.tag===19)qb(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=r.child,u=null;a!==null;)i=a.alternate,i!==null&&Wu(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=r.child,r.child=null):(u=a.sibling,a.sibling=null),sp(r,!1,u,a,h,o);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=r.child,r.child=null;u!==null;){if(i=u.alternate,i!==null&&Wu(i)===null){r.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}sp(r,!0,a,null,h,o);break;case"together":sp(r,!1,null,null,void 0,o);break;default:r.memoizedState=null}return r.child}function ts(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),qs|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(xl(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=Xr(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Xr(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function ap(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&ju(i)))}function ck(i,r,a){switch(r.tag){case 3:Re(r,r.stateNode.containerInfo),zs(r,bi,i.memoizedState.cache),za();break;case 27:case 5:Be(r);break;case 4:Re(r,r.stateNode.containerInfo);break;case 10:zs(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Nf(r),null;break;case 13:var o=r.memoizedState;if(o!==null)return o.dehydrated!==null?(Us(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Wb(i,r,a):(Us(r),i=ts(i,r,a),i!==null?i.sibling:null);Us(r);break;case 19:var u=(i.flags&128)!==0;if(o=(a&r.childLanes)!==0,o||(xl(i,r,a,!1),o=(a&r.childLanes)!==0),u){if(o)return $b(i,r,a);r.flags|=128}if(u=r.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ie(pi,pi.current),o)break;return null;case 22:return r.lanes=0,Pb(i,r,a,r.pendingProps);case 24:zs(r,bi,i.memoizedState.cache)}return ts(i,r,a)}function Vb(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)Si=!0;else{if(!ap(i,a)&&(r.flags&128)===0)return Si=!1,ck(i,r,a);Si=(i.flags&131072)!==0}else Si=!1,bt&&(r.flags&1048576)!==0&&k_(r,Ao,r.index);switch(r.lanes=0,r.tag){case 16:e:{var o=r.pendingProps;if(i=Ua(r.elementType),r.type=i,typeof i=="function")df(i)?(o=qa(i,o),r.tag=1,r=Kb(null,r,i,o,a)):(r.tag=0,r=Jf(null,r,i,o,a));else{if(i!=null){var u=i.$$typeof;if(u===U){r.tag=11,r=Ob(null,r,i,o,a);break e}else if(u===q){r.tag=14,r=jb(null,r,i,o,a);break e}}throw r=K(i)||i,Error(s(306,r,""))}}return r;case 0:return Jf(i,r,r.type,r.pendingProps,a);case 1:return o=r.type,u=qa(o,r.pendingProps),Kb(i,r,o,u,a);case 3:e:{if(Re(r,r.stateNode.containerInfo),i===null)throw Error(s(387));o=r.pendingProps;var h=r.memoizedState;u=h.element,Ef(i,r),Ho(r,o,null,a);var _=r.memoizedState;if(o=_.cache,zs(r,bi,o),o!==h.cache&&yf(r,[bi],a,!0),Io(),o=_.element,h.isDehydrated)if(h={element:o,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){r=Fb(i,r,o,a);break e}else if(o!==u){u=Zn(Error(s(424)),r),Lo(u),r=Fb(i,r,o,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Ft=ir(i.firstChild),Gi=r,bt=!0,Os=null,er=!0,a=P_(r,null,o,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(za(),o===u){r=ts(i,r,a);break e}Qi(i,r,o,a)}r=r.child}return r;case 26:return td(i,r),i===null?(a=rS(r.type,null,r.pendingProps,null))?r.memoizedState=a:bt||(a=r.type,i=r.pendingProps,o=_d(Ee.current).createElement(a),o[si]=r,o[Pi]=i,Ji(o,a,i),$t(o),r.stateNode=o):r.memoizedState=rS(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Be(r),i===null&&bt&&(o=r.stateNode=tS(r.type,r.pendingProps,Ee.current),Gi=r,er=!0,u=Ft,Gs(r.type)?(Ip=u,Ft=ir(o.firstChild)):Ft=u),Qi(i,r,r.pendingProps.children,a),td(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&bt&&((u=o=Ft)&&(o=Ik(o,r.type,r.pendingProps,er),o!==null?(r.stateNode=o,Gi=r,Ft=ir(o.firstChild),er=!1,u=!0):u=!1),u||js(r)),Be(r),u=r.type,h=r.pendingProps,_=i!==null?i.memoizedProps:null,o=h.children,Bp(u,h)?o=null:_!==null&&Bp(u,_)&&(r.flags|=32),r.memoizedState!==null&&(u=Lf(i,r,ek,null,null,a),ac._currentValue=u),td(i,r),Qi(i,r,o,a),r.child;case 6:return i===null&&bt&&((i=a=Ft)&&(a=Hk(a,r.pendingProps,er),a!==null?(r.stateNode=a,Gi=r,Ft=null,i=!0):i=!1),i||js(r)),null;case 13:return Wb(i,r,a);case 4:return Re(r,r.stateNode.containerInfo),o=r.pendingProps,i===null?r.child=Fa(r,null,o,a):Qi(i,r,o,a),r.child;case 11:return Ob(i,r,r.type,r.pendingProps,a);case 7:return Qi(i,r,r.pendingProps,a),r.child;case 8:return Qi(i,r,r.pendingProps.children,a),r.child;case 12:return Qi(i,r,r.pendingProps.children,a),r.child;case 10:return o=r.pendingProps,zs(r,r.type,o.value),Qi(i,r,o.children,a),r.child;case 9:return u=r.type._context,o=r.pendingProps.children,Ia(r),u=Zi(u),o=o(u),r.flags|=1,Qi(i,r,o,a),r.child;case 14:return jb(i,r,r.type,r.pendingProps,a);case 15:return zb(i,r,r.type,r.pendingProps,a);case 19:return $b(i,r,a);case 31:return ok(i,r,a);case 22:return Pb(i,r,a,r.pendingProps);case 24:return Ia(r),o=Zi(bi),i===null?(u=Cf(),u===null&&(u=zt,h=Sf(),u.pooledCache=h,h.refCount++,h!==null&&(u.pooledCacheLanes|=a),u=h),r.memoizedState={parent:o,cache:u},kf(r),zs(r,bi,u)):((i.lanes&a)!==0&&(Ef(i,r),Ho(r,null,null,a),Io()),u=i.memoizedState,h=r.memoizedState,u.parent!==o?(u={parent:o,cache:o},r.memoizedState=u,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=u),zs(r,bi,o)):(o=h.cache,zs(r,bi,o),o!==u.cache&&yf(r,[bi],a,!0))),Qi(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function is(i){i.flags|=4}function lp(i,r,a,o,u){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(yy())i.flags|=8192;else throw Ka=Hu,xf}else i.flags&=-16777217}function Yb(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!cS(r))if(yy())i.flags|=8192;else throw Ka=Hu,xf}function nd(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?Gt():536870912,i.lanes|=r,jl|=r)}function $o(i,r){if(!bt)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:o.sibling=null}}function Wt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,o=0;if(r)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=o,i.childLanes=a,r}function uk(i,r,a){var o=r.pendingProps;switch(mf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wt(r),null;case 1:return Wt(r),null;case 3:return a=r.stateNode,o=null,i!==null&&(o=i.memoizedState.cache),r.memoizedState.cache!==o&&(r.flags|=2048),Qr(bi),Pe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Cl(r)?is(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,vf())),Wt(r),null;case 26:var u=r.type,h=r.memoizedState;return i===null?(is(r),h!==null?(Wt(r),Yb(r,h)):(Wt(r),lp(r,u,null,o,a))):h?h!==i.memoizedState?(is(r),Wt(r),Yb(r,h)):(Wt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==o&&is(r),Wt(r),lp(r,u,i,o,a)),null;case 27:if(oe(r),a=Ee.current,u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&is(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}i=ve.current,Cl(r)?T_(r):(i=tS(u,o,a),r.stateNode=i,is(r))}return Wt(r),null;case 5:if(oe(r),u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&is(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}if(h=ve.current,Cl(r))T_(r);else{var _=_d(Ee.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":h=_.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof o.is=="string"?_.createElement("select",{is:o.is}):_.createElement("select"),o.multiple?h.multiple=!0:o.size&&(h.size=o.size);break;default:h=typeof o.is=="string"?_.createElement(u,{is:o.is}):_.createElement(u)}}h[si]=r,h[Pi]=o;e:for(_=r.child;_!==null;){if(_.tag===5||_.tag===6)h.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===r)break e;for(;_.sibling===null;){if(_.return===null||_.return===r)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}r.stateNode=h;e:switch(Ji(h,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&is(r)}}return Wt(r),lp(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==o&&is(r);else{if(typeof o!="string"&&r.stateNode===null)throw Error(s(166));if(i=Ee.current,Cl(r)){if(i=r.stateNode,a=r.memoizedProps,o=null,u=Gi,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}i[si]=r,i=!!(i.nodeValue===a||o!==null&&o.suppressHydrationWarning===!0||Wy(i.nodeValue,a)),i||js(r,!0)}else i=_d(i).createTextNode(o),i[si]=r,r.stateNode=i}return Wt(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(o=Cl(r),a!==null){if(i===null){if(!o)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[si]=r}else za(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),i=!1}else a=vf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(Hn(r),r):(Hn(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Wt(r),null;case 13:if(o=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Cl(r),o!==null&&o.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=r.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[si]=r}else za(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),u=!1}else u=vf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return r.flags&256?(Hn(r),r):(Hn(r),null)}return Hn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=o!==null,i=i!==null&&i.memoizedState!==null,a&&(o=r.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),h=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),h!==u&&(o.flags|=2048)),a!==i&&a&&(r.child.flags|=8192),nd(r,r.updateQueue),Wt(r),null);case 4:return Pe(),i===null&&Rp(r.stateNode.containerInfo),Wt(r),null;case 10:return Qr(r.type),Wt(r),null;case 19:if(F(pi),o=r.memoizedState,o===null)return Wt(r),null;if(u=(r.flags&128)!==0,h=o.rendering,h===null)if(u)$o(o,!1);else{if(oi!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(h=Wu(i),h!==null){for(r.flags|=128,$o(o,!1),i=h.updateQueue,r.updateQueue=i,nd(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)w_(a,i),a=a.sibling;return ie(pi,pi.current&1|2),bt&&Gr(r,o.treeForkCount),r.child}i=i.sibling}o.tail!==null&&Dt()>od&&(r.flags|=128,u=!0,$o(o,!1),r.lanes=4194304)}else{if(!u)if(i=Wu(h),i!==null){if(r.flags|=128,u=!0,i=i.updateQueue,r.updateQueue=i,nd(r,i),$o(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!bt)return Wt(r),null}else 2*Dt()-o.renderingStartTime>od&&a!==536870912&&(r.flags|=128,u=!0,$o(o,!1),r.lanes=4194304);o.isBackwards?(h.sibling=r.child,r.child=h):(i=o.last,i!==null?i.sibling=h:r.child=h,o.last=h)}return o.tail!==null?(i=o.tail,o.rendering=i,o.tail=i.sibling,o.renderingStartTime=Dt(),i.sibling=null,a=pi.current,ie(pi,u?a&1|2:a&1),bt&&Gr(r,o.treeForkCount),i):(Wt(r),null);case 22:case 23:return Hn(r),Mf(),o=r.memoizedState!==null,i!==null?i.memoizedState!==null!==o&&(r.flags|=8192):o&&(r.flags|=8192),o?(a&536870912)!==0&&(r.flags&128)===0&&(Wt(r),r.subtreeFlags&6&&(r.flags|=8192)):Wt(r),a=r.updateQueue,a!==null&&nd(r,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048),i!==null&&F(Ha),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),Qr(bi),Wt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function dk(i,r){switch(mf(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Qr(bi),Pe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return oe(r),null;case 31:if(r.memoizedState!==null){if(Hn(r),r.alternate===null)throw Error(s(340));za()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Hn(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));za()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return F(pi),null;case 4:return Pe(),null;case 10:return Qr(r.type),null;case 22:case 23:return Hn(r),Mf(),i!==null&&F(Ha),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return Qr(bi),null;case 25:return null;default:return null}}function Xb(i,r){switch(mf(r),r.tag){case 3:Qr(bi),Pe();break;case 26:case 27:case 5:oe(r);break;case 4:Pe();break;case 31:r.memoizedState!==null&&Hn(r);break;case 13:Hn(r);break;case 19:F(pi);break;case 10:Qr(r.type);break;case 22:case 23:Hn(r),Mf(),i!==null&&F(Ha);break;case 24:Qr(bi)}}function Vo(i,r){try{var a=r.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&i)===i){o=void 0;var h=a.create,_=a.inst;o=h(),_.destroy=o}a=a.next}while(a!==u)}}catch(E){Mt(r,r.return,E)}}function Fs(i,r,a){try{var o=r.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var h=u.next;o=h;do{if((o.tag&i)===i){var _=o.inst,E=_.destroy;if(E!==void 0){_.destroy=void 0,u=r;var N=a,Y=E;try{Y()}catch(ce){Mt(u,N,ce)}}}o=o.next}while(o!==h)}}catch(ce){Mt(r,r.return,ce)}}function Gb(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{H_(r,a)}catch(o){Mt(i,i.return,o)}}}function Zb(i,r,a){a.props=qa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(o){Mt(i,r,o)}}function Yo(i,r){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var o=i.stateNode;break;case 30:o=i.stateNode;break;default:o=i.stateNode}typeof a=="function"?i.refCleanup=a(o):a.current=o}}catch(u){Mt(i,r,u)}}function Lr(i,r){var a=i.ref,o=i.refCleanup;if(a!==null)if(typeof o=="function")try{o()}catch(u){Mt(i,r,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){Mt(i,r,u)}else a.current=null}function Qb(i){var r=i.type,a=i.memoizedProps,o=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&o.focus();break e;case"img":a.src?o.src=a.src:a.srcSet&&(o.srcset=a.srcSet)}}catch(u){Mt(i,i.return,u)}}function op(i,r,a){try{var o=i.stateNode;Lk(o,i.type,a,r),o[Pi]=r}catch(u){Mt(i,i.return,u)}}function Jb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Gs(i.type)||i.tag===4}function cp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Jb(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Gs(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function up(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(i),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=cn));else if(o!==4&&(o===27&&Gs(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(up(i,r,a),i=i.sibling;i!==null;)up(i,r,a),i=i.sibling}function rd(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(o!==4&&(o===27&&Gs(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(rd(i,r,a),i=i.sibling;i!==null;)rd(i,r,a),i=i.sibling}function ey(i){var r=i.stateNode,a=i.memoizedProps;try{for(var o=i.type,u=r.attributes;u.length;)r.removeAttributeNode(u[0]);Ji(r,o,a),r[si]=i,r[Pi]=a}catch(h){Mt(i,i.return,h)}}var ns=!1,wi=!1,dp=!1,ty=typeof WeakSet=="function"?WeakSet:Set,Ui=null;function hk(i,r){if(i=i.containerInfo,Ap=kd,i=Ro(i),Mo(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var o=a.getSelection&&a.getSelection();if(o&&o.rangeCount!==0){a=o.anchorNode;var u=o.anchorOffset,h=o.focusNode;o=o.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,E=-1,N=-1,Y=0,ce=0,fe=i,Q=null;t:for(;;){for(var te;fe!==a||u!==0&&fe.nodeType!==3||(E=_+u),fe!==h||o!==0&&fe.nodeType!==3||(N=_+o),fe.nodeType===3&&(_+=fe.nodeValue.length),(te=fe.firstChild)!==null;)Q=fe,fe=te;for(;;){if(fe===i)break t;if(Q===a&&++Y===u&&(E=_),Q===h&&++ce===o&&(N=_),(te=fe.nextSibling)!==null)break;fe=Q,Q=fe.parentNode}fe=te}a=E===-1||N===-1?null:{start:E,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(Lp={focusedElem:i,selectionRange:a},kd=!1,Ui=r;Ui!==null;)if(r=Ui,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ui=i;else for(;Ui!==null;){switch(r=Ui,h=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=r,u=h.memoizedProps,h=h.memoizedState,o=a.stateNode;try{var Ie=qa(a.type,u);i=o.getSnapshotBeforeUpdate(Ie,h),o.__reactInternalSnapshotBeforeUpdate=i}catch(Xe){Mt(a,a.return,Xe)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)jp(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":jp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=r.sibling,i!==null){i.return=r.return,Ui=i;break}Ui=r.return}}function iy(i,r,a){var o=a.flags;switch(a.tag){case 0:case 11:case 15:ss(i,a),o&4&&Vo(5,a);break;case 1:if(ss(i,a),o&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(_){Mt(a,a.return,_)}else{var u=qa(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(u,r,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Mt(a,a.return,_)}}o&64&&Gb(a),o&512&&Yo(a,a.return);break;case 3:if(ss(i,a),o&64&&(i=a.updateQueue,i!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{H_(i,r)}catch(_){Mt(a,a.return,_)}}break;case 27:r===null&&o&4&&ey(a);case 26:case 5:ss(i,a),r===null&&o&4&&Qb(a),o&512&&Yo(a,a.return);break;case 12:ss(i,a);break;case 31:ss(i,a),o&4&&sy(i,a);break;case 13:ss(i,a),o&4&&ay(i,a),o&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Sk.bind(null,a),Uk(i,a))));break;case 22:if(o=a.memoizedState!==null||ns,!o){r=r!==null&&r.memoizedState!==null||wi,u=ns;var h=wi;ns=o,(wi=r)&&!h?as(i,a,(a.subtreeFlags&8772)!==0):ss(i,a),ns=u,wi=h}break;case 30:break;default:ss(i,a)}}function ny(i){var r=i.alternate;r!==null&&(i.alternate=null,ny(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&on(r)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Yt=null,wn=!1;function rs(i,r,a){for(a=a.child;a!==null;)ry(i,r,a),a=a.sibling}function ry(i,r,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(xt,a)}catch{}switch(a.tag){case 26:wi||Lr(a,r),rs(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:wi||Lr(a,r);var o=Yt,u=wn;Gs(a.type)&&(Yt=a.stateNode,wn=!1),rs(i,r,a),nc(a.stateNode),Yt=o,wn=u;break;case 5:wi||Lr(a,r);case 6:if(o=Yt,u=wn,Yt=null,rs(i,r,a),Yt=o,wn=u,Yt!==null)if(wn)try{(Yt.nodeType===9?Yt.body:Yt.nodeName==="HTML"?Yt.ownerDocument.body:Yt).removeChild(a.stateNode)}catch(h){Mt(a,r,h)}else try{Yt.removeChild(a.stateNode)}catch(h){Mt(a,r,h)}break;case 18:Yt!==null&&(wn?(i=Yt,Gy(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),Wl(i)):Gy(Yt,a.stateNode));break;case 4:o=Yt,u=wn,Yt=a.stateNode.containerInfo,wn=!0,rs(i,r,a),Yt=o,wn=u;break;case 0:case 11:case 14:case 15:Fs(2,a,r),wi||Fs(4,a,r),rs(i,r,a);break;case 1:wi||(Lr(a,r),o=a.stateNode,typeof o.componentWillUnmount=="function"&&Zb(a,r,o)),rs(i,r,a);break;case 21:rs(i,r,a);break;case 22:wi=(o=wi)||a.memoizedState!==null,rs(i,r,a),wi=o;break;default:rs(i,r,a)}}function sy(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Wl(i)}catch(a){Mt(r,r.return,a)}}}function ay(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Wl(i)}catch(a){Mt(r,r.return,a)}}function fk(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new ty),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new ty),r;default:throw Error(s(435,i.tag))}}function sd(i,r){var a=fk(i);r.forEach(function(o){if(!a.has(o)){a.add(o);var u=wk.bind(null,i,o);o.then(u,u)}})}function Cn(i,r){var a=r.deletions;if(a!==null)for(var o=0;o<a.length;o++){var u=a[o],h=i,_=r,E=_;e:for(;E!==null;){switch(E.tag){case 27:if(Gs(E.type)){Yt=E.stateNode,wn=!1;break e}break;case 5:Yt=E.stateNode,wn=!1;break e;case 3:case 4:Yt=E.stateNode.containerInfo,wn=!0;break e}E=E.return}if(Yt===null)throw Error(s(160));ry(h,_,u),Yt=null,wn=!1,h=u.alternate,h!==null&&(h.return=null),u.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ly(r,i),r=r.sibling}var vr=null;function ly(i,r){var a=i.alternate,o=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Cn(r,i),xn(i),o&4&&(Fs(3,i,i.return),Vo(3,i),Fs(5,i,i.return));break;case 1:Cn(r,i),xn(i),o&512&&(wi||a===null||Lr(a,a.return)),o&64&&ns&&(i=i.updateQueue,i!==null&&(o=i.callbacks,o!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?o:a.concat(o))));break;case 26:var u=vr;if(Cn(r,i),xn(i),o&512&&(wi||a===null||Lr(a,a.return)),o&4){var h=a!==null?a.memoizedState:null;if(o=i.memoizedState,a===null)if(o===null)if(i.stateNode===null){e:{o=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":h=u.getElementsByTagName("title")[0],(!h||h[It]||h[si]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=u.createElement(o),u.head.insertBefore(h,u.querySelector("head > title"))),Ji(h,o,a),h[si]=i,$t(h),o=h;break e;case"link":var _=lS("link","href",u).get(o+(a.href||""));if(_){for(var E=0;E<_.length;E++)if(h=_[E],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(E,1);break t}}h=u.createElement(o),Ji(h,o,a),u.head.appendChild(h);break;case"meta":if(_=lS("meta","content",u).get(o+(a.content||""))){for(E=0;E<_.length;E++)if(h=_[E],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(E,1);break t}}h=u.createElement(o),Ji(h,o,a),u.head.appendChild(h);break;default:throw Error(s(468,o))}h[si]=i,$t(h),o=h}i.stateNode=o}else oS(u,i.type,i.stateNode);else i.stateNode=aS(u,o,i.memoizedProps);else h!==o?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,o===null?oS(u,i.type,i.stateNode):aS(u,o,i.memoizedProps)):o===null&&i.stateNode!==null&&op(i,i.memoizedProps,a.memoizedProps)}break;case 27:Cn(r,i),xn(i),o&512&&(wi||a===null||Lr(a,a.return)),a!==null&&o&4&&op(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Cn(r,i),xn(i),o&512&&(wi||a===null||Lr(a,a.return)),i.flags&32){u=i.stateNode;try{pr(u,"")}catch(Ie){Mt(i,i.return,Ie)}}o&4&&i.stateNode!=null&&(u=i.memoizedProps,op(i,u,a!==null?a.memoizedProps:u)),o&1024&&(dp=!0);break;case 6:if(Cn(r,i),xn(i),o&4){if(i.stateNode===null)throw Error(s(162));o=i.memoizedProps,a=i.stateNode;try{a.nodeValue=o}catch(Ie){Mt(i,i.return,Ie)}}break;case 3:if(Sd=null,u=vr,vr=bd(r.containerInfo),Cn(r,i),vr=u,xn(i),o&4&&a!==null&&a.memoizedState.isDehydrated)try{Wl(r.containerInfo)}catch(Ie){Mt(i,i.return,Ie)}dp&&(dp=!1,oy(i));break;case 4:o=vr,vr=bd(i.stateNode.containerInfo),Cn(r,i),xn(i),vr=o;break;case 12:Cn(r,i),xn(i);break;case 31:Cn(r,i),xn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,sd(i,o)));break;case 13:Cn(r,i),xn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(ld=Dt()),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,sd(i,o)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,Y=ns,ce=wi;if(ns=Y||u,wi=ce||N,Cn(r,i),wi=ce,ns=Y,xn(i),o&8192)e:for(r=i.stateNode,r._visibility=u?r._visibility&-2:r._visibility|1,u&&(a===null||N||ns||wi||$a(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){N=a=r;try{if(h=N.stateNode,u)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{E=N.stateNode;var fe=N.memoizedProps.style,Q=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;E.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(Ie){Mt(N,N.return,Ie)}}}else if(r.tag===6){if(a===null){N=r;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Ie){Mt(N,N.return,Ie)}}}else if(r.tag===18){if(a===null){N=r;try{var te=N.stateNode;u?Zy(te,!0):Zy(N.stateNode,!1)}catch(Ie){Mt(N,N.return,Ie)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}o&4&&(o=i.updateQueue,o!==null&&(a=o.retryQueue,a!==null&&(o.retryQueue=null,sd(i,a))));break;case 19:Cn(r,i),xn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,sd(i,o)));break;case 30:break;case 21:break;default:Cn(r,i),xn(i)}}function xn(i){var r=i.flags;if(r&2){try{for(var a,o=i.return;o!==null;){if(Jb(o)){a=o;break}o=o.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,h=cp(i);rd(i,h,u);break;case 5:var _=a.stateNode;a.flags&32&&(pr(_,""),a.flags&=-33);var E=cp(i);rd(i,E,_);break;case 3:case 4:var N=a.stateNode.containerInfo,Y=cp(i);up(i,Y,N);break;default:throw Error(s(161))}}catch(ce){Mt(i,i.return,ce)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function oy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;oy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function ss(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)iy(i,r.alternate,r),r=r.sibling}function $a(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Fs(4,r,r.return),$a(r);break;case 1:Lr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&Zb(r,r.return,a),$a(r);break;case 27:nc(r.stateNode);case 26:case 5:Lr(r,r.return),$a(r);break;case 22:r.memoizedState===null&&$a(r);break;case 30:$a(r);break;default:$a(r)}i=i.sibling}}function as(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var o=r.alternate,u=i,h=r,_=h.flags;switch(h.tag){case 0:case 11:case 15:as(u,h,a),Vo(4,h);break;case 1:if(as(u,h,a),o=h,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(Y){Mt(o,o.return,Y)}if(o=h,u=o.updateQueue,u!==null){var E=o.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)I_(N[u],E)}catch(Y){Mt(o,o.return,Y)}}a&&_&64&&Gb(h),Yo(h,h.return);break;case 27:ey(h);case 26:case 5:as(u,h,a),a&&o===null&&_&4&&Qb(h),Yo(h,h.return);break;case 12:as(u,h,a);break;case 31:as(u,h,a),a&&_&4&&sy(u,h);break;case 13:as(u,h,a),a&&_&4&&ay(u,h);break;case 22:h.memoizedState===null&&as(u,h,a),Yo(h,h.return);break;case 30:break;default:as(u,h,a)}r=r.sibling}}function hp(i,r){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Bo(a))}function fp(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Bo(i))}function _r(i,r,a,o){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)cy(i,r,a,o),r=r.sibling}function cy(i,r,a,o){var u=r.flags;switch(r.tag){case 0:case 11:case 15:_r(i,r,a,o),u&2048&&Vo(9,r);break;case 1:_r(i,r,a,o);break;case 3:_r(i,r,a,o),u&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Bo(i)));break;case 12:if(u&2048){_r(i,r,a,o),i=r.stateNode;try{var h=r.memoizedProps,_=h.id,E=h.onPostCommit;typeof E=="function"&&E(_,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){Mt(r,r.return,N)}}else _r(i,r,a,o);break;case 31:_r(i,r,a,o);break;case 13:_r(i,r,a,o);break;case 23:break;case 22:h=r.stateNode,_=r.alternate,r.memoizedState!==null?h._visibility&2?_r(i,r,a,o):Xo(i,r):h._visibility&2?_r(i,r,a,o):(h._visibility|=2,Ll(i,r,a,o,(r.subtreeFlags&10256)!==0||!1)),u&2048&&hp(_,r);break;case 24:_r(i,r,a,o),u&2048&&fp(r.alternate,r);break;default:_r(i,r,a,o)}}function Ll(i,r,a,o,u){for(u=u&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var h=i,_=r,E=a,N=o,Y=_.flags;switch(_.tag){case 0:case 11:case 15:Ll(h,_,E,N,u),Vo(8,_);break;case 23:break;case 22:var ce=_.stateNode;_.memoizedState!==null?ce._visibility&2?Ll(h,_,E,N,u):Xo(h,_):(ce._visibility|=2,Ll(h,_,E,N,u)),u&&Y&2048&&hp(_.alternate,_);break;case 24:Ll(h,_,E,N,u),u&&Y&2048&&fp(_.alternate,_);break;default:Ll(h,_,E,N,u)}r=r.sibling}}function Xo(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=i,o=r,u=o.flags;switch(o.tag){case 22:Xo(a,o),u&2048&&hp(o.alternate,o);break;case 24:Xo(a,o),u&2048&&fp(o.alternate,o);break;default:Xo(a,o)}r=r.sibling}}var Go=8192;function Bl(i,r,a){if(i.subtreeFlags&Go)for(i=i.child;i!==null;)uy(i,r,a),i=i.sibling}function uy(i,r,a){switch(i.tag){case 26:Bl(i,r,a),i.flags&Go&&i.memoizedState!==null&&Jk(a,vr,i.memoizedState,i.memoizedProps);break;case 5:Bl(i,r,a);break;case 3:case 4:var o=vr;vr=bd(i.stateNode.containerInfo),Bl(i,r,a),vr=o;break;case 22:i.memoizedState===null&&(o=i.alternate,o!==null&&o.memoizedState!==null?(o=Go,Go=16777216,Bl(i,r,a),Go=o):Bl(i,r,a));break;default:Bl(i,r,a)}}function dy(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function Zo(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Ui=o,fy(o,i)}dy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)hy(i),i=i.sibling}function hy(i){switch(i.tag){case 0:case 11:case 15:Zo(i),i.flags&2048&&Fs(9,i,i.return);break;case 3:Zo(i);break;case 12:Zo(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,ad(i)):Zo(i);break;default:Zo(i)}}function ad(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Ui=o,fy(o,i)}dy(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Fs(8,r,r.return),ad(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,ad(r));break;default:ad(r)}i=i.sibling}}function fy(i,r){for(;Ui!==null;){var a=Ui;switch(a.tag){case 0:case 11:case 15:Fs(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var o=a.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Bo(a.memoizedState.cache)}if(o=a.child,o!==null)o.return=a,Ui=o;else e:for(a=i;Ui!==null;){o=Ui;var u=o.sibling,h=o.return;if(ny(o),o===a){Ui=null;break e}if(u!==null){u.return=h,Ui=u;break e}Ui=h}}}var pk={getCacheForType:function(i){var r=Zi(bi),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Zi(bi).controller.signal}},mk=typeof WeakMap=="function"?WeakMap:Map,Ct=0,zt=null,pt=null,vt=0,Rt=0,Un=null,Ws=!1,Ol=!1,pp=!1,ls=0,oi=0,qs=0,Va=0,mp=0,Kn=0,jl=0,Qo=null,kn=null,gp=!1,ld=0,py=0,od=1/0,cd=null,$s=null,Ri=0,Vs=null,zl=null,os=0,vp=0,_p=null,my=null,Jo=0,bp=null;function Fn(){return(Ct&2)!==0&&vt!==0?vt&-vt:A.T!==null?kp():Ti()}function gy(){if(Kn===0)if((vt&536870912)===0||bt){var i=st;st<<=1,(st&3932160)===0&&(st=262144),Kn=i}else Kn=536870912;return i=In.current,i!==null&&(i.flags|=32),Kn}function En(i,r,a){(i===zt&&(Rt===2||Rt===9)||i.cancelPendingCommit!==null)&&(Pl(i,0),Ys(i,vt,Kn,!1)),Kt(i,a),((Ct&2)===0||i!==zt)&&(i===zt&&((Ct&2)===0&&(Va|=a),oi===4&&Ys(i,vt,Kn,!1)),Br(i))}function vy(i,r,a){if((Ct&6)!==0)throw Error(s(327));var o=!a&&(r&127)===0&&(r&i.expiredLanes)===0||Ut(i,r),u=o?_k(i,r):Sp(i,r,!0),h=o;do{if(u===0){Ol&&!o&&Ys(i,r,0,!1);break}else{if(a=i.current.alternate,h&&!gk(a)){u=Sp(i,r,!1),h=!1;continue}if(u===2){if(h=r,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){r=_;e:{var E=i;u=Qo;var N=E.current.memoizedState.isDehydrated;if(N&&(Pl(E,_).flags|=256),_=Sp(E,_,!1),_!==2){if(pp&&!N){E.errorRecoveryDisabledLanes|=h,Va|=h,u=4;break e}h=kn,kn=u,h!==null&&(kn===null?kn=h:kn.push.apply(kn,h))}u=_}if(h=!1,u!==2)continue}}if(u===1){Pl(i,0),Ys(i,r,0,!0);break}e:{switch(o=i,h=u,h){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:Ys(o,r,Kn,!Ws);break e;case 2:kn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(u=ld+300-Dt(),10<u)){if(Ys(o,r,Kn,!Ws),Et(o,0,!0)!==0)break e;os=r,o.timeoutHandle=Yy(_y.bind(null,o,a,kn,cd,gp,r,Kn,Va,jl,Ws,h,"Throttled",-0,0),u);break e}_y(o,a,kn,cd,gp,r,Kn,Va,jl,Ws,h,null,-0,0)}}break}while(!0);Br(i)}function _y(i,r,a,o,u,h,_,E,N,Y,ce,fe,Q,te){if(i.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cn},uy(r,h,fe);var Ie=(h&62914560)===h?ld-Dt():(h&4194048)===h?py-Dt():0;if(Ie=eE(fe,Ie),Ie!==null){os=h,i.cancelPendingCommit=Ie(Ey.bind(null,i,r,h,a,o,u,_,E,N,ce,fe,null,Q,te)),Ys(i,h,_,!Y);return}}Ey(i,r,h,a,o,u,_,E,N)}function gk(i){for(var r=i;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var o=0;o<a.length;o++){var u=a[o],h=u.getSnapshot;u=u.value;try{if(!ot(h(),u))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Ys(i,r,a,o){r&=~mp,r&=~Va,i.suspendedLanes|=r,i.pingedLanes&=~r,o&&(i.warmLanes|=r),o=i.expirationTimes;for(var u=r;0<u;){var h=31-kt(u),_=1<<h;o[h]=-1,u&=~_}a!==0&&ji(i,a,r)}function ud(){return(Ct&6)===0?(ec(0),!1):!0}function yp(){if(pt!==null){if(Rt===0)var i=pt.return;else i=pt,Zr=Pa=null,jf(i),Dl=null,jo=0,i=pt;for(;i!==null;)Xb(i.alternate,i),i=i.return;pt=null}}function Pl(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,jk(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),os=0,yp(),zt=i,pt=a=Xr(i.current,null),vt=r,Rt=0,Un=null,Ws=!1,Ol=Ut(i,r),pp=!1,jl=Kn=mp=Va=qs=oi=0,kn=Qo=null,gp=!1,(r&8)!==0&&(r|=r&32);var o=i.entangledLanes;if(o!==0)for(i=i.entanglements,o&=r;0<o;){var u=31-kt(o),h=1<<u;r|=i[u],o&=~h}return ls=r,Nu(),a}function by(i,r){rt=null,A.H=Wo,r===Tl||r===Iu?(r=O_(),Rt=3):r===xf?(r=O_(),Rt=4):Rt=r===Qf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Un=r,pt===null&&(oi=1,Ju(i,Zn(r,i.current)))}function yy(){var i=In.current;return i===null?!0:(vt&4194048)===vt?tr===null:(vt&62914560)===vt||(vt&536870912)!==0?i===tr:!1}function Sy(){var i=A.H;return A.H=Wo,i===null?Wo:i}function wy(){var i=A.A;return A.A=pk,i}function dd(){oi=4,Ws||(vt&4194048)!==vt&&In.current!==null||(Ol=!0),(qs&134217727)===0&&(Va&134217727)===0||zt===null||Ys(zt,vt,Kn,!1)}function Sp(i,r,a){var o=Ct;Ct|=2;var u=Sy(),h=wy();(zt!==i||vt!==r)&&(cd=null,Pl(i,r)),r=!1;var _=oi;e:do try{if(Rt!==0&&pt!==null){var E=pt,N=Un;switch(Rt){case 8:yp(),_=6;break e;case 3:case 2:case 9:case 6:In.current===null&&(r=!0);var Y=Rt;if(Rt=0,Un=null,Il(i,E,N,Y),a&&Ol){_=0;break e}break;default:Y=Rt,Rt=0,Un=null,Il(i,E,N,Y)}}vk(),_=oi;break}catch(ce){by(i,ce)}while(!0);return r&&i.shellSuspendCounter++,Zr=Pa=null,Ct=o,A.H=u,A.A=h,pt===null&&(zt=null,vt=0,Nu()),_}function vk(){for(;pt!==null;)Cy(pt)}function _k(i,r){var a=Ct;Ct|=2;var o=Sy(),u=wy();zt!==i||vt!==r?(cd=null,od=Dt()+500,Pl(i,r)):Ol=Ut(i,r);e:do try{if(Rt!==0&&pt!==null){r=pt;var h=Un;t:switch(Rt){case 1:Rt=0,Un=null,Il(i,r,h,1);break;case 2:case 9:if(L_(h)){Rt=0,Un=null,xy(r);break}r=function(){Rt!==2&&Rt!==9||zt!==i||(Rt=7),Br(i)},h.then(r,r);break e;case 3:Rt=7;break e;case 4:Rt=5;break e;case 7:L_(h)?(Rt=0,Un=null,xy(r)):(Rt=0,Un=null,Il(i,r,h,7));break;case 5:var _=null;switch(pt.tag){case 26:_=pt.memoizedState;case 5:case 27:var E=pt;if(_?cS(_):E.stateNode.complete){Rt=0,Un=null;var N=E.sibling;if(N!==null)pt=N;else{var Y=E.return;Y!==null?(pt=Y,hd(Y)):pt=null}break t}}Rt=0,Un=null,Il(i,r,h,5);break;case 6:Rt=0,Un=null,Il(i,r,h,6);break;case 8:yp(),oi=6;break e;default:throw Error(s(462))}}bk();break}catch(ce){by(i,ce)}while(!0);return Zr=Pa=null,A.H=o,A.A=u,Ct=a,pt!==null?0:(zt=null,vt=0,Nu(),oi)}function bk(){for(;pt!==null&&!nt();)Cy(pt)}function Cy(i){var r=Vb(i.alternate,i,ls);i.memoizedProps=i.pendingProps,r===null?hd(i):pt=r}function xy(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=Ub(a,r,r.pendingProps,r.type,void 0,vt);break;case 11:r=Ub(a,r,r.pendingProps,r.type.render,r.ref,vt);break;case 5:jf(r);default:Xb(a,r),r=pt=w_(r,ls),r=Vb(a,r,ls)}i.memoizedProps=i.pendingProps,r===null?hd(i):pt=r}function Il(i,r,a,o){Zr=Pa=null,jf(r),Dl=null,jo=0;var u=r.return;try{if(lk(i,u,r,a,vt)){oi=1,Ju(i,Zn(a,i.current)),pt=null;return}}catch(h){if(u!==null)throw pt=u,h;oi=1,Ju(i,Zn(a,i.current)),pt=null;return}r.flags&32768?(bt||o===1?i=!0:Ol||(vt&536870912)!==0?i=!1:(Ws=i=!0,(o===2||o===9||o===3||o===6)&&(o=In.current,o!==null&&o.tag===13&&(o.flags|=16384))),ky(r,i)):hd(r)}function hd(i){var r=i;do{if((r.flags&32768)!==0){ky(r,Ws);return}i=r.return;var a=uk(r.alternate,r,ls);if(a!==null){pt=a;return}if(r=r.sibling,r!==null){pt=r;return}pt=r=i}while(r!==null);oi===0&&(oi=5)}function ky(i,r){do{var a=dk(i.alternate,i);if(a!==null){a.flags&=32767,pt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){pt=i;return}pt=i=a}while(i!==null);oi=6,pt=null}function Ey(i,r,a,o,u,h,_,E,N){i.cancelPendingCommit=null;do fd();while(Ri!==0);if((Ct&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(h=r.lanes|r.childLanes,h|=cf,Qt(i,a,h,_,E,N),i===zt&&(pt=zt=null,vt=0),zl=r,Vs=i,os=a,vp=h,_p=u,my=o,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Ck(le,function(){return Ny(),null})):(i.callbackNode=null,i.callbackPriority=0),o=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||o){o=A.T,A.T=null,u=R.p,R.p=2,_=Ct,Ct|=4;try{hk(i,r,a)}finally{Ct=_,R.p=u,A.T=o}}Ri=1,Ty(),Dy(),Ry()}}function Ty(){if(Ri===1){Ri=0;var i=Vs,r=zl,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=A.T,A.T=null;var o=R.p;R.p=2;var u=Ct;Ct|=4;try{ly(r,i);var h=Lp,_=Ro(i.containerInfo),E=h.focusedElem,N=h.selectionRange;if(_!==E&&E&&E.ownerDocument&&un(E.ownerDocument.documentElement,E)){if(N!==null&&Mo(E)){var Y=N.start,ce=N.end;if(ce===void 0&&(ce=Y),"selectionStart"in E)E.selectionStart=Y,E.selectionEnd=Math.min(ce,E.value.length);else{var fe=E.ownerDocument||document,Q=fe&&fe.defaultView||window;if(Q.getSelection){var te=Q.getSelection(),Ie=E.textContent.length,Xe=Math.min(N.start,Ie),Lt=N.end===void 0?Xe:Math.min(N.end,Ie);!te.extend&&Xe>Lt&&(_=Lt,Lt=Xe,Xe=_);var H=Sn(E,Xe),P=Sn(E,Lt);if(H&&P&&(te.rangeCount!==1||te.anchorNode!==H.node||te.anchorOffset!==H.offset||te.focusNode!==P.node||te.focusOffset!==P.offset)){var V=fe.createRange();V.setStart(H.node,H.offset),te.removeAllRanges(),Xe>Lt?(te.addRange(V),te.extend(P.node,P.offset)):(V.setEnd(P.node,P.offset),te.addRange(V))}}}}for(fe=[],te=E;te=te.parentNode;)te.nodeType===1&&fe.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<fe.length;E++){var de=fe[E];de.element.scrollLeft=de.left,de.element.scrollTop=de.top}}kd=!!Ap,Lp=Ap=null}finally{Ct=u,R.p=o,A.T=a}}i.current=r,Ri=2}}function Dy(){if(Ri===2){Ri=0;var i=Vs,r=zl,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=A.T,A.T=null;var o=R.p;R.p=2;var u=Ct;Ct|=4;try{iy(i,r.alternate,r)}finally{Ct=u,R.p=o,A.T=a}}Ri=3}}function Ry(){if(Ri===4||Ri===3){Ri=0,ht();var i=Vs,r=zl,a=os,o=my;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ri=5:(Ri=0,zl=Vs=null,My(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&($s=null),Yi(a),r=r.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(xt,r,void 0,(r.current.flags&128)===128)}catch{}if(o!==null){r=A.T,u=R.p,R.p=2,A.T=null;try{for(var h=i.onRecoverableError,_=0;_<o.length;_++){var E=o[_];h(E.value,{componentStack:E.stack})}}finally{A.T=r,R.p=u}}(os&3)!==0&&fd(),Br(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===bp?Jo++:(Jo=0,bp=i):Jo=0,ec(0)}}function My(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Bo(r)))}function fd(){return Ty(),Dy(),Ry(),Ny()}function Ny(){if(Ri!==5)return!1;var i=Vs,r=vp;vp=0;var a=Yi(os),o=A.T,u=R.p;try{R.p=32>a?32:a,A.T=null,a=_p,_p=null;var h=Vs,_=os;if(Ri=0,zl=Vs=null,os=0,(Ct&6)!==0)throw Error(s(331));var E=Ct;if(Ct|=4,hy(h.current),cy(h,h.current,_,a),Ct=E,ec(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(xt,h)}catch{}return!0}finally{R.p=u,A.T=o,My(i,r)}}function Ay(i,r,a){r=Zn(a,r),r=Zf(i.stateNode,r,2),i=Hs(i,r,2),i!==null&&(Kt(i,2),Br(i))}function Mt(i,r,a){if(i.tag===3)Ay(i,i,a);else for(;r!==null;){if(r.tag===3){Ay(r,i,a);break}else if(r.tag===1){var o=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&($s===null||!$s.has(o))){i=Zn(a,i),a=Lb(2),o=Hs(r,a,2),o!==null&&(Bb(a,o,r,i),Kt(o,2),Br(o));break}}r=r.return}}function wp(i,r,a){var o=i.pingCache;if(o===null){o=i.pingCache=new mk;var u=new Set;o.set(r,u)}else u=o.get(r),u===void 0&&(u=new Set,o.set(r,u));u.has(a)||(pp=!0,u.add(a),i=yk.bind(null,i,r,a),r.then(i,i))}function yk(i,r,a){var o=i.pingCache;o!==null&&o.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,zt===i&&(vt&a)===a&&(oi===4||oi===3&&(vt&62914560)===vt&&300>Dt()-ld?(Ct&2)===0&&Pl(i,0):mp|=a,jl===vt&&(jl=0)),Br(i)}function Ly(i,r){r===0&&(r=Gt()),i=Oa(i,r),i!==null&&(Kt(i,r),Br(i))}function Sk(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Ly(i,a)}function wk(i,r){var a=0;switch(i.tag){case 31:case 13:var o=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:o=i.stateNode;break;case 22:o=i.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(r),Ly(i,a)}function Ck(i,r){return ze(i,r)}var pd=null,Hl=null,Cp=!1,md=!1,xp=!1,Xs=0;function Br(i){i!==Hl&&i.next===null&&(Hl===null?pd=Hl=i:Hl=Hl.next=i),md=!0,Cp||(Cp=!0,kk())}function ec(i,r){if(!xp&&md){xp=!0;do for(var a=!1,o=pd;o!==null;){if(i!==0){var u=o.pendingLanes;if(u===0)var h=0;else{var _=o.suspendedLanes,E=o.pingedLanes;h=(1<<31-kt(42|i)+1)-1,h&=u&~(_&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,zy(o,h))}else h=vt,h=Et(o,o===zt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||Ut(o,h)||(a=!0,zy(o,h));o=o.next}while(a);xp=!1}}function xk(){By()}function By(){md=Cp=!1;var i=0;Xs!==0&&Ok()&&(i=Xs);for(var r=Dt(),a=null,o=pd;o!==null;){var u=o.next,h=Oy(o,r);h===0?(o.next=null,a===null?pd=u:a.next=u,u===null&&(Hl=a)):(a=o,(i!==0||(h&3)!==0)&&(md=!0)),o=u}Ri!==0&&Ri!==5||ec(i),Xs!==0&&(Xs=0)}function Oy(i,r){for(var a=i.suspendedLanes,o=i.pingedLanes,u=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-kt(h),E=1<<_,N=u[_];N===-1?((E&a)===0||(E&o)!==0)&&(u[_]=ri(E,r)):N<=r&&(i.expiredLanes|=E),h&=~E}if(r=zt,a=vt,a=Et(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o=i.callbackNode,a===0||i===r&&(Rt===2||Rt===9)||i.cancelPendingCommit!==null)return o!==null&&o!==null&&Ue(o),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Ut(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(o!==null&&Ue(o),Yi(a)){case 2:case 8:a=di;break;case 32:a=le;break;case 268435456:a=Qe;break;default:a=le}return o=jy.bind(null,i),a=ze(a,o),i.callbackPriority=r,i.callbackNode=a,r}return o!==null&&o!==null&&Ue(o),i.callbackPriority=2,i.callbackNode=null,2}function jy(i,r){if(Ri!==0&&Ri!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(fd()&&i.callbackNode!==a)return null;var o=vt;return o=Et(i,i===zt?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o===0?null:(vy(i,o,r),Oy(i,Dt()),i.callbackNode!=null&&i.callbackNode===a?jy.bind(null,i):null)}function zy(i,r){if(fd())return null;vy(i,r,!0)}function kk(){zk(function(){(Ct&6)!==0?ze(ni,xk):By()})}function kp(){if(Xs===0){var i=kl;i===0&&(i=We,We<<=1,(We&261888)===0&&(We=256)),Xs=i}return Xs}function Py(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Kr(""+i)}function Iy(i,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,i.id&&a.setAttribute("form",i.id),r.parentNode.insertBefore(a,r),i=new FormData(i),a.parentNode.removeChild(a),i}function Ek(i,r,a,o,u){if(r==="submit"&&a&&a.stateNode===u){var h=Py((u[Pi]||null).action),_=o.submitter;_&&(r=(r=_[Pi]||null)?Py(r.formAction):_.getAttribute("formAction"),r!==null&&(h=r,_=null));var E=new S("action","action",null,o,u);i.push({event:E,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Xs!==0){var N=_?Iy(u,_):new FormData(u);qf(a,{pending:!0,data:N,method:u.method,action:h},null,N)}}else typeof h=="function"&&(E.preventDefault(),N=_?Iy(u,_):new FormData(u),qf(a,{pending:!0,data:N,method:u.method,action:h},h,N))},currentTarget:u}]})}}for(var Ep=0;Ep<of.length;Ep++){var Tp=of[Ep],Tk=Tp.toLowerCase(),Dk=Tp[0].toUpperCase()+Tp.slice(1);gr(Tk,"on"+Dk)}gr(g_,"onAnimationEnd"),gr(v_,"onAnimationIteration"),gr(__,"onAnimationStart"),gr("dblclick","onDoubleClick"),gr("focusin","onFocus"),gr("focusout","onBlur"),gr(Wx,"onTransitionRun"),gr(qx,"onTransitionStart"),gr($x,"onTransitionCancel"),gr(b_,"onTransitionEnd"),_n("onMouseEnter",["mouseout","mouseover"]),_n("onMouseLeave",["mouseout","mouseover"]),_n("onPointerEnter",["pointerout","pointerover"]),_n("onPointerLeave",["pointerout","pointerover"]),An("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),An("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),An("onBeforeInput",["compositionend","keypress","textInput","paste"]),An("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),An("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),An("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var tc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Rk=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(tc));function Hy(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var o=i[a],u=o.event;o=o.listeners;e:{var h=void 0;if(r)for(var _=o.length-1;0<=_;_--){var E=o[_],N=E.instance,Y=E.currentTarget;if(E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Y;try{h(u)}catch(ce){Mu(ce)}u.currentTarget=null,h=N}else for(_=0;_<o.length;_++){if(E=o[_],N=E.instance,Y=E.currentTarget,E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Y;try{h(u)}catch(ce){Mu(ce)}u.currentTarget=null,h=N}}}}function mt(i,r){var a=r[Sa];a===void 0&&(a=r[Sa]=new Set);var o=i+"__bubble";a.has(o)||(Uy(r,i,2,!1),a.add(o))}function Dp(i,r,a){var o=0;r&&(o|=4),Uy(a,i,o,r)}var gd="_reactListening"+Math.random().toString(36).slice(2);function Rp(i){if(!i[gd]){i[gd]=!0,dl.forEach(function(a){a!=="selectionchange"&&(Rk.has(a)||Dp(a,!1,i),Dp(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[gd]||(r[gd]=!0,Dp("selectionchange",!1,r))}}function Uy(i,r,a,o){switch(gS(r)){case 2:var u=nE;break;case 8:u=rE;break;default:u=Wp}a=u.bind(null,r,a,i),u=void 0,!Ta||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(u=!0),o?u!==void 0?i.addEventListener(r,a,{capture:!0,passive:u}):i.addEventListener(r,a,!0):u!==void 0?i.addEventListener(r,a,{passive:u}):i.addEventListener(r,a,!1)}function Mp(i,r,a,o,u){var h=o;if((r&1)===0&&(r&2)===0&&o!==null)e:for(;;){if(o===null)return;var _=o.tag;if(_===3||_===4){var E=o.stateNode.containerInfo;if(E===u)break;if(_===4)for(_=o.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;E!==null;){if(_=vi(E),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){o=h=_;continue e}E=E.parentNode}}o=o.return}Wr(function(){var Y=h,ce=Fr(a),fe=[];e:{var Q=y_.get(i);if(Q!==void 0){var te=S,Ie=i;switch(i){case"keypress":if(Dr(a)===0)break e;case"keydown":case"keyup":te=Jh;break;case"focusin":Ie="focus",te=$r;break;case"focusout":Ie="blur",te=$r;break;case"beforeblur":case"afterblur":te=$r;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":te=qe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":te=_i;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":te=ef;break;case g_:case v_:case __:te=Zh;break;case b_:te=nf;break;case"scroll":case"scrollend":te=j;break;case"wheel":te=Co;break;case"copy":case"cut":case"paste":te=Vr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":te=vu;break;case"toggle":case"beforetoggle":te=yu}var Xe=(r&4)!==0,Lt=!Xe&&(i==="scroll"||i==="scrollend"),H=Xe?Q!==null?Q+"Capture":null:Q;Xe=[];for(var P=Y,V;P!==null;){var de=P;if(V=de.stateNode,de=de.tag,de!==5&&de!==26&&de!==27||V===null||H===null||(de=qr(P,H),de!=null&&Xe.push(ic(P,de,V))),Lt)break;P=P.return}0<Xe.length&&(Q=new te(Q,Ie,null,a,ce),fe.push({event:Q,listeners:Xe}))}}if((r&7)===0){e:{if(Q=i==="mouseover"||i==="pointerover",te=i==="mouseout"||i==="pointerout",Q&&a!==Er&&(Ie=a.relatedTarget||a.fromElement)&&(vi(Ie)||Ie[Vn]))break e;if((te||Q)&&(Q=ce.window===ce?ce:(Q=ce.ownerDocument)?Q.defaultView||Q.parentWindow:window,te?(Ie=a.relatedTarget||a.toElement,te=Y,Ie=Ie?vi(Ie):null,Ie!==null&&(Lt=c(Ie),Xe=Ie.tag,Ie!==Lt||Xe!==5&&Xe!==27&&Xe!==6)&&(Ie=null)):(te=null,Ie=Y),te!==Ie)){if(Xe=qe,de="onMouseLeave",H="onMouseEnter",P="mouse",(i==="pointerout"||i==="pointerover")&&(Xe=vu,de="onPointerLeave",H="onPointerEnter",P="pointer"),Lt=te==null?Q:wr(te),V=Ie==null?Q:wr(Ie),Q=new Xe(de,P+"leave",te,a,ce),Q.target=Lt,Q.relatedTarget=V,de=null,vi(ce)===Y&&(Xe=new Xe(H,P+"enter",Ie,a,ce),Xe.target=V,Xe.relatedTarget=Lt,de=Xe),Lt=de,te&&Ie)t:{for(Xe=Mk,H=te,P=Ie,V=0,de=H;de;de=Xe(de))V++;de=0;for(var $e=P;$e;$e=Xe($e))de++;for(;0<V-de;)H=Xe(H),V--;for(;0<de-V;)P=Xe(P),de--;for(;V--;){if(H===P||P!==null&&H===P.alternate){Xe=H;break t}H=Xe(H),P=Xe(P)}Xe=null}else Xe=null;te!==null&&Ky(fe,Q,te,Xe,!1),Ie!==null&&Lt!==null&&Ky(fe,Lt,Ie,Xe,!0)}}e:{if(Q=Y?wr(Y):window,te=Q.nodeName&&Q.nodeName.toLowerCase(),te==="select"||te==="input"&&Q.type==="file")var yt=Du;else if(mr(Q))if(Ru)yt=Je;else{yt=Fe;var He=Ae}else te=Q.nodeName,!te||te.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?Y&&bn(Y.elementType)&&(yt=Du):yt=Ve;if(yt&&(yt=yt(i,Y))){Eu(fe,yt,a,ce);break e}He&&He(i,Q,Y),i==="focusout"&&Y&&Q.type==="number"&&Y.memoizedProps.value!=null&&ks(Q,"number",Q.value)}switch(He=Y?wr(Y):window,i){case"focusin":(mr(He)||He.contentEditable==="true")&&(Yr=He,vl=Y,No=null);break;case"focusout":No=vl=Yr=null;break;case"mousedown":af=!0;break;case"contextmenu":case"mouseup":case"dragend":af=!1,p_(fe,a,ce);break;case"selectionchange":if(Mr)break;case"keydown":case"keyup":p_(fe,a,ce)}var at;if(xo)e:{switch(i){case"compositionstart":var _t="onCompositionStart";break e;case"compositionend":_t="onCompositionEnd";break e;case"compositionupdate":_t="onCompositionUpdate";break e}_t=void 0}else Ls?Rr(i,a)&&(_t="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(_t="onCompositionStart");_t&&(ko&&a.locale!=="ko"&&(Ls||_t!=="onCompositionStart"?_t==="onCompositionEnd"&&Ls&&(at=Ms()):(yn=ce,Da="value"in yn?yn.value:yn.textContent,Ls=!0)),He=vd(Y,_t),0<He.length&&(_t=new fu(_t,i,null,a,ce),fe.push({event:_t,listeners:He}),at?_t.data=at:(at=xu(a),at!==null&&(_t.data=at)))),(at=wu?ku(i,a):rf(i,a))&&(_t=vd(Y,"onBeforeInput"),0<_t.length&&(He=new fu("onBeforeInput","beforeinput",null,a,ce),fe.push({event:He,listeners:_t}),He.data=at)),Ek(fe,i,Y,a,ce)}Hy(fe,r)})}function ic(i,r,a){return{instance:i,listener:r,currentTarget:a}}function vd(i,r){for(var a=r+"Capture",o=[];i!==null;){var u=i,h=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||h===null||(u=qr(i,a),u!=null&&o.unshift(ic(i,u,h)),u=qr(i,r),u!=null&&o.push(ic(i,u,h))),i.tag===3)return o;i=i.return}return[]}function Mk(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Ky(i,r,a,o,u){for(var h=r._reactName,_=[];a!==null&&a!==o;){var E=a,N=E.alternate,Y=E.stateNode;if(E=E.tag,N!==null&&N===o)break;E!==5&&E!==26&&E!==27||Y===null||(N=Y,u?(Y=qr(a,h),Y!=null&&_.unshift(ic(a,Y,N))):u||(Y=qr(a,h),Y!=null&&_.push(ic(a,Y,N)))),a=a.return}_.length!==0&&i.push({event:r,listeners:_})}var Nk=/\r\n?/g,Ak=/\u0000|\uFFFD/g;function Fy(i){return(typeof i=="string"?i:""+i).replace(Nk,`
|
|
10
|
+
`).replace(Ak,"")}function Wy(i,r){return r=Fy(r),Fy(i)===r}function At(i,r,a,o,u,h){switch(a){case"children":typeof o=="string"?r==="body"||r==="textarea"&&o===""||pr(i,o):(typeof o=="number"||typeof o=="bigint")&&r!=="body"&&pr(i,""+o);break;case"className":dr(i,"class",o);break;case"tabIndex":dr(i,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":dr(i,a,o);break;case"style":kr(i,o,h);break;case"data":if(r!=="object"){dr(i,"data",o);break}case"src":case"href":if(o===""&&(r!=="a"||a!=="href")){i.removeAttribute(a);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Kr(""+o),i.setAttribute(a,o);break;case"action":case"formAction":if(typeof o=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(r!=="input"&&At(i,r,"name",u.name,u,null),At(i,r,"formEncType",u.formEncType,u,null),At(i,r,"formMethod",u.formMethod,u,null),At(i,r,"formTarget",u.formTarget,u,null)):(At(i,r,"encType",u.encType,u,null),At(i,r,"method",u.method,u,null),At(i,r,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Kr(""+o),i.setAttribute(a,o);break;case"onClick":o!=null&&(i.onclick=cn);break;case"onScroll":o!=null&&mt("scroll",i);break;case"onScrollEnd":o!=null&&mt("scrollend",i);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":i.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){i.removeAttribute("xlink:href");break}a=Kr(""+o),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""+o):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":o===!0?i.setAttribute(a,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,o):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?i.setAttribute(a,o):i.removeAttribute(a);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?i.removeAttribute(a):i.setAttribute(a,o);break;case"popover":mt("beforetoggle",i),mt("toggle",i),Cr(i,"popover",o);break;case"xlinkActuate":Ln(i,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Ln(i,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Ln(i,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Ln(i,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Ln(i,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Ln(i,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Ln(i,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Ln(i,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Ln(i,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Cr(i,"is",o);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=pl.get(a)||a,Cr(i,a,o))}}function Np(i,r,a,o,u,h){switch(a){case"style":kr(i,o,h);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof o=="string"?pr(i,o):(typeof o=="number"||typeof o=="bigint")&&pr(i,""+o);break;case"onScroll":o!=null&&mt("scroll",i);break;case"onScrollEnd":o!=null&&mt("scrollend",i);break;case"onClick":o!=null&&(i.onclick=cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Cs.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),r=a.slice(2,u?a.length-7:void 0),h=i[Pi]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(r,h,u),typeof o=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(r,o,u);break e}a in i?i[a]=o:o===!0?i.setAttribute(a,""):Cr(i,a,o)}}}function Ji(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mt("error",i),mt("load",i);var o=!1,u=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:At(i,r,h,_,a,null)}}u&&At(i,r,"srcSet",a.srcSet,a,null),o&&At(i,r,"src",a.src,a,null);return;case"input":mt("invalid",i);var E=h=_=u=null,N=null,Y=null;for(o in a)if(a.hasOwnProperty(o)){var ce=a[o];if(ce!=null)switch(o){case"name":u=ce;break;case"type":_=ce;break;case"checked":N=ce;break;case"defaultChecked":Y=ce;break;case"value":h=ce;break;case"defaultValue":E=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,r));break;default:At(i,r,o,ce,a,null)}}fr(i,h,E,N,Y,_,u,!1);return;case"select":mt("invalid",i),o=_=h=null;for(u in a)if(a.hasOwnProperty(u)&&(E=a[u],E!=null))switch(u){case"value":h=E;break;case"defaultValue":_=E;break;case"multiple":o=E;default:At(i,r,u,E,a,null)}r=h,a=_,i.multiple=!!o,r!=null?ai(i,!!o,r,!1):a!=null&&ai(i,!!o,a,!0);return;case"textarea":mt("invalid",i),h=u=o=null;for(_ in a)if(a.hasOwnProperty(_)&&(E=a[_],E!=null))switch(_){case"value":o=E;break;case"defaultValue":u=E;break;case"children":h=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(s(91));break;default:At(i,r,_,E,a,null)}ka(i,o,u,h);return;case"option":for(N in a)a.hasOwnProperty(N)&&(o=a[N],o!=null)&&(N==="selected"?i.selected=o&&typeof o!="function"&&typeof o!="symbol":At(i,r,N,o,a,null));return;case"dialog":mt("beforetoggle",i),mt("toggle",i),mt("cancel",i),mt("close",i);break;case"iframe":case"object":mt("load",i);break;case"video":case"audio":for(o=0;o<tc.length;o++)mt(tc[o],i);break;case"image":mt("error",i),mt("load",i);break;case"details":mt("toggle",i);break;case"embed":case"source":case"link":mt("error",i),mt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Y in a)if(a.hasOwnProperty(Y)&&(o=a[Y],o!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:At(i,r,Y,o,a,null)}return;default:if(bn(r)){for(ce in a)a.hasOwnProperty(ce)&&(o=a[ce],o!==void 0&&Np(i,r,ce,o,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(o=a[E],o!=null&&At(i,r,E,o,a,null))}function Lk(i,r,a,o){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,h=null,_=null,E=null,N=null,Y=null,ce=null;for(te in a){var fe=a[te];if(a.hasOwnProperty(te)&&fe!=null)switch(te){case"checked":break;case"value":break;case"defaultValue":N=fe;default:o.hasOwnProperty(te)||At(i,r,te,null,o,fe)}}for(var Q in o){var te=o[Q];if(fe=a[Q],o.hasOwnProperty(Q)&&(te!=null||fe!=null))switch(Q){case"type":h=te;break;case"name":u=te;break;case"checked":Y=te;break;case"defaultChecked":ce=te;break;case"value":_=te;break;case"defaultValue":E=te;break;case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(s(137,r));break;default:te!==fe&&At(i,r,Q,te,o,fe)}}dt(i,_,E,N,Y,ce,h,u);return;case"select":te=_=E=Q=null;for(h in a)if(N=a[h],a.hasOwnProperty(h)&&N!=null)switch(h){case"value":break;case"multiple":te=N;default:o.hasOwnProperty(h)||At(i,r,h,null,o,N)}for(u in o)if(h=o[u],N=a[u],o.hasOwnProperty(u)&&(h!=null||N!=null))switch(u){case"value":Q=h;break;case"defaultValue":E=h;break;case"multiple":_=h;default:h!==N&&At(i,r,u,h,o,N)}r=E,a=_,o=te,Q!=null?ai(i,!!a,Q,!1):!!o!=!!a&&(r!=null?ai(i,!!a,r,!0):ai(i,!!a,a?[]:"",!1));return;case"textarea":te=Q=null;for(E in a)if(u=a[E],a.hasOwnProperty(E)&&u!=null&&!o.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:At(i,r,E,null,o,u)}for(_ in o)if(u=o[_],h=a[_],o.hasOwnProperty(_)&&(u!=null||h!=null))switch(_){case"value":Q=u;break;case"defaultValue":te=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==h&&At(i,r,_,u,o,h)}xa(i,Q,te);return;case"option":for(var Ie in a)Q=a[Ie],a.hasOwnProperty(Ie)&&Q!=null&&!o.hasOwnProperty(Ie)&&(Ie==="selected"?i.selected=!1:At(i,r,Ie,null,o,Q));for(N in o)Q=o[N],te=a[N],o.hasOwnProperty(N)&&Q!==te&&(Q!=null||te!=null)&&(N==="selected"?i.selected=Q&&typeof Q!="function"&&typeof Q!="symbol":At(i,r,N,Q,o,te));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Xe in a)Q=a[Xe],a.hasOwnProperty(Xe)&&Q!=null&&!o.hasOwnProperty(Xe)&&At(i,r,Xe,null,o,Q);for(Y in o)if(Q=o[Y],te=a[Y],o.hasOwnProperty(Y)&&Q!==te&&(Q!=null||te!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(s(137,r));break;default:At(i,r,Y,Q,o,te)}return;default:if(bn(r)){for(var Lt in a)Q=a[Lt],a.hasOwnProperty(Lt)&&Q!==void 0&&!o.hasOwnProperty(Lt)&&Np(i,r,Lt,void 0,o,Q);for(ce in o)Q=o[ce],te=a[ce],!o.hasOwnProperty(ce)||Q===te||Q===void 0&&te===void 0||Np(i,r,ce,Q,o,te);return}}for(var H in a)Q=a[H],a.hasOwnProperty(H)&&Q!=null&&!o.hasOwnProperty(H)&&At(i,r,H,null,o,Q);for(fe in o)Q=o[fe],te=a[fe],!o.hasOwnProperty(fe)||Q===te||Q==null&&te==null||At(i,r,fe,Q,o,te)}function qy(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Bk(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=0,a=performance.getEntriesByType("resource"),o=0;o<a.length;o++){var u=a[o],h=u.transferSize,_=u.initiatorType,E=u.duration;if(h&&E&&qy(_)){for(_=0,E=u.responseEnd,o+=1;o<a.length;o++){var N=a[o],Y=N.startTime;if(Y>E)break;var ce=N.transferSize,fe=N.initiatorType;ce&&qy(fe)&&(N=N.responseEnd,_+=ce*(N<E?1:(E-Y)/(N-Y)))}if(--o,r+=8*(h+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Ap=null,Lp=null;function _d(i){return i.nodeType===9?i:i.ownerDocument}function $y(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Vy(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function Bp(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Op=null;function Ok(){var i=window.event;return i&&i.type==="popstate"?i===Op?!1:(Op=i,!0):(Op=null,!1)}var Yy=typeof setTimeout=="function"?setTimeout:void 0,jk=typeof clearTimeout=="function"?clearTimeout:void 0,Xy=typeof Promise=="function"?Promise:void 0,zk=typeof queueMicrotask=="function"?queueMicrotask:typeof Xy<"u"?function(i){return Xy.resolve(null).then(i).catch(Pk)}:Yy;function Pk(i){setTimeout(function(){throw i})}function Gs(i){return i==="head"}function Gy(i,r){var a=r,o=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(o===0){i.removeChild(u),Wl(r);return}o--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")o++;else if(a==="html")nc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,nc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,E=h.nodeName;h[It]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&nc(i.ownerDocument.body);a=u}while(a);Wl(r)}function Zy(i,r){var a=i;i=0;do{var o=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),o&&o.nodeType===8)if(a=o.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=o}while(a)}function jp(i){var r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":jp(a),on(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Ik(i,r,a,o){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!o&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(o){if(!i[It])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var h=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=ir(i.nextSibling),i===null)break}return null}function Hk(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ir(i.nextSibling),i===null))return null;return i}function Qy(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=ir(i.nextSibling),i===null))return null;return i}function zp(i){return i.data==="$?"||i.data==="$~"}function Pp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Uk(i,r){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||a.readyState!=="loading")r();else{var o=function(){r(),a.removeEventListener("DOMContentLoaded",o)};a.addEventListener("DOMContentLoaded",o),i._reactRetry=o}}function ir(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var Ip=null;function Jy(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return ir(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function eS(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return i;r--}else a!=="/$"&&a!=="/&"||r++}i=i.previousSibling}return null}function tS(i,r,a){switch(r=_d(a),i){case"html":if(i=r.documentElement,!i)throw Error(s(452));return i;case"head":if(i=r.head,!i)throw Error(s(453));return i;case"body":if(i=r.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function nc(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);on(i)}var nr=new Map,iS=new Set;function bd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var cs=R.d;R.d={f:Kk,r:Fk,D:Wk,C:qk,L:$k,m:Vk,X:Xk,S:Yk,M:Gk};function Kk(){var i=cs.f(),r=ud();return i||r}function Fk(i){var r=Xn(i);r!==null&&r.tag===5&&r.type==="form"?bb(r):cs.r(i)}var Ul=typeof document>"u"?null:document;function nS(i,r,a){var o=Ul;if(o&&typeof r=="string"&&r){var u=Ii(r);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),iS.has(u)||(iS.add(u),i={rel:i,crossOrigin:a,href:r},o.querySelector(u)===null&&(r=o.createElement("link"),Ji(r,"link",i),$t(r),o.head.appendChild(r)))}}function Wk(i){cs.D(i),nS("dns-prefetch",i,null)}function qk(i,r){cs.C(i,r),nS("preconnect",i,r)}function $k(i,r,a){cs.L(i,r,a);var o=Ul;if(o&&i&&r){var u='link[rel="preload"][as="'+Ii(r)+'"]';r==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Ii(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Ii(a.imageSizes)+'"]')):u+='[href="'+Ii(i)+'"]';var h=u;switch(r){case"style":h=Kl(i);break;case"script":h=Fl(i)}nr.has(h)||(i=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),nr.set(h,i),o.querySelector(u)!==null||r==="style"&&o.querySelector(rc(h))||r==="script"&&o.querySelector(sc(h))||(r=o.createElement("link"),Ji(r,"link",i),$t(r),o.head.appendChild(r)))}}function Vk(i,r){cs.m(i,r);var a=Ul;if(a&&i){var o=r&&typeof r.as=="string"?r.as:"script",u='link[rel="modulepreload"][as="'+Ii(o)+'"][href="'+Ii(i)+'"]',h=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Fl(i)}if(!nr.has(h)&&(i=b({rel:"modulepreload",href:i},r),nr.set(h,i),a.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(sc(h)))return}o=a.createElement("link"),Ji(o,"link",i),$t(o),a.head.appendChild(o)}}}function Yk(i,r,a){cs.S(i,r,a);var o=Ul;if(o&&i){var u=vn(o).hoistableStyles,h=Kl(i);r=r||"default";var _=u.get(h);if(!_){var E={loading:0,preload:null};if(_=o.querySelector(rc(h)))E.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":r},a),(a=nr.get(h))&&Hp(i,a);var N=_=o.createElement("link");$t(N),Ji(N,"link",i),N._p=new Promise(function(Y,ce){N.onload=Y,N.onerror=ce}),N.addEventListener("load",function(){E.loading|=1}),N.addEventListener("error",function(){E.loading|=2}),E.loading|=4,yd(_,r,o)}_={type:"stylesheet",instance:_,count:1,state:E},u.set(h,_)}}}function Xk(i,r){cs.X(i,r);var a=Ul;if(a&&i){var o=vn(a).hoistableScripts,u=Fl(i),h=o.get(u);h||(h=a.querySelector(sc(u)),h||(i=b({src:i,async:!0},r),(r=nr.get(u))&&Up(i,r),h=a.createElement("script"),$t(h),Ji(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(u,h))}}function Gk(i,r){cs.M(i,r);var a=Ul;if(a&&i){var o=vn(a).hoistableScripts,u=Fl(i),h=o.get(u);h||(h=a.querySelector(sc(u)),h||(i=b({src:i,async:!0,type:"module"},r),(r=nr.get(u))&&Up(i,r),h=a.createElement("script"),$t(h),Ji(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(u,h))}}function rS(i,r,a,o){var u=(u=Ee.current)?bd(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Kl(a.href),a=vn(u).hoistableStyles,o=a.get(r),o||(o={type:"style",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Kl(a.href);var h=vn(u).hoistableStyles,_=h.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=u.querySelector(rc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),nr.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},nr.set(i,a),h||Zk(u,i,a,_.state))),r&&o===null)throw Error(s(528,""));return _}if(r&&o!==null)throw Error(s(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fl(a),a=vn(u).hoistableScripts,o=a.get(r),o||(o={type:"script",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Kl(i){return'href="'+Ii(i)+'"'}function rc(i){return'link[rel="stylesheet"]['+i+"]"}function sS(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function Zk(i,r,a,o){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?o.loading=1:(r=i.createElement("link"),o.preload=r,r.addEventListener("load",function(){return o.loading|=1}),r.addEventListener("error",function(){return o.loading|=2}),Ji(r,"link",a),$t(r),i.head.appendChild(r))}function Fl(i){return'[src="'+Ii(i)+'"]'}function sc(i){return"script[async]"+i}function aS(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var o=i.querySelector('style[data-href~="'+Ii(a.href)+'"]');if(o)return r.instance=o,$t(o),o;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return o=(i.ownerDocument||i).createElement("style"),$t(o),Ji(o,"style",u),yd(o,a.precedence,i),r.instance=o;case"stylesheet":u=Kl(a.href);var h=i.querySelector(rc(u));if(h)return r.state.loading|=4,r.instance=h,$t(h),h;o=sS(a),(u=nr.get(u))&&Hp(o,u),h=(i.ownerDocument||i).createElement("link"),$t(h);var _=h;return _._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),Ji(h,"link",o),r.state.loading|=4,yd(h,a.precedence,i),r.instance=h;case"script":return h=Fl(a.src),(u=i.querySelector(sc(h)))?(r.instance=u,$t(u),u):(o=a,(u=nr.get(h))&&(o=b({},a),Up(o,u)),i=i.ownerDocument||i,u=i.createElement("script"),$t(u),Ji(u,"link",o),i.head.appendChild(u),r.instance=u);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(o=r.instance,r.state.loading|=4,yd(o,a.precedence,i));return r.instance}function yd(i,r,a){for(var o=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,h=u,_=0;_<o.length;_++){var E=o[_];if(E.dataset.precedence===r)h=E;else if(h!==u)break}h?h.parentNode.insertBefore(i,h.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function Hp(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Up(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var Sd=null;function lS(i,r,a){if(Sd===null){var o=new Map,u=Sd=new Map;u.set(a,o)}else u=Sd,o=u.get(a),o||(o=new Map,u.set(a,o));if(o.has(i))return o;for(o.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var h=a[u];if(!(h[It]||h[si]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(r)||"";_=i+_;var E=o.get(_);E?E.push(h):o.set(_,[h])}}return o}function oS(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function Qk(i,r,a){if(a===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(i=r.disabled,typeof r.precedence=="string"&&i==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function cS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Jk(i,r,a,o){if(a.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=Kl(o.href),h=r.querySelector(rc(u));if(h){r=h._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=wd.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=h,$t(h);return}h=r.ownerDocument||r,o=sS(o),(u=nr.get(u))&&Hp(o,u),h=h.createElement("link"),$t(h);var _=h;_._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),Ji(h,"link",o),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=wd.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Kp=0;function eE(i,r){return i.stylesheets&&i.count===0&&xd(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var o=setTimeout(function(){if(i.stylesheets&&xd(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+r);0<i.imgBytes&&Kp===0&&(Kp=62500*Bk());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&xd(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>Kp?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function wd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Cd=null;function xd(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Cd=new Map,r.forEach(tE,i),Cd=null,wd.call(i))}function tE(i,r){if(!(r.state.loading&4)){var a=Cd.get(i);if(a)var o=a.get(null);else{a=new Map,Cd.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<u.length;h++){var _=u[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),o=_)}o&&a.set(null,o)}u=r.instance,_=u.getAttribute("data-precedence"),h=a.get(_)||o,h===o&&a.set(null,u),a.set(_,u),this.count++,o=wd.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),h?h.parentNode.insertBefore(u,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),r.state.loading|=4}}var ac={$$typeof:X,Provider:null,Consumer:null,_currentValue:z,_currentValue2:z,_threadCount:0};function iE(i,r,a,o,u,h,_,E,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Zt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zt(0),this.hiddenUpdates=Zt(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function uS(i,r,a,o,u,h,_,E,N,Y,ce,fe){return i=new iE(i,r,a,_,N,Y,ce,fe,E),r=1,h===!0&&(r|=24),h=Pn(3,null,null,r),i.current=h,h.stateNode=i,r=Sf(),r.refCount++,i.pooledCache=r,r.refCount++,h.memoizedState={element:o,isDehydrated:a,cache:r},kf(h),i}function dS(i){return i?(i=yl,i):yl}function hS(i,r,a,o,u,h){u=dS(u),o.context===null?o.context=u:o.pendingContext=u,o=Is(r),o.payload={element:a},h=h===void 0?null:h,h!==null&&(o.callback=h),a=Hs(i,o,r),a!==null&&(En(a,i,r),Po(a,i,r))}function fS(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Fp(i,r){fS(i,r),(i=i.alternate)&&fS(i,r)}function pS(i){if(i.tag===13||i.tag===31){var r=Oa(i,67108864);r!==null&&En(r,i,67108864),Fp(i,67108864)}}function mS(i){if(i.tag===13||i.tag===31){var r=Fn();r=gn(r);var a=Oa(i,r);a!==null&&En(a,i,r),Fp(i,r)}}var kd=!0;function nE(i,r,a,o){var u=A.T;A.T=null;var h=R.p;try{R.p=2,Wp(i,r,a,o)}finally{R.p=h,A.T=u}}function rE(i,r,a,o){var u=A.T;A.T=null;var h=R.p;try{R.p=8,Wp(i,r,a,o)}finally{R.p=h,A.T=u}}function Wp(i,r,a,o){if(kd){var u=qp(o);if(u===null)Mp(i,r,o,Ed,a),vS(i,o);else if(aE(u,i,r,a,o))o.stopPropagation();else if(vS(i,o),r&4&&-1<sE.indexOf(i)){for(;u!==null;){var h=Xn(u);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=wt(h.pendingLanes);if(_!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;_;){var N=1<<31-kt(_);E.entanglements[1]|=N,_&=~N}Br(h),(Ct&6)===0&&(od=Dt()+500,ec(0))}}break;case 31:case 13:E=Oa(h,2),E!==null&&En(E,h,2),ud(),Fp(h,2)}if(h=qp(o),h===null&&Mp(i,r,o,Ed,a),h===u)break;u=h}u!==null&&o.stopPropagation()}else Mp(i,r,o,null,a)}}function qp(i){return i=Fr(i),$p(i)}var Ed=null;function $p(i){if(Ed=null,i=vi(i),i!==null){var r=c(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=d(r),i!==null)return i;i=null}else if(a===31){if(i=m(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return Ed=i,null}function gS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ei()){case ni:return 2;case di:return 8;case le:case Ne:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var Vp=!1,Zs=null,Qs=null,Js=null,lc=new Map,oc=new Map,ea=[],sE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function vS(i,r){switch(i){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":Qs=null;break;case"mouseover":case"mouseout":Js=null;break;case"pointerover":case"pointerout":lc.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":oc.delete(r.pointerId)}}function cc(i,r,a,o,u,h){return i===null||i.nativeEvent!==h?(i={blockedOn:r,domEventName:a,eventSystemFlags:o,nativeEvent:h,targetContainers:[u]},r!==null&&(r=Xn(r),r!==null&&pS(r)),i):(i.eventSystemFlags|=o,r=i.targetContainers,u!==null&&r.indexOf(u)===-1&&r.push(u),i)}function aE(i,r,a,o,u){switch(r){case"focusin":return Zs=cc(Zs,i,r,a,o,u),!0;case"dragenter":return Qs=cc(Qs,i,r,a,o,u),!0;case"mouseover":return Js=cc(Js,i,r,a,o,u),!0;case"pointerover":var h=u.pointerId;return lc.set(h,cc(lc.get(h)||null,i,r,a,o,u)),!0;case"gotpointercapture":return h=u.pointerId,oc.set(h,cc(oc.get(h)||null,i,r,a,o,u)),!0}return!1}function _S(i){var r=vi(i.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=d(a),r!==null){i.blockedOn=r,ln(i.priority,function(){mS(a)});return}}else if(r===31){if(r=m(a),r!==null){i.blockedOn=r,ln(i.priority,function(){mS(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Td(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=qp(i.nativeEvent);if(a===null){a=i.nativeEvent;var o=new a.constructor(a.type,a);Er=o,a.target.dispatchEvent(o),Er=null}else return r=Xn(a),r!==null&&pS(r),i.blockedOn=a,!1;r.shift()}return!0}function bS(i,r,a){Td(i)&&a.delete(r)}function lE(){Vp=!1,Zs!==null&&Td(Zs)&&(Zs=null),Qs!==null&&Td(Qs)&&(Qs=null),Js!==null&&Td(Js)&&(Js=null),lc.forEach(bS),oc.forEach(bS)}function Dd(i,r){i.blockedOn===r&&(i.blockedOn=null,Vp||(Vp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,lE)))}var Rd=null;function yS(i){Rd!==i&&(Rd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Rd===i&&(Rd=null);for(var r=0;r<i.length;r+=3){var a=i[r],o=i[r+1],u=i[r+2];if(typeof o!="function"){if($p(o||a)===null)continue;break}var h=Xn(a);h!==null&&(i.splice(r,3),r-=3,qf(h,{pending:!0,data:u,method:a.method,action:o},o,u))}}))}function Wl(i){function r(N){return Dd(N,i)}Zs!==null&&Dd(Zs,i),Qs!==null&&Dd(Qs,i),Js!==null&&Dd(Js,i),lc.forEach(r),oc.forEach(r);for(var a=0;a<ea.length;a++){var o=ea[a];o.blockedOn===i&&(o.blockedOn=null)}for(;0<ea.length&&(a=ea[0],a.blockedOn===null);)_S(a),a.blockedOn===null&&ea.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(o=0;o<a.length;o+=3){var u=a[o],h=a[o+1],_=u[Pi]||null;if(typeof h=="function")_||yS(a);else if(_){var E=null;if(h&&h.hasAttribute("formAction")){if(u=h,_=h[Pi]||null)E=_.formAction;else if($p(u)!==null)continue}else E=_.action;typeof E=="function"?a[o+1]=E:(a.splice(o,3),o-=3),yS(a)}}}function SS(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function r(){u!==null&&(u(),u=null),o||setTimeout(a,20)}function a(){if(!o&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){o=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),u!==null&&(u(),u=null)}}}function Yp(i){this._internalRoot=i}Md.prototype.render=Yp.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,o=Fn();hS(a,o,i,r,null,null)},Md.prototype.unmount=Yp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;hS(i.current,2,null,i,null,null),ud(),r[Vn]=null}};function Md(i){this._internalRoot=i}Md.prototype.unstable_scheduleHydration=function(i){if(i){var r=Ti();i={blockedOn:null,target:i,priority:r};for(var a=0;a<ea.length&&r!==0&&r<ea[a].priority;a++);ea.splice(a,0,i),a===0&&_S(i)}};var wS=t.version;if(wS!=="19.2.6")throw Error(s(527,wS,"19.2.6"));R.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(r),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var oE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nd.isDisabled&&Nd.supportsFiber)try{xt=Nd.inject(oE),gt=Nd}catch{}}return dc.createRoot=function(i,r){if(!l(i))throw Error(s(299));var a=!1,o="",u=Rb,h=Mb,_=Nb;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(o=r.identifierPrefix),r.onUncaughtError!==void 0&&(u=r.onUncaughtError),r.onCaughtError!==void 0&&(h=r.onCaughtError),r.onRecoverableError!==void 0&&(_=r.onRecoverableError)),r=uS(i,1,!1,null,null,a,o,null,u,h,_,SS),i[Vn]=r.current,Rp(i),new Yp(r)},dc.hydrateRoot=function(i,r,a){if(!l(i))throw Error(s(299));var o=!1,u="",h=Rb,_=Mb,E=Nb,N=null;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(E=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),r=uS(i,1,!0,r,a??null,o,u,N,h,_,E,SS),r.context=dS(null),a=r.current,o=Fn(),o=gn(o),u=Is(o),u.callback=null,Hs(a,u,o),a=o,r.current.lanes=a,Kt(r,a),Br(r),i[Vn]=r.current,Rp(i),new Md(r)},dc.version="19.2.6",dc}var AS;function _E(){if(AS)return Zp.exports;AS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Zp.exports=vE(),Zp.exports}var bE=_E();class or extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Mh(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${ua(t)}`),setupPassword:t=>De(e,"/api/auth/password",Ge("POST",t)),login:t=>De(e,"/api/auth/login",Ge("POST",t)),reauth:t=>De(e,"/api/auth/reauth",Ge("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",Ge("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",Ge("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Yl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",Ge("POST",t)),removeNetwork:async t=>{await Yl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",Ge("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",Ge("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,Ge("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",Ge("PATCH",{name:t})),removeAgent:async t=>{await Yl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${ua(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",Ge("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",Ge("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",Ge("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",Ge("POST",t)),listFiles:t=>De(e,"/api/files/list",Ge("POST",t)),readFile:t=>De(e,"/api/files/read",Ge("POST",t)),writeFile:t=>De(e,"/api/files/write",Ge("POST",t)),createFileEntry:t=>De(e,"/api/files/create",Ge("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",Ge("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",Ge("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",Ge("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",Ge("POST",t)),previewFile:t=>Yw(e,"/api/files/preview",Ge("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",Ge("POST",t)),closeTerminal:async t=>{await Yl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,Ge("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${ua(n)}`),getTerminalTranscriptHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${ua(n)}`),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",Ge("PUT",t)),deleteNotificationAsset:async t=>{await Yl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?ua({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",Ge("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",Ge("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",Ge("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",Ge("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",Ge("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",Ge("POST",t))}}function no(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(s={})=>De(t,n("terminals"),Ge("POST",s)),closeTerminal:async s=>{await Yl(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,l)=>De(t,n(`terminals/${encodeURIComponent(s)}`),Ge("PATCH",{title:l})),getTerminalHistory:(s,l={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${ua(l)}`),getTerminalTranscriptHistory:(s,l={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${ua(l)}`),getTerminalTranscriptSource:s=>De(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:s=>De(t,n("terminal-layout"),Ge("PUT",s)),createFileRoot:s=>De(t,n("files/root"),Ge("POST",s)),listFiles:s=>De(t,n("files/list"),Ge("POST",s)),readFile:s=>De(t,n("files/read"),Ge("POST",s)),writeFile:s=>De(t,n("files/write"),Ge("POST",s)),createFileEntry:s=>De(t,n("files/create"),Ge("POST",s)),moveFileEntry:s=>De(t,n("files/move"),Ge("POST",s)),previewDeleteFileEntry:s=>De(t,n("files/delete-preview"),Ge("POST",s)),deleteFileEntry:s=>De(t,n("files/delete"),Ge("POST",s)),openFileInTerminal:s=>De(t,n("files/open"),Ge("POST",s)),previewFile:s=>Yw(t,n("files/preview"),Ge("POST",s)),getCodeServerStatus:(s={})=>De(t,`${n("code-server/status")}${ua(s)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>De(t,n("code-server/open"),Ge("POST",s)),stopCodeServer:(s={})=>De(t,n("code-server/stop"),Ge("POST",s)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,l=window.location.href)=>yE(n(`terminals/${encodeURIComponent(s)}/ws`),l)}}function yE(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function Ge(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function ua(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function De(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await bv(s);try{return await s.json()}catch{throw new or(s.status,"invalid_json_response")}}async function Yl(e,t,n){const s=await e(t,n);await bv(s)}async function Yw(e,t,n){const s=await e(t,n);return await bv(s),s.blob()}async function bv(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),s=typeof n.error=="string"?n.error:n.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new or(e.status,t)}const yv="nterminal.theme.id",Xw="nterminal.theme.accent",zm="nterminal:theme",oh=[{id:"midnight",label:"Midnight",description:"Current dark terminal look with aqua focus.",mode:"dark",tokens:{bg:"#0a0d10",bg2:"#0d1216",bgSidebar:"#08090b",line:"#1a2128",line2:"#2a3340",fg:"#e2e8ee",fg2:"#8896a3",fg3:"#54616d",fg4:"#3f4a54",accent:"#5eead4",accentSoft:"rgba(94, 234, 212, 0.10)",accentGlow:"rgba(94, 234, 212, 0.55)",onAccent:"#062423",ok:"#34d399",danger:"#f87171",onDanger:"#190607",dangerSoft:"rgba(248, 113, 113, 0.08)",dangerLine:"rgba(248, 113, 113, 0.30)",warning:"#fbbf24",warningSoft:"rgba(247, 217, 119, 0.075)",warningGlow:"rgba(245, 158, 11, 0.55)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.35)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(10, 13, 16, 0.86)",floatingBgStrong:"rgba(10, 13, 16, 0.96)",floatingBgHover:"rgba(15, 23, 27, 0.94)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.015)",scrollbarThumb:"rgba(148, 163, 184, 0.50)",scrollbarThumbHover:"rgba(148, 163, 184, 0.70)",transcriptUser:"#f7d977",transcriptAssistant:"#5eead4",transcriptTool:"#9aa7b4",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f7d977",transcriptOnSearch:"#121417",qrBg:"#ffffff"},xterm:{background:"#0a0d10",foreground:"#e2e8ee",cursor:"#5eead4",selectionBackground:"#1f3f45"}},{id:"daylight",label:"Daylight",description:"Light workspace with dark terminal contrast.",mode:"light",tokens:{bg:"#f7f9fc",bg2:"#ffffff",bgSidebar:"#eef2f7",line:"#dbe3ec",line2:"#c3cedb",fg:"#17212b",fg2:"#526170",fg3:"#7b8794",fg4:"#a1acb8",accent:"#0f8f83",accentSoft:"rgba(15, 143, 131, 0.11)",accentGlow:"rgba(15, 143, 131, 0.24)",onAccent:"#021918",ok:"#16835c",danger:"#c03545",onDanger:"#fff7f8",dangerSoft:"rgba(192, 53, 69, 0.10)",dangerLine:"rgba(192, 53, 69, 0.30)",warning:"#b7791f",warningSoft:"rgba(183, 121, 31, 0.12)",warningGlow:"rgba(183, 121, 31, 0.26)",scrim:"rgba(15, 23, 42, 0.34)",scrimSoft:"rgba(15, 23, 42, 0.20)",shadow:"rgba(15, 23, 42, 0.18)",shadowStrong:"rgba(15, 23, 42, 0.28)",floatingBg:"rgba(255, 255, 255, 0.92)",floatingBgStrong:"rgba(255, 255, 255, 0.98)",floatingBgHover:"rgba(239, 246, 249, 0.96)",subtleFill:"rgba(15, 23, 42, 0.025)",hoverFill:"rgba(15, 23, 42, 0.035)",scrollbarThumb:"rgba(82, 97, 112, 0.38)",scrollbarThumbHover:"rgba(82, 97, 112, 0.58)",transcriptUser:"#8b3f75",transcriptAssistant:"#0f8f83",transcriptTool:"#66717d",transcriptCommand:"#0b6fa4",transcriptCode:"#075985",transcriptSearch:"#f0c14b",transcriptOnSearch:"#1f1a10",qrBg:"#ffffff"},xterm:{background:"#ffffff",foreground:"#17212b",cursor:"#0f8f83",selectionBackground:"#cdeee9",...LS({foreground:"#17212b",foregroundMuted:"#526170",line:"#dbe3ec",red:"#b4232f",green:"#16794f",yellow:"#9a6700",blue:"#0b6fa4",magenta:"#8f3f85",cyan:"#0f766e"})}},{id:"signal-red",label:"Signal",description:"Dark control-room surface with red alerts.",mode:"dark",tokens:{bg:"#100d0f",bg2:"#171113",bgSidebar:"#0b080a",line:"#2a1b20",line2:"#452b32",fg:"#f1e7e9",fg2:"#a58d93",fg3:"#765f66",fg4:"#55434a",accent:"#ff2a3d",accentSoft:"rgba(255, 42, 61, 0.12)",accentGlow:"rgba(255, 42, 61, 0.52)",onAccent:"#210407",ok:"#34d399",danger:"#ff4d5f",onDanger:"#210407",dangerSoft:"rgba(255, 77, 95, 0.10)",dangerLine:"rgba(255, 77, 95, 0.32)",warning:"#fbbf24",warningSoft:"rgba(251, 191, 36, 0.10)",warningGlow:"rgba(245, 158, 11, 0.50)",scrim:"rgba(0, 0, 0, 0.58)",scrimSoft:"rgba(0, 0, 0, 0.30)",shadow:"rgba(0, 0, 0, 0.36)",shadowStrong:"rgba(0, 0, 0, 0.52)",floatingBg:"rgba(16, 13, 15, 0.88)",floatingBgStrong:"rgba(16, 13, 15, 0.96)",floatingBgHover:"rgba(25, 16, 19, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(165, 141, 147, 0.45)",scrollbarThumbHover:"rgba(165, 141, 147, 0.65)",transcriptUser:"#f8d36f",transcriptAssistant:"#ff2a3d",transcriptTool:"#ad9ca2",transcriptCommand:"#ff9ca6",transcriptCode:"#ffd1d6",transcriptSearch:"#f8d36f",transcriptOnSearch:"#1b0e10",qrBg:"#ffffff"},xterm:{background:"#100d0f",foreground:"#f1e7e9",cursor:"#ff2a3d",selectionBackground:"#4a1b22"}},{id:"graphite",label:"Graphite",description:"Neutral dark theme with blue command focus.",mode:"dark",tokens:{bg:"#101214",bg2:"#171a1d",bgSidebar:"#0c0e10",line:"#262b30",line2:"#39414a",fg:"#eceff3",fg2:"#9aa4af",fg3:"#6c7680",fg4:"#4d5660",accent:"#7dd3fc",accentSoft:"rgba(125, 211, 252, 0.11)",accentGlow:"rgba(125, 211, 252, 0.38)",onAccent:"#071c26",ok:"#4ade80",danger:"#fb7185",onDanger:"#26070d",dangerSoft:"rgba(251, 113, 133, 0.09)",dangerLine:"rgba(251, 113, 133, 0.30)",warning:"#facc15",warningSoft:"rgba(250, 204, 21, 0.09)",warningGlow:"rgba(250, 204, 21, 0.42)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.34)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(16, 18, 20, 0.88)",floatingBgStrong:"rgba(16, 18, 20, 0.96)",floatingBgHover:"rgba(22, 28, 33, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(154, 164, 175, 0.45)",scrollbarThumbHover:"rgba(154, 164, 175, 0.65)",transcriptUser:"#f2d675",transcriptAssistant:"#7dd3fc",transcriptTool:"#aab4bf",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f2d675",transcriptOnSearch:"#141513",qrBg:"#ffffff"},xterm:{background:"#101214",foreground:"#eceff3",cursor:"#7dd3fc",selectionBackground:"#263d4b"}},{id:"paper",label:"Paper",description:"Warm light surface with restrained amber accent.",mode:"light",tokens:{bg:"#fbfaf7",bg2:"#ffffff",bgSidebar:"#f2f0ea",line:"#e2ddd4",line2:"#cbc3b6",fg:"#25211d",fg2:"#62584e",fg3:"#8d8275",fg4:"#afa69b",accent:"#a35d00",accentSoft:"rgba(163, 93, 0, 0.11)",accentGlow:"rgba(163, 93, 0, 0.24)",onAccent:"#fffaf2",ok:"#26744d",danger:"#b23a48",onDanger:"#fff8f8",dangerSoft:"rgba(178, 58, 72, 0.10)",dangerLine:"rgba(178, 58, 72, 0.30)",warning:"#a35d00",warningSoft:"rgba(163, 93, 0, 0.12)",warningGlow:"rgba(163, 93, 0, 0.26)",scrim:"rgba(37, 33, 29, 0.32)",scrimSoft:"rgba(37, 33, 29, 0.18)",shadow:"rgba(37, 33, 29, 0.18)",shadowStrong:"rgba(37, 33, 29, 0.28)",floatingBg:"rgba(255, 253, 249, 0.92)",floatingBgStrong:"rgba(255, 253, 249, 0.98)",floatingBgHover:"rgba(250, 247, 240, 0.96)",subtleFill:"rgba(37, 33, 29, 0.025)",hoverFill:"rgba(37, 33, 29, 0.035)",scrollbarThumb:"rgba(98, 88, 78, 0.35)",scrollbarThumbHover:"rgba(98, 88, 78, 0.55)",transcriptUser:"#7b3f8c",transcriptAssistant:"#a35d00",transcriptTool:"#776d63",transcriptCommand:"#176a94",transcriptCode:"#6f4b00",transcriptSearch:"#e9c46a",transcriptOnSearch:"#241b0a",qrBg:"#ffffff"},xterm:{background:"#fffdf9",foreground:"#25211d",cursor:"#a35d00",selectionBackground:"#f2dfc5",...LS({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],ro="midnight";function Nh(e){return oh.some(t=>t.id===e)?e:ro}function Sv(e){return oh.find(t=>t.id===e)??oh[0]}function ma(){if(typeof window>"u")return ro;try{const e=window.localStorage.getItem(yv);return e?Nh(e):kE(window.localStorage.getItem(Xw))}catch{return ro}}function SE(e){const t=Nh(e);if(typeof window<"u"){try{window.localStorage.setItem(yv,t)}catch{}wv(t),window.dispatchEvent(new CustomEvent(zm,{detail:t}))}return t}function wv(e=ma()){if(typeof document>"u")return;const t=Sv(Nh(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),lt(n,"--nt-bg",t.tokens.bg),lt(n,"--nt-bg-2",t.tokens.bg2),lt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),lt(n,"--nt-line",t.tokens.line),lt(n,"--nt-line-2",t.tokens.line2),lt(n,"--nt-fg",t.tokens.fg),lt(n,"--nt-fg-2",t.tokens.fg2),lt(n,"--nt-fg-3",t.tokens.fg3),lt(n,"--nt-fg-4",t.tokens.fg4),lt(n,"--nt-accent",t.tokens.accent),lt(n,"--nt-accent-soft",t.tokens.accentSoft),lt(n,"--nt-accent-glow",t.tokens.accentGlow),lt(n,"--nt-on-accent",t.tokens.onAccent),lt(n,"--nt-ok",t.tokens.ok),lt(n,"--nt-danger",t.tokens.danger),lt(n,"--nt-on-danger",t.tokens.onDanger),lt(n,"--nt-danger-soft",t.tokens.dangerSoft),lt(n,"--nt-danger-line",t.tokens.dangerLine),lt(n,"--nt-warning",t.tokens.warning),lt(n,"--nt-warn",t.tokens.warning),lt(n,"--nt-warning-soft",t.tokens.warningSoft),lt(n,"--nt-warning-glow",t.tokens.warningGlow),lt(n,"--nt-scrim",t.tokens.scrim),lt(n,"--nt-scrim-soft",t.tokens.scrimSoft),lt(n,"--nt-shadow",t.tokens.shadow),lt(n,"--nt-shadow-strong",t.tokens.shadowStrong),lt(n,"--nt-floating-bg",t.tokens.floatingBg),lt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),lt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),lt(n,"--nt-subtle-fill",t.tokens.subtleFill),lt(n,"--nt-hover-fill",t.tokens.hoverFill),lt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),lt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),lt(n,"--nt-transcript-user",t.tokens.transcriptUser),lt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),lt(n,"--nt-transcript-tool",t.tokens.transcriptTool),lt(n,"--nt-transcript-command",t.tokens.transcriptCommand),lt(n,"--nt-transcript-code",t.tokens.transcriptCode),lt(n,"--nt-transcript-search",t.tokens.transcriptSearch),lt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),lt(n,"--nt-qr-bg",t.tokens.qrBg)}function wE(e=ma()){return Sv(Nh(e)).xterm}function Cv(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===yv||n.key===Xw)&&(wv(ma()),e())};return window.addEventListener(zm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zm,e),window.removeEventListener("storage",t)}}function lt(e,t,n){e.style.setProperty(t,n)}function LS(e){const t=CE(237);return t[215]=e.foreground,t[221]=e.line,{black:e.foreground,red:e.red,green:e.green,yellow:e.yellow,blue:e.blue,magenta:e.magenta,cyan:e.cyan,white:e.foregroundMuted,brightBlack:e.foregroundMuted,brightRed:e.red,brightGreen:e.green,brightYellow:e.yellow,brightBlue:e.blue,brightMagenta:e.magenta,brightCyan:e.cyan,brightWhite:e.foreground,extendedAnsi:t}}function CE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(xE(n));return t}function xE(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],s=n[Math.floor(t/36)%6],l=n[Math.floor(t/6)%6],c=n[t%6];return BS(s,l,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return BS(t,t,t)}return"#000000"}function BS(e,t,n){return`#${tm(e)}${tm(t)}${tm(n)}`}function tm(e){return e.toString(16).padStart(2,"0")}function kE(e){return e==="signal-red"?"signal-red":ro}function Gw(){const e=v.useSyncExternalStore(Cv,ma,()=>ro);return Sv(e).mode==="light"?"-light":""}function Zw({size:e=22}){const t=Gw();return p.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function Qw({height:e=18}){const t=Gw(),n=Math.round(243/34*e);return p.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var wc=Vw();const Ah=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function uo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function xv(e){return"nodeType"in e}function Rn(e){var t,n;return e?uo(e)?e:xv(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function kv(e){const{Document:t}=Rn(e);return e instanceof t}function iu(e){return uo(e)?!1:e instanceof Rn(e).HTMLElement}function Jw(e){return e instanceof Rn(e).SVGElement}function ho(e){return e?uo(e)?e.document:xv(e)?kv(e)?e:iu(e)||Jw(e)?e.ownerDocument:document:document:document}const ga=Ah?v.useLayoutEffect:v.useEffect;function Ev(e){const t=v.useRef(e);return ga(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,s=new Array(n),l=0;l<n;l++)s[l]=arguments[l];return t.current==null?void 0:t.current(...s)},[])}function EE(){const e=v.useRef(null),t=v.useCallback((s,l)=>{e.current=setInterval(s,l)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Uc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ga(()=>{n.current!==e&&(n.current=e)},t),n}function nu(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function ch(e){const t=Ev(e),n=v.useRef(null),s=v.useCallback(l=>{l!==n.current&&t?.(l,n.current),n.current=l},[]);return[n,s]}function Pm(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let im={};function Lh(e,t){return v.useMemo(()=>{if(t)return t;const n=im[e]==null?0:im[e]+1;return im[e]=n,e+"-"+n},[e,t])}function e1(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),l=1;l<n;l++)s[l-1]=arguments[l];return s.reduce((c,d)=>{const m=Object.entries(d);for(const[g,f]of m){const y=c[g];y!=null&&(c[g]=y+e*f)}return c},{...t})}}const to=e1(1),uh=e1(-1);function TE(e){return"clientX"in e&&"clientY"in e}function t1(e){if(!e)return!1;const{KeyboardEvent:t}=Rn(e.target);return t&&e instanceof t}function DE(e){if(!e)return!1;const{TouchEvent:t}=Rn(e.target);return t&&e instanceof t}function Im(e){if(DE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return TE(e)?{x:e.clientX,y:e.clientY}:null}const Hm=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Hm.Translate.toString(e),Hm.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),OS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function RE(e){return e.matches(OS)?e:e.querySelector(OS)}const ME={display:"none"};function NE(e){let{id:t,value:n}=e;return Li.createElement("div",{id:t,style:ME},n)}function AE(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;const l={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Li.createElement("div",{id:t,style:l,role:"status","aria-live":s,"aria-atomic":!0},n)}function LE(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const i1=v.createContext(null);function BE(e){const t=v.useContext(i1);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function OE(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:l,event:c}=s;e.forEach(d=>{var m;return(m=d[l])==null?void 0:m.call(d,c)})},[e]),t]}const jE={draggable:`
|
|
11
11
|
To pick up a draggable item, press the space bar.
|
|
12
12
|
While dragging, use the arrow keys to move the item.
|
|
13
13
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
14
|
-
`},zE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function PE(e){let{announcements:t=zE,container:n,hiddenTextDescribedById:s,screenReaderInstructions:o=jE}=e;const{announce:c,announcement:d}=LE(),m=Lh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),BE(v.useMemo(()=>({onDragStart(b){let{active:C}=b;c(t.onDragStart({active:C}))},onDragMove(b){let{active:C,over:w}=b;t.onDragMove&&c(t.onDragMove({active:C,over:w}))},onDragOver(b){let{active:C,over:w}=b;c(t.onDragOver({active:C,over:w}))},onDragEnd(b){let{active:C,over:w}=b;c(t.onDragEnd({active:C,over:w}))},onDragCancel(b){let{active:C,over:w}=b;c(t.onDragCancel({active:C,over:w}))}}),[c,t])),!g)return null;const y=Li.createElement(Li.Fragment,null,Li.createElement(NE,{id:s,value:o.draggable}),Li.createElement(AE,{id:m,announcement:d}));return n?wc.createPortal(y,n):y}var Ai;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ai||(Ai={}));function dh(){}function jS(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function IE(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const yr=Object.freeze({x:0,y:0});function HE(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function UE(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function KE(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-s,m=c-n;if(s<o&&n<c){const g=t.width*t.height,f=e.width*e.height,y=d*m,b=y/(g+f-y);return Number(b.toFixed(4))}return 0}const FE=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=[];for(const c of s){const{id:d}=c,m=n.get(d);if(m){const g=KE(m,t);g>0&&o.push({id:d,data:{droppableContainer:c,value:g}})}}return o.sort(HE)};function WE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function n1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:yr}function qE(e){return function(n){for(var s=arguments.length,o=new Array(s>1?s-1:0),c=1;c<s;c++)o[c-1]=arguments[c];return o.reduce((d,m)=>({...d,top:d.top+e*m.y,bottom:d.bottom+e*m.y,left:d.left+e*m.x,right:d.right+e*m.x}),{...n})}}const $E=qE(1);function VE(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function YE(e,t,n){const s=VE(t);if(!s)return e;const{scaleX:o,scaleY:c,x:d,y:m}=s,g=e.left-d-(1-o)*parseFloat(n),f=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:f,right:g+y,bottom:f+b,left:g}}const XE={ignoreTransform:!1};function ru(e,t){t===void 0&&(t=XE);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:y}=Dn(e).getComputedStyle(e);f&&(n=YE(n,f,y))}const{top:s,left:o,width:c,height:d,bottom:m,right:g}=n;return{top:s,left:o,width:c,height:d,bottom:m,right:g}}function zS(e){return ru(e,{ignoreTransform:!0})}function GE(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ZE(e,t){return t===void 0&&(t=Dn(e).getComputedStyle(e)),t.position==="fixed"}function QE(e,t){t===void 0&&(t=Dn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function Tv(e,t){const n=[];function s(o){if(t!=null&&n.length>=t||!o)return n;if(kv(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!iu(o)||Jw(o)||n.includes(o))return n;const c=Dn(e).getComputedStyle(o);return o!==e&&QE(o,c)&&n.push(o),ZE(o,c)?n:s(o.parentNode)}return e?s(e):n}function r1(e){const[t]=Tv(e,1);return t??null}function nm(e){return!Ah||!e?null:dl(e)?e:xv(e)?kv(e)||e===hl(e).scrollingElement?window:iu(e)?e:null:null}function s1(e){return dl(e)?e.scrollX:e.scrollLeft}function a1(e){return dl(e)?e.scrollY:e.scrollTop}function Um(e){return{x:s1(e),y:a1(e)}}var Fi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Fi||(Fi={}));function o1(e){return!Ah||!e?!1:e===document.scrollingElement}function l1(e){const t={x:0,y:0},n=o1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=s.y,m=e.scrollLeft>=s.x;return{isTop:o,isLeft:c,isBottom:d,isRight:m,maxScroll:s,minScroll:t}}const JE={x:.2,y:.2};function eT(e,t,n,s,o){let{top:c,left:d,right:m,bottom:g}=n;s===void 0&&(s=10),o===void 0&&(o=JE);const{isTop:f,isBottom:y,isLeft:b,isRight:C}=l1(e),w={x:0,y:0},x={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+D.height?(w.y=Fi.Backward,x.y=s*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(w.y=Fi.Forward,x.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!C&&m>=t.right-D.width?(w.x=Fi.Forward,x.x=s*Math.abs((t.right-D.width-m)/D.width)):!b&&d<=t.left+D.width&&(w.x=Fi.Backward,x.x=s*Math.abs((t.left+D.width-d)/D.width)),{direction:w,speed:x}}function tT(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function c1(e){return e.reduce((t,n)=>il(t,Um(n)),yr)}function iT(e){return e.reduce((t,n)=>t+s1(n),0)}function nT(e){return e.reduce((t,n)=>t+a1(n),0)}function rT(e,t){if(t===void 0&&(t=ru),!e)return;const{top:n,left:s,bottom:o,right:c}=t(e);r1(e)&&(o<=0||c<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const sT=[["x",["left","right"],iT],["y",["top","bottom"],nT]];class Dv{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Tv(n),o=c1(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,m]of sT)for(const g of d)Object.defineProperty(this,g,{get:()=>{const f=m(s),y=o[c]-f;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Lc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var o;(o=this.target)==null||o.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function aT(e){const{EventTarget:t}=Dn(e);return e instanceof t?e:hl(e)}function rm(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var sr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(sr||(sr={}));function PS(e){e.preventDefault()}function oT(e){e.stopPropagation()}var Pt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Pt||(Pt={}));const u1={start:[Pt.Space,Pt.Enter],cancel:[Pt.Esc],end:[Pt.Space,Pt.Enter,Pt.Tab]},lT=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Pt.Right:return{...n,x:n.x+25};case Pt.Left:return{...n,x:n.x-25};case Pt.Down:return{...n,y:n.y+25};case Pt.Up:return{...n,y:n.y-25}}};class d1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Lc(hl(n)),this.windowListeners=new Lc(Dn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(sr.Resize,this.handleCancel),this.windowListeners.add(sr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(sr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&rT(s),n(yr)}handleKeyDown(t){if(t1(t)){const{active:n,context:s,options:o}=this.props,{keyboardCodes:c=u1,coordinateGetter:d=lT,scrollBehavior:m="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,y=f?{x:f.left,y:f.top}:yr;this.referenceCoordinates||(this.referenceCoordinates=y);const b=d(t,{active:n,context:s.current,currentCoordinates:y});if(b){const C=uh(b,y),w={x:0,y:0},{scrollableAncestors:x}=s.current;for(const D of x){const B=t.code,{isTop:L,isRight:O,isLeft:X,isBottom:U,maxScroll:G,minScroll:F}=l1(D),W=tT(D),ve={x:Math.min(B===Pt.Right?W.right-W.width/2:W.right,Math.max(B===Pt.Right?W.left:W.left+W.width/2,b.x)),y:Math.min(B===Pt.Down?W.bottom-W.height/2:W.bottom,Math.max(B===Pt.Down?W.top:W.top+W.height/2,b.y))},Se=B===Pt.Right&&!O||B===Pt.Left&&!X,xe=B===Pt.Down&&!U||B===Pt.Up&&!L;if(Se&&ve.x!==b.x){const ie=D.scrollLeft+C.x,q=B===Pt.Right&&ie<=G.x||B===Pt.Left&&ie>=F.x;if(q&&!C.y){D.scrollTo({left:ie,behavior:m});return}q?w.x=D.scrollLeft-ie:w.x=B===Pt.Right?D.scrollLeft-G.x:D.scrollLeft-F.x,w.x&&D.scrollBy({left:-w.x,behavior:m});break}else if(xe&&ve.y!==b.y){const ie=D.scrollTop+C.y,q=B===Pt.Down&&ie<=G.y||B===Pt.Up&&ie>=F.y;if(q&&!C.x){D.scrollTo({top:ie,behavior:m});return}q?w.y=D.scrollTop-ie:w.y=B===Pt.Down?D.scrollTop-G.y:D.scrollTop-F.y,w.y&&D.scrollBy({top:-w.y,behavior:m});break}}this.handleMove(t,il(uh(b,this.referenceCoordinates),w))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}d1.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=u1,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(s.start.includes(d)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function IS(e){return!!(e&&"distance"in e)}function HS(e){return!!(e&&"delay"in e)}class Rv{constructor(t,n,s){var o;s===void 0&&(s=aT(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=hl(d),this.documentListeners=new Lc(this.document),this.listeners=new Lc(s),this.windowListeners=new Lc(Dn(d)),this.initialCoordinates=(o=Im(c))!=null?o:yr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(sr.Resize,this.handleCancel),this.windowListeners.add(sr.DragStart,PS),this.windowListeners.add(sr.VisibilityChange,this.handleCancel),this.windowListeners.add(sr.ContextMenu,PS),this.documentListeners.add(sr.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(IS(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(sr.Click,oT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(sr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=Im(t))!=null?n:yr,f=uh(o,g);if(!s&&m){if(IS(m)){if(m.tolerance!=null&&rm(f,m.tolerance))return this.handleCancel();if(rm(f,m.distance))return this.handleStart()}if(HS(m)&&rm(f,m.tolerance))return this.handleCancel();this.handlePending(m,f);return}t.cancelable&&t.preventDefault(),d(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Pt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const cT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class h1 extends Rv{constructor(t){const{event:n}=t,s=hl(n.target);super(t,cT,s)}}h1.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const uT={move:{name:"mousemove"},end:{name:"mouseup"}};var Km;(function(e){e[e.RightClick=2]="RightClick"})(Km||(Km={}));class f1 extends Rv{constructor(t){super(t,uT,hl(t.event.target))}}f1.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===Km.RightClick?!1:(s?.({event:n}),!0)}}];const sm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class p1 extends Rv{constructor(t){super(t,sm)}static setup(){return window.addEventListener(sm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(sm.move.name,t)};function t(){}}}p1.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:o}=n;return o.length>1?!1:(s?.({event:n}),!0)}}];var Bc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Bc||(Bc={}));var hh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(hh||(hh={}));function dT(e){let{acceleration:t,activator:n=Bc.Pointer,canScroll:s,draggingRect:o,enabled:c,interval:d=5,order:m=hh.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:y,delta:b,threshold:C}=e;const w=fT({delta:b,disabled:!c}),[x,D]=EE(),B=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),O=v.useMemo(()=>{switch(n){case Bc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Bc.DraggableRect:return o}},[n,o,g]),X=v.useRef(null),U=v.useCallback(()=>{const F=X.current;if(!F)return;const W=B.current.x*L.current.x,ve=B.current.y*L.current.y;F.scrollBy(W,ve)},[]),G=v.useMemo(()=>m===hh.TreeOrder?[...f].reverse():f,[m,f]);v.useEffect(()=>{if(!c||!f.length||!O){D();return}for(const F of G){if(s?.(F)===!1)continue;const W=f.indexOf(F),ve=y[W];if(!ve)continue;const{direction:Se,speed:xe}=eT(F,ve,O,t,C);for(const ie of["x","y"])w[ie][Se[ie]]||(xe[ie]=0,Se[ie]=0);if(xe.x>0||xe.y>0){D(),X.current=F,x(U,d),B.current=xe,L.current=Se;return}}B.current={x:0,y:0},L.current={x:0,y:0},D()},[t,U,s,D,c,d,JSON.stringify(O),JSON.stringify(w),x,f,G,y,JSON.stringify(C)])}const hT={x:{[Fi.Backward]:!1,[Fi.Forward]:!1},y:{[Fi.Backward]:!1,[Fi.Forward]:!1}};function fT(e){let{delta:t,disabled:n}=e;const s=Pm(t);return nu(o=>{if(n||!s||!o)return hT;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Fi.Backward]:o.x[Fi.Backward]||c.x===-1,[Fi.Forward]:o.x[Fi.Forward]||c.x===1},y:{[Fi.Backward]:o.y[Fi.Backward]||c.y===-1,[Fi.Forward]:o.y[Fi.Forward]||c.y===1}}},[n,t,s])}function pT(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return nu(o=>{var c;return t==null?null:(c=s??o)!=null?c:null},[s,t])}function mT(e,t){return v.useMemo(()=>e.reduce((n,s)=>{const{sensor:o}=s,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,s)}));return[...n,...c]},[]),[e,t])}var Kc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Kc||(Kc={}));var Fm;(function(e){e.Optimized="optimized"})(Fm||(Fm={}));const US=new Map;function gT(e,t){let{dragging:n,dependencies:s,config:o}=t;const[c,d]=v.useState(null),{frequency:m,measure:g,strategy:f}=o,y=v.useRef(e),b=B(),C=Uc(b),w=v.useCallback(function(L){L===void 0&&(L=[]),!C.current&&d(O=>O===null?L:O.concat(L.filter(X=>!O.includes(X))))},[C]),x=v.useRef(null),D=nu(L=>{if(b&&!n)return US;if(!L||L===US||y.current!==e||c!=null){const O=new Map;for(let X of e){if(!X)continue;if(c&&c.length>0&&!c.includes(X.id)&&X.rect.current){O.set(X.id,X.rect.current);continue}const U=X.node.current,G=U?new Dv(g(U),U):null;X.rect.current=G,G&&O.set(X.id,G)}return O}return L},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||w()},[n,b]),v.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},m))},[m,b,w,...s]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function B(){switch(f){case Kc.Always:return!1;case Kc.BeforeDragging:return n;default:return!n}}}function m1(e,t){return nu(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function vT(e,t){return m1(e,t)}function _T(e){let{callback:t,disabled:n}=e;const s=Ev(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Bh(e){let{callback:t,disabled:n}=e;const s=Ev(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function bT(e){return new Dv(ru(e),e)}function KS(e,t,n){t===void 0&&(t=bT);const[s,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??n)!=null?f:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const d=_T({callback(g){if(e)for(const f of g){const{type:y,target:b}=f;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Bh({callback:c});return ma(()=>{c(),e?(m?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),d?.disconnect())},[e]),s}function yT(e){const t=m1(e);return n1(e,t)}const FS=[];function ST(e){const t=v.useRef(e),n=nu(s=>e?s&&s!==FS&&e&&t.current&&e.parentNode===t.current.parentNode?s:Tv(e):FS,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function wT(e){const[t,n]=v.useState(null),s=v.useRef(e),o=v.useCallback(c=>{const d=nm(c.target);d&&n(m=>m?(m.set(d,Um(d)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){d(c);const m=e.map(g=>{const f=nm(g);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Um(f)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),s.current=e}return()=>{d(e),d(c)};function d(m){m.forEach(g=>{const f=nm(g);f?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>il(c,d),yr):c1(e):yr,[e,t])}function WS(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==yr;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?uh(e,n.current):yr}function CT(e){v.useEffect(()=>{if(!Ah)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function xT(e,t){return v.useMemo(()=>e.reduce((n,s)=>{let{eventName:o,handler:c}=s;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function g1(e){return v.useMemo(()=>e?GE(e):null,[e])}const qS=[];function kT(e,t){t===void 0&&(t=ru);const[n]=e,s=g1(n?Dn(n):null),[o,c]=v.useState(qS);function d(){c(()=>e.length?e.map(g=>o1(g)?s:new Dv(t(g),g)):qS)}const m=Bh({callback:d});return ma(()=>{m?.disconnect(),d(),e.forEach(g=>m?.observe(g))},[e]),o}function ET(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return iu(t)?t:e}function TT(e){let{measure:t}=e;const[n,s]=v.useState(null),o=v.useCallback(f=>{for(const{target:y}of f)if(iu(y)){s(b=>{const C=t(y);return b?{...b,width:C.width,height:C.height}:C});break}},[t]),c=Bh({callback:o}),d=v.useCallback(f=>{const y=ET(f);c?.disconnect(),y&&c?.observe(y),s(y?t(y):null)},[t,c]),[m,g]=ch(d);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const DT=[{sensor:h1,options:{}},{sensor:d1,options:{}}],RT={current:{}},Yd={draggable:{measure:zS},droppable:{measure:zS,strategy:Kc.WhileDragging,frequency:Fm.Optimized},dragOverlay:{measure:ru}};class Oc extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const MT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Oc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:dh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yd,measureDroppableContainers:dh,windowRect:null,measuringScheduled:!1},NT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:dh,draggableNodes:new Map,over:null,measureDroppableContainers:dh},Oh=v.createContext(NT),AT=v.createContext(MT);function LT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Oc}}}function BT(e,t){switch(t.type){case Ai.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ai.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ai.DragEnd:case Ai.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ai.RegisterDroppable:{const{element:n}=t,{id:s}=n,o=new Oc(e.droppable.containers);return o.set(s,n),{...e,droppable:{...e.droppable,containers:o}}}case Ai.SetDroppableDisabled:{const{id:n,key:s,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||s!==c.key)return e;const d=new Oc(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case Ai.UnregisterDroppable:{const{id:n,key:s}=t,o=e.droppable.containers.get(n);if(!o||s!==o.key)return e;const c=new Oc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function OT(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:o}=v.useContext(Oh),c=Pm(s),d=Pm(n?.id);return v.useEffect(()=>{if(!t&&!s&&c&&d!=null){if(!t1(c)||document.activeElement===c.target)return;const m=o.get(d);if(!m)return;const{activatorNode:g,node:f}=m;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const y of[g.current,f.current]){if(!y)continue;const b=RE(y);if(b){b.focus();break}}})}},[s,t,o,d,c]),null}function jT(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...s}),n):n}function zT(e){return v.useMemo(()=>({draggable:{...Yd.draggable,...e?.draggable},droppable:{...Yd.droppable,...e?.droppable},dragOverlay:{...Yd.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function PT(e){let{activeNode:t,measure:n,initialRect:s,config:o=!0}=e;const c=v.useRef(!1),{x:d,y:m}=typeof o=="boolean"?{x:o,y:o}:o;ma(()=>{if(!d&&!m||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const y=n(f),b=n1(y,s);if(d||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const C=r1(f);C&&C.scrollBy({top:b.y,left:b.x})}},[t,d,m,s,n])}const v1=v.createContext({...yr,scaleX:1,scaleY:1});var oa;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(oa||(oa={}));const IT=v.memo(function(t){var n,s,o,c;let{id:d,accessibility:m,autoScroll:g=!0,children:f,sensors:y=DT,collisionDetection:b=FE,measuring:C,modifiers:w,...x}=t;const D=v.useReducer(BT,void 0,LT),[B,L]=D,[O,X]=OE(),[U,G]=v.useState(oa.Uninitialized),F=U===oa.Initialized,{draggable:{active:W,nodes:ve,translate:Se},droppable:{containers:xe}}=B,ie=W!=null?ve.get(W):null,q=v.useRef({initial:null,translated:null}),J=v.useMemo(()=>{var et;return W!=null?{id:W,data:(et=ie?.data)!=null?et:RT,rect:q}:null},[W,ie]),K=v.useRef(null),[re,A]=v.useState(null),[R,P]=v.useState(null),ne=Uc(x,Object.values(x)),ge=Lh("DndDescribedBy",d),M=v.useMemo(()=>xe.getEnabled(),[xe]),V=zT(C),{droppableRects:le,measureDroppableContainers:_e,measuringScheduled:be}=gT(M,{dragging:F,dependencies:[Se.x,Se.y],config:V.droppable}),Ee=pT(ve,W),Me=v.useMemo(()=>R?Im(R):null,[R]),Re=st(),Pe=vT(Ee,V.draggable.measure);PT({activeNode:W!=null?ve.get(W):null,config:Re.layoutShiftCompensation,initialRect:Pe,measure:V.draggable.measure});const Be=KS(Ee,V.draggable.measure,Pe),oe=KS(Ee?Ee.parentElement:null),he=v.useRef({activatorEvent:null,active:null,activeNode:Ee,collisionRect:null,collisions:null,droppableRects:le,draggableNodes:ve,draggingNode:null,draggingNodeRect:null,droppableContainers:xe,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ye=xe.getNodeFor((n=he.current.over)==null?void 0:n.id),Oe=TT({measure:V.dragOverlay.measure}),Ke=(s=Oe.nodeRef.current)!=null?s:Ee,je=F?(o=Oe.rect)!=null?o:Be:null,se=!!(Oe.nodeRef.current&&Oe.rect),Te=yT(se?null:Be),we=g1(Ke?Dn(Ke):null),ze=ST(F?ye??Ee:null),Ue=kT(ze),nt=jT(w,{transform:{x:Se.x-Te.x,y:Se.y-Te.y,scaleX:1,scaleY:1},activatorEvent:R,active:J,activeNodeRect:Be,containerNodeRect:oe,draggingNodeRect:je,over:he.current.over,overlayNodeRect:Oe.rect,scrollableAncestors:ze,scrollableAncestorRects:Ue,windowRect:we}),ht=Me?il(Me,Se):null,Dt=wT(ze),Ei=WS(Dt),ni=WS(Dt,[Be]),di=il(nt,Ei),ae=je?$E(je,nt):null,Ne=J&&ae?b({active:J,collisionRect:ae,droppableRects:le,droppableContainers:M,pointerCoordinates:ht}):null,Qe=UE(Ne,"id"),[it,jt]=v.useState(null),xt=se?nt:il(nt,ni),gt=WE(xt,(c=it?.rect)!=null?c:null,Be),Ht=v.useRef(null),kt=v.useCallback((et,wt)=>{let{sensor:Et,options:Ut}=wt;if(K.current==null)return;const ri=ve.get(K.current);if(!ri)return;const Gt=et.nativeEvent,Zt=new Et({active:K.current,activeNode:ri,event:Gt,options:Ut,context:he,onAbort(Qt){if(!ve.get(Qt))return;const{onDragAbort:hi}=ne.current,zi={id:Qt};hi?.(zi),O({type:"onDragAbort",event:zi})},onPending(Qt,ji,hi,zi){if(!ve.get(Qt))return;const{onDragPending:Yi}=ne.current,Ti={id:Qt,constraint:ji,initialCoordinates:hi,offset:zi};Yi?.(Ti),O({type:"onDragPending",event:Ti})},onStart(Qt){const ji=K.current;if(ji==null)return;const hi=ve.get(ji);if(!hi)return;const{onDragStart:zi}=ne.current,gn={activatorEvent:Gt,active:{id:ji,data:hi.data,rect:q}};wc.unstable_batchedUpdates(()=>{zi?.(gn),G(oa.Initializing),L({type:Ai.DragStart,initialCoordinates:Qt,active:ji}),O({type:"onDragStart",event:gn}),A(Ht.current),P(Gt)})},onMove(Qt){L({type:Ai.DragMove,coordinates:Qt})},onEnd:Kt(Ai.DragEnd),onCancel:Kt(Ai.DragCancel)});Ht.current=Zt;function Kt(Qt){return async function(){const{active:hi,collisions:zi,over:gn,scrollAdjustedTranslate:Yi}=he.current;let Ti=null;if(hi&&Yi){const{cancelDrop:on}=ne.current;Ti={activatorEvent:Gt,active:hi,collisions:zi,delta:Yi,over:gn},Qt===Ai.DragEnd&&typeof on=="function"&&await Promise.resolve(on(Ti))&&(Qt=Ai.DragCancel)}K.current=null,wc.unstable_batchedUpdates(()=>{L({type:Qt}),G(oa.Uninitialized),jt(null),A(null),P(null),Ht.current=null;const on=Qt===Ai.DragEnd?"onDragEnd":"onDragCancel";if(Ti){const Di=ne.current[on];Di?.(Ti),O({type:on,event:Ti})}})}}},[ve]),Rn=v.useCallback((et,wt)=>(Et,Ut)=>{const ri=Et.nativeEvent,Gt=ve.get(Ut);if(K.current!==null||!Gt||ri.dndKit||ri.defaultPrevented)return;const Zt={active:Gt};et(Et,wt.options,Zt)===!0&&(ri.dndKit={capturedBy:wt.sensor},K.current=Ut,kt(Et,wt))},[ve,kt]),Mn=mT(y,Rn);CT(y),ma(()=>{Be&&U===oa.Initializing&&G(oa.Initialized)},[Be,U]),v.useEffect(()=>{const{onDragMove:et}=ne.current,{active:wt,activatorEvent:Et,collisions:Ut,over:ri}=he.current;if(!wt||!Et)return;const Gt={active:wt,activatorEvent:Et,collisions:Ut,delta:{x:di.x,y:di.y},over:ri};wc.unstable_batchedUpdates(()=>{et?.(Gt),O({type:"onDragMove",event:Gt})})},[di.x,di.y]),v.useEffect(()=>{const{active:et,activatorEvent:wt,collisions:Et,droppableContainers:Ut,scrollAdjustedTranslate:ri}=he.current;if(!et||K.current==null||!wt||!ri)return;const{onDragOver:Gt}=ne.current,Zt=Ut.get(Qe),Kt=Zt&&Zt.rect.current?{id:Zt.id,rect:Zt.rect.current,data:Zt.data,disabled:Zt.disabled}:null,Qt={active:et,activatorEvent:wt,collisions:Et,delta:{x:ri.x,y:ri.y},over:Kt};wc.unstable_batchedUpdates(()=>{jt(Kt),Gt?.(Qt),O({type:"onDragOver",event:Qt})})},[Qe]),ma(()=>{he.current={activatorEvent:R,active:J,activeNode:Ee,collisionRect:ae,collisions:Ne,droppableRects:le,draggableNodes:ve,draggingNode:Ke,draggingNodeRect:je,droppableContainers:xe,over:it,scrollableAncestors:ze,scrollAdjustedTranslate:di},q.current={initial:je,translated:ae}},[J,Ee,Ne,ae,ve,Ke,je,le,xe,it,ze,di]),dT({...Re,delta:Se,draggingRect:ae,pointerCoordinates:ht,scrollableAncestors:ze,scrollableAncestorRects:Ue});const Z=v.useMemo(()=>({active:J,activeNode:Ee,activeNodeRect:Be,activatorEvent:R,collisions:Ne,containerNodeRect:oe,dragOverlay:Oe,draggableNodes:ve,droppableContainers:xe,droppableRects:le,over:it,measureDroppableContainers:_e,scrollableAncestors:ze,scrollableAncestorRects:Ue,measuringConfiguration:V,measuringScheduled:be,windowRect:we}),[J,Ee,Be,R,Ne,oe,Oe,ve,xe,le,it,_e,ze,Ue,V,be,we]),We=v.useMemo(()=>({activatorEvent:R,activators:Mn,active:J,activeNodeRect:Be,ariaDescribedById:{draggable:ge},dispatch:L,draggableNodes:ve,over:it,measureDroppableContainers:_e}),[R,Mn,J,Be,L,ge,ve,it,_e]);return Li.createElement(i1.Provider,{value:X},Li.createElement(Oh.Provider,{value:We},Li.createElement(AT.Provider,{value:Z},Li.createElement(v1.Provider,{value:gt},f)),Li.createElement(OT,{disabled:m?.restoreFocus===!1})),Li.createElement(PE,{...m,hiddenTextDescribedById:ge}));function st(){const et=re?.autoScrollEnabled===!1,wt=typeof g=="object"?g.enabled===!1:g===!1,Et=F&&!et&&!wt;return typeof g=="object"?{...g,enabled:Et}:{enabled:Et}}}),HT=v.createContext(null),$S="button",UT="Draggable";function _1(e){let{id:t,data:n,disabled:s=!1,attributes:o}=e;const c=Lh(UT),{activators:d,activatorEvent:m,active:g,activeNodeRect:f,ariaDescribedById:y,draggableNodes:b,over:C}=v.useContext(Oh),{role:w=$S,roleDescription:x="draggable",tabIndex:D=0}=o??{},B=g?.id===t,L=v.useContext(B?v1:HT),[O,X]=ch(),[U,G]=ch(),F=xT(d,t),W=Uc(n);ma(()=>(b.set(t,{id:t,key:c,node:O,activatorNode:U,data:W}),()=>{const Se=b.get(t);Se&&Se.key===c&&b.delete(t)}),[b,t]);const ve=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":s,"aria-pressed":B&&w===$S?!0:void 0,"aria-roledescription":x,"aria-describedby":y.draggable}),[s,w,D,B,x,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:f,attributes:ve,isDragging:B,listeners:s?void 0:F,node:O,over:C,setNodeRef:X,setActivatorNodeRef:G,transform:L}}const KT="Droppable",FT={timeout:25};function Mv(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:o}=e;const c=Lh(KT),{active:d,dispatch:m,over:g,measureDroppableContainers:f}=v.useContext(Oh),y=v.useRef({disabled:n}),b=v.useRef(!1),C=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:B}={...FT,...o},L=Uc(D??s),O=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(L.current)?L.current:[L.current]),w.current=null},B)},[B]),X=Bh({callback:O,disabled:x||!d}),U=v.useCallback((ve,Se)=>{X&&(Se&&(X.unobserve(Se),b.current=!1),ve&&X.observe(ve))},[X]),[G,F]=ch(U),W=Uc(t);return v.useEffect(()=>{!X||!G.current||(X.disconnect(),b.current=!1,X.observe(G.current))},[G,X]),v.useEffect(()=>(m({type:Ai.RegisterDroppable,element:{id:s,key:c,disabled:n,node:G,rect:C,data:W}}),()=>m({type:Ai.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:Ai.SetDroppableDisabled,id:s,key:c,disabled:n}),y.current.disabled=n)},[s,c,n,m]),{active:d,rect:C,isOver:g?.id===s,node:G,over:g,setNodeRef:F}}const WT=128,qT=512,fl=100,$T="too_many_detached_terminals",VT=64,YT=4096;function b1(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>WT)return null;const n=t.workspaces.map(XT);return n.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function y1(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const s=n.detachedTerminalIds;return Array.isArray(s)&&s.length>fl}):!1}function XT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>qT)return null;const n=t.tabs.map(GT);if(n.some(o=>o===null))return null;const s=e2(t.detachedTerminalIds,fl);return s===null?null:{id:t.id,title:t.title,defaultCwd:JT(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function GT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=ZT(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function ZT(e){if(!e||typeof e!="object")return null;let t=0;return Wm(e,1,()=>(t+=1,t<=YT))}function Wm(e,t,n){if(!e||typeof e!="object"||t>VT||!n())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const o=Wm(s.first,t+1,n),c=Wm(s.second,t+1,n);return!o||!c?null:{type:"split",direction:s.direction,ratio:QT(s.ratio),first:o,second:c}}function QT(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function JT(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function e2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,s=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),s.push(o));return s}const S1=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],t2="nterminal-focus",i2=/^[A-Za-z0-9_.:-]{1,128}$/;function n2(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(t2)!=="terminal"?null:jh({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function jh(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!VS(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!VS(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function VS(e){return typeof e=="string"&&i2.test(e)}const lr="__main__",w1="nterminal.clientDiagnostics.v1",C1=150,r2=24,s2=160;let YS=!1,hc=null;function a2(){YS||typeof window>"u"||(YS=!0,fn("page.load",{navigation:g2(),visibility:document.visibilityState,online:navigator.onLine,viewport:E1(),standalone:m2()}),document.addEventListener("visibilitychange",()=>{fn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{fn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{fn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>fn("network.online")),window.addEventListener("offline",()=>fn("network.offline")),window.addEventListener("focus",()=>fn("window.focus")),window.addEventListener("blur",()=>fn("window.blur")),window.addEventListener("error",e=>{fn("runtime.error",{message:e.message,source:v2(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{fn("runtime.unhandledrejection",{reason:_2(e.reason)})}))}function fn(e,t={}){const n={at:new Date().toISOString(),event:zh(e,80),data:k1({...t,visibility:t.visibility??f2(),online:t.online??p2(),viewport:t.viewport??E1()})},s=x1();return s.push(n),o2(s.slice(-C1)),n}function x1(){try{const e=window.localStorage.getItem(w1);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(l2).filter(n=>n!==null).slice(-C1):[]}catch{return[]}}async function Nv(e,t=fetch){if(hc)return hc;const n=x1(),s={reason:zh(e,80),events:n},o=JSON.stringify(s);hc=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await hc}finally{hc=null}}function o2(e){try{window.localStorage.setItem(w1,JSON.stringify(e))}catch{}}function l2(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:zh(t.event,80),...t.data&&typeof t.data=="object"?{data:k1(t.data)}:{}}}function k1(e){const t={};for(const[n,s]of Object.entries(e).slice(0,r2)){const o=zh(n,64);if(!o||c2(o))continue;const c=u2(s);c!==void 0&&(t[o]=c)}return t}function c2(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function u2(e){if(typeof e=="string")return d2(e,s2);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function zh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function d2(e,t){return h2(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function h2(e){return e.replace(/https?:\/\/[^\s"'<>]+/gi,"[url]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[redacted]").replace(/\b((?:auth|authorization|cookie|password|secret|session|sessionid|session_id|token)[a-z0-9_.:-]*\s*[:=]\s*)[^\s&,;]+/gi,"$1[redacted]").replace(/\b(nterminal_session|nterminal_device)\s*=\s*[^\s;,]+/gi,"$1=[redacted]").replace(/\b[A-Za-z0-9+/_=-]{48,}\b/g,"[redacted]")}function f2(){return typeof document>"u"?void 0:document.visibilityState}function p2(){return typeof navigator>"u"?void 0:navigator.onLine}function E1(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function m2(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function g2(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function v2(e){if(!e)return null;try{const t=new URL(e);return t.pathname.split("/").pop()||t.pathname}catch{return e.split("/").pop()??e}}function _2(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const T1="nterminal.notifications.completionEnabled",Av="nterminal.notifications.completionToastEnabled",Lv="nterminal.notifications.completionToastDurationSeconds",Bv="nterminal.notifications.completionToastPersistent",qm="nterminal:completion-toast-display",$m="nterminal:notification-focus",jc=6.5,Vm=2,Ym=60;function Ph(){return typeof window<"u"&&"Notification"in window}function Ov(){try{return window.localStorage.getItem(T1)==="true"}catch{return!1}}function XS(e){try{window.localStorage.setItem(T1,e?"true":"false")}catch{}}function ro(){return{enabled:w2(),durationSeconds:S2(),persistUntilDismissed:C2()}}function b2(e){if(typeof window<"u"){try{window.localStorage.setItem(Av,e?"true":"false")}catch{}jv()}return ro()}function GS(e){const t=R1(e);if(typeof window<"u"){try{window.localStorage.setItem(Lv,String(t))}catch{}jv()}return ro()}function y2(e){if(typeof window<"u"){try{window.localStorage.setItem(Bv,e?"true":"false")}catch{}jv()}return ro()}function D1(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Av||n.key===Lv||n.key===Bv)&&e()};return window.addEventListener(qm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qm,e),window.removeEventListener("storage",t)}}function pl(){return Ph()?window.Notification.permission:"unsupported"}function S2(){if(typeof window>"u")return jc;try{const e=window.localStorage.getItem(Lv);return e===null?jc:R1(Number(e))}catch{return jc}}function w2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Av)!=="false"}catch{return!0}}function C2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Bv)==="true"}catch{return!1}}function R1(e){if(!Number.isFinite(e))return jc;const t=Math.round(e*2)/2;return Math.max(Vm,Math.min(Ym,t))}function jv(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(qm))}async function M1(){if(!Ph())return"unsupported";try{return await window.Notification.requestPermission()}catch{return pl()}}function x2(e){if(!Ph()||pl()!=="granted"||!Ov()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,s=jh({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:s?{focus:s}:void 0,silent:!0});s&&(o.onclick=()=>{window.focus(),k2(s)})}catch{}}function k2(e){typeof window>"u"||window.dispatchEvent(new CustomEvent($m,{detail:e}))}const ZS="nterminal.push.clientId",E2=2e4,QS=[5e3,3e4,12e4];function ps(){try{const e=window.localStorage.getItem(ZS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Gm()}`;return window.localStorage.setItem(ZS,t),t}catch{return`client-${Gm()}`}}function T2(){return`page-${Gm()}`}function Ih(){const e=typeof window<"u"&&window.isSecureContext===!0,t=B2(),n=O2(),s=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&s;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":s?o?"supported":"unsupported":"not_mobile":"insecure"}}async function D2(e,t){const n=Ih();if(!n.supported)throw new Error(n.reason);if((pl()==="granted"?"granted":await M1())!=="granted")throw new Error("permission_denied");const o=ps(),c=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(o),g=await z2(c,d.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L1(d.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:A1(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:N1(n.deviceKind),alwaysNotify:t})}async function R2(e){const t=Ih();if(!t.supported||pl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),s=await n?.pushManager.getSubscription();if(!n||!s)return!1;const o=ps(),c=await P2(s.endpoint),d=await e.getPushNotificationStatus(o,c);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&Xm(s,d.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=d.endpointRegistered===!0&&Xm(s,m.publicKey);g||await s.unsubscribe();const f=g?s:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L1(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:A1(f),deviceKind:t.deviceKind,displayMode:t.displayMode,label:N1(t.deviceKind),alwaysNotify:!1}),!0}function M2(e){let t=!1,n=!1,s=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},d=y=>{t||n||(n=!0,R2(e).then(b=>{s=0,b&&fn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(fn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&s<QS.length){const C=QS[s++];o=window.setTimeout(()=>{o=null,d("retry")},C)}}).finally(()=>{n=!1}))},m=y=>{c(),s=0,d(y)},g=()=>m("online"),f=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",f),d("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",f)}}async function N2(e){const t=ps();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function A2(e,t){await e.updatePushNotificationDevice({clientId:ps(),alwaysNotify:t})}function L2(e){if(typeof window>"u")return()=>{};const t=ps(),n=T2();let s=null,o=!1;const c=(f=!0)=>{const y=Ih();e.updatePushPresence({clientId:t,pageId:n,visibilityState:j2(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:Ov()&&pl()==="granted",active:f}).catch(()=>{})},d=()=>{o||s!==null||(s=window.setInterval(()=>c(!0),E2))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),d(),()=>{o=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function B2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function O2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function N1(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function j2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function A1(e){const t=e.toJSON(),n=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!n||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:s}}}async function z2(e,t){const n=await e.pushManager.getSubscription();return n?Xm(n,t)?n:(await n.unsubscribe(),null):null}function Xm(e,t){const n=e.options.applicationServerKey;return n?B1(n)===t:!0}async function P2(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return B1(t)}function L1(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(n),o=new ArrayBuffer(s.length),c=new Uint8Array(o);for(let d=0;d<s.length;d+=1)c[d]=s.charCodeAt(d);return o}function B1(e){const t=new Uint8Array(e);let n="";for(const s of t)n+=String.fromCharCode(s);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Gm(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function I2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function H2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const JS="Local",U2=3e4,K2=2,F2=6,O1="nterminal.serverList.viewMode.v1";function W2(){try{return window.localStorage.getItem(O1)==="list"?"list":"stats"}catch{return"stats"}}function q2(e){try{window.localStorage.setItem(O1,e)}catch{}}function Ga(e,t){const n=[lr,...t.map(d=>d.id)],s=new Set(n),o=new Set,c=[];for(const d of e??[])!s.has(d)||o.has(d)||(o.add(d),c.push(d));for(const d of n)o.has(d)||c.push(d);return c}function $2(e,t){const n=new Map(e.map(s=>[s.id,s]));return Ga(t,e).flatMap(s=>{if(s===lr)return[{kind:"main",id:lr}];const o=n.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function e0(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function j1(e){return e===void 0?"":e==="error"?"offline":[`CPU ${cr(e.cpuPercent)} ${zv(e)}`,`MEM ${cr(e.memoryPercent)} ${gs(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${cr(e.diskPercent)} ${gs(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${cr(e.swapPercent)} ${gs(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function V2(e){if(!(e===void 0||e==="error"))return[`CPU ${cr(e.cpuPercent)} (${zv(e)})`,`RAM ${cr(e.memoryPercent)} (${gs(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${cr(e.diskPercent)} (${gs(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${cr(e.swapPercent)} (${gs(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Y2(e,t){const n=j1(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function cr(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function zv(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Zm(e.cpuPercent/100*t)}/${t} cores`}function gs(e,t){return!t0(e)||!t0(t)?"–/–":X2(e,t)}function X2(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Zm(e/s)}/${Zm(t/s)} ${n}`}function Zm(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function t0(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Ad(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function G2(e){return[{label:"CPU",percent:cr(e.cpuPercent),detail:zv(e),tone:Ad(e.cpuPercent)},{label:"MEM",percent:cr(e.memoryPercent),detail:gs(e.memoryUsedBytes,e.memoryTotalBytes),tone:Ad(e.memoryPercent)},{label:"DISK",percent:cr(e.diskPercent),detail:gs(e.diskUsedBytes,e.diskTotalBytes),tone:Ad(e.diskPercent)},{label:"SWAP",percent:cr(e.swapPercent),detail:gs(e.swapUsedBytes,e.swapTotalBytes),tone:Ad(e.swapPercent)}]}function Z2({entry:e}){return e==="error"?p.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?p.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t}),p.jsx("span",{className:"server-list-stat-value",children:"–"})]}),p.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):p.jsx("span",{className:"server-list-stats server-list-stats-grid",title:V2(e),children:G2(e).map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t.label}),p.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),p.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function i0({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:o=0,onServerLabelsChange:c,renderServerChildren:d,compact:m=!1}){const[g,f]=v.useState([]),[y,b]=v.useState([lr]),[C,w]=v.useState(null),[x,D]=v.useState(null),[B,L]=v.useState(""),O=v.useRef(null),[X,U]=v.useState(()=>W2()),[G,F]=v.useState(null),[W,ve]=v.useState(null),[Se,xe]=v.useState({}),ie=v.useRef({}),q=v.useRef(0),J=v.useRef([]),K=v.useRef([lr]),re=v.useRef(null);v.useEffect(()=>{J.current=g},[g]),v.useEffect(()=>{const oe=Ga(y,g);K.current=oe,e0(oe,y)||b(oe)},[g,y]),v.useEffect(()=>{let oe=!1;return e.listAgents().then(he=>{oe||(f(he.agents),b(Ga(he.serverOrder,he.agents)))}).catch(()=>{}),e.getMainInfo().then(he=>{oe||w(he.name)}).catch(()=>{}),()=>{oe=!0}},[e,o]),v.useEffect(()=>{x&&(O.current?.focus(),O.current?.select())},[x]),v.useEffect(()=>{let oe=!1;function he(){const Oe=[{key:"__main__",load:()=>e.getMainStats()},...g.map(je=>({key:je.id,load:()=>e.getAgentStats(je.id)}))],Ke=new Set(Oe.map(je=>je.key));for(const je of Object.keys(ie.current))Ke.has(je)||delete ie.current[je];xe(je=>{const se={};for(const Te of Ke)Te in je&&(se[Te]=je[Te]);return se});for(const je of Oe)je.load().then(se=>{oe||(ie.current[je.key]=0,xe(Te=>Ke.has(je.key)?{...Te,[je.key]:se}:Te))}).catch(se=>{if(oe)return;if(se instanceof or&&se.status===401&&je.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const Te=(ie.current[je.key]??0)+1;ie.current[je.key]=Te,Te>=K2&&xe(we=>Ke.has(je.key)?{...we,[je.key]:"error"}:we)})}he();const ye=window.setInterval(he,U2);return()=>{oe=!0,window.clearInterval(ye)}},[e,g,s]);function A(oe){oe==="main"?(L(C??""),D({kind:"main"})):(L(oe.name),D({kind:"agent",id:oe.id}))}async function R(){if(!x)return;const oe=B.trim(),he=x;if(D(null),he.kind==="main"){const ye=oe||"";try{const Oe=await e.renameMain(ye);w(Oe.name)}catch{}}else{if(!oe)return;const ye=g.find(Oe=>Oe.id===he.id)?.name;f(Oe=>Oe.map(Ke=>Ke.id===he.id?{...Ke,name:oe}:Ke));try{await e.renameAgent(he.id,oe)}catch{ye!==void 0&&f(Oe=>Oe.map(Ke=>Ke.id===he.id?{...Ke,name:ye}:Ke))}}}function P(){D(null)}function ne(oe){U(oe),q2(oe)}function ge(oe,he,ye){if(oe===he)return;const Oe=Ga(K.current,J.current),Ke=Oe.findIndex(nt=>nt===oe),je=Oe.findIndex(nt=>nt===he);if(Ke<0||je<0)return;const se=[...Oe],[Te]=se.splice(Ke,1);if(!Te)return;const we=se.findIndex(nt=>nt===he);if(we<0)return;const ze=ye==="before"?we:we+1;if(se.splice(ze,0,Te),e0(se,Oe))return;const Ue=q.current+1;q.current=Ue,K.current=se,b(se),e.reorderAgents(se).then(nt=>{if(q.current===Ue){J.current=nt.agents;const ht=Ga(nt.serverOrder,nt.agents);K.current=ht,f(nt.agents),b(ht)}}).catch(async()=>{if(q.current===Ue)try{const nt=await e.listAgents();if(q.current===Ue){J.current=nt.agents;const ht=Ga(nt.serverOrder,nt.agents);K.current=ht,f(nt.agents),b(ht)}}catch{q.current===Ue&&(K.current=Oe,b(Oe))}})}function M(oe,he){const ye=Ga(K.current,J.current),Oe=ye.findIndex(je=>je===oe),Ke=ye[Oe+he];Oe<0||!Ke||ge(oe,Ke,he<0?"before":"after")}function V(oe,he){he.pointerType==="mouse"&&he.button!==0||(he.stopPropagation(),re.current={sourceId:oe,pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,active:!1,targetId:null,placement:"after"},he.currentTarget.setPointerCapture?.(he.pointerId))}function le(oe){const he=re.current;if(!he||he.pointerId!==oe.pointerId)return;const ye=Math.hypot(oe.clientX-he.startX,oe.clientY-he.startY);if(!he.active){if(ye<F2)return;he.active=!0,F(he.sourceId)}const Ke=document.elementFromPoint(oe.clientX,oe.clientY)?.closest("[data-server-id]"),je=Ke?.dataset.serverId??null;if(!Ke||!je||je===he.sourceId){he.targetId=null,ve(null);return}const se=Ke.getBoundingClientRect(),Te=oe.clientY<se.top+se.height/2?"before":"after";he.targetId=je,he.placement=Te,ve({serverId:je,placement:Te})}function _e(oe){const he=re.current;!he||he.pointerId!==oe.pointerId||(oe.stopPropagation(),oe.currentTarget.releasePointerCapture?.(oe.pointerId),re.current=null,F(null),ve(null),he.active&&he.targetId&&ge(he.sourceId,he.targetId,he.placement))}function be(oe){const he=re.current;he&&he.pointerId===oe.pointerId&&oe.currentTarget.releasePointerCapture?.(oe.pointerId),re.current=null,F(null),ve(null)}const Ee=C?.trim()||JS,Me=x?.kind==="main",Re=X==="stats",Pe=$2(g,y),Be=Pe.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:Ee},...g.map(oe=>({agentId:oe.id,label:oe.name}))])},[g,Ee,c]),m?p.jsx("div",{className:"server-list server-list--compact",children:Pe.map(oe=>{const he=oe.kind==="main",ye=he?Ee:oe.agent.name,Oe=he?lr:oe.id,Ke=Se[Oe],je=j1(Ke);return p.jsxs("button",{type:"button",className:`server-list-chip${(he?t===null:t===oe.id)?" server-list-chip--active":""}`,onClick:()=>n(he?null:oe.id),"aria-label":ye,title:`${ye}${je?` — ${je}`:""}`,children:[p.jsx("span",{className:"server-list-chip-initial",children:H2(ye)}),p.jsx("span",{className:"server-list-chip-pip","data-status":I2(Ke)})]},oe.id)})}):p.jsxs("div",{className:`server-list server-list--${X}`,children:[p.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":X==="list",onClick:()=>ne("list"),title:"Show server names only",children:"List"}),p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":X==="stats",onClick:()=>ne("stats"),title:"Show resource usage",children:"Stats"})]}),Pe.map(oe=>{const he=oe.kind==="main",ye=he?Ee:oe.agent.name,Oe=he?lr:oe.id,Ke=he?t===null:t===oe.id,je=he?Me:x?.kind==="agent"&&x.id===oe.id,se=d?.({agentId:he?null:oe.id,serverId:oe.id,label:ye,active:Ke}),Te=W?.serverId===oe.id&&G!==oe.id?` server-list-section--drop-target server-list-section--drop-${W.placement}`:"";return p.jsxs("section",{className:`server-list-section${Te}`,"aria-label":`${ye} server`,children:[p.jsx("div",{className:["server-list-row",G===oe.id?"server-list-row--dragging":"",W?.serverId===oe.id&&G!==oe.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":oe.id,children:je?p.jsxs(p.Fragment,{children:[Be?p.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,p.jsx("form",{className:"server-list-editor",onSubmit:we=>{we.preventDefault(),R()},children:p.jsx("input",{ref:O,"aria-label":he?"Rename main server":`Rename ${ye}`,value:B,onChange:we=>L(we.target.value),onBlur:()=>{R()},onKeyDown:we=>{we.key==="Escape"&&(we.preventDefault(),P())},placeholder:he?JS:void 0})})]}):p.jsxs(p.Fragment,{children:[Be?p.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":oe.id,title:"Drag to reorder","aria-label":`Reorder ${ye}`,"aria-grabbed":G===oe.id,onPointerDown:we=>V(oe.id,we),onPointerMove:le,onPointerUp:_e,onPointerCancel:be,onKeyDown:we=>{(we.key==="ArrowUp"||we.key==="ArrowDown")&&(we.preventDefault(),we.stopPropagation(),M(oe.id,we.key==="ArrowUp"?-1:1))},onClick:we=>we.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:`server-list-item${Ke?" server-list-item--active":""}`,onClick:()=>n(he?null:oe.id),onDoubleClick:we=>{we.preventDefault(),A(he?"main":{id:oe.id,name:ye})},title:Y2(ye,Se[Oe]),children:[p.jsxs("span",{className:"server-list-item-header",children:[p.jsx("span",{className:"server-list-dot"}),p.jsx("span",{className:"server-list-name",title:he?void 0:oe.agent.url??"Outbound connection to main",children:ye})]}),Re?p.jsx(Z2,{entry:Se[Oe]}):null]})]})}),se?p.jsx("div",{className:"server-list-children",children:se}):null]},oe.id)})]})}function Q2({api:e}){const[t,n]=v.useState([]),[s,o]=v.useState([]),[c,d]=v.useState(!1),[m,g]=v.useState(null),[f,y]=v.useState(""),[b,C]=v.useState("");async function w(){try{const[L,O,X]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(L.devices),o(O.networks),d(X.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(L){await e.revokeDevice(L),await w()}async function D(L){await e.removeNetwork(L),await w()}async function B(L){L.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:b.trim()}),y(""),C(""),await w()}catch(O){g(O instanceof Error?O.message:"Failed to add network")}}return p.jsxs(p.Fragment,{children:[m?p.jsx("p",{className:"form-error",children:m}):null,p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted devices"}),p.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?p.jsx("p",{className:"muted",children:"No trusted devices."}):p.jsx("ul",{className:"security-list",children:t.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsxs("span",{className:"security-item-label",children:[L.label,L.current?p.jsx("span",{className:"security-badge",children:"this device"}):null]}),p.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(L.id)},children:"revoke"})]},L.id))})]}),p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted networks"}),p.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?p.jsx("p",{className:"muted",children:"No trusted networks."}):p.jsx("ul",{className:"security-list",children:s.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?p.jsx("span",{className:"security-item-meta",children:L.label}):null]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(L.id)},children:"remove"})]},L.id))}),p.jsxs("form",{className:"security-add-form",onSubmit:B,children:[p.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:L=>y(L.currentTarget.value),required:!0}),p.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:L=>C(L.currentTarget.value)}),p.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Two-factor authentication"}),p.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),p.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const J2=1500,Pv="nterminal.terminal.fontSize",Iv="nterminal.terminal.fontFamily",Qm="nterminal:terminal-font-size",Jm="nterminal:terminal-font-family",eg=11,tg=20,eo=14,fh=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],al="meslo";ig(al);async function am(e=eo,t=al){if(typeof document>"u"||!document.fonts)return;const n=I1(t).webFontFamilies;if(n.length===0)return;const s=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(o=>{globalThis.setTimeout(o,J2)})])}function z1(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return eo;const n=Math.round(t);return Math.max(eg,Math.min(tg,n))}function P1(e){return fh.some(t=>t.id===e)?e:al}function ig(e){return I1(e).cssFamily}function I1(e){return fh.find(t=>t.id===e)??fh[0]}function ng(){if(typeof window>"u")return eo;try{const e=window.localStorage.getItem(Pv);return e?z1(e):eo}catch{return eo}}function rg(){if(typeof window>"u")return al;try{return P1(window.localStorage.getItem(Iv))}catch{return al}}function Ld(e){const t=z1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Pv,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Qm,{detail:t})),t}function eD(e){const t=P1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Iv,t)}catch{}return window.dispatchEvent(new CustomEvent(Jm,{detail:t})),t}function H1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Pv&&e()};return window.addEventListener(Qm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qm,e),window.removeEventListener("storage",t)}}function U1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Iv&&e()};return window.addEventListener(Jm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Jm,e),window.removeEventListener("storage",t)}}const Hv="nterminal.terminal.showScrollProgress",sg="nterminal:terminal-scroll-progress",Uv="nterminal.terminal.tmuxScrollback.shell",Kv="nterminal.terminal.tmuxScrollback.agent",Fv="nterminal.terminal.tmuxScrollback.overrides",Fc="nterminal:terminal-tmux-scrollback",tD=200;function ag(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Hv)!=="false"}catch{return!0}}function iD(e){if(typeof window<"u"){try{window.localStorage.setItem(Hv,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(sg,{detail:e}))}return e}function K1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Hv&&e()};return window.addEventListener(sg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(sg,e),window.removeEventListener("storage",t)}}function og(){return F1(Uv,!0)}function nD(e){return W1(Uv,e,Fc)}function lg(){return F1(Kv,!0)}function rD(e){return W1(Kv,e,Fc)}function Xd(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Uv||n.key===Kv||n.key===Fv)&&e()};return window.addEventListener(Fc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Fc,e),window.removeEventListener("storage",t)}}function om(e){const n=q1()[e];return typeof n=="boolean"?n:null}function sD(e,t){if(typeof window<"u"){try{const n=q1(),s=Object.entries(n).filter(([c])=>c!==e);s.push([e,t]);const o=s.slice(-tD);window.localStorage.setItem(Fv,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Fc,{detail:{terminalId:e,enabled:t}}))}return t}function F1(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function W1(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function q1(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Fv);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t))typeof o=="boolean"&&(n[s]=o);return n}catch{return{}}}const Wv="nterminal.shortcuts.workspace.v1",cg="nterminal:workspace-shortcuts",Wc=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],Hh={"server.previous":xi("ArrowUp",{ctrlKey:!0}),"server.next":xi("ArrowDown",{ctrlKey:!0}),"tab.previous":xi("ArrowLeft",{ctrlKey:!0}),"tab.next":xi("ArrowRight",{ctrlKey:!0}),"tab.index":xi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":xi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":xi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":xi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":xi("KeyH",{altKey:!0}),"scrollback.toggle":xi("KeyS",{altKey:!0})},aD={"server.previous":xi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":xi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":xi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":xi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":xi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":xi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":xi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":xi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":xi("KeyH",{altKey:!0}),"scrollback.toggle":xi("KeyS",{altKey:!0})};function so(){const e=Y1(Hh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Wv);if(!t)return e;const n=JSON.parse(t);for(const s of Wc){const o=n[s.id];if(pD(o)){const c=X1(o,s);fD(c,aD[s.id])||(e[s.id]=c)}}}catch{return e}return e}function n0(){return JSON.stringify(so())}function oD(e,t){const n=so(),s=Wc.find(o=>o.id===e);return s&&(n[e]=X1(t,s),qv(n)),n}function lD(e){const t=so();return t[e]={...Hh[e]},qv(t),t}function cD(){const e=Y1(Hh);return qv(e),e}function ph(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Wv&&e()};return window.addEventListener(cg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(cg,e),window.removeEventListener("storage",t)}}function uD(e,t){const n=Q1(e);return!n||gD(n)||t.indexed&&Z1(e)===null||t.requiresPrimaryModifier&&!G1(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function $1(e){const t=so();for(const n of Wc){const s=t[n.id];if(!(!s||!mD(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const o=Z1(e);if(o!==null)return{id:n.id,index:o};continue}if(Q1(e)===s.code)return{id:n.id,index:null}}}return null}function mh(e){return V1(so()[e])}function V1(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(vD(e.code)),t.join("+")}const dD=()=>mh("split.right"),hD=()=>mh("split.down");function xi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Y1(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function fD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function qv(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Wv,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(cg))}}function X1(e,t){return t.requiresPrimaryModifier&&!G1(e)?{...Hh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function G1(e){return e.ctrlKey||e.altKey||e.metaKey}function pD(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function mD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Z1(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function Q1(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function gD(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function vD(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const _D="Automatic update needs write access to the global npm install. Run this from a normal NTerminal runtime-user shell; only the npm install step uses sudo.";function bD(e="nterminal",t=new Date){return{reason:"permission",message:_D,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function yD(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const J1=3600*1e3,SD="local",ug=new Set,ha=new Map;let ga={checking:!1,hasUpdates:!1,lastCheckedAt:null},$v=null,zc=null,gh=0,aa=null;function wD(e){return ug.add(e),()=>{ug.delete(e)}}function r0(){return ga}function CD(e){const t=DD();$v=e,Vv(),dg(e,t);const n=()=>{if(document.visibilityState!=="visible"||!va(e,t))return;const s=ga.lastCheckedAt;(s===null||Date.now()-s>=J1)&&dg(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),va(e,t)&&TD()}}function xD(e,t){ha.set(e,eC(t)),ol({...ga,hasUpdates:Yv(),lastCheckedAt:Date.now()})}function lm(e){e===void 0?ha.clear():ha.set(e,!1),ol({...ga,hasUpdates:Yv()})}async function dg(e,t){if(!va(e,t))return;if(aa&&aa.api===e&&aa.runId===t)return aa.promise;ol({...ga,checking:!0});const n=kD(e,t).finally(()=>{aa?.promise===n&&(aa=null),va(e,t)&&(ol({...ga,checking:!1,lastCheckedAt:Date.now()}),ED(e,t))});return aa={api:e,runId:t,promise:n},n}async function kD(e,t){try{const n=await e.listAgents();if(!va(e,t))return;const s=[{key:SD,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(s.map(async c=>{try{const d=await c.check();o.set(c.key,eC(d))}catch{o.set(c.key,ha.get(c.key)??!1)}})),!va(e,t))return;ha.clear();for(const[c,d]of o)ha.set(c,d);ol({...ga,hasUpdates:Yv()})}catch{}}function ED(e,t){va(e,t)&&(Vv(),zc=window.setTimeout(()=>{zc=null,va(e,t)&&dg(e,t)},J1))}function TD(){gh+=1,Vv(),$v=null,aa=null,ha.clear(),ol({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Vv(){zc!==null&&(window.clearTimeout(zc),zc=null)}function DD(){return gh+=1,gh}function va(e,t){return $v===e&&gh===t}function eC(e){return e.updateAvailable===!0}function Yv(){return Array.from(ha.values()).some(Boolean)}function ol(e){ga=e;for(const t of Array.from(ug))t()}const RD=e=>new Promise(t=>setTimeout(t,e));function MD({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[d,m]=v.useState(!1),[g,f]=v.useState(null),[y,b]=v.useState(!1),[C,w]=v.useState({});function x(R,P){c(ne=>({...ne,[R]:{...ne[R],...P}}))}function D(R,P){w(ne=>({...ne,[R]:{status:ne[R]?.status??null,busy:ne[R]?.busy??!1,error:ne[R]?.error??null,...P}}))}const B=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),L=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),O=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),X=R=>R.id===null?e:rl(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(P=>{if(R)return;const ne=[{key:"local",id:null,name:"Local (main)"},...P.agents.map(ge=>({key:ge.id,id:ge.id,name:ge.name}))];s(ne);for(const ge of ne)B(ge).then(M=>x(ge.key,{version:M,manualUpdate:M.manualUpdate??null})).catch(M=>x(ge.key,{error:M instanceof Error?M.message:"unreachable"})),K(ge)}).catch(()=>{}),()=>{R=!0}},[]);async function U(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const P=await L(R);xD(R.key,P),x(R.key,{latestVersion:P.latestVersion,updateAvailable:P.updateAvailable,status:ie(P),...P.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(P){x(R.key,{busy:!1,error:P instanceof Error?P.message:"check failed"})}}async function G(){m(!0),await Promise.all(n.map(R=>U(R))),m(!1)}async function F(R,P){const ne=Date.now()+18e4;for(;Date.now()<ne;){await RD(3e3);try{const ge=await B(R);if(P&&ge.runningVersion!==P.runningVersion)return ge}catch{}}return null}async function W(R){let P=o[R.key]?.version;if(!P)try{P=await B(R),x(R.key,{version:P,manualUpdate:P.manualUpdate??null})}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let ne;try{ne=await O(R)}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!ne.ok){const M=ne.manualUpdate??(yD(ne.message)?bD():null);return M?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(x(R.key,{busy:!1,status:void 0,error:ne.message}),"failed")}if(!ne.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),lm(R.key),"unchanged";x(R.key,{status:"restarting…"});const ge=await F(R,P);return ge?(x(R.key,{busy:!1,version:ge,updateAvailable:!1,status:"updated",manualUpdate:ge.manualUpdate??null}),lm(R.key),R.id===null&&(b(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(x(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function ve(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
-
`)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ne=await e.uninstallAgent(R.id);s(
|
|
16
|
-
`):`${g.action} ${g.status}`}):null,p.jsxs("div",{className:"server-code-addon-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:t||f||!w,children:"Check"}),b?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||f||!w,children:e?.updateAvailable?"Update code-server":"Reinstall"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!C,children:"Stop"}),p.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||f,children:"Uninstall"})]}):p.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:!y||x||t||f||!w,children:"Install code-server"})]})]})}async function AD(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Bd=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function LD({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const c=v.useMemo(()=>t??Mh(),[t]),[d,m]=v.useState(()=>ng()),[g,f]=v.useState(()=>rg()),[y,b]=v.useState(()=>ag()),[C,w]=v.useState(()=>og()),[x,D]=v.useState(()=>lg()),[B,L]=v.useState(()=>pa()),[O,X]=v.useState(()=>so()),[U,G]=v.useState(null),[F,W]=v.useState(null),[ve,Se]=v.useState("appearance"),[xe,ie]=v.useState(()=>Ov()),[q,J]=v.useState(()=>ro()),[K,re]=v.useState(()=>pl()),[A,R]=v.useState([]),[P,ne]=v.useState([]),[ge,M]=v.useState([]),[V,le]=v.useState(5*1024*1024),[_e,be]=v.useState(!1),[Ee,Me]=v.useState(null),[Re,Pe]=v.useState(null),[Be,oe]=v.useState(!1),[he,ye]=v.useState(null),[Oe,Ke]=v.useState(null),je=v.useRef(null),se=v.useRef(null),Te=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),we=v.useMemo(()=>new Set(P),[P]),ze=!OD(P,ge),Ue=v.useMemo(()=>Ih(),[]),nt=Re?.displayMode==="standalone"&&(Re.deviceKind==="mobile"||Re.deviceKind==="tablet");v.useEffect(()=>H1(()=>m(ng())),[]),v.useEffect(()=>U1(()=>f(rg())),[]),v.useEffect(()=>K1(()=>b(ag())),[]),v.useEffect(()=>Xd(()=>{w(og()),D(lg())}),[]),v.useEffect(()=>Cv(()=>L(pa())),[]),v.useEffect(()=>ph(()=>X(so())),[]),v.useEffect(()=>D1(()=>J(ro())),[]),v.useEffect(()=>{if(!U)return;const Z=Wc.find(st=>st.id===U);if(!Z)return;const We=st=>{if(st.preventDefault(),st.stopPropagation(),st.key==="Escape"){G(null),W(null);return}const et=uD(st,Z);if(!et){W(BD(Z));return}X(oD(U,et)),G(null),W(null)};return window.addEventListener("keydown",We,!0),()=>window.removeEventListener("keydown",We,!0)},[U]),v.useEffect(()=>{let Z=!1;return c.listNotificationAssets().then(We=>{Z||Ne(We)}).catch(We=>{Z||Me(Go(We))}),()=>{Z=!0}},[c]),v.useEffect(()=>{let Z=!1;return c.getPushNotificationStatus(ps()).then(We=>{Z||(Pe(We.currentDevice),ye(null))}).catch(We=>{Z||ye(Go(We))}),()=>{Z=!0}},[c]);function ht(Z){m(Ld(Number(Z)))}function Dt(Z){J(GS(Number(Z)))}function Ei(Z){Se(Z);const We=se.current,st=Te.current[Z];if(!We||!st)return;const et=Math.max(0,s0(st,We)-12);typeof We.scrollTo=="function"?We.scrollTo({top:et,behavior:"smooth"}):We.scrollTop=et}function ni(){const Z=se.current;if(!Z)return;if(Z.scrollTop+Z.clientHeight>=Z.scrollHeight-2){Se(Bd[Bd.length-1].id);return}let We="appearance";const st=Z.scrollTop+Math.min(180,Math.max(48,Z.clientHeight*.28));for(const et of Bd){const wt=Te.current[et.id];wt&&s0(wt,Z)<=st&&(We=et.id)}Se(We)}function di(Z){X(lD(Z)),G(null),W(null)}function ae(){X(cD()),G(null),W(null)}function Ne(Z){const We=Z.assets.filter(st=>st.enabled).map(st=>st.id);R(Z.assets),ne(We),M(We),le(Z.maxFileBytes),Me(null)}async function Qe(){if(xe){XS(!1),ie(!1);return}let Z=K;Z==="default"&&(Z=await M1(),re(Z)),Z==="granted"&&(XS(!0),ie(!0))}async function it(){oe(!0),ye(null),Ke(null);try{if(Re)await N2(c),Pe(null);else{await D2(c,!1);const Z=await c.getPushNotificationStatus(ps());Pe(Z.currentDevice)}}catch(Z){ye(um(Z))}finally{oe(!1)}}async function jt(Z){oe(!0),ye(null),Ke(null);try{await A2(c,Z);const We=await c.getPushNotificationStatus(ps());Pe(We.currentDevice)}catch(We){ye(um(We))}finally{oe(!1)}}async function xt(){oe(!0),ye(null),Ke(null);try{await c.testPushNotification({clientId:ps()}),Ke("Test notification accepted by the push service.")}catch(Z){ye(um(Z))}finally{oe(!1)}}async function gt(Z){const We=Z?.[0];if(We){if(We.size>V){Me(`File must be ${cm(V)} or smaller.`),kt();return}if(We.type!=="video/mp4"&&We.type!=="video/webm"){Me("Upload an MP4 or WebM video."),kt();return}be(!0),Me(null);try{await c.uploadNotificationAsset(We),Ne(await c.listNotificationAssets()),s?.()}catch(st){Me(Go(st))}finally{be(!1),kt()}}}async function Ht(Z){be(!0),Me(null);try{await c.deleteNotificationAsset(Z),Ne(await c.listNotificationAssets()),s?.()}catch(We){Me(Go(We))}finally{be(!1)}}function kt(){je.current&&(je.current.value="")}function Rn(Z,We){const st=new Set(P);if(We?st.add(Z):st.delete(Z),st.size===0){Me("Keep at least one toast video selected.");return}Me(null),ne(Array.from(st))}async function Mn(){if(P.length===0){Me("Keep at least one toast video selected.");return}be(!0),Me(null);try{const Z=await c.updateNotificationAssetSelection({enabledAssetIds:P});Ne(Z),s?.()}catch(Z){Me(Go(Z))}finally{be(!1)}}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:p.jsxs("div",{className:"security-panel settings-panel",onClick:Z=>Z.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{children:"Settings"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),p.jsxs("div",{className:"settings-layout",children:[p.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Bd.map(Z=>p.jsxs("button",{type:"button","data-active":ve===Z.id?"true":"false","aria-current":ve===Z.id?"true":void 0,onClick:()=>Ei(Z.id),children:[Z.label,Z.id==="servers"&&n?p.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},Z.id))}),p.jsxs("div",{ref:se,className:"settings-content",onScroll:ni,children:[p.jsxs("section",{id:"settings-appearance",ref:Z=>{Te.current.appearance=Z},className:"security-section settings-section",children:[p.jsx("h3",{children:"Appearance"}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Theme"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),p.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:lh.map(Z=>p.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":B===Z.id,"data-active":B===Z.id?"true":"false",onClick:()=>L(SE(Z.id)),style:{"--settings-theme-bg":Z.tokens.bg,"--settings-theme-bg-2":Z.tokens.bg2,"--settings-theme-sidebar":Z.tokens.bgSidebar,"--settings-theme-line":Z.tokens.line,"--settings-theme-fg":Z.tokens.fg,"--settings-theme-fg-2":Z.tokens.fg2,"--settings-theme-accent":Z.tokens.accent,"--settings-theme-xterm-bg":Z.xterm.background,"--settings-theme-xterm-fg":Z.xterm.foreground,"--settings-theme-xterm-selection":Z.xterm.selectionBackground},children:[p.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[p.jsxs("span",{className:"settings-theme-preview-sidebar",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-main",children:[p.jsxs("span",{className:"settings-theme-preview-tabs",children:[p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-terminal",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})]})]}),p.jsxs("span",{className:"settings-theme-card-copy",children:[p.jsx("strong",{children:Z.label}),p.jsx("small",{children:Z.description})]})]},Z.id))}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font size"}),p.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),p.jsx("input",{type:"range",min:eg,max:tg,step:1,value:d,"aria-label":"Terminal font size",onChange:Z=>ht(Z.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row",children:[p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Ld(d-1)),children:"-"}),p.jsx("input",{type:"number",min:eg,max:tg,step:1,value:d,"aria-label":"Terminal font size value",onChange:Z=>ht(Z.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Ld(d+1)),children:"+"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(Ld(eo)),children:"Reset"})]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font family"}),p.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:Z=>f(eD(Z.currentTarget.value)),children:fh.map(Z=>p.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:y,onChange:Z=>b(iD(Z.currentTarget.checked))}),"Show scroll progress"]}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:C,onChange:Z=>w(nD(Z.currentTarget.checked))}),"Shell panes"]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:x,onChange:Z=>D(rD(Z.currentTarget.checked))}),"Codex/Claude panes"]})]}),p.jsxs("section",{id:"settings-shortcuts",ref:Z=>{Te.current.shortcuts=Z},className:"security-section settings-section",children:[p.jsxs("div",{className:"settings-section-heading",children:[p.jsx("h3",{children:"Shortcuts"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ae,children:"Reset all"})]}),p.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),F?p.jsx("p",{className:"settings-error",children:F}):null,p.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Wc.map(Z=>{const We=U===Z.id;return p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"settings-shortcut-label",children:Z.label}),p.jsx("span",{className:"settings-shortcut-group",children:Z.group})]}),p.jsxs("div",{className:"settings-shortcut-actions",children:[p.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":We?"true":"false",onClick:()=>{G(Z.id),W(null)},children:We?"Press keys…":V1(O[Z.id])}),p.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>di(Z.id),children:"Reset"})]})]},Z.id)})})]}),p.jsxs("section",{id:"settings-notifications",ref:Z=>{Te.current.notifications=Z},className:"security-section settings-section",children:[p.jsx("h3",{children:"Notifications"}),Ph()?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:xe&&K==="granted",onChange:()=>{Qe()},disabled:K==="denied"}),"System notification when page is hidden"]}),K==="denied"?p.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):p.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):p.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),p.jsxs("div",{className:"settings-subsection",children:[p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:!!Re,onChange:()=>{it()},disabled:Be||!Ue.supported}),"Installed app push notifications"]}),p.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ue.supported?null:p.jsx("p",{className:"muted",children:Gd(Ue.reason)}),Re?p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"muted",children:["Registered as ",Re.label,". Last active ",new Date(Re.lastActiveAt).toLocaleString(),"."]}),p.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{xt()},disabled:Be,children:"Send test notification"})]}):null,nt?p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:Re?.alwaysNotify===!0,onChange:Z=>{jt(Z.currentTarget.checked)},disabled:Be||!Re}),"Always notify this mobile device"]}):null,he?p.jsx("p",{className:"form-error",children:he}):null,Oe?p.jsx("p",{className:"muted",role:"status",children:Oe}):null]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:q.enabled,onChange:Z=>J(b2(Z.currentTarget.checked))}),"Show animated completion toast"]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Toast duration"}),p.jsx("span",{className:"settings-control-value",children:q.persistUntilDismissed?"Until closed":`${q.durationSeconds}s`}),p.jsx("input",{type:"range",min:Vm,max:Ym,step:.5,value:q.durationSeconds,disabled:!q.enabled||q.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:Z=>Dt(Z.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[p.jsx("input",{type:"number",min:Vm,max:Ym,step:.5,value:q.durationSeconds,disabled:!q.enabled||q.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:Z=>Dt(Z.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!q.enabled||q.persistUntilDismissed,onClick:()=>J(GS(jc)),children:"Reset"})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:q.persistUntilDismissed,disabled:!q.enabled,onChange:Z=>J(y2(Z.currentTarget.checked))}),"Keep toast until dismissed"]}),p.jsxs("div",{className:"settings-assets-header",children:[p.jsx("span",{children:"Toast videos"}),p.jsxs("span",{children:[cm(V)," max"]})]}),p.jsx("input",{ref:je,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:Z=>{gt(Z.currentTarget.files)}}),p.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:_e,onClick:()=>je.current?.click(),children:"Upload video"}),Ee?p.jsx("p",{className:"settings-error",children:Ee}):null,A.length>0?p.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:A.map(Z=>p.jsxs("li",{"data-enabled":we.has(Z.id)?"true":"false",children:[p.jsxs("label",{className:"settings-asset-choice",children:[p.jsx("input",{type:"checkbox",checked:we.has(Z.id),disabled:_e,"aria-label":`Use ${Z.filename}`,onChange:We=>Rn(Z.id,We.currentTarget.checked)}),p.jsx("video",{src:Z.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),p.jsxs("span",{className:"settings-asset-copy",children:[p.jsx("span",{children:Z.filename}),p.jsx("small",{children:Z.source==="built-in"?"Built-in":cm(Z.size)})]})]}),Z.source==="uploaded"?p.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:_e,"aria-label":`Delete ${Z.filename}`,onClick:()=>{Ht(Z.id)},children:"x"}):null]},Z.id))}):p.jsx("p",{className:"muted",children:"Built-in videos will be used."}),p.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:_e||A.length===0||!ze,onClick:()=>{Mn()},children:"Save selected videos"})]}),p.jsx("div",{id:"settings-security",ref:Z=>{Te.current.security=Z},className:"settings-section-group",children:p.jsx(Q2,{api:c})}),p.jsx("div",{id:"settings-servers",ref:Z=>{Te.current.servers=Z},className:"settings-section-group",children:p.jsx(MD,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function s0(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function cm(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Go(e){return e instanceof Error?e.message:"Request failed."}function Gd(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function um(e){const t=Go(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Gd("not_standalone"):t==="insecure"?Gd("insecure"):t==="not_mobile"?Gd("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function BD(e){return e.indexed?"Press a shortcut ending in a number from 1 to 9.":e.requiresPrimaryModifier?"Use Ctrl, Alt, or Meta with another key.":"Press a complete shortcut."}function OD(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}class Va extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function jD(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,s=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{d||(d=!0,m(),o(b))},f=b=>{d||(d=!0,m(),c(b))},y=()=>{t.abort(),f(new Va(0,"Upload aborted."))};if(e.signal?.aborted){f(new Va(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new Va(t.status,"Invalid upload response."))}return}f(new Va(t.status,zD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Va(0,"Upload failed.")),t.onabort=()=>f(new Va(0,"Upload aborted.")),t.ontimeout=()=>f(new Va(0,"Upload timed out.")),t.send(n)})}function zD(e,t){try{const n=JSON.parse(e),s=typeof n.error=="string"?n.error:n.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const PD="modulepreload",ID=function(e){return"/"+e},a0={},Xv=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let g=function(f){return Promise.all(f.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");o=g(n.map(f=>{if(f=ID(f),f in a0)return;a0[f]=!0;const y=f.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const C=document.createElement("link");if(C.rel=y?"stylesheet":PD,y||(C.as="script"),C.crossOrigin="",C.href=f,m&&C.setAttribute("nonce",m),document.head.appendChild(C),y)return new Promise((w,x)=>{C.addEventListener("load",w),C.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return o.then(d=>{for(const m of d||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},HD=v.lazy(()=>Xv(()=>import("./MarkdownPreview-D5NthhhG.js"),__vite__mapDeps([0,1])));function UD({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:o}){const[c,d]=v.useState(null),[m,g]=v.useState(""),[f,y]=v.useState({}),[b,C]=v.useState(()=>new Set),[w,x]=v.useState(null),[D,B]=v.useState({type:"empty"}),[L,O]=v.useState("idle"),[X,U]=v.useState(null),G=v.useRef(null),F=v.useRef(null),W=v.useRef(!1),ve=v.useRef(0),Se=v.useRef(null);Se.current===null&&t&&(Se.current=t);const xe=Se.current,ie=s?FD(s):t?o0(t,n):null,q=c?[c.rootPath,m].filter(Boolean).join("/"):"",J=w?.path??null;v.useEffect(()=>(W.current=!0,()=>{W.current=!1,ve.current+=1,oe()}),[]),v.useEffect(()=>{Se.current=t,F.current=null,K(ie)},[e]),v.useEffect(()=>{s&&ie!==F.current&&re(s,ie)},[s,ie]),v.useEffect(()=>{if(s||!xe||t!==xe)return;const se=o0(xe,n);se!==F.current&&A(xe,se)},[xe,t,n,s]);async function K(se=ie){if(s){await re(s,se);return}await A(t,se)}async function re(se,Te=ie){const we=he();if(F.current=Te,oe(),d(null),g(""),y({}),C(new Set),x(null),B({type:"empty"}),U(null),!se){O("idle");return}O("loading");try{const ze=await e.createFileRoot({path:se});if(!ye(we))return;d({rootToken:ze.rootToken,rootPath:ze.rootPath});const Ue=await e.listFiles({rootToken:ze.rootToken,path:""});if(!ye(we))return;ne(Ue),O("idle")}catch(ze){ye(we)&&(U(us(ze)),O("idle"))}}async function A(se,Te=ie){const we=he();if(F.current=Te,oe(),d(null),g(""),y({}),C(new Set),x(null),B({type:"empty"}),U(null),!se){O("idle");return}O("loading");try{const ze=await e.createFileRoot({terminalId:se});if(!ye(we))return;d({rootToken:ze.rootToken,rootPath:ze.rootPath});const Ue=await e.listFiles({rootToken:ze.rootToken,path:""});if(!ye(we))return;ne(Ue),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function R(se=m,Te=c){if(!Te)return;const we=he();O("loading"),U(null);try{const ze=await e.listFiles({rootToken:Te.rootToken,path:se});if(!ye(we))return;ne(ze),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function P(){if(s){await re(s,ie);return}Se.current=t,await A(t,ie)}function ne(se){y(Te=>({...Te,[se.path]:WD(se.entries)}))}async function ge(se){if(!(!dm(se)||!c)){if(x(se),U(null),se.kind==="directory"){g(se.path),Be(),await V(se);return}if(g(Ya(se.path)),se.editable){await _e(se);return}se.previewKind!=="none"&&await Ee(se,se.previewKind)}}async function M(se){if(!(!dm(se)||!c)){if(x(se),U(null),se.kind==="directory"){g(se.path),Be(),await V(se);return}if(g(Ya(se.path)),se.editable){await be(se);return}se.previewKind!=="none"&&await Ee(se,se.previewKind)}}async function V(se){if(b.has(se.path)){C(Te=>{const we=new Set(Te);return we.delete(se.path),we});return}C(Te=>new Set(Te).add(se.path)),await R(se.path)}function le(se,Te){se.key==="Enter"&&(se.preventDefault(),M(Te))}async function _e(se){if(!c)return;const Te=he();O("loading"),oe();try{const we=await e.readFile({rootToken:c.rootToken,path:se.path});if(!ye(Te))return;B({type:"text-preview",file:se,read:we}),O("idle")}catch(we){if(await Oe(we,Te))return;ye(Te)&&(U(us(we)),O("idle"))}}async function be(se){if(!c)return;const Te=he();O("loading");try{await o({rootToken:c.rootToken,path:se.path,...t?{terminalId:t}:{}}),ye(Te)&&O("idle")}catch(we){if(await Oe(we,Te))return;ye(Te)&&(U(us(we)),O("idle"))}}async function Ee(se,Te){if(!c)return;const we=he();O("loading"),oe();try{const ze=await e.previewFile({rootToken:c.rootToken,path:se.path});if(!ye(we))return;const Ue=URL.createObjectURL(ze);if(!ye(we)){URL.revokeObjectURL(Ue);return}G.current=Ue,B({type:"preview",file:se,previewKind:Te,url:Ue}),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function Me(se){if(!c)return;const Te=se==="file"?"New file":"New folder",we=window.prompt(Te,""),ze=w?w.kind==="directory"?w.path:Ya(w.path):m,Ue=l0(we,ze);if(Ue){U(null);try{const nt=await e.createFileEntry({rootToken:c.rootToken,path:Ue,kind:se});x(nt.entry),await R(ze)}catch(nt){if(await Oe(nt))return;U(us(nt))}}}async function Re(){if(!c||!w)return;const se=window.prompt("Move selected entry",w.path),Te=l0(se,"");if(!Te||Te===w.path)return;const we=Ya(w.path),ze=Ya(Te);U(null);try{const Ue=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:Te});x(Ue.entry),g(Ue.entry.kind==="directory"?Ue.entry.path:Ya(Ue.entry.path)),Be(),await R(we),ze!==we&&await R(ze)}catch(Ue){if(await Oe(Ue))return;U(us(Ue))}}async function Pe(){if(!c||!w)return;const se=w.path,Te=Ya(se);U(null);try{const we=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),ze=we.descendantCount>0?` and ${we.descendantCount} nested item${we.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${we.path}${ze}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:we.previewToken}),x(null),g(Te),C(Ue=>{const nt=new Set(Ue);for(const ht of Ue)(ht===se||ht.startsWith(`${se}/`))&&nt.delete(ht);return nt}),Be(),await R(Te)}catch(we){if(await Oe(we))return;U(us(we))}}function Be(){ve.current+=1,oe(),B({type:"empty"})}function oe(){G.current&&(URL.revokeObjectURL(G.current),G.current=null)}function he(){return ve.current+=1,ve.current}function ye(se){return W.current&&se===ve.current}async function Oe(se,Te){return qD(se)?(Te!==void 0&&!ye(Te)||await K(ie),!0):!1}function Ke(se,Te){const we=dm(se),ze=se.kind==="directory"&&b.has(se.path),Ue=f[se.path]??[],nt={"--file-tree-depth":Te};return p.jsxs(Li.Fragment,{children:[p.jsxs("button",{type:"button",className:"file-entry-button","data-kind":se.kind,"data-expanded":ze,"data-active":J===se.path,disabled:!we,style:nt,"aria-expanded":se.kind==="directory"?ze:void 0,"aria-label":`${se.kind==="directory"?"Open folder":"Open file"} ${se.name}`,title:se.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ge(se)},onDoubleClick:()=>{M(se)},onKeyDown:ht=>le(ht,se),children:[p.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:se.kind==="directory"?ze?"▾":"▸":""}),p.jsx("span",{className:"file-entry-name",children:se.name}),p.jsx("small",{children:KD(se)})]}),ze?p.jsx("div",{className:"file-tree-children",role:"group",children:Ue.map(ht=>Ke(ht,Te+1))}):null]},se.path)}const je=f[""]??[];return p.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[p.jsxs("header",{className:"file-explorer-header",children:[p.jsx("div",{className:"file-explorer-path",title:q,children:q||"No active pane"}),p.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[p.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{P()},children:"↻"}),p.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Me("file")},children:"+"}),p.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Me("directory")},children:"▣"})]})]}),X?p.jsx("div",{className:"file-explorer-alert",role:"alert",children:X}):null,p.jsxs("div",{className:"file-explorer-layout",children:[p.jsx("div",{className:"file-tree","aria-label":q?`Files in ${q}`:"Files",children:je.map(se=>Ke(se,0))}),p.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[p.jsxs("div",{className:"file-detail-header",children:[p.jsx("strong",{children:w?.name??"detail"}),p.jsxs("div",{className:"file-detail-actions",children:[p.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Re()},children:"Move"}),p.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Pe()},children:"Delete"})]})]}),L==="loading"?p.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&L!=="loading"?p.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?p.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?p.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?p.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?p.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:p.jsx(v.Suspense,{fallback:p.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:p.jsx(HD,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?p.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function dm(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function KD(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function o0(e,t){return`${e}\0${t??""}`}function FD(e){return`workspace\0${e}`}function WD(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Ya(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function l0(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function us(e){return e instanceof Error?e.message:"Request failed"}function qD(e){return e instanceof or&&e.status===409&&e.message==="terminal_cwd_changed"}const $D=v.lazy(()=>Xv(()=>import("./MarkdownPreview-D5NthhhG.js"),__vite__mapDeps([0,1])));function c0({api:e,editor:t,canClose:n,onClose:s}){const[o,c]=v.useState(t.read),[d,m]=v.useState(t.read.content),[g,f]=v.useState("idle"),[y,b]=v.useState(null),[C,w]=v.useState(!1),[x,D]=v.useState("edit"),B=v.useRef(t),L=v.useRef(t.read),O=v.useRef(t.read.content),X=v.useRef(!1),U=v.useRef(!1),G=v.useRef(0),F=d!==o.content&&g!=="saving"&&!C;v.useEffect(()=>(U.current=!0,()=>{U.current=!1,G.current+=1}),[]),v.useEffect(()=>{G.current+=1,X.current=!1,B.current=t,L.current=t.read,O.current=t.read.content,c(t.read),m(t.read.content),f("idle"),b(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{L.current=o},[o]),v.useEffect(()=>{O.current=d},[d]),v.useEffect(()=>{if(d===o.content||C)return;const ie=window.setInterval(()=>{!X.current&&O.current!==L.current.content&&W()},1e3);return()=>window.clearInterval(ie)},[d===o.content,C,t.id]);async function W(){if(X.current)return;const ie=O.current,q=L.current;if(ie===q.content)return;const J=B.current,K=G.current;X.current=!0,f("saving"),b(null),w(!1);try{const re=await e.writeFile({rootToken:J.rootToken,path:J.path,content:ie,expectedVersion:q.version});if(!U.current||K!==G.current)return;const A={...q,content:ie,version:re.version};L.current=A,c(A),f(O.current===ie?"saved":"idle")}catch(re){if(!U.current||K!==G.current)return;if(re instanceof or&&re.status===409){w(!0),f("idle");return}b(VD(re)),f("idle")}finally{K===G.current&&(X.current=!1)}}const ve=g==="saving"?"saving":g==="saved"?"saved":o.language,Se=o.language==="markdown",xe=Se&&x==="preview";return p.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[p.jsxs("header",{className:"editor-pane-header",children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("strong",{children:t.title}),p.jsx("span",{className:"terminal-pane-spacer"}),p.jsx("span",{className:"terminal-pane-state",children:ve}),p.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!F,onClick:()=>{W()},children:"Save"}),Se?p.jsx("button",{type:"button","aria-label":`${xe?"Edit":"Preview"} ${t.title}`,onClick:()=>D(ie=>ie==="preview"?"edit":"preview"),children:xe?"Edit":"Preview"}):null,n?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),y?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,C?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,xe?p.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:p.jsx(v.Suspense,{fallback:p.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:p.jsx($D,{content:d})})}):p.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:ie=>{const q=ie.target.value;O.current=q,m(q),f("idle"),b(null),w(!1)}})]})}function VD(e){return e instanceof Error?e.message:"Request failed"}var YD=2,XD=1,GD=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=d.top+d.bottom,g=d.right+d.left,f=s-m,y=o-g-t;return{cols:Math.max(YD,Math.floor(y/e.css.cell.width)),rows:Math.max(XD,Math.floor(f/e.css.cell.height))}}};var tC=Object.defineProperty,ZD=Object.getOwnPropertyDescriptor,QD=(e,t)=>{for(var n in t)tC(e,n,{get:t[n],enumerable:!0})},ui=(e,t,n,s)=>{for(var o=s>1?void 0:s?ZD(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(s?d(t,n,o):d(o))||o);return s&&o&&tC(t,n,o),o},Le=(e,t)=>(n,s)=>t(n,s,e),u0="Terminal input",hg={get:()=>u0,set:e=>u0=e},d0="Too much output to announce, navigate to rows manually to read",fg={get:()=>d0,set:e=>d0=e};function JD(e){return e.replace(/\r?\n/g,"\r")}function eR(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function tR(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function iR(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");iC(o,t,n,s)}}function iC(e,t,n,s){e=JD(e),e=eR(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nC(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function h0(e,t,n,s,o){nC(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function la(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Uh(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var nR=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,s;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[s++]=(d-55296)*1024+m-56320+65536:(t[s++]=d,t[s++]=m);continue}d!==65279&&(t[s++]=d)}return s}},rR=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,c,d,m,g=0,f=0;if(this.interim[0]){let C=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)w<<=6,w|=D;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=B-x;for(;f<L;){if(f>=n)return 0;if(D=e[f++],(D&192)!==128){f--,C=!0;break}else this.interim[x++]=D,w<<=6,w|=D&63}C||(B===2?w<128?f--:t[s++]=w:B===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let y=n-4,b=f;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((d=e[b+2])&128)&&!((m=e[b+3])&128);)t[s++]=o,t[s++]=c,t[s++]=d,t[s++]=m,b+=4;if(o=e[b++],o<128)t[s++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,s;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[s++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|d&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,s;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(d&63)<<6|m&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},rC="",da=" ",su=class sC{constructor(){this.fg=0,this.bg=0,this.extended=new vh}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 sC;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}},vh=class aC{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}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 aC(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ur=class oC extends su{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new vh,this.combinedData=""}static fromCharData(t){let n=new oC;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?la(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 n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},f0="di$target",pg="di$dependencies",hm=new Map;function sR(e){return e[pg]||[]}function Vi(e){if(hm.has(e))return hm.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");aR(t,n,o)};return t._id=e,hm.set(e,t),t}function aR(e,t,n){t[f0]===t?t[pg].push({id:e,index:n}):(t[pg]=[{id:e,index:n}],t[f0]=t)}var pn=Vi("BufferService"),lC=Vi("CoreMouseService"),lo=Vi("CoreService"),oR=Vi("CharsetService"),Gv=Vi("InstantiationService"),cC=Vi("LogService"),mn=Vi("OptionsService"),uC=Vi("OscLinkService"),lR=Vi("UnicodeService"),au=Vi("DecorationService"),mg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,c=new ur,d=n.getTrimmedLength(),m=-1,g=-1,f=!1;for(let y=0;y<d;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else f=c.extended.urlId!==m;else g!==-1&&(f=!0);if(f||g!==-1&&y===d-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let C={start:{x:g+1,y:e},end:{x:y+(!f&&y===d-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:b,range:C,activate:(x,D)=>o?o.activate(x,D,C):cR(x,D),hover:(x,D)=>o?.hover?.(x,D,C),leave:(x,D)=>o?.leave?.(x,D,C)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(s)}};mg=ui([Le(0,pn),Le(1,mn),Le(2,uC)],mg);function cR(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
14
|
+
`},zE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function PE(e){let{announcements:t=zE,container:n,hiddenTextDescribedById:s,screenReaderInstructions:l=jE}=e;const{announce:c,announcement:d}=LE(),m=Lh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),BE(v.useMemo(()=>({onDragStart(b){let{active:C}=b;c(t.onDragStart({active:C}))},onDragMove(b){let{active:C,over:w}=b;t.onDragMove&&c(t.onDragMove({active:C,over:w}))},onDragOver(b){let{active:C,over:w}=b;c(t.onDragOver({active:C,over:w}))},onDragEnd(b){let{active:C,over:w}=b;c(t.onDragEnd({active:C,over:w}))},onDragCancel(b){let{active:C,over:w}=b;c(t.onDragCancel({active:C,over:w}))}}),[c,t])),!g)return null;const y=Li.createElement(Li.Fragment,null,Li.createElement(NE,{id:s,value:l.draggable}),Li.createElement(AE,{id:m,announcement:d}));return n?wc.createPortal(y,n):y}var Ai;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ai||(Ai={}));function dh(){}function jS(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function IE(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const yr=Object.freeze({x:0,y:0});function HE(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function UE(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function KE(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),l=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=l-s,m=c-n;if(s<l&&n<c){const g=t.width*t.height,f=e.width*e.height,y=d*m,b=y/(g+f-y);return Number(b.toFixed(4))}return 0}const FE=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const l=[];for(const c of s){const{id:d}=c,m=n.get(d);if(m){const g=KE(m,t);g>0&&l.push({id:d,data:{droppableContainer:c,value:g}})}}return l.sort(HE)};function WE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function n1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:yr}function qE(e){return function(n){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];return l.reduce((d,m)=>({...d,top:d.top+e*m.y,bottom:d.bottom+e*m.y,left:d.left+e*m.x,right:d.right+e*m.x}),{...n})}}const $E=qE(1);function VE(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function YE(e,t,n){const s=VE(t);if(!s)return e;const{scaleX:l,scaleY:c,x:d,y:m}=s,g=e.left-d-(1-l)*parseFloat(n),f=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=l?e.width/l:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:f,right:g+y,bottom:f+b,left:g}}const XE={ignoreTransform:!1};function ru(e,t){t===void 0&&(t=XE);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:y}=Rn(e).getComputedStyle(e);f&&(n=YE(n,f,y))}const{top:s,left:l,width:c,height:d,bottom:m,right:g}=n;return{top:s,left:l,width:c,height:d,bottom:m,right:g}}function zS(e){return ru(e,{ignoreTransform:!0})}function GE(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ZE(e,t){return t===void 0&&(t=Rn(e).getComputedStyle(e)),t.position==="fixed"}function QE(e,t){t===void 0&&(t=Rn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=t[l];return typeof c=="string"?n.test(c):!1})}function Tv(e,t){const n=[];function s(l){if(t!=null&&n.length>=t||!l)return n;if(kv(l)&&l.scrollingElement!=null&&!n.includes(l.scrollingElement))return n.push(l.scrollingElement),n;if(!iu(l)||Jw(l)||n.includes(l))return n;const c=Rn(e).getComputedStyle(l);return l!==e&&QE(l,c)&&n.push(l),ZE(l,c)?n:s(l.parentNode)}return e?s(e):n}function r1(e){const[t]=Tv(e,1);return t??null}function nm(e){return!Ah||!e?null:uo(e)?e:xv(e)?kv(e)||e===ho(e).scrollingElement?window:iu(e)?e:null:null}function s1(e){return uo(e)?e.scrollX:e.scrollLeft}function a1(e){return uo(e)?e.scrollY:e.scrollTop}function Um(e){return{x:s1(e),y:a1(e)}}var Fi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Fi||(Fi={}));function l1(e){return!Ah||!e?!1:e===document.scrollingElement}function o1(e){const t={x:0,y:0},n=l1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},l=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=s.y,m=e.scrollLeft>=s.x;return{isTop:l,isLeft:c,isBottom:d,isRight:m,maxScroll:s,minScroll:t}}const JE={x:.2,y:.2};function eT(e,t,n,s,l){let{top:c,left:d,right:m,bottom:g}=n;s===void 0&&(s=10),l===void 0&&(l=JE);const{isTop:f,isBottom:y,isLeft:b,isRight:C}=o1(e),w={x:0,y:0},x={x:0,y:0},D={height:t.height*l.y,width:t.width*l.x};return!f&&c<=t.top+D.height?(w.y=Fi.Backward,x.y=s*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(w.y=Fi.Forward,x.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!C&&m>=t.right-D.width?(w.x=Fi.Forward,x.x=s*Math.abs((t.right-D.width-m)/D.width)):!b&&d<=t.left+D.width&&(w.x=Fi.Backward,x.x=s*Math.abs((t.left+D.width-d)/D.width)),{direction:w,speed:x}}function tT(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:s,bottom:l}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:l,width:e.clientWidth,height:e.clientHeight}}function c1(e){return e.reduce((t,n)=>to(t,Um(n)),yr)}function iT(e){return e.reduce((t,n)=>t+s1(n),0)}function nT(e){return e.reduce((t,n)=>t+a1(n),0)}function rT(e,t){if(t===void 0&&(t=ru),!e)return;const{top:n,left:s,bottom:l,right:c}=t(e);r1(e)&&(l<=0||c<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const sT=[["x",["left","right"],iT],["y",["top","bottom"],nT]];class Dv{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Tv(n),l=c1(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,m]of sT)for(const g of d)Object.defineProperty(this,g,{get:()=>{const f=m(s),y=l[c]-f;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Lc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var l;(l=this.target)==null||l.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function aT(e){const{EventTarget:t}=Rn(e);return e instanceof t?e:ho(e)}function rm(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var ar;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ar||(ar={}));function PS(e){e.preventDefault()}function lT(e){e.stopPropagation()}var Pt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Pt||(Pt={}));const u1={start:[Pt.Space,Pt.Enter],cancel:[Pt.Esc],end:[Pt.Space,Pt.Enter,Pt.Tab]},oT=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Pt.Right:return{...n,x:n.x+25};case Pt.Left:return{...n,x:n.x-25};case Pt.Down:return{...n,y:n.y+25};case Pt.Up:return{...n,y:n.y-25}}};class d1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Lc(ho(n)),this.windowListeners=new Lc(Rn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ar.Resize,this.handleCancel),this.windowListeners.add(ar.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ar.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&rT(s),n(yr)}handleKeyDown(t){if(t1(t)){const{active:n,context:s,options:l}=this.props,{keyboardCodes:c=u1,coordinateGetter:d=oT,scrollBehavior:m="smooth"}=l,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,y=f?{x:f.left,y:f.top}:yr;this.referenceCoordinates||(this.referenceCoordinates=y);const b=d(t,{active:n,context:s.current,currentCoordinates:y});if(b){const C=uh(b,y),w={x:0,y:0},{scrollableAncestors:x}=s.current;for(const D of x){const B=t.code,{isTop:L,isRight:O,isLeft:X,isBottom:U,maxScroll:G,minScroll:W}=o1(D),q=tT(D),ge={x:Math.min(B===Pt.Right?q.right-q.width/2:q.right,Math.max(B===Pt.Right?q.left:q.left+q.width/2,b.x)),y:Math.min(B===Pt.Down?q.bottom-q.height/2:q.bottom,Math.max(B===Pt.Down?q.top:q.top+q.height/2,b.y))},Se=B===Pt.Right&&!O||B===Pt.Left&&!X,xe=B===Pt.Down&&!U||B===Pt.Up&&!L;if(Se&&ge.x!==b.x){const re=D.scrollLeft+C.x,$=B===Pt.Right&&re<=G.x||B===Pt.Left&&re>=W.x;if($&&!C.y){D.scrollTo({left:re,behavior:m});return}$?w.x=D.scrollLeft-re:w.x=B===Pt.Right?D.scrollLeft-G.x:D.scrollLeft-W.x,w.x&&D.scrollBy({left:-w.x,behavior:m});break}else if(xe&&ge.y!==b.y){const re=D.scrollTop+C.y,$=B===Pt.Down&&re<=G.y||B===Pt.Up&&re>=W.y;if($&&!C.x){D.scrollTo({top:re,behavior:m});return}$?w.y=D.scrollTop-re:w.y=B===Pt.Down?D.scrollTop-G.y:D.scrollTop-W.y,w.y&&D.scrollBy({top:-w.y,behavior:m});break}}this.handleMove(t,to(uh(b,this.referenceCoordinates),w))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}d1.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=u1,onActivation:l}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(s.start.includes(d)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function IS(e){return!!(e&&"distance"in e)}function HS(e){return!!(e&&"delay"in e)}class Rv{constructor(t,n,s){var l;s===void 0&&(s=aT(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=ho(d),this.documentListeners=new Lc(this.document),this.listeners=new Lc(s),this.windowListeners=new Lc(Rn(d)),this.initialCoordinates=(l=Im(c))!=null?l:yr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ar.Resize,this.handleCancel),this.windowListeners.add(ar.DragStart,PS),this.windowListeners.add(ar.VisibilityChange,this.handleCancel),this.windowListeners.add(ar.ContextMenu,PS),this.documentListeners.add(ar.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(IS(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:s,onPending:l}=this.props;l(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ar.Click,lT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ar.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:l,props:c}=this,{onMove:d,options:{activationConstraint:m}}=c;if(!l)return;const g=(n=Im(t))!=null?n:yr,f=uh(l,g);if(!s&&m){if(IS(m)){if(m.tolerance!=null&&rm(f,m.tolerance))return this.handleCancel();if(rm(f,m.distance))return this.handleStart()}if(HS(m)&&rm(f,m.tolerance))return this.handleCancel();this.handlePending(m,f);return}t.cancelable&&t.preventDefault(),d(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Pt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const cT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class h1 extends Rv{constructor(t){const{event:n}=t,s=ho(n.target);super(t,cT,s)}}h1.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const uT={move:{name:"mousemove"},end:{name:"mouseup"}};var Km;(function(e){e[e.RightClick=2]="RightClick"})(Km||(Km={}));class f1 extends Rv{constructor(t){super(t,uT,ho(t.event.target))}}f1.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===Km.RightClick?!1:(s?.({event:n}),!0)}}];const sm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class p1 extends Rv{constructor(t){super(t,sm)}static setup(){return window.addEventListener(sm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(sm.move.name,t)};function t(){}}}p1.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:l}=n;return l.length>1?!1:(s?.({event:n}),!0)}}];var Bc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Bc||(Bc={}));var hh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(hh||(hh={}));function dT(e){let{acceleration:t,activator:n=Bc.Pointer,canScroll:s,draggingRect:l,enabled:c,interval:d=5,order:m=hh.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:y,delta:b,threshold:C}=e;const w=fT({delta:b,disabled:!c}),[x,D]=EE(),B=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),O=v.useMemo(()=>{switch(n){case Bc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Bc.DraggableRect:return l}},[n,l,g]),X=v.useRef(null),U=v.useCallback(()=>{const W=X.current;if(!W)return;const q=B.current.x*L.current.x,ge=B.current.y*L.current.y;W.scrollBy(q,ge)},[]),G=v.useMemo(()=>m===hh.TreeOrder?[...f].reverse():f,[m,f]);v.useEffect(()=>{if(!c||!f.length||!O){D();return}for(const W of G){if(s?.(W)===!1)continue;const q=f.indexOf(W),ge=y[q];if(!ge)continue;const{direction:Se,speed:xe}=eT(W,ge,O,t,C);for(const re of["x","y"])w[re][Se[re]]||(xe[re]=0,Se[re]=0);if(xe.x>0||xe.y>0){D(),X.current=W,x(U,d),B.current=xe,L.current=Se;return}}B.current={x:0,y:0},L.current={x:0,y:0},D()},[t,U,s,D,c,d,JSON.stringify(O),JSON.stringify(w),x,f,G,y,JSON.stringify(C)])}const hT={x:{[Fi.Backward]:!1,[Fi.Forward]:!1},y:{[Fi.Backward]:!1,[Fi.Forward]:!1}};function fT(e){let{delta:t,disabled:n}=e;const s=Pm(t);return nu(l=>{if(n||!s||!l)return hT;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Fi.Backward]:l.x[Fi.Backward]||c.x===-1,[Fi.Forward]:l.x[Fi.Forward]||c.x===1},y:{[Fi.Backward]:l.y[Fi.Backward]||c.y===-1,[Fi.Forward]:l.y[Fi.Forward]||c.y===1}}},[n,t,s])}function pT(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return nu(l=>{var c;return t==null?null:(c=s??l)!=null?c:null},[s,t])}function mT(e,t){return v.useMemo(()=>e.reduce((n,s)=>{const{sensor:l}=s,c=l.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,s)}));return[...n,...c]},[]),[e,t])}var Kc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Kc||(Kc={}));var Fm;(function(e){e.Optimized="optimized"})(Fm||(Fm={}));const US=new Map;function gT(e,t){let{dragging:n,dependencies:s,config:l}=t;const[c,d]=v.useState(null),{frequency:m,measure:g,strategy:f}=l,y=v.useRef(e),b=B(),C=Uc(b),w=v.useCallback(function(L){L===void 0&&(L=[]),!C.current&&d(O=>O===null?L:O.concat(L.filter(X=>!O.includes(X))))},[C]),x=v.useRef(null),D=nu(L=>{if(b&&!n)return US;if(!L||L===US||y.current!==e||c!=null){const O=new Map;for(let X of e){if(!X)continue;if(c&&c.length>0&&!c.includes(X.id)&&X.rect.current){O.set(X.id,X.rect.current);continue}const U=X.node.current,G=U?new Dv(g(U),U):null;X.rect.current=G,G&&O.set(X.id,G)}return O}return L},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||w()},[n,b]),v.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},m))},[m,b,w,...s]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function B(){switch(f){case Kc.Always:return!1;case Kc.BeforeDragging:return n;default:return!n}}}function m1(e,t){return nu(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function vT(e,t){return m1(e,t)}function _T(e){let{callback:t,disabled:n}=e;const s=Ev(t),l=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,n]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function Bh(e){let{callback:t,disabled:n}=e;const s=Ev(t),l=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[n]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function bT(e){return new Dv(ru(e),e)}function KS(e,t,n){t===void 0&&(t=bT);const[s,l]=v.useState(null);function c(){l(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??n)!=null?f:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const d=_T({callback(g){if(e)for(const f of g){const{type:y,target:b}=f;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Bh({callback:c});return ga(()=>{c(),e?(m?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),d?.disconnect())},[e]),s}function yT(e){const t=m1(e);return n1(e,t)}const FS=[];function ST(e){const t=v.useRef(e),n=nu(s=>e?s&&s!==FS&&e&&t.current&&e.parentNode===t.current.parentNode?s:Tv(e):FS,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function wT(e){const[t,n]=v.useState(null),s=v.useRef(e),l=v.useCallback(c=>{const d=nm(c.target);d&&n(m=>m?(m.set(d,Um(d)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){d(c);const m=e.map(g=>{const f=nm(g);return f?(f.addEventListener("scroll",l,{passive:!0}),[f,Um(f)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),s.current=e}return()=>{d(e),d(c)};function d(m){m.forEach(g=>{const f=nm(g);f?.removeEventListener("scroll",l)})}},[l,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>to(c,d),yr):c1(e):yr,[e,t])}function WS(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==yr;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?uh(e,n.current):yr}function CT(e){v.useEffect(()=>{if(!Ah)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function xT(e,t){return v.useMemo(()=>e.reduce((n,s)=>{let{eventName:l,handler:c}=s;return n[l]=d=>{c(d,t)},n},{}),[e,t])}function g1(e){return v.useMemo(()=>e?GE(e):null,[e])}const qS=[];function kT(e,t){t===void 0&&(t=ru);const[n]=e,s=g1(n?Rn(n):null),[l,c]=v.useState(qS);function d(){c(()=>e.length?e.map(g=>l1(g)?s:new Dv(t(g),g)):qS)}const m=Bh({callback:d});return ga(()=>{m?.disconnect(),d(),e.forEach(g=>m?.observe(g))},[e]),l}function ET(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return iu(t)?t:e}function TT(e){let{measure:t}=e;const[n,s]=v.useState(null),l=v.useCallback(f=>{for(const{target:y}of f)if(iu(y)){s(b=>{const C=t(y);return b?{...b,width:C.width,height:C.height}:C});break}},[t]),c=Bh({callback:l}),d=v.useCallback(f=>{const y=ET(f);c?.disconnect(),y&&c?.observe(y),s(y?t(y):null)},[t,c]),[m,g]=ch(d);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const DT=[{sensor:h1,options:{}},{sensor:d1,options:{}}],RT={current:{}},Yd={draggable:{measure:zS},droppable:{measure:zS,strategy:Kc.WhileDragging,frequency:Fm.Optimized},dragOverlay:{measure:ru}};class Oc extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const MT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Oc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:dh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yd,measureDroppableContainers:dh,windowRect:null,measuringScheduled:!1},NT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:dh,draggableNodes:new Map,over:null,measureDroppableContainers:dh},Oh=v.createContext(NT),AT=v.createContext(MT);function LT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Oc}}}function BT(e,t){switch(t.type){case Ai.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ai.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ai.DragEnd:case Ai.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ai.RegisterDroppable:{const{element:n}=t,{id:s}=n,l=new Oc(e.droppable.containers);return l.set(s,n),{...e,droppable:{...e.droppable,containers:l}}}case Ai.SetDroppableDisabled:{const{id:n,key:s,disabled:l}=t,c=e.droppable.containers.get(n);if(!c||s!==c.key)return e;const d=new Oc(e.droppable.containers);return d.set(n,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:d}}}case Ai.UnregisterDroppable:{const{id:n,key:s}=t,l=e.droppable.containers.get(n);if(!l||s!==l.key)return e;const c=new Oc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function OT(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:l}=v.useContext(Oh),c=Pm(s),d=Pm(n?.id);return v.useEffect(()=>{if(!t&&!s&&c&&d!=null){if(!t1(c)||document.activeElement===c.target)return;const m=l.get(d);if(!m)return;const{activatorNode:g,node:f}=m;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const y of[g.current,f.current]){if(!y)continue;const b=RE(y);if(b){b.focus();break}}})}},[s,t,l,d,c]),null}function jT(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...s}),n):n}function zT(e){return v.useMemo(()=>({draggable:{...Yd.draggable,...e?.draggable},droppable:{...Yd.droppable,...e?.droppable},dragOverlay:{...Yd.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function PT(e){let{activeNode:t,measure:n,initialRect:s,config:l=!0}=e;const c=v.useRef(!1),{x:d,y:m}=typeof l=="boolean"?{x:l,y:l}:l;ga(()=>{if(!d&&!m||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const y=n(f),b=n1(y,s);if(d||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const C=r1(f);C&&C.scrollBy({top:b.y,left:b.x})}},[t,d,m,s,n])}const v1=v.createContext({...yr,scaleX:1,scaleY:1});var oa;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(oa||(oa={}));const IT=v.memo(function(t){var n,s,l,c;let{id:d,accessibility:m,autoScroll:g=!0,children:f,sensors:y=DT,collisionDetection:b=FE,measuring:C,modifiers:w,...x}=t;const D=v.useReducer(BT,void 0,LT),[B,L]=D,[O,X]=OE(),[U,G]=v.useState(oa.Uninitialized),W=U===oa.Initialized,{draggable:{active:q,nodes:ge,translate:Se},droppable:{containers:xe}}=B,re=q!=null?ge.get(q):null,$=v.useRef({initial:null,translated:null}),J=v.useMemo(()=>{var et;return q!=null?{id:q,data:(et=re?.data)!=null?et:RT,rect:$}:null},[q,re]),K=v.useRef(null),[se,A]=v.useState(null),[R,z]=v.useState(null),ne=Uc(x,Object.values(x)),_e=Lh("DndDescribedBy",d),M=v.useMemo(()=>xe.getEnabled(),[xe]),F=zT(C),{droppableRects:ie,measureDroppableContainers:ve,measuringScheduled:be}=gT(M,{dragging:W,dependencies:[Se.x,Se.y],config:F.droppable}),Ee=pT(ge,q),Me=v.useMemo(()=>R?Im(R):null,[R]),Re=st(),Pe=vT(Ee,F.draggable.measure);PT({activeNode:q!=null?ge.get(q):null,config:Re.layoutShiftCompensation,initialRect:Pe,measure:F.draggable.measure});const Be=KS(Ee,F.draggable.measure,Pe),oe=KS(Ee?Ee.parentElement:null),he=v.useRef({activatorEvent:null,active:null,activeNode:Ee,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:ge,draggingNode:null,draggingNodeRect:null,droppableContainers:xe,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ye=xe.getNodeFor((n=he.current.over)==null?void 0:n.id),Oe=TT({measure:F.dragOverlay.measure}),Ke=(s=Oe.nodeRef.current)!=null?s:Ee,je=W?(l=Oe.rect)!=null?l:Be:null,ae=!!(Oe.nodeRef.current&&Oe.rect),Te=yT(ae?null:Be),we=g1(Ke?Rn(Ke):null),ze=ST(W?ye??Ee:null),Ue=kT(ze),nt=jT(w,{transform:{x:Se.x-Te.x,y:Se.y-Te.y,scaleX:1,scaleY:1},activatorEvent:R,active:J,activeNodeRect:Be,containerNodeRect:oe,draggingNodeRect:je,over:he.current.over,overlayNodeRect:Oe.rect,scrollableAncestors:ze,scrollableAncestorRects:Ue,windowRect:we}),ht=Me?to(Me,Se):null,Dt=wT(ze),Ei=WS(Dt),ni=WS(Dt,[Be]),di=to(nt,Ei),le=je?$E(je,nt):null,Ne=J&&le?b({active:J,collisionRect:le,droppableRects:ie,droppableContainers:M,pointerCoordinates:ht}):null,Qe=UE(Ne,"id"),[it,jt]=v.useState(null),xt=ae?nt:to(nt,ni),gt=WE(xt,(c=it?.rect)!=null?c:null,Be),Ht=v.useRef(null),kt=v.useCallback((et,wt)=>{let{sensor:Et,options:Ut}=wt;if(K.current==null)return;const ri=ge.get(K.current);if(!ri)return;const Gt=et.nativeEvent,Zt=new Et({active:K.current,activeNode:ri,event:Gt,options:Ut,context:he,onAbort(Qt){if(!ge.get(Qt))return;const{onDragAbort:hi}=ne.current,zi={id:Qt};hi?.(zi),O({type:"onDragAbort",event:zi})},onPending(Qt,ji,hi,zi){if(!ge.get(Qt))return;const{onDragPending:Yi}=ne.current,Ti={id:Qt,constraint:ji,initialCoordinates:hi,offset:zi};Yi?.(Ti),O({type:"onDragPending",event:Ti})},onStart(Qt){const ji=K.current;if(ji==null)return;const hi=ge.get(ji);if(!hi)return;const{onDragStart:zi}=ne.current,gn={activatorEvent:Gt,active:{id:ji,data:hi.data,rect:$}};wc.unstable_batchedUpdates(()=>{zi?.(gn),G(oa.Initializing),L({type:Ai.DragStart,initialCoordinates:Qt,active:ji}),O({type:"onDragStart",event:gn}),A(Ht.current),z(Gt)})},onMove(Qt){L({type:Ai.DragMove,coordinates:Qt})},onEnd:Kt(Ai.DragEnd),onCancel:Kt(Ai.DragCancel)});Ht.current=Zt;function Kt(Qt){return async function(){const{active:hi,collisions:zi,over:gn,scrollAdjustedTranslate:Yi}=he.current;let Ti=null;if(hi&&Yi){const{cancelDrop:ln}=ne.current;Ti={activatorEvent:Gt,active:hi,collisions:zi,delta:Yi,over:gn},Qt===Ai.DragEnd&&typeof ln=="function"&&await Promise.resolve(ln(Ti))&&(Qt=Ai.DragCancel)}K.current=null,wc.unstable_batchedUpdates(()=>{L({type:Qt}),G(oa.Uninitialized),jt(null),A(null),z(null),Ht.current=null;const ln=Qt===Ai.DragEnd?"onDragEnd":"onDragCancel";if(Ti){const Di=ne.current[ln];Di?.(Ti),O({type:ln,event:Ti})}})}}},[ge]),Mn=v.useCallback((et,wt)=>(Et,Ut)=>{const ri=Et.nativeEvent,Gt=ge.get(Ut);if(K.current!==null||!Gt||ri.dndKit||ri.defaultPrevented)return;const Zt={active:Gt};et(Et,wt.options,Zt)===!0&&(ri.dndKit={capturedBy:wt.sensor},K.current=Ut,kt(Et,wt))},[ge,kt]),Nn=mT(y,Mn);CT(y),ga(()=>{Be&&U===oa.Initializing&&G(oa.Initialized)},[Be,U]),v.useEffect(()=>{const{onDragMove:et}=ne.current,{active:wt,activatorEvent:Et,collisions:Ut,over:ri}=he.current;if(!wt||!Et)return;const Gt={active:wt,activatorEvent:Et,collisions:Ut,delta:{x:di.x,y:di.y},over:ri};wc.unstable_batchedUpdates(()=>{et?.(Gt),O({type:"onDragMove",event:Gt})})},[di.x,di.y]),v.useEffect(()=>{const{active:et,activatorEvent:wt,collisions:Et,droppableContainers:Ut,scrollAdjustedTranslate:ri}=he.current;if(!et||K.current==null||!wt||!ri)return;const{onDragOver:Gt}=ne.current,Zt=Ut.get(Qe),Kt=Zt&&Zt.rect.current?{id:Zt.id,rect:Zt.rect.current,data:Zt.data,disabled:Zt.disabled}:null,Qt={active:et,activatorEvent:wt,collisions:Et,delta:{x:ri.x,y:ri.y},over:Kt};wc.unstable_batchedUpdates(()=>{jt(Kt),Gt?.(Qt),O({type:"onDragOver",event:Qt})})},[Qe]),ga(()=>{he.current={activatorEvent:R,active:J,activeNode:Ee,collisionRect:le,collisions:Ne,droppableRects:ie,draggableNodes:ge,draggingNode:Ke,draggingNodeRect:je,droppableContainers:xe,over:it,scrollableAncestors:ze,scrollAdjustedTranslate:di},$.current={initial:je,translated:le}},[J,Ee,Ne,le,ge,Ke,je,ie,xe,it,ze,di]),dT({...Re,delta:Se,draggingRect:le,pointerCoordinates:ht,scrollableAncestors:ze,scrollableAncestorRects:Ue});const Z=v.useMemo(()=>({active:J,activeNode:Ee,activeNodeRect:Be,activatorEvent:R,collisions:Ne,containerNodeRect:oe,dragOverlay:Oe,draggableNodes:ge,droppableContainers:xe,droppableRects:ie,over:it,measureDroppableContainers:ve,scrollableAncestors:ze,scrollableAncestorRects:Ue,measuringConfiguration:F,measuringScheduled:be,windowRect:we}),[J,Ee,Be,R,Ne,oe,Oe,ge,xe,ie,it,ve,ze,Ue,F,be,we]),We=v.useMemo(()=>({activatorEvent:R,activators:Nn,active:J,activeNodeRect:Be,ariaDescribedById:{draggable:_e},dispatch:L,draggableNodes:ge,over:it,measureDroppableContainers:ve}),[R,Nn,J,Be,L,_e,ge,it,ve]);return Li.createElement(i1.Provider,{value:X},Li.createElement(Oh.Provider,{value:We},Li.createElement(AT.Provider,{value:Z},Li.createElement(v1.Provider,{value:gt},f)),Li.createElement(OT,{disabled:m?.restoreFocus===!1})),Li.createElement(PE,{...m,hiddenTextDescribedById:_e}));function st(){const et=se?.autoScrollEnabled===!1,wt=typeof g=="object"?g.enabled===!1:g===!1,Et=W&&!et&&!wt;return typeof g=="object"?{...g,enabled:Et}:{enabled:Et}}}),HT=v.createContext(null),$S="button",UT="Draggable";function _1(e){let{id:t,data:n,disabled:s=!1,attributes:l}=e;const c=Lh(UT),{activators:d,activatorEvent:m,active:g,activeNodeRect:f,ariaDescribedById:y,draggableNodes:b,over:C}=v.useContext(Oh),{role:w=$S,roleDescription:x="draggable",tabIndex:D=0}=l??{},B=g?.id===t,L=v.useContext(B?v1:HT),[O,X]=ch(),[U,G]=ch(),W=xT(d,t),q=Uc(n);ga(()=>(b.set(t,{id:t,key:c,node:O,activatorNode:U,data:q}),()=>{const Se=b.get(t);Se&&Se.key===c&&b.delete(t)}),[b,t]);const ge=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":s,"aria-pressed":B&&w===$S?!0:void 0,"aria-roledescription":x,"aria-describedby":y.draggable}),[s,w,D,B,x,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:f,attributes:ge,isDragging:B,listeners:s?void 0:W,node:O,over:C,setNodeRef:X,setActivatorNodeRef:G,transform:L}}const KT="Droppable",FT={timeout:25};function Mv(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:l}=e;const c=Lh(KT),{active:d,dispatch:m,over:g,measureDroppableContainers:f}=v.useContext(Oh),y=v.useRef({disabled:n}),b=v.useRef(!1),C=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:B}={...FT,...l},L=Uc(D??s),O=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(L.current)?L.current:[L.current]),w.current=null},B)},[B]),X=Bh({callback:O,disabled:x||!d}),U=v.useCallback((ge,Se)=>{X&&(Se&&(X.unobserve(Se),b.current=!1),ge&&X.observe(ge))},[X]),[G,W]=ch(U),q=Uc(t);return v.useEffect(()=>{!X||!G.current||(X.disconnect(),b.current=!1,X.observe(G.current))},[G,X]),v.useEffect(()=>(m({type:Ai.RegisterDroppable,element:{id:s,key:c,disabled:n,node:G,rect:C,data:q}}),()=>m({type:Ai.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:Ai.SetDroppableDisabled,id:s,key:c,disabled:n}),y.current.disabled=n)},[s,c,n,m]),{active:d,rect:C,isOver:g?.id===s,node:G,over:g,setNodeRef:W}}const WT=128,qT=512,fo=100,$T="too_many_detached_terminals",VT=64,YT=4096;function b1(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>WT)return null;const n=t.workspaces.map(XT);return n.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function y1(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const s=n.detachedTerminalIds;return Array.isArray(s)&&s.length>fo}):!1}function XT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>qT)return null;const n=t.tabs.map(GT);if(n.some(l=>l===null))return null;const s=e2(t.detachedTerminalIds,fo);return s===null?null:{id:t.id,title:t.title,defaultCwd:JT(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function GT(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=ZT(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function ZT(e){if(!e||typeof e!="object")return null;let t=0;return Wm(e,1,()=>(t+=1,t<=YT))}function Wm(e,t,n){if(!e||typeof e!="object"||t>VT||!n())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const l=Wm(s.first,t+1,n),c=Wm(s.second,t+1,n);return!l||!c?null:{type:"split",direction:s.direction,ratio:QT(s.ratio),first:l,second:c}}function QT(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function JT(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function e2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,s=[];for(const l of e)typeof l!="string"||!l||n.has(l)||(n.add(l),s.push(l));return s}const S1=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],t2="nterminal-focus",i2=/^[A-Za-z0-9_.:-]{1,128}$/;function n2(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(t2)!=="terminal"?null:jh({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function jh(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!VS(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!VS(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function VS(e){return typeof e=="string"&&i2.test(e)}const Dn="__main__",w1="nterminal.clientDiagnostics.v1",C1=150,r2=24,s2=160;let YS=!1,hc=null;function a2(){YS||typeof window>"u"||(YS=!0,fn("page.load",{navigation:g2(),visibility:document.visibilityState,online:navigator.onLine,viewport:E1(),standalone:m2()}),document.addEventListener("visibilitychange",()=>{fn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{fn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{fn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>fn("network.online")),window.addEventListener("offline",()=>fn("network.offline")),window.addEventListener("focus",()=>fn("window.focus")),window.addEventListener("blur",()=>fn("window.blur")),window.addEventListener("error",e=>{fn("runtime.error",{message:e.message,source:v2(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{fn("runtime.unhandledrejection",{reason:_2(e.reason)})}))}function fn(e,t={}){const n={at:new Date().toISOString(),event:zh(e,80),data:k1({...t,visibility:t.visibility??f2(),online:t.online??p2(),viewport:t.viewport??E1()})},s=x1();return s.push(n),l2(s.slice(-C1)),n}function x1(){try{const e=window.localStorage.getItem(w1);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(o2).filter(n=>n!==null).slice(-C1):[]}catch{return[]}}async function Nv(e,t=fetch){if(hc)return hc;const n=x1(),s={reason:zh(e,80),events:n},l=JSON.stringify(s);hc=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:l.length<48e3,body:l});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await hc}finally{hc=null}}function l2(e){try{window.localStorage.setItem(w1,JSON.stringify(e))}catch{}}function o2(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:zh(t.event,80),...t.data&&typeof t.data=="object"?{data:k1(t.data)}:{}}}function k1(e){const t={};for(const[n,s]of Object.entries(e).slice(0,r2)){const l=zh(n,64);if(!l||c2(l))continue;const c=u2(s);c!==void 0&&(t[l]=c)}return t}function c2(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function u2(e){if(typeof e=="string")return d2(e,s2);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function zh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function d2(e,t){return h2(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function h2(e){return e.replace(/https?:\/\/[^\s"'<>]+/gi,"[url]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[redacted]").replace(/\b((?:auth|authorization|cookie|password|secret|session|sessionid|session_id|token)[a-z0-9_.:-]*\s*[:=]\s*)[^\s&,;]+/gi,"$1[redacted]").replace(/\b(nterminal_session|nterminal_device)\s*=\s*[^\s;,]+/gi,"$1=[redacted]").replace(/\b[A-Za-z0-9+/_=-]{48,}\b/g,"[redacted]")}function f2(){return typeof document>"u"?void 0:document.visibilityState}function p2(){return typeof navigator>"u"?void 0:navigator.onLine}function E1(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function m2(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function g2(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function v2(e){if(!e)return null;try{const t=new URL(e);return t.pathname.split("/").pop()||t.pathname}catch{return e.split("/").pop()??e}}function _2(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const T1="nterminal.notifications.completionEnabled",Av="nterminal.notifications.completionToastEnabled",Lv="nterminal.notifications.completionToastDurationSeconds",Bv="nterminal.notifications.completionToastPersistent",qm="nterminal:completion-toast-display",$m="nterminal:notification-focus",jc=6.5,Vm=2,Ym=60;function Ph(){return typeof window<"u"&&"Notification"in window}function Ov(){try{return window.localStorage.getItem(T1)==="true"}catch{return!1}}function XS(e){try{window.localStorage.setItem(T1,e?"true":"false")}catch{}}function rl(){return{enabled:w2(),durationSeconds:S2(),persistUntilDismissed:C2()}}function b2(e){if(typeof window<"u"){try{window.localStorage.setItem(Av,e?"true":"false")}catch{}jv()}return rl()}function GS(e){const t=R1(e);if(typeof window<"u"){try{window.localStorage.setItem(Lv,String(t))}catch{}jv()}return rl()}function y2(e){if(typeof window<"u"){try{window.localStorage.setItem(Bv,e?"true":"false")}catch{}jv()}return rl()}function D1(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Av||n.key===Lv||n.key===Bv)&&e()};return window.addEventListener(qm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qm,e),window.removeEventListener("storage",t)}}function po(){return Ph()?window.Notification.permission:"unsupported"}function S2(){if(typeof window>"u")return jc;try{const e=window.localStorage.getItem(Lv);return e===null?jc:R1(Number(e))}catch{return jc}}function w2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Av)!=="false"}catch{return!0}}function C2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Bv)==="true"}catch{return!1}}function R1(e){if(!Number.isFinite(e))return jc;const t=Math.round(e*2)/2;return Math.max(Vm,Math.min(Ym,t))}function jv(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(qm))}async function M1(){if(!Ph())return"unsupported";try{return await window.Notification.requestPermission()}catch{return po()}}function x2(e){if(!Ph()||po()!=="granted"||!Ov()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,s=jh({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const l=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:s?{focus:s}:void 0,silent:!0});s&&(l.onclick=()=>{window.focus(),k2(s)})}catch{}}function k2(e){typeof window>"u"||window.dispatchEvent(new CustomEvent($m,{detail:e}))}const ZS="nterminal.push.clientId",E2=2e4,QS=[5e3,3e4,12e4];function ms(){try{const e=window.localStorage.getItem(ZS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Gm()}`;return window.localStorage.setItem(ZS,t),t}catch{return`client-${Gm()}`}}function T2(){return`page-${Gm()}`}function Ih(){const e=typeof window<"u"&&window.isSecureContext===!0,t=B2(),n=O2(),s=n==="mobile"||n==="tablet",l=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&s;return{supported:l,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":s?l?"supported":"unsupported":"not_mobile":"insecure"}}async function D2(e,t){const n=Ih();if(!n.supported)throw new Error(n.reason);if((po()==="granted"?"granted":await M1())!=="granted")throw new Error("permission_denied");const l=ms(),c=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(l),g=await z2(c,d.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L1(d.publicKey)});await e.subscribePushNotifications({clientId:l,subscription:A1(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:N1(n.deviceKind),alwaysNotify:t})}async function R2(e){const t=Ih();if(!t.supported||po()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),s=await n?.pushManager.getSubscription();if(!n||!s)return!1;const l=ms(),c=await P2(s.endpoint),d=await e.getPushNotificationStatus(l,c);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&Xm(s,d.vapidPublicKey))return!1;const m=await e.preparePushNotifications(l),g=d.endpointRegistered===!0&&Xm(s,m.publicKey);g||await s.unsubscribe();const f=g?s:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L1(m.publicKey)});return await e.subscribePushNotifications({clientId:l,subscription:A1(f),deviceKind:t.deviceKind,displayMode:t.displayMode,label:N1(t.deviceKind),alwaysNotify:!1}),!0}function M2(e){let t=!1,n=!1,s=0,l=null;const c=()=>{l!==null&&(window.clearTimeout(l),l=null)},d=y=>{t||n||(n=!0,R2(e).then(b=>{s=0,b&&fn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(fn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&s<QS.length){const C=QS[s++];l=window.setTimeout(()=>{l=null,d("retry")},C)}}).finally(()=>{n=!1}))},m=y=>{c(),s=0,d(y)},g=()=>m("online"),f=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",f),d("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",f)}}async function N2(e){const t=ms();let n;try{const l=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=l?.endpoint,await l?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function A2(e,t){await e.updatePushNotificationDevice({clientId:ms(),alwaysNotify:t})}function L2(e){if(typeof window>"u")return()=>{};const t=ms(),n=T2();let s=null,l=!1;const c=(f=!0)=>{const y=Ih();e.updatePushPresence({clientId:t,pageId:n,visibilityState:j2(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:Ov()&&po()==="granted",active:f}).catch(()=>{})},d=()=>{l||s!==null||(s=window.setInterval(()=>c(!0),E2))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),d(),()=>{l=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function B2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function O2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function N1(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function j2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function A1(e){const t=e.toJSON(),n=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!n||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:s}}}async function z2(e,t){const n=await e.pushManager.getSubscription();return n?Xm(n,t)?n:(await n.unsubscribe(),null):null}function Xm(e,t){const n=e.options.applicationServerKey;return n?B1(n)===t:!0}async function P2(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return B1(t)}function L1(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(n),l=new ArrayBuffer(s.length),c=new Uint8Array(l);for(let d=0;d<s.length;d+=1)c[d]=s.charCodeAt(d);return l}function B1(e){const t=new Uint8Array(e);let n="";for(const s of t)n+=String.fromCharCode(s);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Gm(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function ps(e,t){const n=[Dn,...t.map(d=>d.id)],s=new Set(n),l=new Set,c=[];for(const d of e??[])!s.has(d)||l.has(d)||(l.add(d),c.push(d));for(const d of n)l.has(d)||c.push(d);return c}function I2(e,t){return ps(e,t).map(n=>n===Dn?null:n)}function H2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function U2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const JS="Local",K2=3e4,F2=2,W2=6,O1="nterminal.serverList.viewMode.v1";function q2(){try{return window.localStorage.getItem(O1)==="list"?"list":"stats"}catch{return"stats"}}function $2(e){try{window.localStorage.setItem(O1,e)}catch{}}function V2(e,t){const n=new Map(e.map(s=>[s.id,s]));return ps(t,e).flatMap(s=>{if(s===Dn)return[{kind:"main",id:Dn}];const l=n.get(s);return l?[{kind:"agent",id:s,agent:l}]:[]})}function e0(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function j1(e){return e===void 0?"":e==="error"?"offline":[`CPU ${cr(e.cpuPercent)} ${zv(e)}`,`MEM ${cr(e.memoryPercent)} ${vs(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${cr(e.diskPercent)} ${vs(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${cr(e.swapPercent)} ${vs(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function Y2(e){if(!(e===void 0||e==="error"))return[`CPU ${cr(e.cpuPercent)} (${zv(e)})`,`RAM ${cr(e.memoryPercent)} (${vs(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${cr(e.diskPercent)} (${vs(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${cr(e.swapPercent)} (${vs(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function X2(e,t){const n=j1(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function cr(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function zv(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Zm(e.cpuPercent/100*t)}/${t} cores`}function vs(e,t){return!t0(e)||!t0(t)?"–/–":G2(e,t)}function G2(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Zm(e/s)}/${Zm(t/s)} ${n}`}function Zm(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function t0(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Ad(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function Z2(e){return[{label:"CPU",percent:cr(e.cpuPercent),detail:zv(e),tone:Ad(e.cpuPercent)},{label:"MEM",percent:cr(e.memoryPercent),detail:vs(e.memoryUsedBytes,e.memoryTotalBytes),tone:Ad(e.memoryPercent)},{label:"DISK",percent:cr(e.diskPercent),detail:vs(e.diskUsedBytes,e.diskTotalBytes),tone:Ad(e.diskPercent)},{label:"SWAP",percent:cr(e.swapPercent),detail:vs(e.swapUsedBytes,e.swapTotalBytes),tone:Ad(e.swapPercent)}]}function Q2({entry:e}){return e==="error"?p.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?p.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t}),p.jsx("span",{className:"server-list-stat-value",children:"–"})]}),p.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):p.jsx("span",{className:"server-list-stats server-list-stats-grid",title:Y2(e),children:Z2(e).map(t=>p.jsxs("span",{className:"server-list-stat-cell",children:[p.jsxs("span",{className:"server-list-stat-head",children:[p.jsx("span",{className:"server-list-stat-label",children:t.label}),p.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),p.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function i0({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:l=0,onServerLabelsChange:c,renderServerChildren:d,compact:m=!1}){const[g,f]=v.useState([]),[y,b]=v.useState([Dn]),[C,w]=v.useState(null),[x,D]=v.useState(null),[B,L]=v.useState(""),O=v.useRef(null),[X,U]=v.useState(()=>q2()),[G,W]=v.useState(null),[q,ge]=v.useState(null),[Se,xe]=v.useState({}),re=v.useRef({}),$=v.useRef(0),J=v.useRef([]),K=v.useRef([Dn]),se=v.useRef(null);v.useEffect(()=>{J.current=g},[g]),v.useEffect(()=>{const oe=ps(y,g);K.current=oe,e0(oe,y)||b(oe)},[g,y]),v.useEffect(()=>{let oe=!1;return e.listAgents().then(he=>{oe||(f(he.agents),b(ps(he.serverOrder,he.agents)))}).catch(()=>{}),e.getMainInfo().then(he=>{oe||w(he.name)}).catch(()=>{}),()=>{oe=!0}},[e,l]),v.useEffect(()=>{x&&(O.current?.focus(),O.current?.select())},[x]),v.useEffect(()=>{let oe=!1;function he(){const Oe=[{key:"__main__",load:()=>e.getMainStats()},...g.map(je=>({key:je.id,load:()=>e.getAgentStats(je.id)}))],Ke=new Set(Oe.map(je=>je.key));for(const je of Object.keys(re.current))Ke.has(je)||delete re.current[je];xe(je=>{const ae={};for(const Te of Ke)Te in je&&(ae[Te]=je[Te]);return ae});for(const je of Oe)je.load().then(ae=>{oe||(re.current[je.key]=0,xe(Te=>Ke.has(je.key)?{...Te,[je.key]:ae}:Te))}).catch(ae=>{if(oe)return;if(ae instanceof or&&ae.status===401&&je.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const Te=(re.current[je.key]??0)+1;re.current[je.key]=Te,Te>=F2&&xe(we=>Ke.has(je.key)?{...we,[je.key]:"error"}:we)})}he();const ye=window.setInterval(he,K2);return()=>{oe=!0,window.clearInterval(ye)}},[e,g,s]);function A(oe){oe==="main"?(L(C??""),D({kind:"main"})):(L(oe.name),D({kind:"agent",id:oe.id}))}async function R(){if(!x)return;const oe=B.trim(),he=x;if(D(null),he.kind==="main"){const ye=oe||"";try{const Oe=await e.renameMain(ye);w(Oe.name)}catch{}}else{if(!oe)return;const ye=g.find(Oe=>Oe.id===he.id)?.name;f(Oe=>Oe.map(Ke=>Ke.id===he.id?{...Ke,name:oe}:Ke));try{await e.renameAgent(he.id,oe)}catch{ye!==void 0&&f(Oe=>Oe.map(Ke=>Ke.id===he.id?{...Ke,name:ye}:Ke))}}}function z(){D(null)}function ne(oe){U(oe),$2(oe)}function _e(oe,he,ye){if(oe===he)return;const Oe=ps(K.current,J.current),Ke=Oe.findIndex(nt=>nt===oe),je=Oe.findIndex(nt=>nt===he);if(Ke<0||je<0)return;const ae=[...Oe],[Te]=ae.splice(Ke,1);if(!Te)return;const we=ae.findIndex(nt=>nt===he);if(we<0)return;const ze=ye==="before"?we:we+1;if(ae.splice(ze,0,Te),e0(ae,Oe))return;const Ue=$.current+1;$.current=Ue,K.current=ae,b(ae),e.reorderAgents(ae).then(nt=>{if($.current===Ue){J.current=nt.agents;const ht=ps(nt.serverOrder,nt.agents);K.current=ht,f(nt.agents),b(ht)}}).catch(async()=>{if($.current===Ue)try{const nt=await e.listAgents();if($.current===Ue){J.current=nt.agents;const ht=ps(nt.serverOrder,nt.agents);K.current=ht,f(nt.agents),b(ht)}}catch{$.current===Ue&&(K.current=Oe,b(Oe))}})}function M(oe,he){const ye=ps(K.current,J.current),Oe=ye.findIndex(je=>je===oe),Ke=ye[Oe+he];Oe<0||!Ke||_e(oe,Ke,he<0?"before":"after")}function F(oe,he){he.pointerType==="mouse"&&he.button!==0||(he.stopPropagation(),se.current={sourceId:oe,pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,active:!1,targetId:null,placement:"after"},he.currentTarget.setPointerCapture?.(he.pointerId))}function ie(oe){const he=se.current;if(!he||he.pointerId!==oe.pointerId)return;const ye=Math.hypot(oe.clientX-he.startX,oe.clientY-he.startY);if(!he.active){if(ye<W2)return;he.active=!0,W(he.sourceId)}const Ke=document.elementFromPoint(oe.clientX,oe.clientY)?.closest("[data-server-id]"),je=Ke?.dataset.serverId??null;if(!Ke||!je||je===he.sourceId){he.targetId=null,ge(null);return}const ae=Ke.getBoundingClientRect(),Te=oe.clientY<ae.top+ae.height/2?"before":"after";he.targetId=je,he.placement=Te,ge({serverId:je,placement:Te})}function ve(oe){const he=se.current;!he||he.pointerId!==oe.pointerId||(oe.stopPropagation(),oe.currentTarget.releasePointerCapture?.(oe.pointerId),se.current=null,W(null),ge(null),he.active&&he.targetId&&_e(he.sourceId,he.targetId,he.placement))}function be(oe){const he=se.current;he&&he.pointerId===oe.pointerId&&oe.currentTarget.releasePointerCapture?.(oe.pointerId),se.current=null,W(null),ge(null)}const Ee=C?.trim()||JS,Me=x?.kind==="main",Re=X==="stats",Pe=V2(g,y),Be=Pe.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:Ee},...g.map(oe=>({agentId:oe.id,label:oe.name}))])},[g,Ee,c]),m?p.jsx("div",{className:"server-list server-list--compact",children:Pe.map(oe=>{const he=oe.kind==="main",ye=he?Ee:oe.agent.name,Oe=he?Dn:oe.id,Ke=Se[Oe],je=j1(Ke);return p.jsxs("button",{type:"button",className:`server-list-chip${(he?t===null:t===oe.id)?" server-list-chip--active":""}`,onClick:()=>n(he?null:oe.id),"aria-label":ye,title:`${ye}${je?` — ${je}`:""}`,children:[p.jsx("span",{className:"server-list-chip-initial",children:U2(ye)}),p.jsx("span",{className:"server-list-chip-pip","data-status":H2(Ke)})]},oe.id)})}):p.jsxs("div",{className:`server-list server-list--${X}`,children:[p.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":X==="list",onClick:()=>ne("list"),title:"Show server names only",children:"List"}),p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":X==="stats",onClick:()=>ne("stats"),title:"Show resource usage",children:"Stats"})]}),Pe.map(oe=>{const he=oe.kind==="main",ye=he?Ee:oe.agent.name,Oe=he?Dn:oe.id,Ke=he?t===null:t===oe.id,je=he?Me:x?.kind==="agent"&&x.id===oe.id,ae=d?.({agentId:he?null:oe.id,serverId:oe.id,label:ye,active:Ke}),Te=q?.serverId===oe.id&&G!==oe.id?` server-list-section--drop-target server-list-section--drop-${q.placement}`:"";return p.jsxs("section",{className:`server-list-section${Te}`,"aria-label":`${ye} server`,children:[p.jsx("div",{className:["server-list-row",G===oe.id?"server-list-row--dragging":"",q?.serverId===oe.id&&G!==oe.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":oe.id,children:je?p.jsxs(p.Fragment,{children:[Be?p.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,p.jsx("form",{className:"server-list-editor",onSubmit:we=>{we.preventDefault(),R()},children:p.jsx("input",{ref:O,"aria-label":he?"Rename main server":`Rename ${ye}`,value:B,onChange:we=>L(we.target.value),onBlur:()=>{R()},onKeyDown:we=>{we.key==="Escape"&&(we.preventDefault(),z())},placeholder:he?JS:void 0})})]}):p.jsxs(p.Fragment,{children:[Be?p.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":oe.id,title:"Drag to reorder","aria-label":`Reorder ${ye}`,"aria-grabbed":G===oe.id,onPointerDown:we=>F(oe.id,we),onPointerMove:ie,onPointerUp:ve,onPointerCancel:be,onKeyDown:we=>{(we.key==="ArrowUp"||we.key==="ArrowDown")&&(we.preventDefault(),we.stopPropagation(),M(oe.id,we.key==="ArrowUp"?-1:1))},onClick:we=>we.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:`server-list-item${Ke?" server-list-item--active":""}`,onClick:()=>n(he?null:oe.id),onDoubleClick:we=>{we.preventDefault(),A(he?"main":{id:oe.id,name:ye})},title:X2(ye,Se[Oe]),children:[p.jsxs("span",{className:"server-list-item-header",children:[p.jsx("span",{className:"server-list-dot"}),p.jsx("span",{className:"server-list-name",title:he?void 0:oe.agent.url??"Outbound connection to main",children:ye})]}),Re?p.jsx(Q2,{entry:Se[Oe]}):null]})]})}),ae?p.jsx("div",{className:"server-list-children",children:ae}):null]},oe.id)})]})}function J2({api:e}){const[t,n]=v.useState([]),[s,l]=v.useState([]),[c,d]=v.useState(!1),[m,g]=v.useState(null),[f,y]=v.useState(""),[b,C]=v.useState("");async function w(){try{const[L,O,X]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(L.devices),l(O.networks),d(X.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(L){await e.revokeDevice(L),await w()}async function D(L){await e.removeNetwork(L),await w()}async function B(L){L.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:b.trim()}),y(""),C(""),await w()}catch(O){g(O instanceof Error?O.message:"Failed to add network")}}return p.jsxs(p.Fragment,{children:[m?p.jsx("p",{className:"form-error",children:m}):null,p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted devices"}),p.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?p.jsx("p",{className:"muted",children:"No trusted devices."}):p.jsx("ul",{className:"security-list",children:t.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsxs("span",{className:"security-item-label",children:[L.label,L.current?p.jsx("span",{className:"security-badge",children:"this device"}):null]}),p.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(L.id)},children:"revoke"})]},L.id))})]}),p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Trusted networks"}),p.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?p.jsx("p",{className:"muted",children:"No trusted networks."}):p.jsx("ul",{className:"security-list",children:s.map(L=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?p.jsx("span",{className:"security-item-meta",children:L.label}):null]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(L.id)},children:"remove"})]},L.id))}),p.jsxs("form",{className:"security-add-form",onSubmit:B,children:[p.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:L=>y(L.currentTarget.value),required:!0}),p.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:L=>C(L.currentTarget.value)}),p.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Two-factor authentication"}),p.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),p.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const eD=1500,Pv="nterminal.terminal.fontSize",Iv="nterminal.terminal.fontFamily",Qm="nterminal:terminal-font-size",Jm="nterminal:terminal-font-family",eg=11,tg=20,el=14,fh=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],so="meslo";ig(so);async function am(e=el,t=so){if(typeof document>"u"||!document.fonts)return;const n=I1(t).webFontFamilies;if(n.length===0)return;const s=Promise.all(n.map(l=>document.fonts.load(`${e}px ${l}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(l=>{globalThis.setTimeout(l,eD)})])}function z1(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return el;const n=Math.round(t);return Math.max(eg,Math.min(tg,n))}function P1(e){return fh.some(t=>t.id===e)?e:so}function ig(e){return I1(e).cssFamily}function I1(e){return fh.find(t=>t.id===e)??fh[0]}function ng(){if(typeof window>"u")return el;try{const e=window.localStorage.getItem(Pv);return e?z1(e):el}catch{return el}}function rg(){if(typeof window>"u")return so;try{return P1(window.localStorage.getItem(Iv))}catch{return so}}function Ld(e){const t=z1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Pv,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Qm,{detail:t})),t}function tD(e){const t=P1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Iv,t)}catch{}return window.dispatchEvent(new CustomEvent(Jm,{detail:t})),t}function H1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Pv&&e()};return window.addEventListener(Qm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qm,e),window.removeEventListener("storage",t)}}function U1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Iv&&e()};return window.addEventListener(Jm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Jm,e),window.removeEventListener("storage",t)}}const Hv="nterminal.terminal.showScrollProgress",sg="nterminal:terminal-scroll-progress",Uv="nterminal.terminal.tmuxScrollback.shell",Kv="nterminal.terminal.tmuxScrollback.agent",Fv="nterminal.terminal.tmuxScrollback.overrides",Fc="nterminal:terminal-tmux-scrollback",iD=200;function ag(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Hv)!=="false"}catch{return!0}}function nD(e){if(typeof window<"u"){try{window.localStorage.setItem(Hv,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(sg,{detail:e}))}return e}function K1(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Hv&&e()};return window.addEventListener(sg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(sg,e),window.removeEventListener("storage",t)}}function lg(){return F1(Uv,!0)}function rD(e){return W1(Uv,e,Fc)}function og(){return F1(Kv,!0)}function sD(e){return W1(Kv,e,Fc)}function Xd(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Uv||n.key===Kv||n.key===Fv)&&e()};return window.addEventListener(Fc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Fc,e),window.removeEventListener("storage",t)}}function lm(e){const n=q1()[e];return typeof n=="boolean"?n:null}function aD(e,t){if(typeof window<"u"){try{const n=q1(),s=Object.entries(n).filter(([c])=>c!==e);s.push([e,t]);const l=s.slice(-iD);window.localStorage.setItem(Fv,JSON.stringify(Object.fromEntries(l)))}catch{}window.dispatchEvent(new CustomEvent(Fc,{detail:{terminalId:e,enabled:t}}))}return t}function F1(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function W1(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function q1(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Fv);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,l]of Object.entries(t))typeof l=="boolean"&&(n[s]=l);return n}catch{return{}}}const Wv="nterminal.shortcuts.workspace.v1",cg="nterminal:workspace-shortcuts",Wc=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],Hh={"server.previous":xi("ArrowUp",{ctrlKey:!0}),"server.next":xi("ArrowDown",{ctrlKey:!0}),"tab.previous":xi("ArrowLeft",{ctrlKey:!0}),"tab.next":xi("ArrowRight",{ctrlKey:!0}),"tab.index":xi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":xi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":xi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":xi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":xi("KeyH",{altKey:!0}),"scrollback.toggle":xi("KeyS",{altKey:!0})},lD={"server.previous":xi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":xi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":xi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":xi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":xi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":xi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":xi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":xi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":xi("KeyH",{altKey:!0}),"scrollback.toggle":xi("KeyS",{altKey:!0})};function sl(){const e=Y1(Hh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Wv);if(!t)return e;const n=JSON.parse(t);for(const s of Wc){const l=n[s.id];if(mD(l)){const c=X1(l,s);pD(c,lD[s.id])||(e[s.id]=c)}}}catch{return e}return e}function n0(){return JSON.stringify(sl())}function oD(e,t){const n=sl(),s=Wc.find(l=>l.id===e);return s&&(n[e]=X1(t,s),qv(n)),n}function cD(e){const t=sl();return t[e]={...Hh[e]},qv(t),t}function uD(){const e=Y1(Hh);return qv(e),e}function ph(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Wv&&e()};return window.addEventListener(cg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(cg,e),window.removeEventListener("storage",t)}}function dD(e,t){const n=Q1(e);return!n||vD(n)||t.indexed&&Z1(e)===null||t.requiresPrimaryModifier&&!G1(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function $1(e){const t=sl();for(const n of Wc){const s=t[n.id];if(!(!s||!gD(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const l=Z1(e);if(l!==null)return{id:n.id,index:l};continue}if(Q1(e)===s.code)return{id:n.id,index:null}}}return null}function mh(e){return V1(sl()[e])}function V1(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(_D(e.code)),t.join("+")}const hD=()=>mh("split.right"),fD=()=>mh("split.down");function xi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Y1(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function pD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function qv(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Wv,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(cg))}}function X1(e,t){return t.requiresPrimaryModifier&&!G1(e)?{...Hh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function G1(e){return e.ctrlKey||e.altKey||e.metaKey}function mD(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function gD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Z1(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function Q1(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function vD(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function _D(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const bD="Automatic update needs write access to the global npm install. Run this from a normal NTerminal runtime-user shell; only the npm install step uses sudo.";function yD(e="nterminal",t=new Date){return{reason:"permission",message:bD,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function SD(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const J1=3600*1e3,wD="local",ug=new Set,fa=new Map;let va={checking:!1,hasUpdates:!1,lastCheckedAt:null},$v=null,zc=null,gh=0,la=null;function CD(e){return ug.add(e),()=>{ug.delete(e)}}function r0(){return va}function xD(e){const t=RD();$v=e,Vv(),dg(e,t);const n=()=>{if(document.visibilityState!=="visible"||!_a(e,t))return;const s=va.lastCheckedAt;(s===null||Date.now()-s>=J1)&&dg(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),_a(e,t)&&DD()}}function kD(e,t){fa.set(e,eC(t)),ao({...va,hasUpdates:Yv(),lastCheckedAt:Date.now()})}function om(e){e===void 0?fa.clear():fa.set(e,!1),ao({...va,hasUpdates:Yv()})}async function dg(e,t){if(!_a(e,t))return;if(la&&la.api===e&&la.runId===t)return la.promise;ao({...va,checking:!0});const n=ED(e,t).finally(()=>{la?.promise===n&&(la=null),_a(e,t)&&(ao({...va,checking:!1,lastCheckedAt:Date.now()}),TD(e,t))});return la={api:e,runId:t,promise:n},n}async function ED(e,t){try{const n=await e.listAgents();if(!_a(e,t))return;const s=[{key:wD,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],l=new Map;if(await Promise.all(s.map(async c=>{try{const d=await c.check();l.set(c.key,eC(d))}catch{l.set(c.key,fa.get(c.key)??!1)}})),!_a(e,t))return;fa.clear();for(const[c,d]of l)fa.set(c,d);ao({...va,hasUpdates:Yv()})}catch{}}function TD(e,t){_a(e,t)&&(Vv(),zc=window.setTimeout(()=>{zc=null,_a(e,t)&&dg(e,t)},J1))}function DD(){gh+=1,Vv(),$v=null,la=null,fa.clear(),ao({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Vv(){zc!==null&&(window.clearTimeout(zc),zc=null)}function RD(){return gh+=1,gh}function _a(e,t){return $v===e&&gh===t}function eC(e){return e.updateAvailable===!0}function Yv(){return Array.from(fa.values()).some(Boolean)}function ao(e){va=e;for(const t of Array.from(ug))t()}const MD=e=>new Promise(t=>setTimeout(t,e));function ND({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local"}]),[l,c]=v.useState({}),[d,m]=v.useState(!1),[g,f]=v.useState(null),[y,b]=v.useState(!1),[C,w]=v.useState({});function x(R,z){c(ne=>({...ne,[R]:{...ne[R],...z}}))}function D(R,z){w(ne=>({...ne,[R]:{status:ne[R]?.status??null,busy:ne[R]?.busy??!1,error:ne[R]?.error??null,...z}}))}const B=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),L=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),O=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),X=R=>R.id===null?e:no(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async z=>{if(R)return;let ne="Local";try{ne=(await e.getMainInfo()).name?.trim()||ne}catch{}if(R)return;const _e=new Map(z.agents.map(F=>[F.id,F])),M=ps(z.serverOrder,z.agents).flatMap(F=>{if(F===Dn)return[{key:"local",id:null,name:ne}];const ie=_e.get(F);return ie?[{key:ie.id,id:ie.id,name:ie.name}]:[]});s(M);for(const F of M)B(F).then(ie=>x(F.key,{version:ie,manualUpdate:ie.manualUpdate??null})).catch(ie=>x(F.key,{error:ie instanceof Error?ie.message:"unreachable"})),K(F)}).catch(()=>{}),()=>{R=!0}},[]);async function U(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const z=await L(R);kD(R.key,z),x(R.key,{latestVersion:z.latestVersion,updateAvailable:z.updateAvailable,status:re(z),...z.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(z){x(R.key,{busy:!1,error:z instanceof Error?z.message:"check failed"})}}async function G(){m(!0),await Promise.all(n.map(R=>U(R))),m(!1)}async function W(R,z){const ne=Date.now()+18e4;for(;Date.now()<ne;){await MD(3e3);try{const _e=await B(R);if(z&&_e.runningVersion!==z.runningVersion)return _e}catch{}}return null}async function q(R){let z=l[R.key]?.version;if(!z)try{z=await B(R),x(R.key,{version:z,manualUpdate:z.manualUpdate??null})}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let ne;try{ne=await O(R)}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!ne.ok){const M=ne.manualUpdate??(SD(ne.message)?yD():null);return M?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(x(R.key,{busy:!1,status:void 0,error:ne.message}),"failed")}if(!ne.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),om(R.key),"unchanged";x(R.key,{status:"restarting…"});const _e=await W(R,z);return _e?(x(R.key,{busy:!1,version:_e,updateAvailable:!1,status:"updated",manualUpdate:_e.manualUpdate??null}),om(R.key),R.id===null&&(b(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(x(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function ge(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ne=await e.uninstallAgent(R.id);s(_e=>_e.filter(M=>M.key!==R.key)),c(_e=>{const M={..._e};return delete M[R.key],M}),om(R.key),t?.(R.id),f(ne.message)}catch(ne){x(R.key,{busy:!1,status:void 0,error:ne instanceof Error?ne.message:"delete failed"})}}}async function Se(){m(!0),f(null);const R=n.filter(ie=>ie.id!==null),z=n.find(ie=>ie.id===null),ne=await Promise.all(R.map(ie=>q(ie))),_e=ne.filter(ie=>ie==="failed").length;let M=ne.filter(ie=>ie==="manual").length,F=null;if(z&&(F=await q(z),F==="manual"&&(M+=1),F==="updated")){_e>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),m(!1);return}_e>0&&M>0?f("Some servers failed and some need manual update. Check each marked row."):_e>0?f("Some secondary servers failed to update. Check their rows and retry."):M>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function xe(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function re(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function $(R){const z=R?.version;return z?`npm package v${z.runningVersion}`:""}async function J(R,z){try{await LD(z),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(ne){x(R,{error:ne instanceof Error?ne.message:"copy failed"})}}async function K(R,z=!1){try{const ne=await X(R).getCodeServerStatus(z?{checkLatest:!0}:void 0);D(R.key,{status:ne,error:null})}catch(ne){D(R.key,{error:ne instanceof Error?ne.message:"code-server status failed"})}}async function se(R,z){if(z==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const ne=X(R);D(R.key,{busy:!0,error:null});try{if(z==="install"){const _e=await ne.installCodeServer();D(R.key,{status:_e.status})}else if(z==="update"){const _e=await ne.updateCodeServer();D(R.key,{status:_e.status})}else if(z==="stop")D(R.key,{status:await ne.stopCodeServer()});else{const _e=await ne.uninstallCodeServer();D(R.key,{status:_e.status})}}catch(_e){D(R.key,{error:_e instanceof Error?_e.message:"code-server action failed"})}finally{D(R.key,{busy:!1})}}const A=n.filter(R=>C[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(ne=>C[ne.key]?.status?.job?.status==="running");if(R.length===0)return;const z=window.setInterval(()=>{for(const ne of R)K(ne)},1e3);return()=>window.clearInterval(z)},[A]),p.jsxs("section",{className:"security-section",children:[p.jsx("h3",{children:"Servers"}),p.jsxs("div",{className:"update-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{G()},disabled:d,children:"Check for updates"}),p.jsx("button",{type:"button",onClick:()=>{Se()},disabled:d,children:"Update all"})]}),g?p.jsx("p",{className:"settings-status",children:g}):null,y?p.jsxs("div",{className:"server-reload-required",role:"status",children:[p.jsx("span",{children:"Main server update is ready."}),p.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,p.jsx("ul",{className:"security-list",children:n.map(R=>{const z=l[R.key],ne=$(z),_e=z?.manualUpdate??null,M=C[R.key]??{status:null,busy:!1,error:null},F=z?.version!==void 0&&z?.updateAvailable!==!1&&!z?.busy&&!d,ie=R.id!==null&&!z?.busy&&!d;return p.jsxs("li",{children:[p.jsxs("div",{className:"server-row-main",children:[p.jsxs("div",{children:[p.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?p.jsx("span",{className:"security-badge",children:"Main"}):null]}),p.jsxs("span",{className:"security-item-meta",children:[ne?`${ne} — `:"",xe(z)]})]}),_e?p.jsxs("div",{className:"server-manual-update",children:[p.jsx("span",{children:_e.message}),p.jsxs("div",{className:"server-manual-command",children:[p.jsx("code",{children:_e.command}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{J(R.key,_e.command)},children:z?.copiedCommand?"Copied":"Copy"})]})]}):null,p.jsx(AD,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{K(R,!0)},onInstall:()=>{se(R,"install")},onUpdate:()=>{se(R,"update")},onStop:()=>{se(R,"stop")},onUninstall:()=>{se(R,"uninstall")}})]}),p.jsxs("div",{className:"server-row-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{q(R)},disabled:!F,children:z?.busy?"…":"Update"}),R.id!==null?p.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{ge(R)},disabled:!ie,children:"Delete"}):null]})]},R.key)})})]})}function AD({status:e,busy:t,error:n,onCheck:s,onInstall:l,onUpdate:c,onStop:d,onUninstall:m}){const g=e?.job??null,f=g?.status==="running",y=e!==null,b=e?.installed===!0,C=(e?.instances.length??0)>0,w=e?.supported!==!1,x=e===null&&!n;return p.jsxs("div",{className:"server-code-addon",children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),p.jsxs("span",{className:"security-item-meta",children:[w?x?"checking...":b?`code-server v${e?.version??"unknown"}${C?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?p.jsx("p",{className:"settings-error",children:n}):null,g?p.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
|
|
16
|
+
`):`${g.action} ${g.status}`}):null,p.jsxs("div",{className:"server-code-addon-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:t||f||!w,children:"Check"}),b?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||f||!w,children:e?.updateAvailable?"Update code-server":"Reinstall"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!C,children:"Stop"}),p.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||f,children:"Uninstall"})]}):p.jsx("button",{type:"button",className:"secondary-button",onClick:l,disabled:!y||x||t||f||!w,children:"Install code-server"})]})]})}async function LD(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Bd=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function BD({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:l}){const c=v.useMemo(()=>t??Mh(),[t]),[d,m]=v.useState(()=>ng()),[g,f]=v.useState(()=>rg()),[y,b]=v.useState(()=>ag()),[C,w]=v.useState(()=>lg()),[x,D]=v.useState(()=>og()),[B,L]=v.useState(()=>ma()),[O,X]=v.useState(()=>sl()),[U,G]=v.useState(null),[W,q]=v.useState(null),[ge,Se]=v.useState("appearance"),[xe,re]=v.useState(()=>Ov()),[$,J]=v.useState(()=>rl()),[K,se]=v.useState(()=>po()),[A,R]=v.useState([]),[z,ne]=v.useState([]),[_e,M]=v.useState([]),[F,ie]=v.useState(5*1024*1024),[ve,be]=v.useState(!1),[Ee,Me]=v.useState(null),[Re,Pe]=v.useState(null),[Be,oe]=v.useState(!1),[he,ye]=v.useState(null),[Oe,Ke]=v.useState(null),je=v.useRef(null),ae=v.useRef(null),Te=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),we=v.useMemo(()=>new Set(z),[z]),ze=!jD(z,_e),Ue=v.useMemo(()=>Ih(),[]),nt=Re?.displayMode==="standalone"&&(Re.deviceKind==="mobile"||Re.deviceKind==="tablet");v.useEffect(()=>H1(()=>m(ng())),[]),v.useEffect(()=>U1(()=>f(rg())),[]),v.useEffect(()=>K1(()=>b(ag())),[]),v.useEffect(()=>Xd(()=>{w(lg()),D(og())}),[]),v.useEffect(()=>Cv(()=>L(ma())),[]),v.useEffect(()=>ph(()=>X(sl())),[]),v.useEffect(()=>D1(()=>J(rl())),[]),v.useEffect(()=>{if(!U)return;const Z=Wc.find(st=>st.id===U);if(!Z)return;const We=st=>{if(st.preventDefault(),st.stopPropagation(),st.key==="Escape"){G(null),q(null);return}const et=dD(st,Z);if(!et){q(OD(Z));return}X(oD(U,et)),G(null),q(null)};return window.addEventListener("keydown",We,!0),()=>window.removeEventListener("keydown",We,!0)},[U]),v.useEffect(()=>{let Z=!1;return c.listNotificationAssets().then(We=>{Z||Ne(We)}).catch(We=>{Z||Me(Xl(We))}),()=>{Z=!0}},[c]),v.useEffect(()=>{let Z=!1;return c.getPushNotificationStatus(ms()).then(We=>{Z||(Pe(We.currentDevice),ye(null))}).catch(We=>{Z||ye(Xl(We))}),()=>{Z=!0}},[c]);function ht(Z){m(Ld(Number(Z)))}function Dt(Z){J(GS(Number(Z)))}function Ei(Z){Se(Z);const We=ae.current,st=Te.current[Z];if(!We||!st)return;const et=Math.max(0,s0(st,We)-12);typeof We.scrollTo=="function"?We.scrollTo({top:et,behavior:"smooth"}):We.scrollTop=et}function ni(){const Z=ae.current;if(!Z)return;if(Z.scrollTop+Z.clientHeight>=Z.scrollHeight-2){Se(Bd[Bd.length-1].id);return}let We="appearance";const st=Z.scrollTop+Math.min(180,Math.max(48,Z.clientHeight*.28));for(const et of Bd){const wt=Te.current[et.id];wt&&s0(wt,Z)<=st&&(We=et.id)}Se(We)}function di(Z){X(cD(Z)),G(null),q(null)}function le(){X(uD()),G(null),q(null)}function Ne(Z){const We=Z.assets.filter(st=>st.enabled).map(st=>st.id);R(Z.assets),ne(We),M(We),ie(Z.maxFileBytes),Me(null)}async function Qe(){if(xe){XS(!1),re(!1);return}let Z=K;Z==="default"&&(Z=await M1(),se(Z)),Z==="granted"&&(XS(!0),re(!0))}async function it(){oe(!0),ye(null),Ke(null);try{if(Re)await N2(c),Pe(null);else{await D2(c,!1);const Z=await c.getPushNotificationStatus(ms());Pe(Z.currentDevice)}}catch(Z){ye(um(Z))}finally{oe(!1)}}async function jt(Z){oe(!0),ye(null),Ke(null);try{await A2(c,Z);const We=await c.getPushNotificationStatus(ms());Pe(We.currentDevice)}catch(We){ye(um(We))}finally{oe(!1)}}async function xt(){oe(!0),ye(null),Ke(null);try{await c.testPushNotification({clientId:ms()}),Ke("Test notification accepted by the push service.")}catch(Z){ye(um(Z))}finally{oe(!1)}}async function gt(Z){const We=Z?.[0];if(We){if(We.size>F){Me(`File must be ${cm(F)} or smaller.`),kt();return}if(We.type!=="video/mp4"&&We.type!=="video/webm"){Me("Upload an MP4 or WebM video."),kt();return}be(!0),Me(null);try{await c.uploadNotificationAsset(We),Ne(await c.listNotificationAssets()),s?.()}catch(st){Me(Xl(st))}finally{be(!1),kt()}}}async function Ht(Z){be(!0),Me(null);try{await c.deleteNotificationAsset(Z),Ne(await c.listNotificationAssets()),s?.()}catch(We){Me(Xl(We))}finally{be(!1)}}function kt(){je.current&&(je.current.value="")}function Mn(Z,We){const st=new Set(z);if(We?st.add(Z):st.delete(Z),st.size===0){Me("Keep at least one toast video selected.");return}Me(null),ne(Array.from(st))}async function Nn(){if(z.length===0){Me("Keep at least one toast video selected.");return}be(!0),Me(null);try{const Z=await c.updateNotificationAssetSelection({enabledAssetIds:z});Ne(Z),s?.()}catch(Z){Me(Xl(Z))}finally{be(!1)}}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:p.jsxs("div",{className:"security-panel settings-panel",onClick:Z=>Z.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{children:"Settings"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),p.jsxs("div",{className:"settings-layout",children:[p.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Bd.map(Z=>p.jsxs("button",{type:"button","data-active":ge===Z.id?"true":"false","aria-current":ge===Z.id?"true":void 0,onClick:()=>Ei(Z.id),children:[Z.label,Z.id==="servers"&&n?p.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},Z.id))}),p.jsxs("div",{ref:ae,className:"settings-content",onScroll:ni,children:[p.jsxs("section",{id:"settings-appearance",ref:Z=>{Te.current.appearance=Z},className:"security-section settings-section",children:[p.jsx("h3",{children:"Appearance"}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Theme"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),p.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:oh.map(Z=>p.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":B===Z.id,"data-active":B===Z.id?"true":"false",onClick:()=>L(SE(Z.id)),style:{"--settings-theme-bg":Z.tokens.bg,"--settings-theme-bg-2":Z.tokens.bg2,"--settings-theme-sidebar":Z.tokens.bgSidebar,"--settings-theme-line":Z.tokens.line,"--settings-theme-fg":Z.tokens.fg,"--settings-theme-fg-2":Z.tokens.fg2,"--settings-theme-accent":Z.tokens.accent,"--settings-theme-xterm-bg":Z.xterm.background,"--settings-theme-xterm-fg":Z.xterm.foreground,"--settings-theme-xterm-selection":Z.xterm.selectionBackground},children:[p.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[p.jsxs("span",{className:"settings-theme-preview-sidebar",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-main",children:[p.jsxs("span",{className:"settings-theme-preview-tabs",children:[p.jsx("span",{}),p.jsx("span",{})]}),p.jsxs("span",{className:"settings-theme-preview-terminal",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})]})]}),p.jsxs("span",{className:"settings-theme-card-copy",children:[p.jsx("strong",{children:Z.label}),p.jsx("small",{children:Z.description})]})]},Z.id))}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font size"}),p.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),p.jsx("input",{type:"range",min:eg,max:tg,step:1,value:d,"aria-label":"Terminal font size",onChange:Z=>ht(Z.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row",children:[p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Ld(d-1)),children:"-"}),p.jsx("input",{type:"number",min:eg,max:tg,step:1,value:d,"aria-label":"Terminal font size value",onChange:Z=>ht(Z.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Ld(d+1)),children:"+"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(Ld(el)),children:"Reset"})]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Font family"}),p.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:Z=>f(tD(Z.currentTarget.value)),children:fh.map(Z=>p.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:y,onChange:Z=>b(nD(Z.currentTarget.checked))}),"Show scroll progress"]}),p.jsx("div",{className:"settings-section-heading",children:p.jsxs("div",{children:[p.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),p.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:C,onChange:Z=>w(rD(Z.currentTarget.checked))}),"Shell panes"]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:x,onChange:Z=>D(sD(Z.currentTarget.checked))}),"Codex/Claude panes"]})]}),p.jsxs("section",{id:"settings-shortcuts",ref:Z=>{Te.current.shortcuts=Z},className:"security-section settings-section",children:[p.jsxs("div",{className:"settings-section-heading",children:[p.jsx("h3",{children:"Shortcuts"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:le,children:"Reset all"})]}),p.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),W?p.jsx("p",{className:"settings-error",children:W}):null,p.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Wc.map(Z=>{const We=U===Z.id;return p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"settings-shortcut-label",children:Z.label}),p.jsx("span",{className:"settings-shortcut-group",children:Z.group})]}),p.jsxs("div",{className:"settings-shortcut-actions",children:[p.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":We?"true":"false",onClick:()=>{G(Z.id),q(null)},children:We?"Press keys…":V1(O[Z.id])}),p.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>di(Z.id),children:"Reset"})]})]},Z.id)})})]}),p.jsxs("section",{id:"settings-notifications",ref:Z=>{Te.current.notifications=Z},className:"security-section settings-section",children:[p.jsx("h3",{children:"Notifications"}),Ph()?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:xe&&K==="granted",onChange:()=>{Qe()},disabled:K==="denied"}),"System notification when page is hidden"]}),K==="denied"?p.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):p.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):p.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),p.jsxs("div",{className:"settings-subsection",children:[p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:!!Re,onChange:()=>{it()},disabled:Be||!Ue.supported}),"Installed app push notifications"]}),p.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ue.supported?null:p.jsx("p",{className:"muted",children:Gd(Ue.reason)}),Re?p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"muted",children:["Registered as ",Re.label,". Last active ",new Date(Re.lastActiveAt).toLocaleString(),"."]}),p.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{xt()},disabled:Be,children:"Send test notification"})]}):null,nt?p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:Re?.alwaysNotify===!0,onChange:Z=>{jt(Z.currentTarget.checked)},disabled:Be||!Re}),"Always notify this mobile device"]}):null,he?p.jsx("p",{className:"form-error",children:he}):null,Oe?p.jsx("p",{className:"muted",role:"status",children:Oe}):null]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:$.enabled,onChange:Z=>J(b2(Z.currentTarget.checked))}),"Show animated completion toast"]}),p.jsxs("label",{className:"settings-control",children:[p.jsx("span",{children:"Toast duration"}),p.jsx("span",{className:"settings-control-value",children:$.persistUntilDismissed?"Until closed":`${$.durationSeconds}s`}),p.jsx("input",{type:"range",min:Vm,max:Ym,step:.5,value:$.durationSeconds,disabled:!$.enabled||$.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:Z=>Dt(Z.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[p.jsx("input",{type:"number",min:Vm,max:Ym,step:.5,value:$.durationSeconds,disabled:!$.enabled||$.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:Z=>Dt(Z.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!$.enabled||$.persistUntilDismissed,onClick:()=>J(GS(jc)),children:"Reset"})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:$.persistUntilDismissed,disabled:!$.enabled,onChange:Z=>J(y2(Z.currentTarget.checked))}),"Keep toast until dismissed"]}),p.jsxs("div",{className:"settings-assets-header",children:[p.jsx("span",{children:"Toast videos"}),p.jsxs("span",{children:[cm(F)," max"]})]}),p.jsx("input",{ref:je,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:Z=>{gt(Z.currentTarget.files)}}),p.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ve,onClick:()=>je.current?.click(),children:"Upload video"}),Ee?p.jsx("p",{className:"settings-error",children:Ee}):null,A.length>0?p.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:A.map(Z=>p.jsxs("li",{"data-enabled":we.has(Z.id)?"true":"false",children:[p.jsxs("label",{className:"settings-asset-choice",children:[p.jsx("input",{type:"checkbox",checked:we.has(Z.id),disabled:ve,"aria-label":`Use ${Z.filename}`,onChange:We=>Mn(Z.id,We.currentTarget.checked)}),p.jsx("video",{src:Z.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),p.jsxs("span",{className:"settings-asset-copy",children:[p.jsx("span",{children:Z.filename}),p.jsx("small",{children:Z.source==="built-in"?"Built-in":cm(Z.size)})]})]}),Z.source==="uploaded"?p.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ve,"aria-label":`Delete ${Z.filename}`,onClick:()=>{Ht(Z.id)},children:"x"}):null]},Z.id))}):p.jsx("p",{className:"muted",children:"Built-in videos will be used."}),p.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ve||A.length===0||!ze,onClick:()=>{Nn()},children:"Save selected videos"})]}),p.jsx("div",{id:"settings-security",ref:Z=>{Te.current.security=Z},className:"settings-section-group",children:p.jsx(J2,{api:c})}),p.jsx("div",{id:"settings-servers",ref:Z=>{Te.current.servers=Z},className:"settings-section-group",children:p.jsx(ND,{api:c,...l?{onAgentRemoved:l}:{}})})]})]})]})})}function s0(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function cm(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Xl(e){return e instanceof Error?e.message:"Request failed."}function Gd(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function um(e){const t=Xl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Gd("not_standalone"):t==="insecure"?Gd("insecure"):t==="not_mobile"?Gd("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function OD(e){return e.indexed?"Press a shortcut ending in a number from 1 to 9.":e.requiresPrimaryModifier?"Use Ctrl, Alt, or Meta with another key.":"Press a complete shortcut."}function jD(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}class Ya extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function zD(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,s=e.files.map((l,c)=>({fieldName:`file${c}`,relativePath:l.relativePath,size:l.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[l,c]of e.files.entries())n.append(`file${l}`,c.file);return new Promise((l,c)=>{let d=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{d||(d=!0,m(),l(b))},f=b=>{d||(d=!0,m(),c(b))},y=()=>{t.abort(),f(new Ya(0,"Upload aborted."))};if(e.signal?.aborted){f(new Ya(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new Ya(t.status,"Invalid upload response."))}return}f(new Ya(t.status,PD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Ya(0,"Upload failed.")),t.onabort=()=>f(new Ya(0,"Upload aborted.")),t.ontimeout=()=>f(new Ya(0,"Upload timed out.")),t.send(n)})}function PD(e,t){try{const n=JSON.parse(e),s=typeof n.error=="string"?n.error:n.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const ID="modulepreload",HD=function(e){return"/"+e},a0={},Xv=function(t,n,s){let l=Promise.resolve();if(n&&n.length>0){let g=function(f){return Promise.all(f.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");l=g(n.map(f=>{if(f=HD(f),f in a0)return;a0[f]=!0;const y=f.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const C=document.createElement("link");if(C.rel=y?"stylesheet":ID,y||(C.as="script"),C.crossOrigin="",C.href=f,m&&C.setAttribute("nonce",m),document.head.appendChild(C),y)return new Promise((w,x)=>{C.addEventListener("load",w),C.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return l.then(d=>{for(const m of d||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},UD=v.lazy(()=>Xv(()=>import("./MarkdownPreview-BBppqaO6.js"),__vite__mapDeps([0,1])));function KD({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:l}){const[c,d]=v.useState(null),[m,g]=v.useState(""),[f,y]=v.useState({}),[b,C]=v.useState(()=>new Set),[w,x]=v.useState(null),[D,B]=v.useState({type:"empty"}),[L,O]=v.useState("idle"),[X,U]=v.useState(null),G=v.useRef(null),W=v.useRef(null),q=v.useRef(!1),ge=v.useRef(0),Se=v.useRef(null);Se.current===null&&t&&(Se.current=t);const xe=Se.current,re=s?WD(s):t?l0(t,n):null,$=c?[c.rootPath,m].filter(Boolean).join("/"):"",J=w?.path??null;v.useEffect(()=>(q.current=!0,()=>{q.current=!1,ge.current+=1,oe()}),[]),v.useEffect(()=>{Se.current=t,W.current=null,K(re)},[e]),v.useEffect(()=>{s&&re!==W.current&&se(s,re)},[s,re]),v.useEffect(()=>{if(s||!xe||t!==xe)return;const ae=l0(xe,n);ae!==W.current&&A(xe,ae)},[xe,t,n,s]);async function K(ae=re){if(s){await se(s,ae);return}await A(t,ae)}async function se(ae,Te=re){const we=he();if(W.current=Te,oe(),d(null),g(""),y({}),C(new Set),x(null),B({type:"empty"}),U(null),!ae){O("idle");return}O("loading");try{const ze=await e.createFileRoot({path:ae});if(!ye(we))return;d({rootToken:ze.rootToken,rootPath:ze.rootPath});const Ue=await e.listFiles({rootToken:ze.rootToken,path:""});if(!ye(we))return;ne(Ue),O("idle")}catch(ze){ye(we)&&(U(us(ze)),O("idle"))}}async function A(ae,Te=re){const we=he();if(W.current=Te,oe(),d(null),g(""),y({}),C(new Set),x(null),B({type:"empty"}),U(null),!ae){O("idle");return}O("loading");try{const ze=await e.createFileRoot({terminalId:ae});if(!ye(we))return;d({rootToken:ze.rootToken,rootPath:ze.rootPath});const Ue=await e.listFiles({rootToken:ze.rootToken,path:""});if(!ye(we))return;ne(Ue),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function R(ae=m,Te=c){if(!Te)return;const we=he();O("loading"),U(null);try{const ze=await e.listFiles({rootToken:Te.rootToken,path:ae});if(!ye(we))return;ne(ze),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function z(){if(s){await se(s,re);return}Se.current=t,await A(t,re)}function ne(ae){y(Te=>({...Te,[ae.path]:qD(ae.entries)}))}async function _e(ae){if(!(!dm(ae)||!c)){if(x(ae),U(null),ae.kind==="directory"){g(ae.path),Be(),await F(ae);return}if(g(Xa(ae.path)),ae.editable){await ve(ae);return}ae.previewKind!=="none"&&await Ee(ae,ae.previewKind)}}async function M(ae){if(!(!dm(ae)||!c)){if(x(ae),U(null),ae.kind==="directory"){g(ae.path),Be(),await F(ae);return}if(g(Xa(ae.path)),ae.editable){await be(ae);return}ae.previewKind!=="none"&&await Ee(ae,ae.previewKind)}}async function F(ae){if(b.has(ae.path)){C(Te=>{const we=new Set(Te);return we.delete(ae.path),we});return}C(Te=>new Set(Te).add(ae.path)),await R(ae.path)}function ie(ae,Te){ae.key==="Enter"&&(ae.preventDefault(),M(Te))}async function ve(ae){if(!c)return;const Te=he();O("loading"),oe();try{const we=await e.readFile({rootToken:c.rootToken,path:ae.path});if(!ye(Te))return;B({type:"text-preview",file:ae,read:we}),O("idle")}catch(we){if(await Oe(we,Te))return;ye(Te)&&(U(us(we)),O("idle"))}}async function be(ae){if(!c)return;const Te=he();O("loading");try{await l({rootToken:c.rootToken,path:ae.path,...t?{terminalId:t}:{}}),ye(Te)&&O("idle")}catch(we){if(await Oe(we,Te))return;ye(Te)&&(U(us(we)),O("idle"))}}async function Ee(ae,Te){if(!c)return;const we=he();O("loading"),oe();try{const ze=await e.previewFile({rootToken:c.rootToken,path:ae.path});if(!ye(we))return;const Ue=URL.createObjectURL(ze);if(!ye(we)){URL.revokeObjectURL(Ue);return}G.current=Ue,B({type:"preview",file:ae,previewKind:Te,url:Ue}),O("idle")}catch(ze){if(await Oe(ze,we))return;ye(we)&&(U(us(ze)),O("idle"))}}async function Me(ae){if(!c)return;const Te=ae==="file"?"New file":"New folder",we=window.prompt(Te,""),ze=w?w.kind==="directory"?w.path:Xa(w.path):m,Ue=o0(we,ze);if(Ue){U(null);try{const nt=await e.createFileEntry({rootToken:c.rootToken,path:Ue,kind:ae});x(nt.entry),await R(ze)}catch(nt){if(await Oe(nt))return;U(us(nt))}}}async function Re(){if(!c||!w)return;const ae=window.prompt("Move selected entry",w.path),Te=o0(ae,"");if(!Te||Te===w.path)return;const we=Xa(w.path),ze=Xa(Te);U(null);try{const Ue=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:Te});x(Ue.entry),g(Ue.entry.kind==="directory"?Ue.entry.path:Xa(Ue.entry.path)),Be(),await R(we),ze!==we&&await R(ze)}catch(Ue){if(await Oe(Ue))return;U(us(Ue))}}async function Pe(){if(!c||!w)return;const ae=w.path,Te=Xa(ae);U(null);try{const we=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),ze=we.descendantCount>0?` and ${we.descendantCount} nested item${we.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${we.path}${ze}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:we.previewToken}),x(null),g(Te),C(Ue=>{const nt=new Set(Ue);for(const ht of Ue)(ht===ae||ht.startsWith(`${ae}/`))&&nt.delete(ht);return nt}),Be(),await R(Te)}catch(we){if(await Oe(we))return;U(us(we))}}function Be(){ge.current+=1,oe(),B({type:"empty"})}function oe(){G.current&&(URL.revokeObjectURL(G.current),G.current=null)}function he(){return ge.current+=1,ge.current}function ye(ae){return q.current&&ae===ge.current}async function Oe(ae,Te){return $D(ae)?(Te!==void 0&&!ye(Te)||await K(re),!0):!1}function Ke(ae,Te){const we=dm(ae),ze=ae.kind==="directory"&&b.has(ae.path),Ue=f[ae.path]??[],nt={"--file-tree-depth":Te};return p.jsxs(Li.Fragment,{children:[p.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ae.kind,"data-expanded":ze,"data-active":J===ae.path,disabled:!we,style:nt,"aria-expanded":ae.kind==="directory"?ze:void 0,"aria-label":`${ae.kind==="directory"?"Open folder":"Open file"} ${ae.name}`,title:ae.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{_e(ae)},onDoubleClick:()=>{M(ae)},onKeyDown:ht=>ie(ht,ae),children:[p.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ae.kind==="directory"?ze?"▾":"▸":""}),p.jsx("span",{className:"file-entry-name",children:ae.name}),p.jsx("small",{children:FD(ae)})]}),ze?p.jsx("div",{className:"file-tree-children",role:"group",children:Ue.map(ht=>Ke(ht,Te+1))}):null]},ae.path)}const je=f[""]??[];return p.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[p.jsxs("header",{className:"file-explorer-header",children:[p.jsx("div",{className:"file-explorer-path",title:$,children:$||"No active pane"}),p.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[p.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{z()},children:"↻"}),p.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Me("file")},children:"+"}),p.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Me("directory")},children:"▣"})]})]}),X?p.jsx("div",{className:"file-explorer-alert",role:"alert",children:X}):null,p.jsxs("div",{className:"file-explorer-layout",children:[p.jsx("div",{className:"file-tree","aria-label":$?`Files in ${$}`:"Files",children:je.map(ae=>Ke(ae,0))}),p.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[p.jsxs("div",{className:"file-detail-header",children:[p.jsx("strong",{children:w?.name??"detail"}),p.jsxs("div",{className:"file-detail-actions",children:[p.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Re()},children:"Move"}),p.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Pe()},children:"Delete"})]})]}),L==="loading"?p.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&L!=="loading"?p.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?p.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?p.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?p.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?p.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:p.jsx(v.Suspense,{fallback:p.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:p.jsx(UD,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?p.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function dm(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function FD(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function l0(e,t){return`${e}\0${t??""}`}function WD(e){return`workspace\0${e}`}function qD(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Xa(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function o0(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function us(e){return e instanceof Error?e.message:"Request failed"}function $D(e){return e instanceof or&&e.status===409&&e.message==="terminal_cwd_changed"}const VD=v.lazy(()=>Xv(()=>import("./MarkdownPreview-BBppqaO6.js"),__vite__mapDeps([0,1])));function c0({api:e,editor:t,canClose:n,onClose:s}){const[l,c]=v.useState(t.read),[d,m]=v.useState(t.read.content),[g,f]=v.useState("idle"),[y,b]=v.useState(null),[C,w]=v.useState(!1),[x,D]=v.useState("edit"),B=v.useRef(t),L=v.useRef(t.read),O=v.useRef(t.read.content),X=v.useRef(!1),U=v.useRef(!1),G=v.useRef(0),W=d!==l.content&&g!=="saving"&&!C;v.useEffect(()=>(U.current=!0,()=>{U.current=!1,G.current+=1}),[]),v.useEffect(()=>{G.current+=1,X.current=!1,B.current=t,L.current=t.read,O.current=t.read.content,c(t.read),m(t.read.content),f("idle"),b(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{L.current=l},[l]),v.useEffect(()=>{O.current=d},[d]),v.useEffect(()=>{if(d===l.content||C)return;const re=window.setInterval(()=>{!X.current&&O.current!==L.current.content&&q()},1e3);return()=>window.clearInterval(re)},[d===l.content,C,t.id]);async function q(){if(X.current)return;const re=O.current,$=L.current;if(re===$.content)return;const J=B.current,K=G.current;X.current=!0,f("saving"),b(null),w(!1);try{const se=await e.writeFile({rootToken:J.rootToken,path:J.path,content:re,expectedVersion:$.version});if(!U.current||K!==G.current)return;const A={...$,content:re,version:se.version};L.current=A,c(A),f(O.current===re?"saved":"idle")}catch(se){if(!U.current||K!==G.current)return;if(se instanceof or&&se.status===409){w(!0),f("idle");return}b(YD(se)),f("idle")}finally{K===G.current&&(X.current=!1)}}const ge=g==="saving"?"saving":g==="saved"?"saved":l.language,Se=l.language==="markdown",xe=Se&&x==="preview";return p.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[p.jsxs("header",{className:"editor-pane-header",children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("strong",{children:t.title}),p.jsx("span",{className:"terminal-pane-spacer"}),p.jsx("span",{className:"terminal-pane-state",children:ge}),p.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!W,onClick:()=>{q()},children:"Save"}),Se?p.jsx("button",{type:"button","aria-label":`${xe?"Edit":"Preview"} ${t.title}`,onClick:()=>D(re=>re==="preview"?"edit":"preview"),children:xe?"Edit":"Preview"}):null,n?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),y?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,C?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,xe?p.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:p.jsx(v.Suspense,{fallback:p.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:p.jsx(VD,{content:d})})}):p.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:re=>{const $=re.target.value;O.current=$,m($),f("idle"),b(null),w(!1)}})]})}function YD(e){return e instanceof Error?e.message:"Request failed"}var XD=2,GD=1,ZD=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),l=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=d.top+d.bottom,g=d.right+d.left,f=s-m,y=l-g-t;return{cols:Math.max(XD,Math.floor(y/e.css.cell.width)),rows:Math.max(GD,Math.floor(f/e.css.cell.height))}}};var tC=Object.defineProperty,QD=Object.getOwnPropertyDescriptor,JD=(e,t)=>{for(var n in t)tC(e,n,{get:t[n],enumerable:!0})},ui=(e,t,n,s)=>{for(var l=s>1?void 0:s?QD(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(l=(s?d(t,n,l):d(l))||l);return s&&l&&tC(t,n,l),l},Le=(e,t)=>(n,s)=>t(n,s,e),u0="Terminal input",hg={get:()=>u0,set:e=>u0=e},d0="Too much output to announce, navigate to rows manually to read",fg={get:()=>d0,set:e=>d0=e};function eR(e){return e.replace(/\r?\n/g,"\r")}function tR(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function iR(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function nR(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let l=e.clipboardData.getData("text/plain");iC(l,t,n,s)}}function iC(e,t,n,s){e=eR(e),e=tR(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nC(e,t,n){let s=n.getBoundingClientRect(),l=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function h0(e,t,n,s,l){nC(e,t,n),l&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function ca(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Uh(e,t=0,n=e.length){let s="";for(let l=t;l<n;++l){let c=e[l];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var rR=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=l;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,s;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[s++]=(d-55296)*1024+m-56320+65536:(t[s++]=d,t[s++]=m);continue}d!==65279&&(t[s++]=d)}return s}},sR=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l,c,d,m,g=0,f=0;if(this.interim[0]){let C=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)w<<=6,w|=D;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=B-x;for(;f<L;){if(f>=n)return 0;if(D=e[f++],(D&192)!==128){f--,C=!0;break}else this.interim[x++]=D,w<<=6,w|=D&63}C||(B===2?w<128?f--:t[s++]=w:B===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let y=n-4,b=f;for(;b<n;){for(;b<y&&!((l=e[b])&128)&&!((c=e[b+1])&128)&&!((d=e[b+2])&128)&&!((m=e[b+3])&128);)t[s++]=l,t[s++]=c,t[s++]=d,t[s++]=m,b+=4;if(l=e[b++],l<128)t[s++]=l;else if((l&224)===192){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(l&31)<<6|c&63,g<128){b--;continue}t[s++]=g}else if((l&240)===224){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(g=(l&15)<<12|(c&63)<<6|d&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((l&248)===240){if(b>=n)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(b>=n)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=d,s;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(l&7)<<18|(c&63)<<12|(d&63)<<6|m&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},rC="",ha=" ",su=class sC{constructor(){this.fg=0,this.bg=0,this.extended=new vh}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 sC;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}},vh=class aC{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}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 aC(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ur=class lC extends su{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new vh,this.combinedData=""}static fromCharData(t){let n=new lC;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ca(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 n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let l=t[1].charCodeAt(1);56320<=l&&l<=57343?this.content=(s-55296)*1024+l-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},f0="di$target",pg="di$dependencies",hm=new Map;function aR(e){return e[pg]||[]}function Vi(e){if(hm.has(e))return hm.get(e);let t=function(n,s,l){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");lR(t,n,l)};return t._id=e,hm.set(e,t),t}function lR(e,t,n){t[f0]===t?t[pg].push({id:e,index:n}):(t[pg]=[{id:e,index:n}],t[f0]=t)}var pn=Vi("BufferService"),oC=Vi("CoreMouseService"),ol=Vi("CoreService"),oR=Vi("CharsetService"),Gv=Vi("InstantiationService"),cC=Vi("LogService"),mn=Vi("OptionsService"),uC=Vi("OscLinkService"),cR=Vi("UnicodeService"),au=Vi("DecorationService"),mg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],l=this._optionsService.rawOptions.linkHandler,c=new ur,d=n.getTrimmedLength(),m=-1,g=-1,f=!1;for(let y=0;y<d;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else f=c.extended.urlId!==m;else g!==-1&&(f=!0);if(f||g!==-1&&y===d-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let C={start:{x:g+1,y:e},end:{x:y+(!f&&y===d-1?1:0),y:e}},w=!1;if(!l?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:b,range:C,activate:(x,D)=>l?l.activate(x,D,C):uR(x,D),hover:(x,D)=>l?.hover?.(x,D,C),leave:(x,D)=>l?.leave?.(x,D,C)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(s)}};mg=ui([Le(0,pn),Le(1,mn),Le(2,uC)],mg);function uR(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
17
17
|
|
|
18
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Kh=Vi("CharSizeService"),
|
|
18
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Kh=Vi("CharSizeService"),ys=Vi("CoreBrowserService"),Zv=Vi("MouseService"),Ss=Vi("RenderService"),dR=Vi("SelectionService"),dC=Vi("CharacterJoinerService"),mo=Vi("ThemeService"),hC=Vi("LinkProviderService"),hR=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?p0.isErrorNoTelemetry(e)?new p0(e.message+`
|
|
19
19
|
|
|
20
20
|
`+e.stack):new Error(e.message+`
|
|
21
21
|
|
|
22
|
-
`+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)}},hR=new dR;function Zd(e){fR(e)||hR.onUnexpectedError(e)}var gg="Canceled";function fR(e){return e instanceof pR?!0:e instanceof Error&&e.name===gg&&e.message===gg}var pR=class extends Error{constructor(){super(gg),this.name=this.message}};function mR(e){return new Error(`Illegal argument: ${e}`)}var p0=class vg extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vg)return t;let n=new vg;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_g=class fC extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,fC.prototype)}};function Fn(e,t=0){return e[e.length-(1+t)]}var gR;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function s(c){return c>0}e.isGreaterThan=s;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(gR||={});function vR(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var pC;(e=>{function t(U){return U&&typeof U=="object"&&typeof U[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(U){yield U}e.single=o;function c(U){return t(U)?U:o(U)}e.wrap=c;function d(U){return U||n}e.from=d;function*m(U){for(let G=U.length-1;G>=0;G--)yield U[G]}e.reverse=m;function g(U){return!U||U[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(U){return U[Symbol.iterator]().next().value}e.first=f;function y(U,G){let F=0;for(let W of U)if(G(W,F++))return!0;return!1}e.some=y;function b(U,G){for(let F of U)if(G(F))return F}e.find=b;function*C(U,G){for(let F of U)G(F)&&(yield F)}e.filter=C;function*w(U,G){let F=0;for(let W of U)yield G(W,F++)}e.map=w;function*x(U,G){let F=0;for(let W of U)yield*G(W,F++)}e.flatMap=x;function*D(...U){for(let G of U)yield*G}e.concat=D;function B(U,G,F){let W=F;for(let ve of U)W=G(W,ve);return W}e.reduce=B;function*L(U,G,F=U.length){for(G<0&&(G+=U.length),F<0?F+=U.length:F>U.length&&(F=U.length);G<F;G++)yield U[G]}e.slice=L;function O(U,G=Number.POSITIVE_INFINITY){let F=[];if(G===0)return[F,U];let W=U[Symbol.iterator]();for(let ve=0;ve<G;ve++){let Se=W.next();if(Se.done)return[F,e.empty()];F.push(Se.value)}return[F,{[Symbol.iterator](){return W}}]}e.consume=O;async function X(U){let G=[];for await(let F of U)G.push(F);return Promise.resolve(G)}e.asyncToArray=X})(pC||={});function ao(e){if(pC.is(e)){let t=[];for(let n of e)if(n)try{n.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 _R(...e){return Xt(()=>ao(e))}function Xt(e){return{dispose:vR(()=>{e()})}}var mC=class gC{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{ao(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?gC.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)}};mC.DISABLE_DISPOSED_WARNING=!1;var fa=mC,ut=class{constructor(){this._store=new fa,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)}};ut.None=Object.freeze({dispose(){}});var ll=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ms=typeof window=="object"?window:globalThis,bg=class yg{constructor(t){this.element=t,this.next=yg.Undefined,this.prev=yg.Undefined}};bg.Undefined=new bg(void 0);var ti=bg,m0=class{constructor(){this._first=ti.Undefined,this._last=ti.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ti.Undefined}clear(){let e=this._first;for(;e!==ti.Undefined;){let t=e.next;e.prev=ti.Undefined,e.next=ti.Undefined,e=t}this._first=ti.Undefined,this._last=ti.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ti(e);if(this._first===ti.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ti.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ti.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ti.Undefined&&e.next!==ti.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ti.Undefined&&e.next===ti.Undefined?(this._first=ti.Undefined,this._last=ti.Undefined):e.next===ti.Undefined?(this._last=this._last.prev,this._last.next=ti.Undefined):e.prev===ti.Undefined&&(this._first=this._first.next,this._first.prev=ti.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ti.Undefined;)yield e.element,e=e.next}},bR=globalThis.performance&&typeof globalThis.performance.now=="function",yR=class vC{static create(t){return new vC(t)}constructor(t){this._now=bR&&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}},en;(e=>{e.None=()=>ut.None;function t(q,J){return b(q,()=>{},0,void 0,!0,void 0,J)}e.defer=t;function n(q){return(J,K=null,re)=>{let A=!1,R;return R=q(P=>{if(!A)return R?R.dispose():A=!0,J.call(K,P)},null,re),A&&R.dispose(),R}}e.once=n;function s(q,J,K){return f((re,A=null,R)=>q(P=>re.call(A,J(P)),null,R),K)}e.map=s;function o(q,J,K){return f((re,A=null,R)=>q(P=>{J(P),re.call(A,P)},null,R),K)}e.forEach=o;function c(q,J,K){return f((re,A=null,R)=>q(P=>J(P)&&re.call(A,P),null,R),K)}e.filter=c;function d(q){return q}e.signal=d;function m(...q){return(J,K=null,re)=>{let A=_R(...q.map(R=>R(P=>J.call(K,P))));return y(A,re)}}e.any=m;function g(q,J,K,re){let A=K;return s(q,R=>(A=J(A,R),A),re)}e.reduce=g;function f(q,J){let K,re={onWillAddFirstListener(){K=q(A.fire,A)},onDidRemoveLastListener(){K?.dispose()}},A=new ke(re);return J?.add(A),A.event}function y(q,J){return J instanceof Array?J.push(q):J&&J.add(q),q}function b(q,J,K=100,re=!1,A=!1,R,P){let ne,ge,M,V=0,le,_e={leakWarningThreshold:R,onWillAddFirstListener(){ne=q(Ee=>{V++,ge=J(ge,Ee),re&&!M&&(be.fire(ge),ge=void 0),le=()=>{let Me=ge;ge=void 0,M=void 0,(!re||V>1)&&be.fire(Me),V=0},typeof K=="number"?(clearTimeout(M),M=setTimeout(le,K)):M===void 0&&(M=0,queueMicrotask(le))})},onWillRemoveListener(){A&&V>0&&le?.()},onDidRemoveLastListener(){le=void 0,ne.dispose()}},be=new ke(_e);return P?.add(be),be.event}e.debounce=b;function C(q,J=0,K){return e.debounce(q,(re,A)=>re?(re.push(A),re):[A],J,void 0,!0,void 0,K)}e.accumulate=C;function w(q,J=(re,A)=>re===A,K){let re=!0,A;return c(q,R=>{let P=re||!J(R,A);return re=!1,A=R,P},K)}e.latch=w;function x(q,J,K){return[e.filter(q,J,K),e.filter(q,re=>!J(re),K)]}e.split=x;function D(q,J=!1,K=[],re){let A=K.slice(),R=q(ge=>{A?A.push(ge):ne.fire(ge)});re&&re.add(R);let P=()=>{A?.forEach(ge=>ne.fire(ge)),A=null},ne=new ke({onWillAddFirstListener(){R||(R=q(ge=>ne.fire(ge)),re&&re.add(R))},onDidAddFirstListener(){A&&(J?setTimeout(P):P())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return re&&re.add(ne),ne.event}e.buffer=D;function B(q,J){return(K,re,A)=>{let R=J(new O);return q(function(P){let ne=R.evaluate(P);ne!==L&&K.call(re,ne)},void 0,A)}}e.chain=B;let L=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(J){return this.steps.push(J),this}forEach(J){return this.steps.push(K=>(J(K),K)),this}filter(J){return this.steps.push(K=>J(K)?K:L),this}reduce(J,K){let re=K;return this.steps.push(A=>(re=J(re,A),re)),this}latch(J=(K,re)=>K===re){let K=!0,re;return this.steps.push(A=>{let R=K||!J(A,re);return K=!1,re=A,R?A:L}),this}evaluate(J){for(let K of this.steps)if(J=K(J),J===L)break;return J}}function X(q,J,K=re=>re){let re=(...ne)=>P.fire(K(...ne)),A=()=>q.on(J,re),R=()=>q.removeListener(J,re),P=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return P.event}e.fromNodeEventEmitter=X;function U(q,J,K=re=>re){let re=(...ne)=>P.fire(K(...ne)),A=()=>q.addEventListener(J,re),R=()=>q.removeEventListener(J,re),P=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return P.event}e.fromDOMEventEmitter=U;function G(q){return new Promise(J=>n(q)(J))}e.toPromise=G;function F(q){let J=new ke;return q.then(K=>{J.fire(K)},()=>{J.fire(void 0)}).finally(()=>{J.dispose()}),J.event}e.fromPromise=F;function W(q,J){return q(K=>J.fire(K))}e.forward=W;function ve(q,J,K){return J(K),q(re=>J(re))}e.runAndSubscribe=ve;class Se{constructor(J,K){this._observable=J,this._counter=0,this._hasChanged=!1;let re={onWillAddFirstListener:()=>{J.addObserver(this)},onDidRemoveLastListener:()=>{J.removeObserver(this)}};this.emitter=new ke(re),K&&K.add(this.emitter)}beginUpdate(J){this._counter++}handlePossibleChange(J){}handleChange(J,K){this._hasChanged=!0}endUpdate(J){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function xe(q,J){return new Se(q,J).emitter.event}e.fromObservable=xe;function ie(q){return(J,K,re)=>{let A=0,R=!1,P={beginUpdate(){A++},endUpdate(){A--,A===0&&(q.reportChanges(),R&&(R=!1,J.call(K)))},handlePossibleChange(){},handleChange(){R=!0}};q.addObserver(P),q.reportChanges();let ne={dispose(){q.removeObserver(P)}};return re instanceof fa?re.add(ne):Array.isArray(re)&&re.push(ne),ne}}e.fromObservableLight=ie})(en||={});var Sg=class wg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wg._idPool++}`,wg.all.add(this)}start(t){this._stopWatch=new yR,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}}};Sg.all=new Set,Sg._idPool=0;var SR=Sg,wR=-1,_C=class bC{constructor(t,n,s=(bC._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,d]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(m),console.warn(c);let g=new kR(m,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};_C._idPool=1;var CR=_C,xR=class yC{constructor(t){this.value=t}static create(){let t=new Error;return new yC(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`+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)}},fR=new hR;function Zd(e){pR(e)||fR.onUnexpectedError(e)}var gg="Canceled";function pR(e){return e instanceof mR?!0:e instanceof Error&&e.name===gg&&e.message===gg}var mR=class extends Error{constructor(){super(gg),this.name=this.message}};function gR(e){return new Error(`Illegal argument: ${e}`)}var p0=class vg extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vg)return t;let n=new vg;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_g=class fC extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,fC.prototype)}};function Wn(e,t=0){return e[e.length-(1+t)]}var vR;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function s(c){return c>0}e.isGreaterThan=s;function l(c){return c===0}e.isNeitherLessOrGreaterThan=l,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(vR||={});function _R(e,t){let n=this,s=!1,l;return function(){return s||(s=!0,t||(l=e.apply(n,arguments))),l}}var pC;(e=>{function t(U){return U&&typeof U=="object"&&typeof U[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*l(U){yield U}e.single=l;function c(U){return t(U)?U:l(U)}e.wrap=c;function d(U){return U||n}e.from=d;function*m(U){for(let G=U.length-1;G>=0;G--)yield U[G]}e.reverse=m;function g(U){return!U||U[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(U){return U[Symbol.iterator]().next().value}e.first=f;function y(U,G){let W=0;for(let q of U)if(G(q,W++))return!0;return!1}e.some=y;function b(U,G){for(let W of U)if(G(W))return W}e.find=b;function*C(U,G){for(let W of U)G(W)&&(yield W)}e.filter=C;function*w(U,G){let W=0;for(let q of U)yield G(q,W++)}e.map=w;function*x(U,G){let W=0;for(let q of U)yield*G(q,W++)}e.flatMap=x;function*D(...U){for(let G of U)yield*G}e.concat=D;function B(U,G,W){let q=W;for(let ge of U)q=G(q,ge);return q}e.reduce=B;function*L(U,G,W=U.length){for(G<0&&(G+=U.length),W<0?W+=U.length:W>U.length&&(W=U.length);G<W;G++)yield U[G]}e.slice=L;function O(U,G=Number.POSITIVE_INFINITY){let W=[];if(G===0)return[W,U];let q=U[Symbol.iterator]();for(let ge=0;ge<G;ge++){let Se=q.next();if(Se.done)return[W,e.empty()];W.push(Se.value)}return[W,{[Symbol.iterator](){return q}}]}e.consume=O;async function X(U){let G=[];for await(let W of U)G.push(W);return Promise.resolve(G)}e.asyncToArray=X})(pC||={});function al(e){if(pC.is(e)){let t=[];for(let n of e)if(n)try{n.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 bR(...e){return Xt(()=>al(e))}function Xt(e){return{dispose:_R(()=>{e()})}}var mC=class gC{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{al(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?gC.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)}};mC.DISABLE_DISPOSED_WARNING=!1;var pa=mC,ut=class{constructor(){this._store=new pa,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)}};ut.None=Object.freeze({dispose(){}});var lo=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},gs=typeof window=="object"?window:globalThis,bg=class yg{constructor(t){this.element=t,this.next=yg.Undefined,this.prev=yg.Undefined}};bg.Undefined=new bg(void 0);var ti=bg,m0=class{constructor(){this._first=ti.Undefined,this._last=ti.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ti.Undefined}clear(){let e=this._first;for(;e!==ti.Undefined;){let t=e.next;e.prev=ti.Undefined,e.next=ti.Undefined,e=t}this._first=ti.Undefined,this._last=ti.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ti(e);if(this._first===ti.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ti.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ti.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ti.Undefined&&e.next!==ti.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ti.Undefined&&e.next===ti.Undefined?(this._first=ti.Undefined,this._last=ti.Undefined):e.next===ti.Undefined?(this._last=this._last.prev,this._last.next=ti.Undefined):e.prev===ti.Undefined&&(this._first=this._first.next,this._first.prev=ti.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ti.Undefined;)yield e.element,e=e.next}},yR=globalThis.performance&&typeof globalThis.performance.now=="function",SR=class vC{static create(t){return new vC(t)}constructor(t){this._now=yR&&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}},en;(e=>{e.None=()=>ut.None;function t($,J){return b($,()=>{},0,void 0,!0,void 0,J)}e.defer=t;function n($){return(J,K=null,se)=>{let A=!1,R;return R=$(z=>{if(!A)return R?R.dispose():A=!0,J.call(K,z)},null,se),A&&R.dispose(),R}}e.once=n;function s($,J,K){return f((se,A=null,R)=>$(z=>se.call(A,J(z)),null,R),K)}e.map=s;function l($,J,K){return f((se,A=null,R)=>$(z=>{J(z),se.call(A,z)},null,R),K)}e.forEach=l;function c($,J,K){return f((se,A=null,R)=>$(z=>J(z)&&se.call(A,z),null,R),K)}e.filter=c;function d($){return $}e.signal=d;function m(...$){return(J,K=null,se)=>{let A=bR(...$.map(R=>R(z=>J.call(K,z))));return y(A,se)}}e.any=m;function g($,J,K,se){let A=K;return s($,R=>(A=J(A,R),A),se)}e.reduce=g;function f($,J){let K,se={onWillAddFirstListener(){K=$(A.fire,A)},onDidRemoveLastListener(){K?.dispose()}},A=new ke(se);return J?.add(A),A.event}function y($,J){return J instanceof Array?J.push($):J&&J.add($),$}function b($,J,K=100,se=!1,A=!1,R,z){let ne,_e,M,F=0,ie,ve={leakWarningThreshold:R,onWillAddFirstListener(){ne=$(Ee=>{F++,_e=J(_e,Ee),se&&!M&&(be.fire(_e),_e=void 0),ie=()=>{let Me=_e;_e=void 0,M=void 0,(!se||F>1)&&be.fire(Me),F=0},typeof K=="number"?(clearTimeout(M),M=setTimeout(ie,K)):M===void 0&&(M=0,queueMicrotask(ie))})},onWillRemoveListener(){A&&F>0&&ie?.()},onDidRemoveLastListener(){ie=void 0,ne.dispose()}},be=new ke(ve);return z?.add(be),be.event}e.debounce=b;function C($,J=0,K){return e.debounce($,(se,A)=>se?(se.push(A),se):[A],J,void 0,!0,void 0,K)}e.accumulate=C;function w($,J=(se,A)=>se===A,K){let se=!0,A;return c($,R=>{let z=se||!J(R,A);return se=!1,A=R,z},K)}e.latch=w;function x($,J,K){return[e.filter($,J,K),e.filter($,se=>!J(se),K)]}e.split=x;function D($,J=!1,K=[],se){let A=K.slice(),R=$(_e=>{A?A.push(_e):ne.fire(_e)});se&&se.add(R);let z=()=>{A?.forEach(_e=>ne.fire(_e)),A=null},ne=new ke({onWillAddFirstListener(){R||(R=$(_e=>ne.fire(_e)),se&&se.add(R))},onDidAddFirstListener(){A&&(J?setTimeout(z):z())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return se&&se.add(ne),ne.event}e.buffer=D;function B($,J){return(K,se,A)=>{let R=J(new O);return $(function(z){let ne=R.evaluate(z);ne!==L&&K.call(se,ne)},void 0,A)}}e.chain=B;let L=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(J){return this.steps.push(J),this}forEach(J){return this.steps.push(K=>(J(K),K)),this}filter(J){return this.steps.push(K=>J(K)?K:L),this}reduce(J,K){let se=K;return this.steps.push(A=>(se=J(se,A),se)),this}latch(J=(K,se)=>K===se){let K=!0,se;return this.steps.push(A=>{let R=K||!J(A,se);return K=!1,se=A,R?A:L}),this}evaluate(J){for(let K of this.steps)if(J=K(J),J===L)break;return J}}function X($,J,K=se=>se){let se=(...ne)=>z.fire(K(...ne)),A=()=>$.on(J,se),R=()=>$.removeListener(J,se),z=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return z.event}e.fromNodeEventEmitter=X;function U($,J,K=se=>se){let se=(...ne)=>z.fire(K(...ne)),A=()=>$.addEventListener(J,se),R=()=>$.removeEventListener(J,se),z=new ke({onWillAddFirstListener:A,onDidRemoveLastListener:R});return z.event}e.fromDOMEventEmitter=U;function G($){return new Promise(J=>n($)(J))}e.toPromise=G;function W($){let J=new ke;return $.then(K=>{J.fire(K)},()=>{J.fire(void 0)}).finally(()=>{J.dispose()}),J.event}e.fromPromise=W;function q($,J){return $(K=>J.fire(K))}e.forward=q;function ge($,J,K){return J(K),$(se=>J(se))}e.runAndSubscribe=ge;class Se{constructor(J,K){this._observable=J,this._counter=0,this._hasChanged=!1;let se={onWillAddFirstListener:()=>{J.addObserver(this)},onDidRemoveLastListener:()=>{J.removeObserver(this)}};this.emitter=new ke(se),K&&K.add(this.emitter)}beginUpdate(J){this._counter++}handlePossibleChange(J){}handleChange(J,K){this._hasChanged=!0}endUpdate(J){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function xe($,J){return new Se($,J).emitter.event}e.fromObservable=xe;function re($){return(J,K,se)=>{let A=0,R=!1,z={beginUpdate(){A++},endUpdate(){A--,A===0&&($.reportChanges(),R&&(R=!1,J.call(K)))},handlePossibleChange(){},handleChange(){R=!0}};$.addObserver(z),$.reportChanges();let ne={dispose(){$.removeObserver(z)}};return se instanceof pa?se.add(ne):Array.isArray(se)&&se.push(ne),ne}}e.fromObservableLight=re})(en||={});var Sg=class wg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wg._idPool++}`,wg.all.add(this)}start(t){this._stopWatch=new SR,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}}};Sg.all=new Set,Sg._idPool=0;var wR=Sg,CR=-1,_C=class bC{constructor(t,n,s=(bC._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let l=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,l+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,d]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(m),console.warn(c);let g=new ER(m,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,l]of this._stacks)(!t||n<l)&&(t=[s,l],n=l);return t}};_C._idPool=1;var xR=_C,kR=class yC{constructor(t){this.value=t}static create(){let t=new Error;return new yC(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
23
|
`).slice(2).join(`
|
|
24
|
-
`))}},kR=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ER=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},TR=0,fm=class{constructor(e){this.value=e,this.id=TR++}},DR=2,RR,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new CR(e?.onListenerError??Zd,this._options?.leakWarningThreshold??wR):void 0,this._perfMon=this._options?._profName?new SR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new ER(`${d}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||Zd)(g),ut.None}if(this._disposed)return ut.None;t&&(e=e.bind(t));let s=new fm(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=xR.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof fm?(this._deliveryQueue??=new MR,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Xt(()=>{o?.(),this._removeListener(s)});return n instanceof fa?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-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[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*DR<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:s&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Zd;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof fm)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},MR=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cg.INSTANCE=new Cg;var Qv=Cg;function NR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Qv.INSTANCE.onDidChangeZoomLevel;function AR(e){return Qv.INSTANCE.getZoomFactor(e)}Qv.INSTANCE.onDidChangeFullscreen;var gl=typeof navigator=="object"?navigator.userAgent:"",xg=gl.indexOf("Firefox")>=0,LR=gl.indexOf("AppleWebKit")>=0,Jv=gl.indexOf("Chrome")>=0,BR=!Jv&&gl.indexOf("Safari")>=0;gl.indexOf("Electron/")>=0;gl.indexOf("Android")>=0;var pm=!1;if(typeof ms.matchMedia=="function"){let e=ms.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ms.matchMedia("(display-mode: fullscreen)");pm=e.matches,NR(ms,e,({matches:n})=>{pm&&t.matches||(pm=n)})}var Qo="en",kg=!1,Eg=!1,Qd=!1,SC=!1,Od,Jd=Qo,g0=Qo,OR,hs,to=globalThis,qn;typeof to.vscode<"u"&&typeof to.vscode.process<"u"?qn=to.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(qn=process);var jR=typeof qn?.versions?.electron=="string",zR=jR&&qn?.type==="renderer";if(typeof qn=="object"){kg=qn.platform==="win32",Eg=qn.platform==="darwin",Qd=qn.platform==="linux",Qd&&qn.env.SNAP&&qn.env.SNAP_REVISION,qn.env.CI||qn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Od=Qo,Jd=Qo;let e=qn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Od=t.userLocale,g0=t.osLocale,Jd=t.resolvedLanguage||Qo,OR=t.languagePack?.translationsConfigFile}catch{}SC=!0}else typeof navigator=="object"&&!zR?(hs=navigator.userAgent,kg=hs.indexOf("Windows")>=0,Eg=hs.indexOf("Macintosh")>=0,(hs.indexOf("Macintosh")>=0||hs.indexOf("iPad")>=0||hs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Qd=hs.indexOf("Linux")>=0,hs?.indexOf("Mobi")>=0,Jd=globalThis._VSCODE_NLS_LANGUAGE||Qo,Od=navigator.language.toLowerCase(),g0=Od):console.error("Unable to resolve platform.");var wC=kg,Ir=Eg,PR=Qd,v0=SC,Hr=hs,ta=Jd,IR;(e=>{function t(){return ta}e.value=t;function n(){return ta.length===2?ta==="en":ta.length>=3?ta[0]==="e"&&ta[1]==="n"&&ta[2]==="-":!1}e.isDefaultVariant=n;function s(){return ta==="en"}e.isDefault=s})(IR||={});var HR=typeof to.postMessage=="function"&&!to.importScripts;(()=>{if(HR){let e=[];to.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let c=e[s];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),to.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var UR=!!(Hr&&Hr.indexOf("Chrome")>=0);Hr&&Hr.indexOf("Firefox")>=0;!UR&&Hr&&Hr.indexOf("Safari")>=0;Hr&&Hr.indexOf("Edg/")>=0;Hr&&Hr.indexOf("Android")>=0;var $o=typeof navigator=="object"?navigator:{};v0||document.queryCommandSupported&&document.queryCommandSupported("copy")||$o&&$o.clipboard&&$o.clipboard.writeText,v0||$o&&$o.clipboard&&$o.clipboard.readText;var e_=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}},mm=new e_,_0=new e_,b0=new e_,KR=new Array(230),CC;(e=>{function t(m){return mm.keyCodeToStr(m)}e.toString=t;function n(m){return mm.strToKeyCode(m)}e.fromString=n;function s(m){return _0.keyCodeToStr(m)}e.toUserSettingsUS=s;function o(m){return b0.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return _0.strToKeyCode(m)||b0.strToKeyCode(m)}e.fromUserSettings=c;function d(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return mm.keyCodeToStr(m)}e.toElectronAccelerator=d})(CC||={});var FR=class xC{constructor(t,n,s,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof xC&&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",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new WR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},WR=class{constructor(e){if(e.length===0)throw mR("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;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 qR(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return CC.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(xg)switch(t){case 59:return 85;case 60:if(PR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ir)return 57;break}else if(LR&&(Ir&&t===93||!Ir&&t===92))return 57;return KR[t]||0}var $R=Ir?256:2048,VR=512,YR=1024,XR=Ir?2048:256,y0=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=qR(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|=$R),this.altKey&&(t|=VR),this.shiftKey&&(t|=YR),this.metaKey&&(t|=XR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new FR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},S0=new WeakMap;function GR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var ZR=class{static getSameOriginWindowChain(e){let t=S0.get(e);if(!t){t=[],S0.set(e,t);let n=e,s;do s=GR(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let c of o){let d=c.window.deref();if(n+=d?.scrollY??0,s+=d?.scrollX??0,d===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,s+=m.left}return{top:n,left:s}}},jd=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 n=ZR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},w0=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(Jv){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,d=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*d):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?xg&&!Ir?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")BR&&wC?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*d):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?xg&&!Ir?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*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},kC=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),QR;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof JR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:en.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kC})})(QR||={});var JR=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?kC:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},t_=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 _g("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _g("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},eM=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new _g("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Xt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tM;(e=>{async function t(s){let o,c=await Promise.all(s.map(d=>d.then(m=>m,m=>{o||(o=m)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(s){return new Promise(async(o,c)=>{try{await s(o,c)}catch(d){c(d)}})}e.withAsyncBody=n})(tM||={});var C0=class rr{static fromArray(t){return new rr(n=>{n.emitMany(t)})}static fromPromise(t){return new rr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new rr(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new rr(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}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 en.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new rr(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return rr.map(this,t)}static filter(t,n){return new rr(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return rr.filter(this,t)}static coalesce(t){return rr.filter(t,n=>!!n)}coalesce(){return rr.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return rr.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())}};C0.EMPTY=C0.fromArray([]);var{getWindow:Pr,getWindowId:iM,onDidRegisterWindow:nM}=(function(){let e=new Map,t={window:ms,disposables:new fa};e.set(ms.vscodeWindowId,t);let n=new ke,s=new ke,o=new ke;function c(d,m){return(typeof d=="number"?e.get(d):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(d){if(e.has(d.vscodeWindowId))return ut.None;let m=new fa,g={window:d,disposables:m.add(new fa)};return e.set(d.vscodeWindowId,g),m.add(Xt(()=>{e.delete(d.vscodeWindowId),s.fire(d)})),m.add(Ze(d,Ki.BEFORE_UNLOAD,()=>{o.fire(d)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:c,getWindow(d){let m=d;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=d;return g?.view?g.view.window:ms},getDocument(d){return Pr(d).document}}})(),rM=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,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 Ze(e,t,n,s){return new rM(e,t,n,s)}var x0=function(e,t,n,s){return Ze(e,t,n,s)},i_,sM=class extends eM{constructor(e){super(),this.defaultTarget=e&&Pr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},k0=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){Zd(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=c=>{n.set(c,!1);let d=e.get(c)??[];for(t.set(c,d),e.set(c,[]),s.set(c,!0);d.length>0;)d.sort(k0.sort),d.shift().execute();s.set(c,!1)};i_=(c,d,m=0)=>{let g=iM(c),f=new k0(d,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(f),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),f}})();function aM(e){let t=e.getBoundingClientRect(),n=Pr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ki={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"},oM=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=Tn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Tn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Tn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Tn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Tn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Tn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Tn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Tn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Tn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Tn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Tn(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=Tn(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=Tn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Tn(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 Tn(e){return typeof e=="number"?`${e}px`:e}function Pc(e){return new oM(e)}var EC=class{constructor(){this._hooks=new fa,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 n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(Xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Pr(e)}this._hooks.add(Ze(c,Ki.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(Ze(c,Ki.POINTER_UP,d=>this.stopMonitoring(!0)))}};function lM(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[s]=function(...d){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,d)}),this[c]}}var zr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(zr||={});var Cc=class an extends ut{constructor(){super(),this.dispatched=!1,this.targets=new m0,this.ignoreTargets=new m0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(en.runAndSubscribe(nM,({window:t,disposables:n})=>{n.add(Ze(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ze(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ze(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ms,disposables:this._store}))}static addTarget(t){if(!an.isTouchDevice())return ut.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.targets.push(t);return Xt(n)}static ignoreTarget(t){if(!an.isTouchDevice())return ut.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.ignoreTargets.push(t);return Xt(n)}static isTouchDevice(){return"ontouchstart"in ms||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let d=this.newGestureEvent(zr.Start,c.target);d.pageX=c.pageX,d.pageY=c.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,d=n.changedTouches.length;c<d;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],f=Date.now()-g.initialTimeStamp;if(f<an.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(zr.Tap,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(f>=an.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(zr.Contextmenu,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Fn(g.rollingPageX),b=Fn(g.rollingPageY),C=Fn(g.rollingTimestamps)-g.rollingTimestamps[0],w=y-g.rollingPageX[0],x=b-g.rollingPageY[0],D=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(w)/C,w>0?1:-1,y,Math.abs(x)/C,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(zr.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===zr.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>an.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===zr.Change||t.type===zr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==s;)o++,c=c.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,c,d,m,g,f){this.handle=i_(t,()=>{let y=Date.now(),b=y-s,C=0,w=0,x=!0;o+=an.SCROLL_FRICTION*b,m+=an.SCROLL_FRICTION*b,o>0&&(x=!1,C=c*o*b),m>0&&(x=!1,w=g*m*b);let D=this.newGestureEvent(zr.Change);D.translationX=C,D.translationY=w,n.forEach(B=>B.dispatchEvent(D)),x||this.inertia(t,n,y,o,c,d+C,m,g,f+w)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],m=this.newGestureEvent(zr.Change,d.initialTarget);m.translationX=c.pageX-Fn(d.rollingPageX),m.translationY=c.pageY-Fn(d.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(c.pageX),d.rollingPageY.push(c.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Cc.SCROLL_FRICTION=-.005,Cc.HOLD_DELAY=700,Cc.CLEAR_TAP_COUNT_TIME=400,ui([lM],Cc,"isTouchDevice",1);var cM=Cc,n_=class extends ut{onclick(e,t){this._register(Ze(e,Ki.CLICK,n=>t(new jd(Pr(e),n))))}onmousedown(e,t){this._register(Ze(e,Ki.MOUSE_DOWN,n=>t(new jd(Pr(e),n))))}onmouseover(e,t){this._register(Ze(e,Ki.MOUSE_OVER,n=>t(new jd(Pr(e),n))))}onmouseleave(e,t){this._register(Ze(e,Ki.MOUSE_LEAVE,n=>t(new jd(Pr(e),n))))}onkeydown(e,t){this._register(Ze(e,Ki.KEY_DOWN,n=>t(new y0(n))))}onkeyup(e,t){this._register(Ze(e,Ki.KEY_UP,n=>t(new y0(n))))}oninput(e,t){this._register(Ze(e,Ki.INPUT,t))}onblur(e,t){this._register(Ze(e,Ki.BLUR,t))}onfocus(e,t){this._register(Ze(e,Ki.FOCUS,t))}onchange(e,t){this._register(Ze(e,Ki.CHANGE,t))}ignoreGesture(e){return cM.ignoreTarget(e)}},E0=11,uM=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=E0+"px",this.domNode.style.height=E0+"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 EC),this._register(x0(this.bgDomNode,Ki.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(x0(this.domNode,Ki.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new sM),this._pointerdownScheduleRepeatTimer=this._register(new t_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Pr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},dM=class Tg{constructor(t,n,s,o,c,d,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,c=c|0,d=d|0,m=m|0),this.rawScrollLeft=o,this.rawScrollTop=m,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),c<0&&(c=0),m+c>d&&(m=d-c),m<0&&(m=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=c,this.scrollHeight=d,this.scrollTop=m}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,n){return new Tg(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Tg(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,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,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:o,scrollLeftChanged:c,heightChanged:d,scrollHeightChanged:m,scrollTopChanged:g}}},hM=class extends ut{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new dM(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new D0(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=D0.start(this._state,n,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 n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},T0=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function gm(e,t){let n=t-e;return function(s){return e+n*mM(s)}}function fM(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var D0=class Dg{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,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,n,s){if(Math.abs(t-n)>2.5*s){let o,c;return t<n?(o=t+.75*s,c=n-.75*s):(o=t-.75*s,c=n+.75*s),fM(gm(t,o),gm(c,n),.33)}return gm(t,n)}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 n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new T0(s,o,!1)}return new T0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Dg.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Dg(t,n,o,s)}};function pM(e){return Math.pow(e,3)}function mM(e){return 1-pM(1-e)}var gM=class extends ut{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new t_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},vM=140,TC=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 gM(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new EC),this._shouldRender=!0,this.domNode=Pc(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(Ze(this.domNode.domNode,Ki.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new uM(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Pc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ze(this.slider.domNode,Ki.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.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,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=aM(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);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),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),d=Math.abs(c-n);if(wC&&d>vM){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let m=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(m))},()=>{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()}},DC=class Rg{constructor(t,n,s,o,c,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Rg(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,c){let d=Math.max(0,s-t),m=Math.max(0,d-2*n),g=o>0&&o>s;if(!g)return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*m/o))),y=(m-f)/(o-s),b=c*y;return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Rg._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 n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},_M=class extends TC{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new DC(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.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}},bM=class extends TC{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new DC(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.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}},yM=500,R0=50,SM=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Mg=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,n=0,s=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-s);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Jv){let n=Pr(t.browserEvent),s=AR(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,c=new SM(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=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]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){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),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),d=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,d),1),f=Math.max(Math.min(c,m),1),y=Math.max(o,d),b=Math.max(c,m);y%g===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mg.INSTANCE=new Mg;var wM=Mg,CM=class extends n_{constructor(e,t,n){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=kM(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new bM(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _M(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=Pc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Pc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Pc(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,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new t_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ao(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,Ir&&(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 w0(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ao(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new w0(n))};this._mouseWheelToDispose.push(Ze(this._listenOnDomNode,Ki.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=wM.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let d=!Ir&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(o){let f=R0*o,y=m.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let f=R0*c,y=m.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let s=n;!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,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${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(),yM)}},xM=class extends CM{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function kM(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,Ir&&(t.className+=" mac"),t}var Ng=class extends ut{constructor(e,t,n,s,o,c,d,m){super(),this._bufferService=n,this._optionsService=d,this._renderService=m,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new hM({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>i_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new xM(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(en.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Xt(()=>this._styleElement.remove())),this._register(en.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
25
|
-
`)})),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(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Ng=ui([Le(2,pn),Le(3,bs),Le(4,lC),Le(5,ml),Le(6,mn),Le(7,ys)],Ng);var Ag=class extends ut{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,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(c=>this._removeDecoration(c))),this._register(Xt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>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 n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Ag=ui([Le(1,pn),Le(2,bs),Le(3,au),Le(4,ys)],Ag);var EM=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,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Or={full:0,left:0,center:0,right:0},ia={full:0,left:0,center:0,right:0},fc={full:0,left:0,center:0,right:0},_h=class extends ut{constructor(e,t,n,s,o,c,d,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=c,this._themeService=d,this._coreBrowserService=m,this._colorZoneStore=new EM,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Xt(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ia.full=this._canvas.width,ia.left=e,ia.center=t,ia.right=e,this._refreshDrawHeightConstants(),fc.full=1,fc.left=1,fc.center=1+ia.left,fc.right=1+ia.left+ia.center}_refreshDrawHeightConstants(){Or.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);Or.left=t,Or.center=t,Or.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.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(fc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Or[e.position||"full"]/2),ia[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Or[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}))}};_h=ui([Le(2,pn),Le(3,au),Le(4,ys),Le(5,mn),Le(6,ml),Le(7,bs)],_h);var me;(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=`
|
|
26
|
-
`,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=""))(me||={});var eh;(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=""))(eh||={});var RC;(e=>e.ST=`${me.ESC}\\`)(RC||={});var Lg=class{constructor(e,t,n,s,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=c,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 n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!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,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${me.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),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Lg=ui([Le(2,pn),Le(3,mn),Le(4,lo),Le(5,ys)],Lg);var Wi=0,qi=0,$i=0,ci=0,M0={css:"#00000000",rgba:0},ki;(e=>{function t(o,c,d,m){return m!==void 0?`#${Xa(o)}${Xa(c)}${Xa(d)}${Xa(m)}`:`#${Xa(o)}${Xa(c)}${Xa(d)}`}e.toCss=t;function n(o,c,d,m=255){return(o<<24|c<<16|d<<8|m)>>>0}e.toRgba=n;function s(o,c,d,m){return{css:e.toCss(o,c,d,m),rgba:e.toRgba(o,c,d,m)}}e.toColor=s})(ki||={});var qt;(e=>{function t(g,f){if(ci=(f.rgba&255)/255,ci===1)return{css:f.css,rgba:f.rgba};let y=f.rgba>>24&255,b=f.rgba>>16&255,C=f.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Wi=w+Math.round((y-w)*ci),qi=x+Math.round((b-x)*ci),$i=D+Math.round((C-D)*ci);let B=ki.toCss(Wi,qi,$i),L=ki.toRgba(Wi,qi,$i);return{css:B,rgba:L}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,f,y){let b=th.ensureContrastRatio(g.rgba,f.rgba,y);if(b)return ki.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(g){let f=(g.rgba|255)>>>0;return[Wi,qi,$i]=th.toChannels(f),{css:ki.toCss(Wi,qi,$i),rgba:f}}e.opaque=o;function c(g,f){return ci=Math.round(f*255),[Wi,qi,$i]=th.toChannels(g.rgba),{css:ki.toCss(Wi,qi,$i,ci),rgba:ki.toRgba(Wi,qi,$i,ci)}}e.opacity=c;function d(g,f){return ci=g.rgba&255,c(g,ci*f/255)}e.multiplyOpacity=d;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(qt||={});var ii;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Wi=parseInt(o.slice(1,2).repeat(2),16),qi=parseInt(o.slice(2,3).repeat(2),16),$i=parseInt(o.slice(3,4).repeat(2),16),ki.toColor(Wi,qi,$i);case 5:return Wi=parseInt(o.slice(1,2).repeat(2),16),qi=parseInt(o.slice(2,3).repeat(2),16),$i=parseInt(o.slice(3,4).repeat(2),16),ci=parseInt(o.slice(4,5).repeat(2),16),ki.toColor(Wi,qi,$i,ci);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Wi=parseInt(c[1]),qi=parseInt(c[2]),$i=parseInt(c[3]),ci=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ki.toColor(Wi,qi,$i,ci);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wi,qi,$i,ci]=t.getImageData(0,0,1,1).data,ci!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ki.toRgba(Wi,qi,$i,ci),css:o}}e.toColor=s})(ii||={});var hn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,c){let d=s/255,m=o/255,g=c/255,f=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(hn||={});var th;(e=>{function t(d,m){if(ci=(m&255)/255,ci===1)return m;let g=m>>24&255,f=m>>16&255,y=m>>8&255,b=d>>24&255,C=d>>16&255,w=d>>8&255;return Wi=b+Math.round((g-b)*ci),qi=C+Math.round((f-C)*ci),$i=w+Math.round((y-w)*ci),ki.toRgba(Wi,qi,$i)}e.blend=t;function n(d,m,g){let f=hn.relativeLuminance(d>>8),y=hn.relativeLuminance(m>>8);if(ds(f,y)<g){if(y<f){let w=s(d,m,g),x=ds(f,hn.relativeLuminance(w>>8));if(x<g){let D=o(d,m,g),B=ds(f,hn.relativeLuminance(D>>8));return x>B?w:D}return w}let b=o(d,m,g),C=ds(f,hn.relativeLuminance(b>>8));if(C<g){let w=s(d,m,g),x=ds(f,hn.relativeLuminance(w>>8));return C>x?b:w}return b}}e.ensureContrastRatio=n;function s(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,C=m>>24&255,w=m>>16&255,x=m>>8&255,D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));for(;D<g&&(C>0||w>0||x>0);)C-=Math.max(0,Math.ceil(C*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));return(C<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=s;function o(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,C=m>>24&255,w=m>>16&255,x=m>>8&255,D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));for(;D<g&&(C<255||w<255||x<255);)C=Math.min(255,C+Math.ceil((255-C)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));return(C<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=o;function c(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=c})(th||={});function Xa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ds(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var TM=class extends su{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}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()]}},bh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ur}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 n=[],s=t.translateToString(!0),o=0,c=0,d=0,m=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(f-o>1){let y=this._getJoinedRanges(s,d,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=f,d=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||da.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,d,c,t,o);for(let y=0;y<f.length;y++)n.push(f[y])}return n}_getJoinedRanges(e,t,n,s,o){let c=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let f=0;f<g.length;f++)bh._mergeRanges(d,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(d,s,o),d}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,c=0,d=e[s];if(d){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),f=t.getString(m).length||da.length;if(g!==0){if(!o&&d[0]<=c&&(d[0]=m,o=!0),d[1]<=c){if(d[1]=m,d=e[++s],!d)break;d[0]<=c?(d[0]=m,o=!0):o=!1}c+=f}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};bh=ui([Le(0,pn)],bh);function DM(e){return 57508<=e&&e<=57558}function RM(e){return 9472<=e&&e<=9631}function MM(e){return DM(e)||RM(e)}function NM(){return{css:{canvas:zd(),cell:zd()},device:{canvas:zd(),cell:zd(),char:{width:0,height:0,left:0,top:0}}}}function zd(){return{width:0,height:0}}var Bg=class{constructor(e,t,n,s,o,c,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=c,this._themeService=d,this._workCell=new ur,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,c,d,m,g,f,y){let b=[],C=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<c+1&&(x=c+1);let D,B=0,L="",O=0,X=0,U=0,G=0,F=!1,W=0,ve=!1,Se=0,xe=0,ie=[],q=f!==-1&&y!==-1;for(let J=0;J<x;J++){e.loadCell(J,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let re=!1,A=J>=xe,R=J,P=this._workCell;if(C.length>0&&J===C[0][0]&&A){let ye=C.shift(),Oe=this._isCellInSelection(ye[0],t);for(O=ye[0]+1;O<ye[1];O++)A&&=Oe===this._isCellInSelection(O,t);A&&=!n||c<ye[0]||c>=ye[1],A?(re=!0,P=new TM(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),R=ye[1]-1,K=P.getWidth()):xe=ye[1]}let ne=this._isCellInSelection(J,t),ge=n&&J===c,M=q&&J>=f&&J<=y,V=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,ye=>{V=!0});let le=P.getChars()||da;if(le===" "&&(P.isUnderline()||P.isOverline())&&(le=" "),Se=K*m-g.get(le,P.isBold(),P.isItalic()),!D)D=this._document.createElement("span");else if(B&&(ne&&ve||!ne&&!ve&&P.bg===X)&&(ne&&ve&&w.selectionForeground||P.fg===U)&&P.extended.ext===G&&M===F&&Se===W&&!ge&&!re&&!V&&A){P.isInvisible()?L+=da:L+=le,B++;continue}else B&&(D.textContent=L),D=this._document.createElement("span"),B=0,L="";if(X=P.bg,U=P.fg,G=P.extended.ext,F=M,W=Se,ve=ne,re&&c>=J&&c<=R&&(c=J),!this._coreService.isCursorHidden&&ge&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&ie.push("xterm-cursor-blink"),ie.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(P.isBold()&&ie.push("xterm-bold"),P.isItalic()&&ie.push("xterm-italic"),P.isDim()&&ie.push("xterm-dim"),P.isInvisible()?L=da:L=P.getChars()||da,P.isUnderline()&&(ie.push(`xterm-underline-${P.extended.underlineStyle}`),L===" "&&(L=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${su.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let ye=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&ye<8&&(ye+=8),D.style.textDecorationColor=w.ansi[ye].css}P.isOverline()&&(ie.push("xterm-overline"),L===" "&&(L=" ")),P.isStrikethrough()&&ie.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let _e=P.getFgColor(),be=P.getFgColorMode(),Ee=P.getBgColor(),Me=P.getBgColorMode(),Re=!!P.isInverse();if(Re){let ye=_e;_e=Ee,Ee=ye;let Oe=be;be=Me,Me=Oe}let Pe,Be,oe=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,ye=>{ye.options.layer!=="top"&&oe||(ye.backgroundColorRGB&&(Me=50331648,Ee=ye.backgroundColorRGB.rgba>>8&16777215,Pe=ye.backgroundColorRGB),ye.foregroundColorRGB&&(be=50331648,_e=ye.foregroundColorRGB.rgba>>8&16777215,Be=ye.foregroundColorRGB),oe=ye.options.layer==="top")}),!oe&&ne&&(Pe=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Ee=Pe.rgba>>8&16777215,Me=50331648,oe=!0,w.selectionForeground&&(be=50331648,_e=w.selectionForeground.rgba>>8&16777215,Be=w.selectionForeground)),oe&&ie.push("xterm-decoration-top");let he;switch(Me){case 16777216:case 33554432:he=w.ansi[Ee],ie.push(`xterm-bg-${Ee}`);break;case 50331648:he=ki.toColor(Ee>>16,Ee>>8&255,Ee&255),this._addStyle(D,`background-color:#${N0((Ee>>>0).toString(16),"0",6)}`);break;default:Re?(he=w.foreground,ie.push("xterm-bg-257")):he=w.background}switch(Pe||P.isDim()&&(Pe=qt.multiplyOpacity(he,.5)),be){case 16777216:case 33554432:P.isBold()&&_e<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(_e+=8),this._applyMinimumContrast(D,he,w.ansi[_e],P,Pe,void 0)||ie.push(`xterm-fg-${_e}`);break;case 50331648:let ye=ki.toColor(_e>>16&255,_e>>8&255,_e&255);this._applyMinimumContrast(D,he,ye,P,Pe,Be)||this._addStyle(D,`color:#${N0(_e.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,he,w.foreground,P,Pe,Be)||Re&&ie.push("xterm-fg-257")}ie.length&&(D.className=ie.join(" "),ie.length=0),!ge&&!re&&!V&&A?B++:D.textContent=L,Se!==this.defaultSpacing&&(D.style.letterSpacing=`${Se}px`),b.push(D),J=R}return D&&B&&(D.textContent=L),b}_applyMinimumContrast(e,t,n,s,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||MM(s.getCode()))return!1;let d=this._getContrastCache(s),m;if(!o&&!c&&(m=d.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);m=qt.ensureContrastRatio(o||t,c||n,g),d.setColor((o||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.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 n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};Bg=ui([Le(1,dC),Le(2,mn),Le(3,bs),Le(4,lo),Le(5,au),Le(6,ml)],Bg);function N0(e,t,n){for(;e.length<n;)e=t+e;return e}var AM=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 n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,s,o,c],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(c),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,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let d=0;t&&(d|=1),n&&(d|=2),c=this._measure(e,d),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},LM=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,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,d=n[1]-o,m=Math.max(c,0),g=Math.min(d,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=d,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function BM(){return new LM}var vm="xterm-dom-renderer-owner-",nr="xterm-rows",Pd="xterm-fg-",A0="xterm-bg-",pc="xterm-focus",Id="xterm-selection",OM=1,Og=class extends ut{constructor(e,t,n,s,o,c,d,m,g,f,y,b,C,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=c,this._linkifier2=d,this._charSizeService=g,this._optionsService=f,this._bufferService=y,this._coreService=b,this._coreBrowserService=C,this._themeService=w,this._terminalClass=OM++,this._rowElements=[],this._selectionRenderModel=BM(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(nr),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(Id),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=NM(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(Bg,document),this._element.classList.add(vm+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(Xt(()=>{this._element.classList.remove(vm+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new AM(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${nr} 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} .${nr} { 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} .${nr} .xterm-dim { color: ${qt.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 n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${nr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${nr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${nr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${nr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${nr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${nr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${nr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${nr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Id} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Id} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Id} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())t+=`${this._terminalSelector} .${Pd}${c} { color: ${d.css}; }${this._terminalSelector} .${Pd}${c}.xterm-dim { color: ${qt.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${A0}${c} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${Pd}257 { color: ${qt.opaque(e.background).css}; }${this._terminalSelector} .${Pd}257.xterm-dim { color: ${qt.multiplyOpacity(qt.opaque(e.background),.5).css}; }${this._terminalSelector} .${A0}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 n=this._rowElements.length;n<=t;n++){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(pc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(pc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],d-c+1))}else{let g=s===c?e[0]:0,f=c===o?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,f));let y=d-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==d){let b=o===d?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(d,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return c+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-c),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${d}px`,o}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 n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(f);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,f,f===s,d,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${vm}${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,n,s,o,c){n<0&&(e=0),s<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),s=Math.max(Math.min(s,d),0),o=Math.min(o,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,f=Math.min(m.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,C=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=s;++w){let x=w+m.ydisp,D=this._rowElements[w],B=m.lines.get(x);if(!D||!B)break;D.replaceChildren(...this._rowFactory.createRow(B,x,x===g,b,C,f,y,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===s?t:o)-1:-1))}}};Og=ui([Le(7,Gv),Le(8,Kh),Le(9,mn),Le(10,pn),Le(11,lo),Le(12,bs),Le(13,ml)],Og);var jg=class extends ut{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new zM(this._optionsService))}catch{this._measureStrategy=this._register(new jM(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())}};jg=ui([Le(2,mn)],jg);var MC=class extends ut{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)}},jM=class extends MC{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,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}},zM=class extends MC{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}},PM=class extends ut{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new IM(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(en.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ze(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ze(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}},IM=class extends ut{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ll),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ze(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},HM=class extends ut{constructor(){super(),this.linkProviders=[],this._register(Xt(()=>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 r_(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),d=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-d]}function UM(e,t,n,s,o,c,d,m,g){if(!c)return;let f=r_(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(g?d/2:0))/d),f[1]=Math.ceil(f[1]/m),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var zg=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return UM(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=r_(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};zg=ui([Le(0,ys),Le(1,Kh)],zg);var KM=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,n){this._rowCount=n,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=[]}},NC={};QD(NC,{getSafariVersion:()=>WM,isChromeOS:()=>OC,isFirefox:()=>AC,isIpad:()=>qM,isIphone:()=>$M,isLegacyEdge:()=>FM,isLinux:()=>s_,isMac:()=>yh,isNode:()=>Fh,isSafari:()=>LC,isWindows:()=>BC});var Fh=typeof process<"u"&&"title"in process,ou=Fh?"node":navigator.userAgent,lu=Fh?"node":navigator.platform,AC=ou.includes("Firefox"),FM=ou.includes("Edge"),LC=/^((?!chrome|android).)*safari/i.test(ou);function WM(){if(!LC)return 0;let e=ou.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var yh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(lu),qM=lu==="iPad",$M=lu==="iPhone",BC=["Windows","Win16","Win32","WinCE"].includes(lu),s_=lu.indexOf("Linux")>=0,OC=/\bCrOS\b/.test(ou),jC=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,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},VM=class extends jC{_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())}}},YM=class extends jC{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sh=!Fh&&"requestIdleCallback"in window?YM:VM,XM=class{constructor(){this._queue=new Sh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Pg=class extends ut{constructor(e,t,n,s,o,c,d,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new ll),this._pausedResizeTask=new XM,this._observerDisposable=this._register(new ll),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 ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new KM((f,y)=>this._renderRows(f,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new GM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Xt(()=>n.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,n=!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)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Pg=ui([Le(2,mn),Le(3,Kh),Le(4,lo),Le(5,au),Le(6,pn),Le(7,bs),Le(8,ml)],Pg);var GM=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,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 ZM(e,t,n,s){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return eN(o,c,e,t,n,s)+Wh(c,t,n,s)+tN(o,c,e,t,n,s);let d;if(c===t)return d=o>e?"D":"C",$c(Math.abs(o-e),qc(d,s));d=c>t?"D":"C";let m=Math.abs(c-t),g=JM(c>t?e:o,n)+(m-1)*n.cols+1+QM(c>t?o:e);return $c(g,qc(d,s))}function QM(e,t){return e-1}function JM(e,t){return t.cols-e}function eN(e,t,n,s,o,c){return Wh(t,s,o,c).length===0?"":$c(PC(e,t,e,t-oo(t,o),!1,o).length,qc("D",c))}function Wh(e,t,n,s){let o=e-oo(e,n),c=t-oo(t,n),d=Math.abs(o-c)-iN(e,t,n);return $c(d,qc(zC(e,t),s))}function tN(e,t,n,s,o,c){let d;Wh(t,s,o,c).length>0?d=s-oo(s,o):d=t;let m=s,g=nN(e,t,n,s,o,c);return $c(PC(e,d,n,m,g==="C",o).length,qc(g,c))}function iN(e,t,n){let s=0,o=e-oo(e,n),c=t-oo(t,n);for(let d=0;d<Math.abs(o-c);d++){let m=zC(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*d)?.isWrapped&&s++}return s}function oo(e,t){let n=0,s=t.buffer.lines.get(e),o=s?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s?.isWrapped;return n}function nN(e,t,n,s,o,c){let d;return Wh(n,s,o,c).length>0?d=s-oo(s,o):d=t,e<n&&d<=s||e>=n&&d<s?"C":"D"}function zC(e,t){return e>t?"A":"B"}function PC(e,t,n,s,o,c){let d=e,m=t,g="";for(;(d!==n||m!==s)&&m>=0&&m<c.buffer.lines.length;)d+=o?1:-1,o&&d>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,d),d=0,e=0,m++):!o&&d<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),d=c.cols-1,e=d,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,d)}function qc(e,t){let n=t?"O":"[";return me.ESC+n+e}function $c(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var rN=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function L0(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 _m=50,sN=15,aN=50,oN=500,lN=" ",cN=new RegExp(lN,"g"),Ig=class extends ut{constructor(e,t,n,s,o,c,d,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=c,this._optionsService=d,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ur,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new rN(this._bufferService),this._activeSelectionMode=0,this._register(Xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.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 n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let m=n.translateBufferLineToString(d,!0,o,c);s.push(m)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let d=n.lines.get(c),m=n.translateBufferLineToString(c,!0);d?.isWrapped?s[s.length-1]+=m:s.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(o=>o.replace(cN," ")).join(BC?`\r
|
|
24
|
+
`))}},ER=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},TR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},DR=0,fm=class{constructor(e){this.value=e,this.id=DR++}},RR=2,MR,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new xR(e?.onListenerError??Zd,this._options?.leakWarningThreshold??CR):void 0,this._perfMon=this._options?._profName?new wR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new TR(`${d}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||Zd)(g),ut.None}if(this._disposed)return ut.None;t&&(e=e.bind(t));let s=new fm(e),l;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=kR.create(),l=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof fm?(this._deliveryQueue??=new NR,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Xt(()=>{l?.(),this._removeListener(s)});return n instanceof pa?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-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[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*RR<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:s&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Zd;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof fm)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},NR=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cg.INSTANCE=new Cg;var Qv=Cg;function AR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Qv.INSTANCE.onDidChangeZoomLevel;function LR(e){return Qv.INSTANCE.getZoomFactor(e)}Qv.INSTANCE.onDidChangeFullscreen;var go=typeof navigator=="object"?navigator.userAgent:"",xg=go.indexOf("Firefox")>=0,BR=go.indexOf("AppleWebKit")>=0,Jv=go.indexOf("Chrome")>=0,OR=!Jv&&go.indexOf("Safari")>=0;go.indexOf("Electron/")>=0;go.indexOf("Android")>=0;var pm=!1;if(typeof gs.matchMedia=="function"){let e=gs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=gs.matchMedia("(display-mode: fullscreen)");pm=e.matches,AR(gs,e,({matches:n})=>{pm&&t.matches||(pm=n)})}var Zl="en",kg=!1,Eg=!1,Qd=!1,SC=!1,Od,Jd=Zl,g0=Zl,jR,hs,tl=globalThis,$n;typeof tl.vscode<"u"&&typeof tl.vscode.process<"u"?$n=tl.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&($n=process);var zR=typeof $n?.versions?.electron=="string",PR=zR&&$n?.type==="renderer";if(typeof $n=="object"){kg=$n.platform==="win32",Eg=$n.platform==="darwin",Qd=$n.platform==="linux",Qd&&$n.env.SNAP&&$n.env.SNAP_REVISION,$n.env.CI||$n.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Od=Zl,Jd=Zl;let e=$n.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Od=t.userLocale,g0=t.osLocale,Jd=t.resolvedLanguage||Zl,jR=t.languagePack?.translationsConfigFile}catch{}SC=!0}else typeof navigator=="object"&&!PR?(hs=navigator.userAgent,kg=hs.indexOf("Windows")>=0,Eg=hs.indexOf("Macintosh")>=0,(hs.indexOf("Macintosh")>=0||hs.indexOf("iPad")>=0||hs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Qd=hs.indexOf("Linux")>=0,hs?.indexOf("Mobi")>=0,Jd=globalThis._VSCODE_NLS_LANGUAGE||Zl,Od=navigator.language.toLowerCase(),g0=Od):console.error("Unable to resolve platform.");var wC=kg,Ir=Eg,IR=Qd,v0=SC,Hr=hs,ia=Jd,HR;(e=>{function t(){return ia}e.value=t;function n(){return ia.length===2?ia==="en":ia.length>=3?ia[0]==="e"&&ia[1]==="n"&&ia[2]==="-":!1}e.isDefaultVariant=n;function s(){return ia==="en"}e.isDefault=s})(HR||={});var UR=typeof tl.postMessage=="function"&&!tl.importScripts;(()=>{if(UR){let e=[];tl.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,l=e.length;s<l;s++){let c=e[s];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),tl.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var KR=!!(Hr&&Hr.indexOf("Chrome")>=0);Hr&&Hr.indexOf("Firefox")>=0;!KR&&Hr&&Hr.indexOf("Safari")>=0;Hr&&Hr.indexOf("Edg/")>=0;Hr&&Hr.indexOf("Android")>=0;var ql=typeof navigator=="object"?navigator:{};v0||document.queryCommandSupported&&document.queryCommandSupported("copy")||ql&&ql.clipboard&&ql.clipboard.writeText,v0||ql&&ql.clipboard&&ql.clipboard.readText;var e_=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}},mm=new e_,_0=new e_,b0=new e_,FR=new Array(230),CC;(e=>{function t(m){return mm.keyCodeToStr(m)}e.toString=t;function n(m){return mm.strToKeyCode(m)}e.fromString=n;function s(m){return _0.keyCodeToStr(m)}e.toUserSettingsUS=s;function l(m){return b0.keyCodeToStr(m)}e.toUserSettingsGeneral=l;function c(m){return _0.strToKeyCode(m)||b0.strToKeyCode(m)}e.fromUserSettings=c;function d(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return mm.keyCodeToStr(m)}e.toElectronAccelerator=d})(CC||={});var WR=class xC{constructor(t,n,s,l,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=l,this.keyCode=c}equals(t){return t instanceof xC&&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",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",l=this.metaKey?"1":"0";return`K${t}${n}${s}${l}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new qR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},qR=class{constructor(e){if(e.length===0)throw gR("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;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 $R(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return CC.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(xg)switch(t){case 59:return 85;case 60:if(IR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ir)return 57;break}else if(BR&&(Ir&&t===93||!Ir&&t===92))return 57;return FR[t]||0}var VR=Ir?256:2048,YR=512,XR=1024,GR=Ir?2048:256,y0=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=$R(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|=VR),this.altKey&&(t|=YR),this.shiftKey&&(t|=XR),this.metaKey&&(t|=GR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new WR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},S0=new WeakMap;function ZR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var QR=class{static getSameOriginWindowChain(e){let t=S0.get(e);if(!t){t=[],S0.set(e,t);let n=e,s;do s=ZR(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,l=this.getSameOriginWindowChain(e);for(let c of l){let d=c.window.deref();if(n+=d?.scrollY??0,s+=d?.scrollX??0,d===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,s+=m.left}return{top:n,left:s}}},jd=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 n=QR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},w0=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(Jv){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,d=e.view?.devicePixelRatio||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?xg&&!Ir?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")OR&&wC?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?xg&&!Ir?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*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},kC=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),JR;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof eM?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:en.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kC})})(JR||={});var eM=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?kC:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},t_=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 _g("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _g("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},tM=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new _g("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Xt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},iM;(e=>{async function t(s){let l,c=await Promise.all(s.map(d=>d.then(m=>m,m=>{l||(l=m)})));if(typeof l<"u")throw l;return c}e.settled=t;function n(s){return new Promise(async(l,c)=>{try{await s(l,c)}catch(d){c(d)}})}e.withAsyncBody=n})(iM||={});var C0=class sr{static fromArray(t){return new sr(n=>{n.emitMany(t)})}static fromPromise(t){return new sr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new sr(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new sr(async n=>{await Promise.all(t.map(async s=>{for await(let l of s)n.emitOne(l)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:l=>this.emitOne(l),emitMany:l=>this.emitMany(l),reject:l=>this.reject(l)};try{await Promise.resolve(t(s)),this.resolve()}catch(l){this.reject(l)}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 en.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new sr(async s=>{for await(let l of t)s.emitOne(n(l))})}map(t){return sr.map(this,t)}static filter(t,n){return new sr(async s=>{for await(let l of t)n(l)&&s.emitOne(l)})}filter(t){return sr.filter(this,t)}static coalesce(t){return sr.filter(t,n=>!!n)}coalesce(){return sr.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return sr.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())}};C0.EMPTY=C0.fromArray([]);var{getWindow:Pr,getWindowId:nM,onDidRegisterWindow:rM}=(function(){let e=new Map,t={window:gs,disposables:new pa};e.set(gs.vscodeWindowId,t);let n=new ke,s=new ke,l=new ke;function c(d,m){return(typeof d=="number"?e.get(d):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:l.event,onDidUnregisterWindow:s.event,registerWindow(d){if(e.has(d.vscodeWindowId))return ut.None;let m=new pa,g={window:d,disposables:m.add(new pa)};return e.set(d.vscodeWindowId,g),m.add(Xt(()=>{e.delete(d.vscodeWindowId),s.fire(d)})),m.add(Ze(d,Ki.BEFORE_UNLOAD,()=>{l.fire(d)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:c,getWindow(d){let m=d;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=d;return g?.view?g.view.window:gs},getDocument(d){return Pr(d).document}}})(),sM=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,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 Ze(e,t,n,s){return new sM(e,t,n,s)}var x0=function(e,t,n,s){return Ze(e,t,n,s)},i_,aM=class extends tM{constructor(e){super(),this.defaultTarget=e&&Pr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},k0=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){Zd(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,l=c=>{n.set(c,!1);let d=e.get(c)??[];for(t.set(c,d),e.set(c,[]),s.set(c,!0);d.length>0;)d.sort(k0.sort),d.shift().execute();s.set(c,!1)};i_=(c,d,m=0)=>{let g=nM(c),f=new k0(d,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(f),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>l(g))),f}})();function lM(e){let t=e.getBoundingClientRect(),n=Pr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ki={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"},oM=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=Tn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Tn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Tn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Tn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Tn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Tn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Tn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Tn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Tn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Tn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Tn(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=Tn(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=Tn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Tn(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 Tn(e){return typeof e=="number"?`${e}px`:e}function Pc(e){return new oM(e)}var EC=class{constructor(){this._hooks=new pa,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 n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=l;let c=e;try{e.setPointerCapture(t),this._hooks.add(Xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Pr(e)}this._hooks.add(Ze(c,Ki.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(Ze(c,Ki.POINTER_UP,d=>this.stopMonitoring(!0)))}};function cM(e,t,n){let s=null,l=null;if(typeof n.value=="function"?(s="value",l=n.value,l.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",l=n.get),!l)throw new Error("not supported");let c=`$memoize$${t}`;n[s]=function(...d){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:l.apply(this,d)}),this[c]}}var zr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(zr||={});var Cc=class an extends ut{constructor(){super(),this.dispatched=!1,this.targets=new m0,this.ignoreTargets=new m0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(en.runAndSubscribe(rM,({window:t,disposables:n})=>{n.add(Ze(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Ze(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Ze(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:gs,disposables:this._store}))}static addTarget(t){if(!an.isTouchDevice())return ut.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.targets.push(t);return Xt(n)}static ignoreTarget(t){if(!an.isTouchDevice())return ut.None;an.INSTANCE||(an.INSTANCE=new an);let n=an.INSTANCE.ignoreTargets.push(t);return Xt(n)}static isTouchDevice(){return"ontouchstart"in gs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,l=t.targetTouches.length;s<l;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let d=this.newGestureEvent(zr.Start,c.target);d.pageX=c.pageX,d.pageY=c.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),l=Object.keys(this.activeTouches).length;for(let c=0,d=n.changedTouches.length;c<d;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],f=Date.now()-g.initialTimeStamp;if(f<an.HOLD_DELAY&&Math.abs(g.initialPageX-Wn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Wn(g.rollingPageY))<30){let y=this.newGestureEvent(zr.Tap,g.initialTarget);y.pageX=Wn(g.rollingPageX),y.pageY=Wn(g.rollingPageY),this.dispatchEvent(y)}else if(f>=an.HOLD_DELAY&&Math.abs(g.initialPageX-Wn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Wn(g.rollingPageY))<30){let y=this.newGestureEvent(zr.Contextmenu,g.initialTarget);y.pageX=Wn(g.rollingPageX),y.pageY=Wn(g.rollingPageY),this.dispatchEvent(y)}else if(l===1){let y=Wn(g.rollingPageX),b=Wn(g.rollingPageY),C=Wn(g.rollingTimestamps)-g.rollingTimestamps[0],w=y-g.rollingPageX[0],x=b-g.rollingPageY[0],D=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(w)/C,w>0?1:-1,y,Math.abs(x)/C,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(zr.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===zr.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>an.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===zr.Change||t.type===zr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let l=0,c=t.initialTarget;for(;c&&c!==s;)l++,c=c.parentElement;n.push([l,s])}n.sort((s,l)=>s[0]-l[0]);for(let[s,l]of n)l.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,l,c,d,m,g,f){this.handle=i_(t,()=>{let y=Date.now(),b=y-s,C=0,w=0,x=!0;l+=an.SCROLL_FRICTION*b,m+=an.SCROLL_FRICTION*b,l>0&&(x=!1,C=c*l*b),m>0&&(x=!1,w=g*m*b);let D=this.newGestureEvent(zr.Change);D.translationX=C,D.translationY=w,n.forEach(B=>B.dispatchEvent(D)),x||this.inertia(t,n,y,l,c,d+C,m,g,f+w)})}onTouchMove(t){let n=Date.now();for(let s=0,l=t.changedTouches.length;s<l;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],m=this.newGestureEvent(zr.Change,d.initialTarget);m.translationX=c.pageX-Wn(d.rollingPageX),m.translationY=c.pageY-Wn(d.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(c.pageX),d.rollingPageY.push(c.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Cc.SCROLL_FRICTION=-.005,Cc.HOLD_DELAY=700,Cc.CLEAR_TAP_COUNT_TIME=400,ui([cM],Cc,"isTouchDevice",1);var uM=Cc,n_=class extends ut{onclick(e,t){this._register(Ze(e,Ki.CLICK,n=>t(new jd(Pr(e),n))))}onmousedown(e,t){this._register(Ze(e,Ki.MOUSE_DOWN,n=>t(new jd(Pr(e),n))))}onmouseover(e,t){this._register(Ze(e,Ki.MOUSE_OVER,n=>t(new jd(Pr(e),n))))}onmouseleave(e,t){this._register(Ze(e,Ki.MOUSE_LEAVE,n=>t(new jd(Pr(e),n))))}onkeydown(e,t){this._register(Ze(e,Ki.KEY_DOWN,n=>t(new y0(n))))}onkeyup(e,t){this._register(Ze(e,Ki.KEY_UP,n=>t(new y0(n))))}oninput(e,t){this._register(Ze(e,Ki.INPUT,t))}onblur(e,t){this._register(Ze(e,Ki.BLUR,t))}onfocus(e,t){this._register(Ze(e,Ki.FOCUS,t))}onchange(e,t){this._register(Ze(e,Ki.CHANGE,t))}ignoreGesture(e){return uM.ignoreTarget(e)}},E0=11,dM=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=E0+"px",this.domNode.style.height=E0+"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 EC),this._register(x0(this.bgDomNode,Ki.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(x0(this.domNode,Ki.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new aM),this._pointerdownScheduleRepeatTimer=this._register(new t_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Pr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hM=class Tg{constructor(t,n,s,l,c,d,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,l=l|0,c=c|0,d=d|0,m=m|0),this.rawScrollLeft=l,this.rawScrollTop=m,n<0&&(n=0),l+n>s&&(l=s-n),l<0&&(l=0),c<0&&(c=0),m+c>d&&(m=d-c),m<0&&(m=0),this.width=n,this.scrollWidth=s,this.scrollLeft=l,this.height=c,this.scrollHeight=d,this.scrollTop=m}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,n){return new Tg(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Tg(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,n){let s=this.width!==t.width,l=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,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:l,scrollLeftChanged:c,heightChanged:d,scrollHeightChanged:m,scrollTopChanged:g}}},fM=class extends ut{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hM(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new D0(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=D0.start(this._state,n,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 n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},T0=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function gm(e,t){let n=t-e;return function(s){return e+n*gM(s)}}function pM(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var D0=class Dg{constructor(t,n,s,l){this.from=t,this.to=n,this.duration=l,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,n,s){if(Math.abs(t-n)>2.5*s){let l,c;return t<n?(l=t+.75*s,c=n-.75*s):(l=t-.75*s,c=n+.75*s),pM(gm(t,l),gm(c,n),.33)}return gm(t,n)}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 n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),l=this.scrollTop(n);return new T0(s,l,!1)}return new T0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Dg.start(t,n,s)}static start(t,n,s){s=s+10;let l=Date.now()-10;return new Dg(t,n,l,s)}};function mM(e){return Math.pow(e,3)}function gM(e){return 1-mM(1-e)}var vM=class extends ut{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new t_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},_M=140,TC=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 vM(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new EC),this._shouldRender=!0,this.domNode=Pc(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(Ze(this.domNode.domNode,Ki.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new dM(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Pc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ze(this.slider.domNode,Ki.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.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,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);n<=l&&l<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let l=lM(this.domNode.domNode);t=e.pageX-l.left,n=e.pageY-l.top}let s=this._pointerDownRelativePosition(t,n);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),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),d=Math.abs(c-n);if(wC&&d>_M){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let m=this._sliderPointerPosition(l)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(m))},()=>{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()}},DC=class Rg{constructor(t,n,s,l,c,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=l,this._scrollSize=c,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Rg(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,l,c){let d=Math.max(0,s-t),m=Math.max(0,d-2*n),g=l>0&&l>s;if(!g)return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*m/l))),y=(m-f)/(l-s),b=c*y;return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Rg._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 n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},bM=class extends TC{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new DC(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,l.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}},yM=class extends TC{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new DC(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,l.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}},SM=500,R0=50,wM=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Mg=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,n=0,s=1,l=this._rear;do{let c=l===this._front?t:Math.pow(2,-s);if(t-=c,n+=this._memory[l].score*c,l===this._front)break;l=(this._capacity+l-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Jv){let n=Pr(t.browserEvent),s=LR(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let l=null,c=new wM(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(l=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]=c),c.score=this._computeScore(c,l)}_computeScore(t,n){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),n){let l=Math.abs(t.deltaX),c=Math.abs(t.deltaY),d=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(l,d),1),f=Math.max(Math.min(c,m),1),y=Math.max(l,d),b=Math.max(c,m);y%g===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mg.INSTANCE=new Mg;var CM=Mg,xM=class extends n_{constructor(e,t,n){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=EM(t),this._scrollable=n,this._register(this._scrollable.onScroll(l=>{this._onWillScroll.fire(l),this._onDidScroll(l),this._onScroll.fire(l)}));let s={onMouseWheel:l=>this._onMouseWheel(l),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new yM(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new bM(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=Pc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Pc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Pc(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,l=>this._onMouseOver(l)),this.onmouseleave(this._listenOnDomNode,l=>this._onMouseLeave(l)),this._hideTimeout=this._register(new t_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=al(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,Ir&&(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 w0(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=al(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new w0(n))};this._mouseWheelToDispose.push(Ze(this._listenOnDomNode,Ki.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=CM.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!Ir&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(l){let f=R0*l,y=m.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let f=R0*c,y=m.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let s=n;!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,n=e.scrollLeft>0,s=n?" left":"",l=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${l}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${l}${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(),SM)}},kM=class extends xM{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function EM(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,Ir&&(t.className+=" mac"),t}var Ng=class extends ut{constructor(e,t,n,s,l,c,d,m){super(),this._bufferService=n,this._optionsService=d,this._renderService=m,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new fM({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>i_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new kM(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(l.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(en.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Xt(()=>this._styleElement.remove())),this._register(en.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
25
|
+
`)})),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(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Ng=ui([Le(2,pn),Le(3,ys),Le(4,oC),Le(5,mo),Le(6,mn),Le(7,Ss)],Ng);var Ag=class extends ut{constructor(e,t,n,s,l){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=l,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(c=>this._removeDecoration(c))),this._register(Xt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>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 n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Ag=ui([Le(1,pn),Le(2,ys),Le(3,au),Le(4,Ss)],Ag);var TM=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,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Or={full:0,left:0,center:0,right:0},na={full:0,left:0,center:0,right:0},fc={full:0,left:0,center:0,right:0},_h=class extends ut{constructor(e,t,n,s,l,c,d,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=l,this._optionsService=c,this._themeService=d,this._coreBrowserService=m,this._colorZoneStore=new TM,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Xt(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);na.full=this._canvas.width,na.left=e,na.center=t,na.right=e,this._refreshDrawHeightConstants(),fc.full=1,fc.left=1,fc.center=1+na.left,fc.right=1+na.left+na.center}_refreshDrawHeightConstants(){Or.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);Or.left=t,Or.center=t,Or.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Or.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(fc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Or[e.position||"full"]/2),na[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Or[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}))}};_h=ui([Le(2,pn),Le(3,au),Le(4,Ss),Le(5,mn),Le(6,mo),Le(7,ys)],_h);var me;(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=`
|
|
26
|
+
`,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=""))(me||={});var eh;(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=""))(eh||={});var RC;(e=>e.ST=`${me.ESC}\\`)(RC||={});var Lg=class{constructor(e,t,n,s,l,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=l,this._renderService=c,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 n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!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,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${me.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),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=l+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Lg=ui([Le(2,pn),Le(3,mn),Le(4,ol),Le(5,Ss)],Lg);var Wi=0,qi=0,$i=0,ci=0,M0={css:"#00000000",rgba:0},ki;(e=>{function t(l,c,d,m){return m!==void 0?`#${Ga(l)}${Ga(c)}${Ga(d)}${Ga(m)}`:`#${Ga(l)}${Ga(c)}${Ga(d)}`}e.toCss=t;function n(l,c,d,m=255){return(l<<24|c<<16|d<<8|m)>>>0}e.toRgba=n;function s(l,c,d,m){return{css:e.toCss(l,c,d,m),rgba:e.toRgba(l,c,d,m)}}e.toColor=s})(ki||={});var qt;(e=>{function t(g,f){if(ci=(f.rgba&255)/255,ci===1)return{css:f.css,rgba:f.rgba};let y=f.rgba>>24&255,b=f.rgba>>16&255,C=f.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Wi=w+Math.round((y-w)*ci),qi=x+Math.round((b-x)*ci),$i=D+Math.round((C-D)*ci);let B=ki.toCss(Wi,qi,$i),L=ki.toRgba(Wi,qi,$i);return{css:B,rgba:L}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,f,y){let b=th.ensureContrastRatio(g.rgba,f.rgba,y);if(b)return ki.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function l(g){let f=(g.rgba|255)>>>0;return[Wi,qi,$i]=th.toChannels(f),{css:ki.toCss(Wi,qi,$i),rgba:f}}e.opaque=l;function c(g,f){return ci=Math.round(f*255),[Wi,qi,$i]=th.toChannels(g.rgba),{css:ki.toCss(Wi,qi,$i,ci),rgba:ki.toRgba(Wi,qi,$i,ci)}}e.opacity=c;function d(g,f){return ci=g.rgba&255,c(g,ci*f/255)}e.multiplyOpacity=d;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(qt||={});var ii;(e=>{let t,n;try{let l=document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(l){if(l.match(/#[\da-f]{3,8}/i))switch(l.length){case 4:return Wi=parseInt(l.slice(1,2).repeat(2),16),qi=parseInt(l.slice(2,3).repeat(2),16),$i=parseInt(l.slice(3,4).repeat(2),16),ki.toColor(Wi,qi,$i);case 5:return Wi=parseInt(l.slice(1,2).repeat(2),16),qi=parseInt(l.slice(2,3).repeat(2),16),$i=parseInt(l.slice(3,4).repeat(2),16),ci=parseInt(l.slice(4,5).repeat(2),16),ki.toColor(Wi,qi,$i,ci);case 7:return{css:l,rgba:(parseInt(l.slice(1),16)<<8|255)>>>0};case 9:return{css:l,rgba:parseInt(l.slice(1),16)>>>0}}let c=l.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Wi=parseInt(c[1]),qi=parseInt(c[2]),$i=parseInt(c[3]),ci=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ki.toColor(Wi,qi,$i,ci);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=l,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Wi,qi,$i,ci]=t.getImageData(0,0,1,1).data,ci!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ki.toRgba(Wi,qi,$i,ci),css:l}}e.toColor=s})(ii||={});var hn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,l,c){let d=s/255,m=l/255,g=c/255,f=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(hn||={});var th;(e=>{function t(d,m){if(ci=(m&255)/255,ci===1)return m;let g=m>>24&255,f=m>>16&255,y=m>>8&255,b=d>>24&255,C=d>>16&255,w=d>>8&255;return Wi=b+Math.round((g-b)*ci),qi=C+Math.round((f-C)*ci),$i=w+Math.round((y-w)*ci),ki.toRgba(Wi,qi,$i)}e.blend=t;function n(d,m,g){let f=hn.relativeLuminance(d>>8),y=hn.relativeLuminance(m>>8);if(ds(f,y)<g){if(y<f){let w=s(d,m,g),x=ds(f,hn.relativeLuminance(w>>8));if(x<g){let D=l(d,m,g),B=ds(f,hn.relativeLuminance(D>>8));return x>B?w:D}return w}let b=l(d,m,g),C=ds(f,hn.relativeLuminance(b>>8));if(C<g){let w=s(d,m,g),x=ds(f,hn.relativeLuminance(w>>8));return C>x?b:w}return b}}e.ensureContrastRatio=n;function s(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,C=m>>24&255,w=m>>16&255,x=m>>8&255,D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));for(;D<g&&(C>0||w>0||x>0);)C-=Math.max(0,Math.ceil(C*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));return(C<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=s;function l(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,C=m>>24&255,w=m>>16&255,x=m>>8&255,D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));for(;D<g&&(C<255||w<255||x<255);)C=Math.min(255,C+Math.ceil((255-C)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=ds(hn.relativeLuminance2(C,w,x),hn.relativeLuminance2(f,y,b));return(C<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=l;function c(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=c})(th||={});function Ga(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ds(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var DM=class extends su{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}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()]}},bh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ur}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 n=[],s=t.translateToString(!0),l=0,c=0,d=0,m=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(f-l>1){let y=this._getJoinedRanges(s,d,c,t,l);for(let b=0;b<y.length;b++)n.push(y[b])}l=f,d=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||ha.length}if(this._bufferService.cols-l>1){let f=this._getJoinedRanges(s,d,c,t,l);for(let y=0;y<f.length;y++)n.push(f[y])}return n}_getJoinedRanges(e,t,n,s,l){let c=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let f=0;f<g.length;f++)bh._mergeRanges(d,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(d,s,l),d}_stringRangesToCellRanges(e,t,n){let s=0,l=!1,c=0,d=e[s];if(d){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),f=t.getString(m).length||ha.length;if(g!==0){if(!l&&d[0]<=c&&(d[0]=m,l=!0),d[1]<=c){if(d[1]=m,d=e[++s],!d)break;d[0]<=c?(d[0]=m,l=!0):l=!1}c+=f}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let l=e[s];if(n){if(t[1]<=l[0])return e[s-1][1]=t[1],e;if(t[1]<=l[1])return e[s-1][1]=Math.max(t[1],l[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=l[0])return e.splice(s,0,t),e;if(t[1]<=l[1])return l[0]=Math.min(t[0],l[0]),e;t[0]<l[1]&&(l[0]=Math.min(t[0],l[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};bh=ui([Le(0,pn)],bh);function RM(e){return 57508<=e&&e<=57558}function MM(e){return 9472<=e&&e<=9631}function NM(e){return RM(e)||MM(e)}function AM(){return{css:{canvas:zd(),cell:zd()},device:{canvas:zd(),cell:zd(),char:{width:0,height:0,left:0,top:0}}}}function zd(){return{width:0,height:0}}var Bg=class{constructor(e,t,n,s,l,c,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=l,this._decorationService=c,this._themeService=d,this._workCell=new ur,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,l,c,d,m,g,f,y){let b=[],C=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<c+1&&(x=c+1);let D,B=0,L="",O=0,X=0,U=0,G=0,W=!1,q=0,ge=!1,Se=0,xe=0,re=[],$=f!==-1&&y!==-1;for(let J=0;J<x;J++){e.loadCell(J,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let se=!1,A=J>=xe,R=J,z=this._workCell;if(C.length>0&&J===C[0][0]&&A){let ye=C.shift(),Oe=this._isCellInSelection(ye[0],t);for(O=ye[0]+1;O<ye[1];O++)A&&=Oe===this._isCellInSelection(O,t);A&&=!n||c<ye[0]||c>=ye[1],A?(se=!0,z=new DM(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),R=ye[1]-1,K=z.getWidth()):xe=ye[1]}let ne=this._isCellInSelection(J,t),_e=n&&J===c,M=$&&J>=f&&J<=y,F=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,ye=>{F=!0});let ie=z.getChars()||ha;if(ie===" "&&(z.isUnderline()||z.isOverline())&&(ie=" "),Se=K*m-g.get(ie,z.isBold(),z.isItalic()),!D)D=this._document.createElement("span");else if(B&&(ne&&ge||!ne&&!ge&&z.bg===X)&&(ne&&ge&&w.selectionForeground||z.fg===U)&&z.extended.ext===G&&M===W&&Se===q&&!_e&&!se&&!F&&A){z.isInvisible()?L+=ha:L+=ie,B++;continue}else B&&(D.textContent=L),D=this._document.createElement("span"),B=0,L="";if(X=z.bg,U=z.fg,G=z.extended.ext,W=M,q=Se,ge=ne,se&&c>=J&&c<=R&&(c=J),!this._coreService.isCursorHidden&&_e&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&re.push("xterm-cursor-blink"),re.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline");break}}if(z.isBold()&&re.push("xterm-bold"),z.isItalic()&&re.push("xterm-italic"),z.isDim()&&re.push("xterm-dim"),z.isInvisible()?L=ha:L=z.getChars()||ha,z.isUnderline()&&(re.push(`xterm-underline-${z.extended.underlineStyle}`),L===" "&&(L=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${su.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let ye=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&ye<8&&(ye+=8),D.style.textDecorationColor=w.ansi[ye].css}z.isOverline()&&(re.push("xterm-overline"),L===" "&&(L=" ")),z.isStrikethrough()&&re.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let ve=z.getFgColor(),be=z.getFgColorMode(),Ee=z.getBgColor(),Me=z.getBgColorMode(),Re=!!z.isInverse();if(Re){let ye=ve;ve=Ee,Ee=ye;let Oe=be;be=Me,Me=Oe}let Pe,Be,oe=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,ye=>{ye.options.layer!=="top"&&oe||(ye.backgroundColorRGB&&(Me=50331648,Ee=ye.backgroundColorRGB.rgba>>8&16777215,Pe=ye.backgroundColorRGB),ye.foregroundColorRGB&&(be=50331648,ve=ye.foregroundColorRGB.rgba>>8&16777215,Be=ye.foregroundColorRGB),oe=ye.options.layer==="top")}),!oe&&ne&&(Pe=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Ee=Pe.rgba>>8&16777215,Me=50331648,oe=!0,w.selectionForeground&&(be=50331648,ve=w.selectionForeground.rgba>>8&16777215,Be=w.selectionForeground)),oe&&re.push("xterm-decoration-top");let he;switch(Me){case 16777216:case 33554432:he=w.ansi[Ee],re.push(`xterm-bg-${Ee}`);break;case 50331648:he=ki.toColor(Ee>>16,Ee>>8&255,Ee&255),this._addStyle(D,`background-color:#${N0((Ee>>>0).toString(16),"0",6)}`);break;default:Re?(he=w.foreground,re.push("xterm-bg-257")):he=w.background}switch(Pe||z.isDim()&&(Pe=qt.multiplyOpacity(he,.5)),be){case 16777216:case 33554432:z.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(D,he,w.ansi[ve],z,Pe,void 0)||re.push(`xterm-fg-${ve}`);break;case 50331648:let ye=ki.toColor(ve>>16&255,ve>>8&255,ve&255);this._applyMinimumContrast(D,he,ye,z,Pe,Be)||this._addStyle(D,`color:#${N0(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,he,w.foreground,z,Pe,Be)||Re&&re.push("xterm-fg-257")}re.length&&(D.className=re.join(" "),re.length=0),!_e&&!se&&!F&&A?B++:D.textContent=L,Se!==this.defaultSpacing&&(D.style.letterSpacing=`${Se}px`),b.push(D),J=R}return D&&B&&(D.textContent=L),b}_applyMinimumContrast(e,t,n,s,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||NM(s.getCode()))return!1;let d=this._getContrastCache(s),m;if(!l&&!c&&(m=d.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);m=qt.ensureContrastRatio(l||t,c||n,g),d.setColor((l||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.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 n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};Bg=ui([Le(1,dC),Le(2,mn),Le(3,ys),Le(4,ol),Le(5,au),Le(6,mo)],Bg);function N0(e,t,n){for(;e.length<n;)e=t+e;return e}var LM=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 n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,s,l,c],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(l),this._container.appendChild(c),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,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let l=e;t&&(l+="B"),n&&(l+="I");let c=this._holey.get(l);if(c===void 0){let d=0;t&&(d|=1),n&&(d|=2),c=this._measure(e,d),c>0&&this._holey.set(l,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},BM=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,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let l=e.buffers.active.ydisp,c=t[1]-l,d=n[1]-l,m=Math.max(c,0),g=Math.min(d,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=d,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function OM(){return new BM}var vm="xterm-dom-renderer-owner-",rr="xterm-rows",Pd="xterm-fg-",A0="xterm-bg-",pc="xterm-focus",Id="xterm-selection",jM=1,Og=class extends ut{constructor(e,t,n,s,l,c,d,m,g,f,y,b,C,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=l,this._helperContainer=c,this._linkifier2=d,this._charSizeService=g,this._optionsService=f,this._bufferService=y,this._coreService=b,this._coreBrowserService=C,this._themeService=w,this._terminalClass=jM++,this._rowElements=[],this._selectionRenderModel=OM(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(rr),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(Id),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=AM(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(Bg,document),this._element.classList.add(vm+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(Xt(()=>{this._element.classList.remove(vm+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new LM(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${rr} 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} .${rr} { 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} .${rr} .xterm-dim { color: ${qt.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 n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${rr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${rr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${rr}.${pc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${rr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Id} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Id} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Id} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())t+=`${this._terminalSelector} .${Pd}${c} { color: ${d.css}; }${this._terminalSelector} .${Pd}${c}.xterm-dim { color: ${qt.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${A0}${c} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${Pd}257 { color: ${qt.opaque(e.background).css}; }${this._terminalSelector} .${Pd}257.xterm-dim { color: ${qt.multiplyOpacity(qt.opaque(e.background),.5).css}; }${this._terminalSelector} .${A0}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 n=this._rowElements.length;n<=t;n++){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(pc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(pc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],d-c+1))}else{let g=s===c?e[0]:0,f=c===l?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,f));let y=d-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==d){let b=l===d?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(d,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,s=1){let l=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return c+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-c),l.style.height=`${s*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${d}px`,l}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 n=this._bufferService.buffer,s=n.ybase+n.y,l=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(f);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,f,f===s,d,m,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${vm}${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,n,s,l,c){n<0&&(e=0),s<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),s=Math.max(Math.min(s,d),0),l=Math.min(l,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,f=Math.min(m.x,l-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,C=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=s;++w){let x=w+m.ydisp,D=this._rowElements[w],B=m.lines.get(x);if(!D||!B)break;D.replaceChildren(...this._rowFactory.createRow(B,x,x===g,b,C,f,y,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===s?t:l)-1:-1))}}};Og=ui([Le(7,Gv),Le(8,Kh),Le(9,mn),Le(10,pn),Le(11,ol),Le(12,ys),Le(13,mo)],Og);var jg=class extends ut{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new PM(this._optionsService))}catch{this._measureStrategy=this._register(new zM(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())}};jg=ui([Le(2,mn)],jg);var MC=class extends ut{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)}},zM=class extends MC{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,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}},PM=class extends MC{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}},IM=class extends ut{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new HM(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(en.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ze(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ze(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}},HM=class extends ut{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new lo),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ze(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},UM=class extends ut{constructor(){super(),this.linkProviders=[],this._register(Xt(()=>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 r_(e,t,n){let s=n.getBoundingClientRect(),l=e.getComputedStyle(n),c=parseInt(l.getPropertyValue("padding-left")),d=parseInt(l.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-d]}function KM(e,t,n,s,l,c,d,m,g){if(!c)return;let f=r_(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(g?d/2:0))/d),f[1]=Math.ceil(f[1]/m),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),l),f}var zg=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,l){return KM(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,t){let n=r_(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};zg=ui([Le(0,Ss),Le(1,Kh)],zg);var FM=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,n){this._rowCount=n,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=[]}},NC={};JD(NC,{getSafariVersion:()=>qM,isChromeOS:()=>OC,isFirefox:()=>AC,isIpad:()=>$M,isIphone:()=>VM,isLegacyEdge:()=>WM,isLinux:()=>s_,isMac:()=>yh,isNode:()=>Fh,isSafari:()=>LC,isWindows:()=>BC});var Fh=typeof process<"u"&&"title"in process,lu=Fh?"node":navigator.userAgent,ou=Fh?"node":navigator.platform,AC=lu.includes("Firefox"),WM=lu.includes("Edge"),LC=/^((?!chrome|android).)*safari/i.test(lu);function qM(){if(!LC)return 0;let e=lu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var yh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ou),$M=ou==="iPad",VM=ou==="iPhone",BC=["Windows","Win16","Win32","WinCE"].includes(ou),s_=ou.indexOf("Linux")>=0,OC=/\bCrOS\b/.test(lu),jC=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,n=0,s=e.timeRemaining(),l=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),l=e.timeRemaining(),n*1.5>l){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=l}this.clear()}},YM=class extends jC{_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())}}},XM=class extends jC{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Sh=!Fh&&"requestIdleCallback"in window?XM:YM,GM=class{constructor(){this._queue=new Sh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Pg=class extends ut{constructor(e,t,n,s,l,c,d,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=l,this._coreBrowserService=m,this._renderer=this._register(new lo),this._pausedResizeTask=new GM,this._observerDisposable=this._register(new lo),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 ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new FM((f,y)=>this._renderRows(f,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ZM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Xt(()=>n.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,n=!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)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Pg=ui([Le(2,mn),Le(3,Kh),Le(4,ol),Le(5,au),Le(6,pn),Le(7,ys),Le(8,mo)],Pg);var ZM=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,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 QM(e,t,n,s){let l=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return tN(l,c,e,t,n,s)+Wh(c,t,n,s)+iN(l,c,e,t,n,s);let d;if(c===t)return d=l>e?"D":"C",$c(Math.abs(l-e),qc(d,s));d=c>t?"D":"C";let m=Math.abs(c-t),g=eN(c>t?e:l,n)+(m-1)*n.cols+1+JM(c>t?l:e);return $c(g,qc(d,s))}function JM(e,t){return e-1}function eN(e,t){return t.cols-e}function tN(e,t,n,s,l,c){return Wh(t,s,l,c).length===0?"":$c(PC(e,t,e,t-ll(t,l),!1,l).length,qc("D",c))}function Wh(e,t,n,s){let l=e-ll(e,n),c=t-ll(t,n),d=Math.abs(l-c)-nN(e,t,n);return $c(d,qc(zC(e,t),s))}function iN(e,t,n,s,l,c){let d;Wh(t,s,l,c).length>0?d=s-ll(s,l):d=t;let m=s,g=rN(e,t,n,s,l,c);return $c(PC(e,d,n,m,g==="C",l).length,qc(g,c))}function nN(e,t,n){let s=0,l=e-ll(e,n),c=t-ll(t,n);for(let d=0;d<Math.abs(l-c);d++){let m=zC(e,t)==="A"?-1:1;n.buffer.lines.get(l+m*d)?.isWrapped&&s++}return s}function ll(e,t){let n=0,s=t.buffer.lines.get(e),l=s?.isWrapped;for(;l&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),l=s?.isWrapped;return n}function rN(e,t,n,s,l,c){let d;return Wh(n,s,l,c).length>0?d=s-ll(s,l):d=t,e<n&&d<=s||e>=n&&d<s?"C":"D"}function zC(e,t){return e>t?"A":"B"}function PC(e,t,n,s,l,c){let d=e,m=t,g="";for(;(d!==n||m!==s)&&m>=0&&m<c.buffer.lines.length;)d+=l?1:-1,l&&d>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,d),d=0,e=0,m++):!l&&d<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),d=c.cols-1,e=d,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,d)}function qc(e,t){let n=t?"O":"[";return me.ESC+n+e}function $c(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var sN=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function L0(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 _m=50,aN=15,lN=50,oN=500,cN=" ",uN=new RegExp(cN,"g"),Ig=class extends ut{constructor(e,t,n,s,l,c,d,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=l,this._mouseService=c,this._optionsService=d,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ur,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new sN(this._bufferService),this._activeSelectionMode=0,this._register(Xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.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 n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let l=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let m=n.translateBufferLineToString(d,!0,l,c);s.push(m)}}else{let l=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=t[1]-1;c++){let d=n.lines.get(c),m=n.translateBufferLineToString(c,!0);d?.isWrapped?s[s.length-1]+=m:s.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(l=>l.replace(uN," ")).join(BC?`\r
|
|
27
27
|
`:`
|
|
28
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),s_&&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),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=L0(n,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=r_(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-_m),_m),t/=_m,t/Math.abs(t)+Math.round(t*(sN-1)))}shouldForceSelection(e){return yh?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(),aN)}_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&&!(yh&&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 n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.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<oN&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=ZM(n[0]-1,n[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,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);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,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let d=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,f=e[0]-m,y=0,b=0,C=0,w=0;if(d.charAt(m)===" "){for(;m>0&&d.charAt(m-1)===" ";)m--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let B=e[0],L=e[0];c.getWidth(B)===0&&(y++,B--),c.getWidth(L)===2&&(b++,L++);let O=c.getString(L).length;for(O>1&&(w+=O-1,g+=O-1);B>0&&m>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let X=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,B--):X>1&&(C+=X-1,m-=X-1),m--,B--}for(;L<c.length&&g+1<d.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let X=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,L++):X>1&&(w+=X-1,g+=X-1),g++,L++}}g++;let x=m+f-y+C,D=Math.min(this._bufferService.cols,g-m+y+b-C-w);if(!(!t&&d.slice(m,g).trim()==="")){if(n&&x===0&&c.getCodePoint(0)!==32){let B=o.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let O=this._bufferService.cols-L.start;x-=O,D+=O}}}if(s&&x+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=o.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(D+=L.length)}}return{start:x,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={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=L0(n,this._bufferService.cols)}};Ig=ui([Le(3,pn),Le(4,lo),Le(5,Zv),Le(6,mn),Le(7,ys),Le(8,bs)],Ig);var B0=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},O0=class{constructor(){this._color=new B0,this._css=new B0}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Mi=Object.freeze((()=>{let e=[ii.toColor("#2e3436"),ii.toColor("#cc0000"),ii.toColor("#4e9a06"),ii.toColor("#c4a000"),ii.toColor("#3465a4"),ii.toColor("#75507b"),ii.toColor("#06989a"),ii.toColor("#d3d7cf"),ii.toColor("#555753"),ii.toColor("#ef2929"),ii.toColor("#8ae234"),ii.toColor("#fce94f"),ii.toColor("#729fcf"),ii.toColor("#ad7fa8"),ii.toColor("#34e2e2"),ii.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:ki.toCss(s,o,c),rgba:ki.toRgba(s,o,c)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ki.toCss(s,s,s),rgba:ki.toRgba(s,s,s)})}return e})()),Za=ii.toColor("#ffffff"),xc=ii.toColor("#000000"),j0=ii.toColor("#ffffff"),z0=xc,mc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},uN=Za,Hg=class extends ut{constructor(e){super(),this._optionsService=e,this._contrastCache=new O0,this._halfContrastCache=new O0,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Za,background:xc,cursor:j0,cursorAccent:z0,selectionForeground:void 0,selectionBackgroundTransparent:mc,selectionBackgroundOpaque:qt.blend(xc,mc),selectionInactiveBackgroundTransparent:mc,selectionInactiveBackgroundOpaque:qt.blend(xc,mc),scrollbarSliderBackground:qt.opacity(Za,.2),scrollbarSliderHoverBackground:qt.opacity(Za,.4),scrollbarSliderActiveBackground:qt.opacity(Za,.5),overviewRulerBorder:Za,ansi:Mi.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=Bt(e.foreground,Za),t.background=Bt(e.background,xc),t.cursor=qt.blend(t.background,Bt(e.cursor,j0)),t.cursorAccent=qt.blend(t.background,Bt(e.cursorAccent,z0)),t.selectionBackgroundTransparent=Bt(e.selectionBackground,mc),t.selectionBackgroundOpaque=qt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Bt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=qt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Bt(e.selectionForeground,M0):void 0,t.selectionForeground===M0&&(t.selectionForeground=void 0),qt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=qt.opacity(t.selectionBackgroundTransparent,.3)),qt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=qt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Bt(e.scrollbarSliderBackground,qt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Bt(e.scrollbarSliderHoverBackground,qt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Bt(e.scrollbarSliderActiveBackground,qt.opacity(t.foreground,.5)),t.overviewRulerBorder=Bt(e.overviewRulerBorder,uN),t.ansi=Mi.slice(),t.ansi[0]=Bt(e.black,Mi[0]),t.ansi[1]=Bt(e.red,Mi[1]),t.ansi[2]=Bt(e.green,Mi[2]),t.ansi[3]=Bt(e.yellow,Mi[3]),t.ansi[4]=Bt(e.blue,Mi[4]),t.ansi[5]=Bt(e.magenta,Mi[5]),t.ansi[6]=Bt(e.cyan,Mi[6]),t.ansi[7]=Bt(e.white,Mi[7]),t.ansi[8]=Bt(e.brightBlack,Mi[8]),t.ansi[9]=Bt(e.brightRed,Mi[9]),t.ansi[10]=Bt(e.brightGreen,Mi[10]),t.ansi[11]=Bt(e.brightYellow,Mi[11]),t.ansi[12]=Bt(e.brightBlue,Mi[12]),t.ansi[13]=Bt(e.brightMagenta,Mi[13]),t.ansi[14]=Bt(e.brightCyan,Mi[14]),t.ansi[15]=Bt(e.brightWhite,Mi[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=Bt(e.extendedAnsi[s],Mi[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()}}};Hg=ui([Le(0,mn)],Hg);function Bt(e,t){if(e!==void 0)try{return ii.toColor(e)}catch{}return t}var dN=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},hN=class{constructor(){this._services=new dN,this._services.set(Gv,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=sR(e).sort((c,d)=>c.index-d.index),s=[];for(let c of n){let d=this._services.get(c.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(d)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},fN={trace:0,debug:1,info:2,warn:3,error:4,off:5},pN="xterm.js: ",Ug=class extends ut{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=fN[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,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":pN)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Ug=ui([Le(0,mn)],Ug);var P0=class extends ut{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),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 n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];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,...n){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+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-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+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ct=3,Ci=Object.freeze(new su),Hd=0,bm=2,kc=class IC{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ct);let o=n||ur.fromCharData([0,rC,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*ct+0],s=n&2097151;return[this._data[t*ct+1],n&2097152?this._combined[t]:s?la(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*ct+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*ct+0]=t|2097152|n[2]<<22):this._data[t*ct+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*ct+0]>>22}hasWidth(t){return this._data[t*ct+0]&12582912}getFg(t){return this._data[t*ct+1]}getBg(t){return this._data[t*ct+2]}hasContent(t){return this._data[t*ct+0]&4194303}getCodePoint(t){let n=this._data[t*ct+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*ct+0]&2097152}getString(t){let n=this._data[t*ct+0];return n&2097152?this._combined[t]:n&2097151?la(n&2097151):""}isProtected(t){return this._data[t*ct+2]&536870912}loadCell(t,n){return Hd=t*ct,n.content=this._data[Hd+0],n.fg=this._data[Hd+1],n.bg=this._data[Hd+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*ct+0]=n.content,this._data[t*ct+1]=n.fg,this._data[t*ct+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*ct+0]=n|s<<22,this._data[t*ct+1]=o.fg,this._data[t*ct+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*ct+0];o&2097152?this._combined[t]+=la(n):o&2097151?(this._combined[t]=la(o&2097151)+la(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*ct+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new ur;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,o));for(let c=0;c<n;++c)this.setCell(t+c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new ur;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,o));for(let c=this.length-n;c<this.length;++c)this.setCell(c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,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,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&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),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*bm<this._data.buffer.byteLength;let s=t*ct;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let d=0;d<o.length;d++){let m=parseInt(o[d],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let d=0;d<c.length;d++){let m=parseInt(c[d],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,s*4*bm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*bm<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){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 n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new IC(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ct+0]&4194303)return t+(this._data[t*ct+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ct+0]&4194303||this._data[t*ct+2]&50331648)return t+(this._data[t*ct+0]>>22);return 0}copyCellsFrom(t,n,s,o,c){let d=t._data;if(c)for(let g=o-1;g>=0;g--){for(let f=0;f<ct;f++)this._data[(s+g)*ct+f]=d[(n+g)*ct+f];d[(n+g)*ct+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let f=0;f<ct;f++)this._data[(s+g)*ct+f]=d[(n+g)*ct+f];d[(n+g)*ct+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let f=parseInt(m[g],10);f>=n&&(this._combined[f-n+s]=t._combined[f])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<s;){let d=this._data[n*ct+0],m=d&2097151,g=d&2097152?this._combined[n]:m?la(m):da;if(c+=g,o)for(let f=0;f<g.length;++f)o.push(n);n+=d>>22||1}return o&&o.push(n),c}};function mN(e,t,n,s,o,c){let d=[];for(let m=0;m<e.length-1;m++){let g=m,f=e.get(++g);if(!f.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&f.isWrapped;)y.push(f),f=e.get(++g);if(!c&&s>=m&&s<g){m+=y.length-1;continue}let b=0,C=Vc(y,b,t),w=1,x=0;for(;w<y.length;){let B=Vc(y,w,t),L=B-x,O=n-C,X=Math.min(L,O);y[b].copyCellsFrom(y[w],x,C,X,!1),C+=X,C===n&&(b++,C=0),x+=X,x===B&&(w++,x=0),C===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,C++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(C,n,o);let D=0;for(let B=y.length-1;B>0&&(B>b||y[B].getTrimmedLength()===0);B--)D++;D>0&&(d.push(m+y.length-D),d.push(D)),m+=y.length-1}return d}function gN(e,t){let n=[],s=0,o=t[s],c=0;for(let d=0;d<e.length;d++)if(o===d){let m=t[++s];e.onDeleteEmitter.fire({index:d-c,amount:m}),d+=m-1,c+=m,o=t[++s]}else n.push(d);return{layout:n,countRemoved:c}}function vN(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function _N(e,t,n){let s=[],o=e.map((g,f)=>Vc(e,f,t)).reduce((g,f)=>g+f),c=0,d=0,m=0;for(;m<o;){if(o-m<n){s.push(o-m);break}c+=n;let g=Vc(e,d,t);c>g&&(c-=g,d++);let f=e[d].getWidth(c-1)===2;f&&c--;let y=f?n-1:n;s.push(y),m+=y}return s}function Vc(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var HC=class UC{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=UC._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ao(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};HC._nextId=1;var bN=HC,Oi={},Qa=Oi.B;Oi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Oi.A={"#":"£"};Oi.B=void 0;Oi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Oi.C=Oi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Oi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Oi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Oi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Oi.E=Oi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Oi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Oi.H=Oi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var I0=4294967295,H0=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ci.clone(),this.savedCharset=Qa,this.markers=[],this._nullCell=ur.fromCharData([0,rC,1,0]),this._whitespaceCell=ur.fromCharData([0,da,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Sh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new P0(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 vh),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 vh),this._whitespaceCell}getBlankLine(e,t){return new kc(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>I0?I0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ci);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 P0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ci),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)s+=+this.lines.get(d).resize(e,n);let c=0;if(this._rows<t)for(let d=this._rows;d<t;d++)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 kc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new kc(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let d=this.lines.length-o;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),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 c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,n);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 n=this._optionsService.rawOptions.reflowCursorLine,s=mN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ci),n);if(s.length>0){let o=gN(this.lines,s);vN(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ci),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new kc(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Ci),o=[],c=0;for(let d=this.lines.length-1;d>=0;d--){let m=this.lines.get(d);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&d>0;)m=this.lines.get(--d),g.unshift(m);if(!n){let X=this.ybase+this.y;if(X>=d&&X<d+g.length)continue}let f=g[g.length-1].getTrimmedLength(),y=_N(g,this._cols,e),b=y.length-g.length,C;this.ybase===0&&this.y!==this.lines.length-1?C=Math.max(0,this.y-this.lines.maxLength+b):C=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let X=0;X<b;X++){let U=this.getBlankLine(Ci,!0);w.push(U)}w.length>0&&(o.push({start:d+g.length+c,newLines:w}),c+=w.length),g.push(...w);let x=y.length-1,D=y[x];D===0&&(x--,D=y[x]);let B=g.length-b-1,L=f;for(;B>=0;){let X=Math.min(L,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[B],L-X,D-X,X,!0),D-=X,D===0&&(x--,D=y[x]),L-=X,L===0){B--;let U=Math.max(B,0);L=Vc(g,U,this._cols)}}for(let X=0;X<g.length;X++)y[X]<e&&g[X].setCell(y[X],s);let O=b-C;for(;O-- >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+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let d=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,f=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let C=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>f+C){for(let B=b.newLines.length-1;B>=0;B--)this.lines.set(D--,b.newLines[B]);D++,d.push({index:f+1,amount:b.newLines.length}),C+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[f--]);let w=0;for(let D=d.length-1;D>=0;D--)d[D].index+=w,this.lines.onInsertEmitter.fire(d[D]),w+=d[D].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}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 bN(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},yN=class extends ut{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),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 H0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new H0(!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)}},KC=2,FC=1,Kg=class extends ut{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,KC),this.rows=Math.max(e.rawOptions.rows||0,FC),this.buffers=this._register(new yN(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=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:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;c===n.lines.length-1?d?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(c+1,0,s.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=c-o+1;n.lines.shiftElements(o+1,d-1,-1),n.lines.set(c,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Kg=ui([Le(0,mn)],Kg);var Vo={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:yh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},SN=["normal","bold","100","200","300","400","500","600","700","800","900"],wN=class extends ut{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...Vo};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Xt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Vo))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Vo))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Vo[e]),!CN(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Vo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=SN.includes(t)?t:Vo[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 CN(e){return e==="block"||e==="underline"||e==="bar"}function Ec(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Ec(e[s],t-1);return n}var U0=Object.freeze({insertMode:!1}),K0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fg=class extends ut{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ec(U0),this.decPrivateModes=Ec(K0)}reset(){this.modes=Ec(U0),this.decPrivateModes=Ec(K0)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.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))}};Fg=ui([Le(0,pn),Le(1,cC),Le(2,mn)],Fg);var F0={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 ym(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Sm=String.fromCharCode,W0={DEFAULT:e=>{let t=[ym(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Sm(t[0])}${Sm(t[1])}${Sm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ym(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ym(e,!0)};${e.x};${e.y}${t}`}},Wg=class extends ut{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(F0))this.addProtocol(s,F0[s]);for(let s of Object.keys(W0))this.addEncoding(s,W0[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,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_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,n){if(n){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)}};Wg=ui([Le(0,pn),Le(1,lo),Le(2,mn)],Wg);var wm=[[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]],xN=[[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]],Ni;function kN(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var EN=class{constructor(){if(this.version="6",!Ni){Ni=new Uint8Array(65536),Ni.fill(1),Ni[0]=0,Ni.fill(0,1,32),Ni.fill(0,127,160),Ni.fill(2,4352,4448),Ni[9001]=2,Ni[9002]=2,Ni.fill(2,11904,42192),Ni[12351]=1,Ni.fill(2,44032,55204),Ni.fill(2,63744,64256),Ni.fill(2,65040,65050),Ni.fill(2,65072,65136),Ni.fill(2,65280,65377),Ni.fill(2,65504,65511);for(let e=0;e<wm.length;++e)Ni.fill(0,wm[e][0],wm[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ni[e]:kN(e,xN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Ja.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Ja.createPropertyValue(0,n,s)}},Ja=class ih{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new EN;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,n,s=!1){return(t&16777215)<<3|(n&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 n=0,s=0,o=t.length;for(let c=0;c<o;++c){let d=t.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=o)return n+this.wcwidth(d);let f=t.charCodeAt(c);56320<=f&&f<=57343?d=(d-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let m=this.charProperties(d,s),g=ih.extractWidth(m);ih.extractShouldJoin(m)&&(g-=ih.extractWidth(s)),n+=g,s=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},TN=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 q0(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var gc=2147483647,DN=256,WC=class qg{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>DN)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new qg;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let c=0;c<o.length;++c)n.addSubParam(o[c]);else n.addParam(o)}return n}clone(){let t=new qg(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 n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}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>gc?gc: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>gc?gc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,gc):t}},vc=[],RN=class{constructor(){this._state=0,this._active=vc,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 n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=vc}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=vc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||vc,!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,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Uh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){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&&n-t>0&&this._put(e,t,n)}}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 n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=vc,this._id=-1,this._state=0}}},Wn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Uh(e,t,n),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(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},_c=[],MN=class{constructor(){this._handlers=Object.create(null),this._active=_c,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_c}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=_c,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||_c,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Uh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=_c,this._ident=0}},Tc=new WC;Tc.addParam(0);var $0=class{constructor(e){this._handler=e,this._data="",this._params=Tc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Tc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Uh(e,t,n),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(n=>(this._params=Tc,this._data="",this._hitLimit=!1,n));return this._params=Tc,this._data="",this._hitLimit=!1,t}},NN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},ar=160,AN=(function(){let e=new NN(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),d;e.setDefault(1,0),e.addMany(s,0,2,0);for(d in c)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,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(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,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(ar,0,2,0),e.add(ar,8,5,8),e.add(ar,6,0,6),e.add(ar,11,0,11),e.add(ar,13,13,13),e})(),LN=class extends ut{constructor(e=AN){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 WC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},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(Xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new RN),this._dcsParser=this._register(new MN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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 o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}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 n<<=8,n|=s,n}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 n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,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 n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,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,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,c=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,n),d)return d;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],d=this._oscParser.end(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(s=e[m],o=this._transitions.table[this.currentState<<8|(s<160?s:ar)],o>>4){case 2:for(let C=m+1;;++C){if(C>=t||(s=e[C])<32||s>126&&s<ar){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<ar){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<ar){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<ar){this._printHandler(e,m,C),m=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:m,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(d=g[f](this._params),d!==!0);f--)if(d instanceof Promise)return this._preserveStack(3,g,f,o,m),d;f<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(++m<t&&(s=e[m])>47&&s<60);m--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],b=y?y.length-1:-1;for(;b>=0&&(d=y[b](),d!==!0);b--)if(d instanceof Promise)return this._preserveStack(4,y,b,o,m),d;b<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=m+1;;++C)if(C>=t||(s=e[C])===24||s===26||s===27||s>127&&s<ar){this._dcsParser.put(e,m,C),m=C-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,o,m),d;s===27&&(o|=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=m+1;;C++)if(C>=t||(s=e[C])<32||s>127&&s<ar){this._oscParser.put(e,m,C),m=C-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,o,m),d;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},BN=/^([\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})$/,ON=/^[\da-f]+$/;function V0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=BN.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),ON.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return s}}function Cm(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function jN(e,t=16){let[n,s,o]=e;return`rgb:${Cm(n,t)}/${Cm(s,t)}/${Cm(o,t)}`}var zN={"(":0,")":1,"*":2,"+":3,"-":1,".":2},na=131072,Y0=10;function X0(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 G0=5e3,Z0=0,PN=class extends ut{constructor(e,t,n,s,o,c,d,m,g=new LN){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=d,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nR,this._utf8Decoder=new rR,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ci.clone(),this._eraseAttrDataInternal=Ci.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new $g(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:y.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:y,data:b})}),this._parser.setDcsHandlerFallback((f,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:y,payload:b})}),this._parser.setPrintHandler((f,y,b)=>this.print(f,y,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(me.BEL,()=>this.bell()),this._parser.setExecuteHandler(me.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(me.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(me.BS,()=>this.backspace()),this._parser.setExecuteHandler(me.HT,()=>this.tab()),this._parser.setExecuteHandler(me.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(me.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(eh.IND,()=>this.index()),this._parser.setExecuteHandler(eh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(eh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Wn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Wn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Wn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Wn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Wn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Wn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Wn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Wn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Wn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Wn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Wn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Wn(f=>this.restoreCursorColor(f))),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 f in Oi)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new $0((f,y)=>this.requestStatusString(f,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),G0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${G0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,c=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>na&&(c=this._parseStack.position+na)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<na&&(this._parseBuffer=new Uint32Array(Math.min(e.length,na))),d||this._dirtyRowTracker.clearRange(),e.length>na)for(let f=c;f<e.length;f+=na){let y=f+na<e.length?f+na:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,o,b,f),this._logSlowResolvingAsync(n),n}else if(!d){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let m=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(m,this._bufferService.rows-1)})}print(e,t,n){let s,o,c=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let C=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(s=e[w],s<127&&c){let L=c[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let x=this._unicodeService.charProperties(s,C);o=Ja.extractWidth(x);let D=Ja.extractShouldJoin(x),B=D?Ja.extractWidth(C):0;if(C=x,d&&this._onA11yChar.fire(la(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>m){if(g){let L=b,O=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&b instanceof kc&&b.copyCellsFrom(L,O,0,B,!1);O<m;)L.setCellFromCodepoint(O++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(D&&this._activeBuffer.x){let L=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-L,s,o);for(let O=o-B;--O>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(f&&(b.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,s,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=C,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>X0(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new $0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Wn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,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 n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,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 n=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(n,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(Ci));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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=e.params[0]||1,s=Ja.extractWidth(t),o=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),d=new Uint32Array(c.length*n),m=0;for(let f=0;f<c.length;){let y=c.codePointAt(f)||0;d[m++]=y,f+=y>65535?2:1}let g=m;for(let f=1;f<n;++f)d.copyWithin(g,0,m),g+=m;return this.print(d,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(me.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(me.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(me.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(me.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(me.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,Qa),this._charsetService.setgCharset(1,Qa),this._charsetService.setgCharset(2,Qa),this._charsetService.setgCharset(3,Qa);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){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:f,alt:y}=m,b=this._optionsService.rawOptions,C=(D,B)=>(d.triggerDataEvent(`${me.ESC}[${t?"":"?"}${D};${B}$y`),!0),w=D=>D?1:2,x=e.params[0];return t?x===2?C(x,4):x===4?C(x,w(d.modes.insertMode)):x===12?C(x,3):x===20?C(x,w(b.convertEol)):C(x,0):x===1?C(x,w(s.applicationCursorKeys)):x===3?C(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?C(x,w(s.origin)):x===7?C(x,w(s.wraparound)):x===8?C(x,3):x===9?C(x,w(o==="X10")):x===12?C(x,w(b.cursorBlink)):x===25?C(x,w(!d.isCursorHidden)):x===45?C(x,w(s.reverseWraparound)):x===66?C(x,w(s.applicationKeypad)):x===67?C(x,4):x===1e3?C(x,w(o==="VT200")):x===1002?C(x,w(o==="DRAG")):x===1003?C(x,w(o==="ANY")):x===1004?C(x,w(s.sendFocus)):x===1005?C(x,4):x===1006?C(x,w(c==="SGR")):x===1015?C(x,4):x===1016?C(x,w(c==="SGR_PIXELS")):x===1048?C(x,1):x===47||x===1047||x===1049?C(x,w(f===y)):x===2004?C(x,w(s.bracketedPasteMode)):x===2026?C(x,w(s.synchronizedOutput)):C(x,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=su.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,c=0;do{if(s[c+o]=e.params[t+c],e.hasSubParams(t+c)){let d=e.getSubParams(t+c),m=0;do s[1]===5&&(o=1),s[c+m+1+o]=d[m];while(++m<d.length&&m+c+1+o<s.length);break}if(s[1]===5&&c+o>=2||s[1]===2&&c+o>=5)break;s[1]&&(o=1)}while(++c+t<e.length&&c+o<s.length);for(let d=2;d<s.length;++d)s[d]===-1&&(s[d]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return c}_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=Ci.fg,e.bg=Ci.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,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ci.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ci.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ci.fg&16777215,s.bg&=-67108864,s.bg|=Ci.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${me.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[?${t};${n}R`)}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=Ci.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!X0(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(`${me.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Y0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Y0&&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=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(Q0(c))if(o==="?")t.push({type:0,index:c});else{let d=V0(o);d&&t.push({type:1,index:c,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(s=n[o].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 n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=V0(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}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=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Q0(o)&&t.push({type:2,index:o})}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,Qa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(zN[e[0]],Oi[e[1]]||Qa),!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=Ci.clone(),this._eraseAttrDataInternal=Ci.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 ur;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 n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${me.ESC}${d}${me.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(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}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},$g=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&&(Z0=e,e=t,t=Z0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};$g=ui([Le(0,pn)],$g);function Q0(e){return 0<=e&&e<256}var IN=5e7,J0=12,HN=50,UN=class extends ut{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 ke),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 n;for(;n=this._writeBuffer.shift();){this._action(n);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>IN)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 n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let d=m=>performance.now()-n>=J0?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(d);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=J0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>HN&&(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()}},Vg=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 m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Vg=ui([Le(0,pn)],Vg);var ew=!1,KN=class extends ut{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ll),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new hN,this.optionsService=this._register(new wN(e)),this._instantiationService.setService(mn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Kg)),this._instantiationService.setService(pn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ug)),this._instantiationService.setService(cC,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fg)),this._instantiationService.setService(lo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Wg)),this._instantiationService.setService(lC,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ja)),this._instantiationService.setService(lR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(TN),this._instantiationService.setService(oR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Vg),this._instantiationService.setService(uC,this._oscLinkService),this._inputHandler=this._register(new PN(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(en.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(en.forward(this._bufferService.onResize,this._onResize)),this._register(en.forward(this.coreService.onData,this._onData)),this._register(en.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 UN((t,n)=>this._inputHandler.parse(t,n))),this._register(en.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!ew&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ew=!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,KC),t=Math.max(t,FC),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(q0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(q0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Xt(()=>{for(let t of e)t.dispose()})}}},FN={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 WN(e,t,n,s){let o={type:0,cancel:!1,key:void 0},c=(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?o.key=me.ESC+"OA":o.key=me.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=me.ESC+"OD":o.key=me.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=me.ESC+"OC":o.key=me.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=me.ESC+"OB":o.key=me.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":me.DEL,e.altKey&&(o.key=me.ESC+o.key);break;case 9:if(e.shiftKey){o.key=me.ESC+"[Z";break}o.key=me.HT,o.cancel=!0;break;case 13:o.key=e.altKey?me.ESC+me.CR:me.CR,o.cancel=!0;break;case 27:o.key=me.ESC,e.altKey&&(o.key=me.ESC+me.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=me.ESC+"[1;"+(c+1)+"D":t?o.key=me.ESC+"OD":o.key=me.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=me.ESC+"[1;"+(c+1)+"C":t?o.key=me.ESC+"OC":o.key=me.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=me.ESC+"[1;"+(c+1)+"A":t?o.key=me.ESC+"OA":o.key=me.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=me.ESC+"[1;"+(c+1)+"B":t?o.key=me.ESC+"OB":o.key=me.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=me.ESC+"[2~");break;case 46:c?o.key=me.ESC+"[3;"+(c+1)+"~":o.key=me.ESC+"[3~";break;case 36:c?o.key=me.ESC+"[1;"+(c+1)+"H":t?o.key=me.ESC+"OH":o.key=me.ESC+"[H";break;case 35:c?o.key=me.ESC+"[1;"+(c+1)+"F":t?o.key=me.ESC+"OF":o.key=me.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=me.ESC+"[5;"+(c+1)+"~":o.key=me.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=me.ESC+"[6;"+(c+1)+"~":o.key=me.ESC+"[6~";break;case 112:c?o.key=me.ESC+"[1;"+(c+1)+"P":o.key=me.ESC+"OP";break;case 113:c?o.key=me.ESC+"[1;"+(c+1)+"Q":o.key=me.ESC+"OQ";break;case 114:c?o.key=me.ESC+"[1;"+(c+1)+"R":o.key=me.ESC+"OR";break;case 115:c?o.key=me.ESC+"[1;"+(c+1)+"S":o.key=me.ESC+"OS";break;case 116:c?o.key=me.ESC+"[15;"+(c+1)+"~":o.key=me.ESC+"[15~";break;case 117:c?o.key=me.ESC+"[17;"+(c+1)+"~":o.key=me.ESC+"[17~";break;case 118:c?o.key=me.ESC+"[18;"+(c+1)+"~":o.key=me.ESC+"[18~";break;case 119:c?o.key=me.ESC+"[19;"+(c+1)+"~":o.key=me.ESC+"[19~";break;case 120:c?o.key=me.ESC+"[20;"+(c+1)+"~":o.key=me.ESC+"[20~";break;case 121:c?o.key=me.ESC+"[21;"+(c+1)+"~":o.key=me.ESC+"[21~";break;case 122:c?o.key=me.ESC+"[23;"+(c+1)+"~":o.key=me.ESC+"[23~";break;case 123:c?o.key=me.ESC+"[24;"+(c+1)+"~":o.key=me.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=me.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=me.DEL:e.keyCode===219?o.key=me.ESC:e.keyCode===220?o.key=me.FS:e.keyCode===221&&(o.key=me.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=FN[e.keyCode]?.[e.shiftKey?1:0];if(d)o.key=me.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),o.key=me.ESC+g}else if(e.keyCode===32)o.key=me.ESC+(e.ctrlKey?me.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=me.ESC+m,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=me.US),e.key==="@"&&(o.key=me.NUL));break}return o}var gi=0,qN=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Sh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Sh,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((o,c)=>this._getKey(o)-this._getKey(c)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];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||(gi=this._search(t),gi===-1)||this._getKey(this._array[gi])!==t)return!1;do if(this._array[gi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(gi),!0;while(++gi<this._array.length&&this._getKey(this._array[gi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,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&&(gi=this._search(e),!(gi<0||gi>=this._array.length)&&this._getKey(this._array[gi])===e))do yield this._array[gi];while(++gi<this._array.length&&this._getKey(this._array[gi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(gi=this._search(e),!(gi<0||gi>=this._array.length)&&this._getKey(this._array[gi])===e))do t(this._array[gi]);while(++gi<this._array.length&&this._getKey(this._array[gi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},xm=0,tw=0,$N=class extends ut{constructor(){super(),this._decorations=new qN(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new VN(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.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,n){let s=0,o=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,o=s+(c.options.width??1),e>=s&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{xm=o.options.x??0,tw=xm+(o.options.width??1),e>=xm&&e<tw&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},VN=class extends fa{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),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=ii.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ii.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},YN=1e3,XN=class{constructor(e,t=YN){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,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 o=s-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_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)}},iw=20,wh=class extends ut{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,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=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new XN(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(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
29
|
-
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ze(
|
|
30
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===iw+1&&(this._liveRegion.textContent+=fg.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 n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),d=[],m=c?.translateToString(!0,void 0,void 0,d)||"",g=(n.ydisp+o+1).toString(),f=this._rowElements[o];f&&(m.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=m,this._rowColumns.set(f,d)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==s)return;let d,m;if(t===0?(d=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(d=this._rowElements.shift(),m=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,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(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:m,offset:g})=>{let f=m instanceof Text?m.parentNode:m,y=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(f);if(!b)return console.warn("columns is null. Race condition?"),null;let C=g<b.length?b[g]:b.slice(-1)[0]+1;return C>=this._terminal.cols&&(++y,C=0),{row:y,column:C}},c=o(t),d=o(n);if(!(!c||!d)){if(c.row>d.row||c.row===d.row&&c.column>=d.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(d.row-c.row)*this._terminal.cols-c.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};wh=ui([Le(1,Gv),Le(2,bs),Le(3,ys)],wh);var Yg=class extends ut{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Xt(()=>{ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ze(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ze(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ze(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ze(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 n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let d=c?.map(m=>({link:m}));this._activeProviderReplies?.set(s,d),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let c=0;c<o.length;c++){let d=o[c],m=d.link.range.start.y<e?0:d.link.range.start.x,g=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let f=m;f<=g;f++){if(n.has(f)){o.splice(c--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&GN(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,ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.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,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};Yg=ui([Le(1,Zv),Le(2,ys),Le(3,pn),Le(4,hC)],Yg);function GN(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 ZN=class extends KN{constructor(e={}){super(e),this._linkifier=this._register(new ll),this.browser=NC,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ll),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance($N),this._instantiationService.setService(au,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(HM),this._instantiationService.setService(hC,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mg)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(en.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(en.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(en.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(en.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Xt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=qt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${me.ESC}]${s};${jN(o)}${RC.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=ki.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=ki.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(wh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.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 n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ze(this.element,"copy",t=>{this.hasSelection()&&tR(t,this._selectionService)}));let e=t=>iR(t,this.textarea,this.coreService,this.optionsService);this._register(Ze(this.textarea,"paste",e)),this._register(Ze(this.element,"paste",e)),AC?this._register(Ze(this.element,"mousedown",t=>{t.button===2&&h0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ze(this.element,"contextmenu",t=>{h0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s_&&this._register(Ze(this.element,"auxclick",t=>{t.button===1&&nC(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ze(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ze(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ze(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ze(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ze(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ze(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ze(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ze(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",hg.get()),OC||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",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(PM,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(bs,this._coreBrowserService),this._register(Ze(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ze(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(jg,this._document,this._helperContainer),this._instantiationService.setService(Kh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Hg),this._instantiationService.setService(ml,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(bh),this._instantiationService.setService(dC,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Pg,this.rows,this.screenElement)),this._instantiationService.setService(ys,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Lg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zg),this._instantiationService.setService(Zv,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Yg,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(Ng,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ig,this.element,this.screenElement,s)),this._instantiationService.setService(uR,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(en.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ag,this.screenElement)),this._register(Ze(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(wh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_h,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_h,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Og,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),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()),c&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ze(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Ze(t,"wheel",c=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let d=me.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){iC(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,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=WN(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.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((n.key===me.ETX||n.key===me.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=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"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(QN(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ci));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(me.ESC+"[I"):this.coreService.triggerDataEvent(me.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function QN(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var JN=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;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)}},eA=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 ur)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},nw=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 eA(t)}getNullCell(){return new ur}},tA=class extends ut{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new nw(this._core.buffers.normal,"normal"),this._alternate=new nw(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)}},iA=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,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)}},nA=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}},rA=["cols","rows"],jr=0,sA=class extends ut{constructor(e){super(),this._core=this._register(new ZN(e)),this._addonManager=this._register(new JN),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(rA.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 iA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nA(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 tA(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,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}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
|
|
31
|
-
`,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 hg.get()},set promptLabel(e){hg.set(e)},get tooMuchOutput(){return fg.get()},set tooMuchOutput(e){fg.set(e)}}}_verifyIntegers(...e){for(jr of e)if(jr===1/0||isNaN(jr)||jr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(jr of e)if(jr&&(jr===1/0||isNaN(jr)||jr%1!==0||jr<0))throw new Error("This API only accepts positive integers")}};class
|
|
28
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),s_&&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),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=L0(n,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=r_(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-_m),_m),t/=_m,t/Math.abs(t)+Math.round(t*(aN-1)))}shouldForceSelection(e){return yh?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(),lN)}_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&&!(yh&&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 n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.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<oN&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=QM(n[0]-1,n[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,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);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,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let l=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:l>1&&t!==s&&(n+=l-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let d=l.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,f=e[0]-m,y=0,b=0,C=0,w=0;if(d.charAt(m)===" "){for(;m>0&&d.charAt(m-1)===" ";)m--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let B=e[0],L=e[0];c.getWidth(B)===0&&(y++,B--),c.getWidth(L)===2&&(b++,L++);let O=c.getString(L).length;for(O>1&&(w+=O-1,g+=O-1);B>0&&m>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let X=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,B--):X>1&&(C+=X-1,m-=X-1),m--,B--}for(;L<c.length&&g+1<d.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let X=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,L++):X>1&&(w+=X-1,g+=X-1),g++,L++}}g++;let x=m+f-y+C,D=Math.min(this._bufferService.cols,g-m+y+b-C-w);if(!(!t&&d.slice(m,g).trim()==="")){if(n&&x===0&&c.getCodePoint(0)!==32){let B=l.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let O=this._bufferService.cols-L.start;x-=O,D+=O}}}if(s&&x+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=l.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(D+=L.length)}}return{start:x,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={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=L0(n,this._bufferService.cols)}};Ig=ui([Le(3,pn),Le(4,ol),Le(5,Zv),Le(6,mn),Le(7,Ss),Le(8,ys)],Ig);var B0=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},O0=class{constructor(){this._color=new B0,this._css=new B0}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Mi=Object.freeze((()=>{let e=[ii.toColor("#2e3436"),ii.toColor("#cc0000"),ii.toColor("#4e9a06"),ii.toColor("#c4a000"),ii.toColor("#3465a4"),ii.toColor("#75507b"),ii.toColor("#06989a"),ii.toColor("#d3d7cf"),ii.toColor("#555753"),ii.toColor("#ef2929"),ii.toColor("#8ae234"),ii.toColor("#fce94f"),ii.toColor("#729fcf"),ii.toColor("#ad7fa8"),ii.toColor("#34e2e2"),ii.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],l=t[n/6%6|0],c=t[n%6];e.push({css:ki.toCss(s,l,c),rgba:ki.toRgba(s,l,c)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ki.toCss(s,s,s),rgba:ki.toRgba(s,s,s)})}return e})()),Za=ii.toColor("#ffffff"),xc=ii.toColor("#000000"),j0=ii.toColor("#ffffff"),z0=xc,mc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},dN=Za,Hg=class extends ut{constructor(e){super(),this._optionsService=e,this._contrastCache=new O0,this._halfContrastCache=new O0,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Za,background:xc,cursor:j0,cursorAccent:z0,selectionForeground:void 0,selectionBackgroundTransparent:mc,selectionBackgroundOpaque:qt.blend(xc,mc),selectionInactiveBackgroundTransparent:mc,selectionInactiveBackgroundOpaque:qt.blend(xc,mc),scrollbarSliderBackground:qt.opacity(Za,.2),scrollbarSliderHoverBackground:qt.opacity(Za,.4),scrollbarSliderActiveBackground:qt.opacity(Za,.5),overviewRulerBorder:Za,ansi:Mi.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=Bt(e.foreground,Za),t.background=Bt(e.background,xc),t.cursor=qt.blend(t.background,Bt(e.cursor,j0)),t.cursorAccent=qt.blend(t.background,Bt(e.cursorAccent,z0)),t.selectionBackgroundTransparent=Bt(e.selectionBackground,mc),t.selectionBackgroundOpaque=qt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Bt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=qt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Bt(e.selectionForeground,M0):void 0,t.selectionForeground===M0&&(t.selectionForeground=void 0),qt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=qt.opacity(t.selectionBackgroundTransparent,.3)),qt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=qt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Bt(e.scrollbarSliderBackground,qt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Bt(e.scrollbarSliderHoverBackground,qt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Bt(e.scrollbarSliderActiveBackground,qt.opacity(t.foreground,.5)),t.overviewRulerBorder=Bt(e.overviewRulerBorder,dN),t.ansi=Mi.slice(),t.ansi[0]=Bt(e.black,Mi[0]),t.ansi[1]=Bt(e.red,Mi[1]),t.ansi[2]=Bt(e.green,Mi[2]),t.ansi[3]=Bt(e.yellow,Mi[3]),t.ansi[4]=Bt(e.blue,Mi[4]),t.ansi[5]=Bt(e.magenta,Mi[5]),t.ansi[6]=Bt(e.cyan,Mi[6]),t.ansi[7]=Bt(e.white,Mi[7]),t.ansi[8]=Bt(e.brightBlack,Mi[8]),t.ansi[9]=Bt(e.brightRed,Mi[9]),t.ansi[10]=Bt(e.brightGreen,Mi[10]),t.ansi[11]=Bt(e.brightYellow,Mi[11]),t.ansi[12]=Bt(e.brightBlue,Mi[12]),t.ansi[13]=Bt(e.brightMagenta,Mi[13]),t.ansi[14]=Bt(e.brightCyan,Mi[14]),t.ansi[15]=Bt(e.brightWhite,Mi[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=Bt(e.extendedAnsi[s],Mi[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()}}};Hg=ui([Le(0,mn)],Hg);function Bt(e,t){if(e!==void 0)try{return ii.toColor(e)}catch{}return t}var hN=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},fN=class{constructor(){this._services=new hN,this._services.set(Gv,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=aR(e).sort((c,d)=>c.index-d.index),s=[];for(let c of n){let d=this._services.get(c.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(d)}let l=n.length>0?n[0].index:t.length;if(t.length!==l)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${l+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},pN={trace:0,debug:1,info:2,warn:3,error:4,off:5},mN="xterm.js: ",Ug=class extends ut{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=pN[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,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":mN)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Ug=ui([Le(0,mn)],Ug);var P0=class extends ut{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),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 n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];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,...n){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+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let l=t-1;l>=0;l--)this.set(e+l+n,this.get(e+l));let s=e+t+n-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+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ct=3,Ci=Object.freeze(new su),Hd=0,bm=2,kc=class IC{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ct);let l=n||ur.fromCharData([0,rC,1,0]);for(let c=0;c<t;++c)this.setCell(c,l);this.length=t}get(t){let n=this._data[t*ct+0],s=n&2097151;return[this._data[t*ct+1],n&2097152?this._combined[t]:s?ca(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*ct+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*ct+0]=t|2097152|n[2]<<22):this._data[t*ct+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*ct+0]>>22}hasWidth(t){return this._data[t*ct+0]&12582912}getFg(t){return this._data[t*ct+1]}getBg(t){return this._data[t*ct+2]}hasContent(t){return this._data[t*ct+0]&4194303}getCodePoint(t){let n=this._data[t*ct+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*ct+0]&2097152}getString(t){let n=this._data[t*ct+0];return n&2097152?this._combined[t]:n&2097151?ca(n&2097151):""}isProtected(t){return this._data[t*ct+2]&536870912}loadCell(t,n){return Hd=t*ct,n.content=this._data[Hd+0],n.fg=this._data[Hd+1],n.bg=this._data[Hd+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*ct+0]=n.content,this._data[t*ct+1]=n.fg,this._data[t*ct+2]=n.bg}setCellFromCodepoint(t,n,s,l){l.bg&268435456&&(this._extendedAttrs[t]=l.extended),this._data[t*ct+0]=n|s<<22,this._data[t*ct+1]=l.fg,this._data[t*ct+2]=l.bg}addCodepointToCell(t,n,s){let l=this._data[t*ct+0];l&2097152?this._combined[t]+=ca(n):l&2097151?(this._combined[t]=ca(l&2097151)+ca(n),l&=-2097152,l|=2097152):l=n|1<<22,s&&(l&=-12582913,l|=s<<22),this._data[t*ct+0]=l}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let l=new ur;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,l));for(let c=0;c<n;++c)this.setCell(t+c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let l=new ur;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,l));for(let c=this.length-n;c<this.length;++c)this.setCell(c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,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,n,s,l=!1){if(l){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&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),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*bm<this._data.buffer.byteLength;let s=t*ct;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<t;++l)this.setCell(l,n)}else{this._data=this._data.subarray(0,s);let l=Object.keys(this._combined);for(let d=0;d<l.length;d++){let m=parseInt(l[d],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let d=0;d<c.length;d++){let m=parseInt(c[d],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,s*4*bm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*bm<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){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 n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new IC(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ct+0]&4194303)return t+(this._data[t*ct+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ct+0]&4194303||this._data[t*ct+2]&50331648)return t+(this._data[t*ct+0]>>22);return 0}copyCellsFrom(t,n,s,l,c){let d=t._data;if(c)for(let g=l-1;g>=0;g--){for(let f=0;f<ct;f++)this._data[(s+g)*ct+f]=d[(n+g)*ct+f];d[(n+g)*ct+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<l;g++){for(let f=0;f<ct;f++)this._data[(s+g)*ct+f]=d[(n+g)*ct+f];d[(n+g)*ct+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let f=parseInt(m[g],10);f>=n&&(this._combined[f-n+s]=t._combined[f])}}translateToString(t,n,s,l){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let c="";for(;n<s;){let d=this._data[n*ct+0],m=d&2097151,g=d&2097152?this._combined[n]:m?ca(m):ha;if(c+=g,l)for(let f=0;f<g.length;++f)l.push(n);n+=d>>22||1}return l&&l.push(n),c}};function gN(e,t,n,s,l,c){let d=[];for(let m=0;m<e.length-1;m++){let g=m,f=e.get(++g);if(!f.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&f.isWrapped;)y.push(f),f=e.get(++g);if(!c&&s>=m&&s<g){m+=y.length-1;continue}let b=0,C=Vc(y,b,t),w=1,x=0;for(;w<y.length;){let B=Vc(y,w,t),L=B-x,O=n-C,X=Math.min(L,O);y[b].copyCellsFrom(y[w],x,C,X,!1),C+=X,C===n&&(b++,C=0),x+=X,x===B&&(w++,x=0),C===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,C++,1,!1),y[b-1].setCell(n-1,l))}y[b].replaceCells(C,n,l);let D=0;for(let B=y.length-1;B>0&&(B>b||y[B].getTrimmedLength()===0);B--)D++;D>0&&(d.push(m+y.length-D),d.push(D)),m+=y.length-1}return d}function vN(e,t){let n=[],s=0,l=t[s],c=0;for(let d=0;d<e.length;d++)if(l===d){let m=t[++s];e.onDeleteEmitter.fire({index:d-c,amount:m}),d+=m-1,c+=m,l=t[++s]}else n.push(d);return{layout:n,countRemoved:c}}function _N(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function bN(e,t,n){let s=[],l=e.map((g,f)=>Vc(e,f,t)).reduce((g,f)=>g+f),c=0,d=0,m=0;for(;m<l;){if(l-m<n){s.push(l-m);break}c+=n;let g=Vc(e,d,t);c>g&&(c-=g,d++);let f=e[d].getWidth(c-1)===2;f&&c--;let y=f?n-1:n;s.push(y),m+=y}return s}function Vc(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,l=e[t+1].getWidth(0)===2;return s&&l?n-1:n}var HC=class UC{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=UC._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),al(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};HC._nextId=1;var yN=HC,Oi={},Qa=Oi.B;Oi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Oi.A={"#":"£"};Oi.B=void 0;Oi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Oi.C=Oi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Oi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Oi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Oi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Oi.E=Oi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Oi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Oi.H=Oi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var I0=4294967295,H0=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ci.clone(),this.savedCharset=Qa,this.markers=[],this._nullCell=ur.fromCharData([0,rC,1,0]),this._whitespaceCell=ur.fromCharData([0,ha,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Sh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new P0(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 vh),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 vh),this._whitespaceCell}getBlankLine(e,t){return new kc(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>I0?I0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ci);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 P0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ci),s=0,l=this._getCorrectBufferLength(t);if(l>this.lines.maxLength&&(this.lines.maxLength=l),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)s+=+this.lines.get(d).resize(e,n);let c=0;if(this._rows<t)for(let d=this._rows;d<t;d++)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 kc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new kc(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(l<this.lines.maxLength){let d=this.lines.length-l;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=l}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),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 c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,n);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 n=this._optionsService.rawOptions.reflowCursorLine,s=gN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ci),n);if(s.length>0){let l=vN(this.lines,s);_N(this.lines,l.layout),this._reflowLargerAdjustViewport(e,t,l.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ci),l=n;for(;l-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new kc(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Ci),l=[],c=0;for(let d=this.lines.length-1;d>=0;d--){let m=this.lines.get(d);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&d>0;)m=this.lines.get(--d),g.unshift(m);if(!n){let X=this.ybase+this.y;if(X>=d&&X<d+g.length)continue}let f=g[g.length-1].getTrimmedLength(),y=bN(g,this._cols,e),b=y.length-g.length,C;this.ybase===0&&this.y!==this.lines.length-1?C=Math.max(0,this.y-this.lines.maxLength+b):C=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let X=0;X<b;X++){let U=this.getBlankLine(Ci,!0);w.push(U)}w.length>0&&(l.push({start:d+g.length+c,newLines:w}),c+=w.length),g.push(...w);let x=y.length-1,D=y[x];D===0&&(x--,D=y[x]);let B=g.length-b-1,L=f;for(;B>=0;){let X=Math.min(L,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[B],L-X,D-X,X,!0),D-=X,D===0&&(x--,D=y[x]),L-=X,L===0){B--;let U=Math.max(B,0);L=Vc(g,U,this._cols)}}for(let X=0;X<g.length;X++)y[X]<e&&g[X].setCell(y[X],s);let O=b-C;for(;O-- >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+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(l.length>0){let d=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,f=g-1,y=0,b=l[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let C=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>f+C){for(let B=b.newLines.length-1;B>=0;B--)this.lines.set(D--,b.newLines[B]);D++,d.push({index:f+1,amount:b.newLines.length}),C+=b.newLines.length,b=l[++y]}else this.lines.set(D,m[f--]);let w=0;for(let D=d.length-1;D>=0;D--)d[D].index+=w,this.lines.onInsertEmitter.fire(d[D]),w+=d[D].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let l=this.lines.get(e);return l?l.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}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 yN(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},SN=class extends ut{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),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 H0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new H0(!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)}},KC=2,FC=1,Kg=class extends ut{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,KC),this.rows=Math.max(e.rawOptions.rows||0,FC),this.buffers=this._register(new SN(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=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:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let l=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;c===n.lines.length-1?d?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(c+1,0,s.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=c-l+1;n.lines.shiftElements(l+1,d-1,-1),n.lines.set(c,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Kg=ui([Le(0,mn)],Kg);var $l={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:yh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},wN=["normal","bold","100","200","300","400","500","600","700","800","900"],CN=class extends ut{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...$l};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Xt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in $l))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in $l))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=$l[e]),!xN(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=$l[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=wN.includes(t)?t:$l[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 xN(e){return e==="block"||e==="underline"||e==="bar"}function Ec(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Ec(e[s],t-1);return n}var U0=Object.freeze({insertMode:!1}),K0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fg=class extends ut{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ec(U0),this.decPrivateModes=Ec(K0)}reset(){this.modes=Ec(U0),this.decPrivateModes=Ec(K0)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.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))}};Fg=ui([Le(0,pn),Le(1,cC),Le(2,mn)],Fg);var F0={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 ym(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Sm=String.fromCharCode,W0={DEFAULT:e=>{let t=[ym(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Sm(t[0])}${Sm(t[1])}${Sm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ym(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ym(e,!0)};${e.x};${e.y}${t}`}},Wg=class extends ut{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(F0))this.addProtocol(s,F0[s]);for(let s of Object.keys(W0))this.addEncoding(s,W0[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,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,l=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=s+0,Math.abs(e.deltaY)<50&&(l*=.3),this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_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,n){if(n){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)}};Wg=ui([Le(0,pn),Le(1,ol),Le(2,mn)],Wg);var wm=[[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]],kN=[[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]],Ni;function EN(e,t){let n=0,s=t.length-1,l;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(l=n+s>>1,e>t[l][1])n=l+1;else if(e<t[l][0])s=l-1;else return!0;return!1}var TN=class{constructor(){if(this.version="6",!Ni){Ni=new Uint8Array(65536),Ni.fill(1),Ni[0]=0,Ni.fill(0,1,32),Ni.fill(0,127,160),Ni.fill(2,4352,4448),Ni[9001]=2,Ni[9002]=2,Ni.fill(2,11904,42192),Ni[12351]=1,Ni.fill(2,44032,55204),Ni.fill(2,63744,64256),Ni.fill(2,65040,65050),Ni.fill(2,65072,65136),Ni.fill(2,65280,65377),Ni.fill(2,65504,65511);for(let e=0;e<wm.length;++e)Ni.fill(0,wm[e][0],wm[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ni[e]:EN(e,kN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let l=Ja.extractWidth(t);l===0?s=!1:l>n&&(n=l)}return Ja.createPropertyValue(0,n,s)}},Ja=class ih{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new TN;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,n,s=!1){return(t&16777215)<<3|(n&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 n=0,s=0,l=t.length;for(let c=0;c<l;++c){let d=t.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=l)return n+this.wcwidth(d);let f=t.charCodeAt(c);56320<=f&&f<=57343?d=(d-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let m=this.charProperties(d,s),g=ih.extractWidth(m);ih.extractShouldJoin(m)&&(g-=ih.extractWidth(s)),n+=g,s=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},DN=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 q0(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var gc=2147483647,RN=256,WC=class qg{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>RN)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new qg;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let l=t[s];if(Array.isArray(l))for(let c=0;c<l.length;++c)n.addSubParam(l[c]);else n.addParam(l)}return n}clone(){let t=new qg(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 n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,l))}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>gc?gc: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>gc?gc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&(t[n]=this._subParams.slice(s,l))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,l=s[n-1];s[n-1]=~l?Math.min(l*10+t,gc):t}},vc=[],MN=class{constructor(){this._state=0,this._active=vc,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 n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=vc}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=vc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||vc,!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,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Uh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){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&&n-t>0&&this._put(e,t,n)}}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 n=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=vc,this._id=-1,this._state=0}}},qn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Uh(e,t,n),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(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},_c=[],NN=class{constructor(){this._handlers=Object.create(null),this._active=_c,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_c}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=_c,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||_c,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Uh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=_c,this._ident=0}},Tc=new WC;Tc.addParam(0);var $0=class{constructor(e){this._handler=e,this._data="",this._params=Tc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Tc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Uh(e,t,n),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(n=>(this._params=Tc,this._data="",this._hitLimit=!1,n));return this._params=Tc,this._data="",this._hitLimit=!1,t}},AN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let l=0;l<e.length;l++)this.table[t<<8|e[l]]=n<<4|s}},lr=160,LN=(function(){let e=new AN(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),s=n(32,127),l=n(0,24);l.push(25),l.push.apply(l,n(28,32));let c=n(0,14),d;e.setDefault(1,0),e.addMany(s,0,2,0);for(d in c)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(l,0,3,0),e.addMany(l,1,3,1),e.add(127,1,0,1),e.addMany(l,8,0,8),e.addMany(l,3,3,3),e.add(127,3,0,3),e.addMany(l,4,3,4),e.add(127,4,0,4),e.addMany(l,6,3,6),e.addMany(l,5,3,5),e.add(127,5,0,5),e.addMany(l,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(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(l,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(l,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(l,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(l,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(l,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(l,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(lr,0,2,0),e.add(lr,8,5,8),e.add(lr,6,0,6),e.add(lr,11,0,11),e.add(lr,13,13,13),e})(),BN=class extends ut{constructor(e=LN){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 WC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},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(Xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new MN),this._dcsParser=this._register(new NN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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 l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}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 n<<=8,n|=s,n}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 n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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 n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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,n,s,l){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=l}parse(e,t,n){let s=0,l=0,c=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,n),d)return d;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],d=this._oscParser.end(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(s=e[m],l=this._transitions.table[this.currentState<<8|(s<160?s:lr)],l>>4){case 2:for(let C=m+1;;++C){if(C>=t||(s=e[C])<32||s>126&&s<lr){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<lr){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<lr){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(s=e[C])<32||s>126&&s<lr){this._printHandler(e,m,C),m=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:m,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(d=g[f](this._params),d!==!0);f--)if(d instanceof Promise)return this._preserveStack(3,g,f,l,m),d;f<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(++m<t&&(s=e[m])>47&&s<60);m--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],b=y?y.length-1:-1;for(;b>=0&&(d=y[b](),d!==!0);b--)if(d instanceof Promise)return this._preserveStack(4,y,b,l,m),d;b<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=m+1;;++C)if(C>=t||(s=e[C])===24||s===26||s===27||s>127&&s<lr){this._dcsParser.put(e,m,C),m=C-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,l,m),d;s===27&&(l|=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=m+1;;C++)if(C>=t||(s=e[C])<32||s>127&&s<lr){this._oscParser.put(e,m,C),m=C-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,l,m),d;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},ON=/^([\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})$/,jN=/^[\da-f]+$/;function V0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=ON.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),jN.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let l=0;l<3;++l){let c=parseInt(t.slice(n*l,n*l+n),16);s[l]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return s}}function Cm(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function zN(e,t=16){let[n,s,l]=e;return`rgb:${Cm(n,t)}/${Cm(s,t)}/${Cm(l,t)}`}var PN={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ra=131072,Y0=10;function X0(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 G0=5e3,Z0=0,IN=class extends ut{constructor(e,t,n,s,l,c,d,m,g=new BN){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=l,this._oscLinkService=c,this._coreMouseService=d,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rR,this._utf8Decoder=new sR,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ci.clone(),this._eraseAttrDataInternal=Ci.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new $g(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:y.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:y,data:b})}),this._parser.setDcsHandlerFallback((f,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:y,payload:b})}),this._parser.setPrintHandler((f,y,b)=>this.print(f,y,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(me.BEL,()=>this.bell()),this._parser.setExecuteHandler(me.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(me.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(me.BS,()=>this.backspace()),this._parser.setExecuteHandler(me.HT,()=>this.tab()),this._parser.setExecuteHandler(me.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(me.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(eh.IND,()=>this.index()),this._parser.setExecuteHandler(eh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(eh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new qn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new qn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new qn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new qn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new qn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new qn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new qn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new qn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new qn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new qn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new qn(f=>this.restoreCursorColor(f))),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 f in Oi)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new $0((f,y)=>this.requestStatusString(f,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),G0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${G0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,l=this._activeBuffer.y,c=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,l=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ra&&(c=this._parseStack.position+ra)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ra&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ra))),d||this._dirtyRowTracker.clearRange(),e.length>ra)for(let f=c;f<e.length;f+=ra){let y=f+ra<e.length?f+ra:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,l,b,f),this._logSlowResolvingAsync(n),n}else if(!d){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,l,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==l)&&this._onCursorMove.fire();let m=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(m,this._bufferService.rows-1)})}print(e,t,n){let s,l,c=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let C=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(s=e[w],s<127&&c){let L=c[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let x=this._unicodeService.charProperties(s,C);l=Ja.extractWidth(x);let D=Ja.extractShouldJoin(x),B=D?Ja.extractWidth(C):0;if(C=x,d&&this._onA11yChar.fire(ca(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+l-B>m){if(g){let L=b,O=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&b instanceof kc&&b.copyCellsFrom(L,O,0,B,!1);O<m;)L.setCellFromCodepoint(O++,0,1,y)}else if(this._activeBuffer.x=m-1,l===2)continue}if(D&&this._activeBuffer.x){let L=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-L,s,l);for(let O=l-B;--O>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(f&&(b.insertCells(this._activeBuffer.x,l-B,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,s,l,y),l>0)for(;--l;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=C,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>X0(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new $0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,l=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),l),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,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 n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,l=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(l-1,1),this._activeBuffer.lines.splice(n,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 n=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(n,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(Ci));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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=e.params[0]||1,s=Ja.extractWidth(t),l=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(l),d=new Uint32Array(c.length*n),m=0;for(let f=0;f<c.length;){let y=c.codePointAt(f)||0;d[m++]=y,f+=y>65535?2:1}let g=m;for(let f=1;f<n;++f)d.copyWithin(g,0,m),g+=m;return this.print(d,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(me.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(me.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(me.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(me.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(me.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,Qa),this._charsetService.setgCharset(1,Qa),this._charsetService.setgCharset(2,Qa),this._charsetService.setgCharset(3,Qa);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){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let s=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:f,alt:y}=m,b=this._optionsService.rawOptions,C=(D,B)=>(d.triggerDataEvent(`${me.ESC}[${t?"":"?"}${D};${B}$y`),!0),w=D=>D?1:2,x=e.params[0];return t?x===2?C(x,4):x===4?C(x,w(d.modes.insertMode)):x===12?C(x,3):x===20?C(x,w(b.convertEol)):C(x,0):x===1?C(x,w(s.applicationCursorKeys)):x===3?C(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?C(x,w(s.origin)):x===7?C(x,w(s.wraparound)):x===8?C(x,3):x===9?C(x,w(l==="X10")):x===12?C(x,w(b.cursorBlink)):x===25?C(x,w(!d.isCursorHidden)):x===45?C(x,w(s.reverseWraparound)):x===66?C(x,w(s.applicationKeypad)):x===67?C(x,4):x===1e3?C(x,w(l==="VT200")):x===1002?C(x,w(l==="DRAG")):x===1003?C(x,w(l==="ANY")):x===1004?C(x,w(s.sendFocus)):x===1005?C(x,4):x===1006?C(x,w(c==="SGR")):x===1015?C(x,4):x===1016?C(x,w(c==="SGR_PIXELS")):x===1048?C(x,1):x===47||x===1047||x===1049?C(x,w(f===y)):x===2004?C(x,w(s.bracketedPasteMode)):x===2026?C(x,w(s.synchronizedOutput)):C(x,0)}_updateAttrColor(e,t,n,s,l){return t===2?(e|=50331648,e&=-16777216,e|=su.fromColorRGB([n,s,l])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],l=0,c=0;do{if(s[c+l]=e.params[t+c],e.hasSubParams(t+c)){let d=e.getSubParams(t+c),m=0;do s[1]===5&&(l=1),s[c+m+1+l]=d[m];while(++m<d.length&&m+c+1+l<s.length);break}if(s[1]===5&&c+l>=2||s[1]===2&&c+l>=5)break;s[1]&&(l=1)}while(++c+t<e.length&&c+l<s.length);for(let d=2;d<s.length;++d)s[d]===-1&&(s[d]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return c}_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=Ci.fg,e.bg=Ci.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,n,s=this._curAttrData;for(let l=0;l<t;l++)n=e.params[l],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(l)?e.getSubParams(l)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Ci.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ci.bg&16777215):n===38||n===48||n===58?l+=this._extractColor(e,l,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Ci.fg&16777215,s.bg&=-67108864,s.bg|=Ci.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${me.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[?${t};${n}R`)}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=Ci.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 n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!X0(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(`${me.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Y0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Y0&&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=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),l=n.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(Q0(c))if(l==="?")t.push({type:0,index:c});else{let d=V0(l);d&&t.push({type:1,index:c,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,l=n.findIndex(c=>c.startsWith("id="));return l!==-1&&(s=n[l].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 n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let l=V0(n[s]);l&&this._onColor.fire([{type:1,index:this._specialColors[t],color:l}])}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=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let l=parseInt(n[s]);Q0(l)&&t.push({type:2,index:l})}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,Qa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(PN[e[0]],Oi[e[1]]||Qa),!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=Ci.clone(),this._eraseAttrDataInternal=Ci.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 ur;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 n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${me.ESC}${d}${me.ESC}\\`),!0),s=this._bufferService.buffer,l=this._optionsService.rawOptions;return n(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}[l.cursorStyle]-(l.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},$g=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&&(Z0=e,e=t,t=Z0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};$g=ui([Le(0,pn)],$g);function Q0(e){return 0<=e&&e<256}var HN=5e7,J0=12,UN=50,KN=class extends ut{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 ke),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 n;for(;n=this._writeBuffer.shift();){this._action(n);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>HN)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 n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],l=this._action(s,t);if(l){let d=m=>performance.now()-n>=J0?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);l.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(d);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=J0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>UN&&(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()}},Vg=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 m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,s=this._getEntryIdKey(n),l=this._entriesWithId.get(s);if(l)return this.addLineToLink(l.id,t.ybase+t.y),l.id;let c=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Vg=ui([Le(0,pn)],Vg);var ew=!1,FN=class extends ut{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new lo),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new fN,this.optionsService=this._register(new CN(e)),this._instantiationService.setService(mn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Kg)),this._instantiationService.setService(pn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ug)),this._instantiationService.setService(cC,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fg)),this._instantiationService.setService(ol,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Wg)),this._instantiationService.setService(oC,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ja)),this._instantiationService.setService(cR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(DN),this._instantiationService.setService(oR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Vg),this._instantiationService.setService(uC,this._oscLinkService),this._inputHandler=this._register(new IN(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(en.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(en.forward(this._bufferService.onResize,this._onResize)),this._register(en.forward(this.coreService.onData,this._onData)),this._register(en.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 KN((t,n)=>this._inputHandler.parse(t,n))),this._register(en.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!ew&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ew=!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,KC),t=Math.max(t,FC),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(q0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(q0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Xt(()=>{for(let t of e)t.dispose()})}}},WN={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 qN(e,t,n,s){let l={type:0,cancel:!1,key:void 0},c=(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?l.key=me.ESC+"OA":l.key=me.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?l.key=me.ESC+"OD":l.key=me.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?l.key=me.ESC+"OC":l.key=me.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?l.key=me.ESC+"OB":l.key=me.ESC+"[B");break;case 8:l.key=e.ctrlKey?"\b":me.DEL,e.altKey&&(l.key=me.ESC+l.key);break;case 9:if(e.shiftKey){l.key=me.ESC+"[Z";break}l.key=me.HT,l.cancel=!0;break;case 13:l.key=e.altKey?me.ESC+me.CR:me.CR,l.cancel=!0;break;case 27:l.key=me.ESC,e.altKey&&(l.key=me.ESC+me.ESC),l.cancel=!0;break;case 37:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"D":t?l.key=me.ESC+"OD":l.key=me.ESC+"[D";break;case 39:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"C":t?l.key=me.ESC+"OC":l.key=me.ESC+"[C";break;case 38:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"A":t?l.key=me.ESC+"OA":l.key=me.ESC+"[A";break;case 40:if(e.metaKey)break;c?l.key=me.ESC+"[1;"+(c+1)+"B":t?l.key=me.ESC+"OB":l.key=me.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(l.key=me.ESC+"[2~");break;case 46:c?l.key=me.ESC+"[3;"+(c+1)+"~":l.key=me.ESC+"[3~";break;case 36:c?l.key=me.ESC+"[1;"+(c+1)+"H":t?l.key=me.ESC+"OH":l.key=me.ESC+"[H";break;case 35:c?l.key=me.ESC+"[1;"+(c+1)+"F":t?l.key=me.ESC+"OF":l.key=me.ESC+"[F";break;case 33:e.shiftKey?l.type=2:e.ctrlKey?l.key=me.ESC+"[5;"+(c+1)+"~":l.key=me.ESC+"[5~";break;case 34:e.shiftKey?l.type=3:e.ctrlKey?l.key=me.ESC+"[6;"+(c+1)+"~":l.key=me.ESC+"[6~";break;case 112:c?l.key=me.ESC+"[1;"+(c+1)+"P":l.key=me.ESC+"OP";break;case 113:c?l.key=me.ESC+"[1;"+(c+1)+"Q":l.key=me.ESC+"OQ";break;case 114:c?l.key=me.ESC+"[1;"+(c+1)+"R":l.key=me.ESC+"OR";break;case 115:c?l.key=me.ESC+"[1;"+(c+1)+"S":l.key=me.ESC+"OS";break;case 116:c?l.key=me.ESC+"[15;"+(c+1)+"~":l.key=me.ESC+"[15~";break;case 117:c?l.key=me.ESC+"[17;"+(c+1)+"~":l.key=me.ESC+"[17~";break;case 118:c?l.key=me.ESC+"[18;"+(c+1)+"~":l.key=me.ESC+"[18~";break;case 119:c?l.key=me.ESC+"[19;"+(c+1)+"~":l.key=me.ESC+"[19~";break;case 120:c?l.key=me.ESC+"[20;"+(c+1)+"~":l.key=me.ESC+"[20~";break;case 121:c?l.key=me.ESC+"[21;"+(c+1)+"~":l.key=me.ESC+"[21~";break;case 122:c?l.key=me.ESC+"[23;"+(c+1)+"~":l.key=me.ESC+"[23~";break;case 123:c?l.key=me.ESC+"[24;"+(c+1)+"~":l.key=me.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?l.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?l.key=me.NUL:e.keyCode>=51&&e.keyCode<=55?l.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?l.key=me.DEL:e.keyCode===219?l.key=me.ESC:e.keyCode===220?l.key=me.FS:e.keyCode===221&&(l.key=me.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=WN[e.keyCode]?.[e.shiftKey?1:0];if(d)l.key=me.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),l.key=me.ESC+g}else if(e.keyCode===32)l.key=me.ESC+(e.ctrlKey?me.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),l.key=me.ESC+m,l.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(l.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?l.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(l.key=me.US),e.key==="@"&&(l.key=me.NUL));break}return l}var gi=0,$N=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Sh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Sh,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((l,c)=>this._getKey(l)-this._getKey(c)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<s.length;l++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[l]=e[t],t++):s[l]=this._array[n++];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||(gi=this._search(t),gi===-1)||this._getKey(this._array[gi])!==t)return!1;do if(this._array[gi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(gi),!0;while(++gi<this._array.length&&this._getKey(this._array[gi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),t=0,n=new Array(this._array.length-e.length),s=0;for(let l=0;l<this._array.length;l++)e[t]===l?t++:n[s++]=this._array[l];this._array=n,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&&(gi=this._search(e),!(gi<0||gi>=this._array.length)&&this._getKey(this._array[gi])===e))do yield this._array[gi];while(++gi<this._array.length&&this._getKey(this._array[gi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(gi=this._search(e),!(gi<0||gi>=this._array.length)&&this._getKey(this._array[gi])===e))do t(this._array[gi]);while(++gi<this._array.length&&this._getKey(this._array[gi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,l=this._getKey(this._array[s]);if(l>e)n=s-1;else if(l<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},xm=0,tw=0,VN=class extends ut{constructor(){super(),this._decorations=new $N(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new YN(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.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,n){let s=0,l=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,l=s+(c.options.width??1),e>=s&&e<l&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,l=>{xm=l.options.x??0,tw=xm+(l.options.width??1),e>=xm&&e<tw&&(!n||(l.options.layer??"bottom")===n)&&s(l)})}},YN=class extends pa{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),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=ii.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ii.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},XN=1e3,GN=class{constructor(e,t=XN){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,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 l=s-this._lastRefreshMs,c=this._debounceThresholdMS-l;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_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)}},iw=20,wh=class extends ut{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let l=this._coreBrowserService.mainDocument;this._accessibilityContainer=l.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=l.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,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=l.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new GN(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(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
29
|
+
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ze(l,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Xt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<iw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===iw+1&&(this._liveRegion.textContent+=fg.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 n=this._terminal.buffer,s=n.lines.length.toString();for(let l=e;l<=t;l++){let c=n.lines.get(n.ydisp+l),d=[],m=c?.translateToString(!0,void 0,void 0,d)||"",g=(n.ydisp+l+1).toString(),f=this._rowElements[l];f&&(m.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=m,this._rowColumns.set(f,d)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],l=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(l===c||e.relatedTarget!==s)return;let d,m;if(t===0?(d=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(d=this._rowElements.shift(),m=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,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(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let l=({node:m,offset:g})=>{let f=m instanceof Text?m.parentNode:m,y=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(f);if(!b)return console.warn("columns is null. Race condition?"),null;let C=g<b.length?b[g]:b.slice(-1)[0]+1;return C>=this._terminal.cols&&(++y,C=0),{row:y,column:C}},c=l(t),d=l(n);if(!(!c||!d)){if(c.row>d.row||c.row===d.row&&c.column>=d.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(d.row-c.row)*this._terminal.cols-c.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};wh=ui([Le(1,Gv),Le(2,ys),Le(3,Ss)],wh);var Yg=class extends ut{constructor(e,t,n,s,l){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=l,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Xt(()=>{al(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ze(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ze(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ze(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ze(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 n=e.composedPath();for(let s=0;s<n.length;s++){let l=n[s];if(l.classList.contains("xterm"))break;if(l.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,l]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):l.provideLinks(e.y,c=>{if(this._isMouseOut)return;let d=c?.map(m=>({link:m}));this._activeProviderReplies?.set(s,d),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let l=t.get(s);if(l)for(let c=0;c<l.length;c++){let d=l[c],m=d.link.range.start.y<e?0:d.link.range.start.x,g=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let f=m;f<=g;f++){if(n.has(f)){l.splice(c--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),l=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(l=!0);if(!l&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&ZN(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,al(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,l=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=l&&(this._clearCurrentLink(s,l),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,l=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(l)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,l=t.y*this._bufferService.cols+t.x;return n<=l&&l<=s}_positionFromMouseEvent(e,t,n){let s=n.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,n,s,l){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:l}}};Yg=ui([Le(1,Zv),Le(2,Ss),Le(3,pn),Le(4,hC)],Yg);function ZN(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 QN=class extends FN{constructor(e={}){super(e),this._linkifier=this._register(new lo),this.browser=NC,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new lo),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(VN),this._instantiationService.setService(au,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(UM),this._instantiationService.setService(hC,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mg)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(en.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(en.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(en.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(en.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Xt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let l=qt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${me.ESC}]${s};${zN(l)}${RC.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=ki.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=ki.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(wh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.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 n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,l=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*l,d=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ze(this.element,"copy",t=>{this.hasSelection()&&iR(t,this._selectionService)}));let e=t=>nR(t,this.textarea,this.coreService,this.optionsService);this._register(Ze(this.textarea,"paste",e)),this._register(Ze(this.element,"paste",e)),AC?this._register(Ze(this.element,"mousedown",t=>{t.button===2&&h0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ze(this.element,"contextmenu",t=>{h0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s_&&this._register(Ze(this.element,"auxclick",t=>{t.button===1&&nC(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ze(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ze(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ze(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ze(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ze(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ze(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ze(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ze(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",hg.get()),OC||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",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(IM,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ys,this._coreBrowserService),this._register(Ze(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Ze(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(jg,this._document,this._helperContainer),this._instantiationService.setService(Kh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Hg),this._instantiationService.setService(mo,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(bh),this._instantiationService.setService(dC,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Pg,this.rows,this.screenElement)),this._instantiationService.setService(Ss,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Lg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zg),this._instantiationService.setService(Zv,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Yg,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(Ng,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ig,this.element,this.screenElement,s)),this._instantiationService.setService(dR,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(en.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ag,this.screenElement)),this._register(Ze(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),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(wh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_h,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_h,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Og,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),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()),c&8?s.mousemove||(t.addEventListener("mousemove",l.mousemove),s.mousemove=l.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",l.wheel,{passive:!1}),s.wheel=l.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ze(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Ze(t,"wheel",c=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let d=me.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){iC(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,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=qN(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.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((n.key===me.ETX||n.key===me.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=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"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(JN(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ci));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(me.ESC+"[I"):this.coreService.triggerDataEvent(me.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[6;${l};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function JN(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var eA=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;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)}},tA=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 ur)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},nw=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 tA(t)}getNullCell(){return new ur}},iA=class extends ut{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new nw(this._core.buffers.normal,"normal"),this._alternate=new nw(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)}},nA=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,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)}},rA=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}},sA=["cols","rows"],jr=0,aA=class extends ut{constructor(e){super(),this._core=this._register(new QN(e)),this._addonManager=this._register(new eA),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,l)=>{this._checkReadonlyOptions(s),this._core.options[s]=l};for(let s in this._core.options){let l={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,l)}}_checkReadonlyOptions(e){if(sA.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 nA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new rA(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 iA(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,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}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
|
|
31
|
+
`,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 hg.get()},set promptLabel(e){hg.set(e)},get tooMuchOutput(){return fg.get()},set tooMuchOutput(e){fg.set(e)}}}_verifyIntegers(...e){for(jr of e)if(jr===1/0||isNaN(jr)||jr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(jr of e)if(jr&&(jr===1/0||isNaN(jr)||jr%1!==0||jr<0))throw new Error("This API only accepts positive integers")}};class lA{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():YC.has(t)?this.acceptConsonant(t):XC.has(t)?this.acceptVowel(t):dA(t)&&this.canReplacePendingWith(t)?(this.pending=sw(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const l=this.flushPending();return this.pending={initial:t},l}if(!this.pending.final){if(GC.has(t))return this.pending.final=t,"";const l=this.flushPending();return this.pending={initial:t},l}const n=uA.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=cA.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=rw.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const s=this.pending.final,l=aw({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},l}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=rw.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=sw(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=aw(this.pending);return this.pending=null,t}}const Ch=44032,xh=21,Ql=28,oA=19*xh*Ql,qC=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],$C=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],VC=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],YC=a_(qC),XC=a_($C),GC=a_(VC),cA=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),ZC=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],uA=new Map(ZC),rw=new Map(ZC.map(([e,t])=>[t,[e[0],e[1]]]));function a_(e){return new Map(e.map((t,n)=>[t,n]))}function dA(e){const t=e.codePointAt(0);return t!==void 0&&t>=Ch&&t<Ch+oA}function sw(e){const t=e.codePointAt(0)-Ch,n=Math.floor(t/(xh*Ql)),s=Math.floor(t%(xh*Ql)/Ql),l=t%Ql,c={initial:qC[n],vowel:$C[s]};return l===0?c:{...c,final:VC[l]}}function aw(e){if(!e.vowel)return e.initial;const t=YC.get(e.initial),n=XC.get(e.vowel),s=e.final?GC.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Ch+(t*xh+n)*Ql+s)}const hA=[{key:"interrupt",label:"^C",ariaLabel:"Send Interrupt"},{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function fA({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:s,onHide:l}){function c(d){d.preventDefault(),d.stopPropagation(),s()}return p.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[p.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),hA.map(d=>p.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":d.ariaLabel,onClick:()=>n(d.key),children:d.label},d.key)),p.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:l,children:"×"})]})}const pA={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function mA(e){return pA[e]}function gA(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const QC="--nterminal-viewport-height",JC="--nterminal-keyboard-inset-bottom",ex="data-nterminal-keyboard-visible",qh="data-nterminal-compose-open",kh="nterminal:viewport-refresh",vA=120;function _A(e=window){const t=e.document.documentElement,n=e.visualViewport,s=xA(e);function l(){l_(e)}return l(),n?.addEventListener("resize",l),n?.addEventListener("scroll",l),s?.addEventListener("geometrychange",l),e.addEventListener("resize",l),e.addEventListener(kh,l),e.addEventListener("orientationchange",l),e.addEventListener("pageshow",l),e.document.addEventListener("visibilitychange",l),()=>{n?.removeEventListener("resize",l),n?.removeEventListener("scroll",l),s?.removeEventListener("geometrychange",l),e.removeEventListener("resize",l),e.removeEventListener(kh,l),e.removeEventListener("orientationchange",l),e.removeEventListener("pageshow",l),e.document.removeEventListener("visibilitychange",l),t.style.removeProperty(QC),t.style.removeProperty(JC),t.removeAttribute(ex)}}function l_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=Xg(e),l=bA(e,s);return l!==null&&lw(t,QC,`${l}px`),lw(t,JC,`${n}px`),yA(t,ex,String(s)),{viewportHeight:l,keyboardInsetBottom:n,keyboardVisible:s}}function Xg(e=window){const t=SA(e);return{keyboardInsetBottom:t,keyboardVisible:t>vA}}function bA(e,t){if((e.document.documentElement.hasAttribute(qh)||t)&&il(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return il(n)?n:il(e.innerHeight)?e.innerHeight:null}function il(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function lw(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function yA(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function SA(e){return Math.max(wA(e),CA(e))}function wA(e){const t=e.visualViewport?.height;if(!il(t)||!il(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function CA(e){if(!il(e.innerHeight))return 0;const n=tx(e)?.boundingRect?.height;return!il(n)||n>=e.innerHeight*.8?0:Math.round(n)}function tx(e){return e.navigator.virtualKeyboard}function xA(e){const t=tx(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const cu=new Map,Yc=new Map,kA=Object.freeze({open:!1,text:""});function EA(e){let t=Yc.get(e);return t||(t=new Set,Yc.set(e,t)),t}function ix(e){const t=Yc.get(e);if(t)for(const n of Array.from(t))n()}function $h(e){return cu.get(e)??kA}function TA(e,t){const n=EA(e);return n.add(t),()=>{n.delete(t)}}function DA(e,t){const n=$h(e);n.open!==t&&(cu.set(e,{...n,open:t}),ix(e))}function RA(e,t){const n=$h(e);n.text!==t&&(cu.set(e,{...n,text:t}),ix(e))}function Ud(e){cu.delete(e),Yc.delete(e)}function ow(){cu.clear(),Yc.clear()}const nx=120,MA="\x1B[200~",NA="\x1B[201~";function cw(e,t){const n=t.stripTrailingLineBreaks===!1?e:o_(e),s=LA(n);return s?t.bracketedPasteMode?`${MA}${s}${NA}`:s:""}function AA(e){return e==="queue"?" ":"\r"}function o_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function LA(e){return e.replace(/\r\n/g,`
|
|
32
32
|
`).replace(/\r/g,`
|
|
33
|
-
`).replace(/\n/g,"\r")}const LA=420,BA=3e3,uw=650,OA=80,jA=3,nh=new Set;let nl=null;function zA({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1}){const o=v.useMemo(()=>O=>EA(e,O),[e]),c=v.useMemo(()=>()=>$h(e),[e]),d=v.useSyncExternalStore(o,c,c),{open:m,text:g}=d,f=v.useRef(null),y=v.useRef(null),b=v.useRef(null),C=v.useRef(null);v.useEffect(()=>()=>{C.current?.(),C.current=null},[]),v.useLayoutEffect(()=>{if(!(!m||!rh()))return IA(e),()=>HA(e)},[m,e]),v.useLayoutEffect(()=>{const O=f.current?.closest(".terminal-pane");if(!O)return;function X(){O?.removeAttribute("data-compose-open"),O?.style.removeProperty("--compose-drawer-panel-height")}if(!m){X();return}const U=y.current;O.setAttribute("data-compose-open","true");function G(){const Se=U?.getBoundingClientRect().height??0;Se>0&&O?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Se)}px`)}G();const F=[window.setTimeout(G,0),window.setTimeout(G,180),window.setTimeout(G,260)],W=window.requestAnimationFrame?.(G)??null,ve=typeof ResizeObserver=="function"&&U?new ResizeObserver(G):null;return ve&&U&&ve.observe(U),()=>{for(const Se of F)window.clearTimeout(Se);W!==null&&window.cancelAnimationFrame?.(W),ve?.disconnect(),X()}},[m]),v.useEffect(()=>{if(!m){C.current?.(),C.current=null;return}dw(b.current),L()},[m]);function w(O){TA(e,O)}function x(O){DA(e,O)}function D(){PA(f.current),w(!1),hw()}function B(O="send"){if(!(s||!g)){if(t(g,O),x(""),rh()){b.current?.blur(),hw();return}window.setTimeout(()=>b.current?.focus(),nx+20)}}function L(){rh()&&(C.current?.(),C.current=UA())}return p.jsxs("div",{ref:f,className:"compose-drawer","data-open":m?"true":"false",children:[p.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":m?"true":void 0,tabIndex:m?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[p.jsx("span",{"aria-hidden":"true",children:"▴"}),p.jsx("span",{children:"compose"}),g?p.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),p.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":m?void 0:"true",children:[p.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:m?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[p.jsx("span",{"aria-hidden":"true",children:"▾"}),p.jsx("span",{className:"compose-drawer-title",children:"compose"}),p.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),p.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),p.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:m?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:O=>x(O.target.value),onFocus:L,onKeyDown:O=>{if(O.key==="Enter"&&(O.metaKey||O.ctrlKey)){if(O.preventDefault(),O.shiftKey){n&&B("queue");return}B("send");return}O.key==="Escape"&&(O.preventDefault(),D())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),p.jsxs("div",{className:"compose-drawer-actions",children:[p.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:m?0:-1,onClick:()=>{x(""),dw(b.current),L()},disabled:!g,children:"Clear"}),n?p.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:m?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>B("queue"),disabled:s||!g,children:"Queue"}):null,p.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:m?0:-1,onClick:()=>B("send"),disabled:s||!g,children:"Send"})]})]})]})}function PA(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function dw(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function rh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function hw(){if(!rh())return;const e=el;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function IA(e){nl!==null&&(window.clearTimeout(nl),nl=null),nh.add(e),document.documentElement.setAttribute(qh,"true"),el()}function HA(e){if(nh.delete(e),nh.size>0||nl!==null){el();return}nl=window.setTimeout(()=>{if(nl=null,nh.size>0){el();return}document.documentElement.removeAttribute(qh),el()},LA),el()}function UA(){let e=!1,t=null,n=null,s=null,o=0;const c=Date.now(),d=window.visualViewport,m=KA();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function f(){e||(e=!0,g(),d?.removeEventListener("resize",b),d?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(C){if(!e){if(C<uw&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,OA)}}function b(){if(e)return;g();const C=o_(),w=Date.now()-c;if(C.keyboardInsetBottom>0&&C.keyboardInsetBottom===s?o+=1:(o=C.keyboardInsetBottom>0?1:0,s=C.keyboardInsetBottom),w>=BA||w>=uw&&o>=jA){f();return}y(w)}return d?.addEventListener("resize",b),d?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),f}function el(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,o_()}function KA(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function FA(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if($A(d))return d.preventDefault(),d.stopPropagation(),WA(e),!1;if(qA(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(VA(d)){const m=Gg(e);return m?(d.preventDefault(),d.stopPropagation(),Zg(m),!1):!0}return YA(d)?(d.preventDefault(),d.stopPropagation(),XA(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const m=Gg(e);if(m){if(d.clipboardData){d.clipboardData.setData("text/plain",m),d.preventDefault();return}d.preventDefault(),Zg(m)}},c=d=>{const m=d.clipboardData?.getData("text/plain");if(!m)return;const g=l_(m);d.preventDefault(),d.stopImmediatePropagation(),rx(e,g,n.onPasteText)};return s.addEventListener("copy",o,!0),s.addEventListener("paste",c,!0),{dispose(){s.removeEventListener("copy",o,!0),s.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function WA(e){const t=Gg(e);t&&await Zg(t)}function qA(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function $A(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function VA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function YA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function XA(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;rx(e,l_(n),t)}catch{}}function rx(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function Gg(e){return e.hasSelection()?e.getSelection():GA(e.element??null)}function GA(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let s=0;s<t.rangeCount;s+=1){const o=t.getRangeAt(s);if(e.contains(o.commonAncestorContainer))return n}return""}async function Zg(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}ZA(e)}function ZA(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const QA=[4,10,11,12];function JA(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>fw(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>fw(s)),e.parser.registerCsiHandler({final:"n"},s=>eL(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>tL(s)),e.parser.registerCsiHandler({final:"t"},s=>iL(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...QA.map(s=>e.parser.registerOscHandler(s,o=>nL(o)))];return{dispose(){for(const s of n)s.dispose()}}}function fw(e){return Vh(e)===0}function eL(e){const t=Vh(e);return t===5||t===6}function tL(e){return Vh(e)===6}function iL(e){const t=Vh(e);return t===14||t===16||t===18}function nL(e){return e.split(";").some(t=>t==="?")}function Vh(e){const t=e[0];return typeof t=="number"?t:0}const _s=new Map,rL=2*1024*1024,sL=1500,pw=25e3,aL=2500,oL=1e3;let lL=0;function cL(e,t){let n=_s.get(e);n||(n=pL(e),_s.set(e,n),uu(n)),n.listeners.add(t);const s=c=>bL(n,c),o=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:s,detach:o}}function Dc(e){const t=_s.get(e);t&&(yL(t),_s.delete(e))}function uL(e,t={}){const n=_s.get(e);if(!n)return!1;n.exited=!1,n.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(n.preserveCachedOutputOnNextSnapshot=!0),n.reconnectTimer!==null&&(window.clearTimeout(n.reconnectTimer),n.reconnectTimer=null),vs(n,"reconnecting"),ba(n);const s=n.socket;return n.socket=null,ua(n,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),uu(n),!0}function dL(e){const t=_s.get(e);if(!t||(t.heartbeatSuspended=!1,t.exited||!t.reconnectEnabled||t.status==="unauthorized"))return Promise.resolve("skipped");const n=t.socket;if(!n||n.readyState!==WebSocket.OPEN)return Promise.resolve(t.status==="closed"?"skipped":"reconnecting");if(t.resumeProbe?.socket===n)return t.resumeProbe.promise;const s=Date.now();if(t.lastResumeProbeSocket===n&&s-t.lastResumeProbeAt<oL)return Promise.resolve("alive");vs(t,"reconnecting"),ba(t),t.lastResumeProbeSocket=n,t.lastResumeProbeAt=s;const o=`resume-${s.toString(36)}-${(++lL).toString(36)}`;let c;const d=new Promise(g=>{c=g}),m={socket:n,nonce:o,timeout:0,promise:d,resolve:c};t.resumeProbe=m,m.timeout=window.setTimeout(()=>{t.resumeProbe!==m||t.socket!==n||(vs(t,"reconnecting"),vw(t))},aL);try{n.send(JSON.stringify({type:"ping",nonce:o}))}catch{vs(t,"reconnecting"),vw(t)}return d}function hL(){for(const e of _s.values())e.heartbeatSuspended=!0,e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,vs(e,"skipped"),ba(e)}function fL(){for(const e of _s.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),ba(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,ua(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),uu(e)}}function km(){for(const e of Array.from(_s.keys()))Dc(e)}function pL(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function uu(e){if(!e.reconnectEnabled)return;ua(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,t.addEventListener("open",()=>{e.socket===t&&(ua(e,"connected"),gw(e,t),e.isAlive=!0,mw(e))}),t.addEventListener("message",n=>{if(e.socket!==t)return;const s=typeof n.data=="string"?n.data:"";if(!s)return;let o=null;try{o=JSON.parse(s)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;const d=e.resumeProbe;d?.socket===t&&d.nonce===o.nonce&&(e.lastResumeProbeAt=Date.now(),vs(e,"alive"),gw(e,t),mw(e));return}const c=gL(e,o);c_(e,{type:"message",message:c})}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,vs(e,"reconnecting"),ba(e),n.code===1008){e.reconnectEnabled=!1,ua(e,mL(n.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){ua(e,"closed");return}ua(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,uu(e)},sL)}}),t.addEventListener("error",()=>{})}function mw(e){if(ba(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),s=n-e.heartbeatTickAt>pw*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!s){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},pw)}function ba(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function mL(e){return e.trim().toLowerCase()==="unauthorized"}function gL(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,vL(e,t.output),Em(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+s.length,0),Em(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,Em(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function vL(e,t){const n=_L(e.output,t);if(n===0)return;const s=t.slice(n);for(const o of s)e.output.push(o),e.outputBytes+=o.length}function _L(e,t){const n=Math.min(e.length,t.length);for(let s=n;s>0;s-=1){let o=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){o=!1;break}if(o)return s}return 0}function Em(e){for(;e.outputBytes>rL&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function ua(e,t){e.status!==t&&(e.status=t,c_(e,{type:"status",status:t}))}function c_(e,t){for(const n of Array.from(e.listeners))n(t)}function bL(e,t){const n=e.socket,s=n?.readyState===WebSocket.OPEN;return(t.type==="input"||t.type==="cancel_scrollback")&&(!s||e.resumeProbe!==null||e.pendingOut.length>0)?(e.pendingOut.push(t),"queued"):s?(n.send(JSON.stringify(t)),"sent"):"rejected"}function gw(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe)return;const n=e.pendingOut.splice(0);for(let s=0;s<n.length;s+=1)try{t.send(JSON.stringify(n[s]))}catch{e.pendingOut.unshift(...n.slice(s)),t.close();return}n.length>0&&c_(e,{type:"outbound_flushed"})}function vs(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function vw(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),vs(e,"reconnecting"),ba(e);const t=e.socket;e.socket=null,ua(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),uu(e)}function yL(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),vs(e,"skipped"),ba(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const SL=[0,50,150,350],wL=[100,300,750],CL=2,xL=[300,1200,2500],kL=1e3,EL=1e5,TL="",Qg="\x1B[?1049l\x1B[?1047l\x1B[?47l",DL=new Set(["47","1047","1049"]),RL=400,ML=9,NL=9,AL=32,LL=1.42,BL=2,OL=24,jL=720,zL=60,PL=1260,IL=6,HL=2,_w=[500,1500,3e3,5e3,8e3],bw=15e3,UL=1e3,yw="Do not take action. Wait for my next input.",Eh=6e4,KL=Eh+5*6e4,Sw=Eh+6e4,FL=40,Kd=240,WL=5e3,qL=Li.lazy(()=>Xv(()=>import("./TranscriptMarkdownBody-BkGu6YVq.js"),__vite__mapDeps([2,1]))),Ic=new Map,Zo=new Map;function ww({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:d,codeServerContext:m,onSelect:g,onClose:f,onExit:y,onSnapshot:b,onAuthClose:C}){const w=v.useSyncExternalStore(H1,ng,()=>eo),x=v.useSyncExternalStore(U1,rg,()=>al),D=v.useSyncExternalStore(K1,ag,()=>!0),B=v.useSyncExternalStore(Xd,og,()=>!0),L=v.useSyncExternalStore(Xd,lg,()=>!0),O=v.useSyncExternalStore(Cv,pa,()=>sl),X=v.useSyncExternalStore(ph,()=>mh("history.toggle"),()=>"Alt+H"),U=v.useSyncExternalStore(ph,()=>mh("scrollback.toggle"),()=>"Alt+S"),G=v.useRef(null),F=v.useRef(null),W=v.useRef(null),ve=v.useRef(null),Se=v.useRef({onExit:y,onSnapshot:b}),xe=v.useRef(t.createWebSocketUrl),ie=v.useRef(C),q=v.useRef(null),J=v.useRef(null),K=v.useRef(null),re=v.useRef(!1),A=v.useRef(new Map),R=v.useRef(new Map),P=v.useRef(new Set),ne=v.useRef([]),ge=v.useRef(!1),M=v.useRef(null),V=v.useRef(0),le=v.useRef(!1),_e=v.useRef(!1),be=v.useRef(!1),Ee=v.useRef({terminalId:e.id,enabled:!1}),Me=v.useRef([]),Re=v.useRef([]),Pe=v.useRef(0),Be=v.useRef(!1),oe=v.useRef(null),he=v.useRef(0),ye=v.useRef(null),Oe=v.useRef(null),Ke=v.useRef(!1),je=v.useRef(!1),se=v.useRef(!1),Te=v.useRef(!1),we=v.useRef(null),ze=v.useRef(null),Ue=v.useRef(!1),nt=v.useRef(!1),ht=v.useRef(!1),Dt=v.useRef(!1),Ei=v.useRef(!1),ni=v.useRef(!1),di=v.useRef(!1),ae=v.useRef(n),Ne=v.useRef(s),Qe=v.useRef(c),it=v.useRef(w),jt=v.useRef(x),xt=v.useRef(!1),gt=v.useRef(null),Ht=v.useRef(e.id),kt=v.useRef(()=>{}),Rn=v.useRef(null),Mn=v.useRef(null),Z=v.useRef(!1),We=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),st=v.useRef(0),et=v.useRef(null),wt=v.useRef(0),Et=v.useRef(null),Ut=v.useRef(0),ri=v.useRef(!1),Gt=v.useRef(!1),Zt=v.useRef(null),[,Kt]=v.useState("connecting"),[Qt,ji]=v.useState(!1),[hi,zi]=v.useState(null),[gn,Yi]=v.useState(!1),[Ti,on]=v.useState(null),[Di,si]=v.useState(!1),[Pi,$n]=v.useState(!1),[ya,Vn]=v.useState(!1),[bl,Ss]=v.useState(!1),[It,ln]=v.useState(null),vi=e.agentCache&&It&&e.agentCache.source.provider===It.provider&&e.agentCache.source.sessionId===It.sessionId?e.agentCache:null,[Yn,wr]=v.useState(()=>Date.now()),[vn,$t]=v.useState(!1),[ho,ws]=v.useState(null),[Nn,_n]=v.useState(!1),[Xi,Ur]=v.useState(null),[fo,Sa]=v.useState(!1),[Cr,dr]=v.useState(!1),[An,fi]=v.useState(null),[wa,po]=v.useState(null),Ln=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Cs,xr]=v.useState(()=>om(e.id)),hr=!!It||Rc(e.currentCommand),Ii=It?.provider==="claude"||ux(e.currentCommand),dt=!!It||Rc(e.currentCommand),fr=e.capabilities?.tmuxScrollback===!0,ai=fr&&(Cs??(dt?L:B)),[Ca,xa]=v.useState(!1);v.useLayoutEffect(()=>{ae.current=n},[n]),v.useLayoutEffect(()=>{Ne.current=s},[s]),v.useLayoutEffect(()=>{Qe.current=c},[c]),v.useLayoutEffect(()=>{it.current=w},[w]),v.useLayoutEffect(()=>{jt.current=x},[x]),v.useLayoutEffect(()=>{xt.current=Nn},[Nn]),v.useLayoutEffect(()=>{gt.current=It},[It]);const pr=v.useCallback((k,I={})=>{!k&&I.preserveOnNull||ln(Ae=>Ae&&k&&Ae.provider===k.provider&&Ae.sessionId===k.sessionId?Ae:k)},[]),ks=v.useCallback(async(k={})=>{const I=await t.getTerminalTranscriptSource(e.id);return pr(I.source,k),I.source},[pr,t,e.id]),Es=v.useCallback(()=>{gt.current&&(async()=>{let k=gt.current;try{k=await ks({preserveOnNull:!0})??k}catch{}k&&(Rn.current=Dw(e.id,k),_n(!0))})()},[ks,e.id]),kr=v.useCallback(async(k={})=>{const I=await xw(Ln,t,k);return Ur(I),I},[Ln,t]),bn=v.useCallback((k,I="info")=>{Et.current!==null&&window.clearTimeout(Et.current),po({id:wt.current++,message:k,tone:I}),Et.current=window.setTimeout(()=>{po(null),Et.current=null},3200)},[]),mo=v.useCallback(()=>{const k=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Ae=m?.tabName.trim()||e.title||"Terminal",Fe=Xi?.instances.find(ft=>ft.cwd===e.cwd);if(Fe&&kw(Fd(k,Fe.id))){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Fe&&Tm(Fd(k,Fe.id),Fe.url)){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ve=null;const Je=()=>((!Ve||ax(Ve))&&(Ve=window.open("about:blank","_blank"),$L(Ve)),Ve);Xi?.installed!==!0&&Je(),dr(!0),fi(null),(async()=>{let ft=Xi;if(ft?.installed||(ft=await kr({force:!0})),!ft?.installed||ft.supported===!1){Dm(Ve),Sa(!0);return}const lt=ft.instances.find(Sn=>Sn.cwd===e.cwd);if(lt){const Sn=Fd(k,lt.id);if(Ew(Ve,Sn,lt.url)||Tm(Sn,lt.url)!==null){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Tt=Je();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Ae}),targetPopup:Tt}})().then(ft=>{if(!ft)return;const{response:lt,targetPopup:Tt}=ft;Jg(Ln,lt.status),Ur(lt.status);const ei=Fd(k,lt.instance.id);if(kw(ei)){Dm(Tt),bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}Ew(Tt,ei,lt.url)||Tm(ei,lt.url)?bn("Opening VS Code..."):bn("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ft=>{Dm(Ve),Sa(!0),fi(Wd(ft))}).finally(()=>dr(!1))},[m?.serverName,m?.tabName,Ln,Xi,kr,t,bn,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return xw(Ln,t).then(I=>{k||Ur(I)}).catch(()=>{}),()=>{k=!0}},[Ln,t]),v.useEffect(()=>{if(Xi?.job?.status!=="running")return;const k=window.setInterval(()=>{kr({force:!0}).catch(I=>fi(Wd(I)))},1e3);return()=>window.clearInterval(k)},[Xi?.job?.status,kr]),v.useEffect(()=>()=>{Et.current!==null&&window.clearTimeout(Et.current)},[]),v.useLayoutEffect(()=>{kt.current=Es},[Es]),v.useLayoutEffect(()=>{Mn.current=vi},[vi]),v.useLayoutEffect(()=>{Z.current=vn},[vn]),v.useLayoutEffect(()=>{ri.current=hr},[hr]),v.useLayoutEffect(()=>{Gt.current=Ii},[Ii]),v.useLayoutEffect(()=>{const k=Ee.current;_e.current=ai,be.current=fr,Ee.current={terminalId:e.id,enabled:ai},Aw(G.current,ai),k.terminalId===e.id&&k.enabled&&!ai&&xl(),ai||Vn(!1)},[e.id,ai,fr]),v.useEffect(()=>{xr(om(e.id)),V.current=0,le.current=!1,Vn(!1),vo()},[e.id]),v.useEffect(()=>Xd(()=>{xr(om(e.id))}),[e.id]),v.useEffect(()=>()=>{El()},[]),v.useEffect(()=>{let k=!1;return s&&e.status==="running"&&Wr(()=>k),()=>{k=!0}},[s,e.id,e.status]),v.useEffect(()=>{s&&n&&e.status==="running"&&jn("auto")},[n,s,e.status]),v.useEffect(()=>{Se.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{xe.current=t.createWebSocketUrl,ie.current=C},[t,C]),v.useEffect(()=>{let k=!1,I=null,Ae=0;const Fe=S3(e.currentCommand),Ve=Rc(e.currentCommand);function Je(){I!==null&&(window.clearTimeout(I),I=null)}function ft(Tt){if(k)return;let ei;if(Tt)ei=bw;else if(Ae<_w.length){if(!Fe)return;ei=_w[Ae++]}else{if(!Ve)return;ei=bw}I=window.setTimeout(()=>{I=null,lt()},ei)}async function lt(){try{const Tt=gt.current!==null,ei=await ks({preserveOnNull:Tt});if(k)return;!ei&&Tt&&!Fe&&(gt.current=null,ln(null)),ft(!!ei||Tt&&Fe)}catch(Tt){if(k)return;Rm(Tt)&&(gt.current=null,ln(null)),ft(!1)}}return Ht.current!==e.id&&(Ht.current=e.id,gt.current=null,ln(null)),e.status!=="running"?(gt.current=null,ln(null),()=>{k=!0,Je()}):(lt(),()=>{k=!0,Je()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=Dw(e.id,It),I=Rn.current;I!==null&&k!==null&&I!==k&&xt.current&&_n(!1),Rn.current=k},[e.id,It?.provider,It?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!It){$t(!1);return}const k=window.setInterval(()=>{wr(Date.now())},UL);return()=>{window.clearInterval(k)}},[e.status,It?.provider,It?.sessionId]),v.useEffect(()=>{const k=XL(vi);We.current.key!==k&&(We.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[vi?.expiresAt,vi?.source?.provider,vi?.source?.sessionId]),v.useEffect(()=>{if(!vn||!vi||vi.status!=="ready")return;const k=ox(vi,Yn);if(k===null||k<=0)return;const I=We.current;!I.warnedFiveMinutes&&k<=KL&&k>Sw&&(I.warnedFiveMinutes=!0,Rr({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!I.warnedOneMinute&&k<=Sw&&k>Eh&&(I.warnedOneMinute=!0,Rr({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&k<=Eh&&ku()},[vn,Yn,vi,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(I){if(!ae.current||!Ne.current||I.isComposing||I.key==="Process"||QL(I.target))return;const Ae=$1(I);if(Ae?.id==="history.toggle"&>.current){I.preventDefault(),I.stopPropagation(),xt.current?_n(!1):kt.current();return}if(Ae?.id==="scrollback.toggle"&&be.current){I.preventDefault(),I.stopPropagation(),kl();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=F.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&Kt("closed")},[e.status]),v.useEffect(()=>{const k=F.current;k&&(k.options.fontSize=w,am(w,jt.current).then(()=>{it.current===w&&T()}))},[w]),v.useEffect(()=>{const k=F.current;k&&(k.options.fontFamily=ig(x),am(it.current,x).then(()=>{jt.current===x&&T()}))},[x]),v.useEffect(()=>{const k=F.current;k&&(k.options.theme=Cw(O))},[O]),v.useEffect(()=>{const k=G.current;if(!k)return;let I=!1,Ae=null,Fe=null,Ve=null,Je=null,ft=null,lt=null,Tt=null;q.current=null,Ei.current=!1,ni.current=!1,Te.current=!1,pe(),ue(),Kr(),ge.current=!1;const ei=it.current,Sn=jt.current,un=new sA({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:ig(Sn),fontSize:ei,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:EL,theme:{...Cw(pa())}}),Rl=new GD;return un.loadAddon(Rl),Je=JA(un),F.current=un,W.current=Rl,am(ei,Sn).then(()=>{if(I)return;un.open(k),Aw(k,_e.current),Ei.current=!0,Ae=FA(un,{onPasteText:Ra,onInterrupt:Eu,shouldInterruptPlainCtrlC:()=>Gt.current}),Ne.current&&ae.current&&e.status==="running"&&jn("auto"),T(),ft=M3(k,un,()=>it.current*1.2,qe,Mr=>{tn(Mr)},wl,Da,()=>_e.current,Su),lt=T3(k,un,qe,Mr=>{tn(Mr)},wl,Da,()=>_e.current,Su);const Ml=new aA;Fe=un.onData(Mr=>{if(di.current){const _o=mA(Mr);if(_o){Na(!1),mr(_o);return}}const Yr=Ml.accept(Mr);Yr&&mr(Yr)}),Ve=un.onScroll(Mr=>{if(nt.current||Dt.current||ht.current){Ye();return}$r(),br(un)&&Vr({scrollToBottom:!0}),qe(),!_e.current&&Mr<=3&&tn()}),Tt=new ResizeObserver(()=>{Tr()}),Tt.observe(k),ni.current&&(Fr(),ni.current=!1,T()),S()}),()=>{Ns(ve.current,{updateUi:!1}),I=!0,Ei.current=!1,ni.current=!1,pe(),ue(),J.current=null,K.current=null,re.current=!1,Ce(),ge.current=!1,Vt(),ht.current=!1,ft?.(),lt?.(),Tt?.disconnect(),Ae?.dispose(),Fe?.dispose(),Ve?.dispose(),Je?.dispose(),un.dispose(),F.current=null,W.current=null}},[e.id]),v.useEffect(()=>{const k=xe.current(e.id),I=cL(k,yl);return ve.current=I.send,Kt(I.status),I.status==="connected"&&T(),I.snapshot&&(Se.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),F.current&&(T(),cn(I.output,I.history),T())),()=>{Ns(I.send,{updateUi:!1}),I.detach(),ve.current=null}},[e.id,e.status]);function yl(k){if(k.type==="status"){Kt(k.status),k.status==="unauthorized"&&ie.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(T(),j());return}if(k.type==="outbound_flushed"){ge.current&&(ge.current=!1,Tu());return}Bn(k.message)}function Kr(k=[],I=null){Me.current=[],Re.current=qd(k),Pe.current=0,Be.current=!1,oe.current=null,ht.current=!1,he.current+=1,ye.current=I,Oe.current=null,Ke.current=!1,je.current=!1,se.current=!1,ni.current=!1,Zt.current=null,we.current=null,Ue.current=!1,ji(!1),zi(null),Yi(!1),on(null),si(!1),$n(!1)}function cn(k=[],I=null){Kr(k,I),Er()}function Er(){if(!F.current||!Ei.current){ni.current=!0;return}ni.current=!1,Fr()}async function Fr(){const k=F.current;if(!k)return;const I=$d(k,Ue.current),Ae=I?Re.current.length:Pe.current,Fe=await Hi(k,{liveOutputLimit:Ae,scrollToBottom:I});F.current===k&&(Ye(),Fe&&j())}function Hi(k,I={}){return new Promise(Ae=>{ht.current=!0,Be.current=!1;const Fe=he.current+1;he.current=Fe;const Ve=Math.max(0,Math.min(I.liveOutputLimit??Re.current.length,Re.current.length)),Je=I.historyPages??Me.current,ft=()=>{if(F.current!==k||he.current!==Fe){Ae(!1);return}try{Pe.current=Ve,I.scrollToBottom&&go(k)}finally{ht.current=!1;const Tt=hu();Tt?Vr(Tt):I.applyDeferredSnapshot!==!1&&mu(),Ae(!0)}},lt=()=>{if(F.current!==k||he.current!==Fe){Ae(!1);return}k.clear();const Tt=qd([...Je,...Re.current.slice(0,Ve)]);if(Tt.length===0){ft();return}for(let ei=0;ei<Tt.length;ei+=1){const Sn=Tt[ei];ei===Tt.length-1?k.write(Sn,ft):k.write(Sn)}};if(k.buffer.active.type==="alternate"){k.write(Qg,lt);return}lt()})}async function tn(k=0){const I=F.current;if(se.current||!I)return;if(Sl(I)){Ye();return}const Ae=ye.current;se.current=!0,ji(!0);const Fe=I.buffer.active.viewportY;try{let Ve=!!(Ae&&!Ae.hasMore);if(!Ve)try{const Je=await t.getTerminalHistory(e.id,{beforeLine:Ae?.startLine??0,limit:kL}),ft={startLine:Je.startLine,endLine:Je.endLine,hasMore:Je.hasMore};if(Je.output.length>0){await Ts(I,Je.output,Fe,k)&&(ye.current=ft);return}ye.current=ft,Ve=!Je.hasMore}catch(Je){Ve=Rm(Je)}if(Ve){if(Sl(I)){Ye();return}await ka(I,Fe,k)}}catch{}finally{se.current=!1,ji(!1)}}async function ka(k,I,Ae){if(!(Ke.current||je.current))try{const Fe=Oe.current,Ve=await t.getTerminalTranscriptHistory(e.id,{...Fe?{cursor:Fe}:{},limit:RL}),Je=Ve.output.map(dx);if(!Ve.source)return;if(Je.length===0){ln(Ve.source),Oe.current=Ve.cursor,je.current=!Ve.hasMore||!Ve.cursor;return}await Ts(k,Je,I,Ae)&&(ln(Ve.source),Oe.current=Ve.cursor,je.current=!Ve.hasMore||!Ve.cursor)}catch(Fe){Rm(Fe)&&(Ke.current=!0)}}async function Ts(k,I,Ae,Fe){if(Sl(k))return Ye(),!1;const Ve=[...I,...Me.current],Je=k3(I);return!await Hi(k,{liveOutputLimit:Pe.current,scrollToBottom:!1,historyPages:Ve,applyDeferredSnapshot:!1})||F.current!==k?!1:(Me.current=Ve,Jh(k,Math.max(0,Ae+Je+Math.min(0,Fe))),Ue.current=!br(k),qe(),!0)}v.useEffect(()=>{const k=window.visualViewport;let I=!1;function Ae(){if(document.visibilityState==="hidden"){hL();return}Wr(()=>I)}function Fe(){Wr(()=>I)}function Ve(){Wr(()=>I)}function Je(){Tr()}function ft(){Ta()}return document.addEventListener("visibilitychange",Ae),window.addEventListener("pageshow",Fe),window.addEventListener("online",Ve),window.addEventListener("resize",Je),window.addEventListener(kh,ft),k?.addEventListener("resize",Je),k?.addEventListener("scroll",Je),()=>{I=!0,document.removeEventListener("visibilitychange",Ae),window.removeEventListener("pageshow",Fe),window.removeEventListener("online",Ve),window.removeEventListener("resize",Je),window.removeEventListener(kh,ft),k?.removeEventListener("resize",Je),k?.removeEventListener("scroll",Je)}},[e.id]);function Wr(k){if(document.visibilityState==="hidden"||!Ne.current)return;j(),T();const I=xe.current(e.id);dL(I).then(()=>{k()||(T(),j())})}function qr(){const k=xe.current(e.id);Te.current=!0,Zt.current=null,Kt("reconnecting"),T(),uL(k,{preserveCachedOutputOnNextSnapshot:!0})}function Bn(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Se.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Ae=F.current;if(!Ae)return;T();const Fe=Te.current;if(Te.current=!1,Fe){ye.current=k.history??ye.current,Ye(),T();return}if(fu(Ae,k.terminal)){Qh(k.output,k.history??null),Ye(),T();return}cn(k.output,k.history??null),T();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){Se.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Ae=px(k.data);if(!Ae)return;Re.current.push(Ae),F.current&&Ei.current?Vr({scrollToBottom:!0}):ni.current=!0;return}const I=F.current;if(I){if(k.type==="exit"&&k.terminalId===e.id){Se.current.onExit(k.exitCode),Kt("closed");return}k.type==="error"&&I.writeln(`\r
|
|
34
|
-
[nterminal] ${k.message}`)}}function Ea(k=25){if(document.visibilityState==="hidden"||!Ne.current||A.current.has(k))return;const I=window.setTimeout(()=>{A.current.delete(k),!yn()&&nf()},k);A.current.set(k,I)}function Tr(){yn()||S()}function yn(){const k=Dr();return k&&Ds(k)?(re.current=!0,K.current=k,!0):k&&Rs(k)?(re.current=!1,K.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(re.current=!1,K.current=null),!1)}function Ta(){if(!re.current)return;const k=Dr();k&&(k.composeOpen||k.keyboardVisible)||(re.current=!1,K.current=null)}function Ds(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const I=J.current;return I?nn(k.windowWidth,I.windowWidth)&&nn(k.visualViewportWidth,I.visualViewportWidth)&&nn(k.containerWidth,I.containerWidth):!1}function Rs(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const I=K.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:nn(k.windowWidth,I.windowWidth)&&nn(k.visualViewportWidth,I.visualViewportWidth)&&nn(k.containerWidth,I.containerWidth)}function Dr(){const k=G.current;if(!k||k.isConnected===!1)return null;const I=k.getBoundingClientRect(),Ae=Jt(window.innerWidth)??0,Fe=Jt(window.visualViewport?.width)??Ae,Ve=Jt(I.width)??Jt(k.clientWidth)??Ae;if(Ae<=0||Fe<=0||Ve<=0)return null;const{keyboardVisible:Je}=Xg(),ft=document.documentElement.hasAttribute(qh),lt=Ms()||Je;return{windowWidth:Ae,visualViewportWidth:Fe,containerWidth:Ve,composeOpen:ft,keyboardVisible:Je,mobileLike:lt}}function Ms(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function On(){return Xg().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Jt(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function nn(k,I){return Math.abs(k-I)<=CL}function S(){for(const k of SL)Ea(k)}function T(){q.current=null,S()}function j(){if(ee(),P.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{P.current.delete(k),ee();const I=window.requestAnimationFrame(()=>{P.current.delete(I),ee()});P.current.add(I)});P.current.add(k)}for(const k of wL){if(R.current.has(k))continue;const I=window.setTimeout(()=>{R.current.delete(k),ee()},k);R.current.set(k,I)}}function ee(){const k=F.current;if(!(!k||!Ei.current||document.visibilityState==="hidden"||!Ne.current||G.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function pe(){for(const k of A.current.values())window.clearTimeout(k);A.current.clear()}function ue(){for(const k of R.current.values())window.clearTimeout(k);R.current.clear();for(const k of P.current)window.cancelAnimationFrame(k);P.current.clear()}function Ce(){for(const k of ne.current)window.clearTimeout(k);ne.current=[]}function qe(){if(Ye(),!we.current){Yi(!1);return}Yi(!0),Vt(),ze.current=window.setTimeout(()=>{ze.current=null,Yi(!1)},1200)}function Ye(){const k=F.current,I=k?E3(k):null;if(we.current=I,zi(I),$n(!!(k&&I)),si(!!(k&&I&&!br(k))),I||!k||!_i()){on(null);return}on({alternate:k.buffer.active.type==="alternate"})}function _i(){const k=ye.current;return Me.current.length>0||!!k?.hasMore}function Vt(){ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null)}function $r(){const k=F.current;k&&(Ue.current=!br(k),Ye())}function du(k){oe.current=Mm(oe.current,k)}function Zh(k){const I=oe.current;return oe.current=null,Mm(I,k)}function hu(){const k=oe.current;return oe.current=null,k}function Vr(k={}){const I=F.current;if(!I||!Ei.current){ni.current=!0;return}if(ht.current){du(k);return}if(Be.current){du(k);return}const Ae=Zh(k);if(!Ae.force&&!$d(I,Ue.current)){Ye();return}Be.current=!0;const Fe=he.current,Ve=()=>{if(F.current!==I||he.current!==Fe){Be.current=!1;return}if(!Ae.force&&!$d(I,Ue.current)){Be.current=!1,Ye();return}const Je=Pe.current,ft=Re.current[Je];if(ft===void 0){Be.current=!1,Ae.scrollToBottom&&go(I),Ye();const lt=hu();lt?Vr(Mm(Ae,lt)):mu();return}I.write(ft,()=>{if(F.current!==I||he.current!==Fe){Be.current=!1;return}Pe.current=Je+1,Ve()})};Ve()}function Sl(k){return!br(k)&&(pu()||Be.current||ht.current)}function fu(k,I){return(ri.current||Rc(I?.currentCommand))&&!br(k)}function pu(){return Pe.current<Re.current.length}function Qh(k,I){Zt.current={output:k,history:I,appendFromLiveOutputIndex:Pe.current}}function mu(){const k=F.current,I=Zt.current;if(!k||!I||!br(k)||pu()||Be.current||ht.current)return;const Ae=qd(I.output),Fe=qd(Re.current.slice(I.appendFromLiveOutputIndex));Zt.current=null,cn(x3(Ae,Fe),I.history),T()}function wl(){Dt.current=!0}function Da(){$r(),Dt.current=!1;const k=F.current;k&&br(k)&&Vr({scrollToBottom:!0})}function go(k){gu(()=>Lw(k))&&(Ue.current=!1)}function Jh(k,I){gu(()=>(k.scrollToLine(I),!0))}function gu(k){nt.current=!0;try{return k()}finally{nt.current=!1}}function vu(){const k=F.current;if(!k)return;const I=()=>{_e.current&&(wu(ve.current),Vn(!1)),Lw(k),Ue.current=!1,Ye(),Vr({force:!0,scrollToBottom:!0}),jn("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(Qg,I);return}I()}function _u(k){const I=F.current,Ae=G.current;if(!I||!Ae)return;const Fe=Ae.getBoundingClientRect();if(Fe.height<=0)return;const Ve=Math.max(0,Math.min(1,(k-Fe.top)/Fe.height)),Je=Math.round(I.buffer.active.baseY*Ve);wl();try{I.scrollToLine(Je)}finally{Da()}Ue.current=!br(I),Ye(),qe(),Je<=3&&tn()}function ef(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),_u(k.clientY)}function tf(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),_u(k.clientY))}function nf(){const k=F.current,I=W.current;if(!(!k||!I)&&!(document.visibilityState==="hidden"||!Ne.current||G.current?.isConnected===!1))try{const Ae=$d(k,Ue.current),Fe=Dr();I.fit(),Fe&&(J.current=Fe),Ae&&go(k),k.refresh(0,Math.max(0,k.rows-1)),Ye();const Ve={cols:k.cols,rows:k.rows},Je=q.current;if(Je&&Je.cols===Ve.cols&&Je.rows===Ve.rows)return;Cl({type:"resize",terminalId:e.id,cols:Ve.cols,rows:Ve.rows})&&(q.current=Ve)}catch{}}function bu(k){const I=ve.current;return I?I(k):"rejected"}function Cl(k){return bu(k)==="sent"}function vo(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function yu(){vo();const k=Math.max(-Kd,Math.min(Kd,V.current));if(V.current=0,k===0)return!1;const I=Cl({type:"scrollback_scroll",terminalId:e.id,lines:k});return I&&(le.current=!0,k<0&&Vn(!0)),I}function Su(k){if(!_e.current||k===0)return;const I=V.current+k;V.current=Math.max(-Kd,Math.min(Kd,I)),M.current===null&&(M.current=window.setTimeout(()=>{M.current=null,yu()},FL))}function xl(){wu(ve.current)}function Ns(k=ve.current,I={}){const Ae=le.current;vo(),V.current=0,le.current=!1,I.updateUi!==!1&&Vn(!1),Ae&&k?.({type:"cancel_scrollback",terminalId:e.id})}function wu(k){vo(),V.current=0,le.current=!1,Vn(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function kl(){if(!be.current)return;const k=!_e.current;xr(sD(e.id,k)),sf()}function Cu(){const k=!Z.current;Z.current=k,$t(k),Rr({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function El(){et.current!==null&&(window.clearTimeout(et.current),et.current=null)}function Rr(k,I={}){El();const Ae=st.current+1;st.current=Ae,ws({...k,id:Ae}),!I.sticky&&(et.current=window.setTimeout(()=>{et.current=null,ws(Fe=>Fe?.id===Ae?null:Fe)},12e3))}function xu(){We.current.skipped=!0,Rr({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function As(){Z.current=!1,$t(!1),Rr({tone:"skipped",message:"Cache keep-alive off"})}async function ku(){const k=We.current;if(k.sent||k.skipped)return;const I=rf();if(k.sent=!0,I){Rr({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}mr(`${yw}\r`,{userInitiated:!1}),Rr({tone:"success",message:"Cache keep-alive sent",detail:yw})}function rf(){const k=Mn.current,I=gt.current;return Z.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!I?"Transcript cache status is unavailable.":k.source.provider!==I.provider||k.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Xc(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":$h(e.id).text.trim()?"Compose has an unsent draft.":JL(G.current)?"Pane input is focused.":Date.now()-Ut.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function sf(){const k=F.current;k&&(go(k),Ye())}function mr(k,I={}){I.userInitiated!==!1&&(Ut.current=Date.now()),yu();const Ae=le.current;le.current=!1,Ae&&Vn(!1),Vr({force:!0,scrollToBottom:!0});const Fe=bu({type:"input",terminalId:e.id,data:k,...Ae?{cancelScrollbackMode:!0}:{}});y3(k)&&(Fe==="sent"?Tu():Fe==="queued"&&(ge.current=!0))}function Eu(){di.current&&Na(!1),mr(TL)}function Ra(k){const I=cw(k,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&mr(I)}function Ma(k,I){const Ae=cw(k,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ae&&mr(Ae),window.setTimeout(()=>mr(NA(I)),nx)}function Tu(){!Qe.current||!ae.current||(Ce(),ne.current=xL.map(k=>{const I=window.setTimeout(()=>{ne.current=ne.current.filter(Ae=>Ae!==I),Qe.current&&ae.current&&Cl({type:"refresh_cwd",terminalId:e.id})},k);return I}))}function jn(k="terminal-interaction"){xt.current||On()&&(k==="auto"||k==="scroll-action")||F.current?.focus()}const Du=v.useCallback(()=>{_n(!1)},[]);function Ru(){Ss(k=>{const I=!k;return di.current=I,I}),jn("input-action")}function Na(k){di.current=k,Ss(k)}function Tl(k){di.current&&Na(!1),mr(pA(k)),jn("input-action")}async function Dl(k="install"){dr(!0),fi(null);try{const I=k==="update"?await t.updateCodeServer():await t.installCodeServer();Jg(Ln,I.status),Ur(I.status)}catch(I){fi(Wd(I))}finally{dr(!1)}}return p.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":ai?"true":"false",onMouseDown:()=>{n||g()},children:[p.jsx(e3,{terminal:e,canClose:o,tabId:d,transcriptSource:It,transcriptShortcutLabel:X,transcriptCacheStatus:vi,transcriptCacheNow:Yn,cacheKeepAliveEnabled:vn,codeServerAvailable:!0,codeServerInstallState:Xi===null?"unknown":Xi.installed?"installed":"missing",codeServerBusy:Cr||Xi?.job?.status==="running",codeServerSupported:Xi?.supported!==!1,scrollbackShortcutLabel:U,tmuxScrollbackSupported:fr,tmuxScrollbackEnabled:ai,onToggleCacheKeepAlive:Cu,onOpenCodeServer:mo,onToggleTmuxScrollback:kl,onOpenTranscript:Es,onReload:qr,onClose:f}),p.jsx("div",{className:"xterm-container",ref:G}),Qt?p.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:p.jsx("span",{"aria-hidden":"true"})}):null,D&&!ai&&hi?p.jsxs("div",{className:"terminal-scroll-progress","data-active":gn,"aria-hidden":"true",children:[hi.current,"/",hi.total]}):D&&!ai&&Ti?p.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ti.alternate?"alternate":"normal","aria-hidden":"true",children:[Ti.alternate?"alt ":"","0/?"]}):null,Di||ai&&ya?p.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),vu()},children:"↓"}):null,Pi&&!ai?p.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:ef,onPointerMove:tf,children:p.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Ca?p.jsx(hA,{ctrlActive:bl,onCtrl:Ru,onStandaloneKey:Tl,onPreserveFocus:()=>jn("input-action"),onHide:()=>xa(!1)}):p.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),jn("input-action")},onPointerDown:k=>{k.stopPropagation(),jn("input-action")},onClick:()=>xa(!0),children:"⌨"}):null,p.jsx(zA,{terminalId:e.id,onSubmit:Ma,queueAvailable:It?.provider==="codex"||cx(e.currentCommand),disabled:e.status!=="running"}),p.jsx(r3,{toast:ho,onSendNow:()=>{ku()},onSkipOnce:xu,onTurnOff:As,onDismiss:()=>ws(null)}),Nn&&It?p.jsx(s3,{terminalId:e.id,serverApi:t,source:It,fontSize:w,onClose:Du}):null,wa?p.jsx(i3,{notice:wa}):null,fo?p.jsx(t3,{status:Xi,busy:Cr,error:An,onInstall:()=>{Dl("install")},onUpdate:()=>{Dl("update")},onOpen:mo,onRefresh:()=>{kr({checkLatest:!0}).catch(k=>fi(Wd(k)))},onClose:()=>Sa(!1)}):null]})}function Cw(e){return wE(e)}async function xw(e,t,n={}){const s=n.checkLatest===!0,o=n.force===!0||s,c=Date.now(),d=Zo.get(e);if(!o&&d?.status&&c-d.fetchedAt<=WL)return d.status;if(d?.inflight&&(!s||d.inflightCheckLatest))return d.inflight;let m;return m=t.getCodeServerStatus(s?{checkLatest:!0}:void 0).then(g=>(Jg(e,g),g)).catch(g=>{const f=Zo.get(e);throw f?.inflight===m&&(f.status?Zo.set(e,{status:f.status,fetchedAt:f.fetchedAt}):Zo.delete(e)),g}),Zo.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:s}),m}function Jg(e,t){Zo.set(e,{status:t,fetchedAt:Date.now()})}function Fd(e,t){return`${e}:${t}`}function sx(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function kw(e){const t=Ic.get(e);if(!t)return!1;try{return t.closed?(Ic.delete(e),!1):(t.focus(),!0)}catch{return Ic.delete(e),!1}}function Tm(e,t){const n=window.open(t,sx(e));if(!n)return null;Ic.set(e,n);try{n.focus()}catch{}return n}function Ew(e,t,n){if(!e||ax(e))return!1;try{return e.name=sx(t),e.location.href=n,Ic.set(t,e),e.focus(),!0}catch{return!1}}function $L(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function ax(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Dm(e){if(e)try{e.closed||e.close()}catch{}}function VL(e,t,n){const s=YL(e,t),o=Tw(s*Math.max(1,n),zL,PL);return{limit:Tw(Math.ceil(o/BL),OL,jL),maxLines:o}}function YL(e,t){const n=e?.clientHeight??0;if(n<=0)return AL;const s=Math.max(10,t*LL);return Math.max(1,Math.floor(n/s))}function Tw(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function XL(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Dw(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function ox(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function GL(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function ZL(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const s=Math.floor(n/60),o=n%60;if(s<24&&o>0)return`${s}h ${o}m`;if(s<24)return`${s}h`;const c=Math.floor(s/24),d=s%24;return d>0?`${c}d ${d}h`:`${c}d`}function QL(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Wd(e){return e instanceof or||e instanceof Error?e.message:"Something went wrong."}function JL(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function e3({terminal:e,canClose:t,tabId:n,transcriptSource:s,transcriptShortcutLabel:o,transcriptCacheStatus:c,transcriptCacheNow:d,cacheKeepAliveEnabled:m,codeServerAvailable:g,codeServerInstallState:f,codeServerBusy:y,codeServerSupported:b,scrollbackShortcutLabel:C,tmuxScrollbackSupported:w,tmuxScrollbackEnabled:x,onToggleCacheKeepAlive:D,onOpenCodeServer:B,onToggleTmuxScrollback:L,onOpenTranscript:O,onReload:X,onClose:U}){const G=_1({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),F={cursor:n?"grab":"default",opacity:G.isDragging?.5:void 0};return p.jsxs("header",{ref:G.setNodeRef,className:"terminal-pane-header",style:F,"data-dragging":G.isDragging,...G.attributes,...G.listeners,children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),p.jsx("span",{className:"terminal-pane-spacer"}),g?p.jsx("button",{type:"button",className:"terminal-pane-code","data-state":f,"data-busy":y?"true":"false",disabled:!b||y,title:f==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":f==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:W=>W.stopPropagation(),onMouseDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),B()},children:p.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,s?p.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Xc(s.provider)} transcript history`,"aria-label":`View ${Xc(s.provider)} transcript history`,onPointerDown:W=>W.stopPropagation(),onMouseDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),O()},children:[p.jsx("span",{children:"View history"}),p.jsx("kbd",{children:o})]}):null,s?p.jsx(n3,{status:c,now:d,keepAliveEnabled:m,onToggle:D}):null,e.status==="exited"?p.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,w&&e.status==="running"?p.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":x?"true":"false","aria-pressed":x,"aria-label":`Toggle tmux scrollback (${C})`,title:x?`Scroll input uses tmux scrollback (${C}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${C}).`,onPointerDown:W=>W.stopPropagation(),onMouseDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),L()},children:[x?p.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):p.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),p.jsx("kbd",{children:C})]}):null,e.status==="running"?p.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:W=>W.stopPropagation(),onMouseDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),X()},children:"↻"}):null,t?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:W=>W.stopPropagation(),onMouseDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),U()},children:"x"}):null]})}function t3({status:e,busy:t,error:n,onInstall:s,onUpdate:o,onOpen:c,onRefresh:d,onClose:m}){const g=e?.job??null,f=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,C=e===null&&t,w=e?.updateAvailable===!0,x=y?"VS Code add-on":"Install VS Code add-on";return p.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:m,children:p.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsxs("div",{children:[p.jsx("h2",{children:x}),p.jsx("p",{children:C?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),p.jsxs("div",{className:"code-server-dialog-scroll",children:[p.jsxs("div",{className:"code-server-dialog-body",children:[p.jsxs("p",{children:["NTerminal installs code-server under ",p.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),C?p.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:p.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?p.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?p.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[p.jsxs("div",{className:"code-server-progress-heading",children:[p.jsx("span",{children:g.action}),p.jsx("strong",{children:g.status})]}),p.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
35
|
-
`):"Preparing..."})]}):null]}),p.jsxs("div",{className:"code-server-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!b,children:"Check"}),y?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:
|
|
36
|
-
`).length-1:0,
|
|
33
|
+
`).replace(/\n/g,"\r")}const BA=420,OA=3e3,uw=650,jA=80,zA=3,nh=new Set;let io=null;function PA({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1}){const l=v.useMemo(()=>O=>TA(e,O),[e]),c=v.useMemo(()=>()=>$h(e),[e]),d=v.useSyncExternalStore(l,c,c),{open:m,text:g}=d,f=v.useRef(null),y=v.useRef(null),b=v.useRef(null),C=v.useRef(null);v.useEffect(()=>()=>{C.current?.(),C.current=null},[]),v.useLayoutEffect(()=>{if(!(!m||!rh()))return HA(e),()=>UA(e)},[m,e]),v.useLayoutEffect(()=>{const O=f.current?.closest(".terminal-pane");if(!O)return;function X(){O?.removeAttribute("data-compose-open"),O?.style.removeProperty("--compose-drawer-panel-height")}if(!m){X();return}const U=y.current;O.setAttribute("data-compose-open","true");function G(){const Se=U?.getBoundingClientRect().height??0;Se>0&&O?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Se)}px`)}G();const W=[window.setTimeout(G,0),window.setTimeout(G,180),window.setTimeout(G,260)],q=window.requestAnimationFrame?.(G)??null,ge=typeof ResizeObserver=="function"&&U?new ResizeObserver(G):null;return ge&&U&&ge.observe(U),()=>{for(const Se of W)window.clearTimeout(Se);q!==null&&window.cancelAnimationFrame?.(q),ge?.disconnect(),X()}},[m]),v.useEffect(()=>{if(!m){C.current?.(),C.current=null;return}dw(b.current),L()},[m]);function w(O){DA(e,O)}function x(O){RA(e,O)}function D(){IA(f.current),w(!1),hw()}function B(O="send"){if(!(s||!g)){if(t(g,O),x(""),rh()){b.current?.blur(),hw();return}window.setTimeout(()=>b.current?.focus(),nx+20)}}function L(){rh()&&(C.current?.(),C.current=KA())}return p.jsxs("div",{ref:f,className:"compose-drawer","data-open":m?"true":"false",children:[p.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":m?"true":void 0,tabIndex:m?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[p.jsx("span",{"aria-hidden":"true",children:"▴"}),p.jsx("span",{children:"compose"}),g?p.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),p.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":m?void 0:"true",children:[p.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:m?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[p.jsx("span",{"aria-hidden":"true",children:"▾"}),p.jsx("span",{className:"compose-drawer-title",children:"compose"}),p.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),p.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),p.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:m?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:O=>x(O.target.value),onFocus:L,onKeyDown:O=>{if(O.key==="Enter"&&(O.metaKey||O.ctrlKey)){if(O.preventDefault(),O.shiftKey){n&&B("queue");return}B("send");return}O.key==="Escape"&&(O.preventDefault(),D())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),p.jsxs("div",{className:"compose-drawer-actions",children:[p.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:m?0:-1,onClick:()=>{x(""),dw(b.current),L()},disabled:!g,children:"Clear"}),n?p.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:m?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>B("queue"),disabled:s||!g,children:"Queue"}):null,p.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:m?0:-1,onClick:()=>B("send"),disabled:s||!g,children:"Send"})]})]})]})}function IA(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function dw(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function rh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function hw(){if(!rh())return;const e=Jl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function HA(e){io!==null&&(window.clearTimeout(io),io=null),nh.add(e),document.documentElement.setAttribute(qh,"true"),Jl()}function UA(e){if(nh.delete(e),nh.size>0||io!==null){Jl();return}io=window.setTimeout(()=>{if(io=null,nh.size>0){Jl();return}document.documentElement.removeAttribute(qh),Jl()},BA),Jl()}function KA(){let e=!1,t=null,n=null,s=null,l=0;const c=Date.now(),d=window.visualViewport,m=FA();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function f(){e||(e=!0,g(),d?.removeEventListener("resize",b),d?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(C){if(!e){if(C<uw&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,jA)}}function b(){if(e)return;g();const C=l_(),w=Date.now()-c;if(C.keyboardInsetBottom>0&&C.keyboardInsetBottom===s?l+=1:(l=C.keyboardInsetBottom>0?1:0,s=C.keyboardInsetBottom),w>=OA||w>=uw&&l>=zA){f();return}y(w)}return d?.addEventListener("resize",b),d?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),f}function Jl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,l_()}function FA(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function WA(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(VA(d))return d.preventDefault(),d.stopPropagation(),qA(e),!1;if($A(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(YA(d)){const m=Gg(e);return m?(d.preventDefault(),d.stopPropagation(),Zg(m),!1):!0}return XA(d)?(d.preventDefault(),d.stopPropagation(),GA(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const l=d=>{const m=Gg(e);if(m){if(d.clipboardData){d.clipboardData.setData("text/plain",m),d.preventDefault();return}d.preventDefault(),Zg(m)}},c=d=>{const m=d.clipboardData?.getData("text/plain");if(!m)return;const g=o_(m);d.preventDefault(),d.stopImmediatePropagation(),rx(e,g,n.onPasteText)};return s.addEventListener("copy",l,!0),s.addEventListener("paste",c,!0),{dispose(){s.removeEventListener("copy",l,!0),s.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function qA(e){const t=Gg(e);t&&await Zg(t)}function $A(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function VA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function YA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function XA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function GA(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;rx(e,o_(n),t)}catch{}}function rx(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function Gg(e){return e.hasSelection()?e.getSelection():ZA(e.element??null)}function ZA(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let s=0;s<t.rangeCount;s+=1){const l=t.getRangeAt(s);if(e.contains(l.commonAncestorContainer))return n}return""}async function Zg(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}QA(e)}function QA(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const JA=[4,10,11,12];function eL(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>fw(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>fw(s)),e.parser.registerCsiHandler({final:"n"},s=>tL(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>iL(s)),e.parser.registerCsiHandler({final:"t"},s=>nL(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...JA.map(s=>e.parser.registerOscHandler(s,l=>rL(l)))];return{dispose(){for(const s of n)s.dispose()}}}function fw(e){return Vh(e)===0}function tL(e){const t=Vh(e);return t===5||t===6}function iL(e){return Vh(e)===6}function nL(e){const t=Vh(e);return t===14||t===16||t===18}function rL(e){return e.split(";").some(t=>t==="?")}function Vh(e){const t=e[0];return typeof t=="number"?t:0}const bs=new Map,sL=2*1024*1024,aL=1500,pw=25e3,lL=2500,oL=1e3;let cL=0;function uL(e,t){let n=bs.get(e);n||(n=mL(e),bs.set(e,n),uu(n)),n.listeners.add(t);const s=c=>yL(n,c),l=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:s,detach:l}}function Dc(e){const t=bs.get(e);t&&(SL(t),bs.delete(e))}function dL(e,t={}){const n=bs.get(e);if(!n)return!1;n.exited=!1,n.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(n.preserveCachedOutputOnNextSnapshot=!0),n.reconnectTimer!==null&&(window.clearTimeout(n.reconnectTimer),n.reconnectTimer=null),_s(n,"reconnecting"),ya(n);const s=n.socket;return n.socket=null,da(n,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),uu(n),!0}function hL(e){const t=bs.get(e);if(!t||(t.heartbeatSuspended=!1,t.exited||!t.reconnectEnabled||t.status==="unauthorized"))return Promise.resolve("skipped");const n=t.socket;if(!n||n.readyState!==WebSocket.OPEN)return Promise.resolve(t.status==="closed"?"skipped":"reconnecting");if(t.resumeProbe?.socket===n)return t.resumeProbe.promise;const s=Date.now();if(t.lastResumeProbeSocket===n&&s-t.lastResumeProbeAt<oL)return Promise.resolve("alive");_s(t,"reconnecting"),ya(t),t.lastResumeProbeSocket=n,t.lastResumeProbeAt=s;const l=`resume-${s.toString(36)}-${(++cL).toString(36)}`;let c;const d=new Promise(g=>{c=g}),m={socket:n,nonce:l,timeout:0,promise:d,resolve:c};t.resumeProbe=m,m.timeout=window.setTimeout(()=>{t.resumeProbe!==m||t.socket!==n||(_s(t,"reconnecting"),vw(t))},lL);try{n.send(JSON.stringify({type:"ping",nonce:l}))}catch{_s(t,"reconnecting"),vw(t)}return d}function fL(){for(const e of bs.values())e.heartbeatSuspended=!0,e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,_s(e,"skipped"),ya(e)}function pL(){for(const e of bs.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),ya(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),uu(e)}}function km(){for(const e of Array.from(bs.keys()))Dc(e)}function mL(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function uu(e){if(!e.reconnectEnabled)return;da(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,t.addEventListener("open",()=>{e.socket===t&&(da(e,"connected"),gw(e,t),e.isAlive=!0,mw(e))}),t.addEventListener("message",n=>{if(e.socket!==t)return;const s=typeof n.data=="string"?n.data:"";if(!s)return;let l=null;try{l=JSON.parse(s)}catch{return}if(!l||typeof l.type!="string")return;if(l.type==="pong"){e.isAlive=!0;const d=e.resumeProbe;d?.socket===t&&d.nonce===l.nonce&&(e.lastResumeProbeAt=Date.now(),_s(e,"alive"),gw(e,t),mw(e));return}const c=vL(e,l);c_(e,{type:"message",message:c})}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,_s(e,"reconnecting"),ya(e),n.code===1008){e.reconnectEnabled=!1,da(e,gL(n.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){da(e,"closed");return}da(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,uu(e)},aL)}}),t.addEventListener("error",()=>{})}function mw(e){if(ya(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),s=n-e.heartbeatTickAt>pw*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!s){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},pw)}function ya(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function gL(e){return e.trim().toLowerCase()==="unauthorized"}function vL(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,_L(e,t.output),Em(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+s.length,0),Em(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,Em(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function _L(e,t){const n=bL(e.output,t);if(n===0)return;const s=t.slice(n);for(const l of s)e.output.push(l),e.outputBytes+=l.length}function bL(e,t){const n=Math.min(e.length,t.length);for(let s=n;s>0;s-=1){let l=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){l=!1;break}if(l)return s}return 0}function Em(e){for(;e.outputBytes>sL&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function da(e,t){e.status!==t&&(e.status=t,c_(e,{type:"status",status:t}))}function c_(e,t){for(const n of Array.from(e.listeners))n(t)}function yL(e,t){const n=e.socket,s=n?.readyState===WebSocket.OPEN;return(t.type==="input"||t.type==="cancel_scrollback")&&(!s||e.resumeProbe!==null||e.pendingOut.length>0)?(e.pendingOut.push(t),"queued"):s?(n.send(JSON.stringify(t)),"sent"):"rejected"}function gw(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe)return;const n=e.pendingOut.splice(0);for(let s=0;s<n.length;s+=1)try{t.send(JSON.stringify(n[s]))}catch{e.pendingOut.unshift(...n.slice(s)),t.close();return}n.length>0&&c_(e,{type:"outbound_flushed"})}function _s(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function vw(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),_s(e,"reconnecting"),ya(e);const t=e.socket;e.socket=null,da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),uu(e)}function SL(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),_s(e,"skipped"),ya(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const wL=[0,50,150,350],CL=[100,300,750],xL=2,kL=[300,1200,2500],EL=1e3,TL=1e5,DL="",Qg="\x1B[?1049l\x1B[?1047l\x1B[?47l",RL=new Set(["47","1047","1049"]),ML=400,NL=9,AL=9,LL=32,BL=1.42,OL=2,jL=24,zL=720,PL=60,IL=1260,HL=6,UL=2,_w=[500,1500,3e3,5e3,8e3],bw=15e3,KL=1e3,yw="Do not take action. Wait for my next input.",Eh=6e4,FL=Eh+5*6e4,Sw=Eh+6e4,WL=40,Kd=240,qL=5e3,$L=Li.lazy(()=>Xv(()=>import("./TranscriptMarkdownBody-9-cPRj-d.js"),__vite__mapDeps([2,1]))),Ic=new Map,Gl=new Map;function ww({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:l,refreshCwdOnEnter:c=!1,tabId:d,codeServerContext:m,onSelect:g,onClose:f,onExit:y,onSnapshot:b,onAuthClose:C}){const w=v.useSyncExternalStore(H1,ng,()=>el),x=v.useSyncExternalStore(U1,rg,()=>so),D=v.useSyncExternalStore(K1,ag,()=>!0),B=v.useSyncExternalStore(Xd,lg,()=>!0),L=v.useSyncExternalStore(Xd,og,()=>!0),O=v.useSyncExternalStore(Cv,ma,()=>ro),X=v.useSyncExternalStore(ph,()=>mh("history.toggle"),()=>"Alt+H"),U=v.useSyncExternalStore(ph,()=>mh("scrollback.toggle"),()=>"Alt+S"),G=v.useRef(null),W=v.useRef(null),q=v.useRef(null),ge=v.useRef(null),Se=v.useRef({onExit:y,onSnapshot:b}),xe=v.useRef(t.createWebSocketUrl),re=v.useRef(C),$=v.useRef(null),J=v.useRef(null),K=v.useRef(null),se=v.useRef(!1),A=v.useRef(new Map),R=v.useRef(new Map),z=v.useRef(new Set),ne=v.useRef([]),_e=v.useRef(!1),M=v.useRef(null),F=v.useRef(0),ie=v.useRef(!1),ve=v.useRef(!1),be=v.useRef(!1),Ee=v.useRef({terminalId:e.id,enabled:!1}),Me=v.useRef([]),Re=v.useRef([]),Pe=v.useRef(0),Be=v.useRef(!1),oe=v.useRef(null),he=v.useRef(0),ye=v.useRef(null),Oe=v.useRef(null),Ke=v.useRef(!1),je=v.useRef(!1),ae=v.useRef(!1),Te=v.useRef(!1),we=v.useRef(null),ze=v.useRef(null),Ue=v.useRef(!1),nt=v.useRef(!1),ht=v.useRef(!1),Dt=v.useRef(!1),Ei=v.useRef(!1),ni=v.useRef(!1),di=v.useRef(!1),le=v.useRef(n),Ne=v.useRef(s),Qe=v.useRef(c),it=v.useRef(w),jt=v.useRef(x),xt=v.useRef(!1),gt=v.useRef(null),Ht=v.useRef(e.id),kt=v.useRef(()=>{}),Mn=v.useRef(null),Nn=v.useRef(null),Z=v.useRef(!1),We=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),st=v.useRef(0),et=v.useRef(null),wt=v.useRef(0),Et=v.useRef(null),Ut=v.useRef(0),ri=v.useRef(!1),Gt=v.useRef(!1),Zt=v.useRef(null),[,Kt]=v.useState("connecting"),[Qt,ji]=v.useState(!1),[hi,zi]=v.useState(null),[gn,Yi]=v.useState(!1),[Ti,ln]=v.useState(null),[Di,si]=v.useState(!1),[Pi,Vn]=v.useState(!1),[Sa,Yn]=v.useState(!1),[bo,ws]=v.useState(!1),[It,on]=v.useState(null),vi=e.agentCache&&It&&e.agentCache.source.provider===It.provider&&e.agentCache.source.sessionId===It.sessionId?e.agentCache:null,[Xn,wr]=v.useState(()=>Date.now()),[vn,$t]=v.useState(!1),[dl,Cs]=v.useState(null),[An,_n]=v.useState(!1),[Xi,Ur]=v.useState(null),[hl,wa]=v.useState(!1),[Cr,dr]=v.useState(!1),[Ln,fi]=v.useState(null),[Ca,fl]=v.useState(null),Bn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[xs,xr]=v.useState(()=>lm(e.id)),hr=!!It||Rc(e.currentCommand),Ii=It?.provider==="claude"||ux(e.currentCommand),dt=!!It||Rc(e.currentCommand),fr=e.capabilities?.tmuxScrollback===!0,ai=fr&&(xs??(dt?L:B)),[xa,ka]=v.useState(!1);v.useLayoutEffect(()=>{le.current=n},[n]),v.useLayoutEffect(()=>{Ne.current=s},[s]),v.useLayoutEffect(()=>{Qe.current=c},[c]),v.useLayoutEffect(()=>{it.current=w},[w]),v.useLayoutEffect(()=>{jt.current=x},[x]),v.useLayoutEffect(()=>{xt.current=An},[An]),v.useLayoutEffect(()=>{gt.current=It},[It]);const pr=v.useCallback((k,I={})=>{!k&&I.preserveOnNull||on(Ae=>Ae&&k&&Ae.provider===k.provider&&Ae.sessionId===k.sessionId?Ae:k)},[]),Es=v.useCallback(async(k={})=>{const I=await t.getTerminalTranscriptSource(e.id);return pr(I.source,k),I.source},[pr,t,e.id]),Ts=v.useCallback(()=>{gt.current&&(async()=>{let k=gt.current;try{k=await Es({preserveOnNull:!0})??k}catch{}k&&(Mn.current=Dw(e.id,k),_n(!0))})()},[Es,e.id]),kr=v.useCallback(async(k={})=>{const I=await xw(Bn,t,k);return Ur(I),I},[Bn,t]),bn=v.useCallback((k,I="info")=>{Et.current!==null&&window.clearTimeout(Et.current),fl({id:wt.current++,message:k,tone:I}),Et.current=window.setTimeout(()=>{fl(null),Et.current=null},3200)},[]),pl=v.useCallback(()=>{const k=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Ae=m?.tabName.trim()||e.title||"Terminal",Fe=Xi?.instances.find(ft=>ft.cwd===e.cwd);if(Fe&&kw(Fd(k,Fe.id))){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Fe&&Tm(Fd(k,Fe.id),Fe.url)){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ve=null;const Je=()=>((!Ve||ax(Ve))&&(Ve=window.open("about:blank","_blank"),VL(Ve)),Ve);Xi?.installed!==!0&&Je(),dr(!0),fi(null),(async()=>{let ft=Xi;if(ft?.installed||(ft=await kr({force:!0})),!ft?.installed||ft.supported===!1){Dm(Ve),wa(!0);return}const ot=ft.instances.find(Sn=>Sn.cwd===e.cwd);if(ot){const Sn=Fd(k,ot.id);if(Ew(Ve,Sn,ot.url)||Tm(Sn,ot.url)!==null){bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Tt=Je();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Ae}),targetPopup:Tt}})().then(ft=>{if(!ft)return;const{response:ot,targetPopup:Tt}=ft;Jg(Bn,ot.status),Ur(ot.status);const ei=Fd(k,ot.instance.id);if(kw(ei)){Dm(Tt),bn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}Ew(Tt,ei,ot.url)||Tm(ei,ot.url)?bn("Opening VS Code..."):bn("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ft=>{Dm(Ve),wa(!0),fi(Wd(ft))}).finally(()=>dr(!1))},[m?.serverName,m?.tabName,Bn,Xi,kr,t,bn,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return xw(Bn,t).then(I=>{k||Ur(I)}).catch(()=>{}),()=>{k=!0}},[Bn,t]),v.useEffect(()=>{if(Xi?.job?.status!=="running")return;const k=window.setInterval(()=>{kr({force:!0}).catch(I=>fi(Wd(I)))},1e3);return()=>window.clearInterval(k)},[Xi?.job?.status,kr]),v.useEffect(()=>()=>{Et.current!==null&&window.clearTimeout(Et.current)},[]),v.useLayoutEffect(()=>{kt.current=Ts},[Ts]),v.useLayoutEffect(()=>{Nn.current=vi},[vi]),v.useLayoutEffect(()=>{Z.current=vn},[vn]),v.useLayoutEffect(()=>{ri.current=hr},[hr]),v.useLayoutEffect(()=>{Gt.current=Ii},[Ii]),v.useLayoutEffect(()=>{const k=Ee.current;ve.current=ai,be.current=fr,Ee.current={terminalId:e.id,enabled:ai},Aw(G.current,ai),k.terminalId===e.id&&k.enabled&&!ai&&xo(),ai||Yn(!1)},[e.id,ai,fr]),v.useEffect(()=>{xr(lm(e.id)),F.current=0,ie.current=!1,Yn(!1),gl()},[e.id]),v.useEffect(()=>Xd(()=>{xr(lm(e.id))}),[e.id]),v.useEffect(()=>()=>{Eo()},[]),v.useEffect(()=>{let k=!1;return s&&e.status==="running"&&Wr(()=>k),()=>{k=!0}},[s,e.id,e.status]),v.useEffect(()=>{s&&n&&e.status==="running"&&zn("auto")},[n,s,e.status]),v.useEffect(()=>{Se.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{xe.current=t.createWebSocketUrl,re.current=C},[t,C]),v.useEffect(()=>{let k=!1,I=null,Ae=0;const Fe=w3(e.currentCommand),Ve=Rc(e.currentCommand);function Je(){I!==null&&(window.clearTimeout(I),I=null)}function ft(Tt){if(k)return;let ei;if(Tt)ei=bw;else if(Ae<_w.length){if(!Fe)return;ei=_w[Ae++]}else{if(!Ve)return;ei=bw}I=window.setTimeout(()=>{I=null,ot()},ei)}async function ot(){try{const Tt=gt.current!==null,ei=await Es({preserveOnNull:Tt});if(k)return;!ei&&Tt&&!Fe&&(gt.current=null,on(null)),ft(!!ei||Tt&&Fe)}catch(Tt){if(k)return;Rm(Tt)&&(gt.current=null,on(null)),ft(!1)}}return Ht.current!==e.id&&(Ht.current=e.id,gt.current=null,on(null)),e.status!=="running"?(gt.current=null,on(null),()=>{k=!0,Je()}):(ot(),()=>{k=!0,Je()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=Dw(e.id,It),I=Mn.current;I!==null&&k!==null&&I!==k&&xt.current&&_n(!1),Mn.current=k},[e.id,It?.provider,It?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!It){$t(!1);return}const k=window.setInterval(()=>{wr(Date.now())},KL);return()=>{window.clearInterval(k)}},[e.status,It?.provider,It?.sessionId]),v.useEffect(()=>{const k=GL(vi);We.current.key!==k&&(We.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[vi?.expiresAt,vi?.source?.provider,vi?.source?.sessionId]),v.useEffect(()=>{if(!vn||!vi||vi.status!=="ready")return;const k=lx(vi,Xn);if(k===null||k<=0)return;const I=We.current;!I.warnedFiveMinutes&&k<=FL&&k>Sw&&(I.warnedFiveMinutes=!0,Rr({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!I.warnedOneMinute&&k<=Sw&&k>Eh&&(I.warnedOneMinute=!0,Rr({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&k<=Eh&&ku()},[vn,Xn,vi,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(I){if(!le.current||!Ne.current||I.isComposing||I.key==="Process"||JL(I.target))return;const Ae=$1(I);if(Ae?.id==="history.toggle"&>.current){I.preventDefault(),I.stopPropagation(),xt.current?_n(!1):kt.current();return}if(Ae?.id==="scrollback.toggle"&&be.current){I.preventDefault(),I.stopPropagation(),ko();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=W.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&Kt("closed")},[e.status]),v.useEffect(()=>{const k=W.current;k&&(k.options.fontSize=w,am(w,jt.current).then(()=>{it.current===w&&T()}))},[w]),v.useEffect(()=>{const k=W.current;k&&(k.options.fontFamily=ig(x),am(it.current,x).then(()=>{jt.current===x&&T()}))},[x]),v.useEffect(()=>{const k=W.current;k&&(k.options.theme=Cw(O))},[O]),v.useEffect(()=>{const k=G.current;if(!k)return;let I=!1,Ae=null,Fe=null,Ve=null,Je=null,ft=null,ot=null,Tt=null;$.current=null,Ei.current=!1,ni.current=!1,Te.current=!1,pe(),ue(),Kr(),_e.current=!1;const ei=it.current,Sn=jt.current,un=new aA({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:ig(Sn),fontSize:ei,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:TL,theme:{...Cw(ma())}}),Ro=new ZD;return un.loadAddon(Ro),Je=eL(un),W.current=un,q.current=Ro,am(ei,Sn).then(()=>{if(I)return;un.open(k),Aw(k,ve.current),Ei.current=!0,Ae=WA(un,{onPasteText:Ma,onInterrupt:Eu,shouldInterruptPlainCtrlC:()=>Gt.current}),Ne.current&&le.current&&e.status==="running"&&zn("auto"),T(),ft=N3(k,un,()=>it.current*1.2,qe,Mr=>{tn(Mr)},wo,Ra,()=>ve.current,Su),ot=D3(k,un,qe,Mr=>{tn(Mr)},wo,Ra,()=>ve.current,Su);const Mo=new lA;Fe=un.onData(Mr=>{if(di.current){const vl=gA(Mr);if(vl){Aa(!1),mr(vl);return}}const Yr=Mo.accept(Mr);Yr&&mr(Yr)}),Ve=un.onScroll(Mr=>{if(nt.current||Dt.current||ht.current){Ye();return}$r(),br(un)&&Vr({scrollToBottom:!0}),qe(),!ve.current&&Mr<=3&&tn()}),Tt=new ResizeObserver(()=>{Tr()}),Tt.observe(k),ni.current&&(Fr(),ni.current=!1,T()),S()}),()=>{As(ge.current,{updateUi:!1}),I=!0,Ei.current=!1,ni.current=!1,pe(),ue(),J.current=null,K.current=null,se.current=!1,Ce(),_e.current=!1,Vt(),ht.current=!1,ft?.(),ot?.(),Tt?.disconnect(),Ae?.dispose(),Fe?.dispose(),Ve?.dispose(),Je?.dispose(),un.dispose(),W.current=null,q.current=null}},[e.id]),v.useEffect(()=>{const k=xe.current(e.id),I=uL(k,yo);return ge.current=I.send,Kt(I.status),I.status==="connected"&&T(),I.snapshot&&(Se.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),W.current&&(T(),cn(I.output,I.history),T())),()=>{As(I.send,{updateUi:!1}),I.detach(),ge.current=null}},[e.id,e.status]);function yo(k){if(k.type==="status"){Kt(k.status),k.status==="unauthorized"&&re.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(T(),j());return}if(k.type==="outbound_flushed"){_e.current&&(_e.current=!1,Tu());return}On(k.message)}function Kr(k=[],I=null){Me.current=[],Re.current=qd(k),Pe.current=0,Be.current=!1,oe.current=null,ht.current=!1,he.current+=1,ye.current=I,Oe.current=null,Ke.current=!1,je.current=!1,ae.current=!1,ni.current=!1,Zt.current=null,we.current=null,Ue.current=!1,ji(!1),zi(null),Yi(!1),ln(null),si(!1),Vn(!1)}function cn(k=[],I=null){Kr(k,I),Er()}function Er(){if(!W.current||!Ei.current){ni.current=!0;return}ni.current=!1,Fr()}async function Fr(){const k=W.current;if(!k)return;const I=$d(k,Ue.current),Ae=I?Re.current.length:Pe.current,Fe=await Hi(k,{liveOutputLimit:Ae,scrollToBottom:I});W.current===k&&(Ye(),Fe&&j())}function Hi(k,I={}){return new Promise(Ae=>{ht.current=!0,Be.current=!1;const Fe=he.current+1;he.current=Fe;const Ve=Math.max(0,Math.min(I.liveOutputLimit??Re.current.length,Re.current.length)),Je=I.historyPages??Me.current,ft=()=>{if(W.current!==k||he.current!==Fe){Ae(!1);return}try{Pe.current=Ve,I.scrollToBottom&&ml(k)}finally{ht.current=!1;const Tt=hu();Tt?Vr(Tt):I.applyDeferredSnapshot!==!1&&mu(),Ae(!0)}},ot=()=>{if(W.current!==k||he.current!==Fe){Ae(!1);return}k.clear();const Tt=qd([...Je,...Re.current.slice(0,Ve)]);if(Tt.length===0){ft();return}for(let ei=0;ei<Tt.length;ei+=1){const Sn=Tt[ei];ei===Tt.length-1?k.write(Sn,ft):k.write(Sn)}};if(k.buffer.active.type==="alternate"){k.write(Qg,ot);return}ot()})}async function tn(k=0){const I=W.current;if(ae.current||!I)return;if(So(I)){Ye();return}const Ae=ye.current;ae.current=!0,ji(!0);const Fe=I.buffer.active.viewportY;try{let Ve=!!(Ae&&!Ae.hasMore);if(!Ve)try{const Je=await t.getTerminalHistory(e.id,{beforeLine:Ae?.startLine??0,limit:EL}),ft={startLine:Je.startLine,endLine:Je.endLine,hasMore:Je.hasMore};if(Je.output.length>0){await Ds(I,Je.output,Fe,k)&&(ye.current=ft);return}ye.current=ft,Ve=!Je.hasMore}catch(Je){Ve=Rm(Je)}if(Ve){if(So(I)){Ye();return}await Ea(I,Fe,k)}}catch{}finally{ae.current=!1,ji(!1)}}async function Ea(k,I,Ae){if(!(Ke.current||je.current))try{const Fe=Oe.current,Ve=await t.getTerminalTranscriptHistory(e.id,{...Fe?{cursor:Fe}:{},limit:ML}),Je=Ve.output.map(dx);if(!Ve.source)return;if(Je.length===0){on(Ve.source),Oe.current=Ve.cursor,je.current=!Ve.hasMore||!Ve.cursor;return}await Ds(k,Je,I,Ae)&&(on(Ve.source),Oe.current=Ve.cursor,je.current=!Ve.hasMore||!Ve.cursor)}catch(Fe){Rm(Fe)&&(Ke.current=!0)}}async function Ds(k,I,Ae,Fe){if(So(k))return Ye(),!1;const Ve=[...I,...Me.current],Je=E3(I);return!await Hi(k,{liveOutputLimit:Pe.current,scrollToBottom:!1,historyPages:Ve,applyDeferredSnapshot:!1})||W.current!==k?!1:(Me.current=Ve,Jh(k,Math.max(0,Ae+Je+Math.min(0,Fe))),Ue.current=!br(k),qe(),!0)}v.useEffect(()=>{const k=window.visualViewport;let I=!1;function Ae(){if(document.visibilityState==="hidden"){fL();return}Wr(()=>I)}function Fe(){Wr(()=>I)}function Ve(){Wr(()=>I)}function Je(){Tr()}function ft(){Da()}return document.addEventListener("visibilitychange",Ae),window.addEventListener("pageshow",Fe),window.addEventListener("online",Ve),window.addEventListener("resize",Je),window.addEventListener(kh,ft),k?.addEventListener("resize",Je),k?.addEventListener("scroll",Je),()=>{I=!0,document.removeEventListener("visibilitychange",Ae),window.removeEventListener("pageshow",Fe),window.removeEventListener("online",Ve),window.removeEventListener("resize",Je),window.removeEventListener(kh,ft),k?.removeEventListener("resize",Je),k?.removeEventListener("scroll",Je)}},[e.id]);function Wr(k){if(document.visibilityState==="hidden"||!Ne.current)return;j(),T();const I=xe.current(e.id);hL(I).then(()=>{k()||(T(),j())})}function qr(){const k=xe.current(e.id);Te.current=!0,Zt.current=null,Kt("reconnecting"),T(),dL(k,{preserveCachedOutputOnNextSnapshot:!0})}function On(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Se.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Ae=W.current;if(!Ae)return;T();const Fe=Te.current;if(Te.current=!1,Fe){ye.current=k.history??ye.current,Ye(),T();return}if(fu(Ae,k.terminal)){Qh(k.output,k.history??null),Ye(),T();return}cn(k.output,k.history??null),T();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){Se.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Ae=px(k.data);if(!Ae)return;Re.current.push(Ae),W.current&&Ei.current?Vr({scrollToBottom:!0}):ni.current=!0;return}const I=W.current;if(I){if(k.type==="exit"&&k.terminalId===e.id){Se.current.onExit(k.exitCode),Kt("closed");return}k.type==="error"&&I.writeln(`\r
|
|
34
|
+
[nterminal] ${k.message}`)}}function Ta(k=25){if(document.visibilityState==="hidden"||!Ne.current||A.current.has(k))return;const I=window.setTimeout(()=>{A.current.delete(k),!yn()&&nf()},k);A.current.set(k,I)}function Tr(){yn()||S()}function yn(){const k=Dr();return k&&Rs(k)?(se.current=!0,K.current=k,!0):k&&Ms(k)?(se.current=!1,K.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(se.current=!1,K.current=null),!1)}function Da(){if(!se.current)return;const k=Dr();k&&(k.composeOpen||k.keyboardVisible)||(se.current=!1,K.current=null)}function Rs(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const I=J.current;return I?nn(k.windowWidth,I.windowWidth)&&nn(k.visualViewportWidth,I.visualViewportWidth)&&nn(k.containerWidth,I.containerWidth):!1}function Ms(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const I=K.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:nn(k.windowWidth,I.windowWidth)&&nn(k.visualViewportWidth,I.visualViewportWidth)&&nn(k.containerWidth,I.containerWidth)}function Dr(){const k=G.current;if(!k||k.isConnected===!1)return null;const I=k.getBoundingClientRect(),Ae=Jt(window.innerWidth)??0,Fe=Jt(window.visualViewport?.width)??Ae,Ve=Jt(I.width)??Jt(k.clientWidth)??Ae;if(Ae<=0||Fe<=0||Ve<=0)return null;const{keyboardVisible:Je}=Xg(),ft=document.documentElement.hasAttribute(qh),ot=Ns()||Je;return{windowWidth:Ae,visualViewportWidth:Fe,containerWidth:Ve,composeOpen:ft,keyboardVisible:Je,mobileLike:ot}}function Ns(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function jn(){return Xg().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Jt(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function nn(k,I){return Math.abs(k-I)<=xL}function S(){for(const k of wL)Ta(k)}function T(){$.current=null,S()}function j(){if(ee(),z.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{z.current.delete(k),ee();const I=window.requestAnimationFrame(()=>{z.current.delete(I),ee()});z.current.add(I)});z.current.add(k)}for(const k of CL){if(R.current.has(k))continue;const I=window.setTimeout(()=>{R.current.delete(k),ee()},k);R.current.set(k,I)}}function ee(){const k=W.current;if(!(!k||!Ei.current||document.visibilityState==="hidden"||!Ne.current||G.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function pe(){for(const k of A.current.values())window.clearTimeout(k);A.current.clear()}function ue(){for(const k of R.current.values())window.clearTimeout(k);R.current.clear();for(const k of z.current)window.cancelAnimationFrame(k);z.current.clear()}function Ce(){for(const k of ne.current)window.clearTimeout(k);ne.current=[]}function qe(){if(Ye(),!we.current){Yi(!1);return}Yi(!0),Vt(),ze.current=window.setTimeout(()=>{ze.current=null,Yi(!1)},1200)}function Ye(){const k=W.current,I=k?T3(k):null;if(we.current=I,zi(I),Vn(!!(k&&I)),si(!!(k&&I&&!br(k))),I||!k||!_i()){ln(null);return}ln({alternate:k.buffer.active.type==="alternate"})}function _i(){const k=ye.current;return Me.current.length>0||!!k?.hasMore}function Vt(){ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null)}function $r(){const k=W.current;k&&(Ue.current=!br(k),Ye())}function du(k){oe.current=Mm(oe.current,k)}function Zh(k){const I=oe.current;return oe.current=null,Mm(I,k)}function hu(){const k=oe.current;return oe.current=null,k}function Vr(k={}){const I=W.current;if(!I||!Ei.current){ni.current=!0;return}if(ht.current){du(k);return}if(Be.current){du(k);return}const Ae=Zh(k);if(!Ae.force&&!$d(I,Ue.current)){Ye();return}Be.current=!0;const Fe=he.current,Ve=()=>{if(W.current!==I||he.current!==Fe){Be.current=!1;return}if(!Ae.force&&!$d(I,Ue.current)){Be.current=!1,Ye();return}const Je=Pe.current,ft=Re.current[Je];if(ft===void 0){Be.current=!1,Ae.scrollToBottom&&ml(I),Ye();const ot=hu();ot?Vr(Mm(Ae,ot)):mu();return}I.write(ft,()=>{if(W.current!==I||he.current!==Fe){Be.current=!1;return}Pe.current=Je+1,Ve()})};Ve()}function So(k){return!br(k)&&(pu()||Be.current||ht.current)}function fu(k,I){return(ri.current||Rc(I?.currentCommand))&&!br(k)}function pu(){return Pe.current<Re.current.length}function Qh(k,I){Zt.current={output:k,history:I,appendFromLiveOutputIndex:Pe.current}}function mu(){const k=W.current,I=Zt.current;if(!k||!I||!br(k)||pu()||Be.current||ht.current)return;const Ae=qd(I.output),Fe=qd(Re.current.slice(I.appendFromLiveOutputIndex));Zt.current=null,cn(k3(Ae,Fe),I.history),T()}function wo(){Dt.current=!0}function Ra(){$r(),Dt.current=!1;const k=W.current;k&&br(k)&&Vr({scrollToBottom:!0})}function ml(k){gu(()=>Lw(k))&&(Ue.current=!1)}function Jh(k,I){gu(()=>(k.scrollToLine(I),!0))}function gu(k){nt.current=!0;try{return k()}finally{nt.current=!1}}function vu(){const k=W.current;if(!k)return;const I=()=>{ve.current&&(wu(ge.current),Yn(!1)),Lw(k),Ue.current=!1,Ye(),Vr({force:!0,scrollToBottom:!0}),zn("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(Qg,I);return}I()}function _u(k){const I=W.current,Ae=G.current;if(!I||!Ae)return;const Fe=Ae.getBoundingClientRect();if(Fe.height<=0)return;const Ve=Math.max(0,Math.min(1,(k-Fe.top)/Fe.height)),Je=Math.round(I.buffer.active.baseY*Ve);wo();try{I.scrollToLine(Je)}finally{Ra()}Ue.current=!br(I),Ye(),qe(),Je<=3&&tn()}function ef(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),_u(k.clientY)}function tf(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),_u(k.clientY))}function nf(){const k=W.current,I=q.current;if(!(!k||!I)&&!(document.visibilityState==="hidden"||!Ne.current||G.current?.isConnected===!1))try{const Ae=$d(k,Ue.current),Fe=Dr();I.fit(),Fe&&(J.current=Fe),Ae&&ml(k),k.refresh(0,Math.max(0,k.rows-1)),Ye();const Ve={cols:k.cols,rows:k.rows},Je=$.current;if(Je&&Je.cols===Ve.cols&&Je.rows===Ve.rows)return;Co({type:"resize",terminalId:e.id,cols:Ve.cols,rows:Ve.rows})&&($.current=Ve)}catch{}}function bu(k){const I=ge.current;return I?I(k):"rejected"}function Co(k){return bu(k)==="sent"}function gl(){M.current!==null&&(window.clearTimeout(M.current),M.current=null)}function yu(){gl();const k=Math.max(-Kd,Math.min(Kd,F.current));if(F.current=0,k===0)return!1;const I=Co({type:"scrollback_scroll",terminalId:e.id,lines:k});return I&&(ie.current=!0,k<0&&Yn(!0)),I}function Su(k){if(!ve.current||k===0)return;const I=F.current+k;F.current=Math.max(-Kd,Math.min(Kd,I)),M.current===null&&(M.current=window.setTimeout(()=>{M.current=null,yu()},WL))}function xo(){wu(ge.current)}function As(k=ge.current,I={}){const Ae=ie.current;gl(),F.current=0,ie.current=!1,I.updateUi!==!1&&Yn(!1),Ae&&k?.({type:"cancel_scrollback",terminalId:e.id})}function wu(k){gl(),F.current=0,ie.current=!1,Yn(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function ko(){if(!be.current)return;const k=!ve.current;xr(aD(e.id,k)),sf()}function Cu(){const k=!Z.current;Z.current=k,$t(k),Rr({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Eo(){et.current!==null&&(window.clearTimeout(et.current),et.current=null)}function Rr(k,I={}){Eo();const Ae=st.current+1;st.current=Ae,Cs({...k,id:Ae}),!I.sticky&&(et.current=window.setTimeout(()=>{et.current=null,Cs(Fe=>Fe?.id===Ae?null:Fe)},12e3))}function xu(){We.current.skipped=!0,Rr({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function Ls(){Z.current=!1,$t(!1),Rr({tone:"skipped",message:"Cache keep-alive off"})}async function ku(){const k=We.current;if(k.sent||k.skipped)return;const I=rf();if(k.sent=!0,I){Rr({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}mr(`${yw}\r`,{userInitiated:!1}),Rr({tone:"success",message:"Cache keep-alive sent",detail:yw})}function rf(){const k=Nn.current,I=gt.current;return Z.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!I?"Transcript cache status is unavailable.":k.source.provider!==I.provider||k.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Xc(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":$h(e.id).text.trim()?"Compose has an unsent draft.":e3(G.current)?"Pane input is focused.":Date.now()-Ut.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function sf(){const k=W.current;k&&(ml(k),Ye())}function mr(k,I={}){I.userInitiated!==!1&&(Ut.current=Date.now()),yu();const Ae=ie.current;ie.current=!1,Ae&&Yn(!1),Vr({force:!0,scrollToBottom:!0});const Fe=bu({type:"input",terminalId:e.id,data:k,...Ae?{cancelScrollbackMode:!0}:{}});S3(k)&&(Fe==="sent"?Tu():Fe==="queued"&&(_e.current=!0))}function Eu(){di.current&&Aa(!1),mr(DL)}function Ma(k){const I=cw(k,{bracketedPasteMode:W.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&mr(I)}function Na(k,I){const Ae=cw(k,{bracketedPasteMode:W.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ae&&mr(Ae),window.setTimeout(()=>mr(AA(I)),nx)}function Tu(){!Qe.current||!le.current||(Ce(),ne.current=kL.map(k=>{const I=window.setTimeout(()=>{ne.current=ne.current.filter(Ae=>Ae!==I),Qe.current&&le.current&&Co({type:"refresh_cwd",terminalId:e.id})},k);return I}))}function zn(k="terminal-interaction"){xt.current||jn()&&(k==="auto"||k==="scroll-action")||W.current?.focus()}const Du=v.useCallback(()=>{_n(!1)},[]);function Ru(){ws(k=>{const I=!k;return di.current=I,I}),zn("input-action")}function Aa(k){di.current=k,ws(k)}function To(k){di.current&&Aa(!1),mr(mA(k)),zn("input-action")}async function Do(k="install"){dr(!0),fi(null);try{const I=k==="update"?await t.updateCodeServer():await t.installCodeServer();Jg(Bn,I.status),Ur(I.status)}catch(I){fi(Wd(I))}finally{dr(!1)}}return p.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":ai?"true":"false",onMouseDown:()=>{n||g()},children:[p.jsx(t3,{terminal:e,canClose:l,tabId:d,transcriptSource:It,transcriptShortcutLabel:X,transcriptCacheStatus:vi,transcriptCacheNow:Xn,cacheKeepAliveEnabled:vn,codeServerAvailable:!0,codeServerInstallState:Xi===null?"unknown":Xi.installed?"installed":"missing",codeServerBusy:Cr||Xi?.job?.status==="running",codeServerSupported:Xi?.supported!==!1,scrollbackShortcutLabel:U,tmuxScrollbackSupported:fr,tmuxScrollbackEnabled:ai,onToggleCacheKeepAlive:Cu,onOpenCodeServer:pl,onToggleTmuxScrollback:ko,onOpenTranscript:Ts,onReload:qr,onClose:f}),p.jsx("div",{className:"xterm-container",ref:G}),Qt?p.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:p.jsx("span",{"aria-hidden":"true"})}):null,D&&!ai&&hi?p.jsxs("div",{className:"terminal-scroll-progress","data-active":gn,"aria-hidden":"true",children:[hi.current,"/",hi.total]}):D&&!ai&&Ti?p.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ti.alternate?"alternate":"normal","aria-hidden":"true",children:[Ti.alternate?"alt ":"","0/?"]}):null,Di||ai&&Sa?p.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),vu()},children:"↓"}):null,Pi&&!ai?p.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:ef,onPointerMove:tf,children:p.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?xa?p.jsx(fA,{ctrlActive:bo,onCtrl:Ru,onStandaloneKey:To,onPreserveFocus:()=>zn("input-action"),onHide:()=>ka(!1)}):p.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),zn("input-action")},onPointerDown:k=>{k.stopPropagation(),zn("input-action")},onClick:()=>ka(!0),children:"⌨"}):null,p.jsx(PA,{terminalId:e.id,onSubmit:Na,queueAvailable:It?.provider==="codex"||cx(e.currentCommand),disabled:e.status!=="running"}),p.jsx(s3,{toast:dl,onSendNow:()=>{ku()},onSkipOnce:xu,onTurnOff:Ls,onDismiss:()=>Cs(null)}),An&&It?p.jsx(a3,{terminalId:e.id,serverApi:t,source:It,fontSize:w,onClose:Du}):null,Ca?p.jsx(n3,{notice:Ca}):null,hl?p.jsx(i3,{status:Xi,busy:Cr,error:Ln,onInstall:()=>{Do("install")},onUpdate:()=>{Do("update")},onOpen:pl,onRefresh:()=>{kr({checkLatest:!0}).catch(k=>fi(Wd(k)))},onClose:()=>wa(!1)}):null]})}function Cw(e){return wE(e)}async function xw(e,t,n={}){const s=n.checkLatest===!0,l=n.force===!0||s,c=Date.now(),d=Gl.get(e);if(!l&&d?.status&&c-d.fetchedAt<=qL)return d.status;if(d?.inflight&&(!s||d.inflightCheckLatest))return d.inflight;let m;return m=t.getCodeServerStatus(s?{checkLatest:!0}:void 0).then(g=>(Jg(e,g),g)).catch(g=>{const f=Gl.get(e);throw f?.inflight===m&&(f.status?Gl.set(e,{status:f.status,fetchedAt:f.fetchedAt}):Gl.delete(e)),g}),Gl.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:s}),m}function Jg(e,t){Gl.set(e,{status:t,fetchedAt:Date.now()})}function Fd(e,t){return`${e}:${t}`}function sx(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function kw(e){const t=Ic.get(e);if(!t)return!1;try{return t.closed?(Ic.delete(e),!1):(t.focus(),!0)}catch{return Ic.delete(e),!1}}function Tm(e,t){const n=window.open(t,sx(e));if(!n)return null;Ic.set(e,n);try{n.focus()}catch{}return n}function Ew(e,t,n){if(!e||ax(e))return!1;try{return e.name=sx(t),e.location.href=n,Ic.set(t,e),e.focus(),!0}catch{return!1}}function VL(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function ax(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Dm(e){if(e)try{e.closed||e.close()}catch{}}function YL(e,t,n){const s=XL(e,t),l=Tw(s*Math.max(1,n),PL,IL);return{limit:Tw(Math.ceil(l/OL),jL,zL),maxLines:l}}function XL(e,t){const n=e?.clientHeight??0;if(n<=0)return LL;const s=Math.max(10,t*BL);return Math.max(1,Math.floor(n/s))}function Tw(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function GL(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Dw(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function lx(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function ZL(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function QL(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const s=Math.floor(n/60),l=n%60;if(s<24&&l>0)return`${s}h ${l}m`;if(s<24)return`${s}h`;const c=Math.floor(s/24),d=s%24;return d>0?`${c}d ${d}h`:`${c}d`}function JL(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Wd(e){return e instanceof or||e instanceof Error?e.message:"Something went wrong."}function e3(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function t3({terminal:e,canClose:t,tabId:n,transcriptSource:s,transcriptShortcutLabel:l,transcriptCacheStatus:c,transcriptCacheNow:d,cacheKeepAliveEnabled:m,codeServerAvailable:g,codeServerInstallState:f,codeServerBusy:y,codeServerSupported:b,scrollbackShortcutLabel:C,tmuxScrollbackSupported:w,tmuxScrollbackEnabled:x,onToggleCacheKeepAlive:D,onOpenCodeServer:B,onToggleTmuxScrollback:L,onOpenTranscript:O,onReload:X,onClose:U}){const G=_1({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),W={cursor:n?"grab":"default",opacity:G.isDragging?.5:void 0};return p.jsxs("header",{ref:G.setNodeRef,className:"terminal-pane-header",style:W,"data-dragging":G.isDragging,...G.attributes,...G.listeners,children:[p.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),p.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),p.jsx("span",{className:"terminal-pane-spacer"}),g?p.jsx("button",{type:"button",className:"terminal-pane-code","data-state":f,"data-busy":y?"true":"false",disabled:!b||y,title:f==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":f==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),B()},children:p.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,s?p.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Xc(s.provider)} transcript history`,"aria-label":`View ${Xc(s.provider)} transcript history`,onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),O()},children:[p.jsx("span",{children:"View history"}),p.jsx("kbd",{children:l})]}):null,s?p.jsx(r3,{status:c,now:d,keepAliveEnabled:m,onToggle:D}):null,e.status==="exited"?p.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,w&&e.status==="running"?p.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":x?"true":"false","aria-pressed":x,"aria-label":`Toggle tmux scrollback (${C})`,title:x?`Scroll input uses tmux scrollback (${C}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${C}).`,onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),L()},children:[x?p.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):p.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),p.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),p.jsx("kbd",{children:C})]}):null,e.status==="running"?p.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),X()},children:"↻"}):null,t?p.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),U()},children:"x"}):null]})}function i3({status:e,busy:t,error:n,onInstall:s,onUpdate:l,onOpen:c,onRefresh:d,onClose:m}){const g=e?.job??null,f=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,C=e===null&&t,w=e?.updateAvailable===!0,x=y?"VS Code add-on":"Install VS Code add-on";return p.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:m,children:p.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsxs("div",{children:[p.jsx("h2",{children:x}),p.jsx("p",{children:C?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),p.jsxs("div",{className:"code-server-dialog-scroll",children:[p.jsxs("div",{className:"code-server-dialog-body",children:[p.jsxs("p",{children:["NTerminal installs code-server under ",p.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),C?p.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:p.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?p.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?p.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[p.jsxs("div",{className:"code-server-progress-heading",children:[p.jsx("span",{children:g.action}),p.jsx("strong",{children:g.status})]}),p.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
35
|
+
`):"Preparing..."})]}):null]}),p.jsxs("div",{className:"code-server-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!b,children:"Check"}),y?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:l,disabled:t||f||!b,children:w?"Update":"Reinstall"}),p.jsx("button",{type:"button",onClick:c,disabled:t||f,children:"Open"})]}):p.jsx("button",{type:"button",onClick:s,disabled:t||f||!b,children:f?"Installing...":"Install"})]})]})})}function n3({notice:e}){return p.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function r3({status:e,now:t,keepAliveEnabled:n,onToggle:s}){const l=lx(e,t),c=ZL(e,l),d=l===null?"?":QL(l),m=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return p.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:m,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),s()},children:[p.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[p.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),p.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),p.jsx("span",{children:d})]})}function s3({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:s,onDismiss:l}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return p.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[p.jsxs("header",{children:[p.jsx("strong",{children:e.message}),p.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:l,children:"x"})]}),e.detail?p.jsx("p",{children:e.detail}):null,c?p.jsxs("div",{className:"cache-keepalive-toast-actions",children:[p.jsx("button",{type:"button",onClick:t,children:"Send now"}),p.jsx("button",{type:"button",onClick:n,children:"Skip once"}),p.jsx("button",{type:"button",onClick:s,children:"Turn off"})]}):null]})}const a3=Li.memo(function({terminalId:t,serverApi:n,source:s,fontSize:l,onClose:c}){const d=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),y=v.useRef(null),b=v.useRef(""),C=v.useRef(null),w=v.useRef(null),[x,D]=v.useState([]),[B,L]=v.useState(!1),[O,X]=v.useState(""),[U,G]=v.useState(-1),[W,q]=v.useState(!1),[ge,Se]=v.useState(-1),[xe,re]=v.useState(null),[$,J]=v.useState(null),[K,se]=v.useState(!1),[A,R]=v.useState(!0),[z,ne]=v.useState(!1),[_e,M]=v.useState(null);v.useEffect(()=>{function le(Ne){Ne.key==="Escape"&&(Ne.preventDefault(),Ne.stopPropagation(),c())}return document.addEventListener("keydown",le,!0),()=>document.removeEventListener("keydown",le,!0)},[c]),v.useEffect(()=>{m.current+=1;const le=m.current;return g.current=!1,f.current=!0,y.current=null,C.current=null,w.current=null,D([]),J(null),se(!1),M(null),G(-1),Se(-1),re(null),ze(null,"initial",le),()=>{m.current===le&&(m.current+=1)}},[n,B,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const le=d.current;if(!le)return;if(f.current){if(A||x.length===0)return;f.current=!1;const Qe=()=>{le.scrollTop=le.scrollHeight};Qe(),window.requestAnimationFrame?.(Qe);return}const Ne=y.current;Ne!==null&&(y.current=null,le.scrollTop+=le.scrollHeight-Ne)},[x,A,B]);const F=Xc(s.provider),ie=Nw(x,B),ve=c3(ie),be=f3(ve),Ee=be.map(le=>le.key).join(""),Me=xe?be.find(le=>le.key===xe)?.entryIndex??null:null,Re=O.trim().length>0,Pe=h3(ve,O),Be=Pe.length,oe=Be>0?U>=0&&U<Be?U:0:-1,he=oe>=0?Pe[oe]?.entryIndex??null:null,ye=oe>=0?Pe[oe]??null:null,Oe=Re?he:Me,Ke=Re?he===null?null:"search":Me===null?null:"prompt",je=ie?ie.split(`
|
|
36
|
+
`).length-1:0,ae=be.length>0&&ge>=0&&ge<be.length?ge:be.length-1,Te=xe??(ae>=0?be[ae]?.key??null:null),we=Re?Be>0?`${oe+1}/${Be} ${Be===1?"match":"matches"} · ${je} ${je===1?"line":"lines"}`:`0 matches · ${je} ${je===1?"line":"lines"}`:be.length>0?`${ae+1}/${be.length} prompts · ${je} ${je===1?"line":"lines"}`:`0 prompts · ${je} ${je===1?"line":"lines"}`;v.useEffect(()=>{const le=O.trim().toLowerCase();G(Ne=>!le||Be===0?-1:b.current!==le?0:Ne>=0&&Ne<Be?Ne:0),b.current=le},[O,Be]),v.useEffect(()=>{if(Re){re(null);return}xe&&!be.some(le=>le.key===xe)&&re(null),Se(le=>{if(be.length===0)return w.current=null,-1;const Ne=w.current?be.findIndex(it=>it.key===w.current):-1,Qe=Ne>=0?Ne:le>=0&&le<be.length?le:be.length-1;return w.current=be[Qe]?.key??null,Qe})},[xe,Re,Ee]),v.useEffect(()=>{const le=C.current;if(!le||be.length===0)return;C.current=null;const Ne=le.anchorKey?be.findIndex(it=>it.key===le.anchorKey):-1,Qe=Ne>0?Ne-1:0;Ei(Qe)},[Ee]);async function ze(le,Ne,Qe=m.current){if(!g.current){g.current=!0,Ne==="initial"?R(!0):(ne(!0),y.current=d.current?.scrollHeight??null),M(null);try{await Ue(le,Ne,Qe)}catch(it){if(m.current!==Qe)return;M(it instanceof Error?it.message:"Failed to load transcript history.")}finally{m.current===Qe&&(g.current=!1,R(!1),ne(!1))}}}async function Ue(le,Ne,Qe){let it=le,jt=0,xt=[];const gt=Ne==="initial"&&s.provider!=="claude"?UL:HL;for(;m.current===Qe;){const Ht=await n.getTerminalTranscriptHistory(t,{...it?{cursor:it}:{},...YL(d.current,l,Ne==="initial"?NL:AL),includeTools:B});if(m.current!==Qe)return;const kt=Mw(Ht.output,s.provider,{includeTools:B}),Mn=nt(Ht,Ne,xt,kt);if(kt&&(xt=[kt,...xt],Mn))return;if(!Ht.hasMore||!Ht.cursor||jt>=gt){xt.length>0&&D(Nn=>Ne==="older"?[...xt,...Nn]:xt);return}it=Ht.cursor,jt+=1}}function nt(le,Ne,Qe,it=Mw(le.output,s.provider,{includeTools:B})){if(J(le.cursor),se(!!(le.hasMore&&le.cursor)),!it)return!1;const jt=[it,...Qe];return Nw(jt,B)?(D(xt=>Ne==="older"?[...jt,...xt]:jt),!0):!1}function ht(){const le=d.current;le&&(di(),!(le.scrollTop>72||!K||!$||g.current)&&ze($,"older"))}function Dt(le){Be!==0&&G(Ne=>{const Qe=oe>=0?oe:le>0?-1:0;return((Ne>=0&&Ne<Be?Ne:Qe)+le+Be)%Be})}function Ei(le){const Ne=be[le];Ne&&(w.current=Ne.key,Se(le),re(Ne.key))}async function ni(le){if(be.length===0){le<0&&K&&$&&!g.current&&(C.current={anchorKey:null},await ze($,"older"));return}const Qe=(ge>=0&&ge<be.length?ge:le<0?be.length-1:-1)+le;if(Qe>=0&&Qe<be.length){Ei(Qe);return}le<0&&Qe<0&&K&&$&&!g.current&&(C.current={anchorKey:be[0]?.key??null},await ze($,"older"))}function di(){if(Re)return;const le=d.current;if(!le)return;const Qe=le.getBoundingClientRect().top+Math.min(140,Math.max(48,le.clientHeight*.28));let it=null;for(const jt of _3(le)){const xt=b3(jt);if(xt!==null)if(jt.getBoundingClientRect().top<=Qe)it=xt;else break}if(it!==null){const jt=be[it]?.key??null;w.current=jt,Se(it),xe&&xe!==jt&&re(null)}}return p.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:le=>le.stopPropagation(),onMouseDown:le=>le.stopPropagation(),onClick:le=>{le.stopPropagation(),c()},children:p.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:le=>le.stopPropagation(),onMouseDown:le=>le.stopPropagation(),onClick:le=>le.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsxs("div",{className:"transcript-dialog-title",children:[p.jsxs("h2",{id:"transcript-dialog-title",children:[F," JSONL"]}),p.jsx("span",{title:s.sessionId,children:s.sessionId})]}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),p.jsxs("div",{className:"transcript-dialog-controls",children:[p.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[p.jsx("input",{type:"checkbox",checked:B,onChange:le=>L(le.currentTarget.checked)}),"Show tool output"]}),p.jsx("label",{className:"transcript-search",children:p.jsx("input",{type:"search",value:O,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:le=>X(le.currentTarget.value),onKeyDown:le=>{le.key==="Enter"&&(le.preventDefault(),Re?Dt(le.shiftKey?-1:1):ni(le.shiftKey?-1:1))}})}),p.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":W,"aria-label":"Toggle prompt list",onClick:()=>q(le=>!le),disabled:be.length===0,children:"List"}),p.jsxs("div",{className:"transcript-search-actions","aria-label":Re?"Search result navigation":"Prompt navigation",children:[p.jsx("button",{type:"button",onClick:()=>Re?Dt(-1):void ni(-1),disabled:Re?Be===0:be.length===0&&!K,"aria-label":Re?"Previous search match":"Previous user prompt",title:Re?"Previous search match":"Previous user prompt",children:"Prev"}),p.jsx("button",{type:"button",onClick:()=>Re?Dt(1):void ni(1),disabled:Re?Be===0:be.length===0,"aria-label":Re?"Next search match":"Next user prompt",title:Re?"Next search match":"Next user prompt",children:"Next"})]}),p.jsx("span",{className:"transcript-result-count",children:we})]}),W?p.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:be.length>0?be.map((le,Ne)=>p.jsxs("button",{type:"button",className:Te===le.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>Ei(Ne),children:[p.jsx("span",{children:le.timestampLabel}),p.jsx("strong",{children:le.snippet})]},`${le.key}:${Ne}`)):p.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,p.jsxs("div",{ref:d,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:ht,children:[z?p.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!A&&K?p.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,ie?p.jsx(l3,{entries:ve,searchQuery:O,activeEntryIndex:Oe,activeEntryMode:Ke,activeSearchMatch:ye,fontSize:l}):null,A?p.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!A&&!ie&&!_e?K&&$?p.jsxs("div",{className:"transcript-dialog-status",children:[B?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",p.jsx("button",{type:"button",onClick:()=>{ze($,"older")},disabled:z,children:"Search earlier entries"})]}):p.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,_e?p.jsx("div",{className:"transcript-dialog-error",children:_e}):null]})]})})});function l3({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:l,fontSize:c}){const d=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=d.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((l?.entryIndex===n?f[l.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,s,l,t]);let m=-1;return p.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const y=g.kind==="user"?++m:null,b=n===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return p.jsxs("section",{ref:C=>{C?d.current.set(f,C):d.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?p.jsx("div",{className:"transcript-entry-header",children:ox(g.header,t)}):null,g.body?p.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?p.jsx(Rw,{text:g.body,searchQuery:t}):p.jsx(Li.Suspense,{fallback:p.jsx(Rw,{text:g.body,searchQuery:t}),children:p.jsx($L,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function Rw({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
37
37
|
`)?e.slice(0,-1).split(`
|
|
38
38
|
`):e.split(`
|
|
39
|
-
`);return p.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,
|
|
40
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,
|
|
41
|
-
`);(s||m)&&n.push({header:s,body:m,kind:
|
|
42
|
-
`)){const g=
|
|
43
|
-
${
|
|
44
|
-
`)}function Rm(e){return e instanceof or&&e.status===404}function Rc(e){return cx(e)||ux(e)}function cx(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function ux(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function
|
|
39
|
+
`);return p.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,l)=>p.jsx("span",{className:`transcript-line transcript-line-${y3(s,l===0||n[l-1]?.trim()==="")}`,children:ox(s,t)},l))})}function ox(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),l=n.toLowerCase(),c=[];let d=0,m=s.indexOf(l);for(;m!==-1;){m>d&&c.push(e.slice(d,m));const g=m+n.length;c.push(p.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),d=g,m=s.indexOf(l,d)}return d<e.length&&c.push(e.slice(d)),c.length>0?c:e||" "}function o3(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const s=e.toLowerCase();let l=0,c=s.indexOf(n);for(;c!==-1;)l+=1,c=s.indexOf(n,c+n.length);return l}function c3(e){const t=e.endsWith(`
|
|
40
|
+
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,l="plain",c=[];function d(){const m=u3(c).join(`
|
|
41
|
+
`);(s||m)&&n.push({header:s,body:m,kind:l}),s=null,l="plain",c=[]}for(const m of t.split(`
|
|
42
|
+
`)){const g=d3(m);g?(d(),s=m,l=g):c.push(m)}return d(),n}function u3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function d3(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function h3(e,t){const n=[];for(let s=0;s<e.length;s+=1){const l=e[s];if(!l)continue;const c=l.header?`${l.header}
|
|
43
|
+
${l.body}`:l.body,d=o3(c,t);for(let m=0;m<d;m+=1)n.push({entryIndex:s,matchIndexInEntry:m})}return n}function f3(e){const t=[];for(let l=0;l<e.length;l+=1){const c=e[l];!c||c.kind!=="user"||t.push({contentKey:p3(c),entry:c,entryIndex:l})}const n=new Map,s=new Map;for(let l=t.length-1;l>=0;l-=1){const c=t[l];if(!c)continue;const d=n.get(c.contentKey)??0;n.set(c.contentKey,d+1),s.set(l,JSON.stringify([c.contentKey,d]))}return t.map((l,c)=>({entryIndex:l.entryIndex,key:s.get(c)??JSON.stringify([l.contentKey,0]),snippet:g3(l.entry.body),timestampLabel:v3(l.entry.header)}))}function p3(e){return JSON.stringify([e.header??"",e.body.length,m3(e.body)])}function m3(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function g3(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function v3(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function _3(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function b3(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function y3(e,t){const n=e.trim();if(!n)return"blank";const s=n.replace(/^\[[^\]]+\]\s+/,""),l=/^\[[^\]]+\]\s+/.test(n);return(l||t)&&/^User$/.test(s)?"user":(l||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(l||t)&&/^System$/.test(s)?"system":(l||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||fx(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function S3(e){return e.includes("\r")||e.includes(`
|
|
44
|
+
`)}function Rm(e){return e instanceof or&&e.status===404}function Rc(e){return cx(e)||ux(e)}function cx(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function ux(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function w3(e){if(Rc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Xc(e){return e==="codex"?"Codex":"Claude"}function Mw(e,t,n={}){const s=`[nterminal] ${Xc(t)} transcript archive ends here. Live terminal screen continues below.`,l=e.join("").replace(/\r\n/g,`
|
|
45
45
|
`).replace(/\r/g,`
|
|
46
46
|
`).replace(s,"").replace(/\n{3,}/g,`
|
|
47
47
|
|
|
48
|
-
`).trimEnd(),c=dx(
|
|
49
|
-
`:""}function dx(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const s=
|
|
48
|
+
`).trimEnd(),c=dx(l),d=n.includeTools?c:hx(c);return d?`${d}
|
|
49
|
+
`:""}function dx(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const s=C3(n);return s?`[${s}]`:t})}function C3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=bc(t.getMonth()+1),l=bc(t.getDate()),c=bc(t.getHours()),d=bc(t.getMinutes()),m=bc(t.getSeconds());return`${n}-${s}-${l} ${c}:${d}:${m}`}function bc(e){return e.toString().padStart(2,"0")}function Nw(e,t){return e.map(n=>t?n:hx(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
50
50
|
`)?n:`${n}
|
|
51
51
|
`).join("")}function hx(e){if(!e)return"";const t=e.split(`
|
|
52
|
-
`),n=[];let s=!1,
|
|
52
|
+
`),n=[];let s=!1,l=!1,c=!0;for(const d of t){const m=d.trim()==="",g=c?x3(d):null;if(g&&(s=g==="tool",l=!1),fx(d)){l=!0,c=!1;continue}if(l){m?(l=!1,s||n.push(d),c=!0):c=!1;continue}s||n.push(d),c=m}return n.join(`
|
|
53
53
|
`).replace(/\n{3,}/g,`
|
|
54
54
|
|
|
55
|
-
`).trimEnd()}function C3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function fx(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function x3(e,t){if(t.length===0)return e;let n=0;const s=Math.min(e.length,t.length);for(let o=s;o>0;o-=1){let c=!0;for(let d=0;d<o;d+=1)if(e[e.length-o+d]!==t[d]){c=!1;break}if(c){n=o;break}}return[...e,...t.slice(n)]}function k3(e){let t=0;for(const n of e){if(!n)continue;const s=n.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function qd(e){const t=[];for(const n of e){const s=px(n);s&&t.push(s)}return t}function px(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const o=n.split(";").filter(Boolean).filter(c=>!DL.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${s}`:""})}function Mm(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function E3(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function Aw(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function br(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function $d(e,t){return!t||br(e)}function Lw(e){return br(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function T3(e,t,n,s,o,c,d,m){const g=f=>{const y=R3(f);if(y!==0){if(d()){if(A3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),m(y);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),D3(t,y,n,s,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function D3(e,t,n,s,o,c){const d=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Qg,d);return}d()}function R3(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const s=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,s))}function M3(e,t,n,s,o,c,d,m,g){let f=null,y=0;const b={passive:!1};function C(D){f=Nm(D),y=0}function w(D){const B=Nm(D);if(B===null){f=null,y=0;return}if(f===null){f=B;return}const L=B.clientY-f.clientY;if(f=B,D.cancelable&&D.preventDefault(),L===0)return;if(N3(t)&&L3(t,B,-L)){y=0;return}y-=L/n();const O=y<0?Math.ceil(y):Math.floor(y);if(O!==0){if(y-=O,m()){g(O);return}c();try{t.scrollLines(O)}finally{d()}s(),O<0&&t.buffer.active.viewportY<=3&&o(O)}}function x(D){if(D.touches.length>0){f=Nm(D);return}f=null,y=0}return e.addEventListener("touchstart",C,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",C,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Nm(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function N3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function A3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function L3(e,t,n){const s=e.element;return s?(s.dispatchEvent(B3(t,n)),!0):!1}function B3(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const o=new Event("wheel",s);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function ev({node:e,terminals:t,editors:n,api:s,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:d=!1,tabId:m,codeServerContext:g,dropZoneActive:f=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:C=[],totalPanes:w,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,onAuthClose:U}){const G=w??tv(e);if(C.length===0&&b){const Se=iv(e),xe=Se.some(ie=>ie.key===b)?b:Se[0]?.key;if(Se.length>1&&xe)return p.jsx("div",{className:"mobile-focused-split",children:Se.map(ie=>{const q=ie.key===xe;if(ie.type==="editor"){const K=n[ie.editorId];return p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:K?p.jsx(c0,{api:s,editor:K,canClose:G>1,onClose:()=>X(ie.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ie.key)}const J=t[ie.terminalId];return J?p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:p.jsx(ww,{terminal:J,serverApi:s,active:q,visible:c&&q,canClose:G>1,refreshCwdOnEnter:d&&q,tabId:m,codeServerContext:g,onSelect:()=>x(ie.terminalId),onClose:()=>D(ie.terminalId),onExit:K=>L(ie.terminalId,K),onSnapshot:O,...U?{onAuthClose:U}:{}})},ie.key):p.jsx("div",{className:"mobile-focused-pane","data-active":q,"aria-hidden":!q,children:p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ie.key)})})}if(e.type==="pane"){const Se=t[e.terminalId];if(!Se)return p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const xe=p.jsx(ww,{terminal:Se,serverApi:s,active:e.terminalId===o,visible:c,canClose:G>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>D(e.terminalId),onExit:q=>L(e.terminalId,q),onSnapshot:O,...U?{onAuthClose:U}:{}});return f&&y!==e.terminalId?p.jsxs("div",{className:"pane-drop-host",children:[xe,p.jsx(Vd,{terminalId:e.terminalId,side:"top"}),p.jsx(Vd,{terminalId:e.terminalId,side:"right"}),p.jsx(Vd,{terminalId:e.terminalId,side:"bottom"}),p.jsx(Vd,{terminalId:e.terminalId,side:"left"})]}):xe}if(e.type==="editor"){const Se=n[e.editorId];return Se?p.jsx(c0,{api:s,editor:Se,canClose:G>1,onClose:()=>X(e.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const F=Math.max(.1,Math.min(.9,e.ratio)),W=1-F,ve=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${F}fr) 1px minmax(0, ${W}fr)`}:{gridTemplateRows:`minmax(0, ${F}fr) 1px minmax(0, ${W}fr)`};return p.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ve,children:[p.jsx("div",{className:"split-cell",children:p.jsx(ev,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,0],totalPanes:G,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,...U?{onAuthClose:U}:{}})}),p.jsx(O3,{direction:e.direction,path:C,onResize:B}),p.jsx("div",{className:"split-cell",children:p.jsx(ev,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,1],totalPanes:G,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,...U?{onAuthClose:U}:{}})})]})}function Vd({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=Mv({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return p.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function O3({direction:e,path:t,onResize:n}){function s(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return p.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:p.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function tv(e){return e.type==="pane"||e.type==="editor"?1:tv(e.first)+tv(e.second)}function iv(e){return e.type==="pane"?[{key:j3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:z3(e.editorId),type:"editor",editorId:e.editorId}]:[...iv(e.first),...iv(e.second)]}function j3(e){return`terminal:${e}`}function z3(e){return`editor:${e}`}const Yh="workspace-default",P3="NTerminal";function I3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function H3(e,t){switch(t.type){case"workspace.hydrated":return nv(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return U3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return q3(e,t.workspaceId);case"workspace.selected":return mx(e,t.workspaceId);case"workspace.renamed":return K3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return F3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return W3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return gx(e,t.terminal);case"terminal.split":return $3(e,t.terminal,t.direction);case"terminal.updated":return n5(e,t.terminal);case"terminal.exited":return r5(e,t.terminalId,t.exitCode);case"terminal.closed":return bx(e,t.terminalId);case"terminal.detached":return s5(e,t.terminalId,t.workspaceId);case"editor.split":return V3(e,t.editorId,t.title,t.direction);case"editor.closed":return a5(e,t.editorId);case"pane.selected":return t5(e,t.terminalId);case"pane.resized":return i5(e,t.path,t.ratio);case"tab.selected":return X3(e,t.tabId);case"tab.renamed":return e5(e,t.tabId,t.title);case"tab.reordered":return u_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return G3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return vx(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return _x(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return Z3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return Y3(e);default:return e}}function U3(e,t){if(e.workspaces.some(s=>s.id===t.id))return mx(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Sr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function mx(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function K3(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(d=>d.id!==t||d.title===s?d:(o=!0,{...d,title:s}));return o?{...e,workspaces:c}:e}function F3(e,t,n){const s=Sr(n);let o=!1;const c=e.workspaces.map(d=>d.id!==t||d.defaultCwd===s?d:(o=!0,{...d,defaultCwd:s}));return o?{...e,workspaces:c}:e}function W3(e,t,n,s){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const d=e.workspaces.slice(),[m]=d.splice(o,1);if(!m)return e;const g=d.findIndex(b=>b.id===n);if(g<0)return e;const f=s==="before"?g:g+1,y=d.slice();return y.splice(f,0,m),J3(e.workspaces,y)?e:{...e,workspaces:y}}function q3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),s=new Set(n?Th(n):[]),o={...e.terminals};for(const m of s)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),d=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:d,terminals:o}}function gx(e,t){const n=Sx(e),s=co(n)??Gh(),o=Ex(t);return{...n,activeWorkspaceId:s.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??Sr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:kx(c,t.id))}}function $3(e,t,n){const s=co(e),o=s?Xh(s):void 0;if(!s||!o)return gx(e,t);const c=o.activeTerminalId,d=Zc(o.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(m=>m.id===s.id?{...m,defaultCwd:m.defaultCwd??Sr(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:d,activeTerminalId:t.id}:g)}:kx(m,t.id))}}function V3(e,t,n,s){const o=co(e),c=o?Xh(o):void 0;if(!o||!c)return e;const d=c.activeTerminalId,m=Zc(c.root,d,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:m,activeTerminalId:d}:f)}:g)}}function Y3(e){const t=co(e),n=t?Xh(t):void 0;return n?bx(e,n.activeTerminalId):e}function X3(e,t){const n=co(e);return!n||!n.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===n.id?{...s,activeTabId:t}:s)}}function u_(e,t,n){const s=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const d=o.tabs.slice(),[m]=d.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(d.length,n)),f=d.slice();return f.splice(g,0,m),Q3(o.tabs,f)?o:{...o,tabs:f}});return s.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:s}}function G3(e,t,n,s,o){if(n===s||!e.terminals[n]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(x=>x.id===t);if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b=cl(y.root,n);if(!b){const x=g.tabs.filter((D,B)=>B!==f);return{...g,tabs:x}}const C={...y,root:b,activeTerminalId:Bi(b)[0]??y.activeTerminalId},w=g.tabs.slice();return w[f]=C,{...g,tabs:w}});const d=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>Bi(D.root).includes(s));if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b={type:"pane",terminalId:n},C={type:"split",direction:d,ratio:.5,first:m?b:{type:"pane",terminalId:s},second:m?{type:"pane",terminalId:s}:b},w=Zc(y.root,s,C),x=g.tabs.slice();return x[f]={...y,root:w,activeTerminalId:n},{...g,tabs:x,activeTabId:y.id}}),Sx({...e,workspaces:c})}function vx(e,t,n,s){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const L=e.workspaces[B].tabs.findIndex(O=>O.id===t);if(L>=0){o=B,c=L;break}}if(o<0)return e;const d=e.workspaces[o],m=d.tabs[c],g=Bi(m.root);if(!g.includes(n))return e;if(g.length===1)return u_(e,t,s);const f=cl(m.root,n);if(!f)return e;const y={...m,root:f,activeTerminalId:Bi(f)[0]??m.activeTerminalId},b=e.terminals[n],C={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=d.tabs.slice();w[c]=y;const x=Math.max(0,Math.min(w.length,s));w.splice(x,0,C);const D=e.workspaces.slice();return D[o]={...d,tabs:w,activeTabId:C.id},{...e,workspaces:D}}function _x(e,t,n,s=Number.MAX_SAFE_INTEGER){const o=wx(e.workspaces,t),c=e.workspaces.find(f=>f.id===n);if(!o||!c)return e;if(o.workspace.id===n)return s===Number.MAX_SAFE_INTEGER?e:u_(e,t,s);const d=Bi(o.tab.root),m=d.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===o.workspace.id)return uo({...f,tabs:f.tabs.filter(y=>y.id!==t)});if(f.id===n){const y=f.tabs.slice(),b=Math.max(0,Math.min(y.length,s));return y.splice(b,0,o.tab),{...f,defaultCwd:f.defaultCwd??Sr(m?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(C=>!d.includes(C)),tabs:y,activeTabId:o.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:n}}function Z3(e,t,n,s,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),d=wx(e.workspaces,t);if(!c||!d||!e.terminals[n]||!Bi(d.tab.root).includes(n))return e;if(d.workspace.id===s)return vx(e,t,n,o);if(Bi(d.tab.root).length===1)return _x(e,t,s,o);const g=cl(d.tab.root,n);if(!g)return e;const f={...d.tab,root:g,activeTerminalId:Bi(g)[0]??d.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},C=e.workspaces.map(w=>{if(w.id===d.workspace.id)return uo({...w,tabs:w.tabs.map(x=>x.id===t?f:x)});if(w.id===s){const x=w.tabs.slice(),D=Math.max(0,Math.min(x.length,o));return x.splice(D,0,b),{...w,defaultCwd:w.defaultCwd??Sr(y.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(B=>B!==n),tabs:x,activeTabId:b.id}}return w});return{...e,workspaces:C,activeWorkspaceId:s}}function Q3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function J3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function e5(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(d=>{let m=!1;const g=d.tabs.map(f=>f.id!==t||f.title===s?f:(o=!0,m=!0,{...f,title:s}));return m?{...d,tabs:g}:d});return o?{...e,workspaces:c}:e}function t5(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>ul(c.root,t))),s=n?.tabs.find(o=>ul(o.root,t));return!n||!s?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:s.id,tabs:o.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:o)}}function i5(e,t,n){const s=co(e),o=s?Xh(s):void 0;if(!s||!o)return e;const c=cv(o.root,t,Rx(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===s.id?{...d,tabs:d.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:d)}}function nv(e,t,n,s){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),d=new Set,m=!!(n&&n.some(b=>Tx(b))||t&&t.some(b=>Dx(b)));let g=o5(t,n,c,d);g.length===0&&(g=[Gh()]);const f=typeof s=="string"&&g.some(b=>b.id===s)?s:g[0]?.id??null,y=f??g[0]?.id??Yh;for(const b of e)if(!d.has(b.id)){if(m)g=u5(g,y,b.id,b);else{const C=Ex(b);g=h5(g,y,C,b)}d.add(b.id)}return{workspaces:g.map(b=>uo(d5(b,o))),activeWorkspaceId:f,terminals:o}}function Gc(e){return Bi(e.root)}function rv(e){return uv(e.root)}function Th(e){return d_([...e.tabs.flatMap(t=>Bi(t.root)),...e.detachedTerminalIds])}function Am(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(o=>{const c=ov(o.root);return c?[{...o,root:c}]:[]});return uo({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function n5(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>ul(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function r5(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function bx(e,t){const n={...e.terminals};return delete n[t],yx(e,t,n)}function s5(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(c=>c.id===n)?n:null)??l5(e,t)?.id??c5(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Yh,o=e.workspaces.find(c=>c.id===s);return!o||!xx(o,t)?e:yx(e,t,{...e.terminals},{detachToWorkspaceId:s})}function yx(e,t,n,s={}){let o=e.workspaces.map(d=>{const m=[];for(const g of d.tabs){const f=cl(g.root,t);if(!f)continue;const y=Bi(f),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:f,activeTerminalId:b})}return uo({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:m})});s.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===s.detachToWorkspaceId?Cx(d,t,n[t]):d));const c=o.some(d=>d.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function a5(e,t){const n=e.workspaces.map(o=>{const c=[];for(const d of o.tabs){const m=sv(d.root,t);if(!m)continue;const g=Bi(m),f=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];f&&c.push({...d,root:m,activeTerminalId:f})}return uo({...o,tabs:c})}),s=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function o5(e,t,n,s){if(t&&t.length>0){const o=[];for(const c of t)Tx(c)&&o.push(Bw(c,n,s));if(o.length>0)return o}return[Bw({...Gh(),tabs:e??[]},n,s)]}function Bw(e,t,n){const s=[];for(const c of e.tabs){if(!Dx(c))continue;const d=av(c.root,t);if(!d)continue;const m=Bi(d);for(const f of m)n.add(f);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&s.push({...c,root:d,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return uo({...e,defaultCwd:Sr(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function Sx(e){return co(e)?e:{...e,workspaces:[Gh()],activeWorkspaceId:Yh}}function co(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Xh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function wx(e,t){for(const n of e){const s=n.tabs.findIndex(o=>o.id===t);if(s>=0)return{workspace:n,tab:n.tabs[s],tabIndex:s}}return null}function l5(e,t){return e.workspaces.find(n=>n.tabs.some(s=>ul(s.root,t)))}function c5(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function u5(e,t,n,s){return e.map(o=>o.id===t?Cx(o,n,s):o)}function Cx(e,t,n){return xx(e,t)?{...e,defaultCwd:e.defaultCwd??Sr(n?.cwd),detachedTerminalIds:d_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function xx(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<fl}function kx(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function d5(e,t){if(e.defaultCwd)return e;const n=Th(e).find(o=>!!t[o]),s=n?Sr(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Gh(){return{id:Yh,title:P3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function uo(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Sr(e.defaultCwd),detachedTerminalIds:d_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function h5(e,t,n,s){const o=Bi(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Sr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>!o.includes(d)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function Ex(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Zc(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Zc(e.first,t,n),second:Zc(e.second,t,n)}}function cl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=cl(e.first,t),s=cl(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function sv(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=sv(e.first,t),s=sv(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function av(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=av(e.first,t),s=av(e.second,t);return n&&s?{...e,ratio:Rx(e.ratio),first:n,second:s}:n??s}function ov(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=ov(e.first),n=ov(e.second);return t&&n?{...e,first:t,second:n}:t??n}function Tx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function Dx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&lv(t.root)}function lv(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&lv(t.first)&&lv(t.second):!1}function cv(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[s,...o]=t;if(s===0){const c=cv(e.first,o,n);return c===e.first?e:{...e,first:c}}if(s===1){const c=cv(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function Rx(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Sr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function d_(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));return n}function ul(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:ul(e.first,t)||ul(e.second,t)}function Bi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Bi(e.first),...Bi(e.second)]}function uv(e){return e.type==="pane"||e.type==="editor"?1:uv(e.first)+uv(e.second)}const _a=new Map,Qc=new Map,Jc=new Map,eu=new Map,tu=new Map;function vl(e){return e??"__local__"}function f5(e){return{agentId:e,state:I3(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Ot(e){const t=vl(e);let n=_a.get(t);return n||(n=f5(e),_a.set(t,n)),n}function Mx(e,t){const n=vl(e);let s=Qc.get(n);return s||(s=new Set,Qc.set(n,s)),s.add(t),()=>{s.delete(t)}}function p5(e){const t=vl(e),n=Qc.get(t);if(n)for(const s of Array.from(n))s()}function _l(e,t){_a.set(vl(e),t),p5(e)}const dv=new Set;function m5(e){return dv.add(e),()=>{dv.delete(e)}}function Yo(e,t){const n=Ot(e),s=vl(e);t.type==="workspace.hydrated"&&(Jc.delete(s),eu.delete(s),tu.delete(s));const o=H3(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],y=C5(s),b=x5(s),C=v5(s);if(t.terminal.agentStatus){const w=t.terminal.agentStatus.state,x=t.terminal.agentStatus.sessionId,D=C.get(t.terminal.id),B=!!(f&&(f.currentCommand!==t.terminal.currentCommand||f.agentStatus?.provider!==t.terminal.agentStatus.provider||g5(D,x)));B&&(b.delete(t.terminal.id),y.delete(t.terminal.id),C.delete(t.terminal.id)),x&&C.set(t.terminal.id,x),t.notifyCompletion===!0&&(w==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):w==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!B&&(w==="done"||w==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(d=zw(o,t.terminal.id,f?.currentCommand??null,w==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),w==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{f?.agentStatus&&(b.delete(t.terminal.id),C.delete(t.terminal.id));const w=f?.activity==="busy",x=t.terminal.activity==="busy",D=t.terminal.activity==="idle";t.notifyCompletion===!0&&x&&y.add(t.terminal.id),t.notifyCompletion===!0&&w&&D&&y.has(t.terminal.id)&&(d=zw(o,t.terminal.id,f?.currentCommand??null,"finished")),(D||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(d){const w=Nx(o,t.terminal.id);w&&(w.workspace.activeTabId!==w.tab.id||w.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id),C.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=_5(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(C=>C.id===t.workspaceId);f=b?.tabs.find(C=>C.id===b.activeTabId)??null}const y=f?Bi(f.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const C of y)b.delete(C);c=b}}const m=o!==n.state,g=c!==n.unreadCompletions;if((m||g)&&_l(e,{...n,state:o,unreadCompletions:c}),g&&h_(),d)for(const f of Array.from(dv))f({agentId:e,...d})}function g5(e,t){return e!==void 0&&t!==void 0&&e!==t}function v5(e){let t=tu.get(e);return t||(t=new Map,tu.set(e,t)),t}function Nx(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Bi(s.root).includes(t))return{workspace:n,tab:s};return null}function _5(e,t){for(const n of e.workspaces){const s=n.tabs.find(o=>o.id===t);if(s)return{workspace:n,tab:s}}return null}const hv=new Set;function b5(e){return hv.add(e),()=>{hv.delete(e)}}function y5(){let e=0;for(const t of _a.values())e+=t.unreadCompletions.size;return e}function h_(){for(const e of Array.from(hv))e()}function Ow(e,t){const n=Ot(e);if(!n.unreadCompletions.has(t))return;const s=new Set(n.unreadCompletions);s.delete(t),_l(e,{...n,unreadCompletions:s}),h_()}function jw(e,t){const n=Ot(e);t!==n.state&&_l(e,{...n,state:t})}function Lm(e,t){const n=Ot(e),s=t(n.editors);s!==n.editors&&_l(e,{...n,editors:s})}function ra(e,t,n){const s=Ot(e);s.loaded===t&&s.error===n||_l(e,{...s,loaded:t,error:n})}function yc(e,t,n){const s=Ot(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||_l(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n})}function S5(e){const t=Ot(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function w5(e){const t=vl(e),n=_a.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1;_a.delete(t),Qc.delete(t),Jc.delete(t),eu.delete(t),tu.delete(t),s&&h_()}function Bm(){for(const e of _a.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}_a.clear(),Qc.clear(),Jc.clear(),eu.clear(),tu.clear()}function C5(e){let t=Jc.get(e);return t||(t=new Set,Jc.set(e,t)),t}function x5(e){let t=eu.get(e);return t||(t=new Set,eu.set(e,t)),t}function zw(e,t,n,s){const o=Nx(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:s}:null}function fv(e,t){let n=!1,s=!1,o=null,c=!1;for(const d of Gc(e)){const m=t[d];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(s=!0,n=!0,!o&&m.currentCommand&&(o=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function f_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function pv(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function k5(e,t,n,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function E5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:o,onSelectTab:c,onCreateTab:d,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:C,onRenameTab:w,activePaneAvailable:x}){const[D,B]=v.useState(null),[L,O]=v.useState(!1),[X,U]=v.useState(null),G=v.useRef(null),F=e.findIndex(K=>K.id===t),W=F>=0?e[F]:e[0]??null,ve=W?fv(W,n):null,Se=W?rv(W):0,xe=W?pv(W,n):"No tab";v.useEffect(()=>{G.current?.focus(),G.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!L)return;const K=re=>{re.key==="Escape"&&O(!1)};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[L]),v.useEffect(()=>{L&&e.length===0&&O(!1)},[L,e.length]);function ie(K,re){B({tabId:K,title:re})}function q(){if(!D)return;const K=D.title.trim();K&&w(D.tabId,K),B(null)}function J(){return p.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${dD()}`,onClick:b,disabled:!x,children:p.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${hD()}`,onClick:C,disabled:!x,children:p.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return p.jsxs(p.Fragment,{children:[p.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[p.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:p.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})}),p.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:xe,onClick:()=>O(!0),disabled:e.length===0,children:[ve?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:f_(ve)}):null,p.jsx("span",{children:xe}),p.jsxs("small",{children:[F>=0?F+1:0,"/",e.length||0,Se>1?` / ${Se}`:""]})]}),p.jsxs("div",{className:"terminal-tab-list",children:[e.map((K,re)=>{const A=Gc(K),R=rv(K),P=pv(K,n),ne=K.id===t,ge=D?.tabId===K.id,M=fv(K,n),V=s?.has(K.id)??!1;return p.jsxs(Li.Fragment,{children:[p.jsx(Pw,{index:re}),p.jsx(T5,{tab:K,active:ne,editing:ge,title:P,paneCount:R,terminalIds:A,canClose:e.length>1,editValue:ge?D.title:null,editInputRef:ge?G:null,activity:M,unread:V,onSelect:()=>c(K.id),onBeginRename:()=>ie(K.id,P),onCloseAll:()=>g(A),onCommitRename:q,onCancelRename:()=>B(null),onRenameChange:le=>B({tabId:K.id,title:le})})]},K.id)}),p.jsx(Pw,{index:e.length}),p.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:d,children:"+"}),(o?.length??0)>0?p.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(K=>p.jsx(R5,{terminal:K,onReattach:()=>f?.(K.id),onDelete:()=>U(K)},K.id))}):null]}),p.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:d,children:"+"}),x?J():null]}),L?p.jsx(D5,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:D,editInputRef:G,onClose:()=>O(!1),onSelectTab:K=>{c(K),O(!1)},onCreateTab:()=>{d(),O(!1)},onBeginRename:ie,onCloseTerminals:K=>{g(K),O(!1)},onCommitRename:q,onCancelRename:()=>B(null),onRenameChange:(K,re)=>B({tabId:K,title:re}),onReattachTerminal:K=>{f?.(K),O(!1)},onDeleteTerminal:K=>{U(K),O(!1)}}):null,X?p.jsx(M5,{terminal:X,onCancel:()=>U(null),onConfirm:()=>{y?.(X.id),U(null)}}):null]})}function T5({tab:e,active:t,editing:n,title:s,paneCount:o,canClose:c,editValue:d,editInputRef:m,activity:g,unread:f,onSelect:y,onBeginRename:b,onCloseAll:C,onCommitRename:w,onCancelRename:x,onRenameChange:D}){const{attributes:B,listeners:L,setNodeRef:O,transform:X,isDragging:U}=_1({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),G={transform:Hm.Translate.toString(X),opacity:U?.4:void 0,zIndex:U?2:void 0};return p.jsxs("div",{ref:O,className:"terminal-tab","data-active":t,"data-dragging":U,"data-unread":f?"true":void 0,style:G,...B,...L,children:[g?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:f_(g)}):null,n&&m&&d!==null?p.jsxs("form",{className:"terminal-tab-editor",onSubmit:F=>{F.preventDefault(),w()},children:[p.jsx("input",{ref:m,"aria-label":`Rename ${s}`,value:d,onBlur:w,onChange:F=>D(F.target.value),onKeyDown:F=>{if(F.key==="Enter"){F.preventDefault(),w();return}F.key==="Escape"&&(F.preventDefault(),x())}}),p.jsx("small",{children:o})]}):p.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:y,onDoubleClick:F=>{F.preventDefault(),b()},children:[p.jsx("span",{children:s}),p.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?p.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),C()},children:"x"}):null]})}function D5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:c,editInputRef:d,onClose:m,onSelectTab:g,onCreateTab:f,onBeginRename:y,onCloseTerminals:b,onCommitRename:C,onCancelRename:w,onRenameChange:x,onReattachTerminal:D,onDeleteTerminal:B}){const L=v.useRef(null);return v.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),p.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:p.jsxs("section",{className:"mobile-tab-sheet",onClick:O=>O.stopPropagation(),children:[p.jsxs("header",{children:[p.jsxs("div",{children:[p.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),p.jsxs("small",{children:[e.length," open"]})]}),p.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[p.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),p.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((O,X)=>{const U=Gc(O),G=rv(O),F=pv(O,n),W=O.id===t,ve=c?.tabId===O.id,Se=fv(O,n),xe=s?.has(O.id)??!1;return p.jsxs("div",{ref:W?L:null,className:"mobile-tab-sheet-row","data-active":W,"data-unread":xe?"true":void 0,children:[ve&&c?p.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),C()},children:p.jsx("input",{ref:d,"aria-label":`Rename ${F}`,value:c.title,onBlur:C,onChange:ie=>x(O.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),C();return}ie.key==="Escape"&&(ie.preventDefault(),w())}})}):p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${F}`,onClick:()=>g(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:X+1}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:F}),p.jsx("small",{children:k5(O,n,G,Se)})]}),p.jsxs("span",{className:"mobile-tab-sheet-meta",children:[Se?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":Se.state,"aria-hidden":"true",title:f_(Se)}):null,p.jsx("span",{children:G})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ve?p.jsx("button",{type:"button","aria-label":`Done renaming ${F}`,onClick:C,children:"Done"}):p.jsx("button",{type:"button","aria-label":`Rename ${F}`,onClick:()=>y(O.id,F),children:"Rename"}),e.length>1?p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${F}`,onClick:()=>b(U),children:"×"}):null]})]},O.id)}),(o?.length??0)>0?p.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[p.jsx("span",{children:"Detached"}),(o??[]).map(O=>{const X=O.title||O.cwd||O.id.slice(0,8);return p.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${X}`,onClick:()=>D(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:X}),p.jsx("small",{children:O.cwd})]}),p.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),p.jsx("div",{className:"mobile-tab-sheet-actions",children:p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${X}`,onClick:()=>B(O),children:"×"})})]},O.id)})]}):null]})]})})}function Pw({index:e}){const{setNodeRef:t,isOver:n}=Mv({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return p.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function R5({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
55
|
+
`).trimEnd()}function x3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function fx(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function k3(e,t){if(t.length===0)return e;let n=0;const s=Math.min(e.length,t.length);for(let l=s;l>0;l-=1){let c=!0;for(let d=0;d<l;d+=1)if(e[e.length-l+d]!==t[d]){c=!1;break}if(c){n=l;break}}return[...e,...t.slice(n)]}function E3(e){let t=0;for(const n of e){if(!n)continue;const s=n.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function qd(e){const t=[];for(const n of e){const s=px(n);s&&t.push(s)}return t}function px(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const l=n.split(";").filter(Boolean).filter(c=>!RL.has(c.split(":")[0]??""));return l.length>0?`\x1B[?${l.join(";")}${s}`:""})}function Mm(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function T3(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function Aw(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function br(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function $d(e,t){return!t||br(e)}function Lw(e){return br(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function D3(e,t,n,s,l,c,d,m){const g=f=>{const y=M3(f);if(y!==0){if(d()){if(L3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),m(y);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),R3(t,y,n,s,l,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function R3(e,t,n,s,l,c){const d=()=>{l();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Qg,d);return}d()}function M3(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const s=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,s))}function N3(e,t,n,s,l,c,d,m,g){let f=null,y=0;const b={passive:!1};function C(D){f=Nm(D),y=0}function w(D){const B=Nm(D);if(B===null){f=null,y=0;return}if(f===null){f=B;return}const L=B.clientY-f.clientY;if(f=B,D.cancelable&&D.preventDefault(),L===0)return;if(A3(t)&&B3(t,B,-L)){y=0;return}y-=L/n();const O=y<0?Math.ceil(y):Math.floor(y);if(O!==0){if(y-=O,m()){g(O);return}c();try{t.scrollLines(O)}finally{d()}s(),O<0&&t.buffer.active.viewportY<=3&&l(O)}}function x(D){if(D.touches.length>0){f=Nm(D);return}f=null,y=0}return e.addEventListener("touchstart",C,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",C,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Nm(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function A3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function L3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function B3(e,t,n){const s=e.element;return s?(s.dispatchEvent(O3(t,n)),!0):!1}function O3(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const l=new Event("wheel",s);return Object.defineProperties(l,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),l}function ev({node:e,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c=!0,refreshCwdOnEnter:d=!1,tabId:m,codeServerContext:g,dropZoneActive:f=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:C=[],totalPanes:w,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,onAuthClose:U}){const G=w??tv(e);if(C.length===0&&b){const Se=iv(e),xe=Se.some(re=>re.key===b)?b:Se[0]?.key;if(Se.length>1&&xe)return p.jsx("div",{className:"mobile-focused-split",children:Se.map(re=>{const $=re.key===xe;if(re.type==="editor"){const K=n[re.editorId];return p.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:K?p.jsx(c0,{api:s,editor:K,canClose:G>1,onClose:()=>X(re.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},re.key)}const J=t[re.terminalId];return J?p.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:p.jsx(ww,{terminal:J,serverApi:s,active:$,visible:c&&$,canClose:G>1,refreshCwdOnEnter:d&&$,tabId:m,codeServerContext:g,onSelect:()=>x(re.terminalId),onClose:()=>D(re.terminalId),onExit:K=>L(re.terminalId,K),onSnapshot:O,...U?{onAuthClose:U}:{}})},re.key):p.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},re.key)})})}if(e.type==="pane"){const Se=t[e.terminalId];if(!Se)return p.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const xe=p.jsx(ww,{terminal:Se,serverApi:s,active:e.terminalId===l,visible:c,canClose:G>1,refreshCwdOnEnter:d&&e.terminalId===l,tabId:m,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>D(e.terminalId),onExit:$=>L(e.terminalId,$),onSnapshot:O,...U?{onAuthClose:U}:{}});return f&&y!==e.terminalId?p.jsxs("div",{className:"pane-drop-host",children:[xe,p.jsx(Vd,{terminalId:e.terminalId,side:"top"}),p.jsx(Vd,{terminalId:e.terminalId,side:"right"}),p.jsx(Vd,{terminalId:e.terminalId,side:"bottom"}),p.jsx(Vd,{terminalId:e.terminalId,side:"left"})]}):xe}if(e.type==="editor"){const Se=n[e.editorId];return Se?p.jsx(c0,{api:s,editor:Se,canClose:G>1,onClose:()=>X(e.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const W=Math.max(.1,Math.min(.9,e.ratio)),q=1-W,ge=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${W}fr) 1px minmax(0, ${q}fr)`}:{gridTemplateRows:`minmax(0, ${W}fr) 1px minmax(0, ${q}fr)`};return p.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ge,children:[p.jsx("div",{className:"split-cell",children:p.jsx(ev,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,0],totalPanes:G,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,...U?{onAuthClose:U}:{}})}),p.jsx(j3,{direction:e.direction,path:C,onResize:B}),p.jsx("div",{className:"split-cell",children:p.jsx(ev,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:f,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,1],totalPanes:G,onSelect:x,onClose:D,onResize:B,onExit:L,onSnapshot:O,onCloseEditor:X,...U?{onAuthClose:U}:{}})})]})}function Vd({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=Mv({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return p.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function j3({direction:e,path:t,onResize:n}){function s(l){l.preventDefault(),l.stopPropagation();const c=l.currentTarget;c.setPointerCapture?.(l.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return p.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:p.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function tv(e){return e.type==="pane"||e.type==="editor"?1:tv(e.first)+tv(e.second)}function iv(e){return e.type==="pane"?[{key:z3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:P3(e.editorId),type:"editor",editorId:e.editorId}]:[...iv(e.first),...iv(e.second)]}function z3(e){return`terminal:${e}`}function P3(e){return`editor:${e}`}const Yh="workspace-default",I3="NTerminal";function H3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function U3(e,t){switch(t.type){case"workspace.hydrated":return nv(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return K3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return $3(e,t.workspaceId);case"workspace.selected":return mx(e,t.workspaceId);case"workspace.renamed":return F3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return W3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return q3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return gx(e,t.terminal);case"terminal.split":return V3(e,t.terminal,t.direction);case"terminal.updated":return r5(e,t.terminal);case"terminal.exited":return s5(e,t.terminalId,t.exitCode);case"terminal.closed":return bx(e,t.terminalId);case"terminal.detached":return a5(e,t.terminalId,t.workspaceId);case"editor.split":return Y3(e,t.editorId,t.title,t.direction);case"editor.closed":return l5(e,t.editorId);case"pane.selected":return i5(e,t.terminalId);case"pane.resized":return n5(e,t.path,t.ratio);case"tab.selected":return G3(e,t.tabId);case"tab.renamed":return t5(e,t.tabId,t.title);case"tab.reordered":return u_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return Z3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return vx(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return _x(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return Q3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return X3(e);default:return e}}function K3(e,t){if(e.workspaces.some(s=>s.id===t.id))return mx(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Sr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function mx(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function F3(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(d=>d.id!==t||d.title===s?d:(l=!0,{...d,title:s}));return l?{...e,workspaces:c}:e}function W3(e,t,n){const s=Sr(n);let l=!1;const c=e.workspaces.map(d=>d.id!==t||d.defaultCwd===s?d:(l=!0,{...d,defaultCwd:s}));return l?{...e,workspaces:c}:e}function q3(e,t,n,s){if(t===n)return e;const l=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(l<0||c<0)return e;const d=e.workspaces.slice(),[m]=d.splice(l,1);if(!m)return e;const g=d.findIndex(b=>b.id===n);if(g<0)return e;const f=s==="before"?g:g+1,y=d.slice();return y.splice(f,0,m),e5(e.workspaces,y)?e:{...e,workspaces:y}}function $3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),s=new Set(n?Th(n):[]),l={...e.terminals};for(const m of s)delete l[m];const c=e.workspaces.filter(m=>m.id!==t),d=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:d,terminals:l}}function gx(e,t){const n=Sx(e),s=cl(n)??Gh(),l=Ex(t);return{...n,activeWorkspaceId:s.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??Sr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...c.tabs,l],activeTabId:l.id}:kx(c,t.id))}}function V3(e,t,n){const s=cl(e),l=s?Xh(s):void 0;if(!s||!l)return gx(e,t);const c=l.activeTerminalId,d=Zc(l.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(m=>m.id===s.id?{...m,defaultCwd:m.defaultCwd??Sr(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===l.id?{...g,root:d,activeTerminalId:t.id}:g)}:kx(m,t.id))}}function Y3(e,t,n,s){const l=cl(e),c=l?Xh(l):void 0;if(!l||!c)return e;const d=c.activeTerminalId,m=Zc(c.root,d,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===l.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:m,activeTerminalId:d}:f)}:g)}}function X3(e){const t=cl(e),n=t?Xh(t):void 0;return n?bx(e,n.activeTerminalId):e}function G3(e,t){const n=cl(e);return!n||!n.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===n.id?{...s,activeTabId:t}:s)}}function u_(e,t,n){const s=e.workspaces.map(l=>{const c=l.tabs.findIndex(y=>y.id===t);if(c<0)return l;const d=l.tabs.slice(),[m]=d.splice(c,1);if(!m)return l;const g=Math.max(0,Math.min(d.length,n)),f=d.slice();return f.splice(g,0,m),J3(l.tabs,f)?l:{...l,tabs:f}});return s.every((l,c)=>l===e.workspaces[c])?e:{...e,workspaces:s}}function Z3(e,t,n,s,l){if(n===s||!e.terminals[n]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(x=>x.id===t);if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b=oo(y.root,n);if(!b){const x=g.tabs.filter((D,B)=>B!==f);return{...g,tabs:x}}const C={...y,root:b,activeTerminalId:Bi(b)[0]??y.activeTerminalId},w=g.tabs.slice();return w[f]=C,{...g,tabs:w}});const d=l==="left"||l==="right"?"vertical":"horizontal",m=l==="left"||l==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>Bi(D.root).includes(s));if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b={type:"pane",terminalId:n},C={type:"split",direction:d,ratio:.5,first:m?b:{type:"pane",terminalId:s},second:m?{type:"pane",terminalId:s}:b},w=Zc(y.root,s,C),x=g.tabs.slice();return x[f]={...y,root:w,activeTerminalId:n},{...g,tabs:x,activeTabId:y.id}}),Sx({...e,workspaces:c})}function vx(e,t,n,s){let l=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const L=e.workspaces[B].tabs.findIndex(O=>O.id===t);if(L>=0){l=B,c=L;break}}if(l<0)return e;const d=e.workspaces[l],m=d.tabs[c],g=Bi(m.root);if(!g.includes(n))return e;if(g.length===1)return u_(e,t,s);const f=oo(m.root,n);if(!f)return e;const y={...m,root:f,activeTerminalId:Bi(f)[0]??m.activeTerminalId},b=e.terminals[n],C={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=d.tabs.slice();w[c]=y;const x=Math.max(0,Math.min(w.length,s));w.splice(x,0,C);const D=e.workspaces.slice();return D[l]={...d,tabs:w,activeTabId:C.id},{...e,workspaces:D}}function _x(e,t,n,s=Number.MAX_SAFE_INTEGER){const l=wx(e.workspaces,t),c=e.workspaces.find(f=>f.id===n);if(!l||!c)return e;if(l.workspace.id===n)return s===Number.MAX_SAFE_INTEGER?e:u_(e,t,s);const d=Bi(l.tab.root),m=d.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===l.workspace.id)return ul({...f,tabs:f.tabs.filter(y=>y.id!==t)});if(f.id===n){const y=f.tabs.slice(),b=Math.max(0,Math.min(y.length,s));return y.splice(b,0,l.tab),{...f,defaultCwd:f.defaultCwd??Sr(m?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(C=>!d.includes(C)),tabs:y,activeTabId:l.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:n}}function Q3(e,t,n,s,l=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),d=wx(e.workspaces,t);if(!c||!d||!e.terminals[n]||!Bi(d.tab.root).includes(n))return e;if(d.workspace.id===s)return vx(e,t,n,l);if(Bi(d.tab.root).length===1)return _x(e,t,s,l);const g=oo(d.tab.root,n);if(!g)return e;const f={...d.tab,root:g,activeTerminalId:Bi(g)[0]??d.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},C=e.workspaces.map(w=>{if(w.id===d.workspace.id)return ul({...w,tabs:w.tabs.map(x=>x.id===t?f:x)});if(w.id===s){const x=w.tabs.slice(),D=Math.max(0,Math.min(x.length,l));return x.splice(D,0,b),{...w,defaultCwd:w.defaultCwd??Sr(y.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(B=>B!==n),tabs:x,activeTabId:b.id}}return w});return{...e,workspaces:C,activeWorkspaceId:s}}function J3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function e5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function t5(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(d=>{let m=!1;const g=d.tabs.map(f=>f.id!==t||f.title===s?f:(l=!0,m=!0,{...f,title:s}));return m?{...d,tabs:g}:d});return l?{...e,workspaces:c}:e}function i5(e,t){const n=e.workspaces.find(l=>l.tabs.some(c=>co(c.root,t))),s=n?.tabs.find(l=>co(l.root,t));return!n||!s?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(l=>l.id===n.id?{...l,activeTabId:s.id,tabs:l.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:l)}}function n5(e,t,n){const s=cl(e),l=s?Xh(s):void 0;if(!s||!l)return e;const c=cv(l.root,t,Rx(n));return c===l.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===s.id?{...d,tabs:d.tabs.map(m=>m.id===l.id?{...m,root:c}:m)}:d)}}function nv(e,t,n,s){const l=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),d=new Set,m=!!(n&&n.some(b=>Tx(b))||t&&t.some(b=>Dx(b)));let g=o5(t,n,c,d);g.length===0&&(g=[Gh()]);const f=typeof s=="string"&&g.some(b=>b.id===s)?s:g[0]?.id??null,y=f??g[0]?.id??Yh;for(const b of e)if(!d.has(b.id)){if(m)g=d5(g,y,b.id,b);else{const C=Ex(b);g=f5(g,y,C,b)}d.add(b.id)}return{workspaces:g.map(b=>ul(h5(b,l))),activeWorkspaceId:f,terminals:l}}function Gc(e){return Bi(e.root)}function rv(e){return uv(e.root)}function Th(e){return d_([...e.tabs.flatMap(t=>Bi(t.root)),...e.detachedTerminalIds])}function Am(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(l=>{const c=lv(l.root);return c?[{...l,root:c}]:[]});return ul({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function r5(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>co(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function s5(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function bx(e,t){const n={...e.terminals};return delete n[t],yx(e,t,n)}function a5(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(c=>c.id===n)?n:null)??c5(e,t)?.id??u5(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Yh,l=e.workspaces.find(c=>c.id===s);return!l||!xx(l,t)?e:yx(e,t,{...e.terminals},{detachToWorkspaceId:s})}function yx(e,t,n,s={}){let l=e.workspaces.map(d=>{const m=[];for(const g of d.tabs){const f=oo(g.root,t);if(!f)continue;const y=Bi(f),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:f,activeTerminalId:b})}return ul({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:m})});s.detachToWorkspaceId&&n[t]&&(l=l.map(d=>d.id===s.detachToWorkspaceId?Cx(d,t,n[t]):d));const c=l.some(d=>d.id===e.activeWorkspaceId);return{workspaces:l,activeWorkspaceId:c?e.activeWorkspaceId:l[0]?.id??null,terminals:n}}function l5(e,t){const n=e.workspaces.map(l=>{const c=[];for(const d of l.tabs){const m=sv(d.root,t);if(!m)continue;const g=Bi(m),f=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];f&&c.push({...d,root:m,activeTerminalId:f})}return ul({...l,tabs:c})}),s=n.some(l=>l.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function o5(e,t,n,s){if(t&&t.length>0){const l=[];for(const c of t)Tx(c)&&l.push(Bw(c,n,s));if(l.length>0)return l}return[Bw({...Gh(),tabs:e??[]},n,s)]}function Bw(e,t,n){const s=[];for(const c of e.tabs){if(!Dx(c))continue;const d=av(c.root,t);if(!d)continue;const m=Bi(d);for(const f of m)n.add(f);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&s.push({...c,root:d,activeTerminalId:g})}const l=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),l.push(c));return ul({...e,defaultCwd:Sr(e.defaultCwd),detachedTerminalIds:l,tabs:s})}function Sx(e){return cl(e)?e:{...e,workspaces:[Gh()],activeWorkspaceId:Yh}}function cl(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Xh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function wx(e,t){for(const n of e){const s=n.tabs.findIndex(l=>l.id===t);if(s>=0)return{workspace:n,tab:n.tabs[s],tabIndex:s}}return null}function c5(e,t){return e.workspaces.find(n=>n.tabs.some(s=>co(s.root,t)))}function u5(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function d5(e,t,n,s){return e.map(l=>l.id===t?Cx(l,n,s):l)}function Cx(e,t,n){return xx(e,t)?{...e,defaultCwd:e.defaultCwd??Sr(n?.cwd),detachedTerminalIds:d_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function xx(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<fo}function kx(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function h5(e,t){if(e.defaultCwd)return e;const n=Th(e).find(l=>!!t[l]),s=n?Sr(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Gh(){return{id:Yh,title:I3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ul(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Sr(e.defaultCwd),detachedTerminalIds:d_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function f5(e,t,n,s){const l=Bi(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Sr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>!l.includes(d)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function Ex(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Zc(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Zc(e.first,t,n),second:Zc(e.second,t,n)}}function oo(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=oo(e.first,t),s=oo(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function sv(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=sv(e.first,t),s=sv(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function av(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=av(e.first,t),s=av(e.second,t);return n&&s?{...e,ratio:Rx(e.ratio),first:n,second:s}:n??s}function lv(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=lv(e.first),n=lv(e.second);return t&&n?{...e,first:t,second:n}:t??n}function Tx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function Dx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&ov(t.root)}function ov(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&ov(t.first)&&ov(t.second):!1}function cv(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[s,...l]=t;if(s===0){const c=cv(e.first,l,n);return c===e.first?e:{...e,first:c}}if(s===1){const c=cv(e.second,l,n);return c===e.second?e:{...e,second:c}}return e}function Rx(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Sr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function d_(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));return n}function co(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:co(e.first,t)||co(e.second,t)}function Bi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Bi(e.first),...Bi(e.second)]}function uv(e){return e.type==="pane"||e.type==="editor"?1:uv(e.first)+uv(e.second)}const ba=new Map,Qc=new Map,Jc=new Map,eu=new Map,tu=new Map;function vo(e){return e??"__local__"}function p5(e){return{agentId:e,state:H3(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Ot(e){const t=vo(e);let n=ba.get(t);return n||(n=p5(e),ba.set(t,n)),n}function Mx(e,t){const n=vo(e);let s=Qc.get(n);return s||(s=new Set,Qc.set(n,s)),s.add(t),()=>{s.delete(t)}}function m5(e){const t=vo(e),n=Qc.get(t);if(n)for(const s of Array.from(n))s()}function _o(e,t){ba.set(vo(e),t),m5(e)}const dv=new Set;function g5(e){return dv.add(e),()=>{dv.delete(e)}}function Vl(e,t){const n=Ot(e),s=vo(e);t.type==="workspace.hydrated"&&(Jc.delete(s),eu.delete(s),tu.delete(s));const l=U3(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],y=x5(s),b=k5(s),C=_5(s);if(t.terminal.agentStatus){const w=t.terminal.agentStatus.state,x=t.terminal.agentStatus.sessionId,D=C.get(t.terminal.id),B=!!(f&&(f.currentCommand!==t.terminal.currentCommand||f.agentStatus?.provider!==t.terminal.agentStatus.provider||v5(D,x)));B&&(b.delete(t.terminal.id),y.delete(t.terminal.id),C.delete(t.terminal.id)),x&&C.set(t.terminal.id,x),t.notifyCompletion===!0&&(w==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):w==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!B&&(w==="done"||w==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(d=zw(l,t.terminal.id,f?.currentCommand??null,w==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),w==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{f?.agentStatus&&(b.delete(t.terminal.id),C.delete(t.terminal.id));const w=f?.activity==="busy",x=t.terminal.activity==="busy",D=t.terminal.activity==="idle";t.notifyCompletion===!0&&x&&y.add(t.terminal.id),t.notifyCompletion===!0&&w&&D&&y.has(t.terminal.id)&&(d=zw(l,t.terminal.id,f?.currentCommand??null,"finished")),(D||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(d){const w=Nx(l,t.terminal.id);w&&(w.workspace.activeTabId!==w.tab.id||w.workspace.id!==l.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id),C.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=b5(l,t.tabId)?.tab??null;else{const b=l.workspaces.find(C=>C.id===t.workspaceId);f=b?.tabs.find(C=>C.id===b.activeTabId)??null}const y=f?Bi(f.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const C of y)b.delete(C);c=b}}const m=l!==n.state,g=c!==n.unreadCompletions;if((m||g)&&_o(e,{...n,state:l,unreadCompletions:c}),g&&h_(),d)for(const f of Array.from(dv))f({agentId:e,...d})}function v5(e,t){return e!==void 0&&t!==void 0&&e!==t}function _5(e){let t=tu.get(e);return t||(t=new Map,tu.set(e,t)),t}function Nx(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Bi(s.root).includes(t))return{workspace:n,tab:s};return null}function b5(e,t){for(const n of e.workspaces){const s=n.tabs.find(l=>l.id===t);if(s)return{workspace:n,tab:s}}return null}const hv=new Set;function y5(e){return hv.add(e),()=>{hv.delete(e)}}function S5(){let e=0;for(const t of ba.values())e+=t.unreadCompletions.size;return e}function h_(){for(const e of Array.from(hv))e()}function Ow(e,t){const n=Ot(e);if(!n.unreadCompletions.has(t))return;const s=new Set(n.unreadCompletions);s.delete(t),_o(e,{...n,unreadCompletions:s}),h_()}function jw(e,t){const n=Ot(e);t!==n.state&&_o(e,{...n,state:t})}function Lm(e,t){const n=Ot(e),s=t(n.editors);s!==n.editors&&_o(e,{...n,editors:s})}function sa(e,t,n){const s=Ot(e);s.loaded===t&&s.error===n||_o(e,{...s,loaded:t,error:n})}function yc(e,t,n){const s=Ot(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||_o(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n})}function w5(e){const t=Ot(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function C5(e){const t=vo(e),n=ba.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1;ba.delete(t),Qc.delete(t),Jc.delete(t),eu.delete(t),tu.delete(t),s&&h_()}function Bm(){for(const e of ba.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}ba.clear(),Qc.clear(),Jc.clear(),eu.clear(),tu.clear()}function x5(e){let t=Jc.get(e);return t||(t=new Set,Jc.set(e,t)),t}function k5(e){let t=eu.get(e);return t||(t=new Set,eu.set(e,t)),t}function zw(e,t,n,s){const l=Nx(e,t);return l?{terminalId:t,tabId:l.tab.id,commandName:n,outcome:s}:null}function fv(e,t){let n=!1,s=!1,l=null,c=!1;for(const d of Gc(e)){const m=t[d];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(s=!0,n=!0,!l&&m.currentCommand&&(l=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:l}:{state:"idle",commandName:null}:null}function f_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function pv(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function E5(e,t,n,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function T5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,onSelectTab:c,onCreateTab:d,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:C,onRenameTab:w,activePaneAvailable:x}){const[D,B]=v.useState(null),[L,O]=v.useState(!1),[X,U]=v.useState(null),G=v.useRef(null),W=e.findIndex(K=>K.id===t),q=W>=0?e[W]:e[0]??null,ge=q?fv(q,n):null,Se=q?rv(q):0,xe=q?pv(q,n):"No tab";v.useEffect(()=>{G.current?.focus(),G.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!L)return;const K=se=>{se.key==="Escape"&&O(!1)};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[L]),v.useEffect(()=>{L&&e.length===0&&O(!1)},[L,e.length]);function re(K,se){B({tabId:K,title:se})}function $(){if(!D)return;const K=D.title.trim();K&&w(D.tabId,K),B(null)}function J(){return p.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${hD()}`,onClick:b,disabled:!x,children:p.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),p.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${fD()}`,onClick:C,disabled:!x,children:p.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return p.jsxs(p.Fragment,{children:[p.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[p.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:p.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[p.jsx("span",{}),p.jsx("span",{}),p.jsx("span",{})]})}),p.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:xe,onClick:()=>O(!0),disabled:e.length===0,children:[ge?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":ge.state,"aria-hidden":"true",title:f_(ge)}):null,p.jsx("span",{children:xe}),p.jsxs("small",{children:[W>=0?W+1:0,"/",e.length||0,Se>1?` / ${Se}`:""]})]}),p.jsxs("div",{className:"terminal-tab-list",children:[e.map((K,se)=>{const A=Gc(K),R=rv(K),z=pv(K,n),ne=K.id===t,_e=D?.tabId===K.id,M=fv(K,n),F=s?.has(K.id)??!1;return p.jsxs(Li.Fragment,{children:[p.jsx(Pw,{index:se}),p.jsx(D5,{tab:K,active:ne,editing:_e,title:z,paneCount:R,terminalIds:A,canClose:e.length>1,editValue:_e?D.title:null,editInputRef:_e?G:null,activity:M,unread:F,onSelect:()=>c(K.id),onBeginRename:()=>re(K.id,z),onCloseAll:()=>g(A),onCommitRename:$,onCancelRename:()=>B(null),onRenameChange:ie=>B({tabId:K.id,title:ie})})]},K.id)}),p.jsx(Pw,{index:e.length}),p.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:d,children:"+"}),(l?.length??0)>0?p.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(K=>p.jsx(M5,{terminal:K,onReattach:()=>f?.(K.id),onDelete:()=>U(K)},K.id))}):null]}),p.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:d,children:"+"}),x?J():null]}),L?p.jsx(R5,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:D,editInputRef:G,onClose:()=>O(!1),onSelectTab:K=>{c(K),O(!1)},onCreateTab:()=>{d(),O(!1)},onBeginRename:re,onCloseTerminals:K=>{g(K),O(!1)},onCommitRename:$,onCancelRename:()=>B(null),onRenameChange:(K,se)=>B({tabId:K,title:se}),onReattachTerminal:K=>{f?.(K),O(!1)},onDeleteTerminal:K=>{U(K),O(!1)}}):null,X?p.jsx(N5,{terminal:X,onCancel:()=>U(null),onConfirm:()=>{y?.(X.id),U(null)}}):null]})}function D5({tab:e,active:t,editing:n,title:s,paneCount:l,canClose:c,editValue:d,editInputRef:m,activity:g,unread:f,onSelect:y,onBeginRename:b,onCloseAll:C,onCommitRename:w,onCancelRename:x,onRenameChange:D}){const{attributes:B,listeners:L,setNodeRef:O,transform:X,isDragging:U}=_1({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),G={transform:Hm.Translate.toString(X),opacity:U?.4:void 0,zIndex:U?2:void 0};return p.jsxs("div",{ref:O,className:"terminal-tab","data-active":t,"data-dragging":U,"data-unread":f?"true":void 0,style:G,...B,...L,children:[g?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:f_(g)}):null,n&&m&&d!==null?p.jsxs("form",{className:"terminal-tab-editor",onSubmit:W=>{W.preventDefault(),w()},children:[p.jsx("input",{ref:m,"aria-label":`Rename ${s}`,value:d,onBlur:w,onChange:W=>D(W.target.value),onKeyDown:W=>{if(W.key==="Enter"){W.preventDefault(),w();return}W.key==="Escape"&&(W.preventDefault(),x())}}),p.jsx("small",{children:l})]}):p.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:y,onDoubleClick:W=>{W.preventDefault(),b()},children:[p.jsx("span",{children:s}),p.jsxs("small",{children:[l," pane",l===1?"":"s"]})]}),c&&!n?p.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:W=>W.stopPropagation(),onClick:W=>{W.stopPropagation(),C()},children:"x"}):null]})}function R5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:c,editInputRef:d,onClose:m,onSelectTab:g,onCreateTab:f,onBeginRename:y,onCloseTerminals:b,onCommitRename:C,onCancelRename:w,onRenameChange:x,onReattachTerminal:D,onDeleteTerminal:B}){const L=v.useRef(null);return v.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),p.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:p.jsxs("section",{className:"mobile-tab-sheet",onClick:O=>O.stopPropagation(),children:[p.jsxs("header",{children:[p.jsxs("div",{children:[p.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),p.jsxs("small",{children:[e.length," open"]})]}),p.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[p.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),p.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((O,X)=>{const U=Gc(O),G=rv(O),W=pv(O,n),q=O.id===t,ge=c?.tabId===O.id,Se=fv(O,n),xe=s?.has(O.id)??!1;return p.jsxs("div",{ref:q?L:null,className:"mobile-tab-sheet-row","data-active":q,"data-unread":xe?"true":void 0,children:[ge&&c?p.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:re=>{re.preventDefault(),C()},children:p.jsx("input",{ref:d,"aria-label":`Rename ${W}`,value:c.title,onBlur:C,onChange:re=>x(O.id,re.target.value),onKeyDown:re=>{if(re.key==="Enter"){re.preventDefault(),C();return}re.key==="Escape"&&(re.preventDefault(),w())}})}):p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${W}`,onClick:()=>g(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:X+1}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:W}),p.jsx("small",{children:E5(O,n,G,Se)})]}),p.jsxs("span",{className:"mobile-tab-sheet-meta",children:[Se?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":Se.state,"aria-hidden":"true",title:f_(Se)}):null,p.jsx("span",{children:G})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ge?p.jsx("button",{type:"button","aria-label":`Done renaming ${W}`,onClick:C,children:"Done"}):p.jsx("button",{type:"button","aria-label":`Rename ${W}`,onClick:()=>y(O.id,W),children:"Rename"}),e.length>1?p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${W}`,onClick:()=>b(U),children:"×"}):null]})]},O.id)}),(l?.length??0)>0?p.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[p.jsx("span",{children:"Detached"}),(l??[]).map(O=>{const X=O.title||O.cwd||O.id.slice(0,8);return p.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${X}`,onClick:()=>D(O.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:X}),p.jsx("small",{children:O.cwd})]}),p.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),p.jsx("div",{className:"mobile-tab-sheet-actions",children:p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${X}`,onClick:()=>B(O),children:"×"})})]},O.id)})]}):null]})]})})}function Pw({index:e}){const{setNodeRef:t,isOver:n}=Mv({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return p.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function M5({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),l=`${e.title||"Terminal"}
|
|
56
56
|
${e.cwd}
|
|
57
|
-
(detached — click to re-open, × to delete)`;return p.jsxs("span",{className:"terminal-detached-pill",title:o,children:[p.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),p.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function M5({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:"Delete this terminal?"}),p.jsx("span",{children:s}),p.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function N5({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:o}){if(e.length===0)return null;const d=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return p.jsxs("aside",{className:`upload-toast upload-toast-${j5(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[p.jsxs("header",{className:"upload-toast-header",children:[p.jsx("strong",{children:e.length===1?sh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),p.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),p.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>p.jsx(A5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>o(g.id)},g.id))})]})}function A5({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:o}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return p.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":sh(e),children:[p.jsxs("div",{className:"upload-queue-item-header",children:[p.jsx("strong",{children:sh(e)}),p.jsxs("div",{className:"upload-queue-actions",children:[m?p.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?p.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,p.jsx("button",{type:"button","aria-label":`Dismiss ${sh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?p.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?p.jsx(L5,{toast:e}):null,c&&"message"in e&&e.message?p.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?p.jsx(B5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?p.jsx("p",{children:e.message}):null]})}function L5({toast:e}){const t=e.percent===null?z5(e.loaded):`${e.percent}%`;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"upload-progress-row",children:[p.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),p.jsx("span",{children:t})]}),p.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:p.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function B5({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),s=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,c=[...n,...s].slice(0,o);return p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?p.jsx("ul",{className:"upload-result-list",children:c.map((d,m)=>p.jsx(O5,{result:d},`${d.relativePath}-${m}`))}):null,e.results.length>c.length?p.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function O5({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return p.jsxs("li",{"data-status":e.status,children:[p.jsx("span",{className:"upload-result-path",children:t}),n?p.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?p.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function sh(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function j5(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function z5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function P5({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const s=e,o=s.outcome==="stopped"?"stopped":"finished",c=s.commandName?`${s.commandName} ${o}`:`Command ${o}`;function d(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(s)))}return p.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:m,children:[p.jsxs("header",{className:"completion-toast-header",children:[p.jsxs("div",{className:"completion-toast-copy",children:[p.jsx("strong",{children:s.tabTitle}),p.jsx("span",{children:c})]}),p.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),p.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const I5=Nc(0,0,1,1),fs=1e-6;function H5(e){return Ax(e).map(t=>t.terminalId)}function Ax(e){return Mc(e,I5).sort(W5).map((t,n)=>({...t,index:n+1}))}function U5(e,t,n){const s=Ax(e),o=s.find(d=>d.terminalId===t);return o?s.filter(d=>d.terminalId!==t).map(d=>F5(o,d,n)).filter(d=>d!==null).sort(q5)[0]?.entry.terminalId??null:null}function K5(e,t){return!Number.isInteger(t)||t<1?null:H5(e)[t-1]??null}function Mc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=$5(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Mc(e.first,Nc(t.left,t.top,o,t.bottom)),...Mc(e.second,Nc(o,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...Mc(e.first,Nc(t.left,t.top,t.right,s)),...Mc(e.second,Nc(t.left,s,t.right,t.bottom))]}function F5(e,t,n){const s=e.bounds,o=t.bounds,c=Iw(s.left,s.right,o.left,o.right),d=Iw(s.top,s.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=s.centerX-fs||d<=fs?null:{entry:t,primaryDistance:Math.max(0,s.left-o.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:d};case"right":return o.centerX<=s.centerX+fs||d<=fs?null:{entry:t,primaryDistance:Math.max(0,o.left-s.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:d};case"up":return o.centerY>=s.centerY-fs||c<=fs?null:{entry:t,primaryDistance:Math.max(0,s.top-o.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};case"down":return o.centerY<=s.centerY+fs||c<=fs?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};default:return null}}function W5(e,t){return tl(e.bounds.top,t.bounds.top)||tl(e.bounds.left,t.bounds.left)}function q5(e,t){return tl(e.primaryDistance,t.primaryDistance)||tl(e.perpendicularDistance,t.perpendicularDistance)||tl(t.overlap,e.overlap)||tl(e.entry.index,t.entry.index)}function tl(e,t){const n=e-t;return Math.abs(n)<=fs?0:n}function Iw(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Nc(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function $5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class V5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Hw(e){return e?Array.from(e.types??[]).includes("Files")||jx(e.items).some(n=>n.kind==="file")?!0:zx(e.files).length>0:!1}async function Y5(e){const t=jx(e.items).filter(n=>n.kind==="file");return t.length>0?X5(t):G5(e.files)}async function X5(e){const t=[];for(const n of e){const s=eB(n);if(s){await Lx(s,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Bx(o),file:o});continue}throw new V5("Folder upload is not supported by this browser.")}return t}function G5(e){return zx(e).map(t=>({relativePath:Bx(t),file:t}))}async function Lx(e,t,n){const s=iB(t,e.name);if(e.isFile){const d=await Z5(e);n.push({relativePath:s,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),c=await Q5(o);for(const d of c)await Lx(d,s,n)}function Z5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function Q5(e){const t=[];for(;;){const n=await J5(e);if(n.length===0)return t;t.push(...n)}}function J5(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function Bx(e){const t=e.webkitRelativePath;return Ox(typeof t=="string"&&t?t:e.name)}function eB(e){const t=e.webkitGetAsEntry?.();return tB(t)?t:null}function tB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function iB(e,t){return Ox(e?`${e}/${t}`:t)}function Ox(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function jx(e){return e?Array.from(e):[]}function zx(e){return e?Array.from(e):[]}const Uw="nterminal.terminalWorkspaces.v2",Px="nterminal.sidebarCollapsed.v1",nB=75,Kw=S1.map(e=>e.url),rB=S1[0].url,sB=6;function aB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:d=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??Mh(),[e]),f=v.useMemo(()=>t??rl(null),[t]),y=v.useMemo(()=>TB(n),[n]),b=v.useMemo(()=>S=>Mx(n,S),[n]),C=v.useMemo(()=>()=>Ot(n),[n]),w=v.useSyncExternalStore(b,C,C),x=w.state,D=w.editors,B=!w.loaded,L=w.error,[O,X]=v.useState(!1),[U,G]=v.useState(()=>BB()),[F,W]=v.useState("servers"),[ve,Se]=v.useState(!1),xe=v.useSyncExternalStore(wD,r0,r0);v.useSyncExternalStore(ph,n0,n0);const[ie,q]=v.useState(0),[J,K]=v.useState(null),[re,A]=v.useState(()=>[null]),[R,P]=v.useState(()=>({[lr]:"Local"})),[ne,ge]=v.useState(0),[M,V]=v.useState(()=>[n]),[le,_e]=v.useState(()=>new Set),[be,Ee]=v.useState({}),[Me,Re]=v.useState(null),Pe=v.useRef(0),Be=v.useRef(0),[oe,he]=v.useState(null),[ye,Oe]=v.useState(null),Ke=v.useRef(null),je=v.useRef(0),se=v.useRef(null),Te=v.useRef(null),we=v.useRef(null),ze=v.useRef(null),Ue=v.useRef(()=>{}),[nt,ht]=v.useState(null),Dt=IE(jS(f1,{activationConstraint:{distance:8}}),jS(p1,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>CD(g),[g]);function Ei(S){const T=S.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){ht({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&ht({tabId:T.sourceTabId,terminalId:T.terminalId})}}function ni(S){ht(null);const T=S.active.data.current,j=S.over?.data.current;if(!(!T||!j||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){dt({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){dt({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&dt({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){dt({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){dt({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&dt({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function di(){ht(null)}const ae=x.workspaces.find(S=>S.id===x.activeWorkspaceId)??x.workspaces[0],Ne=ae?.tabs.find(S=>S.id===ae.activeTabId)??ae?.tabs[0],Qe=Ne?.activeTerminalId??null,it=Qe?x.terminals[Qe]:void 0,jt=SB("(max-width: 760px)"),xt=v.useMemo(()=>Ne?Dh(Ne.root):[],[Ne]),gt=ae&&Ne?Ac(n,ae.id,Ne.id):null,Ht=Ne?Ix(xt,Ne.activeTerminalId,gt?be[gt]:void 0):null,kt=jt&&xt.length>1,Rn=v.useMemo(()=>(ae?.detachedTerminalIds??[]).flatMap(S=>{const T=x.terminals[S];return T?[T]:[]}),[ae?.detachedTerminalIds,x.terminals]),Mn=v.useMemo(()=>{const S=new Set;for(const T of ae?.tabs??[])Gc(T).some(j=>w.unreadCompletions.has(j))&&S.add(T.id);return S},[ae?.tabs,w.unreadCompletions]),[Z,We]=v.useState([]),st=v.useRef([]),et=v.useRef(null),[wt,Et]=v.useState(null),[Ut,ri]=v.useState(null),[Gt,Zt]=v.useState([]),[Kt,Qt]=v.useState(()=>ro()),ji=v.useRef(0),hi=v.useRef(n),zi=v.useRef(Kw),gn=v.useRef(Kt),Yi=v.useRef(()=>{});Yi.current=pr,Ue.current=Tr;const Ti=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();Zt(S.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Zt([])}},[g]),on=v.useCallback(S=>{P(T=>{const j={...T};for(const ee of S)j[gv(ee.agentId)]=ee.label;return Om(T,j)?T:j})},[]);v.useEffect(()=>{V(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]);const Di=v.useCallback(S=>{const T=Ot(S),j=rl(S);for(const ee of Object.keys(T.state.terminals))Dc(j.createWebSocketUrl(ee)),Ud(ee);w5(S),V(ee=>ee.filter(pe=>!sn(pe,S))),_e(ee=>{const pe=`${oh(S)}:`;let ue=!1;const Ce=new Set;for(const qe of ee){if(qe.startsWith(pe)){ue=!0;continue}Ce.add(qe)}return ue?Ce:ee}),Ee(ee=>{const pe=`${oh(S)}:`;let ue=!1;const Ce={};for(const[qe,Ye]of Object.entries(ee)){if(qe.startsWith(pe)){ue=!0;continue}Ce[qe]=Ye}return ue?Ce:ee})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(T=>{if(S)return;const j=T.name?.trim()||"Local";P(ee=>{const pe={...ee,[lr]:j};return Om(ee,pe)?ee:pe})}).catch(()=>{}),g.listAgents().then(T=>{if(!S){const j=T.agents.map(pe=>pe.id),ee=[null,...j];P(pe=>{const ue={[lr]:pe[lr]??"Local"};for(const Ce of T.agents)ue[Ce.id]=Ce.name;return Om(pe,ue)?pe:ue}),n!==null&&!j.includes(n)&&(Di(n),s?.(null)),A(ee)}}).catch(()=>{}),()=>{S=!0}},[n,g,Di,s,ne]);const si=v.useCallback(S=>{Di(S),ge(T=>T+1),sn(S,hi.current)&&s?.(null)},[Di,s]);v.useEffect(()=>{A(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]),v.useEffect(()=>{hi.current=n},[n]),v.useEffect(()=>{K(null)},[n]),v.useEffect(()=>{const S=se.current;if(!S)return;if(!sn(S.agentId,n)){se.current=null;return}if(!w.loaded||x.workspaces.length===0)return;se.current=null;const T=S.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];T&&T.id!==x.activeWorkspaceId&&dt({type:"workspace.selected",workspaceId:T.id})},[n,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const S=Te.current;if(S){if(!sn(S.agentId,n)){Te.current=null;return}w.loaded&&(Te.current=null,x.workspaces.some(T=>T.id===S.workspaceId)&&dt({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,w.loaded,x.workspaces]),v.useEffect(()=>{const S=we.current;if(S){if(!sn(S.agentId,n)){we.current=null;return}w.loaded&&(we.current=null,w.error||Vn())}},[n,w.error,w.loaded]),v.useEffect(()=>{yn()},[n,w.loaded,x]),v.useEffect(()=>{const S=()=>{const ee=CB();ee&&Ue.current(ee)},T=ee=>{const pe=xB(ee.data);pe&&Ue.current(pe)},j=ee=>{const pe=jh(ee.detail);pe&&Ue.current(pe)};return S(),window.addEventListener("hashchange",S),window.addEventListener($m,j),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",S),window.removeEventListener($m,j),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{Ti()},[Ti]),v.useEffect(()=>D1(()=>Qt(ro())),[]),v.useEffect(()=>{const S=T=>{Yi.current(T)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{zi.current=Gt.length>0?Gt:Kw},[Gt]),v.useEffect(()=>{gn.current=Kt},[Kt]),v.useEffect(()=>{if(!w.loaded||!ae||!Ne)return;const S=Ac(n,ae.id,Ne.id);_e(T=>{if(T.has(S))return T;const j=new Set(T);return j.add(S),j})},[n,w.loaded,ae?.id,Ne?.id]),v.useEffect(()=>()=>{Ds()},[]),v.useEffect(()=>{const S=M2(g),T=L2(g);return()=>{S(),T()}},[g]),v.useEffect(()=>m5(S=>{const T=Ot(S.agentId).state,j=T.workspaces.flatMap(Ce=>Ce.tabs).find(Ce=>Ce.id===S.tabId),ee=T.terminals[S.terminalId],pe=j?.title?.trim()||ee?.title||S.commandName||"terminal",ue=document.visibilityState==="visible"&&sn(S.agentId,hi.current)&&S.tabId===EB(T);if(ue||x2({agentId:S.agentId,tabTitle:pe,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!ue&&document.visibilityState==="visible"&&gn.current.enabled){const Ce=ji.current+1;ji.current=Ce;const qe=zi.current;Et({id:Ce,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:pe,commandName:S.commandName,outcome:S.outcome,assetSrc:qe[Math.floor(Math.random()*qe.length)]??rB})}}),[]),v.useEffect(()=>{if(!wt||Kt.persistUntilDismissed)return;const S=window.setTimeout(()=>{Et(T=>T?.id===wt.id?null:T)},Kt.durationSeconds*1e3);return()=>window.clearTimeout(S)},[wt,Kt]),v.useEffect(()=>{OB(U),U&&$n()},[U]),v.useEffect(()=>{let S=!1;async function T(){if(!Ot(n).loaded){ra(n,!1,null);try{let ee=null,pe=null;try{ee=DB(y)}catch(Ye){if(!(Ye instanceof Rh))throw Ye;pe=Ye}const[ue,Ce]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),qe=ue.terminals.length>0?ue.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!S){const Ye=Ce.layout?Ux(Ce.layout):null;if(!Ye&&pe)throw pe;const _i=Ye??ee??{},Vt=nv(qe,void 0,_i.savedWorkspaces,_i.savedActiveWorkspaceId),$r=Am(Vt);jw(n,Vt),yc(n,Ce.revision,JSON.stringify($r)),ra(n,!0,null),!Ye&&ee&&Rs($r,{baseRevision:Ce.revision})}}catch(ee){!S&&!Ii(ee)&&ra(n,!0,sa(ee))}}}return T(),()=>{S=!0}},[n,f,ie]);function Pi(){ra(n,!1,null),q(S=>S+1)}function $n(){Pe.current+=1,Be.current+=1,Re(null)}function ya(S){Pe.current+=1,Be.current+=1,Re(T=>T&&{...T,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Vn(){Pe.current+=1,Be.current+=1;const S=x.workspaces.length+1,T=It();Re({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&ln(T)}function bl(S){if(sn(S,n)){Vn();return}we.current={agentId:S},s?.(S)}function Ss(S){if(U&&!O)return;const T=x.workspaces.find(ee=>ee.id===S);if(!T)return;Pe.current+=1,Be.current+=1;const j=T.defaultCwd??it?.cwd??"";Re({mode:"edit",workspaceId:S,title:T.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&ln(j)}function It(){return ae?.defaultCwd??it?.cwd??""}async function ln(S){const T=Pe.current+1;Pe.current=T;const j=S.trim();if(Re(ee=>ee&&{...ee,cwd:S,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const ee=await f.createFileRoot({path:j}),pe=await f.listFiles({rootToken:ee.rootToken,path:""});if(Pe.current!==T)return;Re(ue=>ue&&{...ue,cwd:ee.rootPath,browseRoot:{rootToken:ee.rootToken,rootPath:ee.rootPath},browseEntries:pe.entries.filter(Ce=>Ce.kind==="directory"),browseStatus:"idle",error:null})}catch(ee){if(Pe.current!==T)return;Re(pe=>pe&&{...pe,browseStatus:"idle",error:sa(ee)})}}async function vi(){const S=Me;if(!S)return;const T=S.title.trim(),j=S.cwd.trim();if(!T||!j){Re({...S,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const ee=Be.current+1;Be.current=ee,Re({...S,submitStatus:"submitting",error:null});try{const pe=await f.createFileRoot({path:j});if(Be.current!==ee)return;if(S.mode==="create"){const ue=x.workspaces.length+1;dt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ue}`,title:T,defaultCwd:pe.rootPath})}else S.workspaceId&&(dt({type:"workspace.renamed",workspaceId:S.workspaceId,title:T}),dt({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:pe.rootPath}));Re(null)}catch(pe){if(Be.current!==ee)return;Re(ue=>ue&&{...ue,submitStatus:"idle",error:sa(pe)})}}function Yn(S){Be.current+=1,Re(S)}function wr(S,T,j){if(S===T)return;const ee=x.workspaces.some(ue=>ue.id===S),pe=x.workspaces.some(ue=>ue.id===T);!ee||!pe||dt({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:T,placement:j})}function vn(S,T){const j=x.workspaces.findIndex(pe=>pe.id===S),ee=x.workspaces[j+T];j<0||!ee||wr(S,ee.id,T<0?"before":"after")}function $t(S,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),Ke.current={sourceId:S,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function ho(S){const T=Ke.current;if(!T||T.pointerId!==S.pointerId)return;const j=Math.hypot(S.clientX-T.startX,S.clientY-T.startY);if(!T.active){if(j<sB)return;T.active=!0,he(T.sourceId)}const pe=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),ue=pe?.dataset.workspaceId??null;if(!pe||!ue||ue===T.sourceId||!x.workspaces.some(Ye=>Ye.id===ue)){T.targetId=null,Oe(null);return}const Ce=pe.getBoundingClientRect(),qe=S.clientY<Ce.top+Ce.height/2?"before":"after";T.targetId=ue,T.placement=qe,Oe({workspaceId:ue,placement:qe})}function ws(S){const T=Ke.current;!T||T.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Ke.current=null,he(null),Oe(null),T.active&&T.targetId&&wr(T.sourceId,T.targetId,T.placement))}function Nn(S){const T=Ke.current;T&&T.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Ke.current=null,he(null),Oe(null)}async function _n(){await hr(async()=>{const S=ae?.defaultCwd?{cols:80,rows:24,cwd:ae.defaultCwd}:{cols:80,rows:24},T=await f.createTerminal(S);dt({type:"terminal.created",terminal:T.terminal})})}async function Xi(S){await hr(async()=>{const T=Qe?{parentTerminalId:Qe,cols:80,rows:24}:ae?.defaultCwd?{cols:80,rows:24,cwd:ae.defaultCwd}:{cols:80,rows:24},j=await f.createTerminal(T);dt({type:"terminal.split",terminal:j.terminal,direction:S})})}async function Ur(S){let T=Qe,j=gt;const ee=ae?.defaultCwd?.trim();if(!T&&!ee)throw new Error("No active pane is available.");const pe=await f.readFile(S);if(!T&&ee){const qe=await f.createTerminal({cols:80,rows:24,cwd:ee});T=qe.terminal.id,dt({type:"terminal.created",terminal:qe.terminal})}if(T){dt({type:"pane.selected",terminalId:T});const qe=Ot(n).state,Ye=qe.workspaces.find(Vt=>Vt.id===qe.activeWorkspaceId)??qe.workspaces[0],_i=Ye?.tabs.find(Vt=>Vt.id===Ye.activeTabId)??Ye?.tabs[0];j=Ye&&_i?Ac(n,Ye.id,_i.id):null}const ue=`editor-${Date.now().toString(36)}-${S5(n)}`,Ce=LB(pe.path);Lm(n,qe=>({...qe,[ue]:{id:ue,title:Ce,rootToken:S.rootToken,path:pe.path,read:pe}})),j&&Ee(qe=>({...qe,[j]:Hx(ue)})),dt({type:"editor.split",editorId:ue,title:Ce,direction:"vertical"})}function fo(S){Lm(n,T=>{const j={...T};return delete j[S],j}),dt({type:"editor.closed",editorId:S})}function Sa(S){Cr([S])}function Cr(S){const T=[...new Set(S)].filter(ee=>x.terminals[ee]);if(T.length===0)return;const j=T.length===1?x.terminals[T[0]]?.title||x.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;K(null),ri({terminalIds:T,label:j,workspaceId:ae?.id??x.activeWorkspaceId??null})}function dr(S,T){const j=bn(S,T);if(!j)return!1;const ee=S.filter(pe=>!j.detachedTerminalIds.includes(pe));if(j.detachedTerminalIds.length+ee.length>fl)return K(MB(j.detachedTerminalIds.length)),!1;K(null);for(const pe of S)dt(j.id?{type:"terminal.detached",terminalId:pe,workspaceId:j.id}:{type:"terminal.detached",terminalId:pe});return!0}async function An(S){await hr(async()=>{for(const T of S)await Cs(T),Dc(f.createWebSocketUrl(T)),Ud(T),dt({type:"terminal.closed",terminalId:T})})}async function fi(S){const T=x.workspaces.find(j=>j.id===S);!T||x.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await hr(async()=>{const j=Th(T),ee=[];let pe=null;for(const Ce of j)try{await Cs(Ce)}catch(qe){ee.push(sa(qe)),qe instanceof or&&qe.status===401&&!f.isAgent&&(pe=qe)}finally{Dc(f.createWebSocketUrl(Ce)),Ud(Ce)}const ue=T.tabs.flatMap(Ce=>mv(Ce.root));if(ue.length>0){const Ce=new Set(ue);Lm(n,qe=>{const Ye={...qe};for(const _i of Ce)delete Ye[_i];return Ye})}if(dt({type:"workspace.closed",workspaceId:S}),pe)throw pe;if(ee.length>0)throw new Error(`Workspace was removed, but ${ee.length} terminal session${ee.length===1?"":"s"} may still be running. ${ee[0]}`)})}async function wa(S){await hr(async()=>{await Cs(S),Dc(f.createWebSocketUrl(S)),Ud(S),dt({type:"terminal.closed",terminalId:S})})}async function po(S,T){const j=T.trim();if(!j)return;let ee=null;for(const pe of x.workspaces){const ue=pe.tabs.find(Ce=>Ce.id===S);if(ue){ee=ue.activeTerminalId;break}}if(dt({type:"tab.renamed",tabId:S,title:j}),!!ee)try{const pe=await f.renameTerminal(ee,j);fr({type:"terminal.updated",terminal:pe.terminal})}catch(pe){ra(n,!0,sa(pe))}}function Ln(S){const T=x.terminals[S];T&&dt({type:"terminal.created",terminal:T})}async function Cs(S){try{await f.closeTerminal(S)}catch(T){if(T instanceof or&&T.status===404)return;throw T}}async function xr(){await hr(async()=>{await d()})}async function hr(S){ra(n,!0,null);try{await S()}catch(T){if(Ii(T))return;ra(n,!0,sa(T))}}function Ii(S){return S instanceof or&&S.status===401&&!f.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function dt(S){Yo(n,S);const T=Ot(n),j=T.state;if(!T.loaded||j.workspaces.length===0)return;const ee=Am(j);JSON.stringify(ee)!==T.lastPersistedLayoutJson&&Ta(ee)}function fr(S){Yo(n,S)}function xs(S,T,j,ee){const pe=Ac(S,T,j);Ee(ue=>({...ue,[pe]:ee}))}function ai(S){gt&&Ee(T=>({...T,[gt]:S}))}function Ca(S,T){const j=Hc(S);T?xs(n,T.workspaceId,T.tabId,j):ai(j),dt({type:"pane.selected",terminalId:S})}function xa(S){ai(S.key),S.type==="terminal"&&dt({type:"pane.selected",terminalId:S.terminalId})}function pr(S){if(ve||Ut||S.isComposing||S.key==="Process"||hB(S.target))return;const T=lB(S);if(!T)return;if(S.preventDefault(),S.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){Es(T.type==="server.next"?1:-1);return}const j=Ot(n).state,ee=j.workspaces.find(Ce=>Ce.id===j.activeWorkspaceId)??j.workspaces[0],pe=ee?.tabs.find(Ce=>Ce.id===ee.activeTabId)??ee?.tabs[0];if(T.type==="split"){if(!pe)return;Xi(T.direction);return}if(!ee||!pe)return;if(T.type==="tab.previous"||T.type==="tab.next"){const Ce=dB(ee.tabs,pe.id,T.type==="tab.next"?1:-1);Ce&&dt({type:"tab.selected",tabId:Ce.id});return}if(T.type==="tab.index"){const Ce=ee.tabs[T.index-1];Ce&&dt({type:"tab.selected",tabId:Ce.id});return}const ue=cB(pe.root,pe.activeTerminalId,T);ue&&Ca(ue,{workspaceId:ee.id,tabId:pe.id})}function ks(S,T){if(!s||re.length===0)return;const j=re.findIndex(Ce=>sn(Ce,n)),pe=((j===-1?0:j)+S+re.length)%re.length,ue=re[pe]??null;sn(ue,n)||(T&&(se.current={agentId:ue,edge:T}),s(ue))}function Es(S){const T=Ot(n).state,j=T.workspaces;if(j.length===0){ks(S,S===1?"first":"last");return}const ee=j.findIndex(Ce=>Ce.id===T.activeWorkspaceId),ue=(ee===-1?0:ee)+S;if(ue>=0&&ue<j.length){dt({type:"workspace.selected",workspaceId:j[ue].id});return}ks(S,S===1?"first":"last")}function kr(S,T){if(sn(S,n)){dt({type:"workspace.selected",workspaceId:T});return}Te.current={agentId:S,workspaceId:T},s?.(S)}function bn(S,T){if(T)return x.workspaces.find(j=>j.id===T)??null;for(const j of S){const ee=x.workspaces.find(ue=>ue.tabs.some(Ce=>Gc(Ce).includes(j)));if(ee)return ee;const pe=x.workspaces.find(ue=>ue.detachedTerminalIds.includes(j));if(pe)return pe}return x.workspaces.find(j=>j.id===x.activeWorkspaceId)??x.workspaces[0]??null}function mo(S){Hw(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function yl(S){if(!Hw(S.dataTransfer))return;S.preventDefault();const T=NB(Ot(n).state),j=je.current+1;if(je.current=j,!T){Fr({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Fr({id:j,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Kr(j,T.id,S.dataTransfer)}async function Kr(S,T,j){try{const ee=await Y5(j);if(ee.length===0)throw new Error("No files were found in the drop.");Hi(S,{id:S,status:"queued",fileCount:ee.length,message:"Queued"},{terminalId:T,files:ee})}catch(ee){Hi(S,{id:S,status:"failed",fileCount:0,message:sa(ee)},{terminalId:T})}finally{Er()}}async function cn(S){const T=st.current.find(ue=>ue.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=T.terminalId,ee=T.files,pe=new AbortController;et.current=S,Hi(S,{id:S,status:"uploading",fileCount:ee.length,loaded:0,total:null,percent:null},{terminalId:j,files:ee,abortController:pe});try{const ue=await jD({terminalId:j,files:ee,signal:pe.signal,onProgress:_i=>{Hi(S,{id:S,status:"uploading",fileCount:ee.length,loaded:_i.loaded,total:_i.total,percent:_i.percent},{terminalId:j,files:ee,abortController:pe})}}),Ce=ue.failed>0?ue.uploaded>0?"partial":"failed":"success",qe=ue.failed>0?AB(ue):void 0,Ye={id:S,status:Ce,fileCount:ee.length,response:ue};qe&&(Ye.message=qe),Hi(S,Ye,{terminalId:j,files:ee})}catch(ue){Hi(S,{id:S,status:"failed",fileCount:ee.length,message:pe.signal.aborted?"Upload canceled.":sa(ue)},{terminalId:j,files:ee})}finally{et.current===S&&(et.current=null),Er()}}function Er(){if(et.current!==null)return;const S=st.current.find(T=>T.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&cn(S.id)}function Fr(S){tn(T=>[...T,S])}function Hi(S,T,j={}){tn(ee=>ee.map(pe=>{if(pe.id!==S)return pe;const ue={...T},Ce=j.terminalId??pe.terminalId,qe=j.files??pe.files;return Ce!==void 0&&(ue.terminalId=Ce),qe!==void 0&&(ue.files=qe),j.abortController!==void 0&&(ue.abortController=j.abortController),ue}))}function tn(S){const T=S(st.current);st.current=T,We(T)}function ka(S){st.current.find(j=>j.id===S)?.abortController?.abort(),et.current===S&&(et.current=null),tn(j=>j.filter(ee=>ee.id!==S)),Er()}function Ts(){for(const S of st.current)S.abortController?.abort();et.current=null,tn(()=>[])}function Wr(S){const T=st.current.find(j=>j.id===S);if(T){if(T.status==="queued"){ka(S);return}T.abortController?.abort()}}function qr(S){const T=st.current.find(ee=>ee.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=Bn(T);if(j.length===0){Hi(S,{id:S,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Hi(S,{id:S,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:T.terminalId,files:j}),Er()}function Bn(S){const T=S.files??[],j="response"in S?S.response:void 0;if(!j)return T;const ee=j.results.filter(Ce=>Ce.status==="failed").map(Ce=>Ce.relativePath);if(ee.length===0)return[];const pe=new Map;for(const Ce of T){const qe=pe.get(Ce.relativePath)??[];qe.push(Ce),pe.set(Ce.relativePath,qe)}const ue=[];for(const Ce of ee){const Ye=pe.get(Ce)?.shift();Ye&&ue.push(Ye)}return ue}function Ea(S){const j=Ot(S.agentId).state.workspaces.find(ee=>ee.tabs.some(pe=>pe.id===S.tabId));j&&xs(S.agentId,j.id,S.tabId,Hc(S.terminalId)),Yo(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ow(S.agentId,S.terminalId),sn(S.agentId,n)||s?.(S.agentId),Et(null)}function Tr(S){if(ze.current=S,!sn(S.agentId,n)){s?s(S.agentId):ze.current=null;return}yn()}function yn(){const S=ze.current;if(!S||!sn(S.agentId,n)||!w.loaded)return;const T=Ot(S.agentId),j=kB(T.state,S.terminalId);ze.current=null,j&&(xs(S.agentId,j.workspaceId,j.tabId,Hc(S.terminalId)),Yo(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ow(S.agentId,S.terminalId))}function Ta(S){const T=Ot(n).mutable.saveCoord;T.pendingLayoutSave=S,Sc(S,y),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const j=T.pendingLayoutSave;T.pendingLayoutSave=null,j&&Rs(j)},nB)}function Ds(){const S=Ot(n).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const T=S.pendingLayoutSave;S.pendingLayoutSave=null,T&&(Sc(T,y),Rs(T))}function Rs(S,T={}){const j=Ot(n).mutable.saveCoord;j.nextPersistLayout=S,T.baseRevision!==void 0&&(j.queuedBaseRevision=T.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const ee=j.nextPersistLayout,pe=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,ee&&await Dr(ee,pe!==void 0?{baseRevision:pe}:{})}))}async function Dr(S,T={}){const j=Ot(n),ee=T.baseRevision??j.layoutRevision,pe={layout:S,...typeof ee=="number"?{baseRevision:ee}:{}};try{const ue=await f.saveTerminalLayout(pe),Ce=ue.layout??S;yc(n,ue.revision,JSON.stringify(Ce)),Sc(Ce,y);return}catch(ue){if(ue instanceof or&&ue.status===400&&ue.message===$T){RB(n,y),ra(n,!0,Kx());return}if(ue instanceof or&&ue.status===409)try{const Ce=await f.getTerminalLayout(),qe=Ot(n).mutable.saveCoord;if(qe.nextPersistLayout||qe.pendingLayoutSave){const Ye=Ce.layout?JSON.stringify(Ce.layout):Ot(n).lastPersistedLayoutJson;yc(n,Ce.revision,Ye);return}if(Ce.layout){const Ye=Ot(n).state,_i=nv(Object.values(Ye.terminals),void 0,Ce.layout.workspaces,Ce.layout.activeWorkspaceId),Vt=Am(_i);jw(n,_i),yc(n,Ce.revision,JSON.stringify(Vt)),Sc(Vt,y)}else yc(n,Ce.revision,j.lastPersistedLayoutJson);return}catch{}Sc(S,y)}}const Ms=jB(o),On=!U||O,Jt=On?F:"servers";function nn(S){const T=S.active?w:Ot(S.agentId),j=S.active?x:T.state,ee=S.active?w.loaded:T.loaded,pe=S.active?L:T.error;return p.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[p.jsxs("div",{className:"workspace-list-header",children:[p.jsx("span",{children:"Workspaces"}),p.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>bl(S.agentId),children:"+"})]}),ee?pe?p.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(S.agentId),children:pe}):p.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(ue=>{const Ce=S.active&&ue.id===ae?.id,qe=Th(ue).length,Ye=S.active&&j.workspaces.length>1,_i=ye?.workspaceId===ue.id&&oe!==ue.id?ye.placement:null;return p.jsxs(vB,{workspaceId:ue.id,active:Ce,disabled:!S.active,reorderable:Ye,dragging:oe===ue.id,dropPlacement:_i,children:[Ye?p.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ue.id,title:"Drag to reorder","aria-label":`Reorder ${ue.title}`,"aria-grabbed":oe===ue.id,onPointerDown:Vt=>$t(ue.id,Vt),onPointerMove:ho,onPointerUp:ws,onPointerCancel:Nn,onKeyDown:Vt=>{(Vt.key==="ArrowUp"||Vt.key==="ArrowDown")&&(Vt.preventDefault(),Vt.stopPropagation(),vn(ue.id,Vt.key==="ArrowUp"?-1:1))},onClick:Vt=>Vt.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Ce?"page":void 0,title:ue.defaultCwd??void 0,onClick:()=>kr(S.agentId,ue.id),onDoubleClick:()=>{S.active&&Ss(ue.id)},children:[p.jsx("span",{className:"workspace-list-name",children:ue.title}),p.jsxs("small",{children:[ue.defaultCwd??"No folder"," · ",qe," ",qe===1?"session":"sessions"]})]}),S.active?p.jsxs("div",{className:"workspace-list-actions",children:[p.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ue.title}`,title:"Edit workspace",onClick:()=>Ss(ue.id),children:"..."}),p.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ue.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{fi(ue.id)},children:"x"})]}):null]},ue.id)})}):p.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(S.agentId),children:"Open server to load workspaces"})]})}return p.jsx(IT,{sensors:Dt,onDragStart:Ei,onDragEnd:ni,onDragCancel:di,children:p.jsxs("main",{className:"terminal-shell","data-collapsed":U,"data-sidebar-open":O,onDragOver:mo,onDrop:yl,children:[p.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>X(!1)}),p.jsxs("aside",{className:"workspace-sidebar",children:[p.jsxs("header",{className:"workspace-brand",children:[p.jsxs("div",{className:"workspace-brand-lockup",children:[On?p.jsx(Qw,{height:20}):p.jsx(Zw,{size:24}),c&&On?p.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),p.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":U?"Expand sidebar":"Collapse sidebar",title:U?"Expand sidebar":"Collapse sidebar",onClick:()=>G(S=>!S),children:U?">":"<"}),p.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>X(!1),children:"x"})]}),p.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Jt==="files"?"files":"servers"}`,children:[On?p.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[p.jsx("button",{type:"button",role:"tab","aria-selected":F==="servers",onClick:()=>{W("servers")},children:"Workspaces"}),p.jsx("button",{type:"button",role:"tab","aria-selected":F==="files",onClick:()=>{W("files")},children:"Files"})]}):null,Jt==="servers"&&On?p.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:p.jsx(i0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ne,onServerLabelsChange:on,renderServerChildren:nn})}):null,On?null:p.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:p.jsx(i0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ne,onServerLabelsChange:on,compact:!0})}),Jt==="files"?p.jsx(UD,{api:f,activeTerminalId:Qe,activeTerminalCwd:it?.cwd??null,workspaceRootPath:Qe?null:ae?.defaultCwd??null,onOpenFile:Ur},`${n??"local"}:${ae?.id??"no-workspace"}`):null]}),p.jsxs("div",{className:"workspace-sidebar-footer",children:[On?p.jsx("span",{children:Ms}):null,p.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[p.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>Se(!0),children:[p.jsx(Ww,{name:"settings"}),xe.hasUpdates?p.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),On?p.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{xr()},children:p.jsx(Ww,{name:"logout"})}):null]})]})]}),ve?p.jsx(LD,{api:g,onClose:()=>Se(!1),updateAvailable:xe.hasUpdates,onNotificationAssetsChanged:()=>{Ti()},onAgentRemoved:si}):null,Me?p.jsx(fB,{dialog:Me,activePaneCwd:it?.cwd??null,activeWorkspaceCwd:ae?.defaultCwd??null,onChange:Yn,onManualCwdChange:ya,onBrowse:ln,onCancel:$n,onSubmit:()=>{vi()}}):null,p.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":kt?"true":void 0,children:[p.jsx(E5,{tabs:ae?.tabs??[],activeTabId:ae?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Mn,detachedTerminals:Rn,onSelectTab:S=>dt({type:"tab.selected",tabId:S}),onCreateTab:()=>{_n()},onToggleWorkspaces:()=>X(S=>!S),onCloseTerminals:S=>Cr(S),onReattachTerminal:S=>Ln(S),onDeleteTerminal:S=>{wa(S)},onSplitVertical:()=>{Xi("vertical")},onSplitHorizontal:()=>{Xi("horizontal")},onRenameTab:(S,T)=>{po(S,T)},activePaneAvailable:!!Qe}),kt?p.jsx(bB,{targets:xt,activeLeafKey:Ht,terminals:x.terminals,editors:D,onSelect:xa}):null,L?p.jsxs("div",{className:"workspace-error",role:"alert",children:[p.jsx("span",{children:L}),p.jsxs("div",{className:"workspace-error-actions",children:[p.jsx("button",{type:"button",onClick:Pi,children:"Retry"}),n!==null&&s?p.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,p.jsxs("section",{className:"workspace-body","aria-busy":B,children:[B?p.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!B&&!Ne?p.jsx(gB,{onCreate:()=>{_n()}}):null,M.map(S=>{const T=sn(S,n);return p.jsx(oB,{agentId:S,serverName:R[gv(S)]??(S===null?"Local":"Server"),active:T,activeServerApi:T?f:void 0,visitedTabKeys:le,refreshCwdOnEnter:T,draggingTab:T?nt:null,mobileSplitFocus:jt,mobileFocusedLeafByTabKey:be,onSelect:j=>{T&&Ca(j)},onClose:j=>{T&&Sa(j)},onCloseEditor:j=>{T&&fo(j)},onResize:(j,ee)=>{T&&dt({type:"pane.resized",path:j,ratio:ee})},onExit:(j,ee)=>{T?fr({type:"terminal.exited",terminalId:j,exitCode:ee}):Yo(S,{type:"terminal.exited",terminalId:j,exitCode:ee})},onSnapshot:(j,ee)=>{const pe={type:"terminal.updated",terminal:j,notifyCompletion:ee?.notifyCompletion===!0};T?fr(pe):Yo(S,pe)},...S===null&&m?{onAuthClose:j=>m({...j,source:j?.source??"terminal-ws-1008",activeAgentId:S})}:{}},oh(S))})]}),Ut?p.jsx(_B,{label:Ut.label,count:Ut.terminalIds.length,warning:J,onCancel:()=>{K(null),ri(null)},onHide:()=>{dr(Ut.terminalIds,Ut.workspaceId)&&ri(null)},onDelete:()=>{const S=Ut.terminalIds;K(null),ri(null),An(S)}}):null,p.jsx(P5,{toast:wt,onActivate:Ea,onDismiss:()=>Et(null)}),p.jsx(N5,{uploads:Z,onDismiss:ka,onDismissAll:Ts,onRetry:qr,onCancel:Wr})]})]})})}function oB({agentId:e,serverName:t,active:n,activeServerApi:s,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:d,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:f,onClose:y,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,onAuthClose:D}){const B=v.useMemo(()=>xe=>Mx(e,xe),[e]),L=v.useMemo(()=>()=>Ot(e),[e]),O=v.useSyncExternalStore(B,L,L),X=v.useMemo(()=>rl(e),[e]),U=s??X,G=O.state,F=G.workspaces.find(xe=>xe.id===G.activeWorkspaceId)??G.workspaces[0],W=F?.id??null,Se=(F?.tabs.find(xe=>xe.id===F.activeTabId)??F?.tabs[0])?.id??null;return!O.loaded||G.workspaces.length===0?null:p.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:G.workspaces.flatMap(xe=>xe.tabs.map(ie=>{const q=n&&xe.id===W&&ie.id===Se,J=Ac(e,xe.id,ie.id),K=Dh(ie.root),re=m&&K.length>1?Ix(K,ie.activeTerminalId,g[J]):null;return!q&&!o.has(J)?null:p.jsx("div",{className:"workspace-tab-surface","data-active":q,"aria-hidden":!q,children:p.jsx(ev,{node:ie.root,terminals:G.terminals,editors:O.editors,api:U,activeTerminalId:ie.activeTerminalId,visible:q,refreshCwdOnEnter:q&&c,tabId:ie.id,codeServerContext:{serverKey:gv(e),serverName:t,tabName:ie.title||G.terminals[ie.activeTerminalId]?.title||"Terminal"},dropZoneActive:q&&d!==null,draggingTerminalId:q?d?.terminalId??null:null,mobileFocusLeafKey:re,onSelect:f,onClose:y,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,...D?{onAuthClose:D}:{}})},`${xe.id}:${ie.id}`)}))})}function lB(e){const t=$1(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=uB(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function cB(e,t,n){switch(n.type){case"pane.direction":return U5(e,t,n.direction);case"pane.index":return K5(e,n.index);default:return null}}function uB(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function dB(e,t,n){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+n+e.length)%e.length]??null}function Dh(e){return e.type==="pane"?[{key:Hc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Hx(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Dh(e.first),...Dh(e.second)]}function mv(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...mv(e.first),...mv(e.second)]}function Ix(e,t,n){if(n&&e.some(o=>o.key===n))return n;const s=t?Hc(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function Hc(e){return`terminal:${e}`}function Hx(e){return`editor:${e}`}function hB(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function fB({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:o,onBrowse:c,onCancel:d,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),y=e.submitStatus==="submitting";function b(w){s(x=>x&&{...x,...w})}function C(w){w&&(b({cwd:w,error:null}),c(w))}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:p.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),y||m()},children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),p.jsxs("section",{className:"workspace-dialog-body",children:[p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Name"}),p.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:w=>b({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Default cwd"}),p.jsxs("div",{className:"workspace-dialog-path-row",children:[p.jsx("input",{value:e.cwd,disabled:y,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),p.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),p.jsxs("div",{className:"workspace-dialog-quick-actions",children:[p.jsx("button",{type:"button",onClick:()=>C(t),disabled:y||!t,children:"Use active pane"}),p.jsx("button",{type:"button",onClick:()=>C(n),disabled:y||!n,children:"Use current workspace"})]}),p.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[p.jsxs("div",{className:"workspace-dialog-browser-header",children:[p.jsx("span",{title:g,children:g||"No folder selected"}),p.jsx("button",{type:"button",onClick:()=>{c(mB(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?p.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?p.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?p.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>p.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:y,onClick:()=>{c(pB(g,w.path))},children:[p.jsx("span",{children:w.name}),p.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?p.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),p.jsxs("div",{className:"workspace-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),p.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function pB(e,t){return t?t.startsWith("/")?ah(t):ah(`${e||"/"}/${t}`):ah(e)}function mB(e){const t=ah(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function ah(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function gB({onCreate:e}){return p.jsxs("div",{className:"empty-workspace",children:[p.jsx("span",{children:"No terminal is open."}),p.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function vB({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:c=null,children:d}){const{setNodeRef:m,isOver:g}=Mv({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return p.jsx("div",{ref:m,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:d})}function _B({label:e,count:t,warning:n,onCancel:s,onHide:o,onDelete:c}){return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),p.jsx("span",{children:e}),p.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?p.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function bB({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:o}){const[c,d]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(C=>C.key===t):-1,g=m>=0?m:0,f=e[g]??e[0],y=Fw(f,n,s);function b(C){const w=(g+C+e.length)%e.length,x=e[w];x&&o(x)}return p.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[p.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),p.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>d(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),p.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?p.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:p.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:C=>C.stopPropagation(),children:[p.jsxs("header",{children:[p.jsx("strong",{children:"Panes"}),p.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),p.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((C,w)=>{const x=Fw(C,n,s),D=yB(C,n,s),B=C.key===f.key;return p.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(C),d(!1)},children:[p.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),p.jsxs("span",{className:"mobile-pane-sheet-copy",children:[p.jsx("strong",{children:x}),p.jsx("small",{children:D})]}),p.jsx("span",{className:"mobile-pane-sheet-type",children:C.type})]},C.key)})})]})}):null]})}function Fw(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function yB(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function SB(e){const[t,n]=v.useState(()=>wB(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const s=window.matchMedia(e),o=()=>n(s.matches);return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):(s.addListener(o),()=>s.removeListener(o))},[e]),t}function wB(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function CB(){if(typeof window>"u")return null;const e=n2(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function xB(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:jh(t.focus)}function kB(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Bi(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function sn(e,t){return e===t}function EB(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function oh(e){return e??"__local__"}function Ac(e,t,n){return`${oh(e)}:${t}:${n}`}class Rh extends Error{constructor(){super(Kx())}}function TB(e){return e?{workspaceKey:`${Uw}:${e}`}:{workspaceKey:Uw}}function DB(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(y1(n))throw new Rh;const s=b1(n);return s?Ux(s):null}catch(n){if(n instanceof Rh)throw n;return null}}function Ux(e){if(y1(e))throw new Rh;const t=b1(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Sc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function RB(e,t){const n=Ot(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function MB(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${fl}. Re-open or delete hidden sessions before hiding more.`}function Kx(){return`A saved terminal layout has more than ${fl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function NB(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],s=n?e.terminals[n.activeTerminalId]:void 0;return s?.status==="running"?s:null}function AB(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function LB(e){return e.split("/").filter(Boolean).pop()??e}function BB(){try{return localStorage.getItem(Px)==="true"}catch{return!1}}function OB(e){try{localStorage.setItem(Px,e?"true":"false")}catch{}}function gv(e){return e??lr}function Om(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(o=>e[o]===t[o])}function jB(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const s=Math.max(1,Math.floor(n/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function Ww({name:e}){return p.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M4 7h9"}),p.jsx("path",{d:"M17 7h3"}),p.jsx("circle",{cx:"15",cy:"7",r:"2"}),p.jsx("path",{d:"M4 12h3"}),p.jsx("path",{d:"M11 12h9"}),p.jsx("circle",{cx:"9",cy:"12",r:"2"}),p.jsx("path",{d:"M4 17h9"}),p.jsx("path",{d:"M17 17h3"}),p.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M10 6H6v12h4"}),p.jsx("path",{d:"M13 8l4 4-4 4"}),p.jsx("path",{d:"M8 12h9"})]}):null]})}function sa(e){return e instanceof Error?e.message:"Request failed"}function zB({api:e,onDone:t}){const[n,s]=v.useState(null),[o,c]=v.useState(null),[d,m]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(null),[C,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(B=>{D||(s(B.qrDataUrl),c(B.secret))}).catch(B=>{D||w(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function x(D){if(D.preventDefault(),!!o){f(!0),b(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(B){b(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return C?p.jsx("p",{className:"form-error",children:C}):!n||!o?p.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):p.jsxs("div",{className:"totp-setup",children:[p.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),p.jsx("div",{className:"totp-qr-container",children:p.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),p.jsxs("details",{className:"totp-secret-details",children:[p.jsx("summary",{children:"Can't scan? Enter manually"}),p.jsx("p",{className:"totp-secret-text",children:o})]}),p.jsxs("form",{className:"auth-form",onSubmit:x,children:[p.jsxs("label",{children:["Verification code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?p.jsx("p",{className:"form-error",children:y}):null,p.jsx("button",{type:"submit",disabled:g||d.length!==6,children:"Activate 2FA"})]})]})}function PB(e){return{source:jm(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:jm(e.terminalId)}:{},...e?.detail?{detail:jm(e.detail)}:{}}}function IB(e){return{invalidationSource:e.source}}function HB(e){fn("auth.session_invalid.request",Fx(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Nv("session-invalid-request").catch(()=>{}))}function UB(e,t){fn("auth.session_invalid.result",{...Fx(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Nv("session-invalid-result").catch(()=>{}))}function Fx(e){return{source:e.source,...typeof e.status=="number"?{status:e.status}:{},...e.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e.terminalId?{terminalId:e.terminalId}:{},...e.detail?{detail:e.detail}:{}}}function jm(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function KB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const o=v.useMemo(()=>e??Mh(),[e]),c=v.useMemo(()=>t??rl(null),[t]),[d,m]=v.useState(null),[g,f]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let L=!1;return o.getSession().then(O=>{L||(m(O),f(null))}).catch(O=>{L||(f(no(O)),m(null))}),()=>{L=!0}},[o]);const C=$B(d);v.useEffect(()=>{const L=b.current;fn("auth.view",{view:C,previousView:L,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),L==="workspace"&&C!=="workspace"&&Nv(`auth-left-workspace-${C}`).catch(()=>{}),b.current=C},[d,C]);async function w(){const L=await o.getSession();m(L),f(null)}async function x(){km(),Bm(),lw(),f(null),m(null);try{await w()}catch(L){f(no(L))}}function D(L){const O=PB(L);if(HB(O),y.current)return y.current;const X=(async()=>{f(null);try{const U=await o.getSession(IB(O));if(UB(O,U.authenticated),m(U),U.authenticated){fL();return}km(),Bm(),lw()}catch(U){f(no(U))}finally{y.current=null}})();return y.current=X,X}if(C==="workspace")return p.jsx(aB,{api:o,serverApi:c,activeAgentId:n,onSelectServer:s,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:L=>{D(L)},onLogout:async()=>{km(),Bm();const L=await o.logout();m(L)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return p.jsxs("main",{className:"auth-screen",children:[p.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[p.jsx("div",{className:"auth-grid"}),p.jsx("div",{className:"auth-glow"})]}),p.jsxs("section",{className:"auth-panel","aria-busy":C==="loading",children:[p.jsxs("header",{className:"auth-header",children:[p.jsxs("div",{className:"auth-brand",children:[p.jsx(Zw,{size:26}),p.jsxs("div",{children:[p.jsx(Qw,{height:17}),p.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),p.jsx("h1",{children:B[C]})]}),g?p.jsx("p",{className:"form-error",children:g}):null,C==="loading"?p.jsx("p",{className:"muted",children:"Checking session..."}):null,C==="loading"&&g?p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,C==="setup_password"?p.jsx(FB,{api:o,onSession:L=>{m(L)}}):null,C==="setup_totp"?p.jsx(zB,{api:o,onDone:()=>{w()}}):null,C==="login"?p.jsx(WB,{api:o,session:d,onSession:m,onRefresh:w}):null,C==="reauth"?p.jsx(qB,{api:o,session:d,onSession:m,onFullLogin:()=>m(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function FB({api:e,onSession:t}){const[n,s]=v.useState(""),[o,c]=v.useState(""),[d,m]=v.useState(!1),[g,f]=v.useState(null);async function y(b){b.preventDefault(),m(!0),f(null);try{if(n!==o){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(C){f(no(C))}finally{m(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:y,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,value:n,onChange:b=>s(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),p.jsxs("label",{children:["Confirm password",p.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?p.jsx("p",{className:"form-error",children:g}):null,p.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function WB({api:e,session:t,onSession:n,onRefresh:s}){const[o,c]=v.useState(""),[d,m]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(!1),[C,w]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function B(L){L.preventDefault(),b(!0),w(null);try{n(await e.login({password:o,...x?{otp:d}:{},rememberNetwork:g}))}catch(O){w(no(O))}finally{b(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:B,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:L=>c(L.currentTarget.value),required:!0})]}),x?p.jsxs("label",{children:["Authenticator code",p.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:L=>m(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:g,onChange:L=>f(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),C?p.jsx("p",{className:"form-error",children:C}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:y||o.length===0||x&&d.length!==6,children:"Unlock"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:y,children:"Refresh"})]})]})}function qB({api:e,session:t,onSession:n,onFullLogin:s}){const o=t?.currentIpWhitelisted??!1,[c,d]=v.useState(""),[m,g]=v.useState(!1),[f,y]=v.useState(!1),[b,C]=v.useState(!1),[w,x]=v.useState(!1),[D,B]=v.useState(null),L=Li.useCallback(async(X,U)=>{y(!0),B(null);try{n(await e.reauth({...X?{otp:X}:{},rememberNetwork:U}))}catch(G){B(no(G))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let X=!1;C(!0),x(!1),B(null);const U=window.setTimeout(()=>{X||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(G=>{X||n(G)}).catch(G=>{X||(B(no(G)),x(!0))}).finally(()=>{window.clearTimeout(U),X||C(!1)}),()=>{X=!0,window.clearTimeout(U)}}},[e,o,n]);async function O(X){X.preventDefault(),await L(c,m)}return o&&b&&!w&&!D?p.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):p.jsxs("form",{className:"auth-form",onSubmit:O,children:[o&&w&&!D?p.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,p.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),p.jsxs("label",{children:["Authenticator code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:X=>d(X.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:m,onChange:X=>g(X.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?p.jsx("p",{className:"form-error",children:D}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function $B(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function no(e){return e instanceof Error?e.message:"Request failed"}const qw="NTerminal",vv="nterminal.activeAgentId";function VB(){const[e,t]=v.useState(()=>YB()),n=v.useMemo(()=>Mh(),[]),s=v.useMemo(()=>rl(e),[e]);v.useEffect(()=>{const c=()=>{const d=y5();document.title=d>0?`(${d}) ${qw}`:qw};return c(),b5(c)},[]);function o(c){XB(c),t(c)}return p.jsx(KB,{api:n,activeAgentId:e,serverApi:s,onSelectServer:o})}function YB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(vv);return e&&e.trim()?e:null}catch{return null}}function XB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(vv,e);return}window.localStorage.removeItem(vv)}catch{}}const $w=["gesturestart","gesturechange","gestureend"],GB=[".workspace-list",".workspace-nav",".server-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview",".settings-content",".settings-nav",".transcript-dialog-scroll",".transcript-filter-group"].join(",");function ZB(e=window){if(!JB(e))return()=>{};const t={passive:!1},n=e.document;function s(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!QB(c.target))&&s(c)}for(const c of $w)n.addEventListener(c,s,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",s,t),()=>{for(const c of $w)n.removeEventListener(c,s,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",s,t)}}function QB(e){return e instanceof Element&&e.closest(GB)!==null}function JB(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}a2();vA();ZB();wv();bE.createRoot(document.getElementById("root")).render(p.jsx(Li.StrictMode,{children:p.jsx(VB,{})}));export{Li as R,uE as g,p as j};
|
|
57
|
+
(detached — click to re-open, × to delete)`;return p.jsxs("span",{className:"terminal-detached-pill",title:l,children:[p.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),p.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function N5({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:l=>l.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:"Delete this terminal?"}),p.jsx("span",{children:s}),p.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function A5({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:l}){if(e.length===0)return null;const d=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return p.jsxs("aside",{className:`upload-toast upload-toast-${z5(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[p.jsxs("header",{className:"upload-toast-header",children:[p.jsx("strong",{children:e.length===1?sh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),p.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),p.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>p.jsx(L5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>l(g.id)},g.id))})]})}function L5({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:l}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return p.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":sh(e),children:[p.jsxs("div",{className:"upload-queue-item-header",children:[p.jsx("strong",{children:sh(e)}),p.jsxs("div",{className:"upload-queue-actions",children:[m?p.jsx("button",{type:"button",onClick:l,children:"Cancel"}):null,d?p.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,p.jsx("button",{type:"button","aria-label":`Dismiss ${sh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?p.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?p.jsx(B5,{toast:e}):null,c&&"message"in e&&e.message?p.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?p.jsx(O5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?p.jsx("p",{children:e.message}):null]})}function B5({toast:e}){const t=e.percent===null?P5(e.loaded):`${e.percent}%`;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"upload-progress-row",children:[p.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),p.jsx("span",{children:t})]}),p.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:p.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function O5({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),s=e.results.filter(d=>d.status==="uploaded"),l=t?3:6,c=[...n,...s].slice(0,l);return p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?p.jsx("ul",{className:"upload-result-list",children:c.map((d,m)=>p.jsx(j5,{result:d},`${d.relativePath}-${m}`))}):null,e.results.length>c.length?p.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function j5({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return p.jsxs("li",{"data-status":e.status,children:[p.jsx("span",{className:"upload-result-path",children:t}),n?p.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?p.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function sh(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function z5(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function P5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function I5({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const s=e,l=s.outcome==="stopped"?"stopped":"finished",c=s.commandName?`${s.commandName} ${l}`:`Command ${l}`;function d(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(s)))}return p.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:m,children:[p.jsxs("header",{className:"completion-toast-header",children:[p.jsxs("div",{className:"completion-toast-copy",children:[p.jsx("strong",{children:s.tabTitle}),p.jsx("span",{children:c})]}),p.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),p.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const H5=Nc(0,0,1,1),fs=1e-6;function U5(e){return Ax(e).map(t=>t.terminalId)}function Ax(e){return Mc(e,H5).sort(q5).map((t,n)=>({...t,index:n+1}))}function K5(e,t,n){const s=Ax(e),l=s.find(d=>d.terminalId===t);return l?s.filter(d=>d.terminalId!==t).map(d=>W5(l,d,n)).filter(d=>d!==null).sort($5)[0]?.entry.terminalId??null:null}function F5(e,t){return!Number.isInteger(t)||t<1?null:U5(e)[t-1]??null}function Mc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=V5(e.ratio);if(e.direction==="vertical"){const l=t.left+(t.right-t.left)*n;return[...Mc(e.first,Nc(t.left,t.top,l,t.bottom)),...Mc(e.second,Nc(l,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...Mc(e.first,Nc(t.left,t.top,t.right,s)),...Mc(e.second,Nc(t.left,s,t.right,t.bottom))]}function W5(e,t,n){const s=e.bounds,l=t.bounds,c=Iw(s.left,s.right,l.left,l.right),d=Iw(s.top,s.bottom,l.top,l.bottom);switch(n){case"left":return l.centerX>=s.centerX-fs||d<=fs?null:{entry:t,primaryDistance:Math.max(0,s.left-l.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:d};case"right":return l.centerX<=s.centerX+fs||d<=fs?null:{entry:t,primaryDistance:Math.max(0,l.left-s.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:d};case"up":return l.centerY>=s.centerY-fs||c<=fs?null:{entry:t,primaryDistance:Math.max(0,s.top-l.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};case"down":return l.centerY<=s.centerY+fs||c<=fs?null:{entry:t,primaryDistance:Math.max(0,l.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};default:return null}}function q5(e,t){return eo(e.bounds.top,t.bounds.top)||eo(e.bounds.left,t.bounds.left)}function $5(e,t){return eo(e.primaryDistance,t.primaryDistance)||eo(e.perpendicularDistance,t.perpendicularDistance)||eo(t.overlap,e.overlap)||eo(e.entry.index,t.entry.index)}function eo(e,t){const n=e-t;return Math.abs(n)<=fs?0:n}function Iw(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Nc(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function V5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class Y5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Hw(e){return e?Array.from(e.types??[]).includes("Files")||jx(e.items).some(n=>n.kind==="file")?!0:zx(e.files).length>0:!1}async function X5(e){const t=jx(e.items).filter(n=>n.kind==="file");return t.length>0?G5(t):Z5(e.files)}async function G5(e){const t=[];for(const n of e){const s=tB(n);if(s){await Lx(s,"",t);continue}const l=n.getAsFile();if(l){t.push({relativePath:Bx(l),file:l});continue}throw new Y5("Folder upload is not supported by this browser.")}return t}function Z5(e){return zx(e).map(t=>({relativePath:Bx(t),file:t}))}async function Lx(e,t,n){const s=nB(t,e.name);if(e.isFile){const d=await Q5(e);n.push({relativePath:s,file:d});return}if(!e.isDirectory)return;const l=e.createReader(),c=await J5(l);for(const d of c)await Lx(d,s,n)}function Q5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function J5(e){const t=[];for(;;){const n=await eB(e);if(n.length===0)return t;t.push(...n)}}function eB(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function Bx(e){const t=e.webkitRelativePath;return Ox(typeof t=="string"&&t?t:e.name)}function tB(e){const t=e.webkitGetAsEntry?.();return iB(t)?t:null}function iB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function nB(e,t){return Ox(e?`${e}/${t}`:t)}function Ox(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function jx(e){return e?Array.from(e):[]}function zx(e){return e?Array.from(e):[]}const Uw="nterminal.terminalWorkspaces.v2",Px="nterminal.sidebarCollapsed.v1",rB=75,Kw=S1.map(e=>e.url),sB=S1[0].url,aB=6;function lB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:l=null,previewMode:c=!1,onLogout:d=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??Mh(),[e]),f=v.useMemo(()=>t??no(null),[t]),y=v.useMemo(()=>DB(n),[n]),b=v.useMemo(()=>S=>Mx(n,S),[n]),C=v.useMemo(()=>()=>Ot(n),[n]),w=v.useSyncExternalStore(b,C,C),x=w.state,D=w.editors,B=!w.loaded,L=w.error,[O,X]=v.useState(!1),[U,G]=v.useState(()=>OB()),[W,q]=v.useState("servers"),[ge,Se]=v.useState(!1),xe=v.useSyncExternalStore(CD,r0,r0);v.useSyncExternalStore(ph,n0,n0);const[re,$]=v.useState(0),[J,K]=v.useState(null),[se,A]=v.useState(()=>[null]),[R,z]=v.useState(()=>({[Dn]:"Local"})),[ne,_e]=v.useState(0),[M,F]=v.useState(()=>[n]),[ie,ve]=v.useState(()=>new Set),[be,Ee]=v.useState({}),[Me,Re]=v.useState(null),Pe=v.useRef(0),Be=v.useRef(0),[oe,he]=v.useState(null),[ye,Oe]=v.useState(null),Ke=v.useRef(null),je=v.useRef(0),ae=v.useRef(null),Te=v.useRef(null),we=v.useRef(null),ze=v.useRef(null),Ue=v.useRef(()=>{}),[nt,ht]=v.useState(null),Dt=IE(jS(f1,{activationConstraint:{distance:8}}),jS(p1,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>xD(g),[g]);function Ei(S){const T=S.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){ht({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&ht({tabId:T.sourceTabId,terminalId:T.terminalId})}}function ni(S){ht(null);const T=S.active.data.current,j=S.over?.data.current;if(!(!T||!j||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){dt({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){dt({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&dt({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){dt({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){dt({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&dt({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function di(){ht(null)}const le=x.workspaces.find(S=>S.id===x.activeWorkspaceId)??x.workspaces[0],Ne=le?.tabs.find(S=>S.id===le.activeTabId)??le?.tabs[0],Qe=Ne?.activeTerminalId??null,it=Qe?x.terminals[Qe]:void 0,jt=wB("(max-width: 760px)"),xt=v.useMemo(()=>Ne?Dh(Ne.root):[],[Ne]),gt=le&&Ne?Ac(n,le.id,Ne.id):null,Ht=Ne?Ix(xt,Ne.activeTerminalId,gt?be[gt]:void 0):null,kt=jt&&xt.length>1,Mn=v.useMemo(()=>(le?.detachedTerminalIds??[]).flatMap(S=>{const T=x.terminals[S];return T?[T]:[]}),[le?.detachedTerminalIds,x.terminals]),Nn=v.useMemo(()=>{const S=new Set;for(const T of le?.tabs??[])Gc(T).some(j=>w.unreadCompletions.has(j))&&S.add(T.id);return S},[le?.tabs,w.unreadCompletions]),[Z,We]=v.useState([]),st=v.useRef([]),et=v.useRef(null),[wt,Et]=v.useState(null),[Ut,ri]=v.useState(null),[Gt,Zt]=v.useState([]),[Kt,Qt]=v.useState(()=>rl()),ji=v.useRef(0),hi=v.useRef(n),zi=v.useRef(Kw),gn=v.useRef(Kt),Yi=v.useRef(()=>{});Yi.current=pr,Ue.current=Tr;const Ti=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();Zt(S.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Zt([])}},[g]),ln=v.useCallback(S=>{z(T=>{const j={...T};for(const ee of S)j[gv(ee.agentId)]=ee.label;return Om(T,j)?T:j})},[]);v.useEffect(()=>{F(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]);const Di=v.useCallback(S=>{const T=Ot(S),j=no(S);for(const ee of Object.keys(T.state.terminals))Dc(j.createWebSocketUrl(ee)),Ud(ee);C5(S),F(ee=>ee.filter(pe=>!sn(pe,S))),ve(ee=>{const pe=`${lh(S)}:`;let ue=!1;const Ce=new Set;for(const qe of ee){if(qe.startsWith(pe)){ue=!0;continue}Ce.add(qe)}return ue?Ce:ee}),Ee(ee=>{const pe=`${lh(S)}:`;let ue=!1;const Ce={};for(const[qe,Ye]of Object.entries(ee)){if(qe.startsWith(pe)){ue=!0;continue}Ce[qe]=Ye}return ue?Ce:ee})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(T=>{if(S)return;const j=T.name?.trim()||"Local";z(ee=>{const pe={...ee,[Dn]:j};return Om(ee,pe)?ee:pe})}).catch(()=>{}),g.listAgents().then(T=>{if(!S){const j=T.agents.map(pe=>pe.id),ee=I2(T.serverOrder,T.agents);z(pe=>{const ue={[Dn]:pe[Dn]??"Local"};for(const Ce of T.agents)ue[Ce.id]=Ce.name;return Om(pe,ue)?pe:ue}),n!==null&&!j.includes(n)&&(Di(n),s?.(null)),A(ee)}}).catch(()=>{}),()=>{S=!0}},[n,g,Di,s,ne]);const si=v.useCallback(S=>{Di(S),_e(T=>T+1),sn(S,hi.current)&&s?.(null)},[Di,s]);v.useEffect(()=>{A(S=>S.some(T=>sn(T,n))?S:[...S,n])},[n]),v.useEffect(()=>{hi.current=n},[n]),v.useEffect(()=>{K(null)},[n]),v.useEffect(()=>{const S=ae.current;if(!S)return;if(!sn(S.agentId,n)){ae.current=null;return}if(!w.loaded||x.workspaces.length===0)return;ae.current=null;const T=S.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];T&&T.id!==x.activeWorkspaceId&&dt({type:"workspace.selected",workspaceId:T.id})},[n,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const S=Te.current;if(S){if(!sn(S.agentId,n)){Te.current=null;return}w.loaded&&(Te.current=null,x.workspaces.some(T=>T.id===S.workspaceId)&&dt({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,w.loaded,x.workspaces]),v.useEffect(()=>{const S=we.current;if(S){if(!sn(S.agentId,n)){we.current=null;return}w.loaded&&(we.current=null,w.error||Yn())}},[n,w.error,w.loaded]),v.useEffect(()=>{yn()},[n,w.loaded,x]),v.useEffect(()=>{const S=()=>{const ee=xB();ee&&Ue.current(ee)},T=ee=>{const pe=kB(ee.data);pe&&Ue.current(pe)},j=ee=>{const pe=jh(ee.detail);pe&&Ue.current(pe)};return S(),window.addEventListener("hashchange",S),window.addEventListener($m,j),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",S),window.removeEventListener($m,j),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{Ti()},[Ti]),v.useEffect(()=>D1(()=>Qt(rl())),[]),v.useEffect(()=>{const S=T=>{Yi.current(T)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{zi.current=Gt.length>0?Gt:Kw},[Gt]),v.useEffect(()=>{gn.current=Kt},[Kt]),v.useEffect(()=>{if(!w.loaded||!le||!Ne)return;const S=Ac(n,le.id,Ne.id);ve(T=>{if(T.has(S))return T;const j=new Set(T);return j.add(S),j})},[n,w.loaded,le?.id,Ne?.id]),v.useEffect(()=>()=>{Rs()},[]),v.useEffect(()=>{const S=M2(g),T=L2(g);return()=>{S(),T()}},[g]),v.useEffect(()=>g5(S=>{const T=Ot(S.agentId).state,j=T.workspaces.flatMap(Ce=>Ce.tabs).find(Ce=>Ce.id===S.tabId),ee=T.terminals[S.terminalId],pe=j?.title?.trim()||ee?.title||S.commandName||"terminal",ue=document.visibilityState==="visible"&&sn(S.agentId,hi.current)&&S.tabId===TB(T);if(ue||x2({agentId:S.agentId,tabTitle:pe,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!ue&&document.visibilityState==="visible"&&gn.current.enabled){const Ce=ji.current+1;ji.current=Ce;const qe=zi.current;Et({id:Ce,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:pe,commandName:S.commandName,outcome:S.outcome,assetSrc:qe[Math.floor(Math.random()*qe.length)]??sB})}}),[]),v.useEffect(()=>{if(!wt||Kt.persistUntilDismissed)return;const S=window.setTimeout(()=>{Et(T=>T?.id===wt.id?null:T)},Kt.durationSeconds*1e3);return()=>window.clearTimeout(S)},[wt,Kt]),v.useEffect(()=>{jB(U),U&&Vn()},[U]),v.useEffect(()=>{let S=!1;async function T(){if(!Ot(n).loaded){sa(n,!1,null);try{let ee=null,pe=null;try{ee=RB(y)}catch(Ye){if(!(Ye instanceof Rh))throw Ye;pe=Ye}const[ue,Ce]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),qe=ue.terminals.length>0?ue.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!S){const Ye=Ce.layout?Ux(Ce.layout):null;if(!Ye&&pe)throw pe;const _i=Ye??ee??{},Vt=nv(qe,void 0,_i.savedWorkspaces,_i.savedActiveWorkspaceId),$r=Am(Vt);jw(n,Vt),yc(n,Ce.revision,JSON.stringify($r)),sa(n,!0,null),!Ye&&ee&&Ms($r,{baseRevision:Ce.revision})}}catch(ee){!S&&!Ii(ee)&&sa(n,!0,aa(ee))}}}return T(),()=>{S=!0}},[n,f,re]);function Pi(){sa(n,!1,null),$(S=>S+1)}function Vn(){Pe.current+=1,Be.current+=1,Re(null)}function Sa(S){Pe.current+=1,Be.current+=1,Re(T=>T&&{...T,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Yn(){Pe.current+=1,Be.current+=1;const S=x.workspaces.length+1,T=It();Re({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&on(T)}function bo(S){if(sn(S,n)){Yn();return}we.current={agentId:S},s?.(S)}function ws(S){if(U&&!O)return;const T=x.workspaces.find(ee=>ee.id===S);if(!T)return;Pe.current+=1,Be.current+=1;const j=T.defaultCwd??it?.cwd??"";Re({mode:"edit",workspaceId:S,title:T.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&on(j)}function It(){return le?.defaultCwd??it?.cwd??""}async function on(S){const T=Pe.current+1;Pe.current=T;const j=S.trim();if(Re(ee=>ee&&{...ee,cwd:S,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const ee=await f.createFileRoot({path:j}),pe=await f.listFiles({rootToken:ee.rootToken,path:""});if(Pe.current!==T)return;Re(ue=>ue&&{...ue,cwd:ee.rootPath,browseRoot:{rootToken:ee.rootToken,rootPath:ee.rootPath},browseEntries:pe.entries.filter(Ce=>Ce.kind==="directory"),browseStatus:"idle",error:null})}catch(ee){if(Pe.current!==T)return;Re(pe=>pe&&{...pe,browseStatus:"idle",error:aa(ee)})}}async function vi(){const S=Me;if(!S)return;const T=S.title.trim(),j=S.cwd.trim();if(!T||!j){Re({...S,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const ee=Be.current+1;Be.current=ee,Re({...S,submitStatus:"submitting",error:null});try{const pe=await f.createFileRoot({path:j});if(Be.current!==ee)return;if(S.mode==="create"){const ue=x.workspaces.length+1;dt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ue}`,title:T,defaultCwd:pe.rootPath})}else S.workspaceId&&(dt({type:"workspace.renamed",workspaceId:S.workspaceId,title:T}),dt({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:pe.rootPath}));Re(null)}catch(pe){if(Be.current!==ee)return;Re(ue=>ue&&{...ue,submitStatus:"idle",error:aa(pe)})}}function Xn(S){Be.current+=1,Re(S)}function wr(S,T,j){if(S===T)return;const ee=x.workspaces.some(ue=>ue.id===S),pe=x.workspaces.some(ue=>ue.id===T);!ee||!pe||dt({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:T,placement:j})}function vn(S,T){const j=x.workspaces.findIndex(pe=>pe.id===S),ee=x.workspaces[j+T];j<0||!ee||wr(S,ee.id,T<0?"before":"after")}function $t(S,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),Ke.current={sourceId:S,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function dl(S){const T=Ke.current;if(!T||T.pointerId!==S.pointerId)return;const j=Math.hypot(S.clientX-T.startX,S.clientY-T.startY);if(!T.active){if(j<aB)return;T.active=!0,he(T.sourceId)}const pe=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),ue=pe?.dataset.workspaceId??null;if(!pe||!ue||ue===T.sourceId||!x.workspaces.some(Ye=>Ye.id===ue)){T.targetId=null,Oe(null);return}const Ce=pe.getBoundingClientRect(),qe=S.clientY<Ce.top+Ce.height/2?"before":"after";T.targetId=ue,T.placement=qe,Oe({workspaceId:ue,placement:qe})}function Cs(S){const T=Ke.current;!T||T.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Ke.current=null,he(null),Oe(null),T.active&&T.targetId&&wr(T.sourceId,T.targetId,T.placement))}function An(S){const T=Ke.current;T&&T.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Ke.current=null,he(null),Oe(null)}async function _n(){await hr(async()=>{const S=le?.defaultCwd?{cols:80,rows:24,cwd:le.defaultCwd}:{cols:80,rows:24},T=await f.createTerminal(S);dt({type:"terminal.created",terminal:T.terminal})})}async function Xi(S){await hr(async()=>{const T=Qe?{parentTerminalId:Qe,cols:80,rows:24}:le?.defaultCwd?{cols:80,rows:24,cwd:le.defaultCwd}:{cols:80,rows:24},j=await f.createTerminal(T);dt({type:"terminal.split",terminal:j.terminal,direction:S})})}async function Ur(S){let T=Qe,j=gt;const ee=le?.defaultCwd?.trim();if(!T&&!ee)throw new Error("No active pane is available.");const pe=await f.readFile(S);if(!T&&ee){const qe=await f.createTerminal({cols:80,rows:24,cwd:ee});T=qe.terminal.id,dt({type:"terminal.created",terminal:qe.terminal})}if(T){dt({type:"pane.selected",terminalId:T});const qe=Ot(n).state,Ye=qe.workspaces.find(Vt=>Vt.id===qe.activeWorkspaceId)??qe.workspaces[0],_i=Ye?.tabs.find(Vt=>Vt.id===Ye.activeTabId)??Ye?.tabs[0];j=Ye&&_i?Ac(n,Ye.id,_i.id):null}const ue=`editor-${Date.now().toString(36)}-${w5(n)}`,Ce=BB(pe.path);Lm(n,qe=>({...qe,[ue]:{id:ue,title:Ce,rootToken:S.rootToken,path:pe.path,read:pe}})),j&&Ee(qe=>({...qe,[j]:Hx(ue)})),dt({type:"editor.split",editorId:ue,title:Ce,direction:"vertical"})}function hl(S){Lm(n,T=>{const j={...T};return delete j[S],j}),dt({type:"editor.closed",editorId:S})}function wa(S){Cr([S])}function Cr(S){const T=[...new Set(S)].filter(ee=>x.terminals[ee]);if(T.length===0)return;const j=T.length===1?x.terminals[T[0]]?.title||x.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;K(null),ri({terminalIds:T,label:j,workspaceId:le?.id??x.activeWorkspaceId??null})}function dr(S,T){const j=bn(S,T);if(!j)return!1;const ee=S.filter(pe=>!j.detachedTerminalIds.includes(pe));if(j.detachedTerminalIds.length+ee.length>fo)return K(NB(j.detachedTerminalIds.length)),!1;K(null);for(const pe of S)dt(j.id?{type:"terminal.detached",terminalId:pe,workspaceId:j.id}:{type:"terminal.detached",terminalId:pe});return!0}async function Ln(S){await hr(async()=>{for(const T of S)await xs(T),Dc(f.createWebSocketUrl(T)),Ud(T),dt({type:"terminal.closed",terminalId:T})})}async function fi(S){const T=x.workspaces.find(j=>j.id===S);!T||x.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await hr(async()=>{const j=Th(T),ee=[];let pe=null;for(const Ce of j)try{await xs(Ce)}catch(qe){ee.push(aa(qe)),qe instanceof or&&qe.status===401&&!f.isAgent&&(pe=qe)}finally{Dc(f.createWebSocketUrl(Ce)),Ud(Ce)}const ue=T.tabs.flatMap(Ce=>mv(Ce.root));if(ue.length>0){const Ce=new Set(ue);Lm(n,qe=>{const Ye={...qe};for(const _i of Ce)delete Ye[_i];return Ye})}if(dt({type:"workspace.closed",workspaceId:S}),pe)throw pe;if(ee.length>0)throw new Error(`Workspace was removed, but ${ee.length} terminal session${ee.length===1?"":"s"} may still be running. ${ee[0]}`)})}async function Ca(S){await hr(async()=>{await xs(S),Dc(f.createWebSocketUrl(S)),Ud(S),dt({type:"terminal.closed",terminalId:S})})}async function fl(S,T){const j=T.trim();if(!j)return;let ee=null;for(const pe of x.workspaces){const ue=pe.tabs.find(Ce=>Ce.id===S);if(ue){ee=ue.activeTerminalId;break}}if(dt({type:"tab.renamed",tabId:S,title:j}),!!ee)try{const pe=await f.renameTerminal(ee,j);fr({type:"terminal.updated",terminal:pe.terminal})}catch(pe){sa(n,!0,aa(pe))}}function Bn(S){const T=x.terminals[S];T&&dt({type:"terminal.created",terminal:T})}async function xs(S){try{await f.closeTerminal(S)}catch(T){if(T instanceof or&&T.status===404)return;throw T}}async function xr(){await hr(async()=>{await d()})}async function hr(S){sa(n,!0,null);try{await S()}catch(T){if(Ii(T))return;sa(n,!0,aa(T))}}function Ii(S){return S instanceof or&&S.status===401&&!f.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function dt(S){Vl(n,S);const T=Ot(n),j=T.state;if(!T.loaded||j.workspaces.length===0)return;const ee=Am(j);JSON.stringify(ee)!==T.lastPersistedLayoutJson&&Da(ee)}function fr(S){Vl(n,S)}function ks(S,T,j,ee){const pe=Ac(S,T,j);Ee(ue=>({...ue,[pe]:ee}))}function ai(S){gt&&Ee(T=>({...T,[gt]:S}))}function xa(S,T){const j=Hc(S);T?ks(n,T.workspaceId,T.tabId,j):ai(j),dt({type:"pane.selected",terminalId:S})}function ka(S){ai(S.key),S.type==="terminal"&&dt({type:"pane.selected",terminalId:S.terminalId})}function pr(S){if(ge||Ut||S.isComposing||S.key==="Process"||fB(S.target))return;const T=cB(S);if(!T)return;if(S.preventDefault(),S.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){Ts(T.type==="server.next"?1:-1);return}const j=Ot(n).state,ee=j.workspaces.find(Ce=>Ce.id===j.activeWorkspaceId)??j.workspaces[0],pe=ee?.tabs.find(Ce=>Ce.id===ee.activeTabId)??ee?.tabs[0];if(T.type==="split"){if(!pe)return;Xi(T.direction);return}if(!ee||!pe)return;if(T.type==="tab.previous"||T.type==="tab.next"){const Ce=hB(ee.tabs,pe.id,T.type==="tab.next"?1:-1);Ce&&dt({type:"tab.selected",tabId:Ce.id});return}if(T.type==="tab.index"){const Ce=ee.tabs[T.index-1];Ce&&dt({type:"tab.selected",tabId:Ce.id});return}const ue=uB(pe.root,pe.activeTerminalId,T);ue&&xa(ue,{workspaceId:ee.id,tabId:pe.id})}function Es(S,T){if(!s||se.length===0)return;const j=se.findIndex(Ce=>sn(Ce,n)),pe=((j===-1?0:j)+S+se.length)%se.length,ue=se[pe]??null;sn(ue,n)||(T&&(ae.current={agentId:ue,edge:T}),s(ue))}function Ts(S){const T=Ot(n).state,j=T.workspaces;if(j.length===0){Es(S,S===1?"first":"last");return}const ee=j.findIndex(Ce=>Ce.id===T.activeWorkspaceId),ue=(ee===-1?0:ee)+S;if(ue>=0&&ue<j.length){dt({type:"workspace.selected",workspaceId:j[ue].id});return}Es(S,S===1?"first":"last")}function kr(S,T){if(sn(S,n)){dt({type:"workspace.selected",workspaceId:T});return}Te.current={agentId:S,workspaceId:T},s?.(S)}function bn(S,T){if(T)return x.workspaces.find(j=>j.id===T)??null;for(const j of S){const ee=x.workspaces.find(ue=>ue.tabs.some(Ce=>Gc(Ce).includes(j)));if(ee)return ee;const pe=x.workspaces.find(ue=>ue.detachedTerminalIds.includes(j));if(pe)return pe}return x.workspaces.find(j=>j.id===x.activeWorkspaceId)??x.workspaces[0]??null}function pl(S){Hw(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function yo(S){if(!Hw(S.dataTransfer))return;S.preventDefault();const T=AB(Ot(n).state),j=je.current+1;if(je.current=j,!T){Fr({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Fr({id:j,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Kr(j,T.id,S.dataTransfer)}async function Kr(S,T,j){try{const ee=await X5(j);if(ee.length===0)throw new Error("No files were found in the drop.");Hi(S,{id:S,status:"queued",fileCount:ee.length,message:"Queued"},{terminalId:T,files:ee})}catch(ee){Hi(S,{id:S,status:"failed",fileCount:0,message:aa(ee)},{terminalId:T})}finally{Er()}}async function cn(S){const T=st.current.find(ue=>ue.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=T.terminalId,ee=T.files,pe=new AbortController;et.current=S,Hi(S,{id:S,status:"uploading",fileCount:ee.length,loaded:0,total:null,percent:null},{terminalId:j,files:ee,abortController:pe});try{const ue=await zD({terminalId:j,files:ee,signal:pe.signal,onProgress:_i=>{Hi(S,{id:S,status:"uploading",fileCount:ee.length,loaded:_i.loaded,total:_i.total,percent:_i.percent},{terminalId:j,files:ee,abortController:pe})}}),Ce=ue.failed>0?ue.uploaded>0?"partial":"failed":"success",qe=ue.failed>0?LB(ue):void 0,Ye={id:S,status:Ce,fileCount:ee.length,response:ue};qe&&(Ye.message=qe),Hi(S,Ye,{terminalId:j,files:ee})}catch(ue){Hi(S,{id:S,status:"failed",fileCount:ee.length,message:pe.signal.aborted?"Upload canceled.":aa(ue)},{terminalId:j,files:ee})}finally{et.current===S&&(et.current=null),Er()}}function Er(){if(et.current!==null)return;const S=st.current.find(T=>T.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&cn(S.id)}function Fr(S){tn(T=>[...T,S])}function Hi(S,T,j={}){tn(ee=>ee.map(pe=>{if(pe.id!==S)return pe;const ue={...T},Ce=j.terminalId??pe.terminalId,qe=j.files??pe.files;return Ce!==void 0&&(ue.terminalId=Ce),qe!==void 0&&(ue.files=qe),j.abortController!==void 0&&(ue.abortController=j.abortController),ue}))}function tn(S){const T=S(st.current);st.current=T,We(T)}function Ea(S){st.current.find(j=>j.id===S)?.abortController?.abort(),et.current===S&&(et.current=null),tn(j=>j.filter(ee=>ee.id!==S)),Er()}function Ds(){for(const S of st.current)S.abortController?.abort();et.current=null,tn(()=>[])}function Wr(S){const T=st.current.find(j=>j.id===S);if(T){if(T.status==="queued"){Ea(S);return}T.abortController?.abort()}}function qr(S){const T=st.current.find(ee=>ee.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const j=On(T);if(j.length===0){Hi(S,{id:S,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Hi(S,{id:S,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:T.terminalId,files:j}),Er()}function On(S){const T=S.files??[],j="response"in S?S.response:void 0;if(!j)return T;const ee=j.results.filter(Ce=>Ce.status==="failed").map(Ce=>Ce.relativePath);if(ee.length===0)return[];const pe=new Map;for(const Ce of T){const qe=pe.get(Ce.relativePath)??[];qe.push(Ce),pe.set(Ce.relativePath,qe)}const ue=[];for(const Ce of ee){const Ye=pe.get(Ce)?.shift();Ye&&ue.push(Ye)}return ue}function Ta(S){const j=Ot(S.agentId).state.workspaces.find(ee=>ee.tabs.some(pe=>pe.id===S.tabId));j&&ks(S.agentId,j.id,S.tabId,Hc(S.terminalId)),Vl(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ow(S.agentId,S.terminalId),sn(S.agentId,n)||s?.(S.agentId),Et(null)}function Tr(S){if(ze.current=S,!sn(S.agentId,n)){s?s(S.agentId):ze.current=null;return}yn()}function yn(){const S=ze.current;if(!S||!sn(S.agentId,n)||!w.loaded)return;const T=Ot(S.agentId),j=EB(T.state,S.terminalId);ze.current=null,j&&(ks(S.agentId,j.workspaceId,j.tabId,Hc(S.terminalId)),Vl(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ow(S.agentId,S.terminalId))}function Da(S){const T=Ot(n).mutable.saveCoord;T.pendingLayoutSave=S,Sc(S,y),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const j=T.pendingLayoutSave;T.pendingLayoutSave=null,j&&Ms(j)},rB)}function Rs(){const S=Ot(n).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const T=S.pendingLayoutSave;S.pendingLayoutSave=null,T&&(Sc(T,y),Ms(T))}function Ms(S,T={}){const j=Ot(n).mutable.saveCoord;j.nextPersistLayout=S,T.baseRevision!==void 0&&(j.queuedBaseRevision=T.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const ee=j.nextPersistLayout,pe=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,ee&&await Dr(ee,pe!==void 0?{baseRevision:pe}:{})}))}async function Dr(S,T={}){const j=Ot(n),ee=T.baseRevision??j.layoutRevision,pe={layout:S,...typeof ee=="number"?{baseRevision:ee}:{}};try{const ue=await f.saveTerminalLayout(pe),Ce=ue.layout??S;yc(n,ue.revision,JSON.stringify(Ce)),Sc(Ce,y);return}catch(ue){if(ue instanceof or&&ue.status===400&&ue.message===$T){MB(n,y),sa(n,!0,Kx());return}if(ue instanceof or&&ue.status===409)try{const Ce=await f.getTerminalLayout(),qe=Ot(n).mutable.saveCoord;if(qe.nextPersistLayout||qe.pendingLayoutSave){const Ye=Ce.layout?JSON.stringify(Ce.layout):Ot(n).lastPersistedLayoutJson;yc(n,Ce.revision,Ye);return}if(Ce.layout){const Ye=Ot(n).state,_i=nv(Object.values(Ye.terminals),void 0,Ce.layout.workspaces,Ce.layout.activeWorkspaceId),Vt=Am(_i);jw(n,_i),yc(n,Ce.revision,JSON.stringify(Vt)),Sc(Vt,y)}else yc(n,Ce.revision,j.lastPersistedLayoutJson);return}catch{}Sc(S,y)}}const Ns=zB(l),jn=!U||O,Jt=jn?W:"servers";function nn(S){const T=S.active?w:Ot(S.agentId),j=S.active?x:T.state,ee=S.active?w.loaded:T.loaded,pe=S.active?L:T.error;return p.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[p.jsxs("div",{className:"workspace-list-header",children:[p.jsx("span",{children:"Workspaces"}),p.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>bo(S.agentId),children:"+"})]}),ee?pe?p.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(S.agentId),children:pe}):p.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(ue=>{const Ce=S.active&&ue.id===le?.id,qe=Th(ue).length,Ye=S.active&&j.workspaces.length>1,_i=ye?.workspaceId===ue.id&&oe!==ue.id?ye.placement:null;return p.jsxs(_B,{workspaceId:ue.id,active:Ce,disabled:!S.active,reorderable:Ye,dragging:oe===ue.id,dropPlacement:_i,children:[Ye?p.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ue.id,title:"Drag to reorder","aria-label":`Reorder ${ue.title}`,"aria-grabbed":oe===ue.id,onPointerDown:Vt=>$t(ue.id,Vt),onPointerMove:dl,onPointerUp:Cs,onPointerCancel:An,onKeyDown:Vt=>{(Vt.key==="ArrowUp"||Vt.key==="ArrowDown")&&(Vt.preventDefault(),Vt.stopPropagation(),vn(ue.id,Vt.key==="ArrowUp"?-1:1))},onClick:Vt=>Vt.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Ce?"page":void 0,title:ue.defaultCwd??void 0,onClick:()=>kr(S.agentId,ue.id),onDoubleClick:()=>{S.active&&ws(ue.id)},children:[p.jsx("span",{className:"workspace-list-name",children:ue.title}),p.jsxs("small",{children:[ue.defaultCwd??"No folder"," · ",qe," ",qe===1?"session":"sessions"]})]}),S.active?p.jsxs("div",{className:"workspace-list-actions",children:[p.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ue.title}`,title:"Edit workspace",onClick:()=>ws(ue.id),children:"..."}),p.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ue.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{fi(ue.id)},children:"x"})]}):null]},ue.id)})}):p.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(S.agentId),children:"Open server to load workspaces"})]})}return p.jsx(IT,{sensors:Dt,onDragStart:Ei,onDragEnd:ni,onDragCancel:di,children:p.jsxs("main",{className:"terminal-shell","data-collapsed":U,"data-sidebar-open":O,onDragOver:pl,onDrop:yo,children:[p.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>X(!1)}),p.jsxs("aside",{className:"workspace-sidebar",children:[p.jsxs("header",{className:"workspace-brand",children:[p.jsxs("div",{className:"workspace-brand-lockup",children:[jn?p.jsx(Qw,{height:20}):p.jsx(Zw,{size:24}),c&&jn?p.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),p.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":U?"Expand sidebar":"Collapse sidebar",title:U?"Expand sidebar":"Collapse sidebar",onClick:()=>G(S=>!S),children:U?">":"<"}),p.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>X(!1),children:"x"})]}),p.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Jt==="files"?"files":"servers"}`,children:[jn?p.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[p.jsx("button",{type:"button",role:"tab","aria-selected":W==="servers",onClick:()=>{q("servers")},children:"Workspaces"}),p.jsx("button",{type:"button",role:"tab","aria-selected":W==="files",onClick:()=>{q("files")},children:"Files"})]}):null,Jt==="servers"&&jn?p.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:p.jsx(i0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ne,onServerLabelsChange:ln,renderServerChildren:nn})}):null,jn?null:p.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:p.jsx(i0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:ne,onServerLabelsChange:ln,compact:!0})}),Jt==="files"?p.jsx(KD,{api:f,activeTerminalId:Qe,activeTerminalCwd:it?.cwd??null,workspaceRootPath:Qe?null:le?.defaultCwd??null,onOpenFile:Ur},`${n??"local"}:${le?.id??"no-workspace"}`):null]}),p.jsxs("div",{className:"workspace-sidebar-footer",children:[jn?p.jsx("span",{children:Ns}):null,p.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[p.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>Se(!0),children:[p.jsx(Ww,{name:"settings"}),xe.hasUpdates?p.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),jn?p.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{xr()},children:p.jsx(Ww,{name:"logout"})}):null]})]})]}),ge?p.jsx(BD,{api:g,onClose:()=>Se(!1),updateAvailable:xe.hasUpdates,onNotificationAssetsChanged:()=>{Ti()},onAgentRemoved:si}):null,Me?p.jsx(pB,{dialog:Me,activePaneCwd:it?.cwd??null,activeWorkspaceCwd:le?.defaultCwd??null,onChange:Xn,onManualCwdChange:Sa,onBrowse:on,onCancel:Vn,onSubmit:()=>{vi()}}):null,p.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":kt?"true":void 0,children:[p.jsx(T5,{tabs:le?.tabs??[],activeTabId:le?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Nn,detachedTerminals:Mn,onSelectTab:S=>dt({type:"tab.selected",tabId:S}),onCreateTab:()=>{_n()},onToggleWorkspaces:()=>X(S=>!S),onCloseTerminals:S=>Cr(S),onReattachTerminal:S=>Bn(S),onDeleteTerminal:S=>{Ca(S)},onSplitVertical:()=>{Xi("vertical")},onSplitHorizontal:()=>{Xi("horizontal")},onRenameTab:(S,T)=>{fl(S,T)},activePaneAvailable:!!Qe}),kt?p.jsx(yB,{targets:xt,activeLeafKey:Ht,terminals:x.terminals,editors:D,onSelect:ka}):null,L?p.jsxs("div",{className:"workspace-error",role:"alert",children:[p.jsx("span",{children:L}),p.jsxs("div",{className:"workspace-error-actions",children:[p.jsx("button",{type:"button",onClick:Pi,children:"Retry"}),n!==null&&s?p.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,p.jsxs("section",{className:"workspace-body","aria-busy":B,children:[B?p.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!B&&!Ne?p.jsx(vB,{onCreate:()=>{_n()}}):null,M.map(S=>{const T=sn(S,n);return p.jsx(oB,{agentId:S,serverName:R[gv(S)]??(S===null?"Local":"Server"),active:T,activeServerApi:T?f:void 0,visitedTabKeys:ie,refreshCwdOnEnter:T,draggingTab:T?nt:null,mobileSplitFocus:jt,mobileFocusedLeafByTabKey:be,onSelect:j=>{T&&xa(j)},onClose:j=>{T&&wa(j)},onCloseEditor:j=>{T&&hl(j)},onResize:(j,ee)=>{T&&dt({type:"pane.resized",path:j,ratio:ee})},onExit:(j,ee)=>{T?fr({type:"terminal.exited",terminalId:j,exitCode:ee}):Vl(S,{type:"terminal.exited",terminalId:j,exitCode:ee})},onSnapshot:(j,ee)=>{const pe={type:"terminal.updated",terminal:j,notifyCompletion:ee?.notifyCompletion===!0};T?fr(pe):Vl(S,pe)},...S===null&&m?{onAuthClose:j=>m({...j,source:j?.source??"terminal-ws-1008",activeAgentId:S})}:{}},lh(S))})]}),Ut?p.jsx(bB,{label:Ut.label,count:Ut.terminalIds.length,warning:J,onCancel:()=>{K(null),ri(null)},onHide:()=>{dr(Ut.terminalIds,Ut.workspaceId)&&ri(null)},onDelete:()=>{const S=Ut.terminalIds;K(null),ri(null),Ln(S)}}):null,p.jsx(I5,{toast:wt,onActivate:Ta,onDismiss:()=>Et(null)}),p.jsx(A5,{uploads:Z,onDismiss:Ea,onDismissAll:Ds,onRetry:qr,onCancel:Wr})]})]})})}function oB({agentId:e,serverName:t,active:n,activeServerApi:s,visitedTabKeys:l,refreshCwdOnEnter:c,draggingTab:d,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:f,onClose:y,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,onAuthClose:D}){const B=v.useMemo(()=>xe=>Mx(e,xe),[e]),L=v.useMemo(()=>()=>Ot(e),[e]),O=v.useSyncExternalStore(B,L,L),X=v.useMemo(()=>no(e),[e]),U=s??X,G=O.state,W=G.workspaces.find(xe=>xe.id===G.activeWorkspaceId)??G.workspaces[0],q=W?.id??null,Se=(W?.tabs.find(xe=>xe.id===W.activeTabId)??W?.tabs[0])?.id??null;return!O.loaded||G.workspaces.length===0?null:p.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:G.workspaces.flatMap(xe=>xe.tabs.map(re=>{const $=n&&xe.id===q&&re.id===Se,J=Ac(e,xe.id,re.id),K=Dh(re.root),se=m&&K.length>1?Ix(K,re.activeTerminalId,g[J]):null;return!$&&!l.has(J)?null:p.jsx("div",{className:"workspace-tab-surface","data-active":$,"aria-hidden":!$,children:p.jsx(ev,{node:re.root,terminals:G.terminals,editors:O.editors,api:U,activeTerminalId:re.activeTerminalId,visible:$,refreshCwdOnEnter:$&&c,tabId:re.id,codeServerContext:{serverKey:gv(e),serverName:t,tabName:re.title||G.terminals[re.activeTerminalId]?.title||"Terminal"},dropZoneActive:$&&d!==null,draggingTerminalId:$?d?.terminalId??null:null,mobileFocusLeafKey:se,onSelect:f,onClose:y,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,...D?{onAuthClose:D}:{}})},`${xe.id}:${re.id}`)}))})}function cB(e){const t=$1(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=dB(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function uB(e,t,n){switch(n.type){case"pane.direction":return K5(e,t,n.direction);case"pane.index":return F5(e,n.index);default:return null}}function dB(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function hB(e,t,n){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+n+e.length)%e.length]??null}function Dh(e){return e.type==="pane"?[{key:Hc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Hx(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Dh(e.first),...Dh(e.second)]}function mv(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...mv(e.first),...mv(e.second)]}function Ix(e,t,n){if(n&&e.some(l=>l.key===n))return n;const s=t?Hc(t):null;return s&&e.some(l=>l.key===s)?s:e[0]?.key??null}function Hc(e){return`terminal:${e}`}function Hx(e){return`editor:${e}`}function fB(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function pB({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:l,onBrowse:c,onCancel:d,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),y=e.submitStatus==="submitting";function b(w){s(x=>x&&{...x,...w})}function C(w){w&&(b({cwd:w,error:null}),c(w))}return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:p.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),y||m()},children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),p.jsxs("section",{className:"workspace-dialog-body",children:[p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Name"}),p.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:w=>b({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),p.jsxs("label",{className:"workspace-dialog-field",children:[p.jsx("span",{children:"Default cwd"}),p.jsxs("div",{className:"workspace-dialog-path-row",children:[p.jsx("input",{value:e.cwd,disabled:y,onChange:w=>l(w.currentTarget.value),placeholder:"/home/user/project"}),p.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),p.jsxs("div",{className:"workspace-dialog-quick-actions",children:[p.jsx("button",{type:"button",onClick:()=>C(t),disabled:y||!t,children:"Use active pane"}),p.jsx("button",{type:"button",onClick:()=>C(n),disabled:y||!n,children:"Use current workspace"})]}),p.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[p.jsxs("div",{className:"workspace-dialog-browser-header",children:[p.jsx("span",{title:g,children:g||"No folder selected"}),p.jsx("button",{type:"button",onClick:()=>{c(gB(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?p.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?p.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?p.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>p.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:y,onClick:()=>{c(mB(g,w.path))},children:[p.jsx("span",{children:w.name}),p.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?p.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),p.jsxs("div",{className:"workspace-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),p.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function mB(e,t){return t?t.startsWith("/")?ah(t):ah(`${e||"/"}/${t}`):ah(e)}function gB(e){const t=ah(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function ah(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function vB({onCreate:e}){return p.jsxs("div",{className:"empty-workspace",children:[p.jsx("span",{children:"No terminal is open."}),p.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function _B({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:l=!1,dropPlacement:c=null,children:d}){const{setNodeRef:m,isOver:g}=Mv({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",l?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return p.jsx("div",{ref:m,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:d})}function bB({label:e,count:t,warning:n,onCancel:s,onHide:l,onDelete:c}){return p.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:p.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[p.jsxs("header",{className:"security-panel-header",children:[p.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),p.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),p.jsxs("section",{className:"terminal-delete-dialog-body",children:[p.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),p.jsx("span",{children:e}),p.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?p.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),p.jsxs("div",{className:"terminal-delete-dialog-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:l,children:"Hide"}),p.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function yB({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:l}){const[c,d]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(C=>C.key===t):-1,g=m>=0?m:0,f=e[g]??e[0],y=Fw(f,n,s);function b(C){const w=(g+C+e.length)%e.length,x=e[w];x&&l(x)}return p.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[p.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),p.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>d(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),p.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?p.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:p.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:C=>C.stopPropagation(),children:[p.jsxs("header",{children:[p.jsx("strong",{children:"Panes"}),p.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),p.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((C,w)=>{const x=Fw(C,n,s),D=SB(C,n,s),B=C.key===f.key;return p.jsxs("button",{type:"button","data-active":B,onClick:()=>{l(C),d(!1)},children:[p.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),p.jsxs("span",{className:"mobile-pane-sheet-copy",children:[p.jsx("strong",{children:x}),p.jsx("small",{children:D})]}),p.jsx("span",{className:"mobile-pane-sheet-type",children:C.type})]},C.key)})})]})}):null]})}function Fw(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function SB(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function wB(e){const[t,n]=v.useState(()=>CB(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const s=window.matchMedia(e),l=()=>n(s.matches);return l(),typeof s.addEventListener=="function"?(s.addEventListener("change",l),()=>s.removeEventListener("change",l)):(s.addListener(l),()=>s.removeListener(l))},[e]),t}function CB(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function xB(){if(typeof window>"u")return null;const e=n2(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function kB(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:jh(t.focus)}function EB(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Bi(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function sn(e,t){return e===t}function TB(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function lh(e){return e??"__local__"}function Ac(e,t,n){return`${lh(e)}:${t}:${n}`}class Rh extends Error{constructor(){super(Kx())}}function DB(e){return e?{workspaceKey:`${Uw}:${e}`}:{workspaceKey:Uw}}function RB(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(y1(n))throw new Rh;const s=b1(n);return s?Ux(s):null}catch(n){if(n instanceof Rh)throw n;return null}}function Ux(e){if(y1(e))throw new Rh;const t=b1(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Sc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function MB(e,t){const n=Ot(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function NB(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${fo}. Re-open or delete hidden sessions before hiding more.`}function Kx(){return`A saved terminal layout has more than ${fo} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function AB(e){const t=e.workspaces.find(l=>l.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(l=>l.id===t.activeTabId)??t?.tabs[0],s=n?e.terminals[n.activeTerminalId]:void 0;return s?.status==="running"?s:null}function LB(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function BB(e){return e.split("/").filter(Boolean).pop()??e}function OB(){try{return localStorage.getItem(Px)==="true"}catch{return!1}}function jB(e){try{localStorage.setItem(Px,e?"true":"false")}catch{}}function gv(e){return e??Dn}function Om(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(l=>e[l]===t[l])}function zB(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const s=Math.max(1,Math.floor(n/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function Ww({name:e}){return p.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M4 7h9"}),p.jsx("path",{d:"M17 7h3"}),p.jsx("circle",{cx:"15",cy:"7",r:"2"}),p.jsx("path",{d:"M4 12h3"}),p.jsx("path",{d:"M11 12h9"}),p.jsx("circle",{cx:"9",cy:"12",r:"2"}),p.jsx("path",{d:"M4 17h9"}),p.jsx("path",{d:"M17 17h3"}),p.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M10 6H6v12h4"}),p.jsx("path",{d:"M13 8l4 4-4 4"}),p.jsx("path",{d:"M8 12h9"})]}):null]})}function aa(e){return e instanceof Error?e.message:"Request failed"}function PB({api:e,onDone:t}){const[n,s]=v.useState(null),[l,c]=v.useState(null),[d,m]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(null),[C,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(B=>{D||(s(B.qrDataUrl),c(B.secret))}).catch(B=>{D||w(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function x(D){if(D.preventDefault(),!!l){f(!0),b(null);try{await e.activateTotp({secret:l,otp:d}),t()}catch(B){b(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return C?p.jsx("p",{className:"form-error",children:C}):!n||!l?p.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):p.jsxs("div",{className:"totp-setup",children:[p.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),p.jsx("div",{className:"totp-qr-container",children:p.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),p.jsxs("details",{className:"totp-secret-details",children:[p.jsx("summary",{children:"Can't scan? Enter manually"}),p.jsx("p",{className:"totp-secret-text",children:l})]}),p.jsxs("form",{className:"auth-form",onSubmit:x,children:[p.jsxs("label",{children:["Verification code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?p.jsx("p",{className:"form-error",children:y}):null,p.jsx("button",{type:"submit",disabled:g||d.length!==6,children:"Activate 2FA"})]})]})}function IB(e){return{source:jm(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:jm(e.terminalId)}:{},...e?.detail?{detail:jm(e.detail)}:{}}}function HB(e){return{invalidationSource:e.source}}function UB(e){fn("auth.session_invalid.request",Fx(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Nv("session-invalid-request").catch(()=>{}))}function KB(e,t){fn("auth.session_invalid.result",{...Fx(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Nv("session-invalid-result").catch(()=>{}))}function Fx(e){return{source:e.source,...typeof e.status=="number"?{status:e.status}:{},...e.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e.terminalId?{terminalId:e.terminalId}:{},...e.detail?{detail:e.detail}:{}}}function jm(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function FB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const l=v.useMemo(()=>e??Mh(),[e]),c=v.useMemo(()=>t??no(null),[t]),[d,m]=v.useState(null),[g,f]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let L=!1;return l.getSession().then(O=>{L||(m(O),f(null))}).catch(O=>{L||(f(nl(O)),m(null))}),()=>{L=!0}},[l]);const C=VB(d);v.useEffect(()=>{const L=b.current;fn("auth.view",{view:C,previousView:L,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),L==="workspace"&&C!=="workspace"&&Nv(`auth-left-workspace-${C}`).catch(()=>{}),b.current=C},[d,C]);async function w(){const L=await l.getSession();m(L),f(null)}async function x(){km(),Bm(),ow(),f(null),m(null);try{await w()}catch(L){f(nl(L))}}function D(L){const O=IB(L);if(UB(O),y.current)return y.current;const X=(async()=>{f(null);try{const U=await l.getSession(HB(O));if(KB(O,U.authenticated),m(U),U.authenticated){pL();return}km(),Bm(),ow()}catch(U){f(nl(U))}finally{y.current=null}})();return y.current=X,X}if(C==="workspace")return p.jsx(lB,{api:l,serverApi:c,activeAgentId:n,onSelectServer:s,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:L=>{D(L)},onLogout:async()=>{km(),Bm();const L=await l.logout();m(L)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return p.jsxs("main",{className:"auth-screen",children:[p.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[p.jsx("div",{className:"auth-grid"}),p.jsx("div",{className:"auth-glow"})]}),p.jsxs("section",{className:"auth-panel","aria-busy":C==="loading",children:[p.jsxs("header",{className:"auth-header",children:[p.jsxs("div",{className:"auth-brand",children:[p.jsx(Zw,{size:26}),p.jsxs("div",{children:[p.jsx(Qw,{height:17}),p.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),p.jsx("h1",{children:B[C]})]}),g?p.jsx("p",{className:"form-error",children:g}):null,C==="loading"?p.jsx("p",{className:"muted",children:"Checking session..."}):null,C==="loading"&&g?p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,C==="setup_password"?p.jsx(WB,{api:l,onSession:L=>{m(L)}}):null,C==="setup_totp"?p.jsx(PB,{api:l,onDone:()=>{w()}}):null,C==="login"?p.jsx(qB,{api:l,session:d,onSession:m,onRefresh:w}):null,C==="reauth"?p.jsx($B,{api:l,session:d,onSession:m,onFullLogin:()=>m(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function WB({api:e,onSession:t}){const[n,s]=v.useState(""),[l,c]=v.useState(""),[d,m]=v.useState(!1),[g,f]=v.useState(null);async function y(b){b.preventDefault(),m(!0),f(null);try{if(n!==l){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(C){f(nl(C))}finally{m(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:y,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,value:n,onChange:b=>s(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),p.jsxs("label",{children:["Confirm password",p.jsx("input",{value:l,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?p.jsx("p",{className:"form-error",children:g}):null,p.jsx("button",{type:"submit",disabled:d||n.length<8||l.length<8,children:"Set password"})]})}function qB({api:e,session:t,onSession:n,onRefresh:s}){const[l,c]=v.useState(""),[d,m]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(!1),[C,w]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function B(L){L.preventDefault(),b(!0),w(null);try{n(await e.login({password:l,...x?{otp:d}:{},rememberNetwork:g}))}catch(O){w(nl(O))}finally{b(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:B,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,type:"password",value:l,onChange:L=>c(L.currentTarget.value),required:!0})]}),x?p.jsxs("label",{children:["Authenticator code",p.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:L=>m(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:g,onChange:L=>f(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),C?p.jsx("p",{className:"form-error",children:C}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:y||l.length===0||x&&d.length!==6,children:"Unlock"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:y,children:"Refresh"})]})]})}function $B({api:e,session:t,onSession:n,onFullLogin:s}){const l=t?.currentIpWhitelisted??!1,[c,d]=v.useState(""),[m,g]=v.useState(!1),[f,y]=v.useState(!1),[b,C]=v.useState(!1),[w,x]=v.useState(!1),[D,B]=v.useState(null),L=Li.useCallback(async(X,U)=>{y(!0),B(null);try{n(await e.reauth({...X?{otp:X}:{},rememberNetwork:U}))}catch(G){B(nl(G))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(l){let X=!1;C(!0),x(!1),B(null);const U=window.setTimeout(()=>{X||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(G=>{X||n(G)}).catch(G=>{X||(B(nl(G)),x(!0))}).finally(()=>{window.clearTimeout(U),X||C(!1)}),()=>{X=!0,window.clearTimeout(U)}}},[e,l,n]);async function O(X){X.preventDefault(),await L(c,m)}return l&&b&&!w&&!D?p.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):p.jsxs("form",{className:"auth-form",onSubmit:O,children:[l&&w&&!D?p.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,p.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),p.jsxs("label",{children:["Authenticator code",p.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:X=>d(X.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:m,onChange:X=>g(X.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?p.jsx("p",{className:"form-error",children:D}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function VB(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function nl(e){return e instanceof Error?e.message:"Request failed"}const qw="NTerminal",vv="nterminal.activeAgentId";function YB(){const[e,t]=v.useState(()=>XB()),n=v.useMemo(()=>Mh(),[]),s=v.useMemo(()=>no(e),[e]);v.useEffect(()=>{const c=()=>{const d=S5();document.title=d>0?`(${d}) ${qw}`:qw};return c(),y5(c)},[]);function l(c){GB(c),t(c)}return p.jsx(FB,{api:n,activeAgentId:e,serverApi:s,onSelectServer:l})}function XB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(vv);return e&&e.trim()?e:null}catch{return null}}function GB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(vv,e);return}window.localStorage.removeItem(vv)}catch{}}const $w=["gesturestart","gesturechange","gestureend"],ZB=[".workspace-list",".workspace-nav",".server-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview",".settings-content",".settings-nav",".transcript-dialog-scroll",".transcript-filter-group"].join(",");function QB(e=window){if(!eO(e))return()=>{};const t={passive:!1},n=e.document;function s(c){c.cancelable&&c.preventDefault()}function l(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!JB(c.target))&&s(c)}for(const c of $w)n.addEventListener(c,s,t);return n.addEventListener("touchmove",l,t),n.addEventListener("dblclick",s,t),()=>{for(const c of $w)n.removeEventListener(c,s,t);n.removeEventListener("touchmove",l,t),n.removeEventListener("dblclick",s,t)}}function JB(e){return e instanceof Element&&e.closest(ZB)!==null}function eO(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}a2();_A();QB();wv();bE.createRoot(document.getElementById("root")).render(p.jsx(Li.StrictMode,{children:p.jsx(YB,{})}));export{Li as R,uE as g,p as j};
|