nterminal 1.2.80 → 1.2.82
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-C-ZqElTb.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BFu2FzgT.js → TranscriptMarkdownBody-UgmTgEmq.js} +1 -1
- package/dist/client/assets/index-CEMuRNoD.js +57 -0
- package/dist/client/assets/{index-BFs4imuQ.js → index-i3y_vda1.js} +1 -1
- package/dist/client/assets/{index-rROkcwjD.css → index-yKhwlegq.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/agent/agentRoutes.js +41 -1
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/routes/agentManagementRoutes.js +29 -0
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/server/routes/terminalRoutes.js +51 -0
- package/dist/server/routes/terminalRoutes.js.map +1 -1
- package/dist/server/routes/terminalWebSocket.js +1 -1
- package/dist/server/routes/terminalWebSocket.js.map +1 -1
- package/dist/server/terminal/TerminalManager.d.ts +17 -2
- package/dist/server/terminal/TerminalManager.js +155 -62
- package/dist/server/terminal/TerminalManager.js.map +1 -1
- package/dist/server/terminal/TmuxPtyAdapter.d.ts +6 -0
- package/dist/server/terminal/TmuxPtyAdapter.js +29 -2
- package/dist/server/terminal/TmuxPtyAdapter.js.map +1 -1
- package/dist/server/terminal/codexTranscriptSource.d.ts +2 -2
- package/dist/server/terminal/codexTranscriptSource.js +1 -1
- package/dist/server/terminal/codexTranscriptSource.js.map +1 -1
- package/dist/server/terminal/subagentSources.d.ts +20 -0
- package/dist/server/terminal/subagentSources.js +1072 -0
- package/dist/server/terminal/subagentSources.js.map +1 -0
- package/dist/server/terminal/transcriptHistory.d.ts +2 -0
- package/dist/server/terminal/transcriptHistory.js +62 -37
- package/dist/server/terminal/transcriptHistory.js.map +1 -1
- package/dist/shared/protocol.d.ts +19 -0
- package/dist/shared/protocol.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-D2UZ6wJU.js +0 -1
- package/dist/client/assets/index-4MeJRcb6.js +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-D2UZ6wJU.js","assets/index-BFs4imuQ.js","assets/TranscriptMarkdownBody-BFu2FzgT.js"])))=>i.map(i=>d[i]);
|
|
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 NE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var om={exports:{}},vc={};var jS;function AE(){if(jS)return vc;jS=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 vc.Fragment=t,vc.jsx=n,vc.jsxs=n,vc}var zS;function LE(){return zS||(zS=1,om.exports=AE()),om.exports}var p=LE(),lm={exports:{}},it={};var IS;function OE(){if(IS)return it;IS=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"),k=Symbol.iterator;function x(M){return M===null||typeof M!="object"?null:(M=k&&M[k]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,O={};function A(M,U,ae){this.props=M,this.context=U,this.refs=O,this.updater=ae||w}A.prototype.isReactComponent={},A.prototype.setState=function(M,U){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,U,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function z(){}z.prototype=A.prototype;function $(M,U,ae){this.props=M,this.context=U,this.refs=O,this.updater=ae||w}var K=$.prototype=new z;K.constructor=$,D(K,A.prototype),K.isPureReactComponent=!0;var Q=Array.isArray;function F(){}var q={H:null,A:null,T:null,S:null},be=Object.prototype.hasOwnProperty;function Se(M,U,ae){var _e=ae.ref;return{$$typeof:e,type:M,key:U,ref:_e!==void 0?_e:null,props:ae}}function De(M,U){return Se(M.type,U,M.props)}function ie(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function G(M){var U={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ae){return U[ae]})}var Z=/\/+/g;function W(M,U){return typeof M=="object"&&M!==null&&M.key!=null?G(""+M.key):U.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(U){M.status==="pending"&&(M.status="fulfilled",M.value=U)},function(U){M.status==="pending"&&(M.status="rejected",M.reason=U)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,U,ae,_e,Ne){var xe=typeof M;(xe==="undefined"||xe==="boolean")&&(M=null);var Le=!1;if(M===null)Le=!0;else switch(xe){case"bigint":case"string":case"number":Le=!0;break;case"object":switch(M.$$typeof){case e:case t:Le=!0;break;case y:return Le=M._init,L(Le(M._payload),U,ae,_e,Ne)}}if(Le)return Ne=Ne(M),Le=_e===""?"."+W(M,0):_e,Q(Ne)?(ae="",Le!=null&&(ae=Le.replace(Z,"$&/")+"/"),L(Ne,U,ae,"",function(Fe){return Fe})):Ne!=null&&(ie(Ne)&&(Ne=De(Ne,ae+(Ne.key==null||M&&M.key===Ne.key?"":(""+Ne.key).replace(Z,"$&/")+"/")+Le)),U.push(Ne)),1;Le=0;var Ee=_e===""?".":_e+":";if(Q(M))for(var je=0;je<M.length;je++)_e=M[je],xe=Ee+W(_e,je),Le+=L(_e,U,ae,xe,Ne);else if(je=x(M),typeof je=="function")for(M=je.call(M),je=0;!(_e=M.next()).done;)_e=_e.value,xe=Ee+W(_e,je++),Le+=L(_e,U,ae,xe,Ne);else if(xe==="object"){if(typeof M.then=="function")return L(re(M),U,ae,_e,Ne);throw U=String(M),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Le}function R(M,U,ae){if(M==null)return M;var _e=[],Ne=0;return L(M,_e,"","",function(xe){return U.call(ae,xe,Ne++)}),_e}function I(M){if(M._status===-1){var U=M._result;U=U(),U.then(function(ae){(M._status===0||M._status===-1)&&(M._status=1,M._result=ae)},function(ae){(M._status===0||M._status===-1)&&(M._status=2,M._result=ae)}),M._status===-1&&(M._status=0,M._result=U)}if(M._status===1)return M._result.default;throw M._result}var se=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=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(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ye={map:R,forEach:function(M,U,ae){R(M,function(){U.apply(this,arguments)},ae)},count:function(M){var U=0;return R(M,function(){U++}),U},toArray:function(M){return R(M,function(U){return U})||[]},only:function(M){if(!ie(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return it.Activity=b,it.Children=ye,it.Component=A,it.Fragment=n,it.Profiler=o,it.PureComponent=$,it.StrictMode=s,it.Suspense=g,it.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=q,it.__COMPILER_RUNTIME={__proto__:null,c:function(M){return q.H.useMemoCache(M)}},it.cache=function(M){return function(){return M.apply(null,arguments)}},it.cacheSignal=function(){return null},it.cloneElement=function(M,U,ae){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var _e=D({},M.props),Ne=M.key;if(U!=null)for(xe in U.key!==void 0&&(Ne=""+U.key),U)!be.call(U,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&U.ref===void 0||(_e[xe]=U[xe]);var xe=arguments.length-2;if(xe===1)_e.children=ae;else if(1<xe){for(var Le=Array(xe),Ee=0;Ee<xe;Ee++)Le[Ee]=arguments[Ee+2];_e.children=Le}return Se(M.type,Ne,_e)},it.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},it.createElement=function(M,U,ae){var _e,Ne={},xe=null;if(U!=null)for(_e in U.key!==void 0&&(xe=""+U.key),U)be.call(U,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(Ne[_e]=U[_e]);var Le=arguments.length-2;if(Le===1)Ne.children=ae;else if(1<Le){for(var Ee=Array(Le),je=0;je<Le;je++)Ee[je]=arguments[je+2];Ne.children=Ee}if(M&&M.defaultProps)for(_e in Le=M.defaultProps,Le)Ne[_e]===void 0&&(Ne[_e]=Le[_e]);return Se(M,xe,Ne)},it.createRef=function(){return{current:null}},it.forwardRef=function(M){return{$$typeof:m,render:M}},it.isValidElement=ie,it.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:I}},it.memo=function(M,U){return{$$typeof:f,type:M,compare:U===void 0?null:U}},it.startTransition=function(M){var U=q.T,ae={};q.T=ae;try{var _e=M(),Ne=q.S;Ne!==null&&Ne(ae,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(F,se)}catch(xe){se(xe)}finally{U!==null&&ae.types!==null&&(U.types=ae.types),q.T=U}},it.unstable_useCacheRefresh=function(){return q.H.useCacheRefresh()},it.use=function(M){return q.H.use(M)},it.useActionState=function(M,U,ae){return q.H.useActionState(M,U,ae)},it.useCallback=function(M,U){return q.H.useCallback(M,U)},it.useContext=function(M){return q.H.useContext(M)},it.useDebugValue=function(){},it.useDeferredValue=function(M,U){return q.H.useDeferredValue(M,U)},it.useEffect=function(M,U){return q.H.useEffect(M,U)},it.useEffectEvent=function(M){return q.H.useEffectEvent(M)},it.useId=function(){return q.H.useId()},it.useImperativeHandle=function(M,U,ae){return q.H.useImperativeHandle(M,U,ae)},it.useInsertionEffect=function(M,U){return q.H.useInsertionEffect(M,U)},it.useLayoutEffect=function(M,U){return q.H.useLayoutEffect(M,U)},it.useMemo=function(M,U){return q.H.useMemo(M,U)},it.useOptimistic=function(M,U){return q.H.useOptimistic(M,U)},it.useReducer=function(M,U,ae){return q.H.useReducer(M,U,ae)},it.useRef=function(M){return q.H.useRef(M)},it.useState=function(M){return q.H.useState(M)},it.useSyncExternalStore=function(M,U,ae){return q.H.useSyncExternalStore(M,U,ae)},it.useTransition=function(){return q.H.useTransition()},it.version="19.2.6",it}var PS;function Bv(){return PS||(PS=1,lm.exports=OE()),lm.exports}var v=Bv();const Bi=NE(v);var cm={exports:{}},_c={},um={exports:{}},dm={};var HS;function BE(){return HS||(HS=1,(function(e){function t(L,R){var I=L.length;L.push(R);e:for(;0<I;){var se=I-1>>>1,ye=L[se];if(0<o(ye,R))L[se]=R,L[I]=ye,I=se;else break e}}function n(L){return L.length===0?null:L[0]}function s(L){if(L.length===0)return null;var R=L[0],I=L.pop();if(I!==R){L[0]=I;e:for(var se=0,ye=L.length,M=ye>>>1;se<M;){var U=2*(se+1)-1,ae=L[U],_e=U+1,Ne=L[_e];if(0>o(ae,I))_e<ye&&0>o(Ne,ae)?(L[se]=Ne,L[_e]=I,se=_e):(L[se]=ae,L[U]=I,se=U);else if(_e<ye&&0>o(Ne,I))L[se]=Ne,L[_e]=I,se=_e;else break e}}return R}function o(L,R){var I=L.sortIndex-R.sortIndex;return I!==0?I:L.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,k=3,x=!1,w=!1,D=!1,O=!1,A=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;function K(L){for(var R=n(f);R!==null;){if(R.callback===null)s(f);else if(R.startTime<=L)s(f),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(f)}}function Q(L){if(D=!1,K(L),!w)if(n(g)!==null)w=!0,F||(F=!0,G());else{var R=n(f);R!==null&&re(Q,R.startTime-L)}}var F=!1,q=-1,be=5,Se=-1;function De(){return O?!0:!(e.unstable_now()-Se<be)}function ie(){if(O=!1,F){var L=e.unstable_now();Se=L;var R=!0;try{e:{w=!1,D&&(D=!1,z(q),q=-1),x=!0;var I=k;try{t:{for(K(L),b=n(g);b!==null&&!(b.expirationTime>L&&De());){var se=b.callback;if(typeof se=="function"){b.callback=null,k=b.priorityLevel;var ye=se(b.expirationTime<=L);if(L=e.unstable_now(),typeof ye=="function"){b.callback=ye,K(L),R=!0;break t}b===n(g)&&s(g),K(L)}else s(g);b=n(g)}if(b!==null)R=!0;else{var M=n(f);M!==null&&re(Q,M.startTime-L),R=!1}}break e}finally{b=null,k=I,x=!1}R=void 0}}finally{R?G():F=!1}}}var G;if(typeof $=="function")G=function(){$(ie)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,W=Z.port2;Z.port1.onmessage=ie,G=function(){W.postMessage(null)}}else G=function(){A(ie,0)};function re(L,R){q=A(function(){L(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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):be=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_next=function(L){switch(k){case 1:case 2:case 3:var R=3;break;default:R=k}var I=k;k=R;try{return L()}finally{k=I}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function(L,R){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var I=k;k=L;try{return R()}finally{k=I}},e.unstable_scheduleCallback=function(L,R,I){var se=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?se+I:se):I=se,L){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=I+ye,L={id:y++,callback:R,priorityLevel:L,startTime:I,expirationTime:ye,sortIndex:-1},I>se?(L.sortIndex=I,t(f,L),n(g)===null&&L===n(f)&&(D?(z(q),q=-1):D=!0,re(Q,I-se))):(L.sortIndex=ye,t(g,L),w||x||(w=!0,F||(F=!0,G()))),L},e.unstable_shouldYield=De,e.unstable_wrapCallback=function(L){var R=k;return function(){var I=k;k=R;try{return L.apply(this,arguments)}finally{k=I}}}})(dm)),dm}var US;function jE(){return US||(US=1,um.exports=BE()),um.exports}var hm={exports:{}},pn={};var KS;function zE(){if(KS)return pn;KS=1;var e=Bv();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 pn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,pn.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)},pn.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()}},pn.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))},pn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},pn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var y=f.as,b=m(y,f.crossOrigin),k=typeof f.integrity=="string"?f.integrity:void 0,x=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:k,fetchPriority:x}):y==="script"&&s.d.X(g,{crossOrigin:b,integrity:k,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},pn.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)},pn.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})}},pn.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)},pn.requestFormReset=function(g){s.d.r(g)},pn.unstable_batchedUpdates=function(g,f){return g(f)},pn.useFormState=function(g,f,y){return d.H.useFormState(g,f,y)},pn.useFormStatus=function(){return d.H.useHostTransitionStatus()},pn.version="19.2.6",pn}var FS;function o1(){if(FS)return hm.exports;FS=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(),hm.exports=zE(),hm.exports}var WS;function IE(){if(WS)return _c;WS=1;var e=jE(),t=Bv(),n=o1();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,k=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),$=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),be=Symbol.for("react.lazy"),Se=Symbol.for("react.activity"),De=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function G(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var Z=Symbol.for("react.client.reference");function W(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Z?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case A:return"Profiler";case O:return"StrictMode";case Q:return"Suspense";case F:return"SuspenseList";case Se:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case $:return i.displayName||"Context";case z:return(i._context.displayName||"Context")+".Consumer";case K: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:W(i.type)||"Memo";case be:r=i._payload,i=i._init;try{return W(i(r))}catch{}}return null}var re=Array.isArray,L=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,I={pending:!1,data:null,method:null,action:null},se=[],ye=-1;function M(i){return{current:i}}function U(i){0>ye||(i.current=se[ye],se[ye]=null,ye--)}function ae(i,r){ye++,se[ye]=i.current,i.current=r}var _e=M(null),Ne=M(null),xe=M(null),Le=M(null);function Ee(i,r){switch(ae(xe,r),ae(Ne,i),ae(_e,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?sS(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=sS(r),i=aS(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(_e),ae(_e,i)}function je(){U(_e),U(Ne),U(xe)}function Fe(i){i.memoizedState!==null&&ae(Le,i);var r=_e.current,a=aS(r,i.type);r!==a&&(ae(Ne,i),ae(_e,a))}function ee(i){Ne.current===i&&(U(_e),U(Ne)),Le.current===i&&(U(Le),fc._currentValue=I)}var de,he;function Ae(i){if(de===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);de=r&&r[1]||"",he=-1<a.stack.indexOf(`
|
|
3
|
-
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+de+i+he}var ze=!1;function Me(i,r){if(!i||ze)return"";ze=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(ne){var J=ne}Reflect.construct(i,[],pe)}else{try{pe.call()}catch(ne){J=ne}i.call(pe.prototype)}}else{try{throw Error()}catch(ne){J=ne}(pe=i())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(ne){if(ne&&J&&typeof ne.stack=="string")return[ne.stack,J.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),_=h[0],E=h[1];if(_&&E){var N=_.split(`
|
|
5
|
-
`),X=E.split(`
|
|
6
|
-
`);for(u=l=0;l<N.length&&!N[l].includes("DetermineComponentFrameRoot");)l++;for(;u<X.length&&!X[u].includes("DetermineComponentFrameRoot");)u++;if(l===N.length||u===X.length)for(l=N.length-1,u=X.length-1;1<=l&&0<=u&&N[l]!==X[u];)u--;for(;1<=l&&0<=u;l--,u--)if(N[l]!==X[u]){if(l!==1||u!==1)do if(l--,u--,0>u||N[l]!==X[u]){var le=`
|
|
7
|
-
`+N[l].replace(" at new "," at ");return i.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",i.displayName)),le}while(1<=l&&0<=u);break}}}finally{ze=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ae(a):""}function oe(i,r){switch(i.tag){case 26:case 27:case 5:return Ae(i.type);case 16:return Ae("Lazy");case 13:return i.child!==r&&r!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return Me(i.type,!1);case 11:return Me(i.type.render,!1);case 1:return Me(i.type,!0);case 31:return Ae("Activity");default:return""}}function ke(i){try{var r="",a=null;do r+=oe(i,a),a=i,i=i.return;while(i);return r}catch(l){return`
|
|
8
|
-
Error generating stack: `+l.message+`
|
|
9
|
-
`+l.stack}}var ge=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,Ve=e.unstable_cancelCallback,ot=e.unstable_shouldYield,vt=e.unstable_requestPaint,xt=e.unstable_now,jn=e.unstable_getCurrentPriorityLevel,ni=e.unstable_ImmediatePriority,mi=e.unstable_UserBlockingPriority,Ye=e.unstable_NormalPriority,ft=e.unstable_LowPriority,Vt=e.unstable_IdlePriority,ve=e.log,Ue=e.unstable_setDisableYieldValue,nt=null,Ze=null;function Et(i){if(typeof ve=="function"&&Ue(i),Ze&&typeof Ze.setStrictMode=="function")try{Ze.setStrictMode(nt,i)}catch{}}var ht=Math.clz32?Math.clz32:V,Qt=Math.log,oi=Math.LN2;function V(i){return i>>>=0,i===0?32:31-(Qt(i)/oi|0)|0}var Ke=256,rt=262144,st=4194304;function Rt(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 Lt(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=Rt(l):(_&=E,_!==0?u=Rt(_):a||(a=E&~i,a!==0&&(u=Rt(a))))):(E=l&~h,E!==0?u=Rt(E):_!==0?u=Rt(_):a||(a=l&~i,a!==0&&(u=Rt(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 jt(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function li(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 qt(){var i=st;return st<<=1,(st&62914560)===0&&(st=4194304),i}function Ri(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function $t(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Jt(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,X=i.hiddenUpdates;for(a=_&~a;0<a;){var le=31-ht(a),pe=1<<le;E[le]=0,N[le]=-1;var J=X[le];if(J!==null)for(X[le]=null,le=0;le<J.length;le++){var ne=J[le];ne!==null&&(ne.lane&=-536870913)}a&=~pe}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-ht(r);i.entangledLanes|=r,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function yi(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var l=31-ht(a),u=1<<l;u&r|i[l]&r&&(i[l]|=r),a&=~u}}function ei(i,r){var a=r&-r;return a=(a&42)!==0?1:Ii(a),(a&(i.suspendedLanes|r))!==0?0:a}function Ii(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 Pi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function en(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:RS(i.type))}function ln(i,r){var a=R.p;try{return R.p=i,r()}finally{R.p=a}}var gi=Math.random().toString(36).slice(2),ci="__reactFiber$"+gi,Hi="__reactProps$"+gi,Cn="__reactContainer$"+gi,$r="__reactEvents$"+gi,Ms="__reactListeners$"+gi,Cl="__reactHandles$"+gi,Ns="__reactResources$"+gi,Vr="__reactMarker$"+gi;function Nr(i){delete i[ci],delete i[Hi],delete i[$r],delete i[Ms],delete i[Cl]}function Ar(i){var r=i[ci];if(r)return r;for(var a=i.parentNode;a;){if(r=a[Cn]||a[ci]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=fS(i);i!==null;){if(a=i[ci])return a;i=fS(i)}return r}i=a,a=i.parentNode}return null}function cn(i){if(i=i[ci]||i[Cn]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function Lr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function Gn(i){var r=i[Ns];return r||(r=i[Ns]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function St(i){i[Vr]=!0}var As=new Set,un={};function zn(i,r){mr(i,r),mr(i+"Capture",r)}function mr(i,r){for(un[i]=r,i=0;i<r.length;i++)As.add(r[i])}var gr=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]*$"),Ls={},po={};function Ta(i){return ge.call(po,i)?!0:ge.call(Ls,i)?!1:gr.test(i)?po[i]=!0:(Ls[i]=!0,!1)}function vr(i,r,a){if(Ta(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 _r(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 ri(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 Mi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function mo(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Da(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 Os(i){if(!i._valueTracker){var r=mo(i)?"checked":"value";i._valueTracker=Da(i,r,""+i[r])}}function br(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return i&&(l=mo(i)?i.checked?"true":"false":i.value),i=l,i!==a?(r.setValue(i),!0):!1}function Bs(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 vn=/[\n"\\]/g;function Ui(i){return i.replace(vn,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function pt(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=""+Mi(r)):i.value!==""+Mi(r)&&(i.value=""+Mi(r)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),r!=null?Yr(i,_,Mi(r)):a!=null?Yr(i,_,Mi(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=""+Mi(E):i.removeAttribute("name")}function xn(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)){Os(i);return}a=a!=null?""+Mi(a):"",r=r!=null?""+Mi(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=_),Os(i)}function Yr(i,r,a){r==="number"&&Bs(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function In(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=""+Mi(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 Or(i,r,a){if(r!=null&&(r=""+Mi(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+Mi(a):""}function Ra(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=Mi(r),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),Os(i)}function yr(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var go=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 Xr(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||go.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function xl(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&&Xr(i,u,l)}else for(var h in r)r.hasOwnProperty(h)&&Xr(i,h,r[h])}function Ki(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 kl=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"]]),vo=/^[\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 Fi(i){return vo.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function dn(){}var Zn=null;function Qn(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Yt=null,kn=null;function Ma(i){var r=cn(i);if(r&&(i=r.stateNode)){var a=i[Hi]||null;e:switch(i=r.stateNode,r.type){case"input":if(pt(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="'+Ui(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==i&&l.form===i.form){var u=l[Hi]||null;if(!u)throw Error(s(90));pt(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&&br(l)}break e;case"textarea":Or(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&In(i,!!a.multiple,r,!1)}}}var Gr=!1;function Zr(i,r,a){if(Gr)return i(r,a);Gr=!0;try{var l=i(r);return l}finally{if(Gr=!1,(Yt!==null||kn!==null)&&(bd(),Yt&&(r=Yt,i=kn,kn=Yt=null,Ma(r),i)))for(r=0;r<i.length;r++)Ma(i[r])}}function Sr(i,r){var a=i.stateNode;if(a===null)return null;var l=a[Hi]||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 En=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),js=!1;if(En)try{var wr={};Object.defineProperty(wr,"passive",{get:function(){js=!0}}),window.addEventListener("test",wr,wr),window.removeEventListener("test",wr,wr)}catch{js=!1}var hn=null,Na=null,Qr=null;function Cr(){if(Qr)return Qr;var i,r=Na,a=r.length,l,u="value"in hn?hn.value:hn.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 Qr=u.slice(i,1<l?1-l:void 0)}function Jr(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 zs(){return!0}function Pn(){return!1}function Si(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)?zs:Pn,this.isPropagationStopped=Pn,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=zs)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=zs)},persist:function(){},isPersistent:zs}),r}var Jn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},C=Si(Jn),T=b({},Jn,{view:0,detail:0}),B=Si(T),te,fe,ce,Ce=b({},T,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:El,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!==ce&&(ce&&i.type==="mousemove"?(te=i.screenX-ce.screenX,fe=i.screenY-ce.screenY):fe=te=0,ce=i),te)},movementY:function(i){return"movementY"in i?i.movementY:fe}}),We=Si(Ce),lt=b({},Ce,{dataTransfer:0}),ui=Si(lt),_t=b({},T,{relatedTarget:0}),xr=Si(_t),_o=b({},Jn,{animationName:0,elapsedTime:0,pseudoElement:0}),yu=Si(_o),Su=b({},Jn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),wu=Si(Su),Is=b({},Jn,{data:0}),Wi=Si(Is),uf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cu={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"},xu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ku(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=xu[i])?!!r[i]:!1}function El(){return ku}var Eu=b({},T,{key:function(i){if(i.key){var r=uf[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Jr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Cu[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:El,charCode:function(i){return i.type==="keypress"?Jr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Jr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),es=Si(Eu),Tl=b({},Ce,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Tu=Si(Tl),df=b({},T,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:El}),hf=Si(df),Dl=b({},Jn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Rl=Si(Dl),Ml=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}),bo=Si(Ml),Du=b({},Jn,{newState:0,oldState:0}),Ru=Si(Du),ff=[9,13,27,32],yo=En&&"CompositionEvent"in window,Aa=null;En&&"documentMode"in document&&(Aa=document.documentMode);var pf=En&&"TextEvent"in window&&!Aa,Mu=En&&(!yo||Aa&&8<Aa&&11>=Aa),Nl=" ",So=!1;function La(i,r){switch(i){case"keyup":return ff.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Al(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ts=!1;function mf(i,r){switch(i){case"compositionend":return Al(r);case"keypress":return r.which!==32?null:(So=!0,Nl);case"textInput":return i=r.data,i===Nl&&So?null:i;default:return null}}function Nu(i,r){if(ts)return i==="compositionend"||!yo&&La(i,r)?(i=Cr(),Qr=Na=hn=null,ts=!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 Mu&&r.locale!=="ko"?null:r.data;default:return null}}var Au={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 Ll(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Au[i.type]:r==="textarea"}function Lu(i,r,a,l){Yt?kn?kn.push(l):kn=[l]:Yt=l,r=Ed(r,"onChange"),0<r.length&&(a=new C("onChange","change",null,a,l),i.push({event:a,listeners:r}))}var Ps=null,Tn=null;function gf(i){Jy(i,0)}function wo(i){var r=Lr(i);if(br(r))return i}function Ol(i,r){if(i==="change")return r}var Ou=!1;if(En){var Bl;if(En){var kr="oninput"in document;if(!kr){var Bu=document.createElement("div");Bu.setAttribute("oninput","return;"),kr=typeof Bu.oninput=="function"}Bl=kr}else Bl=!1;Ou=Bl&&(!document.documentMode||9<document.documentMode)}function ju(){Ps&&(Ps.detachEvent("onpropertychange",zu),Tn=Ps=null)}function zu(i){if(i.propertyName==="value"&&wo(Tn)){var r=[];Lu(r,Tn,i,Qn(i)),Zr(gf,r)}}function Iu(i,r,a){i==="focusin"?(ju(),Ps=r,Tn=a,Ps.attachEvent("onpropertychange",zu)):i==="focusout"&&ju()}function Br(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return wo(Tn)}function vf(i,r){if(i==="click")return wo(r)}function _f(i,r){if(i==="input"||i==="change")return wo(r)}function bf(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var tn=typeof Object.is=="function"?Object.is:bf;function Oa(i,r){if(tn(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(!ge.call(r,u)||!tn(i[u],r[u]))return!1}return!0}function jl(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function S(i,r){var a=jl(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=jl(a)}}function P(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?P(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function we(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Bs(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=Bs(i.document)}return r}function He(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 Ge=En&&"documentMode"in document&&11>=document.documentMode,Qe=null,tt=null,at=null,qe=!1;function Kt(i,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;qe||Qe==null||Qe!==Bs(l)||(l=Qe,"selectionStart"in l&&He(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}),at&&Oa(at,l)||(at=l,l=Ed(tt,"onSelect"),0<l.length&&(r=new C("onSelect","select",null,r,a),i.push({event:r,listeners:l}),r.target=Qe)))}function Tt(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var Dt={animationend:Tt("Animation","AnimationEnd"),animationiteration:Tt("Animation","AnimationIteration"),animationstart:Tt("Animation","AnimationStart"),transitionrun:Tt("Transition","TransitionRun"),transitionstart:Tt("Transition","TransitionStart"),transitioncancel:Tt("Transition","TransitionCancel"),transitionend:Tt("Transition","TransitionEnd")},er={},Ba={};En&&(Ba=document.createElement("div").style,"AnimationEvent"in window||(delete Dt.animationend.animation,delete Dt.animationiteration.animation,delete Dt.animationstart.animation),"TransitionEvent"in window||delete Dt.transitionend.transition);function fn(i){if(er[i])return er[i];if(!Dt[i])return i;var r=Dt[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in Ba)return er[i]=r[a];return i}var zl=fn("animationend"),Il=fn("animationiteration"),N_=fn("animationstart"),dk=fn("transitionrun"),hk=fn("transitionstart"),fk=fn("transitioncancel"),A_=fn("transitionend"),L_=new Map,yf="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(" ");yf.push("scrollEnd");function Er(i,r){L_.set(i,r),zn(r,[i])}var Pu=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)},tr=[],Co=0,Sf=0;function Hu(){for(var i=Co,r=Sf=Co=0;r<i;){var a=tr[r];tr[r++]=null;var l=tr[r];tr[r++]=null;var u=tr[r];tr[r++]=null;var h=tr[r];if(tr[r++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}h!==0&&O_(a,u,h)}}function Uu(i,r,a,l){tr[Co++]=i,tr[Co++]=r,tr[Co++]=a,tr[Co++]=l,Sf|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function wf(i,r,a,l){return Uu(i,r,a,l),Ku(i)}function ja(i,r){return Uu(i,null,null,r),Ku(i)}function O_(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-ht(a),i=h.hiddenUpdates,l=i[u],l===null?i[u]=[r]:l.push(r),r.lane=a|536870912),h):null}function Ku(i){if(50<ac)throw ac=0,Np=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var xo={};function pk(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 Hn(i,r,a,l){return new pk(i,r,a,l)}function Cf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function is(i,r){var a=i.alternate;return a===null?(a=Hn(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 B_(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 Fu(i,r,a,l,u,h){var _=0;if(l=i,typeof i=="function")Cf(i)&&(_=1);else if(typeof i=="string")_=bE(i,a,_e.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case Se:return i=Hn(31,a,r,u),i.elementType=Se,i.lanes=h,i;case D:return za(a.children,u,h,r);case O:_=8,u|=24;break;case A:return i=Hn(12,a,r,u|2),i.elementType=A,i.lanes=h,i;case Q:return i=Hn(13,a,r,u),i.elementType=Q,i.lanes=h,i;case F:return i=Hn(19,a,r,u),i.elementType=F,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case $:_=10;break e;case z:_=9;break e;case K:_=11;break e;case q:_=14;break e;case be:_=16,l=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),l=null}return r=Hn(_,a,r,u),r.elementType=i,r.type=l,r.lanes=h,r}function za(i,r,a,l){return i=Hn(7,i,l,r),i.lanes=a,i}function xf(i,r,a){return i=Hn(6,i,null,r),i.lanes=a,i}function j_(i){var r=Hn(18,null,null,0);return r.stateNode=i,r}function kf(i,r,a){return r=Hn(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var z_=new WeakMap;function ir(i,r){if(typeof i=="object"&&i!==null){var a=z_.get(i);return a!==void 0?a:(r={value:i,source:r,stack:ke(r)},z_.set(i,r),r)}return{value:i,source:r,stack:ke(r)}}var ko=[],Eo=0,Wu=null,Pl=0,nr=[],rr=0,Hs=null,jr=1,zr="";function ns(i,r){ko[Eo++]=Pl,ko[Eo++]=Wu,Wu=i,Pl=r}function I_(i,r,a){nr[rr++]=jr,nr[rr++]=zr,nr[rr++]=Hs,Hs=i;var l=jr;i=zr;var u=32-ht(l)-1;l&=~(1<<u),a+=1;var h=32-ht(r)+u;if(30<h){var _=u-u%5;h=(l&(1<<_)-1).toString(32),l>>=_,u-=_,jr=1<<32-ht(r)+u|a<<u|l,zr=h+i}else jr=1<<h|a<<u|l,zr=i}function Ef(i){i.return!==null&&(ns(i,1),I_(i,1,0))}function Tf(i){for(;i===Wu;)Wu=ko[--Eo],ko[Eo]=null,Pl=ko[--Eo],ko[Eo]=null;for(;i===Hs;)Hs=nr[--rr],nr[rr]=null,zr=nr[--rr],nr[rr]=null,jr=nr[--rr],nr[rr]=null}function P_(i,r){nr[rr++]=jr,nr[rr++]=zr,nr[rr++]=Hs,jr=r.id,zr=r.overflow,Hs=i}var nn=null,Xt=null,kt=!1,Us=null,sr=!1,Df=Error(s(519));function Ks(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Hl(ir(r,i)),Df}function H_(i){var r=i.stateNode,a=i.type,l=i.memoizedProps;switch(r[ci]=i,r[Hi]=l,a){case"dialog":yt("cancel",r),yt("close",r);break;case"iframe":case"object":case"embed":yt("load",r);break;case"video":case"audio":for(a=0;a<lc.length;a++)yt(lc[a],r);break;case"source":yt("error",r);break;case"img":case"image":case"link":yt("error",r),yt("load",r);break;case"details":yt("toggle",r);break;case"input":yt("invalid",r),xn(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":yt("invalid",r);break;case"textarea":yt("invalid",r),Ra(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||nS(r.textContent,a)?(l.popover!=null&&(yt("beforetoggle",r),yt("toggle",r)),l.onScroll!=null&&yt("scroll",r),l.onScrollEnd!=null&&yt("scrollend",r),l.onClick!=null&&(r.onclick=dn),r=!0):r=!1,r||Ks(i,!0)}function U_(i){for(nn=i.return;nn;)switch(nn.tag){case 5:case 31:case 13:sr=!1;return;case 27:case 3:sr=!0;return;default:nn=nn.return}}function To(i){if(i!==nn)return!1;if(!kt)return U_(i),kt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||$p(i.type,i.memoizedProps)),a=!a),a&&Xt&&Ks(i),U_(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Xt=hS(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Xt=hS(i)}else r===27?(r=Xt,ia(i.type)?(i=Zp,Zp=null,Xt=i):Xt=r):Xt=nn?or(i.stateNode.nextSibling):null;return!0}function Ia(){Xt=nn=null,kt=!1}function Rf(){var i=Us;return i!==null&&(Nn===null?Nn=i:Nn.push.apply(Nn,i),Us=null),i}function Hl(i){Us===null?Us=[i]:Us.push(i)}var Mf=M(null),Pa=null,rs=null;function Fs(i,r,a){ae(Mf,r._currentValue),r._currentValue=a}function ss(i){i._currentValue=Mf.current,U(Mf)}function Nf(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 Af(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),Nf(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),Nf(_,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 Do(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;tn(u.pendingProps.value,_.value)||(i!==null?i.push(E):i=[E])}}else if(u===Le.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(fc):i=[fc])}u=u.return}i!==null&&Af(r,i,a,l),r.flags|=262144}function qu(i){for(i=i.firstContext;i!==null;){if(!tn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ha(i){Pa=i,rs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function rn(i){return K_(Pa,i)}function $u(i,r){return Pa===null&&Ha(i),K_(i,r)}function K_(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},rs===null){if(i===null)throw Error(s(308));rs=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else rs=rs.next=r;return a}var mk=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()})}},gk=e.unstable_scheduleCallback,vk=e.unstable_NormalPriority,wi={$$typeof:$,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Lf(){return{controller:new mk,data:new Map,refCount:0}}function Ul(i){i.refCount--,i.refCount===0&&gk(vk,function(){i.controller.abort()})}var Kl=null,Of=0,Ro=0,Mo=null;function _k(i,r){if(Kl===null){var a=Kl=[];Of=0,Ro=zp(),Mo={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Of++,r.then(F_,F_),r}function F_(){if(--Of===0&&Kl!==null){Mo!==null&&(Mo.status="fulfilled");var i=Kl;Kl=null,Ro=0,Mo=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function bk(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 W_=L.S;L.S=function(i,r){Ty=xt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&_k(i,r),W_!==null&&W_(i,r)};var Ua=M(null);function Bf(){var i=Ua.current;return i!==null?i:Ft.pooledCache}function Vu(i,r){r===null?ae(Ua,Ua.current):ae(Ua,r.pool)}function q_(){var i=Bf();return i===null?null:{parent:wi._currentValue,pool:i}}var No=Error(s(460)),jf=Error(s(474)),Yu=Error(s(542)),Xu={then:function(){}};function $_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function V_(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(dn,dn),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,X_(i),i;default:if(typeof r.status=="string")r.then(dn,dn);else{if(i=Ft,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,X_(i),i}throw Fa=r,No}}function Ka(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Fa=a,No):a}}var Fa=null;function Y_(){if(Fa===null)throw Error(s(459));var i=Fa;return Fa=null,i}function X_(i){if(i===No||i===Yu)throw Error(s(483))}var Ao=null,Fl=0;function Gu(i){var r=Fl;return Fl+=1,Ao===null&&(Ao=[]),V_(Ao,i,r)}function Wl(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Zu(i,r){throw r.$$typeof===k?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function G_(i){function r(H,j){if(i){var Y=H.deletions;Y===null?(H.deletions=[j],H.flags|=16):Y.push(j)}}function a(H,j){if(!i)return null;for(;j!==null;)r(H,j),j=j.sibling;return null}function l(H){for(var j=new Map;H!==null;)H.key!==null?j.set(H.key,H):j.set(H.index,H),H=H.sibling;return j}function u(H,j){return H=is(H,j),H.index=0,H.sibling=null,H}function h(H,j,Y){return H.index=Y,i?(Y=H.alternate,Y!==null?(Y=Y.index,Y<j?(H.flags|=67108866,j):Y):(H.flags|=67108866,j)):(H.flags|=1048576,j)}function _(H){return i&&H.alternate===null&&(H.flags|=67108866),H}function E(H,j,Y,ue){return j===null||j.tag!==6?(j=xf(Y,H.mode,ue),j.return=H,j):(j=u(j,Y),j.return=H,j)}function N(H,j,Y,ue){var $e=Y.type;return $e===D?le(H,j,Y.props.children,ue,Y.key):j!==null&&(j.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===be&&Ka($e)===j.type)?(j=u(j,Y.props),Wl(j,Y),j.return=H,j):(j=Fu(Y.type,Y.key,Y.props,null,H.mode,ue),Wl(j,Y),j.return=H,j)}function X(H,j,Y,ue){return j===null||j.tag!==4||j.stateNode.containerInfo!==Y.containerInfo||j.stateNode.implementation!==Y.implementation?(j=kf(Y,H.mode,ue),j.return=H,j):(j=u(j,Y.children||[]),j.return=H,j)}function le(H,j,Y,ue,$e){return j===null||j.tag!==7?(j=za(Y,H.mode,ue,$e),j.return=H,j):(j=u(j,Y),j.return=H,j)}function pe(H,j,Y){if(typeof j=="string"&&j!==""||typeof j=="number"||typeof j=="bigint")return j=xf(""+j,H.mode,Y),j.return=H,j;if(typeof j=="object"&&j!==null){switch(j.$$typeof){case x:return Y=Fu(j.type,j.key,j.props,null,H.mode,Y),Wl(Y,j),Y.return=H,Y;case w:return j=kf(j,H.mode,Y),j.return=H,j;case be:return j=Ka(j),pe(H,j,Y)}if(re(j)||G(j))return j=za(j,H.mode,Y,null),j.return=H,j;if(typeof j.then=="function")return pe(H,Gu(j),Y);if(j.$$typeof===$)return pe(H,$u(H,j),Y);Zu(H,j)}return null}function J(H,j,Y,ue){var $e=j!==null?j.key:null;if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return $e!==null?null:E(H,j,""+Y,ue);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case x:return Y.key===$e?N(H,j,Y,ue):null;case w:return Y.key===$e?X(H,j,Y,ue):null;case be:return Y=Ka(Y),J(H,j,Y,ue)}if(re(Y)||G(Y))return $e!==null?null:le(H,j,Y,ue,null);if(typeof Y.then=="function")return J(H,j,Gu(Y),ue);if(Y.$$typeof===$)return J(H,j,$u(H,Y),ue);Zu(H,Y)}return null}function ne(H,j,Y,ue,$e){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return H=H.get(Y)||null,E(j,H,""+ue,$e);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case x:return H=H.get(ue.key===null?Y:ue.key)||null,N(j,H,ue,$e);case w:return H=H.get(ue.key===null?Y:ue.key)||null,X(j,H,ue,$e);case be:return ue=Ka(ue),ne(H,j,Y,ue,$e)}if(re(ue)||G(ue))return H=H.get(Y)||null,le(j,H,ue,$e,null);if(typeof ue.then=="function")return ne(H,j,Y,Gu(ue),$e);if(ue.$$typeof===$)return ne(H,j,Y,$u(j,ue),$e);Zu(j,ue)}return null}function Ie(H,j,Y,ue){for(var $e=null,Mt=null,Pe=j,ut=j=0,Ct=null;Pe!==null&&ut<Y.length;ut++){Pe.index>ut?(Ct=Pe,Pe=null):Ct=Pe.sibling;var Nt=J(H,Pe,Y[ut],ue);if(Nt===null){Pe===null&&(Pe=Ct);break}i&&Pe&&Nt.alternate===null&&r(H,Pe),j=h(Nt,j,ut),Mt===null?$e=Nt:Mt.sibling=Nt,Mt=Nt,Pe=Ct}if(ut===Y.length)return a(H,Pe),kt&&ns(H,ut),$e;if(Pe===null){for(;ut<Y.length;ut++)Pe=pe(H,Y[ut],ue),Pe!==null&&(j=h(Pe,j,ut),Mt===null?$e=Pe:Mt.sibling=Pe,Mt=Pe);return kt&&ns(H,ut),$e}for(Pe=l(Pe);ut<Y.length;ut++)Ct=ne(Pe,H,ut,Y[ut],ue),Ct!==null&&(i&&Ct.alternate!==null&&Pe.delete(Ct.key===null?ut:Ct.key),j=h(Ct,j,ut),Mt===null?$e=Ct:Mt.sibling=Ct,Mt=Ct);return i&&Pe.forEach(function(oa){return r(H,oa)}),kt&&ns(H,ut),$e}function Xe(H,j,Y,ue){if(Y==null)throw Error(s(151));for(var $e=null,Mt=null,Pe=j,ut=j=0,Ct=null,Nt=Y.next();Pe!==null&&!Nt.done;ut++,Nt=Y.next()){Pe.index>ut?(Ct=Pe,Pe=null):Ct=Pe.sibling;var oa=J(H,Pe,Nt.value,ue);if(oa===null){Pe===null&&(Pe=Ct);break}i&&Pe&&oa.alternate===null&&r(H,Pe),j=h(oa,j,ut),Mt===null?$e=oa:Mt.sibling=oa,Mt=oa,Pe=Ct}if(Nt.done)return a(H,Pe),kt&&ns(H,ut),$e;if(Pe===null){for(;!Nt.done;ut++,Nt=Y.next())Nt=pe(H,Nt.value,ue),Nt!==null&&(j=h(Nt,j,ut),Mt===null?$e=Nt:Mt.sibling=Nt,Mt=Nt);return kt&&ns(H,ut),$e}for(Pe=l(Pe);!Nt.done;ut++,Nt=Y.next())Nt=ne(Pe,H,ut,Nt.value,ue),Nt!==null&&(i&&Nt.alternate!==null&&Pe.delete(Nt.key===null?ut:Nt.key),j=h(Nt,j,ut),Mt===null?$e=Nt:Mt.sibling=Nt,Mt=Nt);return i&&Pe.forEach(function(ME){return r(H,ME)}),kt&&ns(H,ut),$e}function Pt(H,j,Y,ue){if(typeof Y=="object"&&Y!==null&&Y.type===D&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case x:e:{for(var $e=Y.key;j!==null;){if(j.key===$e){if($e=Y.type,$e===D){if(j.tag===7){a(H,j.sibling),ue=u(j,Y.props.children),ue.return=H,H=ue;break e}}else if(j.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===be&&Ka($e)===j.type){a(H,j.sibling),ue=u(j,Y.props),Wl(ue,Y),ue.return=H,H=ue;break e}a(H,j);break}else r(H,j);j=j.sibling}Y.type===D?(ue=za(Y.props.children,H.mode,ue,Y.key),ue.return=H,H=ue):(ue=Fu(Y.type,Y.key,Y.props,null,H.mode,ue),Wl(ue,Y),ue.return=H,H=ue)}return _(H);case w:e:{for($e=Y.key;j!==null;){if(j.key===$e)if(j.tag===4&&j.stateNode.containerInfo===Y.containerInfo&&j.stateNode.implementation===Y.implementation){a(H,j.sibling),ue=u(j,Y.children||[]),ue.return=H,H=ue;break e}else{a(H,j);break}else r(H,j);j=j.sibling}ue=kf(Y,H.mode,ue),ue.return=H,H=ue}return _(H);case be:return Y=Ka(Y),Pt(H,j,Y,ue)}if(re(Y))return Ie(H,j,Y,ue);if(G(Y)){if($e=G(Y),typeof $e!="function")throw Error(s(150));return Y=$e.call(Y),Xe(H,j,Y,ue)}if(typeof Y.then=="function")return Pt(H,j,Gu(Y),ue);if(Y.$$typeof===$)return Pt(H,j,$u(H,Y),ue);Zu(H,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,j!==null&&j.tag===6?(a(H,j.sibling),ue=u(j,Y),ue.return=H,H=ue):(a(H,j),ue=xf(Y,H.mode,ue),ue.return=H,H=ue),_(H)):a(H,j)}return function(H,j,Y,ue){try{Fl=0;var $e=Pt(H,j,Y,ue);return Ao=null,$e}catch(Pe){if(Pe===No||Pe===Yu)throw Pe;var Mt=Hn(29,Pe,null,H.mode);return Mt.lanes=ue,Mt.return=H,Mt}}}var Wa=G_(!0),Z_=G_(!1),Ws=!1;function zf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function If(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 qs(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function $s(i,r,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(At&2)!==0){var u=l.pending;return u===null?r.next=r:(r.next=u.next,u.next=r),l.pending=r,r=Ku(i),O_(i,null,a),r}return Uu(i,l,r,a),Ku(i)}function ql(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,yi(i,a)}}function Pf(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 Hf=!1;function $l(){if(Hf){var i=Mo;if(i!==null)throw i}}function Vl(i,r,a,l){Hf=!1;var u=i.updateQueue;Ws=!1;var h=u.firstBaseUpdate,_=u.lastBaseUpdate,E=u.shared.pending;if(E!==null){u.shared.pending=null;var N=E,X=N.next;N.next=null,_===null?h=X:_.next=X,_=N;var le=i.alternate;le!==null&&(le=le.updateQueue,E=le.lastBaseUpdate,E!==_&&(E===null?le.firstBaseUpdate=X:E.next=X,le.lastBaseUpdate=N))}if(h!==null){var pe=u.baseState;_=0,le=X=N=null,E=h;do{var J=E.lane&-536870913,ne=J!==E.lane;if(ne?(wt&J)===J:(l&J)===J){J!==0&&J===Ro&&(Hf=!0),le!==null&&(le=le.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ie=i,Xe=E;J=r;var Pt=a;switch(Xe.tag){case 1:if(Ie=Xe.payload,typeof Ie=="function"){pe=Ie.call(Pt,pe,J);break e}pe=Ie;break e;case 3:Ie.flags=Ie.flags&-65537|128;case 0:if(Ie=Xe.payload,J=typeof Ie=="function"?Ie.call(Pt,pe,J):Ie,J==null)break e;pe=b({},pe,J);break e;case 2:Ws=!0}}J=E.callback,J!==null&&(i.flags|=64,ne&&(i.flags|=8192),ne=u.callbacks,ne===null?u.callbacks=[J]:ne.push(J))}else ne={lane:J,tag:E.tag,payload:E.payload,callback:E.callback,next:null},le===null?(X=le=ne,N=pe):le=le.next=ne,_|=J;if(E=E.next,E===null){if(E=u.shared.pending,E===null)break;ne=E,E=ne.next,ne.next=null,u.lastBaseUpdate=ne,u.shared.pending=null}}while(!0);le===null&&(N=pe),u.baseState=N,u.firstBaseUpdate=X,u.lastBaseUpdate=le,h===null&&(u.shared.lanes=0),Zs|=_,i.lanes=_,i.memoizedState=pe}}function Q_(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function J_(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Q_(a[i],r)}var Lo=M(null),Qu=M(0);function eb(i,r){i=ps,ae(Qu,i),ae(Lo,r),ps=i|r.baseLanes}function Uf(){ae(Qu,ps),ae(Lo,Lo.current)}function Kf(){ps=Qu.current,U(Lo),U(Qu)}var Un=M(null),ar=null;function Vs(i){var r=i.alternate;ae(vi,vi.current&1),ae(Un,i),ar===null&&(r===null||Lo.current!==null||r.memoizedState!==null)&&(ar=i)}function Ff(i){ae(vi,vi.current),ae(Un,i),ar===null&&(ar=i)}function tb(i){i.tag===22?(ae(vi,vi.current),ae(Un,i),ar===null&&(ar=i)):Ys()}function Ys(){ae(vi,vi.current),ae(Un,Un.current)}function Kn(i){U(Un),ar===i&&(ar=null),U(vi)}var vi=M(0);function Ju(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Xp(a)||Gp(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 as=0,ct=null,zt=null,Ci=null,ed=!1,Oo=!1,qa=!1,td=0,Yl=0,Bo=null,yk=0;function di(){throw Error(s(321))}function Wf(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!tn(i[a],r[a]))return!1;return!0}function qf(i,r,a,l,u,h){return as=h,ct=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,L.H=i===null||i.memoizedState===null?Ib:ap,qa=!1,h=a(l,u),qa=!1,Oo&&(h=nb(r,a,l,u)),ib(i),h}function ib(i){L.H=Zl;var r=zt!==null&&zt.next!==null;if(as=0,Ci=zt=ct=null,ed=!1,Yl=0,Bo=null,r)throw Error(s(300));i===null||xi||(i=i.dependencies,i!==null&&qu(i)&&(xi=!0))}function nb(i,r,a,l){ct=i;var u=0;do{if(Oo&&(Bo=null),Yl=0,Oo=!1,25<=u)throw Error(s(301));if(u+=1,Ci=zt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}L.H=Pb,h=r(a,l)}while(Oo);return h}function Sk(){var i=L.H,r=i.useState()[0];return r=typeof r.then=="function"?Xl(r):r,i=i.useState()[0],(zt!==null?zt.memoizedState:null)!==i&&(ct.flags|=1024),r}function $f(){var i=td!==0;return td=0,i}function Vf(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function Yf(i){if(ed){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}ed=!1}as=0,Ci=zt=ct=null,Oo=!1,Yl=td=0,Bo=null}function _n(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ci===null?ct.memoizedState=Ci=i:Ci=Ci.next=i,Ci}function _i(){if(zt===null){var i=ct.alternate;i=i!==null?i.memoizedState:null}else i=zt.next;var r=Ci===null?ct.memoizedState:Ci.next;if(r!==null)Ci=r,zt=i;else{if(i===null)throw ct.alternate===null?Error(s(467)):Error(s(310));zt=i,i={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},Ci===null?ct.memoizedState=Ci=i:Ci=Ci.next=i}return Ci}function id(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xl(i){var r=Yl;return Yl+=1,Bo===null&&(Bo=[]),i=V_(Bo,i,r),r=ct,(Ci===null?r.memoizedState:Ci.next)===null&&(r=r.alternate,L.H=r===null||r.memoizedState===null?Ib:ap),i}function nd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Xl(i);if(i.$$typeof===$)return rn(i)}throw Error(s(438,String(i)))}function Xf(i){var r=null,a=ct.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=ct.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=id(),ct.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]=De;return r.index++,a}function os(i,r){return typeof r=="function"?r(i):r}function rd(i){var r=_i();return Gf(r,zt,i)}function Gf(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,X=r,le=!1;do{var pe=X.lane&-536870913;if(pe!==X.lane?(wt&pe)===pe:(as&pe)===pe){var J=X.revertLane;if(J===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null}),pe===Ro&&(le=!0);else if((as&J)===J){X=X.next,J===Ro&&(le=!0);continue}else pe={lane:0,revertLane:X.revertLane,gesture:null,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null},N===null?(E=N=pe,_=h):N=N.next=pe,ct.lanes|=J,Zs|=J;pe=X.action,qa&&a(h,pe),h=X.hasEagerState?X.eagerState:a(h,pe)}else J={lane:pe,revertLane:X.revertLane,gesture:X.gesture,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null},N===null?(E=N=J,_=h):N=N.next=J,ct.lanes|=pe,Zs|=pe;X=X.next}while(X!==null&&X!==r);if(N===null?_=h:N.next=E,!tn(h,i.memoizedState)&&(xi=!0,le&&(a=Mo,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 Zf(i){var r=_i(),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);tn(h,r.memoizedState)||(xi=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),a.lastRenderedState=h}return[h,l]}function rb(i,r,a){var l=ct,u=_i(),h=kt;if(h){if(a===void 0)throw Error(s(407));a=a()}else a=r();var _=!tn((zt||u).memoizedState,a);if(_&&(u.memoizedState=a,xi=!0),u=u.queue,ep(ob.bind(null,l,u,i),[i]),u.getSnapshot!==r||_||Ci!==null&&Ci.memoizedState.tag&1){if(l.flags|=2048,jo(9,{destroy:void 0},ab.bind(null,l,u,a,r),null),Ft===null)throw Error(s(349));h||(as&127)!==0||sb(l,r,a)}return a}function sb(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=ct.updateQueue,r===null?(r=id(),ct.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function ab(i,r,a,l){r.value=a,r.getSnapshot=l,lb(r)&&cb(i)}function ob(i,r,a){return a(function(){lb(r)&&cb(i)})}function lb(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!tn(i,a)}catch{return!0}}function cb(i){var r=ja(i,2);r!==null&&An(r,i,2)}function Qf(i){var r=_n();if(typeof i=="function"){var a=i;if(i=a(),qa){Et(!0);try{a()}finally{Et(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:i},r}function ub(i,r,a,l){return i.baseState=a,Gf(i,zt,typeof l=="function"?l:os)}function wk(i,r,a,l,u){if(od(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(_)}};L.T!==null?a(!0):h.isTransition=!1,l(h),a=r.pending,a===null?(h.next=r.pending=h,db(r,h)):(h.next=a.next,r.pending=a.next=h)}}function db(i,r){var a=r.action,l=r.payload,u=i.state;if(r.isTransition){var h=L.T,_={};L.T=_;try{var E=a(u,l),N=L.S;N!==null&&N(_,E),hb(i,r,E)}catch(X){Jf(i,r,X)}finally{h!==null&&_.types!==null&&(h.types=_.types),L.T=h}}else try{h=a(u,l),hb(i,r,h)}catch(X){Jf(i,r,X)}}function hb(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){fb(i,r,l)},function(l){return Jf(i,r,l)}):fb(i,r,a)}function fb(i,r,a){r.status="fulfilled",r.value=a,pb(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,db(i,a)))}function Jf(i,r,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,pb(r),r=r.next;while(r!==l)}i.action=null}function pb(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function mb(i,r){return r}function gb(i,r){if(kt){var a=Ft.formState;if(a!==null){e:{var l=ct;if(kt){if(Xt){t:{for(var u=Xt,h=sr;u.nodeType!==8;){if(!h){u=null;break t}if(u=or(u.nextSibling),u===null){u=null;break t}}h=u.data,u=h==="F!"||h==="F"?u:null}if(u){Xt=or(u.nextSibling),l=u.data==="F!";break e}}Ks(l)}l=!1}l&&(r=a[0])}}return a=_n(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mb,lastRenderedState:r},a.queue=l,a=Bb.bind(null,ct,l),l.dispatch=a,l=Qf(!1),h=sp.bind(null,ct,!1,l.queue),l=_n(),u={state:r,dispatch:null,action:i,pending:null},l.queue=u,a=wk.bind(null,ct,u,h,a),u.dispatch=a,l.memoizedState=i,[r,a,!1]}function vb(i){var r=_i();return _b(r,zt,i)}function _b(i,r,a){if(r=Gf(i,r,mb)[0],i=rd(os)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=Xl(r)}catch(_){throw _===No?Yu:_}else l=r;r=_i();var u=r.queue,h=u.dispatch;return a!==r.memoizedState&&(ct.flags|=2048,jo(9,{destroy:void 0},Ck.bind(null,u,a),null)),[l,h,i]}function Ck(i,r){i.action=r}function bb(i){var r=_i(),a=zt;if(a!==null)return _b(r,a,i);_i(),r=r.memoizedState,a=_i();var l=a.queue.dispatch;return a.memoizedState=i,[r,l,!1]}function jo(i,r,a,l){return i={tag:i,create:a,deps:l,inst:r,next:null},r=ct.updateQueue,r===null&&(r=id(),ct.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 yb(){return _i().memoizedState}function sd(i,r,a,l){var u=_n();ct.flags|=i,u.memoizedState=jo(1|r,{destroy:void 0},a,l===void 0?null:l)}function ad(i,r,a,l){var u=_i();l=l===void 0?null:l;var h=u.memoizedState.inst;zt!==null&&l!==null&&Wf(l,zt.memoizedState.deps)?u.memoizedState=jo(r,h,a,l):(ct.flags|=i,u.memoizedState=jo(1|r,h,a,l))}function Sb(i,r){sd(8390656,8,i,r)}function ep(i,r){ad(2048,8,i,r)}function xk(i){ct.flags|=4;var r=ct.updateQueue;if(r===null)r=id(),ct.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function wb(i){var r=_i().memoizedState;return xk({ref:r,nextImpl:i}),function(){if((At&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function Cb(i,r){return ad(4,2,i,r)}function xb(i,r){return ad(4,4,i,r)}function kb(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 Eb(i,r,a){a=a!=null?a.concat([i]):null,ad(4,4,kb.bind(null,r,i),a)}function tp(){}function Tb(i,r){var a=_i();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&Wf(r,l[1])?l[0]:(a.memoizedState=[i,r],i)}function Db(i,r){var a=_i();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&Wf(r,l[1]))return l[0];if(l=i(),qa){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,r],l}function ip(i,r,a){return a===void 0||(as&1073741824)!==0&&(wt&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=Ry(),ct.lanes|=i,Zs|=i,a)}function Rb(i,r,a,l){return tn(a,r)?a:Lo.current!==null?(i=ip(i,a,l),tn(i,r)||(xi=!0),i):(as&42)===0||(as&1073741824)!==0&&(wt&261930)===0?(xi=!0,i.memoizedState=a):(i=Ry(),ct.lanes|=i,Zs|=i,r)}function Mb(i,r,a,l,u){var h=R.p;R.p=h!==0&&8>h?h:8;var _=L.T,E={};L.T=E,sp(i,!1,r,a);try{var N=u(),X=L.S;if(X!==null&&X(E,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var le=bk(N,l);Gl(i,r,le,qn(i))}else Gl(i,r,l,qn(i))}catch(pe){Gl(i,r,{then:function(){},status:"rejected",reason:pe},qn())}finally{R.p=h,_!==null&&E.types!==null&&(_.types=E.types),L.T=_}}function kk(){}function np(i,r,a,l){if(i.tag!==5)throw Error(s(476));var u=Nb(i).queue;Mb(i,u,r,I,a===null?kk:function(){return Ab(i),a(l)})}function Nb(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:I},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Ab(i){var r=Nb(i);r.next===null&&(r=i.alternate.memoizedState),Gl(i,r.next.queue,{},qn())}function rp(){return rn(fc)}function Lb(){return _i().memoizedState}function Ob(){return _i().memoizedState}function Ek(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=qn();i=qs(a);var l=$s(r,i,a);l!==null&&(An(l,r,a),ql(l,r,a)),r={cache:Lf()},i.payload=r;return}r=r.return}}function Tk(i,r,a){var l=qn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},od(i)?jb(r,a):(a=wf(i,r,a,l),a!==null&&(An(a,i,l),zb(a,r,l)))}function Bb(i,r,a){var l=qn();Gl(i,r,a,l)}function Gl(i,r,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(od(i))jb(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,tn(E,_))return Uu(i,r,u,0),Ft===null&&Hu(),!1}catch{}if(a=wf(i,r,u,l),a!==null)return An(a,i,l),zb(a,r,l),!0}return!1}function sp(i,r,a,l){if(l={lane:2,revertLane:zp(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},od(i)){if(r)throw Error(s(479))}else r=wf(i,a,l,2),r!==null&&An(r,i,2)}function od(i){var r=i.alternate;return i===ct||r!==null&&r===ct}function jb(i,r){Oo=ed=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function zb(i,r,a){if((a&4194048)!==0){var l=r.lanes;l&=i.pendingLanes,a|=l,r.lanes=a,yi(i,a)}}var Zl={readContext:rn,use:nd,useCallback:di,useContext:di,useEffect:di,useImperativeHandle:di,useLayoutEffect:di,useInsertionEffect:di,useMemo:di,useReducer:di,useRef:di,useState:di,useDebugValue:di,useDeferredValue:di,useTransition:di,useSyncExternalStore:di,useId:di,useHostTransitionStatus:di,useFormState:di,useActionState:di,useOptimistic:di,useMemoCache:di,useCacheRefresh:di};Zl.useEffectEvent=di;var Ib={readContext:rn,use:nd,useCallback:function(i,r){return _n().memoizedState=[i,r===void 0?null:r],i},useContext:rn,useEffect:Sb,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,sd(4194308,4,kb.bind(null,r,i),a)},useLayoutEffect:function(i,r){return sd(4194308,4,i,r)},useInsertionEffect:function(i,r){sd(4,2,i,r)},useMemo:function(i,r){var a=_n();r=r===void 0?null:r;var l=i();if(qa){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,r],l},useReducer:function(i,r,a){var l=_n();if(a!==void 0){var u=a(r);if(qa){Et(!0);try{a(r)}finally{Et(!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=Tk.bind(null,ct,i),[l.memoizedState,i]},useRef:function(i){var r=_n();return i={current:i},r.memoizedState=i},useState:function(i){i=Qf(i);var r=i.queue,a=Bb.bind(null,ct,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:tp,useDeferredValue:function(i,r){var a=_n();return ip(a,i,r)},useTransition:function(){var i=Qf(!1);return i=Mb.bind(null,ct,i.queue,!0,!1),_n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var l=ct,u=_n();if(kt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),Ft===null)throw Error(s(349));(wt&127)!==0||sb(l,r,a)}u.memoizedState=a;var h={value:a,getSnapshot:r};return u.queue=h,Sb(ob.bind(null,l,h,i),[i]),l.flags|=2048,jo(9,{destroy:void 0},ab.bind(null,l,h,a,r),null),a},useId:function(){var i=_n(),r=Ft.identifierPrefix;if(kt){var a=zr,l=jr;a=(l&~(1<<32-ht(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=td++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=yk++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:rp,useFormState:gb,useActionState:gb,useOptimistic:function(i){var r=_n();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=sp.bind(null,ct,!0,a),a.dispatch=r,[i,r]},useMemoCache:Xf,useCacheRefresh:function(){return _n().memoizedState=Ek.bind(null,ct)},useEffectEvent:function(i){var r=_n(),a={impl:i};return r.memoizedState=a,function(){if((At&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},ap={readContext:rn,use:nd,useCallback:Tb,useContext:rn,useEffect:ep,useImperativeHandle:Eb,useInsertionEffect:Cb,useLayoutEffect:xb,useMemo:Db,useReducer:rd,useRef:yb,useState:function(){return rd(os)},useDebugValue:tp,useDeferredValue:function(i,r){var a=_i();return Rb(a,zt.memoizedState,i,r)},useTransition:function(){var i=rd(os)[0],r=_i().memoizedState;return[typeof i=="boolean"?i:Xl(i),r]},useSyncExternalStore:rb,useId:Lb,useHostTransitionStatus:rp,useFormState:vb,useActionState:vb,useOptimistic:function(i,r){var a=_i();return ub(a,zt,i,r)},useMemoCache:Xf,useCacheRefresh:Ob};ap.useEffectEvent=wb;var Pb={readContext:rn,use:nd,useCallback:Tb,useContext:rn,useEffect:ep,useImperativeHandle:Eb,useInsertionEffect:Cb,useLayoutEffect:xb,useMemo:Db,useReducer:Zf,useRef:yb,useState:function(){return Zf(os)},useDebugValue:tp,useDeferredValue:function(i,r){var a=_i();return zt===null?ip(a,i,r):Rb(a,zt.memoizedState,i,r)},useTransition:function(){var i=Zf(os)[0],r=_i().memoizedState;return[typeof i=="boolean"?i:Xl(i),r]},useSyncExternalStore:rb,useId:Lb,useHostTransitionStatus:rp,useFormState:bb,useActionState:bb,useOptimistic:function(i,r){var a=_i();return zt!==null?ub(a,zt,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Xf,useCacheRefresh:Ob};Pb.useEffectEvent=wb;function op(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 lp={enqueueSetState:function(i,r,a){i=i._reactInternals;var l=qn(),u=qs(l);u.payload=r,a!=null&&(u.callback=a),r=$s(i,u,l),r!==null&&(An(r,i,l),ql(r,i,l))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var l=qn(),u=qs(l);u.tag=1,u.payload=r,a!=null&&(u.callback=a),r=$s(i,u,l),r!==null&&(An(r,i,l),ql(r,i,l))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=qn(),l=qs(a);l.tag=2,r!=null&&(l.callback=r),r=$s(i,l,a),r!==null&&(An(r,i,a),ql(r,i,a))}};function Hb(i,r,a,l,u,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):r.prototype&&r.prototype.isPureReactComponent?!Oa(a,l)||!Oa(u,h):!0}function Ub(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&&lp.enqueueReplaceState(r,r.state,null)}function $a(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 Kb(i){Pu(i)}function Fb(i){console.error(i)}function Wb(i){Pu(i)}function ld(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function qb(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 cp(i,r,a){return a=qs(a),a.tag=3,a.payload={element:null},a.callback=function(){ld(i,r)},a}function $b(i){return i=qs(i),i.tag=3,i}function Vb(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(){qb(r,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){qb(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 Dk(i,r,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&Do(r,a,u,!0),a=Un.current,a!==null){switch(a.tag){case 31:case 13:return ar===null?yd():a.alternate===null&&hi===0&&(hi=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Xu?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),Op(i,l,u)),!1;case 22:return a.flags|=65536,l===Xu?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)),Op(i,l,u)),!1}throw Error(s(435,a.tag))}return Op(i,l,u),yd(),!1}if(kt)return r=Un.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=u,l!==Df&&(i=Error(s(422),{cause:l}),Hl(ir(i,a)))):(l!==Df&&(r=Error(s(423),{cause:l}),Hl(ir(r,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=ir(l,a),u=cp(i.stateNode,l,u),Pf(i,u),hi!==4&&(hi=2)),!1;var h=Error(s(520),{cause:l});if(h=ir(h,a),sc===null?sc=[h]:sc.push(h),hi!==4&&(hi=2),r===null)return!0;l=ir(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=cp(a.stateNode,l,i),Pf(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=$b(u),Vb(u,i,a,l),Pf(a,u),!1}a=a.return}while(a!==null);return!1}var up=Error(s(461)),xi=!1;function sn(i,r,a,l){r.child=i===null?Z_(r,null,a,l):Wa(r,i.child,a,l)}function Yb(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 Ha(r),l=qf(i,r,a,_,h,u),E=$f(),i!==null&&!xi?(Vf(i,r,u),ls(i,r,u)):(kt&&E&&Ef(r),r.flags|=1,sn(i,r,l,u),r.child)}function Xb(i,r,a,l,u){if(i===null){var h=a.type;return typeof h=="function"&&!Cf(h)&&h.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=h,Gb(i,r,h,l,u)):(i=Fu(a.type,null,l,r,r.mode,u),i.ref=r.ref,i.return=r,r.child=i)}if(h=i.child,!_p(i,u)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Oa,a(_,l)&&i.ref===r.ref)return ls(i,r,u)}return r.flags|=1,i=is(h,l),i.ref=r.ref,i.return=r,r.child=i}function Gb(i,r,a,l,u){if(i!==null){var h=i.memoizedProps;if(Oa(h,l)&&i.ref===r.ref)if(xi=!1,r.pendingProps=l=h,_p(i,u))(i.flags&131072)!==0&&(xi=!0);else return r.lanes=i.lanes,ls(i,r,u)}return dp(i,r,a,l,u)}function Zb(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 Qb(i,r,h,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Vu(r,h!==null?h.cachePool:null),h!==null?eb(r,h):Uf(),tb(r);else return l=r.lanes=536870912,Qb(i,r,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(Vu(r,h.cachePool),eb(r,h),Ys(),r.memoizedState=null):(i!==null&&Vu(r,null),Uf(),Ys());return sn(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 Qb(i,r,a,l,u){var h=Bf();return h=h===null?null:{parent:wi._currentValue,pool:h},r.memoizedState={baseLanes:a,cachePool:h},i!==null&&Vu(r,null),Uf(),tb(r),i!==null&&Do(i,r,l,!0),r.childLanes=u,null}function cd(i,r){return r=dd({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function Jb(i,r,a){return Wa(r,i.child,null,a),i=cd(r,r.pendingProps),i.flags|=2,Kn(r),r.memoizedState=null,i}function Rk(i,r,a){var l=r.pendingProps,u=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(kt){if(l.mode==="hidden")return i=cd(r,l),r.lanes=536870912,Ql(null,i);if(Ff(r),(i=Xt)?(i=dS(i,sr),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Hs!==null?{id:jr,overflow:zr}:null,retryLane:536870912,hydrationErrors:null},a=j_(i),a.return=r,r.child=a,nn=r,Xt=null)):i=null,i===null)throw Ks(r);return r.lanes=536870912,null}return cd(r,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(Ff(r),u)if(r.flags&256)r.flags&=-257,r=Jb(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(xi||Do(i,r,a,!1),u=(a&i.childLanes)!==0,xi||u){if(l=Ft,l!==null&&(_=ei(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,ja(i,_),An(l,i,_),up;yd(),r=Jb(i,r,a)}else i=h.treeContext,Xt=or(_.nextSibling),nn=r,kt=!0,Us=null,sr=!1,i!==null&&P_(r,i),r=cd(r,l),r.flags|=4096;return r}return i=is(i.child,{mode:l.mode,children:l.children}),i.ref=r.ref,r.child=i,i.return=r,i}function ud(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 dp(i,r,a,l,u){return Ha(r),a=qf(i,r,a,l,void 0,u),l=$f(),i!==null&&!xi?(Vf(i,r,u),ls(i,r,u)):(kt&&l&&Ef(r),r.flags|=1,sn(i,r,a,u),r.child)}function ey(i,r,a,l,u,h){return Ha(r),r.updateQueue=null,a=nb(r,l,a,u),ib(i),l=$f(),i!==null&&!xi?(Vf(i,r,h),ls(i,r,h)):(kt&&l&&Ef(r),r.flags|=1,sn(i,r,a,h),r.child)}function ty(i,r,a,l,u){if(Ha(r),r.stateNode===null){var h=xo,_=a.contextType;typeof _=="object"&&_!==null&&(h=rn(_)),h=new a(l,h),r.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=lp,r.stateNode=h,h._reactInternals=r,h=r.stateNode,h.props=l,h.state=r.memoizedState,h.refs={},zf(r),_=a.contextType,h.context=typeof _=="object"&&_!==null?rn(_):xo,h.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(op(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&&lp.enqueueReplaceState(h,h.state,null),Vl(r,l,h,u),$l(),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=$a(a,E);h.props=N;var X=h.context,le=a.contextType;_=xo,typeof le=="object"&&le!==null&&(_=rn(le));var pe=a.getDerivedStateFromProps;le=typeof pe=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=r.pendingProps!==E,le||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||X!==_)&&Ub(r,h,l,_),Ws=!1;var J=r.memoizedState;h.state=J,Vl(r,l,h,u),$l(),X=r.memoizedState,E||J!==X||Ws?(typeof pe=="function"&&(op(r,a,pe,l),X=r.memoizedState),(N=Ws||Hb(r,a,N,l,J,X,_))?(le||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=X),h.props=l,h.state=X,h.context=_,l=N):(typeof h.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{h=r.stateNode,If(i,r),_=r.memoizedProps,le=$a(a,_),h.props=le,pe=r.pendingProps,J=h.context,X=a.contextType,N=xo,typeof X=="object"&&X!==null&&(N=rn(X)),E=a.getDerivedStateFromProps,(X=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==pe||J!==N)&&Ub(r,h,l,N),Ws=!1,J=r.memoizedState,h.state=J,Vl(r,l,h,u),$l();var ne=r.memoizedState;_!==pe||J!==ne||Ws||i!==null&&i.dependencies!==null&&qu(i.dependencies)?(typeof E=="function"&&(op(r,a,E,l),ne=r.memoizedState),(le=Ws||Hb(r,a,le,l,J,ne,N)||i!==null&&i.dependencies!==null&&qu(i.dependencies))?(X||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(l,ne,N),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(l,ne,N)),typeof h.componentDidUpdate=="function"&&(r.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=ne),h.props=l,h.state=ne,h.context=N,l=le):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(r.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(r.flags|=1024),l=!1)}return h=l,ud(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=Wa(r,i.child,null,u),r.child=Wa(r,null,a,u)):sn(i,r,a,u),r.memoizedState=h.state,i=r.child):i=ls(i,r,u),i}function iy(i,r,a,l){return Ia(),r.flags|=256,sn(i,r,a,l),r.child}var hp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fp(i){return{baseLanes:i,cachePool:q_()}}function pp(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=Wn),i}function ny(i,r,a){var l=r.pendingProps,u=!1,h=(r.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(vi.current&2)!==0),_&&(u=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,i===null){if(kt){if(u?Vs(r):Ys(),(i=Xt)?(i=dS(i,sr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Hs!==null?{id:jr,overflow:zr}:null,retryLane:536870912,hydrationErrors:null},a=j_(i),a.return=r,r.child=a,nn=r,Xt=null)):i=null,i===null)throw Ks(r);return Gp(i)?r.lanes=32:r.lanes=536870912,null}var E=l.children;return l=l.fallback,u?(Ys(),u=r.mode,E=dd({mode:"hidden",children:E},u),l=za(l,u,a,null),E.return=r,l.return=r,E.sibling=l,r.child=E,l=r.child,l.memoizedState=fp(a),l.childLanes=pp(i,_,a),r.memoizedState=hp,Ql(null,l)):(Vs(r),mp(r,E))}var N=i.memoizedState;if(N!==null&&(E=N.dehydrated,E!==null)){if(h)r.flags&256?(Vs(r),r.flags&=-257,r=gp(i,r,a)):r.memoizedState!==null?(Ys(),r.child=i.child,r.flags|=128,r=null):(Ys(),E=l.fallback,u=r.mode,l=dd({mode:"visible",children:l.children},u),E=za(E,u,a,null),E.flags|=2,l.return=r,E.return=r,l.sibling=E,r.child=l,Wa(r,i.child,null,a),l=r.child,l.memoizedState=fp(a),l.childLanes=pp(i,_,a),r.memoizedState=hp,r=Ql(null,l));else if(Vs(r),Gp(E)){if(_=E.nextSibling&&E.nextSibling.dataset,_)var X=_.dgst;_=X,l=Error(s(419)),l.stack="",l.digest=_,Hl({value:l,source:null,stack:null}),r=gp(i,r,a)}else if(xi||Do(i,r,a,!1),_=(a&i.childLanes)!==0,xi||_){if(_=Ft,_!==null&&(l=ei(_,a),l!==0&&l!==N.retryLane))throw N.retryLane=l,ja(i,l),An(_,i,l),up;Xp(E)||yd(),r=gp(i,r,a)}else Xp(E)?(r.flags|=192,r.child=i.child,r=null):(i=N.treeContext,Xt=or(E.nextSibling),nn=r,kt=!0,Us=null,sr=!1,i!==null&&P_(r,i),r=mp(r,l.children),r.flags|=4096);return r}return u?(Ys(),E=l.fallback,u=r.mode,N=i.child,X=N.sibling,l=is(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,X!==null?E=is(X,E):(E=za(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=fp(a):(u=E.cachePool,u!==null?(N=wi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=q_(),E={baseLanes:E.baseLanes|a,cachePool:u}),l.memoizedState=E,l.childLanes=pp(i,_,a),r.memoizedState=hp,Ql(i.child,l)):(Vs(r),a=i.child,i=a.sibling,a=is(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 mp(i,r){return r=dd({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function dd(i,r){return i=Hn(22,i,null,r),i.lanes=0,i}function gp(i,r,a){return Wa(r,i.child,null,a),i=mp(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function ry(i,r,a){i.lanes|=r;var l=i.alternate;l!==null&&(l.lanes|=r),Nf(i.return,r,a)}function vp(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 sy(i,r,a){var l=r.pendingProps,u=l.revealOrder,h=l.tail;l=l.children;var _=vi.current,E=(_&2)!==0;if(E?(_=_&1|2,r.flags|=128):_&=1,ae(vi,_),sn(i,r,l,a),l=kt?Pl:0,!E&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&ry(i,a,r);else if(i.tag===19)ry(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&&Ju(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=r.child,r.child=null):(u=a.sibling,a.sibling=null),vp(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&&Ju(i)===null){r.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}vp(r,!0,a,null,h,l);break;case"together":vp(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function ls(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Zs|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(Do(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=is(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=is(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function _p(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&qu(i)))}function Mk(i,r,a){switch(r.tag){case 3:Ee(r,r.stateNode.containerInfo),Fs(r,wi,i.memoizedState.cache),Ia();break;case 27:case 5:Fe(r);break;case 4:Ee(r,r.stateNode.containerInfo);break;case 10:Fs(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Ff(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(Vs(r),r.flags|=128,null):(a&r.child.childLanes)!==0?ny(i,r,a):(Vs(r),i=ls(i,r,a),i!==null?i.sibling:null);Vs(r);break;case 19:var u=(i.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(Do(i,r,a,!1),l=(a&r.childLanes)!==0),u){if(l)return sy(i,r,a);r.flags|=128}if(u=r.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ae(vi,vi.current),l)break;return null;case 22:return r.lanes=0,Zb(i,r,a,r.pendingProps);case 24:Fs(r,wi,i.memoizedState.cache)}return ls(i,r,a)}function ay(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)xi=!0;else{if(!_p(i,a)&&(r.flags&128)===0)return xi=!1,Mk(i,r,a);xi=(i.flags&131072)!==0}else xi=!1,kt&&(r.flags&1048576)!==0&&I_(r,Pl,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(i=Ka(r.elementType),r.type=i,typeof i=="function")Cf(i)?(l=$a(i,l),r.tag=1,r=ty(null,r,i,l,a)):(r.tag=0,r=dp(null,r,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===K){r.tag=11,r=Yb(null,r,i,l,a);break e}else if(u===q){r.tag=14,r=Xb(null,r,i,l,a);break e}}throw r=W(i)||i,Error(s(306,r,""))}}return r;case 0:return dp(i,r,r.type,r.pendingProps,a);case 1:return l=r.type,u=$a(l,r.pendingProps),ty(i,r,l,u,a);case 3:e:{if(Ee(r,r.stateNode.containerInfo),i===null)throw Error(s(387));l=r.pendingProps;var h=r.memoizedState;u=h.element,If(i,r),Vl(r,l,null,a);var _=r.memoizedState;if(l=_.cache,Fs(r,wi,l),l!==h.cache&&Af(r,[wi],a,!0),$l(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){r=iy(i,r,l,a);break e}else if(l!==u){u=ir(Error(s(424)),r),Hl(u),r=iy(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,Xt=or(i.firstChild),nn=r,kt=!0,Us=null,sr=!0,a=Z_(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Ia(),l===u){r=ls(i,r,a);break e}sn(i,r,l,a)}r=r.child}return r;case 26:return ud(i,r),i===null?(a=vS(r.type,null,r.pendingProps,null))?r.memoizedState=a:kt||(a=r.type,i=r.pendingProps,l=Td(xe.current).createElement(a),l[ci]=r,l[Hi]=i,an(l,a,i),St(l),r.stateNode=l):r.memoizedState=vS(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Fe(r),i===null&&kt&&(l=r.stateNode=pS(r.type,r.pendingProps,xe.current),nn=r,sr=!0,u=Xt,ia(r.type)?(Zp=u,Xt=or(l.firstChild)):Xt=u),sn(i,r,r.pendingProps.children,a),ud(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&kt&&((u=l=Xt)&&(l=aE(l,r.type,r.pendingProps,sr),l!==null?(r.stateNode=l,nn=r,Xt=or(l.firstChild),sr=!1,u=!0):u=!1),u||Ks(r)),Fe(r),u=r.type,h=r.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,$p(u,h)?l=null:_!==null&&$p(u,_)&&(r.flags|=32),r.memoizedState!==null&&(u=qf(i,r,Sk,null,null,a),fc._currentValue=u),ud(i,r),sn(i,r,l,a),r.child;case 6:return i===null&&kt&&((i=a=Xt)&&(a=oE(a,r.pendingProps,sr),a!==null?(r.stateNode=a,nn=r,Xt=null,i=!0):i=!1),i||Ks(r)),null;case 13:return ny(i,r,a);case 4:return Ee(r,r.stateNode.containerInfo),l=r.pendingProps,i===null?r.child=Wa(r,null,l,a):sn(i,r,l,a),r.child;case 11:return Yb(i,r,r.type,r.pendingProps,a);case 7:return sn(i,r,r.pendingProps,a),r.child;case 8:return sn(i,r,r.pendingProps.children,a),r.child;case 12:return sn(i,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Fs(r,r.type,l.value),sn(i,r,l.children,a),r.child;case 9:return u=r.type._context,l=r.pendingProps.children,Ha(r),u=rn(u),l=l(u),r.flags|=1,sn(i,r,l,a),r.child;case 14:return Xb(i,r,r.type,r.pendingProps,a);case 15:return Gb(i,r,r.type,r.pendingProps,a);case 19:return sy(i,r,a);case 31:return Rk(i,r,a);case 22:return Zb(i,r,a,r.pendingProps);case 24:return Ha(r),l=rn(wi),i===null?(u=Bf(),u===null&&(u=Ft,h=Lf(),u.pooledCache=h,h.refCount++,h!==null&&(u.pooledCacheLanes|=a),u=h),r.memoizedState={parent:l,cache:u},zf(r),Fs(r,wi,u)):((i.lanes&a)!==0&&(If(i,r),Vl(r,null,null,a),$l()),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),Fs(r,wi,l)):(l=h.cache,Fs(r,wi,l),l!==u.cache&&Af(r,[wi],a,!0))),sn(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function cs(i){i.flags|=4}function bp(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(Ly())i.flags|=8192;else throw Fa=Xu,jf}else i.flags&=-16777217}function oy(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!wS(r))if(Ly())i.flags|=8192;else throw Fa=Xu,jf}function hd(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?qt():536870912,i.lanes|=r,Ho|=r)}function Jl(i,r){if(!kt)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 Gt(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 Nk(i,r,a){var l=r.pendingProps;switch(Tf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(r),null;case 1:return Gt(r),null;case 3:return a=r.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),ss(wi),je(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(To(r)?cs(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Rf())),Gt(r),null;case 26:var u=r.type,h=r.memoizedState;return i===null?(cs(r),h!==null?(Gt(r),oy(r,h)):(Gt(r),bp(r,u,null,l,a))):h?h!==i.memoizedState?(cs(r),Gt(r),oy(r,h)):(Gt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==l&&cs(r),Gt(r),bp(r,u,i,l,a)),null;case 27:if(ee(r),a=xe.current,u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==l&&cs(r);else{if(!l){if(r.stateNode===null)throw Error(s(166));return Gt(r),null}i=_e.current,To(r)?H_(r):(i=pS(u,l,a),r.stateNode=i,cs(r))}return Gt(r),null;case 5:if(ee(r),u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==l&&cs(r);else{if(!l){if(r.stateNode===null)throw Error(s(166));return Gt(r),null}if(h=_e.current,To(r))H_(r);else{var _=Td(xe.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[ci]=r,h[Hi]=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(an(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&&cs(r)}}return Gt(r),bp(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==l&&cs(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(s(166));if(i=xe.current,To(r)){if(i=r.stateNode,a=r.memoizedProps,l=null,u=nn,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[ci]=r,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||nS(i.nodeValue,a)),i||Ks(r,!0)}else i=Td(i).createTextNode(l),i[ci]=r,r.stateNode=i}return Gt(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(l=To(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[ci]=r}else Ia(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Gt(r),i=!1}else a=Rf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(Kn(r),r):(Kn(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Gt(r),null;case 13:if(l=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=To(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[ci]=r}else Ia(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Gt(r),u=!1}else u=Rf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return r.flags&256?(Kn(r),r):(Kn(r),null)}return Kn(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),hd(r,r.updateQueue),Gt(r),null);case 4:return je(),i===null&&Up(r.stateNode.containerInfo),Gt(r),null;case 10:return ss(r.type),Gt(r),null;case 19:if(U(vi),l=r.memoizedState,l===null)return Gt(r),null;if(u=(r.flags&128)!==0,h=l.rendering,h===null)if(u)Jl(l,!1);else{if(hi!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(h=Ju(i),h!==null){for(r.flags|=128,Jl(l,!1),i=h.updateQueue,r.updateQueue=i,hd(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)B_(a,i),a=a.sibling;return ae(vi,vi.current&1|2),kt&&ns(r,l.treeForkCount),r.child}i=i.sibling}l.tail!==null&&xt()>vd&&(r.flags|=128,u=!0,Jl(l,!1),r.lanes=4194304)}else{if(!u)if(i=Ju(h),i!==null){if(r.flags|=128,u=!0,i=i.updateQueue,r.updateQueue=i,hd(r,i),Jl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!kt)return Gt(r),null}else 2*xt()-l.renderingStartTime>vd&&a!==536870912&&(r.flags|=128,u=!0,Jl(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=xt(),i.sibling=null,a=vi.current,ae(vi,u?a&1|2:a&1),kt&&ns(r,l.treeForkCount),i):(Gt(r),null);case 22:case 23:return Kn(r),Kf(),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&&(Gt(r),r.subtreeFlags&6&&(r.flags|=8192)):Gt(r),a=r.updateQueue,a!==null&&hd(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&&U(Ua),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),ss(wi),Gt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function Ak(i,r){switch(Tf(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return ss(wi),je(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return ee(r),null;case 31:if(r.memoizedState!==null){if(Kn(r),r.alternate===null)throw Error(s(340));Ia()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Kn(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Ia()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return U(vi),null;case 4:return je(),null;case 10:return ss(r.type),null;case 22:case 23:return Kn(r),Kf(),i!==null&&U(Ua),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return ss(wi),null;case 25:return null;default:return null}}function ly(i,r){switch(Tf(r),r.tag){case 3:ss(wi),je();break;case 26:case 27:case 5:ee(r);break;case 4:je();break;case 31:r.memoizedState!==null&&Kn(r);break;case 13:Kn(r);break;case 19:U(vi);break;case 10:ss(r.type);break;case 22:case 23:Kn(r),Kf(),i!==null&&U(Ua);break;case 24:ss(wi)}}function ec(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){Bt(r,r.return,E)}}function Xs(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,X=E;try{X()}catch(le){Bt(u,N,le)}}}l=l.next}while(l!==h)}}catch(le){Bt(r,r.return,le)}}function cy(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{J_(r,a)}catch(l){Bt(i,i.return,l)}}}function uy(i,r,a){a.props=$a(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){Bt(i,r,l)}}function tc(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){Bt(i,r,u)}}function Ir(i,r){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){Bt(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){Bt(i,r,u)}else a.current=null}function dy(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){Bt(i,i.return,u)}}function yp(i,r,a){try{var l=i.stateNode;eE(l,i.type,a,r),l[Hi]=r}catch(u){Bt(i,i.return,u)}}function hy(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ia(i.type)||i.tag===4}function Sp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||hy(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&&ia(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 wp(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=dn));else if(l!==4&&(l===27&&ia(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(wp(i,r,a),i=i.sibling;i!==null;)wp(i,r,a),i=i.sibling}function fd(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&&ia(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(fd(i,r,a),i=i.sibling;i!==null;)fd(i,r,a),i=i.sibling}function fy(i){var r=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=r.attributes;u.length;)r.removeAttributeNode(u[0]);an(r,l,a),r[ci]=i,r[Hi]=a}catch(h){Bt(i,i.return,h)}}var us=!1,ki=!1,Cp=!1,py=typeof WeakSet=="function"?WeakSet:Set,qi=null;function Lk(i,r){if(i=i.containerInfo,Wp=Od,i=we(i),He(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,X=0,le=0,pe=i,J=null;t:for(;;){for(var ne;pe!==a||u!==0&&pe.nodeType!==3||(E=_+u),pe!==h||l!==0&&pe.nodeType!==3||(N=_+l),pe.nodeType===3&&(_+=pe.nodeValue.length),(ne=pe.firstChild)!==null;)J=pe,pe=ne;for(;;){if(pe===i)break t;if(J===a&&++X===u&&(E=_),J===h&&++le===l&&(N=_),(ne=pe.nextSibling)!==null)break;pe=J,J=pe.parentNode}pe=ne}a=E===-1||N===-1?null:{start:E,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(qp={focusedElem:i,selectionRange:a},Od=!1,qi=r;qi!==null;)if(r=qi,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,qi=i;else for(;qi!==null;){switch(r=qi,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=$a(a.type,u);i=l.getSnapshotBeforeUpdate(Ie,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Xe){Bt(a,a.return,Xe)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)Yp(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Yp(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,qi=i;break}qi=r.return}}function my(i,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:hs(i,a),l&4&&ec(5,a);break;case 1:if(hs(i,a),l&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(_){Bt(a,a.return,_)}else{var u=$a(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(u,r,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Bt(a,a.return,_)}}l&64&&cy(a),l&512&&tc(a,a.return);break;case 3:if(hs(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{J_(i,r)}catch(_){Bt(a,a.return,_)}}break;case 27:r===null&&l&4&&fy(a);case 26:case 5:hs(i,a),r===null&&l&4&&dy(a),l&512&&tc(a,a.return);break;case 12:hs(i,a);break;case 31:hs(i,a),l&4&&_y(i,a);break;case 13:hs(i,a),l&4&&by(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Kk.bind(null,a),lE(i,a))));break;case 22:if(l=a.memoizedState!==null||us,!l){r=r!==null&&r.memoizedState!==null||ki,u=us;var h=ki;us=l,(ki=r)&&!h?fs(i,a,(a.subtreeFlags&8772)!==0):hs(i,a),us=u,ki=h}break;case 30:break;default:hs(i,a)}}function gy(i){var r=i.alternate;r!==null&&(i.alternate=null,gy(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Nr(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 ti=null,Dn=!1;function ds(i,r,a){for(a=a.child;a!==null;)vy(i,r,a),a=a.sibling}function vy(i,r,a){if(Ze&&typeof Ze.onCommitFiberUnmount=="function")try{Ze.onCommitFiberUnmount(nt,a)}catch{}switch(a.tag){case 26:ki||Ir(a,r),ds(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:ki||Ir(a,r);var l=ti,u=Dn;ia(a.type)&&(ti=a.stateNode,Dn=!1),ds(i,r,a),uc(a.stateNode),ti=l,Dn=u;break;case 5:ki||Ir(a,r);case 6:if(l=ti,u=Dn,ti=null,ds(i,r,a),ti=l,Dn=u,ti!==null)if(Dn)try{(ti.nodeType===9?ti.body:ti.nodeName==="HTML"?ti.ownerDocument.body:ti).removeChild(a.stateNode)}catch(h){Bt(a,r,h)}else try{ti.removeChild(a.stateNode)}catch(h){Bt(a,r,h)}break;case 18:ti!==null&&(Dn?(i=ti,cS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),Yo(i)):cS(ti,a.stateNode));break;case 4:l=ti,u=Dn,ti=a.stateNode.containerInfo,Dn=!0,ds(i,r,a),ti=l,Dn=u;break;case 0:case 11:case 14:case 15:Xs(2,a,r),ki||Xs(4,a,r),ds(i,r,a);break;case 1:ki||(Ir(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&uy(a,r,l)),ds(i,r,a);break;case 21:ds(i,r,a);break;case 22:ki=(l=ki)||a.memoizedState!==null,ds(i,r,a),ki=l;break;default:ds(i,r,a)}}function _y(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Yo(i)}catch(a){Bt(r,r.return,a)}}}function by(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Yo(i)}catch(a){Bt(r,r.return,a)}}function Ok(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new py),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new py),r;default:throw Error(s(435,i.tag))}}function pd(i,r){var a=Ok(i);r.forEach(function(l){if(!a.has(l)){a.add(l);var u=Fk.bind(null,i,l);l.then(u,u)}})}function Rn(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(ia(E.type)){ti=E.stateNode,Dn=!1;break e}break;case 5:ti=E.stateNode,Dn=!1;break e;case 3:case 4:ti=E.stateNode.containerInfo,Dn=!0;break e}E=E.return}if(ti===null)throw Error(s(160));vy(h,_,u),ti=null,Dn=!1,h=u.alternate,h!==null&&(h.return=null),u.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)yy(r,i),r=r.sibling}var Tr=null;function yy(i,r){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Rn(r,i),Mn(i),l&4&&(Xs(3,i,i.return),ec(3,i),Xs(5,i,i.return));break;case 1:Rn(r,i),Mn(i),l&512&&(ki||a===null||Ir(a,a.return)),l&64&&us&&(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=Tr;if(Rn(r,i),Mn(i),l&512&&(ki||a===null||Ir(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[Vr]||h[ci]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=u.createElement(l),u.head.insertBefore(h,u.querySelector("head > title"))),an(h,l,a),h[ci]=i,St(h),l=h;break e;case"link":var _=yS("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),an(h,l,a),u.head.appendChild(h);break;case"meta":if(_=yS("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),an(h,l,a),u.head.appendChild(h);break;default:throw Error(s(468,l))}h[ci]=i,St(h),l=h}i.stateNode=l}else SS(u,i.type,i.stateNode);else i.stateNode=bS(u,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?SS(u,i.type,i.stateNode):bS(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&yp(i,i.memoizedProps,a.memoizedProps)}break;case 27:Rn(r,i),Mn(i),l&512&&(ki||a===null||Ir(a,a.return)),a!==null&&l&4&&yp(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Rn(r,i),Mn(i),l&512&&(ki||a===null||Ir(a,a.return)),i.flags&32){u=i.stateNode;try{yr(u,"")}catch(Ie){Bt(i,i.return,Ie)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,yp(i,u,a!==null?a.memoizedProps:u)),l&1024&&(Cp=!0);break;case 6:if(Rn(r,i),Mn(i),l&4){if(i.stateNode===null)throw Error(s(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ie){Bt(i,i.return,Ie)}}break;case 3:if(Md=null,u=Tr,Tr=Dd(r.containerInfo),Rn(r,i),Tr=u,Mn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Yo(r.containerInfo)}catch(Ie){Bt(i,i.return,Ie)}Cp&&(Cp=!1,Sy(i));break;case 4:l=Tr,Tr=Dd(i.stateNode.containerInfo),Rn(r,i),Mn(i),Tr=l;break;case 12:Rn(r,i),Mn(i);break;case 31:Rn(r,i),Mn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,pd(i,l)));break;case 13:Rn(r,i),Mn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(gd=xt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,pd(i,l)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,X=us,le=ki;if(us=X||u,ki=le||N,Rn(r,i),ki=le,us=X,Mn(i),l&8192)e:for(r=i.stateNode,r._visibility=u?r._visibility&-2:r._visibility|1,u&&(a===null||N||us||ki||Va(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 pe=N.memoizedProps.style,J=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;E.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(Ie){Bt(N,N.return,Ie)}}}else if(r.tag===6){if(a===null){N=r;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Ie){Bt(N,N.return,Ie)}}}else if(r.tag===18){if(a===null){N=r;try{var ne=N.stateNode;u?uS(ne,!0):uS(N.stateNode,!1)}catch(Ie){Bt(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,pd(i,a))));break;case 19:Rn(r,i),Mn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,pd(i,l)));break;case 30:break;case 21:break;default:Rn(r,i),Mn(i)}}function Mn(i){var r=i.flags;if(r&2){try{for(var a,l=i.return;l!==null;){if(hy(l)){a=l;break}l=l.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,h=Sp(i);fd(i,h,u);break;case 5:var _=a.stateNode;a.flags&32&&(yr(_,""),a.flags&=-33);var E=Sp(i);fd(i,E,_);break;case 3:case 4:var N=a.stateNode.containerInfo,X=Sp(i);wp(i,X,N);break;default:throw Error(s(161))}}catch(le){Bt(i,i.return,le)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function Sy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;Sy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function hs(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)my(i,r.alternate,r),r=r.sibling}function Va(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Xs(4,r,r.return),Va(r);break;case 1:Ir(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&uy(r,r.return,a),Va(r);break;case 27:uc(r.stateNode);case 26:case 5:Ir(r,r.return),Va(r);break;case 22:r.memoizedState===null&&Va(r);break;case 30:Va(r);break;default:Va(r)}i=i.sibling}}function fs(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:fs(u,h,a),ec(4,h);break;case 1:if(fs(u,h,a),l=h,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(X){Bt(l,l.return,X)}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++)Q_(N[u],E)}catch(X){Bt(l,l.return,X)}}a&&_&64&&cy(h),tc(h,h.return);break;case 27:fy(h);case 26:case 5:fs(u,h,a),a&&l===null&&_&4&&dy(h),tc(h,h.return);break;case 12:fs(u,h,a);break;case 31:fs(u,h,a),a&&_&4&&_y(u,h);break;case 13:fs(u,h,a),a&&_&4&&by(u,h);break;case 22:h.memoizedState===null&&fs(u,h,a),tc(h,h.return);break;case 30:break;default:fs(u,h,a)}r=r.sibling}}function xp(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&&Ul(a))}function kp(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Ul(i))}function Dr(i,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)wy(i,r,a,l),r=r.sibling}function wy(i,r,a,l){var u=r.flags;switch(r.tag){case 0:case 11:case 15:Dr(i,r,a,l),u&2048&&ec(9,r);break;case 1:Dr(i,r,a,l);break;case 3:Dr(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&&Ul(i)));break;case 12:if(u&2048){Dr(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){Bt(r,r.return,N)}}else Dr(i,r,a,l);break;case 31:Dr(i,r,a,l);break;case 13:Dr(i,r,a,l);break;case 23:break;case 22:h=r.stateNode,_=r.alternate,r.memoizedState!==null?h._visibility&2?Dr(i,r,a,l):ic(i,r):h._visibility&2?Dr(i,r,a,l):(h._visibility|=2,zo(i,r,a,l,(r.subtreeFlags&10256)!==0||!1)),u&2048&&xp(_,r);break;case 24:Dr(i,r,a,l),u&2048&&kp(r.alternate,r);break;default:Dr(i,r,a,l)}}function zo(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,X=_.flags;switch(_.tag){case 0:case 11:case 15:zo(h,_,E,N,u),ec(8,_);break;case 23:break;case 22:var le=_.stateNode;_.memoizedState!==null?le._visibility&2?zo(h,_,E,N,u):ic(h,_):(le._visibility|=2,zo(h,_,E,N,u)),u&&X&2048&&xp(_.alternate,_);break;case 24:zo(h,_,E,N,u),u&&X&2048&&kp(_.alternate,_);break;default:zo(h,_,E,N,u)}r=r.sibling}}function ic(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:ic(a,l),u&2048&&xp(l.alternate,l);break;case 24:ic(a,l),u&2048&&kp(l.alternate,l);break;default:ic(a,l)}r=r.sibling}}var nc=8192;function Io(i,r,a){if(i.subtreeFlags&nc)for(i=i.child;i!==null;)Cy(i,r,a),i=i.sibling}function Cy(i,r,a){switch(i.tag){case 26:Io(i,r,a),i.flags&nc&&i.memoizedState!==null&&yE(a,Tr,i.memoizedState,i.memoizedProps);break;case 5:Io(i,r,a);break;case 3:case 4:var l=Tr;Tr=Dd(i.stateNode.containerInfo),Io(i,r,a),Tr=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=nc,nc=16777216,Io(i,r,a),nc=l):Io(i,r,a));break;default:Io(i,r,a)}}function xy(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 rc(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];qi=l,Ey(l,i)}xy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)ky(i),i=i.sibling}function ky(i){switch(i.tag){case 0:case 11:case 15:rc(i),i.flags&2048&&Xs(9,i,i.return);break;case 3:rc(i);break;case 12:rc(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,md(i)):rc(i);break;default:rc(i)}}function md(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];qi=l,Ey(l,i)}xy(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Xs(8,r,r.return),md(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,md(r));break;default:md(r)}i=i.sibling}}function Ey(i,r){for(;qi!==null;){var a=qi;switch(a.tag){case 0:case 11:case 15:Xs(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:Ul(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,qi=l;else e:for(a=i;qi!==null;){l=qi;var u=l.sibling,h=l.return;if(gy(l),l===a){qi=null;break e}if(u!==null){u.return=h,qi=u;break e}qi=h}}}var Bk={getCacheForType:function(i){var r=rn(wi),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return rn(wi).controller.signal}},jk=typeof WeakMap=="function"?WeakMap:Map,At=0,Ft=null,bt=null,wt=0,Ot=0,Fn=null,Gs=!1,Po=!1,Ep=!1,ps=0,hi=0,Zs=0,Ya=0,Tp=0,Wn=0,Ho=0,sc=null,Nn=null,Dp=!1,gd=0,Ty=0,vd=1/0,_d=null,Qs=null,Ni=0,Js=null,Uo=null,ms=0,Rp=0,Mp=null,Dy=null,ac=0,Np=null;function qn(){return(At&2)!==0&&wt!==0?wt&-wt:L.T!==null?zp():en()}function Ry(){if(Wn===0)if((wt&536870912)===0||kt){var i=rt;rt<<=1,(rt&3932160)===0&&(rt=262144),Wn=i}else Wn=536870912;return i=Un.current,i!==null&&(i.flags|=32),Wn}function An(i,r,a){(i===Ft&&(Ot===2||Ot===9)||i.cancelPendingCommit!==null)&&(Ko(i,0),ea(i,wt,Wn,!1)),$t(i,a),((At&2)===0||i!==Ft)&&(i===Ft&&((At&2)===0&&(Ya|=a),hi===4&&ea(i,wt,Wn,!1)),Pr(i))}function My(i,r,a){if((At&6)!==0)throw Error(s(327));var l=!a&&(r&127)===0&&(r&i.expiredLanes)===0||jt(i,r),u=l?Pk(i,r):Lp(i,r,!0),h=l;do{if(u===0){Po&&!l&&ea(i,r,0,!1);break}else{if(a=i.current.alternate,h&&!zk(a)){u=Lp(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=sc;var N=E.current.memoizedState.isDehydrated;if(N&&(Ko(E,_).flags|=256),_=Lp(E,_,!1),_!==2){if(Ep&&!N){E.errorRecoveryDisabledLanes|=h,Ya|=h,u=4;break e}h=Nn,Nn=u,h!==null&&(Nn===null?Nn=h:Nn.push.apply(Nn,h))}u=_}if(h=!1,u!==2)continue}}if(u===1){Ko(i,0),ea(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:ea(l,r,Wn,!Gs);break e;case 2:Nn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(u=gd+300-xt(),10<u)){if(ea(l,r,Wn,!Gs),Lt(l,0,!0)!==0)break e;ms=r,l.timeoutHandle=oS(Ny.bind(null,l,a,Nn,_d,Dp,r,Wn,Ya,Ho,Gs,h,"Throttled",-0,0),u);break e}Ny(l,a,Nn,_d,Dp,r,Wn,Ya,Ho,Gs,h,null,-0,0)}}break}while(!0);Pr(i)}function Ny(i,r,a,l,u,h,_,E,N,X,le,pe,J,ne){if(i.timeoutHandle=-1,pe=r.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dn},Cy(r,h,pe);var Ie=(h&62914560)===h?gd-xt():(h&4194048)===h?Ty-xt():0;if(Ie=SE(pe,Ie),Ie!==null){ms=h,i.cancelPendingCommit=Ie(Py.bind(null,i,r,h,a,l,u,_,E,N,le,pe,null,J,ne)),ea(i,h,_,!X);return}}Py(i,r,h,a,l,u,_,E,N)}function zk(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(!tn(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 ea(i,r,a,l){r&=~Tp,r&=~Ya,i.suspendedLanes|=r,i.pingedLanes&=~r,l&&(i.warmLanes|=r),l=i.expirationTimes;for(var u=r;0<u;){var h=31-ht(u),_=1<<h;l[h]=-1,u&=~_}a!==0&&Ji(i,a,r)}function bd(){return(At&6)===0?(oc(0),!1):!0}function Ap(){if(bt!==null){if(Ot===0)var i=bt.return;else i=bt,rs=Pa=null,Yf(i),Ao=null,Fl=0,i=bt;for(;i!==null;)ly(i.alternate,i),i=i.return;bt=null}}function Ko(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,nE(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),ms=0,Ap(),Ft=i,bt=a=is(i.current,null),wt=r,Ot=0,Fn=null,Gs=!1,Po=jt(i,r),Ep=!1,Ho=Wn=Tp=Ya=Zs=hi=0,Nn=sc=null,Dp=!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-ht(l),h=1<<u;r|=i[u],l&=~h}return ps=r,Hu(),a}function Ay(i,r){ct=null,L.H=Zl,r===No||r===Yu?(r=Y_(),Ot=3):r===jf?(r=Y_(),Ot=4):Ot=r===up?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Fn=r,bt===null&&(hi=1,ld(i,ir(r,i.current)))}function Ly(){var i=Un.current;return i===null?!0:(wt&4194048)===wt?ar===null:(wt&62914560)===wt||(wt&536870912)!==0?i===ar:!1}function Oy(){var i=L.H;return L.H=Zl,i===null?Zl:i}function By(){var i=L.A;return L.A=Bk,i}function yd(){hi=4,Gs||(wt&4194048)!==wt&&Un.current!==null||(Po=!0),(Zs&134217727)===0&&(Ya&134217727)===0||Ft===null||ea(Ft,wt,Wn,!1)}function Lp(i,r,a){var l=At;At|=2;var u=Oy(),h=By();(Ft!==i||wt!==r)&&(_d=null,Ko(i,r)),r=!1;var _=hi;e:do try{if(Ot!==0&&bt!==null){var E=bt,N=Fn;switch(Ot){case 8:Ap(),_=6;break e;case 3:case 2:case 9:case 6:Un.current===null&&(r=!0);var X=Ot;if(Ot=0,Fn=null,Fo(i,E,N,X),a&&Po){_=0;break e}break;default:X=Ot,Ot=0,Fn=null,Fo(i,E,N,X)}}Ik(),_=hi;break}catch(le){Ay(i,le)}while(!0);return r&&i.shellSuspendCounter++,rs=Pa=null,At=l,L.H=u,L.A=h,bt===null&&(Ft=null,wt=0,Hu()),_}function Ik(){for(;bt!==null;)jy(bt)}function Pk(i,r){var a=At;At|=2;var l=Oy(),u=By();Ft!==i||wt!==r?(_d=null,vd=xt()+500,Ko(i,r)):Po=jt(i,r);e:do try{if(Ot!==0&&bt!==null){r=bt;var h=Fn;t:switch(Ot){case 1:Ot=0,Fn=null,Fo(i,r,h,1);break;case 2:case 9:if($_(h)){Ot=0,Fn=null,zy(r);break}r=function(){Ot!==2&&Ot!==9||Ft!==i||(Ot=7),Pr(i)},h.then(r,r);break e;case 3:Ot=7;break e;case 4:Ot=5;break e;case 7:$_(h)?(Ot=0,Fn=null,zy(r)):(Ot=0,Fn=null,Fo(i,r,h,7));break;case 5:var _=null;switch(bt.tag){case 26:_=bt.memoizedState;case 5:case 27:var E=bt;if(_?wS(_):E.stateNode.complete){Ot=0,Fn=null;var N=E.sibling;if(N!==null)bt=N;else{var X=E.return;X!==null?(bt=X,Sd(X)):bt=null}break t}}Ot=0,Fn=null,Fo(i,r,h,5);break;case 6:Ot=0,Fn=null,Fo(i,r,h,6);break;case 8:Ap(),hi=6;break e;default:throw Error(s(462))}}Hk();break}catch(le){Ay(i,le)}while(!0);return rs=Pa=null,L.H=l,L.A=u,At=a,bt!==null?0:(Ft=null,wt=0,Hu(),hi)}function Hk(){for(;bt!==null&&!ot();)jy(bt)}function jy(i){var r=ay(i.alternate,i,ps);i.memoizedProps=i.pendingProps,r===null?Sd(i):bt=r}function zy(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=ey(a,r,r.pendingProps,r.type,void 0,wt);break;case 11:r=ey(a,r,r.pendingProps,r.type.render,r.ref,wt);break;case 5:Yf(r);default:ly(a,r),r=bt=B_(r,ps),r=ay(a,r,ps)}i.memoizedProps=i.pendingProps,r===null?Sd(i):bt=r}function Fo(i,r,a,l){rs=Pa=null,Yf(r),Ao=null,Fl=0;var u=r.return;try{if(Dk(i,u,r,a,wt)){hi=1,ld(i,ir(a,i.current)),bt=null;return}}catch(h){if(u!==null)throw bt=u,h;hi=1,ld(i,ir(a,i.current)),bt=null;return}r.flags&32768?(kt||l===1?i=!0:Po||(wt&536870912)!==0?i=!1:(Gs=i=!0,(l===2||l===9||l===3||l===6)&&(l=Un.current,l!==null&&l.tag===13&&(l.flags|=16384))),Iy(r,i)):Sd(r)}function Sd(i){var r=i;do{if((r.flags&32768)!==0){Iy(r,Gs);return}i=r.return;var a=Nk(r.alternate,r,ps);if(a!==null){bt=a;return}if(r=r.sibling,r!==null){bt=r;return}bt=r=i}while(r!==null);hi===0&&(hi=5)}function Iy(i,r){do{var a=Ak(i.alternate,i);if(a!==null){a.flags&=32767,bt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){bt=i;return}bt=i=a}while(i!==null);hi=6,bt=null}function Py(i,r,a,l,u,h,_,E,N){i.cancelPendingCommit=null;do wd();while(Ni!==0);if((At&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(h=r.lanes|r.childLanes,h|=Sf,Jt(i,a,h,_,E,N),i===Ft&&(bt=Ft=null,wt=0),Uo=r,Js=i,ms=a,Rp=h,Mp=u,Dy=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Wk(Ye,function(){return Wy(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=L.T,L.T=null,u=R.p,R.p=2,_=At,At|=4;try{Lk(i,r,a)}finally{At=_,R.p=u,L.T=l}}Ni=1,Hy(),Uy(),Ky()}}function Hy(){if(Ni===1){Ni=0;var i=Js,r=Uo,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=L.T,L.T=null;var l=R.p;R.p=2;var u=At;At|=4;try{yy(r,i);var h=qp,_=we(i.containerInfo),E=h.focusedElem,N=h.selectionRange;if(_!==E&&E&&E.ownerDocument&&P(E.ownerDocument.documentElement,E)){if(N!==null&&He(E)){var X=N.start,le=N.end;if(le===void 0&&(le=X),"selectionStart"in E)E.selectionStart=X,E.selectionEnd=Math.min(le,E.value.length);else{var pe=E.ownerDocument||document,J=pe&&pe.defaultView||window;if(J.getSelection){var ne=J.getSelection(),Ie=E.textContent.length,Xe=Math.min(N.start,Ie),Pt=N.end===void 0?Xe:Math.min(N.end,Ie);!ne.extend&&Xe>Pt&&(_=Pt,Pt=Xe,Xe=_);var H=S(E,Xe),j=S(E,Pt);if(H&&j&&(ne.rangeCount!==1||ne.anchorNode!==H.node||ne.anchorOffset!==H.offset||ne.focusNode!==j.node||ne.focusOffset!==j.offset)){var Y=pe.createRange();Y.setStart(H.node,H.offset),ne.removeAllRanges(),Xe>Pt?(ne.addRange(Y),ne.extend(j.node,j.offset)):(Y.setEnd(j.node,j.offset),ne.addRange(Y))}}}}for(pe=[],ne=E;ne=ne.parentNode;)ne.nodeType===1&&pe.push({element:ne,left:ne.scrollLeft,top:ne.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<pe.length;E++){var ue=pe[E];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Od=!!Wp,qp=Wp=null}finally{At=u,R.p=l,L.T=a}}i.current=r,Ni=2}}function Uy(){if(Ni===2){Ni=0;var i=Js,r=Uo,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=L.T,L.T=null;var l=R.p;R.p=2;var u=At;At|=4;try{my(i,r.alternate,r)}finally{At=u,R.p=l,L.T=a}}Ni=3}}function Ky(){if(Ni===4||Ni===3){Ni=0,vt();var i=Js,r=Uo,a=ms,l=Dy;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ni=5:(Ni=0,Uo=Js=null,Fy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(Qs=null),Pi(a),r=r.stateNode,Ze&&typeof Ze.onCommitFiberRoot=="function")try{Ze.onCommitFiberRoot(nt,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=L.T,u=R.p,R.p=2,L.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var E=l[_];h(E.value,{componentStack:E.stack})}}finally{L.T=r,R.p=u}}(ms&3)!==0&&wd(),Pr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===Np?ac++:(ac=0,Np=i):ac=0,oc(0)}}function Fy(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Ul(r)))}function wd(){return Hy(),Uy(),Ky(),Wy()}function Wy(){if(Ni!==5)return!1;var i=Js,r=Rp;Rp=0;var a=Pi(ms),l=L.T,u=R.p;try{R.p=32>a?32:a,L.T=null,a=Mp,Mp=null;var h=Js,_=ms;if(Ni=0,Uo=Js=null,ms=0,(At&6)!==0)throw Error(s(331));var E=At;if(At|=4,ky(h.current),wy(h,h.current,_,a),At=E,oc(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(nt,h)}catch{}return!0}finally{R.p=u,L.T=l,Fy(i,r)}}function qy(i,r,a){r=ir(a,r),r=cp(i.stateNode,r,2),i=$s(i,r,2),i!==null&&($t(i,2),Pr(i))}function Bt(i,r,a){if(i.tag===3)qy(i,i,a);else for(;r!==null;){if(r.tag===3){qy(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=ir(a,i),a=$b(2),l=$s(r,a,2),l!==null&&(Vb(a,l,r,i),$t(l,2),Pr(l));break}}r=r.return}}function Op(i,r,a){var l=i.pingCache;if(l===null){l=i.pingCache=new jk;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)||(Ep=!0,u.add(a),i=Uk.bind(null,i,r,a),r.then(i,i))}function Uk(i,r,a){var l=i.pingCache;l!==null&&l.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Ft===i&&(wt&a)===a&&(hi===4||hi===3&&(wt&62914560)===wt&&300>xt()-gd?(At&2)===0&&Ko(i,0):Tp|=a,Ho===wt&&(Ho=0)),Pr(i)}function $y(i,r){r===0&&(r=qt()),i=ja(i,r),i!==null&&($t(i,r),Pr(i))}function Kk(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),$y(i,a)}function Fk(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),$y(i,a)}function Wk(i,r){return Oe(i,r)}var Cd=null,Wo=null,Bp=!1,xd=!1,jp=!1,ta=0;function Pr(i){i!==Wo&&i.next===null&&(Wo===null?Cd=Wo=i:Wo=Wo.next=i),xd=!0,Bp||(Bp=!0,$k())}function oc(i,r){if(!jp&&xd){jp=!0;do for(var a=!1,l=Cd;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-ht(42|i)+1)-1,h&=u&~(_&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,Gy(l,h))}else h=wt,h=Lt(l,l===Ft?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||jt(l,h)||(a=!0,Gy(l,h));l=l.next}while(a);jp=!1}}function qk(){Vy()}function Vy(){xd=Bp=!1;var i=0;ta!==0&&iE()&&(i=ta);for(var r=xt(),a=null,l=Cd;l!==null;){var u=l.next,h=Yy(l,r);h===0?(l.next=null,a===null?Cd=u:a.next=u,u===null&&(Wo=a)):(a=l,(i!==0||(h&3)!==0)&&(xd=!0)),l=u}Ni!==0&&Ni!==5||oc(i),ta!==0&&(ta=0)}function Yy(i,r){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-ht(h),E=1<<_,N=u[_];N===-1?((E&a)===0||(E&l)!==0)&&(u[_]=li(E,r)):N<=r&&(i.expiredLanes|=E),h&=~E}if(r=Ft,a=wt,a=Lt(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===r&&(Ot===2||Ot===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ve(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||jt(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(l!==null&&Ve(l),Pi(a)){case 2:case 8:a=mi;break;case 32:a=Ye;break;case 268435456:a=Vt;break;default:a=Ye}return l=Xy.bind(null,i),a=Oe(a,l),i.callbackPriority=r,i.callbackNode=a,r}return l!==null&&l!==null&&Ve(l),i.callbackPriority=2,i.callbackNode=null,2}function Xy(i,r){if(Ni!==0&&Ni!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(wd()&&i.callbackNode!==a)return null;var l=wt;return l=Lt(i,i===Ft?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(My(i,l,r),Yy(i,xt()),i.callbackNode!=null&&i.callbackNode===a?Xy.bind(null,i):null)}function Gy(i,r){if(wd())return null;My(i,r,!0)}function $k(){rE(function(){(At&6)!==0?Oe(ni,qk):Vy()})}function zp(){if(ta===0){var i=Ro;i===0&&(i=Ke,Ke<<=1,(Ke&261888)===0&&(Ke=256)),ta=i}return ta}function Zy(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Fi(""+i)}function Qy(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 Vk(i,r,a,l,u){if(r==="submit"&&a&&a.stateNode===u){var h=Zy((u[Hi]||null).action),_=l.submitter;_&&(r=(r=_[Hi]||null)?Zy(r.formAction):_.getAttribute("formAction"),r!==null&&(h=r,_=null));var E=new C("action","action",null,l,u);i.push({event:E,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ta!==0){var N=_?Qy(u,_):new FormData(u);np(a,{pending:!0,data:N,method:u.method,action:h},null,N)}}else typeof h=="function"&&(E.preventDefault(),N=_?Qy(u,_):new FormData(u),np(a,{pending:!0,data:N,method:u.method,action:h},h,N))},currentTarget:u}]})}}for(var Ip=0;Ip<yf.length;Ip++){var Pp=yf[Ip],Yk=Pp.toLowerCase(),Xk=Pp[0].toUpperCase()+Pp.slice(1);Er(Yk,"on"+Xk)}Er(zl,"onAnimationEnd"),Er(Il,"onAnimationIteration"),Er(N_,"onAnimationStart"),Er("dblclick","onDoubleClick"),Er("focusin","onFocus"),Er("focusout","onBlur"),Er(dk,"onTransitionRun"),Er(hk,"onTransitionStart"),Er(fk,"onTransitionCancel"),Er(A_,"onTransitionEnd"),mr("onMouseEnter",["mouseout","mouseover"]),mr("onMouseLeave",["mouseout","mouseover"]),mr("onPointerEnter",["pointerout","pointerover"]),mr("onPointerLeave",["pointerout","pointerover"]),zn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),zn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),zn("onBeforeInput",["compositionend","keypress","textInput","paste"]),zn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var lc="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(" "),Gk=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(lc));function Jy(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,X=E.currentTarget;if(E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=X;try{h(u)}catch(le){Pu(le)}u.currentTarget=null,h=N}else for(_=0;_<l.length;_++){if(E=l[_],N=E.instance,X=E.currentTarget,E=E.listener,N!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=X;try{h(u)}catch(le){Pu(le)}u.currentTarget=null,h=N}}}}function yt(i,r){var a=r[$r];a===void 0&&(a=r[$r]=new Set);var l=i+"__bubble";a.has(l)||(eS(r,i,2,!1),a.add(l))}function Hp(i,r,a){var l=0;r&&(l|=4),eS(a,i,l,r)}var kd="_reactListening"+Math.random().toString(36).slice(2);function Up(i){if(!i[kd]){i[kd]=!0,As.forEach(function(a){a!=="selectionchange"&&(Gk.has(a)||Hp(a,!1,i),Hp(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[kd]||(r[kd]=!0,Hp("selectionchange",!1,r))}}function eS(i,r,a,l){switch(RS(r)){case 2:var u=xE;break;case 8:u=kE;break;default:u=im}a=u.bind(null,r,a,i),u=void 0,!js||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 Kp(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(_=Ar(E),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){l=h=_;continue e}E=E.parentNode}}l=l.return}Zr(function(){var X=h,le=Qn(a),pe=[];e:{var J=L_.get(i);if(J!==void 0){var ne=C,Ie=i;switch(i){case"keypress":if(Jr(a)===0)break e;case"keydown":case"keyup":ne=es;break;case"focusin":Ie="focus",ne=xr;break;case"focusout":Ie="blur",ne=xr;break;case"beforeblur":case"afterblur":ne=xr;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":ne=We;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ne=ui;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ne=hf;break;case zl:case Il:case N_:ne=yu;break;case A_:ne=Rl;break;case"scroll":case"scrollend":ne=B;break;case"wheel":ne=bo;break;case"copy":case"cut":case"paste":ne=wu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ne=Tu;break;case"toggle":case"beforetoggle":ne=Ru}var Xe=(r&4)!==0,Pt=!Xe&&(i==="scroll"||i==="scrollend"),H=Xe?J!==null?J+"Capture":null:J;Xe=[];for(var j=X,Y;j!==null;){var ue=j;if(Y=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||Y===null||H===null||(ue=Sr(j,H),ue!=null&&Xe.push(cc(j,ue,Y))),Pt)break;j=j.return}0<Xe.length&&(J=new ne(J,Ie,null,a,le),pe.push({event:J,listeners:Xe}))}}if((r&7)===0){e:{if(J=i==="mouseover"||i==="pointerover",ne=i==="mouseout"||i==="pointerout",J&&a!==Zn&&(Ie=a.relatedTarget||a.fromElement)&&(Ar(Ie)||Ie[Cn]))break e;if((ne||J)&&(J=le.window===le?le:(J=le.ownerDocument)?J.defaultView||J.parentWindow:window,ne?(Ie=a.relatedTarget||a.toElement,ne=X,Ie=Ie?Ar(Ie):null,Ie!==null&&(Pt=c(Ie),Xe=Ie.tag,Ie!==Pt||Xe!==5&&Xe!==27&&Xe!==6)&&(Ie=null)):(ne=null,Ie=X),ne!==Ie)){if(Xe=We,ue="onMouseLeave",H="onMouseEnter",j="mouse",(i==="pointerout"||i==="pointerover")&&(Xe=Tu,ue="onPointerLeave",H="onPointerEnter",j="pointer"),Pt=ne==null?J:Lr(ne),Y=Ie==null?J:Lr(Ie),J=new Xe(ue,j+"leave",ne,a,le),J.target=Pt,J.relatedTarget=Y,ue=null,Ar(le)===X&&(Xe=new Xe(H,j+"enter",Ie,a,le),Xe.target=Y,Xe.relatedTarget=Pt,ue=Xe),Pt=ue,ne&&Ie)t:{for(Xe=Zk,H=ne,j=Ie,Y=0,ue=H;ue;ue=Xe(ue))Y++;ue=0;for(var $e=j;$e;$e=Xe($e))ue++;for(;0<Y-ue;)H=Xe(H),Y--;for(;0<ue-Y;)j=Xe(j),ue--;for(;Y--;){if(H===j||j!==null&&H===j.alternate){Xe=H;break t}H=Xe(H),j=Xe(j)}Xe=null}else Xe=null;ne!==null&&tS(pe,J,ne,Xe,!1),Ie!==null&&Pt!==null&&tS(pe,Pt,Ie,Xe,!0)}}e:{if(J=X?Lr(X):window,ne=J.nodeName&&J.nodeName.toLowerCase(),ne==="select"||ne==="input"&&J.type==="file")var Mt=Ol;else if(Ll(J))if(Ou)Mt=_f;else{Mt=Br;var Pe=Iu}else ne=J.nodeName,!ne||ne.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?X&&Ki(X.elementType)&&(Mt=Ol):Mt=vf;if(Mt&&(Mt=Mt(i,X))){Lu(pe,Mt,a,le);break e}Pe&&Pe(i,J,X),i==="focusout"&&X&&J.type==="number"&&X.memoizedProps.value!=null&&Yr(J,"number",J.value)}switch(Pe=X?Lr(X):window,i){case"focusin":(Ll(Pe)||Pe.contentEditable==="true")&&(Qe=Pe,tt=X,at=null);break;case"focusout":at=tt=Qe=null;break;case"mousedown":qe=!0;break;case"contextmenu":case"mouseup":case"dragend":qe=!1,Kt(pe,a,le);break;case"selectionchange":if(Ge)break;case"keydown":case"keyup":Kt(pe,a,le)}var ut;if(yo)e:{switch(i){case"compositionstart":var Ct="onCompositionStart";break e;case"compositionend":Ct="onCompositionEnd";break e;case"compositionupdate":Ct="onCompositionUpdate";break e}Ct=void 0}else ts?La(i,a)&&(Ct="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Ct="onCompositionStart");Ct&&(Mu&&a.locale!=="ko"&&(ts||Ct!=="onCompositionStart"?Ct==="onCompositionEnd"&&ts&&(ut=Cr()):(hn=le,Na="value"in hn?hn.value:hn.textContent,ts=!0)),Pe=Ed(X,Ct),0<Pe.length&&(Ct=new Wi(Ct,i,null,a,le),pe.push({event:Ct,listeners:Pe}),ut?Ct.data=ut:(ut=Al(a),ut!==null&&(Ct.data=ut)))),(ut=pf?mf(i,a):Nu(i,a))&&(Ct=Ed(X,"onBeforeInput"),0<Ct.length&&(Pe=new Wi("onBeforeInput","beforeinput",null,a,le),pe.push({event:Pe,listeners:Ct}),Pe.data=ut)),Vk(pe,i,X,a,le)}Jy(pe,r)})}function cc(i,r,a){return{instance:i,listener:r,currentTarget:a}}function Ed(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=Sr(i,a),u!=null&&l.unshift(cc(i,u,h)),u=Sr(i,r),u!=null&&l.push(cc(i,u,h))),i.tag===3)return l;i=i.return}return[]}function Zk(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function tS(i,r,a,l,u){for(var h=r._reactName,_=[];a!==null&&a!==l;){var E=a,N=E.alternate,X=E.stateNode;if(E=E.tag,N!==null&&N===l)break;E!==5&&E!==26&&E!==27||X===null||(N=X,u?(X=Sr(a,h),X!=null&&_.unshift(cc(a,X,N))):u||(X=Sr(a,h),X!=null&&_.push(cc(a,X,N)))),a=a.return}_.length!==0&&i.push({event:r,listeners:_})}var Qk=/\r\n?/g,Jk=/\u0000|\uFFFD/g;function iS(i){return(typeof i=="string"?i:""+i).replace(Qk,`
|
|
10
|
-
`).replace(Jk,"")}function nS(i,r){return r=iS(r),iS(i)===r}function It(i,r,a,l,u,h){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||yr(i,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&yr(i,""+l);break;case"className":_r(i,"class",l);break;case"tabIndex":_r(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":_r(i,a,l);break;case"style":xl(i,l,h);break;case"data":if(r!=="object"){_r(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=Fi(""+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"&&It(i,r,"name",u.name,u,null),It(i,r,"formEncType",u.formEncType,u,null),It(i,r,"formMethod",u.formMethod,u,null),It(i,r,"formTarget",u.formTarget,u,null)):(It(i,r,"encType",u.encType,u,null),It(i,r,"method",u.method,u,null),It(i,r,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Fi(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=dn);break;case"onScroll":l!=null&&yt("scroll",i);break;case"onScrollEnd":l!=null&&yt("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=Fi(""+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":yt("beforetoggle",i),yt("toggle",i),vr(i,"popover",l);break;case"xlinkActuate":ri(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":ri(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":ri(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":ri(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":ri(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":ri(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":ri(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":ri(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":ri(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":vr(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=kl.get(a)||a,vr(i,a,l))}}function Fp(i,r,a,l,u,h){switch(a){case"style":xl(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"?yr(i,l):(typeof l=="number"||typeof l=="bigint")&&yr(i,""+l);break;case"onScroll":l!=null&&yt("scroll",i);break;case"onScrollEnd":l!=null&&yt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=dn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!un.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[Hi]||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,""):vr(i,a,l)}}}function an(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":yt("error",i),yt("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:It(i,r,h,_,a,null)}}u&&It(i,r,"srcSet",a.srcSet,a,null),l&&It(i,r,"src",a.src,a,null);return;case"input":yt("invalid",i);var E=h=_=u=null,N=null,X=null;for(l in a)if(a.hasOwnProperty(l)){var le=a[l];if(le!=null)switch(l){case"name":u=le;break;case"type":_=le;break;case"checked":N=le;break;case"defaultChecked":X=le;break;case"value":h=le;break;case"defaultValue":E=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,r));break;default:It(i,r,l,le,a,null)}}xn(i,h,E,N,X,_,u,!1);return;case"select":yt("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:It(i,r,u,E,a,null)}r=h,a=_,i.multiple=!!l,r!=null?In(i,!!l,r,!1):a!=null&&In(i,!!l,a,!0);return;case"textarea":yt("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:It(i,r,_,E,a,null)}Ra(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":It(i,r,N,l,a,null));return;case"dialog":yt("beforetoggle",i),yt("toggle",i),yt("cancel",i),yt("close",i);break;case"iframe":case"object":yt("load",i);break;case"video":case"audio":for(l=0;l<lc.length;l++)yt(lc[l],i);break;case"image":yt("error",i),yt("load",i);break;case"details":yt("toggle",i);break;case"embed":case"source":case"link":yt("error",i),yt("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(X in a)if(a.hasOwnProperty(X)&&(l=a[X],l!=null))switch(X){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:It(i,r,X,l,a,null)}return;default:if(Ki(r)){for(le in a)a.hasOwnProperty(le)&&(l=a[le],l!==void 0&&Fp(i,r,le,l,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(l=a[E],l!=null&&It(i,r,E,l,a,null))}function eE(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,X=null,le=null;for(ne in a){var pe=a[ne];if(a.hasOwnProperty(ne)&&pe!=null)switch(ne){case"checked":break;case"value":break;case"defaultValue":N=pe;default:l.hasOwnProperty(ne)||It(i,r,ne,null,l,pe)}}for(var J in l){var ne=l[J];if(pe=a[J],l.hasOwnProperty(J)&&(ne!=null||pe!=null))switch(J){case"type":h=ne;break;case"name":u=ne;break;case"checked":X=ne;break;case"defaultChecked":le=ne;break;case"value":_=ne;break;case"defaultValue":E=ne;break;case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(s(137,r));break;default:ne!==pe&&It(i,r,J,ne,l,pe)}}pt(i,_,E,N,X,le,h,u);return;case"select":ne=_=E=J=null;for(h in a)if(N=a[h],a.hasOwnProperty(h)&&N!=null)switch(h){case"value":break;case"multiple":ne=N;default:l.hasOwnProperty(h)||It(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":J=h;break;case"defaultValue":E=h;break;case"multiple":_=h;default:h!==N&&It(i,r,u,h,l,N)}r=E,a=_,l=ne,J!=null?In(i,!!a,J,!1):!!l!=!!a&&(r!=null?In(i,!!a,r,!0):In(i,!!a,a?[]:"",!1));return;case"textarea":ne=J=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:It(i,r,E,null,l,u)}for(_ in l)if(u=l[_],h=a[_],l.hasOwnProperty(_)&&(u!=null||h!=null))switch(_){case"value":J=u;break;case"defaultValue":ne=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==h&&It(i,r,_,u,l,h)}Or(i,J,ne);return;case"option":for(var Ie in a)J=a[Ie],a.hasOwnProperty(Ie)&&J!=null&&!l.hasOwnProperty(Ie)&&(Ie==="selected"?i.selected=!1:It(i,r,Ie,null,l,J));for(N in l)J=l[N],ne=a[N],l.hasOwnProperty(N)&&J!==ne&&(J!=null||ne!=null)&&(N==="selected"?i.selected=J&&typeof J!="function"&&typeof J!="symbol":It(i,r,N,J,l,ne));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)J=a[Xe],a.hasOwnProperty(Xe)&&J!=null&&!l.hasOwnProperty(Xe)&&It(i,r,Xe,null,l,J);for(X in l)if(J=l[X],ne=a[X],l.hasOwnProperty(X)&&J!==ne&&(J!=null||ne!=null))switch(X){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(s(137,r));break;default:It(i,r,X,J,l,ne)}return;default:if(Ki(r)){for(var Pt in a)J=a[Pt],a.hasOwnProperty(Pt)&&J!==void 0&&!l.hasOwnProperty(Pt)&&Fp(i,r,Pt,void 0,l,J);for(le in l)J=l[le],ne=a[le],!l.hasOwnProperty(le)||J===ne||J===void 0&&ne===void 0||Fp(i,r,le,J,l,ne);return}}for(var H in a)J=a[H],a.hasOwnProperty(H)&&J!=null&&!l.hasOwnProperty(H)&&It(i,r,H,null,l,J);for(pe in l)J=l[pe],ne=a[pe],!l.hasOwnProperty(pe)||J===ne||J==null&&ne==null||It(i,r,pe,J,l,ne)}function rS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function tE(){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&&rS(_)){for(_=0,E=u.responseEnd,l+=1;l<a.length;l++){var N=a[l],X=N.startTime;if(X>E)break;var le=N.transferSize,pe=N.initiatorType;le&&rS(pe)&&(N=N.responseEnd,_+=le*(N<E?1:(E-X)/(N-X)))}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 Wp=null,qp=null;function Td(i){return i.nodeType===9?i:i.ownerDocument}function sS(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 aS(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 $p(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 Vp=null;function iE(){var i=window.event;return i&&i.type==="popstate"?i===Vp?!1:(Vp=i,!0):(Vp=null,!1)}var oS=typeof setTimeout=="function"?setTimeout:void 0,nE=typeof clearTimeout=="function"?clearTimeout:void 0,lS=typeof Promise=="function"?Promise:void 0,rE=typeof queueMicrotask=="function"?queueMicrotask:typeof lS<"u"?function(i){return lS.resolve(null).then(i).catch(sE)}:oS;function sE(i){setTimeout(function(){throw i})}function ia(i){return i==="head"}function cS(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),Yo(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")uc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,uc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,E=h.nodeName;h[Vr]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&uc(i.ownerDocument.body);a=u}while(a);Yo(r)}function uS(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 Yp(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":Yp(a),Nr(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function aE(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[Vr])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=or(i.nextSibling),i===null)break}return null}function oE(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=or(i.nextSibling),i===null))return null;return i}function dS(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=or(i.nextSibling),i===null))return null;return i}function Xp(i){return i.data==="$?"||i.data==="$~"}function Gp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function lE(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 or(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 Zp=null;function hS(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return or(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function fS(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 pS(i,r,a){switch(r=Td(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 uc(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Nr(i)}var lr=new Map,mS=new Set;function Dd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var gs=R.d;R.d={f:cE,r:uE,D:dE,C:hE,L:fE,m:pE,X:gE,S:mE,M:vE};function cE(){var i=gs.f(),r=bd();return i||r}function uE(i){var r=cn(i);r!==null&&r.tag===5&&r.type==="form"?Ab(r):gs.r(i)}var qo=typeof document>"u"?null:document;function gS(i,r,a){var l=qo;if(l&&typeof r=="string"&&r){var u=Ui(r);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),mS.has(u)||(mS.add(u),i={rel:i,crossOrigin:a,href:r},l.querySelector(u)===null&&(r=l.createElement("link"),an(r,"link",i),St(r),l.head.appendChild(r)))}}function dE(i){gs.D(i),gS("dns-prefetch",i,null)}function hE(i,r){gs.C(i,r),gS("preconnect",i,r)}function fE(i,r,a){gs.L(i,r,a);var l=qo;if(l&&i&&r){var u='link[rel="preload"][as="'+Ui(r)+'"]';r==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Ui(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Ui(a.imageSizes)+'"]')):u+='[href="'+Ui(i)+'"]';var h=u;switch(r){case"style":h=$o(i);break;case"script":h=Vo(i)}lr.has(h)||(i=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),lr.set(h,i),l.querySelector(u)!==null||r==="style"&&l.querySelector(dc(h))||r==="script"&&l.querySelector(hc(h))||(r=l.createElement("link"),an(r,"link",i),St(r),l.head.appendChild(r)))}}function pE(i,r){gs.m(i,r);var a=qo;if(a&&i){var l=r&&typeof r.as=="string"?r.as:"script",u='link[rel="modulepreload"][as="'+Ui(l)+'"][href="'+Ui(i)+'"]',h=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Vo(i)}if(!lr.has(h)&&(i=b({rel:"modulepreload",href:i},r),lr.set(h,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(hc(h)))return}l=a.createElement("link"),an(l,"link",i),St(l),a.head.appendChild(l)}}}function mE(i,r,a){gs.S(i,r,a);var l=qo;if(l&&i){var u=Gn(l).hoistableStyles,h=$o(i);r=r||"default";var _=u.get(h);if(!_){var E={loading:0,preload:null};if(_=l.querySelector(dc(h)))E.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":r},a),(a=lr.get(h))&&Qp(i,a);var N=_=l.createElement("link");St(N),an(N,"link",i),N._p=new Promise(function(X,le){N.onload=X,N.onerror=le}),N.addEventListener("load",function(){E.loading|=1}),N.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Rd(_,r,l)}_={type:"stylesheet",instance:_,count:1,state:E},u.set(h,_)}}}function gE(i,r){gs.X(i,r);var a=qo;if(a&&i){var l=Gn(a).hoistableScripts,u=Vo(i),h=l.get(u);h||(h=a.querySelector(hc(u)),h||(i=b({src:i,async:!0},r),(r=lr.get(u))&&Jp(i,r),h=a.createElement("script"),St(h),an(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function vE(i,r){gs.M(i,r);var a=qo;if(a&&i){var l=Gn(a).hoistableScripts,u=Vo(i),h=l.get(u);h||(h=a.querySelector(hc(u)),h||(i=b({src:i,async:!0,type:"module"},r),(r=lr.get(u))&&Jp(i,r),h=a.createElement("script"),St(h),an(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function vS(i,r,a,l){var u=(u=xe.current)?Dd(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=$o(a.href),a=Gn(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=$o(a.href);var h=Gn(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(dc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),lr.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},lr.set(i,a),h||_E(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=Vo(a),a=Gn(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 $o(i){return'href="'+Ui(i)+'"'}function dc(i){return'link[rel="stylesheet"]['+i+"]"}function _S(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function _E(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}),an(r,"link",a),St(r),i.head.appendChild(r))}function Vo(i){return'[src="'+Ui(i)+'"]'}function hc(i){return"script[async]"+i}function bS(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=i.querySelector('style[data-href~="'+Ui(a.href)+'"]');if(l)return r.instance=l,St(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"),St(l),an(l,"style",u),Rd(l,a.precedence,i),r.instance=l;case"stylesheet":u=$o(a.href);var h=i.querySelector(dc(u));if(h)return r.state.loading|=4,r.instance=h,St(h),h;l=_S(a),(u=lr.get(u))&&Qp(l,u),h=(i.ownerDocument||i).createElement("link"),St(h);var _=h;return _._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),an(h,"link",l),r.state.loading|=4,Rd(h,a.precedence,i),r.instance=h;case"script":return h=Vo(a.src),(u=i.querySelector(hc(h)))?(r.instance=u,St(u),u):(l=a,(u=lr.get(h))&&(l=b({},a),Jp(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),St(u),an(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,Rd(l,a.precedence,i));return r.instance}function Rd(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 Qp(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Jp(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var Md=null;function yS(i,r,a){if(Md===null){var l=new Map,u=Md=new Map;u.set(a,l)}else u=Md,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[Vr]||h[ci]||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 SS(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function bE(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 wS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function yE(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=$o(l.href),h=r.querySelector(dc(u));if(h){r=h._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Nd.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=h,St(h);return}h=r.ownerDocument||r,l=_S(l),(u=lr.get(u))&&Qp(l,u),h=h.createElement("link"),St(h);var _=h;_._p=new Promise(function(E,N){_.onload=E,_.onerror=N}),an(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=Nd.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var em=0;function SE(i,r){return i.stylesheets&&i.count===0&&Ld(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&Ld(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+r);0<i.imgBytes&&em===0&&(em=62500*tE());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ld(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>em?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function Nd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ld(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ad=null;function Ld(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ad=new Map,r.forEach(wE,i),Ad=null,Nd.call(i))}function wE(i,r){if(!(r.state.loading&4)){var a=Ad.get(i);if(a)var l=a.get(null);else{a=new Map,Ad.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=Nd.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 fc={$$typeof:$,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function CE(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=Ri(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ri(0),this.hiddenUpdates=Ri(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 CS(i,r,a,l,u,h,_,E,N,X,le,pe){return i=new CE(i,r,a,_,N,X,le,pe,E),r=1,h===!0&&(r|=24),h=Hn(3,null,null,r),i.current=h,h.stateNode=i,r=Lf(),r.refCount++,i.pooledCache=r,r.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:r},zf(h),i}function xS(i){return i?(i=xo,i):xo}function kS(i,r,a,l,u,h){u=xS(u),l.context===null?l.context=u:l.pendingContext=u,l=qs(r),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=$s(i,l,r),a!==null&&(An(a,i,r),ql(a,i,r))}function ES(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function tm(i,r){ES(i,r),(i=i.alternate)&&ES(i,r)}function TS(i){if(i.tag===13||i.tag===31){var r=ja(i,67108864);r!==null&&An(r,i,67108864),tm(i,67108864)}}function DS(i){if(i.tag===13||i.tag===31){var r=qn();r=Ii(r);var a=ja(i,r);a!==null&&An(a,i,r),tm(i,r)}}var Od=!0;function xE(i,r,a,l){var u=L.T;L.T=null;var h=R.p;try{R.p=2,im(i,r,a,l)}finally{R.p=h,L.T=u}}function kE(i,r,a,l){var u=L.T;L.T=null;var h=R.p;try{R.p=8,im(i,r,a,l)}finally{R.p=h,L.T=u}}function im(i,r,a,l){if(Od){var u=nm(l);if(u===null)Kp(i,r,l,Bd,a),MS(i,l);else if(TE(u,i,r,a,l))l.stopPropagation();else if(MS(i,l),r&4&&-1<EE.indexOf(i)){for(;u!==null;){var h=cn(u);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=Rt(h.pendingLanes);if(_!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;_;){var N=1<<31-ht(_);E.entanglements[1]|=N,_&=~N}Pr(h),(At&6)===0&&(vd=xt()+500,oc(0))}}break;case 31:case 13:E=ja(h,2),E!==null&&An(E,h,2),bd(),tm(h,2)}if(h=nm(l),h===null&&Kp(i,r,l,Bd,a),h===u)break;u=h}u!==null&&l.stopPropagation()}else Kp(i,r,l,null,a)}}function nm(i){return i=Qn(i),rm(i)}var Bd=null;function rm(i){if(Bd=null,i=Ar(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 Bd=i,null}function RS(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(jn()){case ni:return 2;case mi:return 8;case Ye:case ft:return 32;case Vt:return 268435456;default:return 32}default:return 32}}var sm=!1,na=null,ra=null,sa=null,pc=new Map,mc=new Map,aa=[],EE="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 MS(i,r){switch(i){case"focusin":case"focusout":na=null;break;case"dragenter":case"dragleave":ra=null;break;case"mouseover":case"mouseout":sa=null;break;case"pointerover":case"pointerout":pc.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":mc.delete(r.pointerId)}}function gc(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=cn(r),r!==null&&TS(r)),i):(i.eventSystemFlags|=l,r=i.targetContainers,u!==null&&r.indexOf(u)===-1&&r.push(u),i)}function TE(i,r,a,l,u){switch(r){case"focusin":return na=gc(na,i,r,a,l,u),!0;case"dragenter":return ra=gc(ra,i,r,a,l,u),!0;case"mouseover":return sa=gc(sa,i,r,a,l,u),!0;case"pointerover":var h=u.pointerId;return pc.set(h,gc(pc.get(h)||null,i,r,a,l,u)),!0;case"gotpointercapture":return h=u.pointerId,mc.set(h,gc(mc.get(h)||null,i,r,a,l,u)),!0}return!1}function NS(i){var r=Ar(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(){DS(a)});return}}else if(r===31){if(r=m(a),r!==null){i.blockedOn=r,ln(i.priority,function(){DS(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 jd(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=nm(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Zn=l,a.target.dispatchEvent(l),Zn=null}else return r=cn(a),r!==null&&TS(r),i.blockedOn=a,!1;r.shift()}return!0}function AS(i,r,a){jd(i)&&a.delete(r)}function DE(){sm=!1,na!==null&&jd(na)&&(na=null),ra!==null&&jd(ra)&&(ra=null),sa!==null&&jd(sa)&&(sa=null),pc.forEach(AS),mc.forEach(AS)}function zd(i,r){i.blockedOn===r&&(i.blockedOn=null,sm||(sm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,DE)))}var Id=null;function LS(i){Id!==i&&(Id=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Id===i&&(Id=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(rm(l||a)===null)continue;break}var h=cn(a);h!==null&&(i.splice(r,3),r-=3,np(h,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function Yo(i){function r(N){return zd(N,i)}na!==null&&zd(na,i),ra!==null&&zd(ra,i),sa!==null&&zd(sa,i),pc.forEach(r),mc.forEach(r);for(var a=0;a<aa.length;a++){var l=aa[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<aa.length&&(a=aa[0],a.blockedOn===null);)NS(a),a.blockedOn===null&&aa.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[Hi]||null;if(typeof h=="function")_||LS(a);else if(_){var E=null;if(h&&h.hasAttribute("formAction")){if(u=h,_=h[Hi]||null)E=_.formAction;else if(rm(u)!==null)continue}else E=_.action;typeof E=="function"?a[l+1]=E:(a.splice(l,3),l-=3),LS(a)}}}function OS(){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 am(i){this._internalRoot=i}Pd.prototype.render=am.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,l=qn();kS(a,l,i,r,null,null)},Pd.prototype.unmount=am.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;kS(i.current,2,null,i,null,null),bd(),r[Cn]=null}};function Pd(i){this._internalRoot=i}Pd.prototype.unstable_scheduleHydration=function(i){if(i){var r=en();i={blockedOn:null,target:i,priority:r};for(var a=0;a<aa.length&&r!==0&&r<aa[a].priority;a++);aa.splice(a,0,i),a===0&&NS(i)}};var BS=t.version;if(BS!=="19.2.6")throw Error(s(527,BS,"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 RE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hd.isDisabled&&Hd.supportsFiber)try{nt=Hd.inject(RE),Ze=Hd}catch{}}return _c.createRoot=function(i,r){if(!o(i))throw Error(s(299));var a=!1,l="",u=Kb,h=Fb,_=Wb;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=CS(i,1,!1,null,null,a,l,null,u,h,_,OS),i[Cn]=r.current,Up(i),new am(r)},_c.hydrateRoot=function(i,r,a){if(!o(i))throw Error(s(299));var l=!1,u="",h=Kb,_=Fb,E=Wb,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=CS(i,1,!0,r,a??null,l,u,N,h,_,E,OS),r.context=xS(null),a=r.current,l=qn(),l=Ii(l),u=qs(l),u.callback=null,$s(a,u,l),a=l,r.current.lanes=a,$t(r,a),Pr(r),i[Cn]=r.current,Up(i),new Pd(r)},_c.version="19.2.6",_c}var qS;function PE(){if(qS)return cm.exports;qS=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(),cm.exports=IE(),cm.exports}var HE=PE();class On extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Kh(e=fetch){return{getSession:(t={})=>Re(e,`/api/auth/session${ga(t)}`),setupPassword:t=>Re(e,"/api/auth/password",Je("POST",t)),login:t=>Re(e,"/api/auth/login",Je("POST",t)),reauth:t=>Re(e,"/api/auth/reauth",Je("POST",t)),logout:()=>Re(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Re(e,"/api/client-diagnostics",Je("POST",t)),setupTotp:()=>Re(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Re(e,"/api/auth/totp/activate",Je("POST",t)),disableTotp:()=>Re(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Re(e,"/api/auth/devices"),revokeDevice:async t=>{await Qo(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Re(e,"/api/auth/networks"),addNetwork:t=>Re(e,"/api/auth/networks",Je("POST",t)),removeNetwork:async t=>{await Qo(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Re(e,"/api/agents"),addAgent:t=>Re(e,"/api/agents",Je("POST",t)),reorderAgents:t=>Re(e,"/api/agents/order",Je("PUT",{serverIds:t})),renameAgent:(t,n)=>Re(e,`/api/agents/${encodeURIComponent(t)}`,Je("PATCH",{name:n})),getMainInfo:()=>Re(e,"/api/main"),renameMain:t=>Re(e,"/api/main",Je("PATCH",{name:t})),removeAgent:async t=>{await Qo(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Re(e,"/api/stats"),getAgentStats:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Re(e,"/api/version"),checkUpdate:()=>Re(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Re(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Re(e,`/api/code-server/status${ga(t)}`),installCodeServer:()=>Re(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Re(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Re(e,"/api/code-server/open",Je("POST",t)),stopCodeServer:(t={})=>Re(e,"/api/code-server/stop",Je("POST",t)),uninstallCodeServer:()=>Re(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>Re(e,"/api/terminals"),getTerminalLayout:()=>Re(e,"/api/terminal-layout"),saveTerminalLayout:t=>Re(e,"/api/terminal-layout",Je("PUT",t)),createFileRoot:t=>Re(e,"/api/files/root",Je("POST",t)),listFiles:t=>Re(e,"/api/files/list",Je("POST",t)),readFile:t=>Re(e,"/api/files/read",Je("POST",t)),writeFile:t=>Re(e,"/api/files/write",Je("POST",t)),createFileEntry:t=>Re(e,"/api/files/create",Je("POST",t)),moveFileEntry:t=>Re(e,"/api/files/move",Je("POST",t)),previewDeleteFileEntry:t=>Re(e,"/api/files/delete-preview",Je("POST",t)),deleteFileEntry:t=>Re(e,"/api/files/delete",Je("POST",t)),openFileInTerminal:t=>Re(e,"/api/files/open",Je("POST",t)),previewFile:t=>l1(e,"/api/files/preview",Je("POST",t)),createTerminal:(t={})=>Re(e,"/api/terminals",Je("POST",t)),closeTerminal:async t=>{await Qo(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Re(e,`/api/terminals/${encodeURIComponent(t)}`,Je("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Re(e,`/api/terminals/${encodeURIComponent(t)}/history${ga(n)}`),getTerminalTranscriptHistory:(t,n={})=>Re(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${ga(n)}`),getTerminalTranscriptSource:t=>Re(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Re(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Re(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Re(e,"/api/notification-assets/selection",Je("PUT",t)),deleteNotificationAsset:async t=>{await Qo(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Re(e,`/api/push-notifications/status${t||n?ga({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Re(e,"/api/push-notifications/prepare",Je("POST",{clientId:t})),subscribePushNotifications:t=>Re(e,"/api/push-notifications/subscription",Je("POST",t)),updatePushNotificationDevice:t=>Re(e,"/api/push-notifications/device",Je("PATCH",t)),unsubscribePushNotifications:t=>Re(e,"/api/push-notifications/unsubscribe",Je("POST",t)),updatePushPresence:t=>Re(e,"/api/push-notifications/presence",Je("POST",t)),testPushNotification:t=>Re(e,"/api/push-notifications/test",Je("POST",t))}}function ol(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Re(t,n("terminals")),createTerminal:(s={})=>Re(t,n("terminals"),Je("POST",s)),closeTerminal:async s=>{await Qo(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>Re(t,n(`terminals/${encodeURIComponent(s)}`),Je("PATCH",{title:o})),getTerminalHistory:(s,o={})=>Re(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${ga(o)}`),getTerminalTranscriptHistory:(s,o={})=>Re(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${ga(o)}`),getTerminalTranscriptSource:s=>Re(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Re(t,n("terminal-layout")),saveTerminalLayout:s=>Re(t,n("terminal-layout"),Je("PUT",s)),createFileRoot:s=>Re(t,n("files/root"),Je("POST",s)),listFiles:s=>Re(t,n("files/list"),Je("POST",s)),readFile:s=>Re(t,n("files/read"),Je("POST",s)),writeFile:s=>Re(t,n("files/write"),Je("POST",s)),createFileEntry:s=>Re(t,n("files/create"),Je("POST",s)),moveFileEntry:s=>Re(t,n("files/move"),Je("POST",s)),previewDeleteFileEntry:s=>Re(t,n("files/delete-preview"),Je("POST",s)),deleteFileEntry:s=>Re(t,n("files/delete"),Je("POST",s)),openFileInTerminal:s=>Re(t,n("files/open"),Je("POST",s)),previewFile:s=>l1(t,n("files/preview"),Je("POST",s)),getCodeServerStatus:(s={})=>Re(t,`${n("code-server/status")}${ga(s)}`),installCodeServer:()=>Re(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Re(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>Re(t,n("code-server/open"),Je("POST",s)),stopCodeServer:(s={})=>Re(t,n("code-server/stop"),Je("POST",s)),uninstallCodeServer:()=>Re(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,o=window.location.href)=>UE(n(`terminals/${encodeURIComponent(s)}/ws`),o)}}function UE(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 Je(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function ga(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),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 Re(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await jv(s);try{return await s.json()}catch{throw new On(s.status,"invalid_json_response")}}async function Qo(e,t,n){const s=await e(t,n);await jv(s)}async function l1(e,t,n){const s=await e(t,n);return await jv(s),s.blob()}async function jv(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 On(e.status,t)}const zv="nterminal.theme.id",c1="nterminal.theme.accent",Zm="nterminal:theme",bh=[{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",...$S({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",...$S({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],ll="midnight";function Fh(e){return bh.some(t=>t.id===e)?e:ll}function Iv(e){return bh.find(t=>t.id===e)??bh[0]}function Sa(){if(typeof window>"u")return ll;try{const e=window.localStorage.getItem(zv);return e?Fh(e):$E(window.localStorage.getItem(c1))}catch{return ll}}function KE(e){const t=Fh(e);if(typeof window<"u"){try{window.localStorage.setItem(zv,t)}catch{}Pv(t),window.dispatchEvent(new CustomEvent(Zm,{detail:t}))}return t}function Pv(e=Sa()){if(typeof document>"u")return;const t=Iv(Fh(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),dt(n,"--nt-bg",t.tokens.bg),dt(n,"--nt-bg-2",t.tokens.bg2),dt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),dt(n,"--nt-line",t.tokens.line),dt(n,"--nt-line-2",t.tokens.line2),dt(n,"--nt-fg",t.tokens.fg),dt(n,"--nt-fg-2",t.tokens.fg2),dt(n,"--nt-fg-3",t.tokens.fg3),dt(n,"--nt-fg-4",t.tokens.fg4),dt(n,"--nt-accent",t.tokens.accent),dt(n,"--nt-accent-soft",t.tokens.accentSoft),dt(n,"--nt-accent-glow",t.tokens.accentGlow),dt(n,"--nt-on-accent",t.tokens.onAccent),dt(n,"--nt-ok",t.tokens.ok),dt(n,"--nt-danger",t.tokens.danger),dt(n,"--nt-on-danger",t.tokens.onDanger),dt(n,"--nt-danger-soft",t.tokens.dangerSoft),dt(n,"--nt-danger-line",t.tokens.dangerLine),dt(n,"--nt-warning",t.tokens.warning),dt(n,"--nt-warn",t.tokens.warning),dt(n,"--nt-warning-soft",t.tokens.warningSoft),dt(n,"--nt-warning-glow",t.tokens.warningGlow),dt(n,"--nt-scrim",t.tokens.scrim),dt(n,"--nt-scrim-soft",t.tokens.scrimSoft),dt(n,"--nt-shadow",t.tokens.shadow),dt(n,"--nt-shadow-strong",t.tokens.shadowStrong),dt(n,"--nt-floating-bg",t.tokens.floatingBg),dt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),dt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),dt(n,"--nt-subtle-fill",t.tokens.subtleFill),dt(n,"--nt-hover-fill",t.tokens.hoverFill),dt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),dt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),dt(n,"--nt-transcript-user",t.tokens.transcriptUser),dt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),dt(n,"--nt-transcript-tool",t.tokens.transcriptTool),dt(n,"--nt-transcript-command",t.tokens.transcriptCommand),dt(n,"--nt-transcript-code",t.tokens.transcriptCode),dt(n,"--nt-transcript-search",t.tokens.transcriptSearch),dt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),dt(n,"--nt-qr-bg",t.tokens.qrBg)}function FE(e=Sa()){return Iv(Fh(e)).xterm}function Hv(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===zv||n.key===c1)&&(Pv(Sa()),e())};return window.addEventListener(Zm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Zm,e),window.removeEventListener("storage",t)}}function dt(e,t,n){e.style.setProperty(t,n)}function $S(e){const t=WE(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 WE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(qE(n));return t}function qE(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 VS(s,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return VS(t,t,t)}return"#000000"}function VS(e,t,n){return`#${fm(e)}${fm(t)}${fm(n)}`}function fm(e){return e.toString(16).padStart(2,"0")}function $E(e){return e==="signal-red"?"signal-red":ll}function u1(){const e=v.useSyncExternalStore(Hv,Sa,()=>ll);return Iv(e).mode==="light"?"-light":""}function d1({size:e=22}){const t=u1();return p.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function h1({height:e=18}){const t=u1(),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 Rc=o1();const Wh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Uv(e){return"nodeType"in e}function Bn(e){var t,n;return e?pl(e)?e:Uv(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Kv(e){const{Document:t}=Bn(e);return e instanceof t}function uu(e){return pl(e)?!1:e instanceof Bn(e).HTMLElement}function f1(e){return e instanceof Bn(e).SVGElement}function ml(e){return e?pl(e)?e.document:Uv(e)?Kv(e)?e:uu(e)||f1(e)?e.ownerDocument:document:document:document}const wa=Wh?v.useLayoutEffect:v.useEffect;function Fv(e){const t=v.useRef(e);return wa(()=>{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 VE(){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 Yc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return wa(()=>{n.current!==e&&(n.current=e)},t),n}function du(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function yh(e){const t=Fv(e),n=v.useRef(null),s=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,s]}function Qm(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let pm={};function qh(e,t){return v.useMemo(()=>{if(t)return t;const n=pm[e]==null?0:pm[e]+1;return pm[e]=n,e+"-"+n},[e,t])}function p1(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 sl=p1(1),Sh=p1(-1);function YE(e){return"clientX"in e&&"clientY"in e}function m1(e){if(!e)return!1;const{KeyboardEvent:t}=Bn(e.target);return t&&e instanceof t}function XE(e){if(!e)return!1;const{TouchEvent:t}=Bn(e.target);return t&&e instanceof t}function Jm(e){if(XE(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 YE(e)?{x:e.clientX,y:e.clientY}:null}const eg=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[eg.Translate.toString(e),eg.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),YS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function GE(e){return e.matches(YS)?e:e.querySelector(YS)}const ZE={display:"none"};function QE(e){let{id:t,value:n}=e;return Bi.createElement("div",{id:t,style:ZE},n)}function JE(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 Bi.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},n)}function eT(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const g1=v.createContext(null);function tT(e){const t=v.useContext(g1);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function iT(){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 nT={draggable:`
|
|
11
|
-
To pick up a draggable item, press the space bar.
|
|
12
|
-
While dragging, use the arrow keys to move the item.
|
|
13
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
14
|
-
`},rT={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 sT(e){let{announcements:t=rT,container:n,hiddenTextDescribedById:s,screenReaderInstructions:o=nT}=e;const{announce:c,announcement:d}=eT(),m=qh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),tT(v.useMemo(()=>({onDragStart(b){let{active:k}=b;c(t.onDragStart({active:k}))},onDragMove(b){let{active:k,over:x}=b;t.onDragMove&&c(t.onDragMove({active:k,over:x}))},onDragOver(b){let{active:k,over:x}=b;c(t.onDragOver({active:k,over:x}))},onDragEnd(b){let{active:k,over:x}=b;c(t.onDragEnd({active:k,over:x}))},onDragCancel(b){let{active:k,over:x}=b;c(t.onDragCancel({active:k,over:x}))}}),[c,t])),!g)return null;const y=Bi.createElement(Bi.Fragment,null,Bi.createElement(QE,{id:s,value:o.draggable}),Bi.createElement(JE,{id:m,announcement:d}));return n?Rc.createPortal(y,n):y}var Oi;(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"})(Oi||(Oi={}));function wh(){}function XS(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function aT(){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 Rr=Object.freeze({x:0,y:0});function oT(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function lT(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function cT(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 uT=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=cT(m,t);g>0&&o.push({id:d,data:{droppableContainer:c,value:g}})}}return o.sort(oT)};function dT(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function v1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Rr}function hT(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 fT=hT(1);function pT(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 mT(e,t,n){const s=pT(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 gT={ignoreTransform:!1};function hu(e,t){t===void 0&&(t=gT);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:y}=Bn(e).getComputedStyle(e);f&&(n=mT(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 GS(e){return hu(e,{ignoreTransform:!0})}function vT(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function _T(e,t){return t===void 0&&(t=Bn(e).getComputedStyle(e)),t.position==="fixed"}function bT(e,t){t===void 0&&(t=Bn(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 Wv(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(!uu(o)||f1(o)||n.includes(o))return n;const c=Bn(e).getComputedStyle(o);return o!==e&&bT(o,c)&&n.push(o),_T(o,c)?n:s(o.parentNode)}return e?s(e):n}function _1(e){const[t]=Wv(e,1);return t??null}function mm(e){return!Wh||!e?null:pl(e)?e:Uv(e)?Kv(e)||e===ml(e).scrollingElement?window:uu(e)?e:null:null}function b1(e){return pl(e)?e.scrollX:e.scrollLeft}function y1(e){return pl(e)?e.scrollY:e.scrollTop}function tg(e){return{x:b1(e),y:y1(e)}}var Vi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vi||(Vi={}));function S1(e){return!Wh||!e?!1:e===document.scrollingElement}function w1(e){const t={x:0,y:0},n=S1(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 yT={x:.2,y:.2};function ST(e,t,n,s,o){let{top:c,left:d,right:m,bottom:g}=n;s===void 0&&(s=10),o===void 0&&(o=yT);const{isTop:f,isBottom:y,isLeft:b,isRight:k}=w1(e),x={x:0,y:0},w={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+D.height?(x.y=Vi.Backward,w.y=s*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(x.y=Vi.Forward,w.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!k&&m>=t.right-D.width?(x.x=Vi.Forward,w.x=s*Math.abs((t.right-D.width-m)/D.width)):!b&&d<=t.left+D.width&&(x.x=Vi.Backward,w.x=s*Math.abs((t.left+D.width-d)/D.width)),{direction:x,speed:w}}function wT(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)=>sl(t,tg(n)),Rr)}function CT(e){return e.reduce((t,n)=>t+b1(n),0)}function xT(e){return e.reduce((t,n)=>t+y1(n),0)}function kT(e,t){if(t===void 0&&(t=hu),!e)return;const{top:n,left:s,bottom:o,right:c}=t(e);_1(e)&&(o<=0||c<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ET=[["x",["left","right"],CT],["y",["top","bottom"],xT]];class qv{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=Wv(n),o=C1(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,m]of ET)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 Hc{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 TT(e){const{EventTarget:t}=Bn(e);return e instanceof t?e:ml(e)}function gm(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 dr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(dr||(dr={}));function ZS(e){e.preventDefault()}function DT(e){e.stopPropagation()}var Wt;(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"})(Wt||(Wt={}));const x1={start:[Wt.Space,Wt.Enter],cancel:[Wt.Esc],end:[Wt.Space,Wt.Enter,Wt.Tab]},RT=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Wt.Right:return{...n,x:n.x+25};case Wt.Left:return{...n,x:n.x-25};case Wt.Down:return{...n,y:n.y+25};case Wt.Up:return{...n,y:n.y-25}}};class k1{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 Hc(ml(n)),this.windowListeners=new Hc(Bn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(dr.Resize,this.handleCancel),this.windowListeners.add(dr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(dr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&kT(s),n(Rr)}handleKeyDown(t){if(m1(t)){const{active:n,context:s,options:o}=this.props,{keyboardCodes:c=x1,coordinateGetter:d=RT,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}:Rr;this.referenceCoordinates||(this.referenceCoordinates=y);const b=d(t,{active:n,context:s.current,currentCoordinates:y});if(b){const k=Sh(b,y),x={x:0,y:0},{scrollableAncestors:w}=s.current;for(const D of w){const O=t.code,{isTop:A,isRight:z,isLeft:$,isBottom:K,maxScroll:Q,minScroll:F}=w1(D),q=wT(D),be={x:Math.min(O===Wt.Right?q.right-q.width/2:q.right,Math.max(O===Wt.Right?q.left:q.left+q.width/2,b.x)),y:Math.min(O===Wt.Down?q.bottom-q.height/2:q.bottom,Math.max(O===Wt.Down?q.top:q.top+q.height/2,b.y))},Se=O===Wt.Right&&!z||O===Wt.Left&&!$,De=O===Wt.Down&&!K||O===Wt.Up&&!A;if(Se&&be.x!==b.x){const ie=D.scrollLeft+k.x,G=O===Wt.Right&&ie<=Q.x||O===Wt.Left&&ie>=F.x;if(G&&!k.y){D.scrollTo({left:ie,behavior:m});return}G?x.x=D.scrollLeft-ie:x.x=O===Wt.Right?D.scrollLeft-Q.x:D.scrollLeft-F.x,x.x&&D.scrollBy({left:-x.x,behavior:m});break}else if(De&&be.y!==b.y){const ie=D.scrollTop+k.y,G=O===Wt.Down&&ie<=Q.y||O===Wt.Up&&ie>=F.y;if(G&&!k.x){D.scrollTo({top:ie,behavior:m});return}G?x.y=D.scrollTop-ie:x.y=O===Wt.Down?D.scrollTop-Q.y:D.scrollTop-F.y,x.y&&D.scrollBy({top:-x.y,behavior:m});break}}this.handleMove(t,sl(Sh(b,this.referenceCoordinates),x))}}}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()}}k1.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=x1,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 QS(e){return!!(e&&"distance"in e)}function JS(e){return!!(e&&"delay"in e)}class $v{constructor(t,n,s){var o;s===void 0&&(s=TT(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=ml(d),this.documentListeners=new Hc(this.document),this.listeners=new Hc(s),this.windowListeners=new Hc(Bn(d)),this.initialCoordinates=(o=Jm(c))!=null?o:Rr,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(dr.Resize,this.handleCancel),this.windowListeners.add(dr.DragStart,ZS),this.windowListeners.add(dr.VisibilityChange,this.handleCancel),this.windowListeners.add(dr.ContextMenu,ZS),this.documentListeners.add(dr.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(JS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(QS(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(dr.Click,DT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(dr.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=Jm(t))!=null?n:Rr,f=Sh(o,g);if(!s&&m){if(QS(m)){if(m.tolerance!=null&&gm(f,m.tolerance))return this.handleCancel();if(gm(f,m.distance))return this.handleStart()}if(JS(m)&&gm(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===Wt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const MT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class E1 extends $v{constructor(t){const{event:n}=t,s=ml(n.target);super(t,MT,s)}}E1.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 NT={move:{name:"mousemove"},end:{name:"mouseup"}};var ig;(function(e){e[e.RightClick=2]="RightClick"})(ig||(ig={}));class T1 extends $v{constructor(t){super(t,NT,ml(t.event.target))}}T1.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===ig.RightClick?!1:(s?.({event:n}),!0)}}];const vm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class D1 extends $v{constructor(t){super(t,vm)}static setup(){return window.addEventListener(vm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(vm.move.name,t)};function t(){}}}D1.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 Uc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Uc||(Uc={}));var Ch;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ch||(Ch={}));function AT(e){let{acceleration:t,activator:n=Uc.Pointer,canScroll:s,draggingRect:o,enabled:c,interval:d=5,order:m=Ch.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:y,delta:b,threshold:k}=e;const x=OT({delta:b,disabled:!c}),[w,D]=VE(),O=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),z=v.useMemo(()=>{switch(n){case Uc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Uc.DraggableRect:return o}},[n,o,g]),$=v.useRef(null),K=v.useCallback(()=>{const F=$.current;if(!F)return;const q=O.current.x*A.current.x,be=O.current.y*A.current.y;F.scrollBy(q,be)},[]),Q=v.useMemo(()=>m===Ch.TreeOrder?[...f].reverse():f,[m,f]);v.useEffect(()=>{if(!c||!f.length||!z){D();return}for(const F of Q){if(s?.(F)===!1)continue;const q=f.indexOf(F),be=y[q];if(!be)continue;const{direction:Se,speed:De}=ST(F,be,z,t,k);for(const ie of["x","y"])x[ie][Se[ie]]||(De[ie]=0,Se[ie]=0);if(De.x>0||De.y>0){D(),$.current=F,w(K,d),O.current=De,A.current=Se;return}}O.current={x:0,y:0},A.current={x:0,y:0},D()},[t,K,s,D,c,d,JSON.stringify(z),JSON.stringify(x),w,f,Q,y,JSON.stringify(k)])}const LT={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function OT(e){let{delta:t,disabled:n}=e;const s=Qm(t);return du(o=>{if(n||!s||!o)return LT;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Vi.Backward]:o.x[Vi.Backward]||c.x===-1,[Vi.Forward]:o.x[Vi.Forward]||c.x===1},y:{[Vi.Backward]:o.y[Vi.Backward]||c.y===-1,[Vi.Forward]:o.y[Vi.Forward]||c.y===1}}},[n,t,s])}function BT(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return du(o=>{var c;return t==null?null:(c=s??o)!=null?c:null},[s,t])}function jT(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 Xc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Xc||(Xc={}));var ng;(function(e){e.Optimized="optimized"})(ng||(ng={}));const e0=new Map;function zT(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=O(),k=Yc(b),x=v.useCallback(function(A){A===void 0&&(A=[]),!k.current&&d(z=>z===null?A:z.concat(A.filter($=>!z.includes($))))},[k]),w=v.useRef(null),D=du(A=>{if(b&&!n)return e0;if(!A||A===e0||y.current!==e||c!=null){const z=new Map;for(let $ of e){if(!$)continue;if(c&&c.length>0&&!c.includes($.id)&&$.rect.current){z.set($.id,$.rect.current);continue}const K=$.node.current,Q=K?new qv(g(K),K):null;$.rect.current=Q,Q&&z.set($.id,Q)}return z}return A},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||x()},[n,b]),v.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||w.current!==null||(w.current=setTimeout(()=>{x(),w.current=null},m))},[m,b,x,...s]),{droppableRects:D,measureDroppableContainers:x,measuringScheduled:c!=null};function O(){switch(f){case Xc.Always:return!1;case Xc.BeforeDragging:return n;default:return!n}}}function R1(e,t){return du(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function IT(e,t){return R1(e,t)}function PT(e){let{callback:t,disabled:n}=e;const s=Fv(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 $h(e){let{callback:t,disabled:n}=e;const s=Fv(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 HT(e){return new qv(hu(e),e)}function t0(e,t,n){t===void 0&&(t=HT);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=PT({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=$h({callback:c});return wa(()=>{c(),e?(m?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),d?.disconnect())},[e]),s}function UT(e){const t=R1(e);return v1(e,t)}const i0=[];function KT(e){const t=v.useRef(e),n=du(s=>e?s&&s!==i0&&e&&t.current&&e.parentNode===t.current.parentNode?s:Wv(e):i0,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function FT(e){const[t,n]=v.useState(null),s=v.useRef(e),o=v.useCallback(c=>{const d=mm(c.target);d&&n(m=>m?(m.set(d,tg(d)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){d(c);const m=e.map(g=>{const f=mm(g);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,tg(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=mm(g);f?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>sl(c,d),Rr):C1(e):Rr,[e,t])}function n0(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==Rr;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?Sh(e,n.current):Rr}function WT(e){v.useEffect(()=>{if(!Wh)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 qT(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 M1(e){return v.useMemo(()=>e?vT(e):null,[e])}const r0=[];function $T(e,t){t===void 0&&(t=hu);const[n]=e,s=M1(n?Bn(n):null),[o,c]=v.useState(r0);function d(){c(()=>e.length?e.map(g=>S1(g)?s:new qv(t(g),g)):r0)}const m=$h({callback:d});return wa(()=>{m?.disconnect(),d(),e.forEach(g=>m?.observe(g))},[e]),o}function VT(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return uu(t)?t:e}function YT(e){let{measure:t}=e;const[n,s]=v.useState(null),o=v.useCallback(f=>{for(const{target:y}of f)if(uu(y)){s(b=>{const k=t(y);return b?{...b,width:k.width,height:k.height}:k});break}},[t]),c=$h({callback:o}),d=v.useCallback(f=>{const y=VT(f);c?.disconnect(),y&&c?.observe(y),s(y?t(y):null)},[t,c]),[m,g]=yh(d);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const XT=[{sensor:E1,options:{}},{sensor:k1,options:{}}],GT={current:{}},rh={draggable:{measure:GS},droppable:{measure:GS,strategy:Xc.WhileDragging,frequency:ng.Optimized},dragOverlay:{measure:hu}};class Kc 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 ZT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Kc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:wh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:rh,measureDroppableContainers:wh,windowRect:null,measuringScheduled:!1},QT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:wh,draggableNodes:new Map,over:null,measureDroppableContainers:wh},Vh=v.createContext(QT),JT=v.createContext(ZT);function e2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Kc}}}function t2(e,t){switch(t.type){case Oi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Oi.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 Oi.DragEnd:case Oi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Oi.RegisterDroppable:{const{element:n}=t,{id:s}=n,o=new Kc(e.droppable.containers);return o.set(s,n),{...e,droppable:{...e.droppable,containers:o}}}case Oi.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 Kc(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case Oi.UnregisterDroppable:{const{id:n,key:s}=t,o=e.droppable.containers.get(n);if(!o||s!==o.key)return e;const c=new Kc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function i2(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:o}=v.useContext(Vh),c=Qm(s),d=Qm(n?.id);return v.useEffect(()=>{if(!t&&!s&&c&&d!=null){if(!m1(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=GE(y);if(b){b.focus();break}}})}},[s,t,o,d,c]),null}function n2(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...s}),n):n}function r2(e){return v.useMemo(()=>({draggable:{...rh.draggable,...e?.draggable},droppable:{...rh.droppable,...e?.droppable},dragOverlay:{...rh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function s2(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;wa(()=>{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=v1(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 k=_1(f);k&&k.scrollBy({top:b.y,left:b.x})}},[t,d,m,s,n])}const N1=v.createContext({...Rr,scaleX:1,scaleY:1});var pa;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(pa||(pa={}));const a2=v.memo(function(t){var n,s,o,c;let{id:d,accessibility:m,autoScroll:g=!0,children:f,sensors:y=XT,collisionDetection:b=uT,measuring:k,modifiers:x,...w}=t;const D=v.useReducer(t2,void 0,e2),[O,A]=D,[z,$]=iT(),[K,Q]=v.useState(pa.Uninitialized),F=K===pa.Initialized,{draggable:{active:q,nodes:be,translate:Se},droppable:{containers:De}}=O,ie=q!=null?be.get(q):null,G=v.useRef({initial:null,translated:null}),Z=v.useMemo(()=>{var st;return q!=null?{id:q,data:(st=ie?.data)!=null?st:GT,rect:G}:null},[q,ie]),W=v.useRef(null),[re,L]=v.useState(null),[R,I]=v.useState(null),se=Yc(w,Object.values(w)),ye=qh("DndDescribedBy",d),M=v.useMemo(()=>De.getEnabled(),[De]),U=r2(k),{droppableRects:ae,measureDroppableContainers:_e,measuringScheduled:Ne}=zT(M,{dragging:F,dependencies:[Se.x,Se.y],config:U.droppable}),xe=BT(be,q),Le=v.useMemo(()=>R?Jm(R):null,[R]),Ee=rt(),je=IT(xe,U.draggable.measure);s2({activeNode:q!=null?be.get(q):null,config:Ee.layoutShiftCompensation,initialRect:je,measure:U.draggable.measure});const Fe=t0(xe,U.draggable.measure,je),ee=t0(xe?xe.parentElement:null),de=v.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:be,draggingNode:null,draggingNodeRect:null,droppableContainers:De,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),he=De.getNodeFor((n=de.current.over)==null?void 0:n.id),Ae=YT({measure:U.dragOverlay.measure}),ze=(s=Ae.nodeRef.current)!=null?s:xe,Me=F?(o=Ae.rect)!=null?o:Fe:null,oe=!!(Ae.nodeRef.current&&Ae.rect),ke=UT(oe?null:Fe),ge=M1(ze?Bn(ze):null),Oe=KT(F?he??xe:null),Ve=$T(Oe),ot=n2(x,{transform:{x:Se.x-ke.x,y:Se.y-ke.y,scaleX:1,scaleY:1},activatorEvent:R,active:Z,activeNodeRect:Fe,containerNodeRect:ee,draggingNodeRect:Me,over:de.current.over,overlayNodeRect:Ae.rect,scrollableAncestors:Oe,scrollableAncestorRects:Ve,windowRect:ge}),vt=Le?sl(Le,Se):null,xt=FT(Oe),jn=n0(xt),ni=n0(xt,[Fe]),mi=sl(ot,jn),Ye=Me?fT(Me,ot):null,ft=Z&&Ye?b({active:Z,collisionRect:Ye,droppableRects:ae,droppableContainers:M,pointerCoordinates:vt}):null,Vt=lT(ft,"id"),[ve,Ue]=v.useState(null),nt=oe?ot:sl(ot,ni),Ze=dT(nt,(c=ve?.rect)!=null?c:null,Fe),Et=v.useRef(null),ht=v.useCallback((st,Rt)=>{let{sensor:Lt,options:jt}=Rt;if(W.current==null)return;const li=be.get(W.current);if(!li)return;const qt=st.nativeEvent,Ri=new Lt({active:W.current,activeNode:li,event:qt,options:jt,context:de,onAbort(Jt){if(!be.get(Jt))return;const{onDragAbort:yi}=se.current,ei={id:Jt};yi?.(ei),z({type:"onDragAbort",event:ei})},onPending(Jt,Ji,yi,ei){if(!be.get(Jt))return;const{onDragPending:Pi}=se.current,en={id:Jt,constraint:Ji,initialCoordinates:yi,offset:ei};Pi?.(en),z({type:"onDragPending",event:en})},onStart(Jt){const Ji=W.current;if(Ji==null)return;const yi=be.get(Ji);if(!yi)return;const{onDragStart:ei}=se.current,Ii={activatorEvent:qt,active:{id:Ji,data:yi.data,rect:G}};Rc.unstable_batchedUpdates(()=>{ei?.(Ii),Q(pa.Initializing),A({type:Oi.DragStart,initialCoordinates:Jt,active:Ji}),z({type:"onDragStart",event:Ii}),L(Et.current),I(qt)})},onMove(Jt){A({type:Oi.DragMove,coordinates:Jt})},onEnd:$t(Oi.DragEnd),onCancel:$t(Oi.DragCancel)});Et.current=Ri;function $t(Jt){return async function(){const{active:yi,collisions:ei,over:Ii,scrollAdjustedTranslate:Pi}=de.current;let en=null;if(yi&&Pi){const{cancelDrop:ln}=se.current;en={activatorEvent:qt,active:yi,collisions:ei,delta:Pi,over:Ii},Jt===Oi.DragEnd&&typeof ln=="function"&&await Promise.resolve(ln(en))&&(Jt=Oi.DragCancel)}W.current=null,Rc.unstable_batchedUpdates(()=>{A({type:Jt}),Q(pa.Uninitialized),Ue(null),L(null),I(null),Et.current=null;const ln=Jt===Oi.DragEnd?"onDragEnd":"onDragCancel";if(en){const gi=se.current[ln];gi?.(en),z({type:ln,event:en})}})}}},[be]),Qt=v.useCallback((st,Rt)=>(Lt,jt)=>{const li=Lt.nativeEvent,qt=be.get(jt);if(W.current!==null||!qt||li.dndKit||li.defaultPrevented)return;const Ri={active:qt};st(Lt,Rt.options,Ri)===!0&&(li.dndKit={capturedBy:Rt.sensor},W.current=jt,ht(Lt,Rt))},[be,ht]),oi=jT(y,Qt);WT(y),wa(()=>{Fe&&K===pa.Initializing&&Q(pa.Initialized)},[Fe,K]),v.useEffect(()=>{const{onDragMove:st}=se.current,{active:Rt,activatorEvent:Lt,collisions:jt,over:li}=de.current;if(!Rt||!Lt)return;const qt={active:Rt,activatorEvent:Lt,collisions:jt,delta:{x:mi.x,y:mi.y},over:li};Rc.unstable_batchedUpdates(()=>{st?.(qt),z({type:"onDragMove",event:qt})})},[mi.x,mi.y]),v.useEffect(()=>{const{active:st,activatorEvent:Rt,collisions:Lt,droppableContainers:jt,scrollAdjustedTranslate:li}=de.current;if(!st||W.current==null||!Rt||!li)return;const{onDragOver:qt}=se.current,Ri=jt.get(Vt),$t=Ri&&Ri.rect.current?{id:Ri.id,rect:Ri.rect.current,data:Ri.data,disabled:Ri.disabled}:null,Jt={active:st,activatorEvent:Rt,collisions:Lt,delta:{x:li.x,y:li.y},over:$t};Rc.unstable_batchedUpdates(()=>{Ue($t),qt?.(Jt),z({type:"onDragOver",event:Jt})})},[Vt]),wa(()=>{de.current={activatorEvent:R,active:Z,activeNode:xe,collisionRect:Ye,collisions:ft,droppableRects:ae,draggableNodes:be,draggingNode:ze,draggingNodeRect:Me,droppableContainers:De,over:ve,scrollableAncestors:Oe,scrollAdjustedTranslate:mi},G.current={initial:Me,translated:Ye}},[Z,xe,ft,Ye,be,ze,Me,ae,De,ve,Oe,mi]),AT({...Ee,delta:Se,draggingRect:Ye,pointerCoordinates:vt,scrollableAncestors:Oe,scrollableAncestorRects:Ve});const V=v.useMemo(()=>({active:Z,activeNode:xe,activeNodeRect:Fe,activatorEvent:R,collisions:ft,containerNodeRect:ee,dragOverlay:Ae,draggableNodes:be,droppableContainers:De,droppableRects:ae,over:ve,measureDroppableContainers:_e,scrollableAncestors:Oe,scrollableAncestorRects:Ve,measuringConfiguration:U,measuringScheduled:Ne,windowRect:ge}),[Z,xe,Fe,R,ft,ee,Ae,be,De,ae,ve,_e,Oe,Ve,U,Ne,ge]),Ke=v.useMemo(()=>({activatorEvent:R,activators:oi,active:Z,activeNodeRect:Fe,ariaDescribedById:{draggable:ye},dispatch:A,draggableNodes:be,over:ve,measureDroppableContainers:_e}),[R,oi,Z,Fe,A,ye,be,ve,_e]);return Bi.createElement(g1.Provider,{value:$},Bi.createElement(Vh.Provider,{value:Ke},Bi.createElement(JT.Provider,{value:V},Bi.createElement(N1.Provider,{value:Ze},f)),Bi.createElement(i2,{disabled:m?.restoreFocus===!1})),Bi.createElement(sT,{...m,hiddenTextDescribedById:ye}));function rt(){const st=re?.autoScrollEnabled===!1,Rt=typeof g=="object"?g.enabled===!1:g===!1,Lt=F&&!st&&!Rt;return typeof g=="object"?{...g,enabled:Lt}:{enabled:Lt}}}),o2=v.createContext(null),s0="button",l2="Draggable";function A1(e){let{id:t,data:n,disabled:s=!1,attributes:o}=e;const c=qh(l2),{activators:d,activatorEvent:m,active:g,activeNodeRect:f,ariaDescribedById:y,draggableNodes:b,over:k}=v.useContext(Vh),{role:x=s0,roleDescription:w="draggable",tabIndex:D=0}=o??{},O=g?.id===t,A=v.useContext(O?N1:o2),[z,$]=yh(),[K,Q]=yh(),F=qT(d,t),q=Yc(n);wa(()=>(b.set(t,{id:t,key:c,node:z,activatorNode:K,data:q}),()=>{const Se=b.get(t);Se&&Se.key===c&&b.delete(t)}),[b,t]);const be=v.useMemo(()=>({role:x,tabIndex:D,"aria-disabled":s,"aria-pressed":O&&x===s0?!0:void 0,"aria-roledescription":w,"aria-describedby":y.draggable}),[s,x,D,O,w,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:f,attributes:be,isDragging:O,listeners:s?void 0:F,node:z,over:k,setNodeRef:$,setActivatorNodeRef:Q,transform:A}}const c2="Droppable",u2={timeout:25};function Vv(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:o}=e;const c=qh(c2),{active:d,dispatch:m,over:g,measureDroppableContainers:f}=v.useContext(Vh),y=v.useRef({disabled:n}),b=v.useRef(!1),k=v.useRef(null),x=v.useRef(null),{disabled:w,updateMeasurementsFor:D,timeout:O}={...u2,...o},A=Yc(D??s),z=v.useCallback(()=>{if(!b.current){b.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),x.current=null},O)},[O]),$=$h({callback:z,disabled:w||!d}),K=v.useCallback((be,Se)=>{$&&(Se&&($.unobserve(Se),b.current=!1),be&&$.observe(be))},[$]),[Q,F]=yh(K),q=Yc(t);return v.useEffect(()=>{!$||!Q.current||($.disconnect(),b.current=!1,$.observe(Q.current))},[Q,$]),v.useEffect(()=>(m({type:Oi.RegisterDroppable,element:{id:s,key:c,disabled:n,node:Q,rect:k,data:q}}),()=>m({type:Oi.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:Oi.SetDroppableDisabled,id:s,key:c,disabled:n}),y.current.disabled=n)},[s,c,n,m]),{active:d,rect:k,isOver:g?.id===s,node:Q,over:g,setNodeRef:F}}const d2=128,h2=512,gl=100,f2="too_many_detached_terminals",p2=64,m2=4096;function L1(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>d2)return null;const n=t.workspaces.map(g2);return n.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function O1(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>gl}):!1}function g2(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>h2)return null;const n=t.tabs.map(v2);if(n.some(o=>o===null))return null;const s=S2(t.detachedTerminalIds,gl);return s===null?null:{id:t.id,title:t.title,defaultCwd:y2(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function v2(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=_2(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function _2(e){if(!e||typeof e!="object")return null;let t=0;return rg(e,1,()=>(t+=1,t<=m2))}function rg(e,t,n){if(!e||typeof e!="object"||t>p2||!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=rg(s.first,t+1,n),c=rg(s.second,t+1,n);return!o||!c?null:{type:"split",direction:s.direction,ratio:b2(s.ratio),first:o,second:c}}function b2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function y2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function S2(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 B1=[{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"}],w2="nterminal-focus",C2=/^[A-Za-z0-9_.:-]{1,128}$/;function x2(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(w2)!=="terminal"?null:Yh({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Yh(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!a0(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!a0(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function a0(e){return typeof e=="string"&&C2.test(e)}const Yi="__main__",j1=128,k2=600*1e3,z1="nterminal.clientDiagnostics.v1",I1=150,E2=24,T2=160;let o0=!1,bc=null;function D2(){o0||typeof window>"u"||(o0=!0,yn("page.load",{navigation:I2(),visibility:document.visibilityState,online:navigator.onLine,viewport:U1(),standalone:z2()}),document.addEventListener("visibilitychange",()=>{yn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{yn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{yn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>yn("network.online")),window.addEventListener("offline",()=>yn("network.offline")),window.addEventListener("focus",()=>yn("window.focus")),window.addEventListener("blur",()=>yn("window.blur")),window.addEventListener("error",e=>{yn("runtime.error",{message:e.message,source:P2(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{yn("runtime.unhandledrejection",{reason:H2(e.reason)})}))}function yn(e,t={}){const n={at:new Date().toISOString(),event:Xh(e,80),data:H1({...t,visibility:t.visibility??B2(),online:t.online??j2(),viewport:t.viewport??U1()})},s=P1();return s.push(n),R2(s.slice(-I1)),n}function P1(){try{const e=window.localStorage.getItem(z1);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(M2).filter(n=>n!==null).slice(-I1):[]}catch{return[]}}async function Yv(e,t=fetch){if(bc)return bc;const n=P1(),s={reason:Xh(e,80),events:n},o=JSON.stringify(s);bc=(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 bc}finally{bc=null}}function R2(e){try{window.localStorage.setItem(z1,JSON.stringify(e))}catch{}}function M2(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:Xh(t.event,80),...t.data&&typeof t.data=="object"?{data:H1(t.data)}:{}}}function H1(e){const t={};for(const[n,s]of Object.entries(e).slice(0,E2)){const o=Xh(n,64);if(!o||N2(o))continue;const c=A2(s);c!==void 0&&(t[o]=c)}return t}function N2(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function A2(e){if(typeof e=="string")return L2(e,T2);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Xh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function L2(e,t){return O2(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function O2(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 B2(){return typeof document>"u"?void 0:document.visibilityState}function j2(){return typeof navigator>"u"?void 0:navigator.onLine}function U1(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function z2(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function I2(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function P2(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 H2(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const K1="nterminal.notifications.completionEnabled",Xv="nterminal.notifications.completionToastEnabled",Gv="nterminal.notifications.completionToastDurationSeconds",Zv="nterminal.notifications.completionToastPersistent",sg="nterminal:completion-toast-display",ag="nterminal:notification-focus",Fc=6.5,og=2,lg=60;function Gh(){return typeof window<"u"&&"Notification"in window}function Qv(){try{return window.localStorage.getItem(K1)==="true"}catch{return!1}}function l0(e){try{window.localStorage.setItem(K1,e?"true":"false")}catch{}}function so(){return{enabled:W2(),durationSeconds:F2(),persistUntilDismissed:q2()}}function U2(e){if(typeof window<"u"){try{window.localStorage.setItem(Xv,e?"true":"false")}catch{}Jv()}return so()}function c0(e){const t=W1(e);if(typeof window<"u"){try{window.localStorage.setItem(Gv,String(t))}catch{}Jv()}return so()}function K2(e){if(typeof window<"u"){try{window.localStorage.setItem(Zv,e?"true":"false")}catch{}Jv()}return so()}function F1(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Xv||n.key===Gv||n.key===Zv)&&e()};return window.addEventListener(sg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(sg,e),window.removeEventListener("storage",t)}}function vl(){return Gh()?window.Notification.permission:"unsupported"}function F2(){if(typeof window>"u")return Fc;try{const e=window.localStorage.getItem(Gv);return e===null?Fc:W1(Number(e))}catch{return Fc}}function W2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Xv)!=="false"}catch{return!0}}function q2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Zv)==="true"}catch{return!1}}function W1(e){if(!Number.isFinite(e))return Fc;const t=Math.round(e*2)/2;return Math.max(og,Math.min(lg,t))}function Jv(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(sg))}async function q1(){if(!Gh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return vl()}}function $2(e){if(!Gh()||vl()!=="granted"||!Qv()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,s=Yh({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(),V2(s)})}catch{}}function V2(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(ag,{detail:e}))}const u0="nterminal.push.clientId",Y2=2e4,d0=[5e3,3e4,12e4];function ws(){try{const e=window.localStorage.getItem(u0);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${ug()}`;return window.localStorage.setItem(u0,t),t}catch{return`client-${ug()}`}}function X2(){return`page-${ug()}`}function Zh(){const e=typeof window<"u"&&window.isSecureContext===!0,t=iD(),n=nD(),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 G2(e,t){const n=Zh();if(!n.supported)throw new Error(n.reason);if((vl()==="granted"?"granted":await q1())!=="granted")throw new Error("permission_denied");const o=ws(),c=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(o),g=await sD(c,d.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Y1(d.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:V1(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:$1(n.deviceKind),alwaysNotify:t})}async function Z2(e){const t=Zh();if(!t.supported||vl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),s=await n?.pushManager.getSubscription();if(!n||!s)return!1;const o=ws(),c=await aD(s.endpoint),d=await e.getPushNotificationStatus(o,c);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&cg(s,d.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=d.endpointRegistered===!0&&cg(s,m.publicKey);g||await s.unsubscribe();const f=g?s:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Y1(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:V1(f),deviceKind:t.deviceKind,displayMode:t.displayMode,label:$1(t.deviceKind),alwaysNotify:!1}),!0}function Q2(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,Z2(e).then(b=>{s=0,b&&yn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(yn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&s<d0.length){const k=d0[s++];o=window.setTimeout(()=>{o=null,d("retry")},k)}}).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 J2(e){const t=ws();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 eD(e,t){await e.updatePushNotificationDevice({clientId:ws(),alwaysNotify:t})}function tD(e){if(typeof window>"u")return()=>{};const t=ws(),n=X2();let s=null,o=!1;const c=(f=!0)=>{const y=Zh();e.updatePushPresence({clientId:t,pageId:n,visibilityState:rD(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:Qv()&&vl()==="granted",active:f}).catch(()=>{})},d=()=>{o||s!==null||(s=window.setInterval(()=>c(!0),Y2))},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 iD(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function nD(){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 $1(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function rD(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function V1(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 sD(e,t){const n=await e.pushManager.getSubscription();return n?cg(n,t)?n:(await n.unsubscribe(),null):null}function cg(e,t){const n=e.options.applicationServerKey;return n?X1(n)===t:!0}async function aD(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return X1(t)}function Y1(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 X1(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 ug(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Ss(e,t){const n=[Yi,...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 oD(e,t){return Ss(e,t).map(n=>n===Yi?null:n)}function lD(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function cD(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const h0="Local",uD=3e4,dD=2,hD=6,G1="nterminal.serverList.viewMode.v1";function fD(){try{return window.localStorage.getItem(G1)==="list"?"list":"stats"}catch{return"stats"}}function pD(e){try{window.localStorage.setItem(G1,e)}catch{}}function mD(e,t){const n=new Map(e.map(s=>[s.id,s]));return Ss(t,e).flatMap(s=>{if(s===Yi)return[{kind:"main",id:Yi}];const o=n.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function f0(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function Z1(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${fr(e.value.cpuPercent)} ${e_(e.value)}`,`MEM ${fr(e.value.memoryPercent)} ${xs(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${fr(e.value.diskPercent)} ${xs(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${fr(e.value.swapPercent)} ${xs(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function p0(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${fr(e.value.cpuPercent)} (${e_(e.value)})`,`RAM ${fr(e.value.memoryPercent)} (${xs(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${fr(e.value.diskPercent)} (${xs(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${fr(e.value.swapPercent)} (${xs(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function gD(e,t){const n=Z1(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function fr(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function e_(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`:`${dg(e.cpuPercent/100*t)}/${t} cores`}function xs(e,t){return!m0(e)||!m0(t)?"–/–":vD(e,t)}function vD(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${dg(e/s)}/${dg(t/s)} ${n}`}function dg(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function m0(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Ud(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function _D(e){return[{label:"CPU",percent:fr(e.cpuPercent),detail:e_(e),tone:Ud(e.cpuPercent)},{label:"MEM",percent:fr(e.memoryPercent),detail:xs(e.memoryUsedBytes,e.memoryTotalBytes),tone:Ud(e.memoryPercent)},{label:"DISK",percent:fr(e.diskPercent),detail:xs(e.diskUsedBytes,e.diskTotalBytes),tone:Ud(e.diskPercent)},{label:"SWAP",percent:fr(e.swapPercent),detail:xs(e.swapUsedBytes,e.swapTotalBytes),tone:Ud(e.swapPercent)}]}function bD({entry:e}){return e?.status==="offline"?p.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?p.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",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${e.stale?" server-list-stats-grid--stale":""}`,title:p0(e),"aria-label":p0(e),children:_D(e.value).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 g0({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([Yi]),[k,x]=v.useState(null),[w,D]=v.useState(null),[O,A]=v.useState(""),z=v.useRef(null),[$,K]=v.useState(()=>fD()),[Q,F]=v.useState(null),[q,be]=v.useState(null),[Se,De]=v.useState({}),ie=v.useRef({}),G=v.useRef(0),Z=v.useRef([]),W=v.useRef([Yi]),re=v.useRef(null);v.useEffect(()=>{Z.current=g},[g]),v.useEffect(()=>{const ee=Ss(y,g);W.current=ee,f0(ee,y)||b(ee)},[g,y]),v.useEffect(()=>{let ee=!1;return e.listAgents().then(de=>{ee||(f(de.agents),b(Ss(de.serverOrder,de.agents)))}).catch(()=>{}),e.getMainInfo().then(de=>{ee||x(de.name)}).catch(()=>{}),()=>{ee=!0}},[e,o]),v.useEffect(()=>{w&&(z.current?.focus(),z.current?.select())},[w]),v.useEffect(()=>{let ee=!1;function de(){const Ae=[{key:Yi,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...g.map(Me=>({key:Me.id,load:()=>e.getAgentStats(Me.id),probe:async()=>(await e.pingAgent(Me.id)).ok}))],ze=new Set(Ae.map(Me=>Me.key));for(const Me of Object.keys(ie.current))ze.has(Me)||delete ie.current[Me];De(Me=>{const oe={};for(const ke of ze)ke in Me&&(oe[ke]=Me[ke]);return oe});for(const Me of Ae)Me.load().then(oe=>{ee||(ie.current[Me.key]=0,De(ke=>ze.has(Me.key)?{...ke,[Me.key]:{status:"online",value:oe,stale:!1}}:ke))}).catch(async oe=>{if(ee)return;if(oe instanceof On&&oe.status===401&&Me.key===Yi){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(Me.key===Yi&&oe instanceof On){ie.current[Me.key]=0,De(ge=>{if(!ze.has(Me.key))return ge;const Oe=ge[Me.key];return{...ge,[Me.key]:{status:"online",value:Oe?.value??null,stale:!0}}});return}if(Me.probe)try{if(await Me.probe()){if(ee)return;ie.current[Me.key]=0,De(ge=>{if(!ze.has(Me.key))return ge;const Oe=ge[Me.key];return{...ge,[Me.key]:{status:"online",value:Oe?.value??null,stale:!0}}});return}}catch(ge){if(ee)return;if(ge instanceof On&&ge.status===401){s?.({source:Me.key===Yi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const ke=(ie.current[Me.key]??0)+1;ie.current[Me.key]=ke,ke>=dD&&De(ge=>ze.has(Me.key)?{...ge,[Me.key]:{status:"offline",value:ge[Me.key]?.value??null,stale:!0}}:ge)})}de();const he=window.setInterval(de,uD);return()=>{ee=!0,window.clearInterval(he)}},[e,g,s]);function L(ee){ee==="main"?(A(k??""),D({kind:"main"})):(A(ee.name),D({kind:"agent",id:ee.id}))}async function R(){if(!w)return;const ee=O.trim(),de=w;if(D(null),de.kind==="main"){const he=ee||"";try{const Ae=await e.renameMain(he);x(Ae.name)}catch{}}else{if(!ee)return;const he=g.find(Ae=>Ae.id===de.id)?.name;f(Ae=>Ae.map(ze=>ze.id===de.id?{...ze,name:ee}:ze));try{await e.renameAgent(de.id,ee)}catch{he!==void 0&&f(Ae=>Ae.map(ze=>ze.id===de.id?{...ze,name:he}:ze))}}}function I(){D(null)}function se(ee){K(ee),pD(ee)}function ye(ee,de,he){if(ee===de)return;const Ae=Ss(W.current,Z.current),ze=Ae.findIndex(ot=>ot===ee),Me=Ae.findIndex(ot=>ot===de);if(ze<0||Me<0)return;const oe=[...Ae],[ke]=oe.splice(ze,1);if(!ke)return;const ge=oe.findIndex(ot=>ot===de);if(ge<0)return;const Oe=he==="before"?ge:ge+1;if(oe.splice(Oe,0,ke),f0(oe,Ae))return;const Ve=G.current+1;G.current=Ve,W.current=oe,b(oe),e.reorderAgents(oe).then(ot=>{if(G.current===Ve){Z.current=ot.agents;const vt=Ss(ot.serverOrder,ot.agents);W.current=vt,f(ot.agents),b(vt)}}).catch(async()=>{if(G.current===Ve)try{const ot=await e.listAgents();if(G.current===Ve){Z.current=ot.agents;const vt=Ss(ot.serverOrder,ot.agents);W.current=vt,f(ot.agents),b(vt)}}catch{G.current===Ve&&(W.current=Ae,b(Ae))}})}function M(ee,de){const he=Ss(W.current,Z.current),Ae=he.findIndex(Me=>Me===ee),ze=he[Ae+de];Ae<0||!ze||ye(ee,ze,de<0?"before":"after")}function U(ee,de){de.pointerType==="mouse"&&de.button!==0||(de.stopPropagation(),re.current={sourceId:ee,pointerId:de.pointerId,startX:de.clientX,startY:de.clientY,active:!1,targetId:null,placement:"after"},de.currentTarget.setPointerCapture?.(de.pointerId))}function ae(ee){const de=re.current;if(!de||de.pointerId!==ee.pointerId)return;const he=Math.hypot(ee.clientX-de.startX,ee.clientY-de.startY);if(!de.active){if(he<hD)return;de.active=!0,F(de.sourceId)}const ze=document.elementFromPoint(ee.clientX,ee.clientY)?.closest("[data-server-id]"),Me=ze?.dataset.serverId??null;if(!ze||!Me||Me===de.sourceId){de.targetId=null,be(null);return}const oe=ze.getBoundingClientRect(),ke=ee.clientY<oe.top+oe.height/2?"before":"after";de.targetId=Me,de.placement=ke,be({serverId:Me,placement:ke})}function _e(ee){const de=re.current;!de||de.pointerId!==ee.pointerId||(ee.stopPropagation(),ee.currentTarget.releasePointerCapture?.(ee.pointerId),re.current=null,F(null),be(null),de.active&&de.targetId&&ye(de.sourceId,de.targetId,de.placement))}function Ne(ee){const de=re.current;de&&de.pointerId===ee.pointerId&&ee.currentTarget.releasePointerCapture?.(ee.pointerId),re.current=null,F(null),be(null)}const xe=k?.trim()||h0,Le=w?.kind==="main",Ee=$==="stats",je=mD(g,y),Fe=je.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:xe},...g.map(ee=>({agentId:ee.id,label:ee.name}))])},[g,xe,c]),m?p.jsx("div",{className:"server-list server-list--compact",children:je.map(ee=>{const de=ee.kind==="main",he=de?xe:ee.agent.name,Ae=de?Yi:ee.id,ze=Se[Ae],Me=Z1(ze);return p.jsxs("button",{type:"button",className:`server-list-chip${(de?t===null:t===ee.id)?" server-list-chip--active":""}`,onClick:()=>n(de?null:ee.id),"aria-label":`${he}${Me?` — ${Me}`:""}`,title:`${he}${Me?` — ${Me}`:""}`,children:[p.jsx("span",{className:"server-list-chip-initial",children:cD(he)}),p.jsx("span",{className:"server-list-chip-pip","data-status":lD(ze)})]},ee.id)})}):p.jsxs("div",{className:`server-list server-list--${$}`,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":$==="list",onClick:()=>se("list"),title:"Show server names only",children:"List"}),p.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":$==="stats",onClick:()=>se("stats"),title:"Show resource usage",children:"Stats"})]}),je.map(ee=>{const de=ee.kind==="main",he=de?xe:ee.agent.name,Ae=de?Yi:ee.id,ze=de?t===null:t===ee.id,Me=de?Le:w?.kind==="agent"&&w.id===ee.id,oe=d?.({agentId:de?null:ee.id,serverId:ee.id,label:he,active:ze}),ke=q?.serverId===ee.id&&Q!==ee.id?` server-list-section--drop-target server-list-section--drop-${q.placement}`:"";return p.jsxs("section",{className:`server-list-section${ke}`,"aria-label":`${he} server`,children:[p.jsx("div",{className:["server-list-row",Q===ee.id?"server-list-row--dragging":"",q?.serverId===ee.id&&Q!==ee.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ee.id,children:Me?p.jsxs(p.Fragment,{children:[Fe?p.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,p.jsx("form",{className:"server-list-editor",onSubmit:ge=>{ge.preventDefault(),R()},children:p.jsx("input",{ref:z,"aria-label":de?"Rename main server":`Rename ${he}`,value:O,onChange:ge=>A(ge.target.value),onBlur:()=>{R()},onKeyDown:ge=>{ge.key==="Escape"&&(ge.preventDefault(),I())},placeholder:de?h0:void 0})})]}):p.jsxs(p.Fragment,{children:[Fe?p.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ee.id,title:"Drag to reorder","aria-label":`Reorder ${he}`,"aria-grabbed":Q===ee.id,onPointerDown:ge=>U(ee.id,ge),onPointerMove:ae,onPointerUp:_e,onPointerCancel:Ne,onKeyDown:ge=>{(ge.key==="ArrowUp"||ge.key==="ArrowDown")&&(ge.preventDefault(),ge.stopPropagation(),M(ee.id,ge.key==="ArrowUp"?-1:1))},onClick:ge=>ge.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:`server-list-item${ze?" server-list-item--active":""}`,onClick:()=>n(de?null:ee.id),onDoubleClick:ge=>{ge.preventDefault(),L(de?"main":{id:ee.id,name:he})},title:gD(he,Se[Ae]),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:de?void 0:ee.agent.url??"Outbound connection to main",children:he})]}),Ee?p.jsx(bD,{entry:Se[Ae]}):null]})]})}),oe?p.jsx("div",{className:"server-list-children",children:oe}):null]},ee.id)})]})}function yD({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,k]=v.useState("");async function x(){try{const[A,z,$]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(z.networks),d($.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{x()},[]);async function w(A){await e.revokeDevice(A),await x()}async function D(A){await e.removeNetwork(A),await x()}async function O(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:b.trim()}),y(""),k(""),await x()}catch(z){g(z instanceof Error?z.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(A=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsxs("span",{className:"security-item-label",children:[A.label,A.current?p.jsx("span",{className:"security-badge",children:"this device"}):null]}),p.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{w(A.id)},children:"revoke"})]},A.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(A=>p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?p.jsx("span",{className:"security-item-meta",children:A.label}):null]}),p.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(A.id)},children:"remove"})]},A.id))}),p.jsxs("form",{className:"security-add-form",onSubmit:O,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:A=>y(A.currentTarget.value),required:!0}),p.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>k(A.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 x()},children:"Disable 2FA"})]}):null]})}const SD=1500,t_="nterminal.terminal.fontSize",i_="nterminal.terminal.fontFamily",hg="nterminal:terminal-font-size",fg="nterminal:terminal-font-family",pg=11,mg=20,to=14,xh=[{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:[]}],cl="meslo";gg(cl);async function _m(e=to,t=cl){if(typeof document>"u"||!document.fonts)return;const n=eC(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,SD)})])}function Q1(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return to;const n=Math.round(t);return Math.max(pg,Math.min(mg,n))}function J1(e){return xh.some(t=>t.id===e)?e:cl}function gg(e){return eC(e).cssFamily}function eC(e){return xh.find(t=>t.id===e)??xh[0]}function vg(){if(typeof window>"u")return to;try{const e=window.localStorage.getItem(t_);return e?Q1(e):to}catch{return to}}function _g(){if(typeof window>"u")return cl;try{return J1(window.localStorage.getItem(i_))}catch{return cl}}function Kd(e){const t=Q1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(t_,String(t))}catch{}return window.dispatchEvent(new CustomEvent(hg,{detail:t})),t}function wD(e){const t=J1(e);if(typeof window>"u")return t;try{window.localStorage.setItem(i_,t)}catch{}return window.dispatchEvent(new CustomEvent(fg,{detail:t})),t}function tC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===t_&&e()};return window.addEventListener(hg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(hg,e),window.removeEventListener("storage",t)}}function iC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===i_&&e()};return window.addEventListener(fg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(fg,e),window.removeEventListener("storage",t)}}const n_="nterminal.terminal.showScrollProgress",bg="nterminal:terminal-scroll-progress",r_="nterminal.terminal.tmuxScrollback.shell",s_="nterminal.terminal.tmuxScrollback.agent",a_="nterminal.terminal.tmuxScrollback.overrides",Gc="nterminal:terminal-tmux-scrollback",CD=200;function yg(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(n_)!=="false"}catch{return!0}}function xD(e){if(typeof window<"u"){try{window.localStorage.setItem(n_,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(bg,{detail:e}))}return e}function nC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===n_&&e()};return window.addEventListener(bg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(bg,e),window.removeEventListener("storage",t)}}function Sg(){return rC(r_,!0)}function kD(e){return sC(r_,e,Gc)}function wg(){return rC(s_,!0)}function ED(e){return sC(s_,e,Gc)}function sh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===r_||n.key===s_||n.key===a_)&&e()};return window.addEventListener(Gc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Gc,e),window.removeEventListener("storage",t)}}function bm(e){const n=aC()[e];return typeof n=="boolean"?n:null}function TD(e,t){if(typeof window<"u"){try{const n=aC(),s=Object.entries(n).filter(([c])=>c!==e);s.push([e,t]);const o=s.slice(-CD);window.localStorage.setItem(a_,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Gc,{detail:{terminalId:e,enabled:t}}))}return t}function rC(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 sC(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 aC(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(a_);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 o_="nterminal.shortcuts.workspace.v1",Cg="nterminal:workspace-shortcuts",Zc=[{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}],Qh={"server.previous":Ti("ArrowUp",{ctrlKey:!0}),"server.next":Ti("ArrowDown",{ctrlKey:!0}),"tab.previous":Ti("ArrowLeft",{ctrlKey:!0}),"tab.next":Ti("ArrowRight",{ctrlKey:!0}),"tab.index":Ti("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Ti("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Ti("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ti("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ti("KeyH",{altKey:!0}),"scrollback.toggle":Ti("KeyS",{altKey:!0})},DD={"server.previous":Ti("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Ti("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Ti("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Ti("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Ti("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Ti("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Ti("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ti("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ti("KeyH",{altKey:!0}),"scrollback.toggle":Ti("KeyS",{altKey:!0})};function ao(){const e=cC(Qh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(o_);if(!t)return e;const n=JSON.parse(t);for(const s of Zc){const o=n[s.id];if(jD(o)){const c=uC(o,s);BD(c,DD[s.id])||(e[s.id]=c)}}}catch{return e}return e}function v0(){return JSON.stringify(ao())}function RD(e,t){const n=ao(),s=Zc.find(o=>o.id===e);return s&&(n[e]=uC(t,s),l_(n)),n}function MD(e){const t=ao();return t[e]={...Qh[e]},l_(t),t}function ND(){const e=cC(Qh);return l_(e),e}function kh(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===o_&&e()};return window.addEventListener(Cg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Cg,e),window.removeEventListener("storage",t)}}function AD(e,t){const n=fC(e);return!n||ID(n)||t.indexed&&hC(e)===null||t.requiresPrimaryModifier&&!dC(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function oC(e){const t=ao();for(const n of Zc){const s=t[n.id];if(!(!s||!zD(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const o=hC(e);if(o!==null)return{id:n.id,index:o};continue}if(fC(e)===s.code)return{id:n.id,index:null}}}return null}function Eh(e){return lC(ao()[e])}function lC(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(PD(e.code)),t.join("+")}const LD=()=>Eh("split.right"),OD=()=>Eh("split.down");function Ti(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function cC(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function BD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function l_(e){if(!(typeof window>"u")){try{window.localStorage.setItem(o_,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Cg))}}function uC(e,t){return t.requiresPrimaryModifier&&!dC(e)?{...Qh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function dC(e){return e.ctrlKey||e.altKey||e.metaKey}function jD(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 zD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function hC(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 fC(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 ID(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function PD(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 HD="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 UD(e="nterminal",t=new Date){return{reason:"permission",message:HD,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function KD(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 pC=3600*1e3,FD="local",xg=new Set,ba=new Map;let Ca={checking:!1,hasUpdates:!1,lastCheckedAt:null},c_=null,Wc=null,Th=0,fa=null;function WD(e){return xg.add(e),()=>{xg.delete(e)}}function _0(){return Ca}function qD(e){const t=GD();c_=e,u_(),kg(e,t);const n=()=>{if(document.visibilityState!=="visible"||!xa(e,t))return;const s=Ca.lastCheckedAt;(s===null||Date.now()-s>=pC)&&kg(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),xa(e,t)&&XD()}}function $D(e,t){ba.set(e,mC(t)),ul({...Ca,hasUpdates:d_(),lastCheckedAt:Date.now()})}function ym(e){e===void 0?ba.clear():ba.set(e,!1),ul({...Ca,hasUpdates:d_()})}async function kg(e,t){if(!xa(e,t))return;if(fa&&fa.api===e&&fa.runId===t)return fa.promise;ul({...Ca,checking:!0});const n=VD(e,t).finally(()=>{fa?.promise===n&&(fa=null),xa(e,t)&&(ul({...Ca,checking:!1,lastCheckedAt:Date.now()}),YD(e,t))});return fa={api:e,runId:t,promise:n},n}async function VD(e,t){try{const n=await e.listAgents();if(!xa(e,t))return;const s=[{key:FD,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,mC(d))}catch{o.set(c.key,ba.get(c.key)??!1)}})),!xa(e,t))return;ba.clear();for(const[c,d]of o)ba.set(c,d);ul({...Ca,hasUpdates:d_()})}catch{}}function YD(e,t){xa(e,t)&&(u_(),Wc=window.setTimeout(()=>{Wc=null,xa(e,t)&&kg(e,t)},pC))}function XD(){Th+=1,u_(),c_=null,fa=null,ba.clear(),ul({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function u_(){Wc!==null&&(window.clearTimeout(Wc),Wc=null)}function GD(){return Th+=1,Th}function xa(e,t){return c_===e&&Th===t}function mC(e){return e.updateAvailable===!0}function d_(){return Array.from(ba.values()).some(Boolean)}function ul(e){Ca=e;for(const t of Array.from(xg))t()}const ZD=e=>new Promise(t=>setTimeout(t,e));function QD({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[d,m]=v.useState(!1),[g,f]=v.useState(null),[y,b]=v.useState(!1),[k,x]=v.useState({});function w(R,I){c(se=>({...se,[R]:{...se[R],...I}}))}function D(R,I){x(se=>({...se,[R]:{status:se[R]?.status??null,busy:se[R]?.busy??!1,error:se[R]?.error??null,...I}}))}const O=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),A=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),z=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),$=R=>R.id===null?e:ol(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async I=>{if(R)return;let se="Local";try{se=(await e.getMainInfo()).name?.trim()||se}catch{}if(R)return;const ye=new Map(I.agents.map(U=>[U.id,U])),M=Ss(I.serverOrder,I.agents).flatMap(U=>{if(U===Yi)return[{key:"local",id:null,name:se}];const ae=ye.get(U);return ae?[{key:ae.id,id:ae.id,name:ae.name}]:[]});s(M);for(const U of M)O(U).then(ae=>w(U.key,{version:ae,manualUpdate:ae.manualUpdate??null})).catch(ae=>w(U.key,{error:ae instanceof Error?ae.message:"unreachable"})),W(U)}).catch(()=>{}),()=>{R=!0}},[]);async function K(R){w(R.key,{busy:!0,status:"checking…",error:void 0});try{const I=await A(R);$D(R.key,I),w(R.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:ie(I),...I.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(I){w(R.key,{busy:!1,error:I instanceof Error?I.message:"check failed"})}}async function Q(){m(!0),await Promise.all(n.map(R=>K(R))),m(!1)}async function F(R,I){const se=Date.now()+18e4;for(;Date.now()<se;){await ZD(3e3);try{const ye=await O(R);if(I&&ye.runningVersion!==I.runningVersion)return ye}catch{}}return null}async function q(R){let I=o[R.key]?.version;if(!I)try{I=await O(R),w(R.key,{version:I,manualUpdate:I.manualUpdate??null})}catch(M){return w(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}w(R.key,{busy:!0,status:"updating…",error:void 0});let se;try{se=await z(R)}catch(M){return w(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!se.ok){const M=se.manualUpdate??(KD(se.message)?UD():null);return M?(w(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(w(R.key,{busy:!1,status:void 0,error:se.message}),"failed")}if(!se.changed)return w(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),ym(R.key),"unchanged";w(R.key,{status:"restarting…"});const ye=await F(R,I);return ye?(w(R.key,{busy:!1,version:ye,updateAvailable:!1,status:"updated",manualUpdate:ye.manualUpdate??null}),ym(R.key),R.id===null&&(b(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(w(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function be(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
|
-
`)))){w(R.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const se=await e.uninstallAgent(R.id);s(ye=>ye.filter(M=>M.key!==R.key)),c(ye=>{const M={...ye};return delete M[R.key],M}),ym(R.key),t?.(R.id),f(se.message)}catch(se){w(R.key,{busy:!1,status:void 0,error:se instanceof Error?se.message:"delete failed"})}}}async function Se(){m(!0),f(null);const R=n.filter(ae=>ae.id!==null),I=n.find(ae=>ae.id===null),se=await Promise.all(R.map(ae=>q(ae))),ye=se.filter(ae=>ae==="failed").length;let M=se.filter(ae=>ae==="manual").length,U=null;if(I&&(U=await q(I),U==="manual"&&(M+=1),U==="updated")){ye>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}ye>0&&M>0?f("Some servers failed and some need manual update. Check each marked row."):ye>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 De(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function ie(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function G(R){const I=R?.version;return I?`npm package v${I.runningVersion}`:""}async function Z(R,I){try{await eR(I),w(R,{copiedCommand:!0}),window.setTimeout(()=>w(R,{copiedCommand:!1}),1800)}catch(se){w(R,{error:se instanceof Error?se.message:"copy failed"})}}async function W(R,I=!1){try{const se=await $(R).getCodeServerStatus(I?{checkLatest:!0}:void 0);D(R.key,{status:se,error:null})}catch(se){D(R.key,{error:se instanceof Error?se.message:"code-server status failed"})}}async function re(R,I){if(I==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const se=$(R);D(R.key,{busy:!0,error:null});try{if(I==="install"){const ye=await se.installCodeServer();D(R.key,{status:ye.status})}else if(I==="update"){const ye=await se.updateCodeServer();D(R.key,{status:ye.status})}else if(I==="stop")D(R.key,{status:await se.stopCodeServer()});else{const ye=await se.uninstallCodeServer();D(R.key,{status:ye.status})}}catch(ye){D(R.key,{error:ye instanceof Error?ye.message:"code-server action failed"})}finally{D(R.key,{busy:!1})}}const L=n.filter(R=>k[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(se=>k[se.key]?.status?.job?.status==="running");if(R.length===0)return;const I=window.setInterval(()=>{for(const se of R)W(se)},1e3);return()=>window.clearInterval(I)},[L]),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:()=>{Q()},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 I=o[R.key],se=G(I),ye=I?.manualUpdate??null,M=k[R.key]??{status:null,busy:!1,error:null},U=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!d,ae=R.id!==null&&!I?.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:[se?`${se} — `:"",De(I)]})]}),ye?p.jsxs("div",{className:"server-manual-update",children:[p.jsx("span",{children:ye.message}),p.jsxs("div",{className:"server-manual-command",children:[p.jsx("code",{children:ye.command}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Z(R.key,ye.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null,p.jsx(JD,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{W(R,!0)},onInstall:()=>{re(R,"install")},onUpdate:()=>{re(R,"update")},onStop:()=>{re(R,"stop")},onUninstall:()=>{re(R,"uninstall")}})]}),p.jsxs("div",{className:"server-row-actions",children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{q(R)},disabled:!U,children:I?.busy?"…":"Update"}),R.id!==null?p.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{be(R)},disabled:!ae,children:"Delete"}):null]})]},R.key)})})]})}function JD({status:e,busy:t,error:n,onCheck:s,onInstall:o,onUpdate:c,onStop:d,onUninstall:m}){const g=e?.job??null,f=g?.status==="running",y=e!==null,b=e?.installed===!0,k=(e?.instances.length??0)>0,x=e?.supported!==!1,w=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:[x?w?"checking...":b?`code-server v${e?.version??"unknown"}${k?` — ${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||!x,children:"Check"}),b?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||f||!x,children:e?.updateAvailable?"Update code-server":"Reinstall"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||f||!k,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||w||t||f||!x,children:"Install code-server"})]})]})}async function eR(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 Fd=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function tR({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const c=v.useMemo(()=>t??Kh(),[t]),[d,m]=v.useState(()=>vg()),[g,f]=v.useState(()=>_g()),[y,b]=v.useState(()=>yg()),[k,x]=v.useState(()=>Sg()),[w,D]=v.useState(()=>wg()),[O,A]=v.useState(()=>Sa()),[z,$]=v.useState(()=>ao()),[K,Q]=v.useState(null),[F,q]=v.useState(null),[be,Se]=v.useState("appearance"),[De,ie]=v.useState(()=>Qv()),[G,Z]=v.useState(()=>so()),[W,re]=v.useState(()=>vl()),[L,R]=v.useState([]),[I,se]=v.useState([]),[ye,M]=v.useState([]),[U,ae]=v.useState(5*1024*1024),[_e,Ne]=v.useState(!1),[xe,Le]=v.useState(null),[Ee,je]=v.useState(null),[Fe,ee]=v.useState(!1),[de,he]=v.useState(null),[Ae,ze]=v.useState(null),Me=v.useRef(null),oe=v.useRef(null),ke=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),ge=v.useMemo(()=>new Set(I),[I]),Oe=!nR(I,ye),Ve=v.useMemo(()=>Zh(),[]),ot=Ee?.displayMode==="standalone"&&(Ee.deviceKind==="mobile"||Ee.deviceKind==="tablet");v.useEffect(()=>tC(()=>m(vg())),[]),v.useEffect(()=>iC(()=>f(_g())),[]),v.useEffect(()=>nC(()=>b(yg())),[]),v.useEffect(()=>sh(()=>{x(Sg()),D(wg())}),[]),v.useEffect(()=>Hv(()=>A(Sa())),[]),v.useEffect(()=>kh(()=>$(ao())),[]),v.useEffect(()=>F1(()=>Z(so())),[]),v.useEffect(()=>{if(!K)return;const V=Zc.find(rt=>rt.id===K);if(!V)return;const Ke=rt=>{if(rt.preventDefault(),rt.stopPropagation(),rt.key==="Escape"){Q(null),q(null);return}const st=AD(rt,V);if(!st){q(iR(V));return}$(RD(K,st)),Q(null),q(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[K]),v.useEffect(()=>{let V=!1;return c.listNotificationAssets().then(Ke=>{V||ft(Ke)}).catch(Ke=>{V||Le(Jo(Ke))}),()=>{V=!0}},[c]),v.useEffect(()=>{let V=!1;return c.getPushNotificationStatus(ws()).then(Ke=>{V||(je(Ke.currentDevice),he(null))}).catch(Ke=>{V||he(Jo(Ke))}),()=>{V=!0}},[c]);function vt(V){m(Kd(Number(V)))}function xt(V){Z(c0(Number(V)))}function jn(V){Se(V);const Ke=oe.current,rt=ke.current[V];if(!Ke||!rt)return;const st=Math.max(0,b0(rt,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:st,behavior:"smooth"}):Ke.scrollTop=st}function ni(){const V=oe.current;if(!V)return;if(V.scrollTop+V.clientHeight>=V.scrollHeight-2){Se(Fd[Fd.length-1].id);return}let Ke="appearance";const rt=V.scrollTop+Math.min(180,Math.max(48,V.clientHeight*.28));for(const st of Fd){const Rt=ke.current[st.id];Rt&&b0(Rt,V)<=rt&&(Ke=st.id)}Se(Ke)}function mi(V){$(MD(V)),Q(null),q(null)}function Ye(){$(ND()),Q(null),q(null)}function ft(V){const Ke=V.assets.filter(rt=>rt.enabled).map(rt=>rt.id);R(V.assets),se(Ke),M(Ke),ae(V.maxFileBytes),Le(null)}async function Vt(){if(De){l0(!1),ie(!1);return}let V=W;V==="default"&&(V=await q1(),re(V)),V==="granted"&&(l0(!0),ie(!0))}async function ve(){ee(!0),he(null),ze(null);try{if(Ee)await J2(c),je(null);else{await G2(c,!1);const V=await c.getPushNotificationStatus(ws());je(V.currentDevice)}}catch(V){he(wm(V))}finally{ee(!1)}}async function Ue(V){ee(!0),he(null),ze(null);try{await eD(c,V);const Ke=await c.getPushNotificationStatus(ws());je(Ke.currentDevice)}catch(Ke){he(wm(Ke))}finally{ee(!1)}}async function nt(){ee(!0),he(null),ze(null);try{await c.testPushNotification({clientId:ws()}),ze("Test notification accepted by the push service.")}catch(V){he(wm(V))}finally{ee(!1)}}async function Ze(V){const Ke=V?.[0];if(Ke){if(Ke.size>U){Le(`File must be ${Sm(U)} or smaller.`),ht();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){Le("Upload an MP4 or WebM video."),ht();return}Ne(!0),Le(null);try{await c.uploadNotificationAsset(Ke),ft(await c.listNotificationAssets()),s?.()}catch(rt){Le(Jo(rt))}finally{Ne(!1),ht()}}}async function Et(V){Ne(!0),Le(null);try{await c.deleteNotificationAsset(V),ft(await c.listNotificationAssets()),s?.()}catch(Ke){Le(Jo(Ke))}finally{Ne(!1)}}function ht(){Me.current&&(Me.current.value="")}function Qt(V,Ke){const rt=new Set(I);if(Ke?rt.add(V):rt.delete(V),rt.size===0){Le("Keep at least one toast video selected.");return}Le(null),se(Array.from(rt))}async function oi(){if(I.length===0){Le("Keep at least one toast video selected.");return}Ne(!0),Le(null);try{const V=await c.updateNotificationAssetSelection({enabledAssetIds:I});ft(V),s?.()}catch(V){Le(Jo(V))}finally{Ne(!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:V=>V.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:Fd.map(V=>p.jsxs("button",{type:"button","data-active":be===V.id?"true":"false","aria-current":be===V.id?"true":void 0,onClick:()=>jn(V.id),children:[V.label,V.id==="servers"&&n?p.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},V.id))}),p.jsxs("div",{ref:oe,className:"settings-content",onScroll:ni,children:[p.jsxs("section",{id:"settings-appearance",ref:V=>{ke.current.appearance=V},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:bh.map(V=>p.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":O===V.id,"data-active":O===V.id?"true":"false",onClick:()=>A(KE(V.id)),style:{"--settings-theme-bg":V.tokens.bg,"--settings-theme-bg-2":V.tokens.bg2,"--settings-theme-sidebar":V.tokens.bgSidebar,"--settings-theme-line":V.tokens.line,"--settings-theme-fg":V.tokens.fg,"--settings-theme-fg-2":V.tokens.fg2,"--settings-theme-accent":V.tokens.accent,"--settings-theme-xterm-bg":V.xterm.background,"--settings-theme-xterm-fg":V.xterm.foreground,"--settings-theme-xterm-selection":V.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:V.label}),p.jsx("small",{children:V.description})]})]},V.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:pg,max:mg,step:1,value:d,"aria-label":"Terminal font size",onChange:V=>vt(V.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row",children:[p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Kd(d-1)),children:"-"}),p.jsx("input",{type:"number",min:pg,max:mg,step:1,value:d,"aria-label":"Terminal font size value",onChange:V=>vt(V.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Kd(d+1)),children:"+"}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(Kd(to)),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:V=>f(wD(V.currentTarget.value)),children:xh.map(V=>p.jsx("option",{value:V.id,children:V.label},V.id))})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:y,onChange:V=>b(xD(V.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:k,onChange:V=>x(kD(V.currentTarget.checked))}),"Shell panes"]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:w,onChange:V=>D(ED(V.currentTarget.checked))}),"Codex/Claude panes"]})]}),p.jsxs("section",{id:"settings-shortcuts",ref:V=>{ke.current.shortcuts=V},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:Ye,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:Zc.map(V=>{const Ke=K===V.id;return p.jsxs("li",{children:[p.jsxs("div",{children:[p.jsx("span",{className:"settings-shortcut-label",children:V.label}),p.jsx("span",{className:"settings-shortcut-group",children:V.group})]}),p.jsxs("div",{className:"settings-shortcut-actions",children:[p.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{Q(V.id),q(null)},children:Ke?"Press keys…":lC(z[V.id])}),p.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>mi(V.id),children:"Reset"})]})]},V.id)})})]}),p.jsxs("section",{id:"settings-notifications",ref:V=>{ke.current.notifications=V},className:"security-section settings-section",children:[p.jsx("h3",{children:"Notifications"}),Gh()?p.jsxs(p.Fragment,{children:[p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:De&&W==="granted",onChange:()=>{Vt()},disabled:W==="denied"}),"System notification when page is hidden"]}),W==="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:!!Ee,onChange:()=>{ve()},disabled:Fe||!Ve.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."}),Ve.supported?null:p.jsx("p",{className:"muted",children:ah(Ve.reason)}),Ee?p.jsxs(p.Fragment,{children:[p.jsxs("p",{className:"muted",children:["Registered as ",Ee.label,". Last active ",new Date(Ee.lastActiveAt).toLocaleString(),"."]}),p.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{nt()},disabled:Fe,children:"Send test notification"})]}):null,ot?p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:Ee?.alwaysNotify===!0,onChange:V=>{Ue(V.currentTarget.checked)},disabled:Fe||!Ee}),"Always notify this mobile device"]}):null,de?p.jsx("p",{className:"form-error",children:de}):null,Ae?p.jsx("p",{className:"muted",role:"status",children:Ae}):null]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:G.enabled,onChange:V=>Z(U2(V.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:G.persistUntilDismissed?"Until closed":`${G.durationSeconds}s`}),p.jsx("input",{type:"range",min:og,max:lg,step:.5,value:G.durationSeconds,disabled:!G.enabled||G.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:V=>xt(V.currentTarget.value)})]}),p.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[p.jsx("input",{type:"number",min:og,max:lg,step:.5,value:G.durationSeconds,disabled:!G.enabled||G.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:V=>xt(V.currentTarget.value)}),p.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!G.enabled||G.persistUntilDismissed,onClick:()=>Z(c0(Fc)),children:"Reset"})]}),p.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[p.jsx("input",{type:"checkbox",checked:G.persistUntilDismissed,disabled:!G.enabled,onChange:V=>Z(K2(V.currentTarget.checked))}),"Keep toast until dismissed"]}),p.jsxs("div",{className:"settings-assets-header",children:[p.jsx("span",{children:"Toast videos"}),p.jsxs("span",{children:[Sm(U)," max"]})]}),p.jsx("input",{ref:Me,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:V=>{Ze(V.currentTarget.files)}}),p.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:_e,onClick:()=>Me.current?.click(),children:"Upload video"}),xe?p.jsx("p",{className:"settings-error",children:xe}):null,L.length>0?p.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:L.map(V=>p.jsxs("li",{"data-enabled":ge.has(V.id)?"true":"false",children:[p.jsxs("label",{className:"settings-asset-choice",children:[p.jsx("input",{type:"checkbox",checked:ge.has(V.id),disabled:_e,"aria-label":`Use ${V.filename}`,onChange:Ke=>Qt(V.id,Ke.currentTarget.checked)}),p.jsx("video",{src:V.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),p.jsxs("span",{className:"settings-asset-copy",children:[p.jsx("span",{children:V.filename}),p.jsx("small",{children:V.source==="built-in"?"Built-in":Sm(V.size)})]})]}),V.source==="uploaded"?p.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:_e,"aria-label":`Delete ${V.filename}`,onClick:()=>{Et(V.id)},children:"x"}):null]},V.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||L.length===0||!Oe,onClick:()=>{oi()},children:"Save selected videos"})]}),p.jsx("div",{id:"settings-security",ref:V=>{ke.current.security=V},className:"settings-section-group",children:p.jsx(yD,{api:c})}),p.jsx("div",{id:"settings-servers",ref:V=>{ke.current.servers=V},className:"settings-section-group",children:p.jsx(QD,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function b0(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function Sm(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 Jo(e){return e instanceof Error?e.message:"Request failed."}function ah(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 wm(e){const t=Jo(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?ah("not_standalone"):t==="insecure"?ah("insecure"):t==="not_mobile"?ah("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 iR(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 nR(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}class Xa extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function rR(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 Xa(0,"Upload aborted."))};if(e.signal?.aborted){f(new Xa(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 Xa(t.status,"Invalid upload response."))}return}f(new Xa(t.status,sR(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Xa(0,"Upload failed.")),t.onabort=()=>f(new Xa(0,"Upload aborted.")),t.ontimeout=()=>f(new Xa(0,"Upload timed out.")),t.send(n)})}function sR(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 aR="modulepreload",oR=function(e){return"/"+e},y0={},h_=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=oR(f),f in y0)return;y0[f]=!0;const y=f.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":aR,y||(k.as="script"),k.crossOrigin="",k.href=f,m&&k.setAttribute("nonce",m),document.head.appendChild(k),y)return new Promise((x,w)=>{k.addEventListener("load",x),k.addEventListener("error",()=>w(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)})},lR=v.lazy(()=>h_(()=>import("./MarkdownPreview-D2UZ6wJU.js"),__vite__mapDeps([0,1])));function cR({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,k]=v.useState(()=>new Set),[x,w]=v.useState(null),[D,O]=v.useState({type:"empty"}),[A,z]=v.useState("idle"),[$,K]=v.useState(null),Q=v.useRef(null),F=v.useRef(null),q=v.useRef(!1),be=v.useRef(0),Se=v.useRef(null);Se.current===null&&t&&(Se.current=t);const De=Se.current,ie=s?dR(s):t?S0(t,n):null,G=c?[c.rootPath,m].filter(Boolean).join("/"):"",Z=x?.path??null;v.useEffect(()=>(q.current=!0,()=>{q.current=!1,be.current+=1,ee()}),[]),v.useEffect(()=>{Se.current=t,F.current=null,W(ie)},[e]),v.useEffect(()=>{s&&ie!==F.current&&re(s,ie)},[s,ie]),v.useEffect(()=>{if(s||!De||t!==De)return;const oe=S0(De,n);oe!==F.current&&L(De,oe)},[De,t,n,s]);async function W(oe=ie){if(s){await re(s,oe);return}await L(t,oe)}async function re(oe,ke=ie){const ge=de();if(F.current=ke,ee(),d(null),g(""),y({}),k(new Set),w(null),O({type:"empty"}),K(null),!oe){z("idle");return}z("loading");try{const Oe=await e.createFileRoot({path:oe});if(!he(ge))return;d({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const Ve=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!he(ge))return;se(Ve),z("idle")}catch(Oe){he(ge)&&(K(vs(Oe)),z("idle"))}}async function L(oe,ke=ie){const ge=de();if(F.current=ke,ee(),d(null),g(""),y({}),k(new Set),w(null),O({type:"empty"}),K(null),!oe){z("idle");return}z("loading");try{const Oe=await e.createFileRoot({terminalId:oe});if(!he(ge))return;d({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const Ve=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!he(ge))return;se(Ve),z("idle")}catch(Oe){if(await Ae(Oe,ge))return;he(ge)&&(K(vs(Oe)),z("idle"))}}async function R(oe=m,ke=c){if(!ke)return;const ge=de();z("loading"),K(null);try{const Oe=await e.listFiles({rootToken:ke.rootToken,path:oe});if(!he(ge))return;se(Oe),z("idle")}catch(Oe){if(await Ae(Oe,ge))return;he(ge)&&(K(vs(Oe)),z("idle"))}}async function I(){if(s){await re(s,ie);return}Se.current=t,await L(t,ie)}function se(oe){y(ke=>({...ke,[oe.path]:hR(oe.entries)}))}async function ye(oe){if(!(!Cm(oe)||!c)){if(w(oe),K(null),oe.kind==="directory"){g(oe.path),Fe(),await U(oe);return}if(g(Ga(oe.path)),oe.editable){await _e(oe);return}oe.previewKind!=="none"&&await xe(oe,oe.previewKind)}}async function M(oe){if(!(!Cm(oe)||!c)){if(w(oe),K(null),oe.kind==="directory"){g(oe.path),Fe(),await U(oe);return}if(g(Ga(oe.path)),oe.editable){await Ne(oe);return}oe.previewKind!=="none"&&await xe(oe,oe.previewKind)}}async function U(oe){if(b.has(oe.path)){k(ke=>{const ge=new Set(ke);return ge.delete(oe.path),ge});return}k(ke=>new Set(ke).add(oe.path)),await R(oe.path)}function ae(oe,ke){oe.key==="Enter"&&(oe.preventDefault(),M(ke))}async function _e(oe){if(!c)return;const ke=de();z("loading"),ee();try{const ge=await e.readFile({rootToken:c.rootToken,path:oe.path});if(!he(ke))return;O({type:"text-preview",file:oe,read:ge}),z("idle")}catch(ge){if(await Ae(ge,ke))return;he(ke)&&(K(vs(ge)),z("idle"))}}async function Ne(oe){if(!c)return;const ke=de();z("loading");try{await o({rootToken:c.rootToken,path:oe.path,...t?{terminalId:t}:{}}),he(ke)&&z("idle")}catch(ge){if(await Ae(ge,ke))return;he(ke)&&(K(vs(ge)),z("idle"))}}async function xe(oe,ke){if(!c)return;const ge=de();z("loading"),ee();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:oe.path});if(!he(ge))return;const Ve=URL.createObjectURL(Oe);if(!he(ge)){URL.revokeObjectURL(Ve);return}Q.current=Ve,O({type:"preview",file:oe,previewKind:ke,url:Ve}),z("idle")}catch(Oe){if(await Ae(Oe,ge))return;he(ge)&&(K(vs(Oe)),z("idle"))}}async function Le(oe){if(!c)return;const ke=oe==="file"?"New file":"New folder",ge=window.prompt(ke,""),Oe=x?x.kind==="directory"?x.path:Ga(x.path):m,Ve=w0(ge,Oe);if(Ve){K(null);try{const ot=await e.createFileEntry({rootToken:c.rootToken,path:Ve,kind:oe});w(ot.entry),await R(Oe)}catch(ot){if(await Ae(ot))return;K(vs(ot))}}}async function Ee(){if(!c||!x)return;const oe=window.prompt("Move selected entry",x.path),ke=w0(oe,"");if(!ke||ke===x.path)return;const ge=Ga(x.path),Oe=Ga(ke);K(null);try{const Ve=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:x.path,destinationPath:ke});w(Ve.entry),g(Ve.entry.kind==="directory"?Ve.entry.path:Ga(Ve.entry.path)),Fe(),await R(ge),Oe!==ge&&await R(Oe)}catch(Ve){if(await Ae(Ve))return;K(vs(Ve))}}async function je(){if(!c||!x)return;const oe=x.path,ke=Ga(oe);K(null);try{const ge=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:x.path}),Oe=ge.descendantCount>0?` and ${ge.descendantCount} nested item${ge.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${ge.path}${Oe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:x.path,previewToken:ge.previewToken}),w(null),g(ke),k(Ve=>{const ot=new Set(Ve);for(const vt of Ve)(vt===oe||vt.startsWith(`${oe}/`))&&ot.delete(vt);return ot}),Fe(),await R(ke)}catch(ge){if(await Ae(ge))return;K(vs(ge))}}function Fe(){be.current+=1,ee(),O({type:"empty"})}function ee(){Q.current&&(URL.revokeObjectURL(Q.current),Q.current=null)}function de(){return be.current+=1,be.current}function he(oe){return q.current&&oe===be.current}async function Ae(oe,ke){return fR(oe)?(ke!==void 0&&!he(ke)||await W(ie),!0):!1}function ze(oe,ke){const ge=Cm(oe),Oe=oe.kind==="directory"&&b.has(oe.path),Ve=f[oe.path]??[],ot={"--file-tree-depth":ke};return p.jsxs(Bi.Fragment,{children:[p.jsxs("button",{type:"button",className:"file-entry-button","data-kind":oe.kind,"data-expanded":Oe,"data-active":Z===oe.path,disabled:!ge,style:ot,"aria-expanded":oe.kind==="directory"?Oe:void 0,"aria-label":`${oe.kind==="directory"?"Open folder":"Open file"} ${oe.name}`,title:oe.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ye(oe)},onDoubleClick:()=>{M(oe)},onKeyDown:vt=>ae(vt,oe),children:[p.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:oe.kind==="directory"?Oe?"▾":"▸":""}),p.jsx("span",{className:"file-entry-name",children:oe.name}),p.jsx("small",{children:uR(oe)})]}),Oe?p.jsx("div",{className:"file-tree-children",role:"group",children:Ve.map(vt=>ze(vt,ke+1))}):null]},oe.path)}const Me=f[""]??[];return p.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[p.jsxs("header",{className:"file-explorer-header",children:[p.jsx("div",{className:"file-explorer-path",title:G,children:G||"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:()=>{I()},children:"↻"}),p.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Le("file")},children:"+"}),p.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Le("directory")},children:"▣"})]})]}),$?p.jsx("div",{className:"file-explorer-alert",role:"alert",children:$}):null,p.jsxs("div",{className:"file-explorer-layout",children:[p.jsx("div",{className:"file-tree","aria-label":G?`Files in ${G}`:"Files",children:Me.map(oe=>ze(oe,0))}),p.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[p.jsxs("div",{className:"file-detail-header",children:[p.jsx("strong",{children:x?.name??"detail"}),p.jsxs("div",{className:"file-detail-actions",children:[p.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!x,onClick:()=>{Ee()},children:"Move"}),p.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!x,onClick:()=>{je()},children:"Delete"})]})]}),A==="loading"?p.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&A!=="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(lR,{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 Cm(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function uR(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function S0(e,t){return`${e}\0${t??""}`}function dR(e){return`workspace\0${e}`}function hR(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 Ga(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function w0(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 vs(e){return e instanceof Error?e.message:"Request failed"}function fR(e){return e instanceof On&&e.status===409&&e.message==="terminal_cwd_changed"}const pR=v.lazy(()=>h_(()=>import("./MarkdownPreview-D2UZ6wJU.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),[k,x]=v.useState(!1),[w,D]=v.useState("edit"),O=v.useRef(t),A=v.useRef(t.read),z=v.useRef(t.read.content),$=v.useRef(!1),K=v.useRef(!1),Q=v.useRef(0),F=d!==o.content&&g!=="saving"&&!k;v.useEffect(()=>(K.current=!0,()=>{K.current=!1,Q.current+=1}),[]),v.useEffect(()=>{Q.current+=1,$.current=!1,O.current=t,A.current=t.read,z.current=t.read.content,c(t.read),m(t.read.content),f("idle"),b(null),x(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{O.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{z.current=d},[d]),v.useEffect(()=>{if(d===o.content||k)return;const ie=window.setInterval(()=>{!$.current&&z.current!==A.current.content&&q()},1e3);return()=>window.clearInterval(ie)},[d===o.content,k,t.id]);async function q(){if($.current)return;const ie=z.current,G=A.current;if(ie===G.content)return;const Z=O.current,W=Q.current;$.current=!0,f("saving"),b(null),x(!1);try{const re=await e.writeFile({rootToken:Z.rootToken,path:Z.path,content:ie,expectedVersion:G.version});if(!K.current||W!==Q.current)return;const L={...G,content:ie,version:re.version};A.current=L,c(L),f(z.current===ie?"saved":"idle")}catch(re){if(!K.current||W!==Q.current)return;if(re instanceof On&&re.status===409){x(!0),f("idle");return}b(mR(re)),f("idle")}finally{W===Q.current&&($.current=!1)}}const be=g==="saving"?"saving":g==="saved"?"saved":o.language,Se=o.language==="markdown",De=Se&&w==="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:be}),p.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!F,onClick:()=>{q()},children:"Save"}),Se?p.jsx("button",{type:"button","aria-label":`${De?"Edit":"Preview"} ${t.title}`,onClick:()=>D(ie=>ie==="preview"?"edit":"preview"),children:De?"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,k?p.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,De?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(pR,{content:d})})}):p.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:ie=>{const G=ie.target.value;z.current=G,m(G),f("idle"),b(null),x(!1)}})]})}function mR(e){return e instanceof Error?e.message:"Request failed"}var gR=2,vR=1,_R=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(gR,Math.floor(y/e.css.cell.width)),rows:Math.max(vR,Math.floor(f/e.css.cell.height))}}};var gC=Object.defineProperty,bR=Object.getOwnPropertyDescriptor,yR=(e,t)=>{for(var n in t)gC(e,n,{get:t[n],enumerable:!0})},pi=(e,t,n,s)=>{for(var o=s>1?void 0:s?bR(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&&gC(t,n,o),o},Be=(e,t)=>(n,s)=>t(n,s,e),x0="Terminal input",Eg={get:()=>x0,set:e=>x0=e},k0="Too much output to announce, navigate to rows manually to read",Tg={get:()=>k0,set:e=>k0=e};function SR(e){return e.replace(/\r?\n/g,"\r")}function wR(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function CR(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function xR(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");vC(o,t,n,s)}}function vC(e,t,n,s){e=SR(e),e=wR(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function _C(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 E0(e,t,n,s,o){_C(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function ma(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Jh(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 kR=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}},ER=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 k=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let w=0,D;for(;(D=this.interim[++w]&63)&&w<4;)x<<=6,x|=D;let O=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=O-w;for(;f<A;){if(f>=n)return 0;if(D=e[f++],(D&192)!==128){f--,k=!0;break}else this.interim[w++]=D,x<<=6,x|=D&63}k||(O===2?x<128?f--:t[s++]=x:O===3?x<2048||x>=55296&&x<=57343||x===65279||(t[s++]=x):x<65536||x>1114111||(t[s++]=x)),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}},bC="",_a=" ",fu=class yC{constructor(){this.fg=0,this.bg=0,this.extended=new Dh}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 yC;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}},Dh=class SC{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 SC(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},pr=class wC extends fu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Dh,this.combinedData=""}static fromCharData(t){let n=new wC;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?ma(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()]}},T0="di$target",Dg="di$dependencies",xm=new Map;function TR(e){return e[Dg]||[]}function Qi(e){if(xm.has(e))return xm.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");DR(t,n,o)};return t._id=e,xm.set(e,t),t}function DR(e,t,n){t[T0]===t?t[Dg].push({id:e,index:n}):(t[Dg]=[{id:e,index:n}],t[T0]=t)}var Sn=Qi("BufferService"),CC=Qi("CoreMouseService"),uo=Qi("CoreService"),RR=Qi("CharsetService"),f_=Qi("InstantiationService"),xC=Qi("LogService"),wn=Qi("OptionsService"),kC=Qi("OscLinkService"),MR=Qi("UnicodeService"),pu=Qi("DecorationService"),Rg=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 pr,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 k={start:{x:g+1,y:e},end:{x:y+(!f&&y===d-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let w=new URL(b);["http:","https:"].includes(w.protocol)||(x=!0)}catch{x=!0}x||s.push({text:b,range:k,activate:(w,D)=>o?o.activate(w,D,k):NR(w,D),hover:(w,D)=>o?.hover?.(w,D,k),leave:(w,D)=>o?.leave?.(w,D,k)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(s)}};Rg=pi([Be(0,Sn),Be(1,wn),Be(2,kC)],Rg);function NR(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
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 ef=Qi("CharSizeService"),Ds=Qi("CoreBrowserService"),p_=Qi("MouseService"),Rs=Qi("RenderService"),AR=Qi("SelectionService"),EC=Qi("CharacterJoinerService"),_l=Qi("ThemeService"),TC=Qi("LinkProviderService"),LR=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?D0.isErrorNoTelemetry(e)?new D0(e.message+`
|
|
19
|
-
|
|
20
|
-
`+e.stack):new Error(e.message+`
|
|
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)}},OR=new LR;function oh(e){BR(e)||OR.onUnexpectedError(e)}var Mg="Canceled";function BR(e){return e instanceof jR?!0:e instanceof Error&&e.name===Mg&&e.message===Mg}var jR=class extends Error{constructor(){super(Mg),this.name=this.message}};function zR(e){return new Error(`Illegal argument: ${e}`)}var D0=class Ng extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ng)return t;let n=new Ng;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ag=class DC extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,DC.prototype)}};function $n(e,t=0){return e[e.length-(1+t)]}var IR;(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})(IR||={});function PR(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var RC;(e=>{function t(K){return K&&typeof K=="object"&&typeof K[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(K){yield K}e.single=o;function c(K){return t(K)?K:o(K)}e.wrap=c;function d(K){return K||n}e.from=d;function*m(K){for(let Q=K.length-1;Q>=0;Q--)yield K[Q]}e.reverse=m;function g(K){return!K||K[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(K){return K[Symbol.iterator]().next().value}e.first=f;function y(K,Q){let F=0;for(let q of K)if(Q(q,F++))return!0;return!1}e.some=y;function b(K,Q){for(let F of K)if(Q(F))return F}e.find=b;function*k(K,Q){for(let F of K)Q(F)&&(yield F)}e.filter=k;function*x(K,Q){let F=0;for(let q of K)yield Q(q,F++)}e.map=x;function*w(K,Q){let F=0;for(let q of K)yield*Q(q,F++)}e.flatMap=w;function*D(...K){for(let Q of K)yield*Q}e.concat=D;function O(K,Q,F){let q=F;for(let be of K)q=Q(q,be);return q}e.reduce=O;function*A(K,Q,F=K.length){for(Q<0&&(Q+=K.length),F<0?F+=K.length:F>K.length&&(F=K.length);Q<F;Q++)yield K[Q]}e.slice=A;function z(K,Q=Number.POSITIVE_INFINITY){let F=[];if(Q===0)return[F,K];let q=K[Symbol.iterator]();for(let be=0;be<Q;be++){let Se=q.next();if(Se.done)return[F,e.empty()];F.push(Se.value)}return[F,{[Symbol.iterator](){return q}}]}e.consume=z;async function $(K){let Q=[];for await(let F of K)Q.push(F);return Promise.resolve(Q)}e.asyncToArray=$})(RC||={});function oo(e){if(RC.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 HR(...e){return ii(()=>oo(e))}function ii(e){return{dispose:PR(()=>{e()})}}var MC=class NC{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{oo(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?NC.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 ya=MC,gt=class{constructor(){this._store=new ya,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)}};gt.None=Object.freeze({dispose(){}});var dl=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}},Cs=typeof window=="object"?window:globalThis,Lg=class Og{constructor(t){this.element=t,this.next=Og.Undefined,this.prev=Og.Undefined}};Lg.Undefined=new Lg(void 0);var si=Lg,R0=class{constructor(){this._first=si.Undefined,this._last=si.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===si.Undefined}clear(){let e=this._first;for(;e!==si.Undefined;){let t=e.next;e.prev=si.Undefined,e.next=si.Undefined,e=t}this._first=si.Undefined,this._last=si.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new si(e);if(this._first===si.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!==si.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==si.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==si.Undefined&&e.next!==si.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===si.Undefined&&e.next===si.Undefined?(this._first=si.Undefined,this._last=si.Undefined):e.next===si.Undefined?(this._last=this._last.prev,this._last.next=si.Undefined):e.prev===si.Undefined&&(this._first=this._first.next,this._first.prev=si.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==si.Undefined;)yield e.element,e=e.next}},UR=globalThis.performance&&typeof globalThis.performance.now=="function",KR=class AC{static create(t){return new AC(t)}constructor(t){this._now=UR&&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}},on;(e=>{e.None=()=>gt.None;function t(G,Z){return b(G,()=>{},0,void 0,!0,void 0,Z)}e.defer=t;function n(G){return(Z,W=null,re)=>{let L=!1,R;return R=G(I=>{if(!L)return R?R.dispose():L=!0,Z.call(W,I)},null,re),L&&R.dispose(),R}}e.once=n;function s(G,Z,W){return f((re,L=null,R)=>G(I=>re.call(L,Z(I)),null,R),W)}e.map=s;function o(G,Z,W){return f((re,L=null,R)=>G(I=>{Z(I),re.call(L,I)},null,R),W)}e.forEach=o;function c(G,Z,W){return f((re,L=null,R)=>G(I=>Z(I)&&re.call(L,I),null,R),W)}e.filter=c;function d(G){return G}e.signal=d;function m(...G){return(Z,W=null,re)=>{let L=HR(...G.map(R=>R(I=>Z.call(W,I))));return y(L,re)}}e.any=m;function g(G,Z,W,re){let L=W;return s(G,R=>(L=Z(L,R),L),re)}e.reduce=g;function f(G,Z){let W,re={onWillAddFirstListener(){W=G(L.fire,L)},onDidRemoveLastListener(){W?.dispose()}},L=new Te(re);return Z?.add(L),L.event}function y(G,Z){return Z instanceof Array?Z.push(G):Z&&Z.add(G),G}function b(G,Z,W=100,re=!1,L=!1,R,I){let se,ye,M,U=0,ae,_e={leakWarningThreshold:R,onWillAddFirstListener(){se=G(xe=>{U++,ye=Z(ye,xe),re&&!M&&(Ne.fire(ye),ye=void 0),ae=()=>{let Le=ye;ye=void 0,M=void 0,(!re||U>1)&&Ne.fire(Le),U=0},typeof W=="number"?(clearTimeout(M),M=setTimeout(ae,W)):M===void 0&&(M=0,queueMicrotask(ae))})},onWillRemoveListener(){L&&U>0&&ae?.()},onDidRemoveLastListener(){ae=void 0,se.dispose()}},Ne=new Te(_e);return I?.add(Ne),Ne.event}e.debounce=b;function k(G,Z=0,W){return e.debounce(G,(re,L)=>re?(re.push(L),re):[L],Z,void 0,!0,void 0,W)}e.accumulate=k;function x(G,Z=(re,L)=>re===L,W){let re=!0,L;return c(G,R=>{let I=re||!Z(R,L);return re=!1,L=R,I},W)}e.latch=x;function w(G,Z,W){return[e.filter(G,Z,W),e.filter(G,re=>!Z(re),W)]}e.split=w;function D(G,Z=!1,W=[],re){let L=W.slice(),R=G(ye=>{L?L.push(ye):se.fire(ye)});re&&re.add(R);let I=()=>{L?.forEach(ye=>se.fire(ye)),L=null},se=new Te({onWillAddFirstListener(){R||(R=G(ye=>se.fire(ye)),re&&re.add(R))},onDidAddFirstListener(){L&&(Z?setTimeout(I):I())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return re&&re.add(se),se.event}e.buffer=D;function O(G,Z){return(W,re,L)=>{let R=Z(new z);return G(function(I){let se=R.evaluate(I);se!==A&&W.call(re,se)},void 0,L)}}e.chain=O;let A=Symbol("HaltChainable");class z{constructor(){this.steps=[]}map(Z){return this.steps.push(Z),this}forEach(Z){return this.steps.push(W=>(Z(W),W)),this}filter(Z){return this.steps.push(W=>Z(W)?W:A),this}reduce(Z,W){let re=W;return this.steps.push(L=>(re=Z(re,L),re)),this}latch(Z=(W,re)=>W===re){let W=!0,re;return this.steps.push(L=>{let R=W||!Z(L,re);return W=!1,re=L,R?L:A}),this}evaluate(Z){for(let W of this.steps)if(Z=W(Z),Z===A)break;return Z}}function $(G,Z,W=re=>re){let re=(...se)=>I.fire(W(...se)),L=()=>G.on(Z,re),R=()=>G.removeListener(Z,re),I=new Te({onWillAddFirstListener:L,onDidRemoveLastListener:R});return I.event}e.fromNodeEventEmitter=$;function K(G,Z,W=re=>re){let re=(...se)=>I.fire(W(...se)),L=()=>G.addEventListener(Z,re),R=()=>G.removeEventListener(Z,re),I=new Te({onWillAddFirstListener:L,onDidRemoveLastListener:R});return I.event}e.fromDOMEventEmitter=K;function Q(G){return new Promise(Z=>n(G)(Z))}e.toPromise=Q;function F(G){let Z=new Te;return G.then(W=>{Z.fire(W)},()=>{Z.fire(void 0)}).finally(()=>{Z.dispose()}),Z.event}e.fromPromise=F;function q(G,Z){return G(W=>Z.fire(W))}e.forward=q;function be(G,Z,W){return Z(W),G(re=>Z(re))}e.runAndSubscribe=be;class Se{constructor(Z,W){this._observable=Z,this._counter=0,this._hasChanged=!1;let re={onWillAddFirstListener:()=>{Z.addObserver(this)},onDidRemoveLastListener:()=>{Z.removeObserver(this)}};this.emitter=new Te(re),W&&W.add(this.emitter)}beginUpdate(Z){this._counter++}handlePossibleChange(Z){}handleChange(Z,W){this._hasChanged=!0}endUpdate(Z){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function De(G,Z){return new Se(G,Z).emitter.event}e.fromObservable=De;function ie(G){return(Z,W,re)=>{let L=0,R=!1,I={beginUpdate(){L++},endUpdate(){L--,L===0&&(G.reportChanges(),R&&(R=!1,Z.call(W)))},handlePossibleChange(){},handleChange(){R=!0}};G.addObserver(I),G.reportChanges();let se={dispose(){G.removeObserver(I)}};return re instanceof ya?re.add(se):Array.isArray(re)&&re.push(se),se}}e.fromObservableLight=ie})(on||={});var Bg=class jg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${jg._idPool++}`,jg.all.add(this)}start(t){this._stopWatch=new KR,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}}};Bg.all=new Set,Bg._idPool=0;var FR=Bg,WR=-1,LC=class OC{constructor(t,n,s=(OC._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 VR(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}};LC._idPool=1;var qR=LC,$R=class BC{constructor(t){this.value=t}static create(){let t=new Error;return new BC(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
-
`).slice(2).join(`
|
|
24
|
-
`))}},VR=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},YR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},XR=0,km=class{constructor(e){this.value=e,this.id=XR++}},GR=2,ZR,Te=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new qR(e?.onListenerError??oh,this._options?.leakWarningThreshold??WR):void 0,this._perfMon=this._options?._profName?new FR(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 YR(`${d}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||oh)(g),gt.None}if(this._disposed)return gt.None;t&&(e=e.bind(t));let s=new km(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=$R.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof km?(this._deliveryQueue??=new QR,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=ii(()=>{o?.(),this._removeListener(s)});return n instanceof ya?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*GR<=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||oh;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 km)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}},QR=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}},zg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,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}};zg.INSTANCE=new zg;var m_=zg;function JR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}m_.INSTANCE.onDidChangeZoomLevel;function eM(e){return m_.INSTANCE.getZoomFactor(e)}m_.INSTANCE.onDidChangeFullscreen;var bl=typeof navigator=="object"?navigator.userAgent:"",Ig=bl.indexOf("Firefox")>=0,tM=bl.indexOf("AppleWebKit")>=0,g_=bl.indexOf("Chrome")>=0,iM=!g_&&bl.indexOf("Safari")>=0;bl.indexOf("Electron/")>=0;bl.indexOf("Android")>=0;var Em=!1;if(typeof Cs.matchMedia=="function"){let e=Cs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Cs.matchMedia("(display-mode: fullscreen)");Em=e.matches,JR(Cs,e,({matches:n})=>{Em&&t.matches||(Em=n)})}var tl="en",Pg=!1,Hg=!1,lh=!1,jC=!1,Wd,ch=tl,M0=tl,nM,bs,io=globalThis,Xn;typeof io.vscode<"u"&&typeof io.vscode.process<"u"?Xn=io.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Xn=process);var rM=typeof Xn?.versions?.electron=="string",sM=rM&&Xn?.type==="renderer";if(typeof Xn=="object"){Pg=Xn.platform==="win32",Hg=Xn.platform==="darwin",lh=Xn.platform==="linux",lh&&Xn.env.SNAP&&Xn.env.SNAP_REVISION,Xn.env.CI||Xn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Wd=tl,ch=tl;let e=Xn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Wd=t.userLocale,M0=t.osLocale,ch=t.resolvedLanguage||tl,nM=t.languagePack?.translationsConfigFile}catch{}jC=!0}else typeof navigator=="object"&&!sM?(bs=navigator.userAgent,Pg=bs.indexOf("Windows")>=0,Hg=bs.indexOf("Macintosh")>=0,(bs.indexOf("Macintosh")>=0||bs.indexOf("iPad")>=0||bs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lh=bs.indexOf("Linux")>=0,bs?.indexOf("Mobi")>=0,ch=globalThis._VSCODE_NLS_LANGUAGE||tl,Wd=navigator.language.toLowerCase(),M0=Wd):console.error("Unable to resolve platform.");var zC=Pg,Wr=Hg,aM=lh,N0=jC,qr=bs,la=ch,oM;(e=>{function t(){return la}e.value=t;function n(){return la.length===2?la==="en":la.length>=3?la[0]==="e"&&la[1]==="n"&&la[2]==="-":!1}e.isDefaultVariant=n;function s(){return la==="en"}e.isDefault=s})(oM||={});var lM=typeof io.postMessage=="function"&&!io.importScripts;(()=>{if(lM){let e=[];io.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}),io.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var cM=!!(qr&&qr.indexOf("Chrome")>=0);qr&&qr.indexOf("Firefox")>=0;!cM&&qr&&qr.indexOf("Safari")>=0;qr&&qr.indexOf("Edg/")>=0;qr&&qr.indexOf("Android")>=0;var Xo=typeof navigator=="object"?navigator:{};N0||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xo&&Xo.clipboard&&Xo.clipboard.writeText,N0||Xo&&Xo.clipboard&&Xo.clipboard.readText;var v_=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}},Tm=new v_,A0=new v_,L0=new v_,uM=new Array(230),IC;(e=>{function t(m){return Tm.keyCodeToStr(m)}e.toString=t;function n(m){return Tm.strToKeyCode(m)}e.fromString=n;function s(m){return A0.keyCodeToStr(m)}e.toUserSettingsUS=s;function o(m){return L0.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return A0.strToKeyCode(m)||L0.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 Tm.keyCodeToStr(m)}e.toElectronAccelerator=d})(IC||={});var dM=class PC{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 PC&&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 hM([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},hM=class{constructor(e){if(e.length===0)throw zR("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 fM(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return IC.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Ig)switch(t){case 59:return 85;case 60:if(aM)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Wr)return 57;break}else if(tM&&(Wr&&t===93||!Wr&&t===92))return 57;return uM[t]||0}var pM=Wr?256:2048,mM=512,gM=1024,vM=Wr?2048:256,O0=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=fM(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|=pM),this.altKey&&(t|=mM),this.shiftKey&&(t|=gM),this.metaKey&&(t|=vM),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new dM(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},B0=new WeakMap;function _M(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 bM=class{static getSameOriginWindowChain(e){let t=B0.get(e);if(!t){t=[],B0.set(e,t);let n=e,s;do s=_M(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}}},qd=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=bM.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},j0=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(g_){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?Ig&&!Wr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")iM&&zC?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?Ig&&!Wr?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()}},HC=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),yM;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof SM?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:on.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:HC})})(yM||={});var SM=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?HC:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},__=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 Ag("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ag("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},wM=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 Ag("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=ii(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},CM;(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})(CM||={});var z0=class ur{static fromArray(t){return new ur(n=>{n.emitMany(t)})}static fromPromise(t){return new ur(async n=>{n.emitMany(await t)})}static fromPromises(t){return new ur(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new ur(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 Te,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 on.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new ur(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return ur.map(this,t)}static filter(t,n){return new ur(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return ur.filter(this,t)}static coalesce(t){return ur.filter(t,n=>!!n)}coalesce(){return ur.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return ur.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())}};z0.EMPTY=z0.fromArray([]);var{getWindow:Fr,getWindowId:xM,onDidRegisterWindow:kM}=(function(){let e=new Map,t={window:Cs,disposables:new ya};e.set(Cs.vscodeWindowId,t);let n=new Te,s=new Te,o=new Te;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 gt.None;let m=new ya,g={window:d,disposables:m.add(new ya)};return e.set(d.vscodeWindowId,g),m.add(ii(()=>{e.delete(d.vscodeWindowId),s.fire(d)})),m.add(et(d,$i.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:Cs},getDocument(d){return Fr(d).document}}})(),EM=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 et(e,t,n,s){return new EM(e,t,n,s)}var I0=function(e,t,n,s){return et(e,t,n,s)},b_,TM=class extends wM{constructor(e){super(),this.defaultTarget=e&&Fr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},P0=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){oh(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(P0.sort),d.shift().execute();s.set(c,!1)};b_=(c,d,m=0)=>{let g=xM(c),f=new P0(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 DM(e){let t=e.getBoundingClientRect(),n=Fr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var $i={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"},RM=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=Ln(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ln(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ln(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ln(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ln(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ln(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ln(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ln(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ln(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ln(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ln(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=Ln(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=Ln(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ln(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 Ln(e){return typeof e=="number"?`${e}px`:e}function qc(e){return new RM(e)}var UC=class{constructor(){this._hooks=new ya,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(ii(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Fr(e)}this._hooks.add(et(c,$i.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(et(c,$i.POINTER_UP,d=>this.stopMonitoring(!0)))}};function MM(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 Kr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Kr||={});var Mc=class gn extends gt{constructor(){super(),this.dispatched=!1,this.targets=new R0,this.ignoreTargets=new R0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(on.runAndSubscribe(kM,({window:t,disposables:n})=>{n.add(et(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(et(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(et(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Cs,disposables:this._store}))}static addTarget(t){if(!gn.isTouchDevice())return gt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.targets.push(t);return ii(n)}static ignoreTarget(t){if(!gn.isTouchDevice())return gt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.ignoreTargets.push(t);return ii(n)}static isTouchDevice(){return"ontouchstart"in Cs||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(Kr.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<gn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Kr.Tap,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(f>=gn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Kr.Contextmenu,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=$n(g.rollingPageX),b=$n(g.rollingPageY),k=$n(g.rollingTimestamps)-g.rollingTimestamps[0],x=y-g.rollingPageX[0],w=b-g.rollingPageY[0],D=[...this.targets].filter(O=>g.initialTarget instanceof Node&&O.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(x)/k,x>0?1:-1,y,Math.abs(w)/k,w>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Kr.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===Kr.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>gn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Kr.Change||t.type===Kr.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=b_(t,()=>{let y=Date.now(),b=y-s,k=0,x=0,w=!0;o+=gn.SCROLL_FRICTION*b,m+=gn.SCROLL_FRICTION*b,o>0&&(w=!1,k=c*o*b),m>0&&(w=!1,x=g*m*b);let D=this.newGestureEvent(Kr.Change);D.translationX=k,D.translationY=x,n.forEach(O=>O.dispatchEvent(D)),w||this.inertia(t,n,y,o,c,d+k,m,g,f+x)})}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(Kr.Change,d.initialTarget);m.translationX=c.pageX-$n(d.rollingPageX),m.translationY=c.pageY-$n(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)}};Mc.SCROLL_FRICTION=-.005,Mc.HOLD_DELAY=700,Mc.CLEAR_TAP_COUNT_TIME=400,pi([MM],Mc,"isTouchDevice",1);var NM=Mc,y_=class extends gt{onclick(e,t){this._register(et(e,$i.CLICK,n=>t(new qd(Fr(e),n))))}onmousedown(e,t){this._register(et(e,$i.MOUSE_DOWN,n=>t(new qd(Fr(e),n))))}onmouseover(e,t){this._register(et(e,$i.MOUSE_OVER,n=>t(new qd(Fr(e),n))))}onmouseleave(e,t){this._register(et(e,$i.MOUSE_LEAVE,n=>t(new qd(Fr(e),n))))}onkeydown(e,t){this._register(et(e,$i.KEY_DOWN,n=>t(new O0(n))))}onkeyup(e,t){this._register(et(e,$i.KEY_UP,n=>t(new O0(n))))}oninput(e,t){this._register(et(e,$i.INPUT,t))}onblur(e,t){this._register(et(e,$i.BLUR,t))}onfocus(e,t){this._register(et(e,$i.FOCUS,t))}onchange(e,t){this._register(et(e,$i.CHANGE,t))}ignoreGesture(e){return NM.ignoreTarget(e)}},H0=11,AM=class extends y_{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=H0+"px",this.domNode.style.height=H0+"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 UC),this._register(I0(this.bgDomNode,$i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(I0(this.domNode,$i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new TM),this._pointerdownScheduleRepeatTimer=this._register(new __)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Fr(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()}},LM=class Ug{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 Ug(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 Ug(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}}},OM=class extends gt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new LM(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 K0(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=K0.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)))}},U0=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Dm(e,t){let n=t-e;return function(s){return e+n*zM(s)}}function BM(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var K0=class Kg{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),BM(Dm(t,o),Dm(c,n),.33)}return Dm(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 U0(s,o,!1)}return new U0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Kg.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new Kg(t,n,o,s)}};function jM(e){return Math.pow(e,3)}function zM(e){return 1-jM(1-e)}var IM=class extends gt{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 __)}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":"")))}},PM=140,KC=class extends y_{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 IM(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new UC),this._shouldRender=!0,this.domNode=qc(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(et(this.domNode.domNode,$i.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new AM(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=qc(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(et(this.slider.domNode,$i.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=DM(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(zC&&d>PM){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()}},FC=class Fg{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 Fg(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=Fg._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)}},HM=class extends KC{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new FC(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}},UM=class extends KC{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new FC(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}},KM=500,F0=50,FM=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Wg=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(g_){let n=Fr(t.browserEvent),s=eM(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 FM(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}};Wg.INSTANCE=new Wg;var WM=Wg,qM=class extends y_{constructor(e,t,n){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=VM(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 UM(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new HM(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=qc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=qc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=qc(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 __),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=oo(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,Wr&&(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 j0(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=oo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new j0(n))};this._mouseWheelToDispose.push(et(this._listenOnDomNode,$i.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=!Wr&&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=F0*o,y=m.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let f=F0*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(),KM)}},$M=class extends qM{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 VM(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,Wr&&(t.className+=" mac"),t}var qg=class extends gt{constructor(e,t,n,s,o,c,d,m){super(),this._bufferService=n,this._optionsService=d,this._renderService=m,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new OM({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>b_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new $M(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(on.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ii(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ii(()=>this._styleElement.remove())),this._register(on.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}};qg=pi([Be(2,Sn),Be(3,Ds),Be(4,CC),Be(5,_l),Be(6,wn),Be(7,Rs)],qg);var $g=class extends gt{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(ii(()=>{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()}};$g=pi([Be(1,Sn),Be(2,Ds),Be(3,pu),Be(4,Rs)],$g);var YM=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)}},Hr={full:0,left:0,center:0,right:0},ca={full:0,left:0,center:0,right:0},yc={full:0,left:0,center:0,right:0},Rh=class extends gt{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 YM,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(ii(()=>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);ca.full=this._canvas.width,ca.left=e,ca.center=t,ca.right=e,this._refreshDrawHeightConstants(),yc.full=1,yc.left=1,yc.center=1+ca.left,yc.right=1+ca.left+ca.center}_refreshDrawHeightConstants(){Hr.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);Hr.left=t,Hr.center=t,Hr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hr.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(yc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Hr[e.position||"full"]/2),ca[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Hr[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}))}};Rh=pi([Be(2,Sn),Be(3,pu),Be(4,Rs),Be(5,wn),Be(6,_l),Be(7,Ds)],Rh);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 uh;(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=""))(uh||={});var WC;(e=>e.ST=`${me.ESC}\\`)(WC||={});var Vg=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)}}};Vg=pi([Be(2,Sn),Be(3,wn),Be(4,uo),Be(5,Rs)],Vg);var Xi=0,Gi=0,Zi=0,fi=0,W0={css:"#00000000",rgba:0},Di;(e=>{function t(o,c,d,m){return m!==void 0?`#${Za(o)}${Za(c)}${Za(d)}${Za(m)}`:`#${Za(o)}${Za(c)}${Za(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})(Di||={});var Zt;(e=>{function t(g,f){if(fi=(f.rgba&255)/255,fi===1)return{css:f.css,rgba:f.rgba};let y=f.rgba>>24&255,b=f.rgba>>16&255,k=f.rgba>>8&255,x=g.rgba>>24&255,w=g.rgba>>16&255,D=g.rgba>>8&255;Xi=x+Math.round((y-x)*fi),Gi=w+Math.round((b-w)*fi),Zi=D+Math.round((k-D)*fi);let O=Di.toCss(Xi,Gi,Zi),A=Di.toRgba(Xi,Gi,Zi);return{css:O,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,f,y){let b=dh.ensureContrastRatio(g.rgba,f.rgba,y);if(b)return Di.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(g){let f=(g.rgba|255)>>>0;return[Xi,Gi,Zi]=dh.toChannels(f),{css:Di.toCss(Xi,Gi,Zi),rgba:f}}e.opaque=o;function c(g,f){return fi=Math.round(f*255),[Xi,Gi,Zi]=dh.toChannels(g.rgba),{css:Di.toCss(Xi,Gi,Zi,fi),rgba:Di.toRgba(Xi,Gi,Zi,fi)}}e.opacity=c;function d(g,f){return fi=g.rgba&255,c(g,fi*f/255)}e.multiplyOpacity=d;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(Zt||={});var ai;(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 Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),Di.toColor(Xi,Gi,Zi);case 5:return Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),fi=parseInt(o.slice(4,5).repeat(2),16),Di.toColor(Xi,Gi,Zi,fi);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 Xi=parseInt(c[1]),Gi=parseInt(c[2]),Zi=parseInt(c[3]),fi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Di.toColor(Xi,Gi,Zi,fi);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),[Xi,Gi,Zi,fi]=t.getImageData(0,0,1,1).data,fi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Di.toRgba(Xi,Gi,Zi,fi),css:o}}e.toColor=s})(ai||={});var bn;(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})(bn||={});var dh;(e=>{function t(d,m){if(fi=(m&255)/255,fi===1)return m;let g=m>>24&255,f=m>>16&255,y=m>>8&255,b=d>>24&255,k=d>>16&255,x=d>>8&255;return Xi=b+Math.round((g-b)*fi),Gi=k+Math.round((f-k)*fi),Zi=x+Math.round((y-x)*fi),Di.toRgba(Xi,Gi,Zi)}e.blend=t;function n(d,m,g){let f=bn.relativeLuminance(d>>8),y=bn.relativeLuminance(m>>8);if(_s(f,y)<g){if(y<f){let x=s(d,m,g),w=_s(f,bn.relativeLuminance(x>>8));if(w<g){let D=o(d,m,g),O=_s(f,bn.relativeLuminance(D>>8));return w>O?x:D}return x}let b=o(d,m,g),k=_s(f,bn.relativeLuminance(b>>8));if(k<g){let x=s(d,m,g),w=_s(f,bn.relativeLuminance(x>>8));return k>w?b:x}return b}}e.ensureContrastRatio=n;function s(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,k=m>>24&255,x=m>>16&255,w=m>>8&255,D=_s(bn.relativeLuminance2(k,x,w),bn.relativeLuminance2(f,y,b));for(;D<g&&(k>0||x>0||w>0);)k-=Math.max(0,Math.ceil(k*.1)),x-=Math.max(0,Math.ceil(x*.1)),w-=Math.max(0,Math.ceil(w*.1)),D=_s(bn.relativeLuminance2(k,x,w),bn.relativeLuminance2(f,y,b));return(k<<24|x<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(d,m,g){let f=d>>24&255,y=d>>16&255,b=d>>8&255,k=m>>24&255,x=m>>16&255,w=m>>8&255,D=_s(bn.relativeLuminance2(k,x,w),bn.relativeLuminance2(f,y,b));for(;D<g&&(k<255||x<255||w<255);)k=Math.min(255,k+Math.ceil((255-k)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),D=_s(bn.relativeLuminance2(k,x,w),bn.relativeLuminance2(f,y,b));return(k<<24|x<<16|w<<8|255)>>>0}e.increaseLuminance=o;function c(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=c})(dh||={});function Za(e){let t=e.toString(16);return t.length<2?"0"+t:t}function _s(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var XM=class extends fu{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()]}},Mh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new pr}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||_a.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++)Mh._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||_a.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}};Mh=pi([Be(0,Sn)],Mh);function GM(e){return 57508<=e&&e<=57558}function ZM(e){return 9472<=e&&e<=9631}function QM(e){return GM(e)||ZM(e)}function JM(){return{css:{canvas:$d(),cell:$d()},device:{canvas:$d(),cell:$d(),char:{width:0,height:0,left:0,top:0}}}}function $d(){return{width:0,height:0}}var Yg=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 pr,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=[],k=this._characterJoinerService.getJoinedCharacters(t),x=this._themeService.colors,w=e.getNoBgTrimmedLength();n&&w<c+1&&(w=c+1);let D,O=0,A="",z=0,$=0,K=0,Q=0,F=!1,q=0,be=!1,Se=0,De=0,ie=[],G=f!==-1&&y!==-1;for(let Z=0;Z<w;Z++){e.loadCell(Z,this._workCell);let W=this._workCell.getWidth();if(W===0)continue;let re=!1,L=Z>=De,R=Z,I=this._workCell;if(k.length>0&&Z===k[0][0]&&L){let he=k.shift(),Ae=this._isCellInSelection(he[0],t);for(z=he[0]+1;z<he[1];z++)L&&=Ae===this._isCellInSelection(z,t);L&&=!n||c<he[0]||c>=he[1],L?(re=!0,I=new XM(this._workCell,e.translateToString(!0,he[0],he[1]),he[1]-he[0]),R=he[1]-1,W=I.getWidth()):De=he[1]}let se=this._isCellInSelection(Z,t),ye=n&&Z===c,M=G&&Z>=f&&Z<=y,U=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,he=>{U=!0});let ae=I.getChars()||_a;if(ae===" "&&(I.isUnderline()||I.isOverline())&&(ae=" "),Se=W*m-g.get(ae,I.isBold(),I.isItalic()),!D)D=this._document.createElement("span");else if(O&&(se&&be||!se&&!be&&I.bg===$)&&(se&&be&&x.selectionForeground||I.fg===K)&&I.extended.ext===Q&&M===F&&Se===q&&!ye&&!re&&!U&&L){I.isInvisible()?A+=_a:A+=ae,O++;continue}else O&&(D.textContent=A),D=this._document.createElement("span"),O=0,A="";if($=I.bg,K=I.fg,Q=I.extended.ext,F=M,q=Se,be=se,re&&c>=Z&&c<=R&&(c=Z),!this._coreService.isCursorHidden&&ye&&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(I.isBold()&&ie.push("xterm-bold"),I.isItalic()&&ie.push("xterm-italic"),I.isDim()&&ie.push("xterm-dim"),I.isInvisible()?A=_a:A=I.getChars()||_a,I.isUnderline()&&(ie.push(`xterm-underline-${I.extended.underlineStyle}`),A===" "&&(A=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${fu.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let he=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&he<8&&(he+=8),D.style.textDecorationColor=x.ansi[he].css}I.isOverline()&&(ie.push("xterm-overline"),A===" "&&(A=" ")),I.isStrikethrough()&&ie.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let _e=I.getFgColor(),Ne=I.getFgColorMode(),xe=I.getBgColor(),Le=I.getBgColorMode(),Ee=!!I.isInverse();if(Ee){let he=_e;_e=xe,xe=he;let Ae=Ne;Ne=Le,Le=Ae}let je,Fe,ee=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,he=>{he.options.layer!=="top"&&ee||(he.backgroundColorRGB&&(Le=50331648,xe=he.backgroundColorRGB.rgba>>8&16777215,je=he.backgroundColorRGB),he.foregroundColorRGB&&(Ne=50331648,_e=he.foregroundColorRGB.rgba>>8&16777215,Fe=he.foregroundColorRGB),ee=he.options.layer==="top")}),!ee&&se&&(je=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,xe=je.rgba>>8&16777215,Le=50331648,ee=!0,x.selectionForeground&&(Ne=50331648,_e=x.selectionForeground.rgba>>8&16777215,Fe=x.selectionForeground)),ee&&ie.push("xterm-decoration-top");let de;switch(Le){case 16777216:case 33554432:de=x.ansi[xe],ie.push(`xterm-bg-${xe}`);break;case 50331648:de=Di.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(D,`background-color:#${q0((xe>>>0).toString(16),"0",6)}`);break;default:Ee?(de=x.foreground,ie.push("xterm-bg-257")):de=x.background}switch(je||I.isDim()&&(je=Zt.multiplyOpacity(de,.5)),Ne){case 16777216:case 33554432:I.isBold()&&_e<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(_e+=8),this._applyMinimumContrast(D,de,x.ansi[_e],I,je,void 0)||ie.push(`xterm-fg-${_e}`);break;case 50331648:let he=Di.toColor(_e>>16&255,_e>>8&255,_e&255);this._applyMinimumContrast(D,de,he,I,je,Fe)||this._addStyle(D,`color:#${q0(_e.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,de,x.foreground,I,je,Fe)||Ee&&ie.push("xterm-fg-257")}ie.length&&(D.className=ie.join(" "),ie.length=0),!ye&&!re&&!U&&L?O++:D.textContent=A,Se!==this.defaultSpacing&&(D.style.letterSpacing=`${Se}px`),b.push(D),Z=R}return D&&O&&(D.textContent=A),b}_applyMinimumContrast(e,t,n,s,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||QM(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=Zt.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]}};Yg=pi([Be(1,EC),Be(2,wn),Be(3,Ds),Be(4,uo),Be(5,pu),Be(6,_l)],Yg);function q0(e,t,n){for(;e.length<n;)e=t+e;return e}var eN=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}},tN=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 iN(){return new tN}var Rm="xterm-dom-renderer-owner-",cr="xterm-rows",Vd="xterm-fg-",$0="xterm-bg-",Sc="xterm-focus",Yd="xterm-selection",nN=1,Xg=class extends gt{constructor(e,t,n,s,o,c,d,m,g,f,y,b,k,x){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=k,this._themeService=x,this._terminalClass=nN++,this._rowElements=[],this._selectionRenderModel=iN(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(cr),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(Yd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=JM(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(Yg,document),this._element.classList.add(Rm+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(ii(()=>{this._element.classList.remove(Rm+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new eN(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} .${cr} 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} .${cr} { 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} .${cr} .xterm-dim { color: ${Zt.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} .${cr}.${Sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${cr}.${Sc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${cr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Yd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Yd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Yd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())t+=`${this._terminalSelector} .${Vd}${c} { color: ${d.css}; }${this._terminalSelector} .${Vd}${c}.xterm-dim { color: ${Zt.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${$0}${c} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${Vd}257 { color: ${Zt.opaque(e.background).css}; }${this._terminalSelector} .${Vd}257.xterm-dim { color: ${Zt.multiplyOpacity(Zt.opaque(e.background),.5).css}; }${this._terminalSelector} .${$0}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(Sc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Sc),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`.${Rm}${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,k=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=n;x<=s;++x){let w=x+m.ydisp,D=this._rowElements[x],O=m.lines.get(w);if(!D||!O)break;D.replaceChildren(...this._rowFactory.createRow(O,w,w===g,b,k,f,y,this.dimensions.css.cell.width,this._widthCache,c?x===n?e:0:-1,c?(x===s?t:o)-1:-1))}}};Xg=pi([Be(7,f_),Be(8,ef),Be(9,wn),Be(10,Sn),Be(11,uo),Be(12,Ds),Be(13,_l)],Xg);var Gg=class extends gt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new sN(this._optionsService))}catch{this._measureStrategy=this._register(new rN(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())}};Gg=pi([Be(2,wn)],Gg);var qC=class extends gt{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)}},rN=class extends qC{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}},sN=class extends qC{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}},aN=class extends gt{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 oN(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(on.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(et(this._textarea,"focus",()=>this._isFocused=!0)),this._register(et(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}},oN=class extends gt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new dl),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ii(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=et(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)}},lN=class extends gt{constructor(){super(),this.linkProviders=[],this._register(ii(()=>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 S_(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 cN(e,t,n,s,o,c,d,m,g){if(!c)return;let f=S_(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 cN(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=S_(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=pi([Be(0,Rs),Be(1,ef)],Zg);var uN=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=[]}},$C={};yR($C,{getSafariVersion:()=>hN,isChromeOS:()=>GC,isFirefox:()=>VC,isIpad:()=>fN,isIphone:()=>pN,isLegacyEdge:()=>dN,isLinux:()=>w_,isMac:()=>Nh,isNode:()=>tf,isSafari:()=>YC,isWindows:()=>XC});var tf=typeof process<"u"&&"title"in process,mu=tf?"node":navigator.userAgent,gu=tf?"node":navigator.platform,VC=mu.includes("Firefox"),dN=mu.includes("Edge"),YC=/^((?!chrome|android).)*safari/i.test(mu);function hN(){if(!YC)return 0;let e=mu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Nh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(gu),fN=gu==="iPad",pN=gu==="iPhone",XC=["Windows","Win16","Win32","WinCE"].includes(gu),w_=gu.indexOf("Linux")>=0,GC=/\bCrOS\b/.test(mu),ZC=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()}},mN=class extends ZC{_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())}}},gN=class extends ZC{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ah=!tf&&"requestIdleCallback"in window?gN:mN,vN=class{constructor(){this._queue=new Ah}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Qg=class extends gt{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 dl),this._pausedResizeTask=new vN,this._observerDisposable=this._register(new dl),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 Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uN((f,y)=>this._renderRows(f,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new _N(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ii(()=>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=ii(()=>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()}};Qg=pi([Be(2,wn),Be(3,ef),Be(4,uo),Be(5,pu),Be(6,Sn),Be(7,Ds),Be(8,_l)],Qg);var _N=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 bN(e,t,n,s){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return wN(o,c,e,t,n,s)+nf(c,t,n,s)+CN(o,c,e,t,n,s);let d;if(c===t)return d=o>e?"D":"C",Jc(Math.abs(o-e),Qc(d,s));d=c>t?"D":"C";let m=Math.abs(c-t),g=SN(c>t?e:o,n)+(m-1)*n.cols+1+yN(c>t?o:e);return Jc(g,Qc(d,s))}function yN(e,t){return e-1}function SN(e,t){return t.cols-e}function wN(e,t,n,s,o,c){return nf(t,s,o,c).length===0?"":Jc(JC(e,t,e,t-lo(t,o),!1,o).length,Qc("D",c))}function nf(e,t,n,s){let o=e-lo(e,n),c=t-lo(t,n),d=Math.abs(o-c)-xN(e,t,n);return Jc(d,Qc(QC(e,t),s))}function CN(e,t,n,s,o,c){let d;nf(t,s,o,c).length>0?d=s-lo(s,o):d=t;let m=s,g=kN(e,t,n,s,o,c);return Jc(JC(e,d,n,m,g==="C",o).length,Qc(g,c))}function xN(e,t,n){let s=0,o=e-lo(e,n),c=t-lo(t,n);for(let d=0;d<Math.abs(o-c);d++){let m=QC(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*d)?.isWrapped&&s++}return s}function lo(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 kN(e,t,n,s,o,c){let d;return nf(n,s,o,c).length>0?d=s-lo(s,o):d=t,e<n&&d<=s||e>=n&&d<s?"C":"D"}function QC(e,t){return e>t?"A":"B"}function JC(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 Jc(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var EN=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 V0(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 Mm=50,TN=15,DN=50,RN=500,MN=" ",NN=new RegExp(MN,"g"),Jg=class extends gt{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 pr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),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 EN(this._bufferService),this._activeSelectionMode=0,this._register(ii(()=>{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(NN," ")).join(XC?`\r
|
|
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())),w_&&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=V0(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=S_(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,-Mm),Mm),t/=Mm,t/Math.abs(t)+Math.round(t*(TN-1)))}shouldForceSelection(e){return Nh?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(),DN)}_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&&!(Nh&&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<RN&&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=bN(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,k=0,x=0;if(d.charAt(m)===" "){for(;m>0&&d.charAt(m-1)===" ";)m--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let O=e[0],A=e[0];c.getWidth(O)===0&&(y++,O--),c.getWidth(A)===2&&(b++,A++);let z=c.getString(A).length;for(z>1&&(x+=z-1,g+=z-1);O>0&&m>0&&!this._isCharWordSeparator(c.loadCell(O-1,this._workCell));){c.loadCell(O-1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,O--):$>1&&(k+=$-1,m-=$-1),m--,O--}for(;A<c.length&&g+1<d.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,A++):$>1&&(x+=$-1,g+=$-1),g++,A++}}g++;let w=m+f-y+k,D=Math.min(this._bufferService.cols,g-m+y+b-k-x);if(!(!t&&d.slice(m,g).trim()==="")){if(n&&w===0&&c.getCodePoint(0)!==32){let O=o.lines.get(e[1]-1);if(O&&c.isWrapped&&O.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let z=this._bufferService.cols-A.start;w-=z,D+=z}}}if(s&&w+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let O=o.lines.get(e[1]+1);if(O?.isWrapped&&O.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(D+=A.length)}}return{start:w,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=V0(n,this._bufferService.cols)}};Jg=pi([Be(3,Sn),Be(4,uo),Be(5,p_),Be(6,wn),Be(7,Rs),Be(8,Ds)],Jg);var Y0=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={}}},X0=class{constructor(){this._color=new Y0,this._css=new Y0}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()}},Ai=Object.freeze((()=>{let e=[ai.toColor("#2e3436"),ai.toColor("#cc0000"),ai.toColor("#4e9a06"),ai.toColor("#c4a000"),ai.toColor("#3465a4"),ai.toColor("#75507b"),ai.toColor("#06989a"),ai.toColor("#d3d7cf"),ai.toColor("#555753"),ai.toColor("#ef2929"),ai.toColor("#8ae234"),ai.toColor("#fce94f"),ai.toColor("#729fcf"),ai.toColor("#ad7fa8"),ai.toColor("#34e2e2"),ai.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:Di.toCss(s,o,c),rgba:Di.toRgba(s,o,c)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Di.toCss(s,s,s),rgba:Di.toRgba(s,s,s)})}return e})()),Qa=ai.toColor("#ffffff"),Nc=ai.toColor("#000000"),G0=ai.toColor("#ffffff"),Z0=Nc,wc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},AN=Qa,ev=class extends gt{constructor(e){super(),this._optionsService=e,this._contrastCache=new X0,this._halfContrastCache=new X0,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Qa,background:Nc,cursor:G0,cursorAccent:Z0,selectionForeground:void 0,selectionBackgroundTransparent:wc,selectionBackgroundOpaque:Zt.blend(Nc,wc),selectionInactiveBackgroundTransparent:wc,selectionInactiveBackgroundOpaque:Zt.blend(Nc,wc),scrollbarSliderBackground:Zt.opacity(Qa,.2),scrollbarSliderHoverBackground:Zt.opacity(Qa,.4),scrollbarSliderActiveBackground:Zt.opacity(Qa,.5),overviewRulerBorder:Qa,ansi:Ai.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=Ht(e.foreground,Qa),t.background=Ht(e.background,Nc),t.cursor=Zt.blend(t.background,Ht(e.cursor,G0)),t.cursorAccent=Zt.blend(t.background,Ht(e.cursorAccent,Z0)),t.selectionBackgroundTransparent=Ht(e.selectionBackground,wc),t.selectionBackgroundOpaque=Zt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ht(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Zt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ht(e.selectionForeground,W0):void 0,t.selectionForeground===W0&&(t.selectionForeground=void 0),Zt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Zt.opacity(t.selectionBackgroundTransparent,.3)),Zt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Zt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ht(e.scrollbarSliderBackground,Zt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ht(e.scrollbarSliderHoverBackground,Zt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ht(e.scrollbarSliderActiveBackground,Zt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ht(e.overviewRulerBorder,AN),t.ansi=Ai.slice(),t.ansi[0]=Ht(e.black,Ai[0]),t.ansi[1]=Ht(e.red,Ai[1]),t.ansi[2]=Ht(e.green,Ai[2]),t.ansi[3]=Ht(e.yellow,Ai[3]),t.ansi[4]=Ht(e.blue,Ai[4]),t.ansi[5]=Ht(e.magenta,Ai[5]),t.ansi[6]=Ht(e.cyan,Ai[6]),t.ansi[7]=Ht(e.white,Ai[7]),t.ansi[8]=Ht(e.brightBlack,Ai[8]),t.ansi[9]=Ht(e.brightRed,Ai[9]),t.ansi[10]=Ht(e.brightGreen,Ai[10]),t.ansi[11]=Ht(e.brightYellow,Ai[11]),t.ansi[12]=Ht(e.brightBlue,Ai[12]),t.ansi[13]=Ht(e.brightMagenta,Ai[13]),t.ansi[14]=Ht(e.brightCyan,Ai[14]),t.ansi[15]=Ht(e.brightWhite,Ai[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]=Ht(e.extendedAnsi[s],Ai[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()}}};ev=pi([Be(0,wn)],ev);function Ht(e,t){if(e!==void 0)try{return ai.toColor(e)}catch{}return t}var LN=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)}},ON=class{constructor(){this._services=new LN,this._services.set(f_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=TR(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)}},BN={trace:0,debug:1,info:2,warn:3,error:4,off:5},jN="xterm.js: ",tv=class extends gt{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=BN[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?"":jN)+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)}};tv=pi([Be(0,wn)],tv);var Q0=class extends gt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),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}},mt=3,Ei=Object.freeze(new fu),Xd=0,Nm=2,Ac=class ex{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*mt);let o=n||pr.fromCharData([0,bC,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*mt+0],s=n&2097151;return[this._data[t*mt+1],n&2097152?this._combined[t]:s?ma(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*mt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*mt+0]=t|2097152|n[2]<<22):this._data[t*mt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*mt+0]>>22}hasWidth(t){return this._data[t*mt+0]&12582912}getFg(t){return this._data[t*mt+1]}getBg(t){return this._data[t*mt+2]}hasContent(t){return this._data[t*mt+0]&4194303}getCodePoint(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*mt+0]&2097152}getString(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t]:n&2097151?ma(n&2097151):""}isProtected(t){return this._data[t*mt+2]&536870912}loadCell(t,n){return Xd=t*mt,n.content=this._data[Xd+0],n.fg=this._data[Xd+1],n.bg=this._data[Xd+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*mt+0]=n.content,this._data[t*mt+1]=n.fg,this._data[t*mt+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*mt+0]=n|s<<22,this._data[t*mt+1]=o.fg,this._data[t*mt+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*mt+0];o&2097152?this._combined[t]+=ma(n):o&2097151?(this._combined[t]=ma(o&2097151)+ma(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*mt+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 pr;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 pr;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*Nm<this._data.buffer.byteLength;let s=t*mt;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*Nm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Nm<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 ex(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*mt+0]&4194303)return t+(this._data[t*mt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*mt+0]&4194303||this._data[t*mt+2]&50331648)return t+(this._data[t*mt+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<mt;f++)this._data[(s+g)*mt+f]=d[(n+g)*mt+f];d[(n+g)*mt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let f=0;f<mt;f++)this._data[(s+g)*mt+f]=d[(n+g)*mt+f];d[(n+g)*mt+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*mt+0],m=d&2097151,g=d&2097152?this._combined[n]:m?ma(m):_a;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 zN(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,k=eu(y,b,t),x=1,w=0;for(;x<y.length;){let O=eu(y,x,t),A=O-w,z=n-k,$=Math.min(A,z);y[b].copyCellsFrom(y[x],w,k,$,!1),k+=$,k===n&&(b++,k=0),w+=$,w===O&&(x++,w=0),k===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,k++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(k,n,o);let D=0;for(let O=y.length-1;O>0&&(O>b||y[O].getTrimmedLength()===0);O--)D++;D>0&&(d.push(m+y.length-D),d.push(D)),m+=y.length-1}return d}function IN(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 PN(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 HN(e,t,n){let s=[],o=e.map((g,f)=>eu(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=eu(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 eu(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 tx=class ix{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ix._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),oo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};tx._nextId=1;var UN=tx,zi={},Ja=zi.B;zi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};zi.A={"#":"£"};zi.B=void 0;zi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};zi.C=zi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};zi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};zi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};zi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};zi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};zi.E=zi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};zi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};zi.H=zi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};zi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var J0=4294967295,ew=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=Ei.clone(),this.savedCharset=Ja,this.markers=[],this._nullCell=pr.fromCharData([0,bC,1,0]),this._whitespaceCell=pr.fromCharData([0,_a,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ah,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Q0(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 Dh),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 Dh),this._whitespaceCell}getBlankLine(e,t){return new Ac(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>J0?J0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ei);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 Q0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ei),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 Ac(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 Ac(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=zN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ei),n);if(s.length>0){let o=IN(this.lines,s);PN(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Ei),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ac(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(Ei),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 $=this.ybase+this.y;if($>=d&&$<d+g.length)continue}let f=g[g.length-1].getTrimmedLength(),y=HN(g,this._cols,e),b=y.length-g.length,k;this.ybase===0&&this.y!==this.lines.length-1?k=Math.max(0,this.y-this.lines.maxLength+b):k=Math.max(0,this.lines.length-this.lines.maxLength+b);let x=[];for(let $=0;$<b;$++){let K=this.getBlankLine(Ei,!0);x.push(K)}x.length>0&&(o.push({start:d+g.length+c,newLines:x}),c+=x.length),g.push(...x);let w=y.length-1,D=y[w];D===0&&(w--,D=y[w]);let O=g.length-b-1,A=f;for(;O>=0;){let $=Math.min(A,D);if(g[w]===void 0)break;if(g[w].copyCellsFrom(g[O],A-$,D-$,$,!0),D-=$,D===0&&(w--,D=y[w]),A-=$,A===0){O--;let K=Math.max(O,0);A=eu(g,K,this._cols)}}for(let $=0;$<g.length;$++)y[$]<e&&g[$].setCell(y[$],s);let z=b-k;for(;z-- >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 k=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>f+k){for(let O=b.newLines.length-1;O>=0;O--)this.lines.set(D--,b.newLines[O]);D++,d.push({index:f+1,amount:b.newLines.length}),k+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[f--]);let x=0;for(let D=d.length-1;D>=0;D--)d[D].index+=x,this.lines.onInsertEmitter.fire(d[D]),x+=d[D].amount;let w=Math.max(0,g+c-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}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 UN(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)}},KN=class extends gt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Te),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 ew(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ew(!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)}},nx=2,rx=1,iv=class extends gt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,nx),this.rows=Math.max(e.rawOptions.rows||0,rx),this.buffers=this._register(new KN(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))}};iv=pi([Be(0,wn)],iv);var Go={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:Nh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},FN=["normal","bold","100","200","300","400","500","600","700","800","900"],WN=class extends gt{constructor(e){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let t={...Go};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(ii(()=>{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 Go))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Go))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=Go[e]),!qN(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Go[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=FN.includes(t)?t:Go[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 qN(e){return e==="block"||e==="underline"||e==="bar"}function Lc(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]&&Lc(e[s],t-1);return n}var tw=Object.freeze({insertMode:!1}),iw=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),nv=class extends gt{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 Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Lc(tw),this.decPrivateModes=Lc(iw)}reset(){this.modes=Lc(tw),this.decPrivateModes=Lc(iw)}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))}};nv=pi([Be(0,Sn),Be(1,xC),Be(2,wn)],nv);var nw={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 Am(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 Lm=String.fromCharCode,rw={DEFAULT:e=>{let t=[Am(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Lm(t[0])}${Lm(t[1])}${Lm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Am(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Am(e,!0)};${e.x};${e.y}${t}`}},rv=class extends gt{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 Te),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(nw))this.addProtocol(s,nw[s]);for(let s of Object.keys(rw))this.addEncoding(s,rw[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)}};rv=pi([Be(0,Sn),Be(1,uo),Be(2,wn)],rv);var Om=[[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]],$N=[[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]],Li;function VN(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 YN=class{constructor(){if(this.version="6",!Li){Li=new Uint8Array(65536),Li.fill(1),Li[0]=0,Li.fill(0,1,32),Li.fill(0,127,160),Li.fill(2,4352,4448),Li[9001]=2,Li[9002]=2,Li.fill(2,11904,42192),Li[12351]=1,Li.fill(2,44032,55204),Li.fill(2,63744,64256),Li.fill(2,65040,65050),Li.fill(2,65072,65136),Li.fill(2,65280,65377),Li.fill(2,65504,65511);for(let e=0;e<Om.length;++e)Li.fill(0,Om[e][0],Om[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Li[e]:VN(e,$N)?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=eo.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return eo.createPropertyValue(0,n,s)}},eo=class hh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let t=new YN;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=hh.extractWidth(m);hh.extractShouldJoin(m)&&(g-=hh.extractWidth(s)),n+=g,s=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},XN=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 sw(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 Cc=2147483647,GN=256,sx=class sv{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>GN)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 sv;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 sv(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>Cc?Cc: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>Cc?Cc: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,Cc):t}},xc=[],ZN=class{constructor(){this._state=0,this._active=xc,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=xc}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=xc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||xc,!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",Jh(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=xc,this._id=-1,this._state=0}}},Vn=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+=Jh(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}},kc=[],QN=class{constructor(){this._handlers=Object.create(null),this._active=kc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kc}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=kc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||kc,!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",Jh(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=kc,this._ident=0}},Oc=new sx;Oc.addParam(0);var aw=class{constructor(e){this._handler=e,this._data="",this._params=Oc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Oc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Jh(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=Oc,this._data="",this._hitLimit=!1,n));return this._params=Oc,this._data="",this._hitLimit=!1,t}},JN=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}},hr=160,eA=(function(){let e=new JN(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(hr,0,2,0),e.add(hr,8,5,8),e.add(hr,6,0,6),e.add(hr,11,0,11),e.add(hr,13,13,13),e})(),tA=class extends gt{constructor(e=eA){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 sx,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(ii(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ZN),this._dcsParser=this._register(new QN),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:hr)],o>>4){case 2:for(let k=m+1;;++k){if(k>=t||(s=e[k])<32||s>126&&s<hr){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(s=e[k])<32||s>126&&s<hr){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(s=e[k])<32||s>126&&s<hr){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(s=e[k])<32||s>126&&s<hr){this._printHandler(e,m,k),m=k-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 k=m+1;;++k)if(k>=t||(s=e[k])===24||s===26||s===27||s>127&&s<hr){this._dcsParser.put(e,m,k),m=k-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 k=m+1;;k++)if(k>=t||(s=e[k])<32||s>127&&s<hr){this._oscParser.put(e,m,k),m=k-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}}},iA=/^([\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})$/,nA=/^[\da-f]+$/;function ow(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=iA.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),nA.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 Bm(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 rA(e,t=16){let[n,s,o]=e;return`rgb:${Bm(n,t)}/${Bm(s,t)}/${Bm(o,t)}`}var sA={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ua=131072,lw=10;function cw(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 uw=5e3,dw=0,aA=class extends gt{constructor(e,t,n,s,o,c,d,m,g=new tA){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 kR,this._utf8Decoder=new ER,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ei.clone(),this._eraseAttrDataInternal=Ei.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),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 av(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(uh.IND,()=>this.index()),this._parser.setExecuteHandler(uh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(uh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Vn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Vn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Vn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Vn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Vn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Vn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Vn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Vn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Vn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Vn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Vn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Vn(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 zi)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 aw((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"),uw))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${uw} 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>ua&&(c=this._parseStack.position+ua)}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<ua&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ua))),d||this._dirtyRowTracker.clearRange(),e.length>ua)for(let f=c;f<e.length;f+=ua){let y=f+ua<e.length?f+ua: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 k=this._parser.precedingJoinState;for(let x=t;x<n;++x){if(s=e[x],s<127&&c){let A=c[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let w=this._unicodeService.charProperties(s,k);o=eo.extractWidth(w);let D=eo.extractShouldJoin(w),O=D?eo.extractWidth(k):0;if(k=w,d&&this._onA11yChar.fire(ma(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-O>m){if(g){let A=b,z=this._activeBuffer.x-O;for(this._activeBuffer.x=O,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),O>0&&b instanceof Ac&&b.copyCellsFrom(A,z,0,O,!1);z<m;)A.setCellFromCodepoint(z++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(D&&this._activeBuffer.x){let A=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-A,s,o);for(let z=o-O;--z>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(f&&(b.insertCells(this._activeBuffer.x,o-O,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=k,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=>cw(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new aw(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Vn(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(Ei));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=eo.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,Ja),this._charsetService.setgCharset(1,Ja),this._charsetService.setgCharset(2,Ja),this._charsetService.setgCharset(3,Ja);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,k=(D,O)=>(d.triggerDataEvent(`${me.ESC}[${t?"":"?"}${D};${O}$y`),!0),x=D=>D?1:2,w=e.params[0];return t?w===2?k(w,4):w===4?k(w,x(d.modes.insertMode)):w===12?k(w,3):w===20?k(w,x(b.convertEol)):k(w,0):w===1?k(w,x(s.applicationCursorKeys)):w===3?k(w,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):w===6?k(w,x(s.origin)):w===7?k(w,x(s.wraparound)):w===8?k(w,3):w===9?k(w,x(o==="X10")):w===12?k(w,x(b.cursorBlink)):w===25?k(w,x(!d.isCursorHidden)):w===45?k(w,x(s.reverseWraparound)):w===66?k(w,x(s.applicationKeypad)):w===67?k(w,4):w===1e3?k(w,x(o==="VT200")):w===1002?k(w,x(o==="DRAG")):w===1003?k(w,x(o==="ANY")):w===1004?k(w,x(s.sendFocus)):w===1005?k(w,4):w===1006?k(w,x(c==="SGR")):w===1015?k(w,4):w===1016?k(w,x(c==="SGR_PIXELS")):w===1048?k(w,1):w===47||w===1047||w===1049?k(w,x(f===y)):w===2004?k(w,x(s.bracketedPasteMode)):w===2026?k(w,x(s.synchronizedOutput)):k(w,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=fu.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=Ei.fg,e.bg=Ei.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|=Ei.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Ei.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|=Ei.fg&16777215,s.bg&=-67108864,s.bg|=Ei.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=Ei.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(!cw(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>lw&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>lw&&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(hw(c))if(o==="?")t.push({type:0,index:c});else{let d=ow(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=ow(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]);hw(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,Ja),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(sA[e[0]],zi[e[1]]||Ja),!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=Ei.clone(),this._eraseAttrDataInternal=Ei.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 pr;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)}},av=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&&(dw=e,e=t,t=dw),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};av=pi([Be(0,Sn)],av);function hw(e){return 0<=e&&e<256}var oA=5e7,fw=12,lA=50,cA=class extends gt{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 Te),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>oA)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>=fw?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>=fw)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>lA&&(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()}},ov=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)))}};ov=pi([Be(0,Sn)],ov);var pw=!1,uA=class extends gt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new dl),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new ON,this.optionsService=this._register(new WN(e)),this._instantiationService.setService(wn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(iv)),this._instantiationService.setService(Sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(tv)),this._instantiationService.setService(xC,this._logService),this.coreService=this._register(this._instantiationService.createInstance(nv)),this._instantiationService.setService(uo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(rv)),this._instantiationService.setService(CC,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(eo)),this._instantiationService.setService(MR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(XN),this._instantiationService.setService(RR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ov),this._instantiationService.setService(kC,this._oscLinkService),this._inputHandler=this._register(new aA(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(on.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(on.forward(this._bufferService.onResize,this._onResize)),this._register(on.forward(this.coreService.onData,this._onData)),this._register(on.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 cA((t,n)=>this._inputHandler.parse(t,n))),this._register(on.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),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&&!pw&&(this._logService.warn("writeSync is unreliable and will be removed soon."),pw=!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,nx),t=Math.max(t,rx),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(sw.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(sw(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ii(()=>{for(let t of e)t.dispose()})}}},dA={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 hA(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=dA[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 bi=0,fA=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ah,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ah,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||(bi=this._search(t),bi===-1)||this._getKey(this._array[bi])!==t)return!1;do if(this._array[bi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bi),!0;while(++bi<this._array.length&&this._getKey(this._array[bi])===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&&(bi=this._search(e),!(bi<0||bi>=this._array.length)&&this._getKey(this._array[bi])===e))do yield this._array[bi];while(++bi<this._array.length&&this._getKey(this._array[bi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bi=this._search(e),!(bi<0||bi>=this._array.length)&&this._getKey(this._array[bi])===e))do t(this._array[bi]);while(++bi<this._array.length&&this._getKey(this._array[bi])===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}},jm=0,mw=0,pA=class extends gt{constructor(){super(),this._decorations=new fA(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ii(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new mA(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=>{jm=o.options.x??0,mw=jm+(o.options.width??1),e>=jm&&e<mw&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},mA=class extends ya{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),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=ai.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ai.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},gA=1e3,vA=class{constructor(e,t=gA){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)}},gw=20,Lh=class extends gt{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 vA(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(et(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ii(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<gw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===gw+1&&(this._liveRegion.textContent+=Tg.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 k=g<b.length?b[g]:b.slice(-1)[0]+1;return k>=this._terminal.cols&&(++y,k=0),{row:y,column:k}},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})`}};Lh=pi([Be(1,f_),Be(2,Ds),Be(3,Rs)],Lh);var lv=class extends gt{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 Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ii(()=>{oo(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(et(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(et(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(et(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(et(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&&_A(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,oo(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}}};lv=pi([Be(1,p_),Be(2,Rs),Be(3,Sn),Be(4,TC)],lv);function _A(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 bA=class extends uA{constructor(e={}){super(e),this._linkifier=this._register(new dl),this.browser=$C,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new dl),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(pA),this._instantiationService.setService(pu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(lN),this._instantiationService.setService(TC,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Rg)),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(on.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(on.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(on.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(on.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ii(()=>{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=Zt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${me.ESC}]${s};${rA(o)}${WC.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Di.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=Di.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(Lh,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(et(this.element,"copy",t=>{this.hasSelection()&&CR(t,this._selectionService)}));let e=t=>xR(t,this.textarea,this.coreService,this.optionsService);this._register(et(this.textarea,"paste",e)),this._register(et(this.element,"paste",e)),VC?this._register(et(this.element,"mousedown",t=>{t.button===2&&E0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(et(this.element,"contextmenu",t=>{E0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),w_&&this._register(et(this.element,"auxclick",t=>{t.button===1&&_C(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(et(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(et(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(et(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(et(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(et(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(et(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(et(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(et(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",Eg.get()),GC||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(aN,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ds,this._coreBrowserService),this._register(et(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(et(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gg,this._document,this._helperContainer),this._instantiationService.setService(ef,this._charSizeService),this._themeService=this._instantiationService.createInstance(ev),this._instantiationService.setService(_l,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Mh),this._instantiationService.setService(EC,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Qg,this.rows,this.screenElement)),this._instantiationService.setService(Rs,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(Vg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Zg),this._instantiationService.setService(p_,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(lv,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(qg,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(Jg,this.element,this.screenElement,s)),this._instantiationService.setService(AR,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(on.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance($g,this.screenElement)),this._register(et(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(Lh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Rh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Rh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Xg,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(et(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(et(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){vC(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=hA(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)&&(yA(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(Ei));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 yA(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var SA=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)}},wA=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 pr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},vw=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 wA(t)}getNullCell(){return new pr}},CA=class extends gt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new vw(this._core.buffers.normal,"normal"),this._alternate=new vw(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)}},xA=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)}},kA=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}},EA=["cols","rows"],Ur=0,TA=class extends gt{constructor(e){super(),this._core=this._register(new bA(e)),this._addonManager=this._register(new SA),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(EA.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 xA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new kA(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 CA(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 Eg.get()},set promptLabel(e){Eg.set(e)},get tooMuchOutput(){return Tg.get()},set tooMuchOutput(e){Tg.set(e)}}}_verifyIntegers(...e){for(Ur of e)if(Ur===1/0||isNaN(Ur)||Ur%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ur of e)if(Ur&&(Ur===1/0||isNaN(Ur)||Ur%1!==0||Ur<0))throw new Error("This API only accepts positive integers")}};class DA{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():cx.has(t)?this.acceptConsonant(t):ux.has(t)?this.acceptVowel(t):AA(t)&&this.canReplacePendingWith(t)?(this.pending=bw(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(dx.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=NA.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=MA.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=_w.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,o=yw({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=_w.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=bw(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=yw(this.pending);return this.pending=null,t}}const Oh=44032,Bh=21,il=28,RA=19*Bh*il,ax=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],ox=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],lx=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],cx=C_(ax),ux=C_(ox),dx=C_(lx),MA=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),hx=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],NA=new Map(hx),_w=new Map(hx.map(([e,t])=>[t,[e[0],e[1]]]));function C_(e){return new Map(e.map((t,n)=>[t,n]))}function AA(e){const t=e.codePointAt(0);return t!==void 0&&t>=Oh&&t<Oh+RA}function bw(e){const t=e.codePointAt(0)-Oh,n=Math.floor(t/(Bh*il)),s=Math.floor(t%(Bh*il)/il),o=t%il,c={initial:ax[n],vowel:ox[s]};return o===0?c:{...c,final:lx[o]}}function yw(e){if(!e.vowel)return e.initial;const t=cx.get(e.initial),n=ux.get(e.vowel),s=e.final?dx.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Oh+(t*Bh+n)*il+s)}const LA=[{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 OA({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:s,onHide:o}){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"}),LA.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:o,children:"×"})]})}const BA={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function jA(e){return BA[e]}function zA(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const fx="--nterminal-viewport-height",px="--nterminal-keyboard-inset-bottom",mx="data-nterminal-keyboard-visible",rf="data-nterminal-compose-open",jh="nterminal:viewport-refresh",IA=120;function PA(e=window){const t=e.document.documentElement,n=e.visualViewport,s=qA(e);function o(){x_(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),s?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(jh,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),s?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(jh,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(fx),t.style.removeProperty(px),t.removeAttribute(mx)}}function x_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=cv(e),o=HA(e,s);return o!==null&&Sw(t,fx,`${o}px`),Sw(t,px,`${n}px`),UA(t,mx,String(s)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:s}}function cv(e=window){const t=KA(e);return{keyboardInsetBottom:t,keyboardVisible:t>IA}}function HA(e,t){if((e.document.documentElement.hasAttribute(rf)||t)&&no(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return no(n)?n:no(e.innerHeight)?e.innerHeight:null}function no(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Sw(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function UA(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function KA(e){return Math.max(FA(e),WA(e))}function FA(e){const t=e.visualViewport?.height;if(!no(t)||!no(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 WA(e){if(!no(e.innerHeight))return 0;const n=gx(e)?.boundingRect?.height;return!no(n)||n>=e.innerHeight*.8?0:Math.round(n)}function gx(e){return e.navigator.virtualKeyboard}function qA(e){const t=gx(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const vu=new Map,tu=new Map,$A=Object.freeze({open:!1,text:""});function VA(e){let t=tu.get(e);return t||(t=new Set,tu.set(e,t)),t}function vx(e){const t=tu.get(e);if(t)for(const n of Array.from(t))n()}function sf(e){return vu.get(e)??$A}function YA(e,t){const n=VA(e);return n.add(t),()=>{n.delete(t)}}function XA(e,t){const n=sf(e);n.open!==t&&(vu.set(e,{...n,open:t}),vx(e))}function GA(e,t){const n=sf(e);n.text!==t&&(vu.set(e,{...n,text:t}),vx(e))}function Gd(e){vu.delete(e),tu.delete(e)}function ww(){vu.clear(),tu.clear()}const ZA=120,QA="\x1B[200~",JA="\x1B[201~";function Cw(e,t){const n=t.stripTrailingLineBreaks===!1?e:k_(e),s=tL(n);return s?t.bracketedPasteMode?`${QA}${s}${JA}`:s:""}function eL(e){return e==="queue"?" ":"\r"}function k_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function tL(e){return e.replace(/\r\n/g,`
|
|
32
|
-
`).replace(/\r/g,`
|
|
33
|
-
`).replace(/\n/g,"\r")}const iL=420,nL=3e3,xw=650,rL=80,sL=3,fh=new Set;let al=null;function aL({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1}){const o=v.useMemo(()=>z=>YA(e,z),[e]),c=v.useMemo(()=>()=>sf(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),k=v.useRef(null);v.useEffect(()=>()=>{k.current?.(),k.current=null},[]),v.useLayoutEffect(()=>{if(!(!m||!ph()))return lL(e),()=>cL(e)},[m,e]),v.useLayoutEffect(()=>{const z=f.current?.closest(".terminal-pane");if(!z)return;function $(){z?.removeAttribute("data-compose-open"),z?.style.removeProperty("--compose-drawer-panel-height")}if(!m){$();return}const K=y.current;z.setAttribute("data-compose-open","true");function Q(){const Se=K?.getBoundingClientRect().height??0;Se>0&&z?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Se)}px`)}Q();const F=[window.setTimeout(Q,0),window.setTimeout(Q,180),window.setTimeout(Q,260)],q=window.requestAnimationFrame?.(Q)??null,be=typeof ResizeObserver=="function"&&K?new ResizeObserver(Q):null;return be&&K&&be.observe(K),()=>{for(const Se of F)window.clearTimeout(Se);q!==null&&window.cancelAnimationFrame?.(q),be?.disconnect(),$()}},[m]),v.useEffect(()=>{if(!m){k.current?.(),k.current=null;return}kw(b.current),A()},[m]);function x(z){XA(e,z)}function w(z){GA(e,z)}function D(){oL(f.current),x(!1),Ew()}function O(z="send"){if(!(s||!g)&&t(g,z)){if(w(""),ph()){b.current?.blur(),Ew();return}window.setTimeout(()=>b.current?.focus(),ZA+20)}}function A(){ph()&&(k.current?.(),k.current=uL())}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:()=>x(!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:z=>w(z.target.value),onFocus:A,onKeyDown:z=>{if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)){if(z.preventDefault(),z.shiftKey){n&&O("queue");return}O("send");return}z.key==="Escape"&&(z.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:()=>{w(""),kw(b.current),A()},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:()=>O("queue"),disabled:s||!g,children:"Queue"}):null,p.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:m?0:-1,onClick:()=>O("send"),disabled:s||!g,children:"Send"})]})]})]})}function oL(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function kw(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function ph(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Ew(){if(!ph())return;const e=nl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function lL(e){al!==null&&(window.clearTimeout(al),al=null),fh.add(e),document.documentElement.setAttribute(rf,"true"),nl()}function cL(e){if(fh.delete(e),fh.size>0||al!==null){nl();return}al=window.setTimeout(()=>{if(al=null,fh.size>0){nl();return}document.documentElement.removeAttribute(rf),nl()},iL),nl()}function uL(){let e=!1,t=null,n=null,s=null,o=0;const c=Date.now(),d=window.visualViewport,m=dL();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(k){if(!e){if(k<xw&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,rL)}}function b(){if(e)return;g();const k=x_(),x=Date.now()-c;if(k.keyboardInsetBottom>0&&k.keyboardInsetBottom===s?o+=1:(o=k.keyboardInsetBottom>0?1:0,s=k.keyboardInsetBottom),x>=nL||x>=xw&&o>=sL){f();return}y(x)}return d?.addEventListener("resize",b),d?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),f}function nl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,x_()}function dL(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function hL(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(mL(d))return d.preventDefault(),d.stopPropagation(),fL(e),!1;if(pL(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(gL(d)){const m=uv(e);return m?(d.preventDefault(),d.stopPropagation(),dv(m),!1):!0}return vL(d)?(d.preventDefault(),d.stopPropagation(),_L(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const m=uv(e);if(m){if(d.clipboardData){d.clipboardData.setData("text/plain",m),d.preventDefault();return}d.preventDefault(),dv(m)}},c=d=>{const m=d.clipboardData?.getData("text/plain");if(!m)return;const g=k_(m);d.preventDefault(),d.stopImmediatePropagation(),_x(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 fL(e){const t=uv(e);t&&await dv(t)}function pL(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function mL(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 gL(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function vL(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 _L(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;_x(e,k_(n),t)}catch{}}function _x(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function uv(e){return e.hasSelection()?e.getSelection():bL(e.element??null)}function bL(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 dv(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}yL(e)}function yL(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 SL=[4,10,11,12];function wL(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>Tw(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>Tw(s)),e.parser.registerCsiHandler({final:"n"},s=>CL(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>xL(s)),e.parser.registerCsiHandler({final:"t"},s=>kL(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...SL.map(s=>e.parser.registerOscHandler(s,o=>EL(o)))];return{dispose(){for(const s of n)s.dispose()}}}function Tw(e){return af(e)===0}function CL(e){const t=af(e);return t===5||t===6}function xL(e){return af(e)===6}function kL(e){const t=af(e);return t===14||t===16||t===18}function EL(e){return e.split(";").some(t=>t==="?")}function af(e){const t=e[0];return typeof t=="number"?t:0}const Es=new Map,zm=2*1024*1024,TL=1500,Dw=25e3,DL=2500,RL=1e3,ML=3e4,NL=16*1024*1024,hv=256,AL=k2-3e4,fv=16*1024*1024,bx=4*1024*1024,zh=25,LL=1e3;let OL=0,Im=0;const BL=new TextEncoder,jL=YL();function zL(e,t){let n=Es.get(e);n||(n=KL(e),Es.set(e,n),_u(n)),n.listeners.add(t),queueMicrotask(()=>xx(n));const s=c=>qL(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 Bc(e){const t=Es.get(e);t&&(VL(t),Es.delete(e))}function IL(e){const t=Es.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),yl(t),ks(t,"reconnecting"),Ea(t);const n=t.socket;return t.socket=null,va(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),_u(t),!0}function PL(e){const t=Es.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<RL)return Promise.resolve("alive");ks(t,"reconnecting"),Ea(t),t.lastResumeProbeSocket=n,t.lastResumeProbeAt=s;const o=`resume-${s.toString(36)}-${(++OL).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||(ks(t,"reconnecting"),Nw(t))},DL);try{n.send(JSON.stringify({type:"ping",nonce:o}))}catch{ks(t,"reconnecting"),Nw(t)}return d}function HL(){for(const e of Es.values())e.heartbeatSuspended=!0,yl(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,ks(e,"skipped"),Ea(e)}function UL(){for(const e of Es.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ea(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,va(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),_u(e)}}function Pm(){for(const e of Array.from(Es.keys()))Bc(e)}function KL(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:zh,listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function _u(e){if(!e.reconnectEnabled)return;va(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,yl(e),va(e,"connected"),co(e,t),e.isAlive=!0,Rw(e))}),t.addEventListener("message",s=>{if(e.socket!==t)return;const o=typeof s.data=="string"?s.data:"";if(!o)return;let c=null;try{c=JSON.parse(o)}catch{return}if(!c||typeof c.type!="string")return;if(t3(c)){i3(e,t,c.instanceId,c.inputAck);return}if(e.inputProtocolMode==="unknown"&&Sx(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),ks(e,"alive"),co(e,t),Rw(e));return}if(c.type==="input_ack"){QL(e,t,c);return}if(c.type==="input_ack_confirmed"){r3(e,c);return}const d=WL(e,c);if(iu(e,{type:"message",message:d}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;xx(e)}}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",ks(e,"reconnecting"),Ea(e),s.code===1008){e.reconnectEnabled=!1,va(e,FL(s.reason)?"unauthorized":"closed");return}if(!n&&s.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=ML)&&(e.lastUpgradeAuthProbeAt=o,iu(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){va(e,"closed");return}va(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,_u(e)},TL)}}),t.addEventListener("error",()=>{})}function Rw(e){if(Ea(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>Dw*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)}))},Dw)}function Ea(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function FL(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function WL(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+Ts(s),0),Mw(e),e.exited&&mh(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Ts(t.data),Mw(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,mh(e)),t):(t.type==="exit"&&(e.exited=!0,mh(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function Mw(e){for(;e.outputBytes>zm&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Ts(t)}e.outputBytes>zm&&e.output.length===1&&(e.output[0]=a3(e.output[0],zm),e.outputBytes=Ts(e.output[0]))}function va(e,t){e.status!==t&&(e.status=t,iu(e,{type:"status",status:t}))}function iu(e,t){for(const n of Array.from(e.listeners))n(t)}function qL(e,t){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const n=GL(e,t);if(!n)return"rejected";const s=JSON.stringify(n),o=Ts(s);if(o>NL)return"rejected";const c={message:n,encoded:s,bytes:o,sentInstanceId:null,firstSentAt:null};if(!ZL(e,c))return"rejected";const d=e.socket,m=d?.readyState===WebSocket.OPEN,g=n.type!=="ping"&&n.type!=="resize";if(g&&(!m||n.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(d?.bufferedAmount??0)>bx))return $L(e,n)?(m&&d&&co(e,d),"queued"):e.pendingOut.length>=hv||e.pendingOutBytes+o>fv?"rejected":(e.pendingOut.push(c),e.pendingOutBytes+=o,Aw(e,c),m&&d&&co(e,d),"queued");if(m){Aw(e,c);try{return d.send(s),yx(e,c),"sent"}catch{if(g&&e.pendingOut.length<hv&&e.pendingOutBytes+o<=fv)return e.pendingOut.push(c),e.pendingOutBytes+=o,d.close(),"queued";bu(e,c),d.close()}}return"rejected"}function co(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden")return;let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>bx){s3(e,t);return}const s=e.pendingOut[0];if(s.message.type==="input"&&e.inputProtocolMode==="unknown")return;try{t.send(s.encoded),yx(e,s)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-s.bytes),e.outboundFlushDelayMs=zh,n=!0}e.outboundFlushDelayMs=zh,n&&queueMicrotask(()=>{e.pendingOut.length===0&&iu(e,{type:"outbound_flushed"})})}function $L(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let s=null;if(t.type==="resize"&&n.message.type==="resize")s=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const d=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(d===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;s={...t,lines:d}}}if(!s)return!1;const o=JSON.stringify(s),c=Ts(o);return e.pendingOutBytes+=c-n.bytes,n.message=s,n.encoded=o,n.bytes=c,!0}function yl(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=zh}function ks(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Nw(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),yl(e),ks(e,"reconnecting"),Ea(e);const t=e.socket;e.socket=null,va(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),_u(e)}function VL(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),yl(e),ks(e,"skipped"),Ea(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),mh(e),e.listeners.clear()}function YL(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function XL(){return Im=(Im+1)%Number.MAX_SAFE_INTEGER,`${jL}-${Im.toString(36)}`.slice(0,j1)}function GL(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:s,...o}=t;return o}const n=XL();return n.length===0||n.length>j1?null:{...t,messageId:n}}function ZL(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<hv&&e.unackedInputBytes+t.bytes<=fv)}function Aw(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function bu(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function QL(e,t,n){const s=e.unackedInputs.get(n.messageId);if(!s||s.message.type!=="input"||s.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&pv(e,t,c);return}if(bu(e,s),e.inputProtocolMode!=="ack"||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),pv(e,t,o)}function yx(e,t){t.message.type!=="input"||!t.message.messageId||e.inputProtocolMode!=="ack"||!e.serverInstanceId||(t.sentInstanceId=e.serverInstanceId,t.firstSentAt??=Date.now())}function JL(e){if(e3(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(s=>s.message.type==="input"&&s.message.messageId?[s.message.messageId]:[])),n=Array.from(e.unackedInputs.values()).filter(s=>s.message.type==="input"&&s.message.messageId&&!t.has(s.message.messageId));n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((s,o)=>s+o.bytes,0))}function e3(e){const t=Date.now(),n=new Set;for(const[c,d]of e.unackedInputs)d.firstSentAt!==null&&t-d.firstSentAt>=AL&&n.add(c);if(n.size===0)return;e.pendingOut=e.pendingOut.filter(c=>{const d=c.message.type==="input"?c.message.messageId:void 0;return!d||!n.has(d)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of n){const d=e.unackedInputs.get(c);d&&bu(e,d)}const s=n.size===1?"input":"inputs",o=n.size===1?"it":"them";Cx(e,{message:`NTerminal did not replay ${n.size} unacknowledged ${s} after the connection was unavailable for too long, to avoid running ${o} twice.`,ready:!1})}function t3(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function i3(e,t,n,s){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!s){Sx(e,t);return}const o=e.serverInstanceId;e.inputProtocolMode="ack",e.serverInstanceId=n,o===n?(JL(e),n3(e,t)):o!==null&&(wx(e),kx(e)),co(e,t)}function Sx(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",e.serverInstanceId=null,wx(e),kx(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;bu(e,n);const{messageId:s,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=Ts(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}co(e,t)}}function wx(e){const t=new Set;for(const[s,o]of e.unackedInputs)o.sentInstanceId!==null&&t.add(s);if(t.size===0)return;e.pendingOut=e.pendingOut.filter(s=>{const o=s.message.type==="input"?s.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-s.bytes),!1)});for(const s of t){const o=e.unackedInputs.get(s);o&&bu(e,o)}const n=t.size===1?"input was":"inputs were";Cx(e,{message:`The terminal server restarted before ${t.size} ${n} acknowledged. NTerminal did not resend ${t.size===1?"it":"them"} to avoid running input twice.`,ready:!1})}function Cx(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function xx(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)iu(e,{type:"message",message:{type:"error",message:n.message}})}}function mh(e){yl(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function pv(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="ack"||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function n3(e,t){for(const n of e.pendingAckReceipts.values())if(pv(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function r3(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function kx(e){e.pendingAckReceipts.clear()}function s3(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(LL,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,co(e,t)},n)}function Ts(e){return BL.encode(e).byteLength}function a3(e,t){if(Ts(e)<=t)return e;let n=0,s=e.length;for(;n<s;){const o=Math.floor((n+s)/2);Ts(e.slice(o))<=t?s=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const o3=[0,50,150,350],l3=[100,300,750],c3=2,u3=[300,1200,2500],d3=1e3,h3=1e5,f3="",mv="\x1B[?1049l\x1B[?1047l\x1B[?47l",p3=new Set(["47","1047","1049"]),m3=400,g3=9,v3=9,_3=32,b3=1.42,y3=2,S3=24,w3=720,C3=60,x3=1260,k3=6,E3=2,Lw=[500,1500,3e3,5e3,8e3],Ow=15e3,T3=2,D3=1e3,Bw="Do not take action. Wait for my next input.",Ih=6e4,R3=Ih+5*6e4,jw=Ih+6e4,M3=40,Zd=240,N3=5e3,A3=Bi.lazy(()=>h_(()=>import("./TranscriptMarkdownBody-BFu2FzgT.js"),__vite__mapDeps([2,1]))),$c=new Map,el=new Map;function zw({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:k}){const x=v.useSyncExternalStore(tC,vg,()=>to),w=v.useSyncExternalStore(iC,_g,()=>cl),D=v.useSyncExternalStore(nC,yg,()=>!0),O=v.useSyncExternalStore(sh,Sg,()=>!0),A=v.useSyncExternalStore(sh,wg,()=>!0),z=v.useSyncExternalStore(Hv,Sa,()=>ll),$=v.useSyncExternalStore(kh,()=>Eh("history.toggle"),()=>"Alt+H"),K=v.useSyncExternalStore(kh,()=>Eh("scrollback.toggle"),()=>"Alt+S"),Q=v.useRef(null),F=v.useRef(null),q=v.useRef(null),be=v.useRef(null),Se=v.useRef(e.id),De=v.useRef({onExit:y,onSnapshot:b}),ie=v.useRef(t.createWebSocketUrl),G=v.useRef(k),Z=v.useRef(null),W=v.useRef(null),re=v.useRef(null),L=v.useRef(!1),R=v.useRef(new Map),I=v.useRef(new Map),se=v.useRef(new Set),ye=v.useRef([]),M=v.useRef(!1),U=v.useRef(null),ae=v.useRef(0),_e=v.useRef(!1),Ne=v.useRef(!1),xe=v.useRef(!1),Le=v.useRef({terminalId:e.id,enabled:!1}),Ee=v.useRef([]),je=v.useRef([]),Fe=v.useRef(0),ee=v.useRef(!1),de=v.useRef(null),he=v.useRef(0),Ae=v.useRef(0),ze=v.useRef(null),Me=v.useRef(null),oe=v.useRef(!1),ke=v.useRef(!1),ge=v.useRef(!1),Oe=v.useRef(null),Ve=v.useRef(!1),ot=v.useRef(null),vt=v.useRef(null),xt=v.useRef(!1),jn=v.useRef(!1),ni=v.useRef(!1),mi=v.useRef(!1),Ye=v.useRef(!1),ft=v.useRef(!1),Vt=v.useRef(!1),ve=v.useRef(n),Ue=v.useRef(s),nt=v.useRef(c),Ze=v.useRef(x),Et=v.useRef(w),ht=v.useRef(!1),Qt=v.useRef(null),oi=v.useRef(0),V=v.useRef(0),Ke=v.useRef(e.id),rt=v.useRef(()=>{}),st=v.useRef(null),Rt=v.useRef(null),Lt=v.useRef(!1),jt=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),li=v.useRef(0),qt=v.useRef(null),Ri=v.useRef(0),$t=v.useRef(null),Jt=v.useRef(0),Ji=v.useRef(!1),yi=v.useRef(!1),ei=v.useRef(null),Ii=v.useRef(null),[,Pi]=v.useState("connecting"),[en,ln]=v.useState(!1),[gi,ci]=v.useState(null),[Hi,Cn]=v.useState(!1),[$r,Ms]=v.useState(null),[Cl,Ns]=v.useState(!1),[Vr,Nr]=v.useState(!1),[Ar,cn]=v.useState(!1),[Lr,Gn]=v.useState(!1),[St,As]=v.useState(null),un=e.agentCache&&St&&e.agentCache.source.provider===St.provider&&e.agentCache.source.sessionId===St.sessionId?e.agentCache:null,[zn,mr]=v.useState(()=>Date.now()),[gr,Ls]=v.useState(!1),[po,Ta]=v.useState(null),[vr,_r]=v.useState(!1),[ri,Mi]=v.useState(null),[mo,Da]=v.useState(!1),[Os,br]=v.useState(!1),[Bs,vn]=v.useState(null),[Ui,pt]=v.useState(null),xn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Yr,In]=v.useState(()=>bm(e.id)),Or=St?.provider??e.agentStatus?.provider??null,Ra=Or!==null||jc(e.currentCommand),yr=Or==="claude"||Nx(e.currentCommand),go=Or!==null||jc(e.currentCommand),Xr=e.capabilities?.tmuxScrollback===!0,Ki=Xr&&(Yr??(go?A:O)),[kl,vo]=v.useState(!1);v.useLayoutEffect(()=>{ve.current=n},[n]),v.useLayoutEffect(()=>{Ue.current=s},[s]),v.useLayoutEffect(()=>{nt.current=c},[c]),v.useLayoutEffect(()=>{Ze.current=x},[x]),v.useLayoutEffect(()=>{Et.current=w},[w]),v.useLayoutEffect(()=>{ht.current=vr},[vr]),v.useLayoutEffect(()=>{Qt.current=St},[St]);const Fi=v.useCallback((S,P={})=>{!S&&P.preserveOnNull||(Jd(Qt.current,S)||(V.current+=1),Qt.current=S,As(we=>we&&S&&we.provider===S.provider&&we.sessionId===S.sessionId?we:S))},[]),dn=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),Zn=v.useCallback(()=>{const S=Qt.current,P=V.current;S&&(async()=>{let we=S;try{we=await dn()??we}catch{}we&&Ke.current===e.id&&V.current===P&&Jd(S,Qt.current)&&(Fi(we,{preserveOnNull:!0}),st.current=Km(e.id,we),_r(!0))})()},[Fi,dn,e.id]),Qn=v.useCallback(async(S={})=>{const P=await Pw(xn,t,S);return Mi(P),P},[xn,t]),Yt=v.useCallback((S,P="info")=>{$t.current!==null&&window.clearTimeout($t.current),pt({id:Ri.current++,message:S,tone:P}),$t.current=window.setTimeout(()=>{pt(null),$t.current=null},3200)},[]),kn=v.useCallback(()=>{const S=m?.serverKey.trim()||"local",P=m?.serverName.trim()||"Local",we=m?.tabName.trim()||e.title||"Terminal",He=ri?.instances.find(tt=>tt.cwd===e.cwd);if(He&&Hw(Qd(S,He.id))){Yt("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(He&&Hm(Qd(S,He.id),He.url)){Yt("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ge=null;const Qe=()=>((!Ge||Tx(Ge))&&(Ge=window.open("about:blank","_blank"),L3(Ge)),Ge);ri?.installed!==!0&&Qe(),br(!0),vn(null),(async()=>{let tt=ri;if(tt?.installed||(tt=await Qn({force:!0})),!tt?.installed||tt.supported===!1){Um(Ge),Da(!0);return}const at=tt.instances.find(Tt=>Tt.cwd===e.cwd);if(at){const Tt=Qd(S,at.id);if(Uw(Ge,Tt,at.url)||Hm(Tt,at.url)!==null){Yt("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const qe=Qe();return{response:await t.openCodeServer({terminalId:e.id,serverName:P,tabName:we}),targetPopup:qe}})().then(tt=>{if(!tt)return;const{response:at,targetPopup:qe}=tt;gv(xn,at.status),Mi(at.status);const Kt=Qd(S,at.instance.id);if(Hw(Kt)){Um(qe),Yt("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}Uw(qe,Kt,at.url)||Hm(Kt,at.url)?Yt("Opening VS Code..."):Yt("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(tt=>{Um(Ge),Da(!0),vn(eh(tt))}).finally(()=>br(!1))},[m?.serverName,m?.tabName,xn,ri,Qn,t,Yt,e.cwd,e.id,e.title]);v.useEffect(()=>{let S=!1;return Pw(xn,t).then(P=>{S||Mi(P)}).catch(()=>{}),()=>{S=!0}},[xn,t]),v.useEffect(()=>{if(ri?.job?.status!=="running")return;const S=window.setInterval(()=>{Qn({force:!0}).catch(P=>vn(eh(P)))},1e3);return()=>window.clearInterval(S)},[ri?.job?.status,Qn]),v.useEffect(()=>()=>{$t.current!==null&&window.clearTimeout($t.current)},[]),v.useLayoutEffect(()=>{rt.current=Zn},[Zn]),v.useLayoutEffect(()=>{Rt.current=un},[un]),v.useLayoutEffect(()=>{Lt.current=gr},[gr]),v.useLayoutEffect(()=>{Ji.current=Ra},[Ra]),v.useLayoutEffect(()=>{yi.current=yr},[yr]),v.useLayoutEffect(()=>{const S=Le.current;Ne.current=Ki,xe.current=Xr,Le.current={terminalId:e.id,enabled:Ki},$w(Q.current,Ki),S.terminalId===e.id&&S.enabled&&!Ki&&mf(),Ki||cn(!1)},[e.id,Ki,Xr]),v.useEffect(()=>{In(bm(e.id)),ae.current=0,_e.current=!1,cn(!1),La()},[e.id]),v.useEffect(()=>sh(()=>{In(bm(e.id))}),[e.id]),v.useEffect(()=>()=>{Ps()},[]),v.useEffect(()=>{let S=!1;return s&&e.status==="running"&&Cr(()=>S),()=>{S=!0}},[s,e.id,e.status]),v.useEffect(()=>{s&&n&&e.status==="running"&&Br("auto")},[n,s,e.status]),v.useEffect(()=>{De.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{ie.current=t.createWebSocketUrl,G.current=k},[t,k]),v.useLayoutEffect(()=>{Se.current=e.id,Vt.current=!1,Gn(!1)},[e.id]),v.useEffect(()=>{let S=!1,P=null,we=0;const He=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ge=He||l5(e.currentCommand),Qe=He||jc(e.currentCommand);function tt(){P!==null&&(window.clearTimeout(P),P=null)}function at(Kt){if(S)return;let Tt;if(Kt)Tt=Ow;else if(we<Lw.length){if(!Ge)return;Tt=Lw[we++]}else{if(!Qe)return;Tt=Ow}P=window.setTimeout(()=>{P=null,qe()},Tt)}async function qe(){try{const Kt=Qt.current!==null,Tt=await dn();if(S)return;if(Tt){oi.current=0,Fi(Tt),at(!0);return}oi.current+=1;const Dt=!!(Kt&&Ge&&oi.current<T3);Fi(null,{preserveOnNull:Dt}),at(Dt)}catch(Kt){if(S)return;Fm(Kt)&&Fi(null),at(!1)}}return Ke.current!==e.id&&(Ke.current=e.id,V.current+=1,Qt.current=null,oi.current=0,As(null)),e.status!=="running"?(V.current+=1,Qt.current=null,oi.current=0,As(null),()=>{S=!0,tt()}):(qe(),()=>{S=!0,tt()})},[Fi,dn,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const S=Km(e.id,St),P=st.current;P!==null&&S!==null&&P!==S&&(Me.current=null,oe.current=!1,ke.current=!1,ht.current&&_r(!1)),st.current=S},[e.id,St?.provider,St?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!St){Ls(!1);return}const S=window.setInterval(()=>{mr(Date.now())},D3);return()=>{window.clearInterval(S)}},[e.status,St?.provider,St?.sessionId]),v.useEffect(()=>{const S=j3(un);jt.current.key!==S&&(jt.current={key:S,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[un?.expiresAt,un?.source?.provider,un?.source?.sessionId]),v.useEffect(()=>{if(!gr||!un||un.status!=="ready")return;const S=Dx(un,zn);if(S===null||S<=0)return;const P=jt.current;!P.warnedFiveMinutes&&S<=R3&&S>jw&&(P.warnedFiveMinutes=!0,Tn({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."})),!P.warnedOneMinute&&S<=jw&&S>Ih&&(P.warnedOneMinute=!0,Tn({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!P.sent&&!P.skipped&&S<=Ih&&Ol()},[gr,zn,un,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function S(P){if(!ve.current||!Ue.current||P.isComposing||P.key==="Process"||P3(P.target))return;const we=oC(P);if(we?.id==="history.toggle"&&Qt.current){P.preventDefault(),P.stopPropagation(),ht.current?_r(!1):rt.current();return}if(we?.id==="scrollback.toggle"&&xe.current){P.preventDefault(),P.stopPropagation(),Ll();return}}return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{const S=F.current;S&&(S.options.disableStdin=e.status==="exited"),e.status==="exited"&&Pi("closed")},[e.status]),v.useEffect(()=>{const S=F.current;S&&(S.options.fontSize=x,_m(x,Et.current).then(()=>{Ze.current===x&&_t()}))},[x]),v.useEffect(()=>{const S=F.current;S&&(S.options.fontFamily=gg(w),_m(Ze.current,w).then(()=>{Et.current===w&&_t()}))},[w]),v.useEffect(()=>{const S=F.current;S&&(S.options.theme=Iw(z))},[z]),v.useEffect(()=>{const S=Q.current;if(!S)return;let P=!1,we=null,He=null,Ge=null,Qe=null,tt=null,at=null,qe=null;Z.current=null,Ye.current=!1,ft.current=!1,Ve.current=!1,yu(),Su(),Gr(),M.current=!1;const Kt=Ze.current,Tt=Et.current,Dt=new TA({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:gg(Tt),fontSize:Kt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:h3,theme:{...Iw(Sa())}}),er=new _R;return Dt.loadAddon(er),Qe=wL(Dt),F.current=Dt,q.current=er,_m(Kt,Tt).then(()=>{if(P)return;Dt.open(S),$w(S,Ne.current),Ye.current=!0,we=hL(Dt,{onPasteText:ju,onInterrupt:Bu,shouldInterruptPlainCtrlC:()=>yi.current}),Ue.current&&ve.current&&e.status==="running"&&Br("auto"),_t(),tt=g5(S,Dt,()=>Ze.current*1.2,Is,fn=>{hn(fn)},Rl,Ml,()=>Ne.current,ts),at=f5(S,Dt,Is,fn=>{hn(fn)},Rl,Ml,()=>Ne.current,ts);const Ba=new DA;He=Dt.onData(fn=>{if(Vt.current){const Il=zA(fn);if(Il){tn(!1),kr(Il);return}}const zl=Ba.accept(fn);zl&&kr(zl)}),Ge=Dt.onScroll(fn=>{if(jn.current||mi.current||ni.current){Wi();return}xu(),Yn(Dt)&&es({scrollToBottom:!0}),Is(),!Ne.current&&fn<=3&&hn()}),qe=new ResizeObserver(()=>{Jn()}),qe.observe(S),ft.current&&(js(),ft.current=!1,_t()),ui()}),()=>{Nu(be.current,{updateUi:!1}),P=!0,Ye.current=!1,ft.current=!1,yu(),Su(),W.current=null,re.current=null,L.current=!1,wu(),M.current=!1,Cu(),ni.current=!1,ee.current=!1,he.current+=1,Ae.current+=1,de.current=null,ei.current=null,Ii.current=null,ge.current=!1,Oe.current=null,ln(!1),tt?.(),at?.(),qe?.disconnect(),we?.dispose(),He?.dispose(),Ge?.dispose(),Qe?.dispose(),Dt.dispose(),F.current=null,q.current=null}},[e.id]),v.useEffect(()=>{const S=ie.current(e.id),P=zL(S,Ma);return be.current=P.send,Pi(P.status),P.status==="connected"&&_t(),P.snapshot&&(De.current.onSnapshot(P.snapshot,{notifyCompletion:!1}),F.current&&(_t(),Zr(P.output,P.history),_t())),()=>{Nu(P.send,{updateUi:!1}),P.detach(),be.current=null}},[e.id,e.status]);function Ma(S){if(S.type==="status"){Pi(S.status),S.status==="unauthorized"&&G.current?.({source:"terminal-ws-1008",terminalId:e.id}),S.status==="connected"&&(_t(),xr());return}if(S.type==="upgrade_rejected"){G.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(S.type==="outbound_flushed"){M.current&&(M.current=!1,Iu());return}zs(S.message)}function Gr(S=[],P=null){Ee.current=[],je.current=th(S),Fe.current=0,ee.current=!1,de.current=null,ni.current=!1,he.current+=1,ze.current=P,Me.current=null,oe.current=!1,ke.current=!1,ge.current=!1,Oe.current=null,ft.current=!1,ei.current=null,Ii.current=null,ot.current=null,xt.current=!1,ln(!1),ci(null),Cn(!1),Ms(null),Ns(!1),Nr(!1)}function Zr(S=[],P=null){if(ni.current||ee.current){Ii.current={output:S,history:P,appendFromLiveOutputIndex:je.current.length};return}Gr(S,P),En()}function Sr(){if(ni.current||ee.current)return!1;const S=Ii.current;if(!S)return!1;const P=je.current.slice(S.appendFromLiveOutputIndex);return Ii.current=null,Gr([...S.output,...P],S.history),En(),!0}function En(){if(!F.current||!Ye.current){ft.current=!0;return}ft.current=!1,js()}async function js(){const S=F.current;if(!S)return;const P=ih(S,xt.current),we=P?je.current.length:Fe.current,He=await wr(S,{liveOutputLimit:we,scrollToBottom:P});F.current===S&&(Wi(),He&&xr())}function wr(S,P={}){return new Promise(we=>{ni.current=!0,ee.current=!1;const He=he.current+1;he.current=He;const Ge=Math.max(0,Math.min(P.liveOutputLimit??je.current.length,je.current.length)),Qe=P.historyPages??Ee.current,tt=()=>F.current===S&&he.current===He,at=()=>tt()&&(P.isCurrent?.()??!0),qe=()=>{tt()&&(ni.current=!1),we(!1)},Kt=()=>{if(!at()){qe();return}try{Fe.current=Ge,P.scrollToBottom&&bo(S)}finally{if(ni.current=!1,Sr()){we(!1);return}const Dt=Eu();Dt?es(Dt):P.applyDeferredSnapshot!==!1&&Dl(),we(!0)}},Tt=()=>{if(!at()){qe();return}S.clear();const Dt=th([...Qe,...je.current.slice(0,Ge)]);if(Dt.length===0){Kt();return}for(let er=0;er<Dt.length;er+=1){const Ba=Dt[er];er===Dt.length-1?S.write(Ba,Kt):S.write(Ba)}};if(S.buffer.active.type==="alternate"){S.write(mv,Tt);return}Tt()})}async function hn(S=0){const P=F.current;if(ge.current||!P)return;if(Tl(P)){Wi();return}const we=ze.current,He=Ae.current,Ge=Symbol("history-load"),Qe=()=>F.current===P&&Ae.current===He;Oe.current=Ge,ge.current=!0,ln(!0);const tt=P.buffer.active.viewportY;try{let at=!!(we&&!we.hasMore);if(!at)try{const qe=await t.getTerminalHistory(e.id,{beforeLine:we?.startLine??0,...we?.snapshotHistorySize!==void 0?{snapshotHistorySize:we.snapshotHistorySize}:{},...we?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:we.snapshotHistoryLimit}:{},...we?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:we.snapshotHistoryToken}:{},...we?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:we.snapshotPaneWidth}:{},limit:d3});if(!Qe()||ze.current!==we)return;const Kt=()=>Qe()&&ze.current===we;if(qe.invalidated){Jr();return}const Tt=qe.hasMore&&qe.snapshotHistorySize!==void 0&&qe.snapshotPaneWidth!==void 0,Dt={startLine:qe.startLine,endLine:qe.endLine,hasMore:Tt,...qe.snapshotHistorySize!==void 0?{snapshotHistorySize:qe.snapshotHistorySize}:{},...qe.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:qe.snapshotHistoryLimit}:{},...qe.snapshotHistoryToken!==void 0?{snapshotHistoryToken:qe.snapshotHistoryToken}:{},...qe.snapshotPaneWidth!==void 0?{snapshotPaneWidth:qe.snapshotPaneWidth}:{}};if(qe.output.length>0){await Qr(P,qe.output,tt,S)&&Kt()&&(ze.current=Dt);return}if(!Kt())return;ze.current=Dt,at=!Tt}catch(qe){at=Qe()&&Fm(qe)}if(at){if(!Qe()||Tl(P)){Wi();return}await Na(P,tt,S,Qe)}}catch{}finally{Oe.current===Ge&&(Oe.current=null,ge.current=!1,ln(!1))}}async function Na(S,P,we,He){if(!He()||oe.current||ke.current)return;const Ge=Qt.current,Qe=V.current,tt=Me.current,at=()=>He()&&V.current===Qe&&Jd(Ge,Qt.current)&&Me.current===tt;try{const qe=await t.getTerminalTranscriptHistory(e.id,{...tt?{cursor:tt}:{},limit:m3}),Kt=qe.output.map(Ax);if(!qe.source||qe.terminalId!==e.id||!at())return;if(Ge&&!E_(Ge,qe.source)){Me.current=null,oe.current=!1,ke.current=!1,Fi(qe.source);return}if(Kt.length===0){Fi(qe.source),Me.current=qe.cursor,ke.current=!qe.hasMore||!qe.cursor;return}await Qr(S,Kt,P,we,at)&&at()&&(Fi(qe.source),Me.current=qe.cursor,ke.current=!qe.hasMore||!qe.cursor)}catch(qe){at()&&Fm(qe)&&(oe.current=!0)}}async function Qr(S,P,we,He,Ge){if(Tl(S)||Ge&&!Ge())return Wi(),!1;const Qe=Ee.current,tt=[...P,...Qe],at=d5(P),qe=he.current+1,Kt=await wr(S,{liveOutputLimit:Fe.current,scrollToBottom:!1,historyPages:tt,applyDeferredSnapshot:!1,...Ge?{isCurrent:Ge}:{}}),Tt=Ge!==void 0&&!Ge();return!Kt||Tt||F.current!==S?(Tt&&F.current===S&&he.current===qe&&await wr(S,{liveOutputLimit:Fe.current,scrollToBottom:!1,historyPages:Qe,applyDeferredSnapshot:!1})&&F.current===S&&(Du(S,we),xt.current=!Yn(S),Is()),!1):(Ee.current=tt,Du(S,Math.max(0,we+at+Math.min(0,He))),xt.current=!Yn(S),Is(),!0)}v.useEffect(()=>{const S=window.visualViewport;let P=!1;function we(){if(document.visibilityState==="hidden"){HL();return}Cr(()=>P)}function He(){Cr(()=>P)}function Ge(){Cr(()=>P)}function Qe(){Jn()}function tt(){T()}return document.addEventListener("visibilitychange",we),window.addEventListener("pageshow",He),window.addEventListener("online",Ge),window.addEventListener("resize",Qe),window.addEventListener(jh,tt),S?.addEventListener("resize",Qe),S?.addEventListener("scroll",Qe),()=>{P=!0,document.removeEventListener("visibilitychange",we),window.removeEventListener("pageshow",He),window.removeEventListener("online",Ge),window.removeEventListener("resize",Qe),window.removeEventListener(jh,tt),S?.removeEventListener("resize",Qe),S?.removeEventListener("scroll",Qe)}},[e.id]);function Cr(S){if(document.visibilityState==="hidden"||!Ue.current)return;xr(),_t();const P=ie.current(e.id);PL(P).then(()=>{S()||(_t(),xr())})}function Jr(){const S=ie.current(e.id);Ae.current+=1,Ve.current=!0,ei.current=null,Pi("reconnecting"),_t(),IL(S)}function zs(S){if(S.type==="snapshot"&&S.terminal.id===e.id){Ae.current+=1,De.current.onSnapshot(S.terminal,{notifyCompletion:!1});const we=Ve.current;Ve.current=!1;const He=F.current;if(!He)return;if(_t(),we){Pn(S.output,S.history??null);return}if(Tu(He,S.terminal)){hf(S.output,S.history??null),Wi(),_t();return}Zr(S.output,S.history??null),_t();return}if(S.type==="terminal_updated"&&S.terminal.id===e.id){De.current.onSnapshot(S.terminal,{notifyCompletion:!0});return}if(S.type==="output"&&S.terminalId===e.id){const we=Bx(S.data);if(!we)return;je.current.push(we),F.current&&Ye.current?es({scrollToBottom:!0}):ft.current=!0;return}const P=F.current;if(P){if(S.type==="exit"&&S.terminalId===e.id){De.current.onExit(S.exitCode),Pi("closed");return}S.type==="error"&&P.writeln(`\r
|
|
34
|
-
[nterminal] ${S.message}`)}}function Pn(S,P){Zr(S,P),_t()}function Si(S=25){if(document.visibilityState==="hidden"||!Ue.current||R.current.has(S))return;const P=window.setTimeout(()=>{R.current.delete(S),!C()&&Mu()},S);R.current.set(S,P)}function Jn(){C()||ui()}function C(){const S=fe();return S&&B(S)?(L.current=!0,re.current=S,!0):S&&te(S)?(L.current=!1,re.current=null,!0):((!S||!S.composeOpen&&!S.keyboardVisible)&&(L.current=!1,re.current=null),!1)}function T(){if(!L.current)return;const S=fe();S&&(S.composeOpen||S.keyboardVisible)||(L.current=!1,re.current=null)}function B(S){if(!S.mobileLike||!S.composeOpen&&!S.keyboardVisible)return!1;const P=W.current;return P?lt(S.windowWidth,P.windowWidth)&<(S.visualViewportWidth,P.visualViewportWidth)&<(S.containerWidth,P.containerWidth):!1}function te(S){if(!S.mobileLike||S.composeOpen||S.keyboardVisible)return!1;const P=re.current;return!P||!P.composeOpen&&!P.keyboardVisible?!1:lt(S.windowWidth,P.windowWidth)&<(S.visualViewportWidth,P.visualViewportWidth)&<(S.containerWidth,P.containerWidth)}function fe(){const S=Q.current;if(!S||S.isConnected===!1)return null;const P=S.getBoundingClientRect(),we=We(window.innerWidth)??0,He=We(window.visualViewport?.width)??we,Ge=We(P.width)??We(S.clientWidth)??we;if(we<=0||He<=0||Ge<=0)return null;const{keyboardVisible:Qe}=cv(),tt=document.documentElement.hasAttribute(rf),at=ce()||Qe;return{windowWidth:we,visualViewportWidth:He,containerWidth:Ge,composeOpen:tt,keyboardVisible:Qe,mobileLike:at}}function ce(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Ce(){return cv().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function We(S){return typeof S=="number"&&Number.isFinite(S)&&S>0?S:null}function lt(S,P){return Math.abs(S-P)<=c3}function ui(){for(const S of o3)Si(S)}function _t(){Z.current=null,ui()}function xr(){if(_o(),se.current.size===0&&typeof window.requestAnimationFrame=="function"){const S=window.requestAnimationFrame(()=>{se.current.delete(S),_o();const P=window.requestAnimationFrame(()=>{se.current.delete(P),_o()});se.current.add(P)});se.current.add(S)}for(const S of l3){if(I.current.has(S))continue;const P=window.setTimeout(()=>{I.current.delete(S),_o()},S);I.current.set(S,P)}}function _o(){const S=F.current;if(!(!S||!Ye.current||document.visibilityState==="hidden"||!Ue.current||Q.current?.isConnected===!1))try{S.refresh(0,Math.max(0,S.rows-1))}catch{}}function yu(){for(const S of R.current.values())window.clearTimeout(S);R.current.clear()}function Su(){for(const S of I.current.values())window.clearTimeout(S);I.current.clear();for(const S of se.current)window.cancelAnimationFrame(S);se.current.clear()}function wu(){for(const S of ye.current)window.clearTimeout(S);ye.current=[]}function Is(){if(Wi(),!ot.current){Cn(!1);return}Cn(!0),Cu(),vt.current=window.setTimeout(()=>{vt.current=null,Cn(!1)},1200)}function Wi(){const S=F.current,P=S?h5(S):null;if(ot.current=P,ci(P),Nr(!!(S&&P)),Ns(!!(S&&P&&!Yn(S))),P||!S||!uf()){Ms(null);return}Ms({alternate:S.buffer.active.type==="alternate"})}function uf(){const S=ze.current;return Ee.current.length>0||!!S?.hasMore}function Cu(){vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null)}function xu(){const S=F.current;S&&(xt.current=!Yn(S),Wi())}function ku(S){de.current=Wm(de.current,S)}function El(S){const P=de.current;return de.current=null,Wm(P,S)}function Eu(){const S=de.current;return de.current=null,S}function es(S={}){const P=F.current;if(!P||!Ye.current){ft.current=!0;return}if(ei.current&&!ni.current&&!ee.current&&Yn(P)){Dl();return}if(ni.current){ku(S);return}if(ee.current){ku(S);return}const we=El(S);if(!we.force&&!ih(P,xt.current)){Wi();return}ee.current=!0;const He=he.current,Ge=()=>{if(F.current!==P||he.current!==He)return;if(!we.force&&!ih(P,xt.current)){if(ee.current=!1,Sr())return;Wi();return}const Qe=Fe.current,tt=je.current[Qe];if(tt===void 0){if(ee.current=!1,Sr())return;we.scrollToBottom&&bo(P),Wi();const at=Eu();at?es(Wm(we,at)):Dl();return}P.write(tt,()=>{F.current!==P||he.current!==He||(Fe.current=Qe+1,Ge())})};Ge()}function Tl(S){return ei.current!==null||!Yn(S)&&(df()||ee.current||ni.current)}function Tu(S,P){return(P?.agentStatus?.provider==="codex"||P?.agentStatus?.provider==="claude"||Ji.current||jc(P?.currentCommand))&&!Yn(S)}function df(){return Fe.current<je.current.length}function hf(S,P){ei.current={output:S,history:P,appendFromLiveOutputIndex:je.current.length}}function Dl(){const S=F.current,P=ei.current;if(!S||!P||!Yn(S)||ee.current||ni.current)return;const we=th(P.output),He=th(je.current.slice(P.appendFromLiveOutputIndex));ei.current=null,Zr([...we,...He],P.history),_t()}function Rl(){mi.current=!0}function Ml(){xu(),mi.current=!1;const S=F.current;S&&Yn(S)&&es({scrollToBottom:!0})}function bo(S){Ru(()=>Vw(S))&&(xt.current=!1)}function Du(S,P){Ru(()=>(S.scrollToLine(P),!0))}function Ru(S){jn.current=!0;try{return S()}finally{jn.current=!1}}function ff(){const S=F.current;if(!S)return;const P=()=>{Ne.current&&(Au(be.current),cn(!1)),Vw(S),xt.current=!1,Wi(),es({force:!0,scrollToBottom:!0}),Br("scroll-action")};if(S.buffer.active.type==="alternate"){S.write(mv,P);return}P()}function yo(S){const P=F.current,we=Q.current;if(!P||!we)return;const He=we.getBoundingClientRect();if(He.height<=0)return;const Ge=Math.max(0,Math.min(1,(S-He.top)/He.height)),Qe=Math.round(P.buffer.active.baseY*Ge);Rl();try{P.scrollToLine(Qe)}finally{Ml()}xt.current=!Yn(P),Wi(),Is(),Qe<=3&&hn()}function Aa(S){S.preventDefault(),S.stopPropagation(),S.currentTarget.setPointerCapture?.(S.pointerId),yo(S.clientY)}function pf(S){(S.buttons&1)!==0&&(S.preventDefault(),S.stopPropagation(),yo(S.clientY))}function Mu(){const S=F.current,P=q.current;if(!(!S||!P)&&!(document.visibilityState==="hidden"||!Ue.current||Q.current?.isConnected===!1))try{const we=ih(S,xt.current),He=fe();P.fit(),He&&(W.current=He),we&&bo(S),S.refresh(0,Math.max(0,S.rows-1)),Wi();const Ge={cols:S.cols,rows:S.rows},Qe=Z.current;if(Qe&&Qe.cols===Ge.cols&&Qe.rows===Ge.rows)return;So({type:"resize",terminalId:e.id,cols:Ge.cols,rows:Ge.rows})&&(Z.current=Ge)}catch{}}function Nl(S){const P=be.current;return P?P(S):"rejected"}function So(S){return Nl(S)!=="rejected"}function La(){U.current!==null&&(window.clearTimeout(U.current),U.current=null)}function Al(){La();const S=Math.max(-Zd,Math.min(Zd,ae.current));if(ae.current=0,S===0)return!1;const P=So({type:"scrollback_scroll",terminalId:e.id,lines:S});return P&&(_e.current=!0,S<0&&cn(!0)),P}function ts(S){if(!Ne.current||S===0)return;const P=ae.current+S;ae.current=Math.max(-Zd,Math.min(Zd,P)),U.current===null&&(U.current=window.setTimeout(()=>{U.current=null,Al()},M3))}function mf(){Au(be.current)}function Nu(S=be.current,P={}){const we=_e.current;La(),ae.current=0,_e.current=!1,P.updateUi!==!1&&cn(!1),we&&S?.({type:"cancel_scrollback",terminalId:e.id})}function Au(S){La(),ae.current=0,_e.current=!1,cn(!1),S?.({type:"cancel_scrollback",terminalId:e.id})}function Ll(){if(!xe.current)return;const S=!Ne.current;In(TD(Se.current,S)),Bl()}function Lu(){const S=!Lt.current;Lt.current=S,Ls(S),Tn({tone:S?"info":"skipped",message:S?"Cache keep-alive enabled":"Cache keep-alive off",...S?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Ps(){qt.current!==null&&(window.clearTimeout(qt.current),qt.current=null)}function Tn(S,P={}){Ps();const we=li.current+1;li.current=we,Ta({...S,id:we}),!P.sticky&&(qt.current=window.setTimeout(()=>{qt.current=null,Ta(He=>He?.id===we?null:He)},12e3))}function gf(){jt.current.skipped=!0,Tn({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function wo(){Lt.current=!1,Ls(!1),Tn({tone:"skipped",message:"Cache keep-alive off"})}async function Ol(){const S=jt.current;if(S.sent||S.skipped)return;const P=Ou();if(S.sent=!0,P){Tn({tone:"skipped",message:"Skipped cache keep-alive",detail:P});return}if(kr(`${Bw}\r`,{userInitiated:!1})==="rejected"){Tn({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Tn({tone:"success",message:"Cache keep-alive sent",detail:Bw})}function Ou(){const S=Rt.current,P=Qt.current;return Lt.current?e.status!=="running"?"Pane is not running.":!S||S.status!=="ready"||!S.source||!P?"Transcript cache status is unavailable.":S.source.provider!==P.provider||S.source.sessionId!==P.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${nu(P.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":sf(e.id).text.trim()?"Compose has an unsent draft.":H3(Q.current)?"Pane input is focused.":Date.now()-Jt.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function Bl(){const S=F.current;S&&(bo(S),Wi())}function kr(S,P={}){Al();const we=_e.current;es({force:!0,scrollToBottom:!0});const He=Nl({type:"input",terminalId:e.id,data:S,...we?{cancelScrollbackMode:!0}:{}});return He==="rejected"?(Yt("Input was not sent because the terminal connection buffer is full or unavailable.","error"),He):(P.userInitiated!==!1&&(Jt.current=Date.now()),we&&(_e.current=!1,cn(!1)),o5(S)&&(He==="sent"?Iu():He==="queued"&&(M.current=!0)),He)}function Bu(){Vt.current&&tn(!1),kr(f3)}function ju(S){const P=Cw(S,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});P&&kr(P)}function zu(S,P){const we=Cw(S,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});return we?kr(`${we}${eL(P)}`)!=="rejected":!1}function Iu(){!nt.current||!ve.current||(wu(),ye.current=u3.map(S=>{const P=window.setTimeout(()=>{ye.current=ye.current.filter(we=>we!==P),nt.current&&ve.current&&So({type:"refresh_cwd",terminalId:e.id})},S);return P}))}function Br(S="terminal-interaction"){ht.current||Ce()&&(S==="auto"||S==="scroll-action")||F.current?.focus()}const vf=v.useCallback(()=>{_r(!1)},[]),_f=v.useCallback(async()=>{const S=Qt.current,P=V.current;try{const we=await t.getTerminalTranscriptSource(e.id);if(!we.source||Ke.current!==e.id||V.current!==P||!Jd(S,Qt.current))return;Me.current=null,oe.current=!1,ke.current=!1,Fi(we.source),st.current=Km(e.id,we.source)}catch{}},[Fi,t,e.id]);function bf(){Gn(S=>{const P=!S;return Vt.current=P,P}),Br("input-action")}function tn(S){Vt.current=S,Gn(S)}function Oa(S){Vt.current&&tn(!1),kr(jA(S)),Br("input-action")}async function jl(S="install"){br(!0),vn(null);try{const P=S==="update"?await t.updateCodeServer():await t.installCodeServer();gv(xn,P.status),Mi(P.status)}catch(P){vn(eh(P))}finally{br(!1)}}return p.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Ki?"true":"false",onMouseDown:()=>{n||g()},children:[p.jsx(U3,{terminal:e,canClose:o,tabId:d,transcriptSource:St,transcriptShortcutLabel:$,transcriptCacheStatus:un,transcriptCacheNow:zn,cacheKeepAliveEnabled:gr,codeServerAvailable:!0,codeServerInstallState:ri===null?"unknown":ri.installed?"installed":"missing",codeServerBusy:Os||ri?.job?.status==="running",codeServerSupported:ri?.supported!==!1,scrollbackShortcutLabel:K,tmuxScrollbackSupported:Xr,tmuxScrollbackEnabled:Ki,onToggleCacheKeepAlive:Lu,onOpenCodeServer:kn,onToggleTmuxScrollback:Ll,onOpenTranscript:Zn,onReload:Jr,onClose:f}),p.jsx("div",{className:"xterm-container",ref:Q}),en?p.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:p.jsx("span",{"aria-hidden":"true"})}):null,D&&!Ki&&gi?p.jsxs("div",{className:"terminal-scroll-progress","data-active":Hi,"aria-hidden":"true",children:[gi.current,"/",gi.total]}):D&&!Ki&&$r?p.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":$r.alternate?"alternate":"normal","aria-hidden":"true",children:[$r.alternate?"alt ":"","0/?"]}):null,Cl||Ki&&Ar?p.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),onClick:S=>{S.stopPropagation(),ff()},children:"↓"}):null,Vr&&!Ki?p.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Aa,onPointerMove:pf,children:p.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?kl?p.jsx(OA,{ctrlActive:Lr,onCtrl:bf,onStandaloneKey:Oa,onPreserveFocus:()=>Br("input-action"),onHide:()=>vo(!1)}):p.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:S=>{S.stopPropagation(),Br("input-action")},onPointerDown:S=>{S.stopPropagation(),Br("input-action")},onClick:()=>vo(!0),children:"⌨"}):null,p.jsx(aL,{terminalId:e.id,onSubmit:zu,queueAvailable:Or==="codex"||Mx(e.currentCommand),disabled:e.status!=="running"}),p.jsx(q3,{toast:po,onSendNow:()=>{Ol()},onSkipOnce:gf,onTurnOff:wo,onDismiss:()=>Ta(null)}),vr&&St?p.jsx($3,{terminalId:e.id,serverApi:t,source:St,fontSize:x,onClose:vf,onReloadLatest:_f}):null,Ui?p.jsx(F3,{notice:Ui}):null,mo?p.jsx(K3,{status:ri,busy:Os,error:Bs,onInstall:()=>{jl("install")},onUpdate:()=>{jl("update")},onOpen:kn,onRefresh:()=>{Qn({checkLatest:!0}).catch(S=>vn(eh(S)))},onClose:()=>Da(!1)}):null]})}function Iw(e){return FE(e)}async function Pw(e,t,n={}){const s=n.checkLatest===!0,o=n.force===!0||s,c=Date.now(),d=el.get(e);if(!o&&d?.status&&c-d.fetchedAt<=N3)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=>(gv(e,g),g)).catch(g=>{const f=el.get(e);throw f?.inflight===m&&(f.status?el.set(e,{status:f.status,fetchedAt:f.fetchedAt}):el.delete(e)),g}),el.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:s}),m}function gv(e,t){el.set(e,{status:t,fetchedAt:Date.now()})}function Qd(e,t){return`${e}:${t}`}function Ex(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function Hw(e){const t=$c.get(e);if(!t)return!1;try{return t.closed?($c.delete(e),!1):(t.focus(),!0)}catch{return $c.delete(e),!1}}function Hm(e,t){const n=window.open(t,Ex(e));if(!n)return null;$c.set(e,n);try{n.focus()}catch{}return n}function Uw(e,t,n){if(!e||Tx(e))return!1;try{return e.name=Ex(t),e.location.href=n,$c.set(t,e),e.focus(),!0}catch{return!1}}function L3(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 Tx(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Um(e){if(e)try{e.closed||e.close()}catch{}}function O3(e,t,n){const s=B3(e,t),o=Kw(s*Math.max(1,n),C3,x3);return{limit:Kw(Math.ceil(o/y3),S3,w3),maxLines:o}}function B3(e,t){const n=e?.clientHeight??0;if(n<=0)return _3;const s=Math.max(10,t*b3);return Math.max(1,Math.floor(n/s))}function Kw(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function j3(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Km(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function E_(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Jd(e,t){return e===null?t===null:t!==null&&E_(e,t)}function Dx(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 z3(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function I3(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 P3(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function eh(e){return e instanceof On||e instanceof Error?e.message:"Something went wrong."}function H3(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function U3({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:k,tmuxScrollbackSupported:x,tmuxScrollbackEnabled:w,onToggleCacheKeepAlive:D,onOpenCodeServer:O,onToggleTmuxScrollback:A,onOpenTranscript:z,onReload:$,onClose:K}){const Q=A1({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),F={cursor:n?"grab":"default",opacity:Q.isDragging?.5:void 0};return p.jsxs("header",{ref:Q.setNodeRef,className:"terminal-pane-header",style:F,"data-dragging":Q.isDragging,...Q.attributes,...Q.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(),O()},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 ${nu(s.provider)} transcript history`,"aria-label":`View ${nu(s.provider)} transcript history`,onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),z()},children:[p.jsx("span",{children:"View history"}),p.jsx("kbd",{children:o})]}):null,s?p.jsx(W3,{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,x&&e.status==="running"?p.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":w?"true":"false","aria-pressed":w,"aria-label":`Toggle tmux scrollback (${k})`,title:w?`Scroll input uses tmux scrollback (${k}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${k}).`,onPointerDown:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),A()},children:[w?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:k})]}):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(),$()},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(),K()},children:"x"}):null]})}function K3({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,k=e===null&&t,x=e?.updateAvailable===!0,w=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":w,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:w}),p.jsx("p",{children:k?"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."]}),k?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:o,disabled:t||f||!b,children:x?"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 F3({notice:e}){return p.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function W3({status:e,now:t,keepAliveEnabled:n,onToggle:s}){const o=Dx(e,t),c=z3(e,o),d=o===null?"?":I3(o),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 q3({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:s,onDismiss:o}){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:o,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 $3=Bi.memo(function({terminalId:t,serverApi:n,source:s,fontSize:o,onClose:c,onReloadLatest:d}){const m=v.useRef(null),g=v.useRef(0),f=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),k=v.useRef(""),x=v.useRef(null),w=v.useRef(null),[D,O]=v.useState([]),[A,z]=v.useState(!1),[$,K]=v.useState(""),[Q,F]=v.useState(-1),[q,be]=v.useState(!1),[Se,De]=v.useState(-1),[ie,G]=v.useState(null),[Z,W]=v.useState(null),[re,L]=v.useState(!1),[R,I]=v.useState(!0),[se,ye]=v.useState(!1),[M,U]=v.useState(null),[ae,_e]=v.useState(!1);v.useEffect(()=>{function ve(Ue){Ue.key==="Escape"&&(Ue.preventDefault(),Ue.stopPropagation(),c())}return document.addEventListener("keydown",ve,!0),()=>document.removeEventListener("keydown",ve,!0)},[c]),v.useEffect(()=>{g.current+=1;const ve=g.current;return f.current=!1,y.current=!0,b.current=null,x.current=null,w.current=null,O([]),W(null),L(!1),U(null),_e(!1),F(-1),De(-1),G(null),vt(null,"initial",ve),()=>{g.current===ve&&(g.current+=1)}},[n,A,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const ve=m.current;if(!ve)return;if(y.current){if(R||D.length===0)return;y.current=!1;const nt=()=>{ve.scrollTop=ve.scrollHeight};nt(),window.requestAnimationFrame?.(nt);return}const Ue=b.current;Ue!==null&&(b.current=null,ve.scrollTop+=ve.scrollHeight-Ue)},[D,R,A]);const Ne=nu(s.provider),xe=qw(D,A),Le=X3(xe),Ee=J3(Le),je=Ee.map(ve=>ve.key).join(""),Fe=ie?Ee.find(ve=>ve.key===ie)?.entryIndex??null:null,ee=$.trim().length>0,de=Q3(Le,$),he=de.length,Ae=he>0?Q>=0&&Q<he?Q:0:-1,ze=Ae>=0?de[Ae]?.entryIndex??null:null,Me=Ae>=0?de[Ae]??null:null,oe=ee?ze:Fe,ke=ee?ze===null?null:"search":Fe===null?null:"prompt",ge=xe?xe.split(`
|
|
36
|
-
`).length-1:0,Oe=Ee.length>0&&Se>=0&&Se<Ee.length?Se:Ee.length-1,Ve=ie??(Oe>=0?Ee[Oe]?.key??null:null),ot=ee?he>0?`${Ae+1}/${he} ${he===1?"match":"matches"} · ${ge} ${ge===1?"line":"lines"}`:`0 matches · ${ge} ${ge===1?"line":"lines"}`:Ee.length>0?`${Oe+1}/${Ee.length} prompts · ${ge} ${ge===1?"line":"lines"}`:`0 prompts · ${ge} ${ge===1?"line":"lines"}`;v.useEffect(()=>{const ve=$.trim().toLowerCase();F(Ue=>!ve||he===0?-1:k.current!==ve?0:Ue>=0&&Ue<he?Ue:0),k.current=ve},[$,he]),v.useEffect(()=>{if(ee){G(null);return}ie&&!Ee.some(ve=>ve.key===ie)&&G(null),De(ve=>{if(Ee.length===0)return w.current=null,-1;const Ue=w.current?Ee.findIndex(Ze=>Ze.key===w.current):-1,nt=Ue>=0?Ue:ve>=0&&ve<Ee.length?ve:Ee.length-1;return w.current=Ee[nt]?.key??null,nt})},[ie,ee,je]),v.useEffect(()=>{const ve=x.current;if(!ve||Ee.length===0)return;x.current=null;const Ue=ve.anchorKey?Ee.findIndex(Ze=>Ze.key===ve.anchorKey):-1,nt=Ue>0?Ue-1:0;Ye(nt)},[je]);async function vt(ve,Ue,nt=g.current){if(!f.current){f.current=!0,Ue==="initial"?I(!0):(ye(!0),b.current=m.current?.scrollHeight??null),U(null);try{await xt(ve,Ue,nt)}catch(Ze){if(g.current!==nt)return;U(Ze instanceof Error?Ze.message:"Failed to load transcript history.")}finally{g.current===nt&&(f.current=!1,I(!1),ye(!1))}}}async function xt(ve,Ue,nt){let Ze=ve,Et=0,ht=[];const Qt=Ue==="initial"&&s.provider!=="claude"?E3:k3;for(;g.current===nt;){const oi=await n.getTerminalTranscriptHistory(t,{...Ze?{cursor:Ze}:{},...O3(m.current,o,Ue==="initial"?g3:v3),includeTools:A});if(g.current!==nt)return;if(!oi.source){U("Transcript source is temporarily unavailable.");return}if(!E_(s,oi.source)){_e(!0),L(!1);return}const V=Ww(oi.output,s.provider,{includeTools:A}),Ke=jn(oi,Ue,ht,V);if(V&&(ht=[V,...ht],Ke))return;if(!oi.hasMore||!oi.cursor||Et>=Qt){ht.length>0&&O(rt=>Ue==="older"?[...ht,...rt]:ht);return}Ze=oi.cursor,Et+=1}}function jn(ve,Ue,nt,Ze=Ww(ve.output,s.provider,{includeTools:A})){if(W(ve.cursor),L(!!(ve.hasMore&&ve.cursor)),!Ze)return!1;const Et=[Ze,...nt];return qw(Et,A)?(O(ht=>Ue==="older"?[...Et,...ht]:Et),!0):!1}function ni(){const ve=m.current;ve&&(Vt(),!(ve.scrollTop>72||!re||!Z||f.current)&&vt(Z,"older"))}function mi(ve){he!==0&&F(Ue=>{const nt=Ae>=0?Ae:ve>0?-1:0;return((Ue>=0&&Ue<he?Ue:nt)+ve+he)%he})}function Ye(ve){const Ue=Ee[ve];Ue&&(w.current=Ue.key,De(ve),G(Ue.key))}async function ft(ve){if(Ee.length===0){ve<0&&re&&Z&&!f.current&&(x.current={anchorKey:null},await vt(Z,"older"));return}const nt=(Se>=0&&Se<Ee.length?Se:ve<0?Ee.length-1:-1)+ve;if(nt>=0&&nt<Ee.length){Ye(nt);return}ve<0&&nt<0&&re&&Z&&!f.current&&(x.current={anchorKey:Ee[0]?.key??null},await vt(Z,"older"))}function Vt(){if(ee)return;const ve=m.current;if(!ve)return;const nt=ve.getBoundingClientRect().top+Math.min(140,Math.max(48,ve.clientHeight*.28));let Ze=null;for(const Et of r5(ve)){const ht=s5(Et);if(ht!==null)if(Et.getBoundingClientRect().top<=nt)Ze=ht;else break}if(Ze!==null){const Et=Ee[Ze]?.key??null;w.current=Et,De(Ze),ie&&ie!==Et&&G(null)}}return p.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ve=>ve.stopPropagation(),onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>{ve.stopPropagation(),c()},children:p.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ve=>ve.stopPropagation(),onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>ve.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:[Ne," 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:A,onChange:ve=>z(ve.currentTarget.checked)}),"Show tool output"]}),p.jsx("label",{className:"transcript-search",children:p.jsx("input",{type:"search",value:$,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ve=>K(ve.currentTarget.value),onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),ee?mi(ve.shiftKey?-1:1):ft(ve.shiftKey?-1:1))}})}),p.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":q,"aria-label":"Toggle prompt list",onClick:()=>be(ve=>!ve),disabled:Ee.length===0,children:"List"}),p.jsxs("div",{className:"transcript-search-actions","aria-label":ee?"Search result navigation":"Prompt navigation",children:[p.jsx("button",{type:"button",onClick:()=>ee?mi(-1):void ft(-1),disabled:ee?he===0:Ee.length===0&&!re,"aria-label":ee?"Previous search match":"Previous user prompt",title:ee?"Previous search match":"Previous user prompt",children:"Prev"}),p.jsx("button",{type:"button",onClick:()=>ee?mi(1):void ft(1),disabled:ee?he===0:Ee.length===0,"aria-label":ee?"Next search match":"Next user prompt",title:ee?"Next search match":"Next user prompt",children:"Next"})]}),p.jsx("span",{className:"transcript-result-count",children:ot})]}),q?p.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ee.length>0?Ee.map((ve,Ue)=>p.jsxs("button",{type:"button",className:Ve===ve.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>Ye(Ue),children:[p.jsx("span",{children:ve.timestampLabel}),p.jsx("strong",{children:ve.snippet})]},`${ve.key}:${Ue}`)):p.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,p.jsxs("div",{ref:m,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:ni,children:[se?p.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&re?p.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,xe?p.jsx(V3,{entries:Le,searchQuery:$,activeEntryIndex:oe,activeEntryMode:ke,activeSearchMatch:Me,fontSize:o}):null,R?p.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,ae?p.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",p.jsx("button",{type:"button",onClick:()=>{d()},children:"Load current session"})]}):null,!ae&&!R&&!xe&&!M?re&&Z?p.jsxs("div",{className:"transcript-dialog-status",children:[A?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",p.jsx("button",{type:"button",onClick:()=>{vt(Z,"older")},disabled:se,children:"Search earlier entries"})]}):p.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,M?p.jsx("div",{className:"transcript-dialog-error",children:M}):null]})]})})});function V3({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:o,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");((o?.entryIndex===n?f[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,s,o,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:k=>{k?d.current.set(f,k):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:Rx(g.header,t)}):null,g.body?p.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?p.jsx(Fw,{text:g.body,searchQuery:t}):p.jsx(Bi.Suspense,{fallback:p.jsx(Fw,{text:g.body,searchQuery:t}),children:p.jsx(A3,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function Fw({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
37
|
-
`)?e.slice(0,-1).split(`
|
|
38
|
-
`):e.split(`
|
|
39
|
-
`);return p.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,o)=>p.jsx("span",{className:`transcript-line transcript-line-${a5(s,o===0||n[o-1]?.trim()==="")}`,children:Rx(s,t)},o))})}function Rx(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),o=n.toLowerCase(),c=[];let d=0,m=s.indexOf(o);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(o,d)}return d<e.length&&c.push(e.slice(d)),c.length>0?c:e||" "}function Y3(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const s=e.toLowerCase();let o=0,c=s.indexOf(n);for(;c!==-1;)o+=1,c=s.indexOf(n,c+n.length);return o}function X3(e){const t=e.endsWith(`
|
|
40
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,o="plain",c=[];function d(){const m=G3(c).join(`
|
|
41
|
-
`);(s||m)&&n.push({header:s,body:m,kind:o}),s=null,o="plain",c=[]}for(const m of t.split(`
|
|
42
|
-
`)){const g=Z3(m);g?(d(),s=m,o=g):c.push(m)}return d(),n}function G3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function Z3(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 Q3(e,t){const n=[];for(let s=0;s<e.length;s+=1){const o=e[s];if(!o)continue;const c=o.header?`${o.header}
|
|
43
|
-
${o.body}`:o.body,d=Y3(c,t);for(let m=0;m<d;m+=1)n.push({entryIndex:s,matchIndexInEntry:m})}return n}function J3(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:e5(c),entry:c,entryIndex:o})}const n=new Map,s=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const d=n.get(c.contentKey)??0;n.set(c.contentKey,d+1),s.set(o,JSON.stringify([c.contentKey,d]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:s.get(c)??JSON.stringify([o.contentKey,0]),snippet:i5(o.entry.body),timestampLabel:n5(o.entry.header)}))}function e5(e){return JSON.stringify([e.header??"",e.body.length,t5(e.body)])}function t5(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 i5(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function n5(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function r5(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function s5(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 a5(e,t){const n=e.trim();if(!n)return"blank";const s=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(s)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(o||t)&&/^System$/.test(s)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||Ox(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 o5(e){return e.includes("\r")||e.includes(`
|
|
44
|
-
`)}function Fm(e){return e instanceof On&&e.status===404}function jc(e){return Mx(e)||Nx(e)}function Mx(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function Nx(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function l5(e){if(jc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function nu(e){return e==="codex"?"Codex":"Claude"}function Ww(e,t,n={}){const s=`[nterminal] ${nu(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
45
|
-
`).replace(/\r/g,`
|
|
46
|
-
`).replace(s,"").replace(/\n{3,}/g,`
|
|
47
|
-
|
|
48
|
-
`).trimEnd(),c=Ax(o),d=n.includeTools?c:Lx(c);return d?`${d}
|
|
49
|
-
`:""}function Ax(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=c5(n);return s?`[${s}]`:t})}function c5(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=Ec(t.getMonth()+1),o=Ec(t.getDate()),c=Ec(t.getHours()),d=Ec(t.getMinutes()),m=Ec(t.getSeconds());return`${n}-${s}-${o} ${c}:${d}:${m}`}function Ec(e){return e.toString().padStart(2,"0")}function qw(e,t){return e.map(n=>t?n:Lx(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
50
|
-
`)?n:`${n}
|
|
51
|
-
`).join("")}function Lx(e){if(!e)return"";const t=e.split(`
|
|
52
|
-
`),n=[];let s=!1,o=!1,c=!0;for(const d of t){const m=d.trim()==="",g=c?u5(d):null;if(g&&(s=g==="tool",o=!1),Ox(d)){o=!0,c=!1;continue}if(o){m?(o=!1,s||n.push(d),c=!0):c=!1;continue}s||n.push(d),c=m}return n.join(`
|
|
53
|
-
`).replace(/\n{3,}/g,`
|
|
54
|
-
|
|
55
|
-
`).trimEnd()}function u5(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function Ox(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function d5(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 th(e){const t=[];for(const n of e){const s=Bx(n);s&&t.push(s)}return t}function Bx(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const o=n.split(";").filter(Boolean).filter(c=>!p3.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${s}`:""})}function Wm(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function h5(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 $w(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 Yn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function ih(e,t){return!t||Yn(e)}function Vw(e){return Yn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function f5(e,t,n,s,o,c,d,m){const g=f=>{const y=m5(f);if(y!==0){if(d()){if(_5(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),m(y);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),p5(t,y,n,s,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function p5(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(mv,d);return}d()}function m5(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 g5(e,t,n,s,o,c,d,m,g){let f=null,y=0;const b={passive:!1};function k(D){f=qm(D),y=0}function x(D){const O=qm(D);if(O===null){f=null,y=0;return}if(f===null){f=O;return}const A=O.clientY-f.clientY;if(f=O,D.cancelable&&D.preventDefault(),A===0)return;if(v5(t)&&b5(t,O,-A)){y=0;return}y-=A/n();const z=y<0?Math.ceil(y):Math.floor(y);if(z!==0){if(y-=z,m()){g(z);return}c();try{t.scrollLines(z)}finally{d()}s(),z<0&&t.buffer.active.viewportY<=3&&o(z)}}function w(D){if(D.touches.length>0){f=qm(D);return}f=null,y=0}return e.addEventListener("touchstart",k,b),e.addEventListener("touchmove",x,b),e.addEventListener("touchend",w),e.addEventListener("touchcancel",w),()=>{e.removeEventListener("touchstart",k,b),e.removeEventListener("touchmove",x,b),e.removeEventListener("touchend",w),e.removeEventListener("touchcancel",w)}}function qm(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function v5(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function _5(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function b5(e,t,n){const s=e.element;return s?(s.dispatchEvent(y5(t,n)),!0):!1}function y5(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 vv({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:k=[],totalPanes:x,onSelect:w,onClose:D,onResize:O,onExit:A,onSnapshot:z,onCloseEditor:$,onAuthClose:K}){const Q=x??_v(e);if(k.length===0&&b){const Se=bv(e),De=Se.some(ie=>ie.key===b)?b:Se[0]?.key;if(Se.length>1&&De)return p.jsx("div",{className:"mobile-focused-split",children:Se.map(ie=>{const G=ie.key===De;if(ie.type==="editor"){const W=n[ie.editorId];return p.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,children:W?p.jsx(C0,{api:s,editor:W,canClose:Q>1,onClose:()=>$(ie.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ie.key)}const Z=t[ie.terminalId];return Z?p.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,children:p.jsx(zw,{terminal:Z,serverApi:s,active:G,visible:c&&G,canClose:Q>1,refreshCwdOnEnter:d&&G,tabId:m,codeServerContext:g,onSelect:()=>w(ie.terminalId),onClose:()=>D(ie.terminalId),onExit:W=>A(ie.terminalId,W),onSnapshot:z,...K?{onAuthClose:K}:{}})},ie.key):p.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,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 De=p.jsx(zw,{terminal:Se,serverApi:s,active:e.terminalId===o,visible:c,canClose:Q>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>w(e.terminalId),onClose:()=>D(e.terminalId),onExit:G=>A(e.terminalId,G),onSnapshot:z,...K?{onAuthClose:K}:{}});return f&&y!==e.terminalId?p.jsxs("div",{className:"pane-drop-host",children:[De,p.jsx(nh,{terminalId:e.terminalId,side:"top"}),p.jsx(nh,{terminalId:e.terminalId,side:"right"}),p.jsx(nh,{terminalId:e.terminalId,side:"bottom"}),p.jsx(nh,{terminalId:e.terminalId,side:"left"})]}):De}if(e.type==="editor"){const Se=n[e.editorId];return Se?p.jsx(C0,{api:s,editor:Se,canClose:Q>1,onClose:()=>$(e.editorId)}):p.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const F=Math.max(.1,Math.min(.9,e.ratio)),q=1-F,be=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${F}fr) 1px minmax(0, ${q}fr)`}:{gridTemplateRows:`minmax(0, ${F}fr) 1px minmax(0, ${q}fr)`};return p.jsxs("div",{className:"split-pane","data-direction":e.direction,style:be,children:[p.jsx("div",{className:"split-cell",children:p.jsx(vv,{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:[...k,0],totalPanes:Q,onSelect:w,onClose:D,onResize:O,onExit:A,onSnapshot:z,onCloseEditor:$,...K?{onAuthClose:K}:{}})}),p.jsx(S5,{direction:e.direction,path:k,onResize:O}),p.jsx("div",{className:"split-cell",children:p.jsx(vv,{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:[...k,1],totalPanes:Q,onSelect:w,onClose:D,onResize:O,onExit:A,onSnapshot:z,onCloseEditor:$,...K?{onAuthClose:K}:{}})})]})}function nh({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=Vv({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 S5({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 _v(e){return e.type==="pane"||e.type==="editor"?1:_v(e.first)+_v(e.second)}function bv(e){return e.type==="pane"?[{key:w5(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:C5(e.editorId),type:"editor",editorId:e.editorId}]:[...bv(e.first),...bv(e.second)]}function w5(e){return`terminal:${e}`}function C5(e){return`editor:${e}`}const of="workspace-default",x5="NTerminal";function k5(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function E5(e,t){switch(t.type){case"workspace.hydrated":return yv(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return T5(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return N5(e,t.workspaceId);case"workspace.selected":return jx(e,t.workspaceId);case"workspace.renamed":return D5(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return R5(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return M5(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return zx(e,t.terminal);case"terminal.split":return A5(e,t.terminal,t.direction);case"terminal.updated":return F5(e,t.terminal);case"terminal.exited":return W5(e,t.terminalId,t.exitCode);case"terminal.closed":return Hx(e,t.terminalId);case"terminal.detached":return q5(e,t.terminalId,t.workspaceId);case"editor.split":return L5(e,t.editorId,t.title,t.direction);case"editor.closed":return $5(e,t.editorId);case"pane.selected":return U5(e,t.terminalId);case"pane.resized":return K5(e,t.path,t.ratio);case"tab.selected":return B5(e,t.tabId);case"tab.renamed":return H5(e,t.tabId,t.title);case"tab.reordered":return T_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return j5(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return Ix(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return Px(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return z5(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return O5(e);default:return e}}function T5(e,t){if(e.workspaces.some(s=>s.id===t.id))return jx(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Mr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function jx(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function D5(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 R5(e,t,n){const s=Mr(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 M5(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),P5(e.workspaces,y)?e:{...e,workspaces:y}}function N5(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?Ph(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 zx(e,t){const n=Kx(e),s=ho(n)??cf(),o=Vx(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??Mr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:$x(c,t.id))}}function A5(e,t,n){const s=ho(e),o=s?lf(s):void 0;if(!s||!o)return zx(e,t);const c=o.activeTerminalId,d=su(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??Mr(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)}:$x(m,t.id))}}function L5(e,t,n,s){const o=ho(e),c=o?lf(o):void 0;if(!o||!c)return e;const d=c.activeTerminalId,m=su(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 O5(e){const t=ho(e),n=t?lf(t):void 0;return n?Hx(e,n.activeTerminalId):e}function B5(e,t){const n=ho(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 T_(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),I5(o.tabs,f)?o:{...o,tabs:f}});return s.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:s}}function j5(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(w=>w.id===t);if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b=hl(y.root,n);if(!b){const w=g.tabs.filter((D,O)=>O!==f);return{...g,tabs:w}}const k={...y,root:b,activeTerminalId:ji(b)[0]??y.activeTerminalId},x=g.tabs.slice();return x[f]=k,{...g,tabs:x}});const d=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>ji(D.root).includes(s));if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b={type:"pane",terminalId:n},k={type:"split",direction:d,ratio:.5,first:m?b:{type:"pane",terminalId:s},second:m?{type:"pane",terminalId:s}:b},x=su(y.root,s,k),w=g.tabs.slice();return w[f]={...y,root:x,activeTerminalId:n},{...g,tabs:w,activeTabId:y.id}}),Kx({...e,workspaces:c})}function Ix(e,t,n,s){let o=-1,c=-1;for(let O=0;O<e.workspaces.length;O+=1){const A=e.workspaces[O].tabs.findIndex(z=>z.id===t);if(A>=0){o=O,c=A;break}}if(o<0)return e;const d=e.workspaces[o],m=d.tabs[c],g=ji(m.root);if(!g.includes(n))return e;if(g.length===1)return T_(e,t,s);const f=hl(m.root,n);if(!f)return e;const y={...m,root:f,activeTerminalId:ji(f)[0]??m.activeTerminalId},b=e.terminals[n],k={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},x=d.tabs.slice();x[c]=y;const w=Math.max(0,Math.min(x.length,s));x.splice(w,0,k);const D=e.workspaces.slice();return D[o]={...d,tabs:x,activeTabId:k.id},{...e,workspaces:D}}function Px(e,t,n,s=Number.MAX_SAFE_INTEGER){const o=Fx(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:T_(e,t,s);const d=ji(o.tab.root),m=d.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===o.workspace.id)return fo({...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??Mr(m?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(k=>!d.includes(k)),tabs:y,activeTabId:o.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:n}}function z5(e,t,n,s,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(x=>x.id===s),d=Fx(e.workspaces,t);if(!c||!d||!e.terminals[n]||!ji(d.tab.root).includes(n))return e;if(d.workspace.id===s)return Ix(e,t,n,o);if(ji(d.tab.root).length===1)return Px(e,t,s,o);const g=hl(d.tab.root,n);if(!g)return e;const f={...d.tab,root:g,activeTerminalId:ji(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}},k=e.workspaces.map(x=>{if(x.id===d.workspace.id)return fo({...x,tabs:x.tabs.map(w=>w.id===t?f:w)});if(x.id===s){const w=x.tabs.slice(),D=Math.max(0,Math.min(w.length,o));return w.splice(D,0,b),{...x,defaultCwd:x.defaultCwd??Mr(y.cwd),detachedTerminalIds:x.detachedTerminalIds.filter(O=>O!==n),tabs:w,activeTabId:b.id}}return x});return{...e,workspaces:k,activeWorkspaceId:s}}function I5(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 P5(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 H5(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 U5(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>fl(c.root,t))),s=n?.tabs.find(o=>fl(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 K5(e,t,n){const s=ho(e),o=s?lf(s):void 0;if(!s||!o)return e;const c=Ev(o.root,t,Gx(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 yv(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=>Yx(b))||t&&t.some(b=>Xx(b)));let g=V5(t,n,c,d);g.length===0&&(g=[cf()]);const f=typeof s=="string"&&g.some(b=>b.id===s)?s:g[0]?.id??null,y=f??g[0]?.id??of;for(const b of e)if(!d.has(b.id)){if(m)g=G5(g,y,b.id,b);else{const k=Vx(b);g=Q5(g,y,k,b)}d.add(b.id)}return{workspaces:g.map(b=>fo(Z5(b,o))),activeWorkspaceId:f,terminals:o}}function ru(e){return ji(e.root)}function Sv(e){return Tv(e.root)}function Ph(e){return D_([...e.tabs.flatMap(t=>ji(t.root)),...e.detachedTerminalIds])}function $m(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(o=>{const c=xv(o.root);return c?[{...o,root:c}]:[]});return fo({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function F5(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>fl(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function W5(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function Hx(e,t){const n={...e.terminals};return delete n[t],Ux(e,t,n)}function q5(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(c=>c.id===n)?n:null)??Y5(e,t)?.id??X5(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??of,o=e.workspaces.find(c=>c.id===s);return!o||!qx(o,t)?e:Ux(e,t,{...e.terminals},{detachToWorkspaceId:s})}function Ux(e,t,n,s={}){let o=e.workspaces.map(d=>{const m=[];for(const g of d.tabs){const f=hl(g.root,t);if(!f)continue;const y=ji(f),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:f,activeTerminalId:b})}return fo({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:m})});s.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===s.detachToWorkspaceId?Wx(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 $5(e,t){const n=e.workspaces.map(o=>{const c=[];for(const d of o.tabs){const m=wv(d.root,t);if(!m)continue;const g=ji(m),f=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];f&&c.push({...d,root:m,activeTerminalId:f})}return fo({...o,tabs:c})}),s=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function V5(e,t,n,s){if(t&&t.length>0){const o=[];for(const c of t)Yx(c)&&o.push(Yw(c,n,s));if(o.length>0)return o}return[Yw({...cf(),tabs:e??[]},n,s)]}function Yw(e,t,n){const s=[];for(const c of e.tabs){if(!Xx(c))continue;const d=Cv(c.root,t);if(!d)continue;const m=ji(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 fo({...e,defaultCwd:Mr(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function Kx(e){return ho(e)?e:{...e,workspaces:[cf()],activeWorkspaceId:of}}function ho(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function lf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function Fx(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 Y5(e,t){return e.workspaces.find(n=>n.tabs.some(s=>fl(s.root,t)))}function X5(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function G5(e,t,n,s){return e.map(o=>o.id===t?Wx(o,n,s):o)}function Wx(e,t,n){return qx(e,t)?{...e,defaultCwd:e.defaultCwd??Mr(n?.cwd),detachedTerminalIds:D_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function qx(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<gl}function $x(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function Z5(e,t){if(e.defaultCwd)return e;const n=Ph(e).find(o=>!!t[o]),s=n?Mr(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function cf(){return{id:of,title:x5,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function fo(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Mr(e.defaultCwd),detachedTerminalIds:D_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function Q5(e,t,n,s){const o=ji(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Mr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>!o.includes(d)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function Vx(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function su(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:su(e.first,t,n),second:su(e.second,t,n)}}function hl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=hl(e.first,t),s=hl(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function wv(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=wv(e.first,t),s=wv(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function Cv(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Cv(e.first,t),s=Cv(e.second,t);return n&&s?{...e,ratio:Gx(e.ratio),first:n,second:s}:n??s}function xv(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=xv(e.first),n=xv(e.second);return t&&n?{...e,first:t,second:n}:t??n}function Yx(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 Xx(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&kv(t.root)}function kv(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")&&kv(t.first)&&kv(t.second):!1}function Ev(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=Ev(e.first,o,n);return c===e.first?e:{...e,first:c}}if(s===1){const c=Ev(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function Gx(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Mr(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 fl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:fl(e.first,t)||fl(e.second,t)}function ji(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...ji(e.first),...ji(e.second)]}function Tv(e){return e.type==="pane"||e.type==="editor"?1:Tv(e.first)+Tv(e.second)}const ka=new Map,au=new Map,ou=new Map,lu=new Map,cu=new Map;function Sl(e){return e??"__local__"}function J5(e){return{agentId:e,state:k5(),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 Ut(e){const t=Sl(e);let n=ka.get(t);return n||(n=J5(e),ka.set(t,n)),n}function Zx(e,t){const n=Sl(e);let s=au.get(n);return s||(s=new Set,au.set(n,s)),s.add(t),()=>{s.delete(t)}}function eO(e){const t=Sl(e),n=au.get(t);if(n)for(const s of Array.from(n))s()}function wl(e,t){ka.set(Sl(e),t),eO(e)}const Dv=new Set;function tO(e){return Dv.add(e),()=>{Dv.delete(e)}}function Zo(e,t){const n=Ut(e),s=Sl(e);t.type==="workspace.hydrated"&&(ou.delete(s),lu.delete(s),cu.delete(s));const o=E5(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],y=cO(s),b=uO(s),k=nO(s);if(t.terminal.agentStatus){const x=t.terminal.agentStatus.state,w=t.terminal.agentStatus.sessionId,D=k.get(t.terminal.id),O=!!(f&&(f.currentCommand!==t.terminal.currentCommand||f.agentStatus?.provider!==t.terminal.agentStatus.provider||iO(D,w)));O&&(b.delete(t.terminal.id),y.delete(t.terminal.id),k.delete(t.terminal.id)),w&&k.set(t.terminal.id,w),t.notifyCompletion===!0&&(x==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):x==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!O&&(x==="done"||x==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(d=Zw(o,t.terminal.id,f?.currentCommand??null,x==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),x==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{f?.agentStatus&&(b.delete(t.terminal.id),k.delete(t.terminal.id));const x=f?.activity==="busy",w=t.terminal.activity==="busy",D=t.terminal.activity==="idle";t.notifyCompletion===!0&&w&&y.add(t.terminal.id),t.notifyCompletion===!0&&x&&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 x=Qx(o,t.terminal.id);x&&(x.workspace.activeTabId!==x.tab.id||x.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),k.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=rO(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(k=>k.id===t.workspaceId);f=b?.tabs.find(k=>k.id===b.activeTabId)??null}const y=f?ji(f.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const k of y)b.delete(k);c=b}}const m=o!==n.state,g=c!==n.unreadCompletions;if((m||g)&&wl(e,{...n,state:o,unreadCompletions:c}),g&&R_(),d)for(const f of Array.from(Dv))f({agentId:e,...d})}function iO(e,t){return e!==void 0&&t!==void 0&&e!==t}function nO(e){let t=cu.get(e);return t||(t=new Map,cu.set(e,t)),t}function Qx(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(ji(s.root).includes(t))return{workspace:n,tab:s};return null}function rO(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 Rv=new Set;function sO(e){return Rv.add(e),()=>{Rv.delete(e)}}function aO(){let e=0;for(const t of ka.values())e+=t.unreadCompletions.size;return e}function R_(){for(const e of Array.from(Rv))e()}function Xw(e,t){const n=Ut(e);if(!n.unreadCompletions.has(t))return;const s=new Set(n.unreadCompletions);s.delete(t),wl(e,{...n,unreadCompletions:s}),R_()}function Gw(e,t){const n=Ut(e);t!==n.state&&wl(e,{...n,state:t})}function Vm(e,t){const n=Ut(e),s=t(n.editors);s!==n.editors&&wl(e,{...n,editors:s})}function da(e,t,n){const s=Ut(e);s.loaded===t&&s.error===n||wl(e,{...s,loaded:t,error:n})}function Tc(e,t,n){const s=Ut(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||wl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n})}function oO(e){const t=Ut(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function lO(e){const t=Sl(e),n=ka.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1;ka.delete(t),au.delete(t),ou.delete(t),lu.delete(t),cu.delete(t),s&&R_()}function Ym(){for(const e of ka.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}ka.clear(),au.clear(),ou.clear(),lu.clear(),cu.clear()}function cO(e){let t=ou.get(e);return t||(t=new Set,ou.set(e,t)),t}function uO(e){let t=lu.get(e);return t||(t=new Set,lu.set(e,t)),t}function Zw(e,t,n,s){const o=Qx(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:s}:null}function Mv(e,t){let n=!1,s=!1,o=null,c=!1;for(const d of ru(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 M_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Nv(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function dO(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 hO({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:k,onRenameTab:x,activePaneAvailable:w}){const[D,O]=v.useState(null),[A,z]=v.useState(!1),[$,K]=v.useState(null),Q=v.useRef(null),F=e.findIndex(W=>W.id===t),q=F>=0?e[F]:e[0]??null,be=q?Mv(q,n):null,Se=q?Sv(q):0,De=q?Nv(q,n):"No tab";v.useEffect(()=>{Q.current?.focus(),Q.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!A)return;const W=re=>{re.key==="Escape"&&z(!1)};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[A]),v.useEffect(()=>{A&&e.length===0&&z(!1)},[A,e.length]);function ie(W,re){O({tabId:W,title:re})}function G(){if(!D)return;const W=D.title.trim();W&&x(D.tabId,W),O(null)}function Z(){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 - ${LD()}`,onClick:b,disabled:!w,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 - ${OD()}`,onClick:k,disabled:!w,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:De,onClick:()=>z(!0),disabled:e.length===0,children:[be?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":be.state,"aria-hidden":"true",title:M_(be)}):null,p.jsx("span",{children:De}),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((W,re)=>{const L=ru(W),R=Sv(W),I=Nv(W,n),se=W.id===t,ye=D?.tabId===W.id,M=Mv(W,n),U=s?.has(W.id)??!1;return p.jsxs(Bi.Fragment,{children:[p.jsx(Qw,{index:re}),p.jsx(fO,{tab:W,active:se,editing:ye,title:I,paneCount:R,terminalIds:L,canClose:e.length>1,editValue:ye?D.title:null,editInputRef:ye?Q:null,activity:M,unread:U,onSelect:()=>c(W.id),onBeginRename:()=>ie(W.id,I),onCloseAll:()=>g(L),onCommitRename:G,onCancelRename:()=>O(null),onRenameChange:ae=>O({tabId:W.id,title:ae})})]},W.id)}),p.jsx(Qw,{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(W=>p.jsx(mO,{terminal:W,onReattach:()=>f?.(W.id),onDelete:()=>K(W)},W.id))}):null]}),p.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:d,children:"+"}),w?Z():null]}),A?p.jsx(pO,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:D,editInputRef:Q,onClose:()=>z(!1),onSelectTab:W=>{c(W),z(!1)},onCreateTab:()=>{d(),z(!1)},onBeginRename:ie,onCloseTerminals:W=>{g(W),z(!1)},onCommitRename:G,onCancelRename:()=>O(null),onRenameChange:(W,re)=>O({tabId:W,title:re}),onReattachTerminal:W=>{f?.(W),z(!1)},onDeleteTerminal:W=>{K(W),z(!1)}}):null,$?p.jsx(gO,{terminal:$,onCancel:()=>K(null),onConfirm:()=>{y?.($.id),K(null)}}):null]})}function fO({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:k,onCommitRename:x,onCancelRename:w,onRenameChange:D}){const{attributes:O,listeners:A,setNodeRef:z,transform:$,isDragging:K}=A1({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),Q={transform:eg.Translate.toString($),opacity:K?.4:void 0,zIndex:K?2:void 0};return p.jsxs("div",{ref:z,className:"terminal-tab","data-active":t,"data-dragging":K,"data-unread":f?"true":void 0,style:Q,...O,...A,children:[g?p.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:M_(g)}):null,n&&m&&d!==null?p.jsxs("form",{className:"terminal-tab-editor",onSubmit:F=>{F.preventDefault(),x()},children:[p.jsx("input",{ref:m,"aria-label":`Rename ${s}`,value:d,onBlur:x,onChange:F=>D(F.target.value),onKeyDown:F=>{if(F.key==="Enter"){F.preventDefault(),x();return}F.key==="Escape"&&(F.preventDefault(),w())}}),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(),k()},children:"x"}):null]})}function pO({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:k,onCancelRename:x,onRenameChange:w,onReattachTerminal:D,onDeleteTerminal:O}){const A=v.useRef(null);return v.useEffect(()=>{A.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:z=>z.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((z,$)=>{const K=ru(z),Q=Sv(z),F=Nv(z,n),q=z.id===t,be=c?.tabId===z.id,Se=Mv(z,n),De=s?.has(z.id)??!1;return p.jsxs("div",{ref:q?A:null,className:"mobile-tab-sheet-row","data-active":q,"data-unread":De?"true":void 0,children:[be&&c?p.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),k()},children:p.jsx("input",{ref:d,"aria-label":`Rename ${F}`,value:c.title,onBlur:k,onChange:ie=>w(z.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),k();return}ie.key==="Escape"&&(ie.preventDefault(),x())}})}):p.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${F}`,onClick:()=>g(z.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:$+1}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:F}),p.jsx("small",{children:dO(z,n,Q,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:M_(Se)}):null,p.jsx("span",{children:Q})]})]}),p.jsxs("div",{className:"mobile-tab-sheet-actions",children:[be?p.jsx("button",{type:"button","aria-label":`Done renaming ${F}`,onClick:k,children:"Done"}):p.jsx("button",{type:"button","aria-label":`Rename ${F}`,onClick:()=>y(z.id,F),children:"Rename"}),e.length>1?p.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${F}`,onClick:()=>b(K),children:"×"}):null]})]},z.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(z=>{const $=z.title||z.cwd||z.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 ${$}`,onClick:()=>D(z.id),children:[p.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),p.jsxs("span",{className:"mobile-tab-sheet-copy",children:[p.jsx("strong",{children:$}),p.jsx("small",{children:z.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 ${$}`,onClick:()=>O(z),children:"×"})})]},z.id)})]}):null]})]})})}function Qw({index:e}){const{setNodeRef:t,isOver:n}=Vv({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 mO({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
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 gO({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 vO({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-${wO(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?gh(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(_O,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>o(g.id)},g.id))})]})}function _O({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":gh(e),children:[p.jsxs("div",{className:"upload-queue-item-header",children:[p.jsx("strong",{children:gh(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 ${gh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?p.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?p.jsx(bO,{toast:e}):null,c&&"message"in e&&e.message?p.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?p.jsx(yO,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?p.jsx("p",{children:e.message}):null]})}function bO({toast:e}){const t=e.percent===null?CO(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 yO({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(SO,{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 SO({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 gh(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 wO(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 CO(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function xO({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 kO=Ic(0,0,1,1),ys=1e-6;function EO(e){return Jx(e).map(t=>t.terminalId)}function Jx(e){return zc(e,kO).sort(MO).map((t,n)=>({...t,index:n+1}))}function TO(e,t,n){const s=Jx(e),o=s.find(d=>d.terminalId===t);return o?s.filter(d=>d.terminalId!==t).map(d=>RO(o,d,n)).filter(d=>d!==null).sort(NO)[0]?.entry.terminalId??null:null}function DO(e,t){return!Number.isInteger(t)||t<1?null:EO(e)[t-1]??null}function zc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=AO(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...zc(e.first,Ic(t.left,t.top,o,t.bottom)),...zc(e.second,Ic(o,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...zc(e.first,Ic(t.left,t.top,t.right,s)),...zc(e.second,Ic(t.left,s,t.right,t.bottom))]}function RO(e,t,n){const s=e.bounds,o=t.bounds,c=Jw(s.left,s.right,o.left,o.right),d=Jw(s.top,s.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=s.centerX-ys||d<=ys?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+ys||d<=ys?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-ys||c<=ys?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+ys||c<=ys?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};default:return null}}function MO(e,t){return rl(e.bounds.top,t.bounds.top)||rl(e.bounds.left,t.bounds.left)}function NO(e,t){return rl(e.primaryDistance,t.primaryDistance)||rl(e.perpendicularDistance,t.perpendicularDistance)||rl(t.overlap,e.overlap)||rl(e.entry.index,t.entry.index)}function rl(e,t){const n=e-t;return Math.abs(n)<=ys?0:n}function Jw(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Ic(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function AO(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class LO extends Error{constructor(t){super(t),this.name="UploadDropError"}}function e1(e){return e?Array.from(e.types??[]).includes("Files")||nk(e.items).some(n=>n.kind==="file")?!0:rk(e.files).length>0:!1}async function OO(e){const t=nk(e.items).filter(n=>n.kind==="file");return t.length>0?BO(t):jO(e.files)}async function BO(e){const t=[];for(const n of e){const s=HO(n);if(s){await ek(s,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:tk(o),file:o});continue}throw new LO("Folder upload is not supported by this browser.")}return t}function jO(e){return rk(e).map(t=>({relativePath:tk(t),file:t}))}async function ek(e,t,n){const s=KO(t,e.name);if(e.isFile){const d=await zO(e);n.push({relativePath:s,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),c=await IO(o);for(const d of c)await ek(d,s,n)}function zO(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function IO(e){const t=[];for(;;){const n=await PO(e);if(n.length===0)return t;t.push(...n)}}function PO(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function tk(e){const t=e.webkitRelativePath;return ik(typeof t=="string"&&t?t:e.name)}function HO(e){const t=e.webkitGetAsEntry?.();return UO(t)?t:null}function UO(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 KO(e,t){return ik(e?`${e}/${t}`:t)}function ik(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function nk(e){return e?Array.from(e):[]}function rk(e){return e?Array.from(e):[]}const t1="nterminal.terminalWorkspaces.v2",sk="nterminal.sidebarCollapsed.v1",FO=75,i1=B1.map(e=>e.url),WO=B1[0].url,qO=6;function $O({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??Kh(),[e]),f=v.useMemo(()=>t??ol(null),[t]),y=v.useMemo(()=>fB(n),[n]),b=v.useMemo(()=>C=>Zx(n,C),[n]),k=v.useMemo(()=>()=>Ut(n),[n]),x=v.useSyncExternalStore(b,k,k),w=x.state,D=x.editors,O=!x.loaded,A=x.error,[z,$]=v.useState(!1),[K,Q]=v.useState(()=>yB()),[F,q]=v.useState("servers"),[be,Se]=v.useState(!1),De=v.useSyncExternalStore(WD,_0,_0);v.useSyncExternalStore(kh,v0,v0);const[ie,G]=v.useState(0),[Z,W]=v.useState(null),[re,L]=v.useState(()=>[null]),[R,I]=v.useState(()=>({[Yi]:"Local"})),[se,ye]=v.useState(0),[M,U]=v.useState(()=>[n]),[ae,_e]=v.useState(()=>new Set),[Ne,xe]=v.useState({}),[Le,Ee]=v.useState(null),je=v.useRef(0),Fe=v.useRef(0),[ee,de]=v.useState(null),[he,Ae]=v.useState(null),ze=v.useRef(null),Me=v.useRef(0),oe=v.useRef(null),ke=v.useRef(null),ge=v.useRef(null),Oe=v.useRef(null),Ve=v.useRef(()=>{}),[ot,vt]=v.useState(null),xt=aT(XS(T1,{activationConstraint:{distance:8}}),XS(D1,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>qD(g),[g]);function jn(C){const T=C.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){vt({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&vt({tabId:T.sourceTabId,terminalId:T.terminalId})}}function ni(C){vt(null);const T=C.active.data.current,B=C.over?.data.current;if(!(!T||!B||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){pt({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){pt({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&pt({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){pt({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){pt({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&pt({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function mi(){vt(null)}const Ye=w.workspaces.find(C=>C.id===w.activeWorkspaceId)??w.workspaces[0],ft=Ye?.tabs.find(C=>C.id===Ye.activeTabId)??Ye?.tabs[0],Vt=ft?.activeTerminalId??null,ve=Vt?w.terminals[Vt]:void 0,Ue=oB("(max-width: 760px)"),nt=v.useMemo(()=>ft?Hh(ft.root):[],[ft]),Ze=Ye&&ft?Pc(n,Ye.id,ft.id):null,Et=ft?ak(nt,ft.activeTerminalId,Ze?Ne[Ze]:void 0):null,ht=Ue&&nt.length>1,Qt=v.useMemo(()=>(Ye?.detachedTerminalIds??[]).flatMap(C=>{const T=w.terminals[C];return T?[T]:[]}),[Ye?.detachedTerminalIds,w.terminals]),oi=v.useMemo(()=>{const C=new Set;for(const T of Ye?.tabs??[])ru(T).some(B=>x.unreadCompletions.has(B))&&C.add(T.id);return C},[Ye?.tabs,x.unreadCompletions]),[V,Ke]=v.useState([]),rt=v.useRef([]),st=v.useRef(null),[Rt,Lt]=v.useState(null),[jt,li]=v.useState(null),[qt,Ri]=v.useState([]),[$t,Jt]=v.useState(()=>so()),Ji=v.useRef(0),yi=v.useRef(n),ei=v.useRef(i1),Ii=v.useRef($t),Pi=v.useRef(()=>{});Pi.current=yr,Ve.current=wr;const en=v.useCallback(async()=>{try{const C=await g.listNotificationAssets();Ri(C.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Ri([])}},[g]),ln=v.useCallback(C=>{I(T=>{const B={...T};for(const te of C)B[Lv(te.agentId)]=te.label;return Xm(T,B)?T:B})},[]);v.useEffect(()=>{U(C=>C.some(T=>mn(T,n))?C:[...C,n])},[n]);const gi=v.useCallback(C=>{const T=Ut(C),B=ol(C);for(const te of Object.keys(T.state.terminals))Bc(B.createWebSocketUrl(te)),Gd(te);lO(C),U(te=>te.filter(fe=>!mn(fe,C))),_e(te=>{const fe=`${_h(C)}:`;let ce=!1;const Ce=new Set;for(const We of te){if(We.startsWith(fe)){ce=!0;continue}Ce.add(We)}return ce?Ce:te}),xe(te=>{const fe=`${_h(C)}:`;let ce=!1;const Ce={};for(const[We,lt]of Object.entries(te)){if(We.startsWith(fe)){ce=!0;continue}Ce[We]=lt}return ce?Ce:te})},[]);v.useEffect(()=>{let C=!1;return g.getMainInfo().then(T=>{if(C)return;const B=T.name?.trim()||"Local";I(te=>{const fe={...te,[Yi]:B};return Xm(te,fe)?te:fe})}).catch(()=>{}),g.listAgents().then(T=>{if(!C){const B=T.agents.map(fe=>fe.id),te=oD(T.serverOrder,T.agents);I(fe=>{const ce={[Yi]:fe[Yi]??"Local"};for(const Ce of T.agents)ce[Ce.id]=Ce.name;return Xm(fe,ce)?fe:ce}),n!==null&&!B.includes(n)&&(gi(n),s?.(null)),L(te)}}).catch(()=>{}),()=>{C=!0}},[n,g,gi,s,se]);const ci=v.useCallback(C=>{gi(C),ye(T=>T+1),mn(C,yi.current)&&s?.(null)},[gi,s]);v.useEffect(()=>{L(C=>C.some(T=>mn(T,n))?C:[...C,n])},[n]),v.useEffect(()=>{yi.current=n},[n]),v.useEffect(()=>{W(null)},[n]),v.useEffect(()=>{const C=oe.current;if(!C)return;if(!mn(C.agentId,n)){oe.current=null;return}if(!x.loaded||w.workspaces.length===0)return;oe.current=null;const T=C.edge==="first"?w.workspaces[0]:w.workspaces[w.workspaces.length-1];T&&T.id!==w.activeWorkspaceId&&pt({type:"workspace.selected",workspaceId:T.id})},[n,x.loaded,w.activeWorkspaceId,w.workspaces]),v.useEffect(()=>{const C=ke.current;if(C){if(!mn(C.agentId,n)){ke.current=null;return}x.loaded&&(ke.current=null,w.workspaces.some(T=>T.id===C.workspaceId)&&pt({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,x.loaded,w.workspaces]),v.useEffect(()=>{const C=ge.current;if(C){if(!mn(C.agentId,n)){ge.current=null;return}x.loaded&&(ge.current=null,x.error||Ms())}},[n,x.error,x.loaded]),v.useEffect(()=>{hn()},[n,x.loaded,w]),v.useEffect(()=>{const C=()=>{const te=cB();te&&Ve.current(te)},T=te=>{const fe=uB(te.data);fe&&Ve.current(fe)},B=te=>{const fe=Yh(te.detail);fe&&Ve.current(fe)};return C(),window.addEventListener("hashchange",C),window.addEventListener(ag,B),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(ag,B),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{en()},[en]),v.useEffect(()=>F1(()=>Jt(so())),[]),v.useEffect(()=>{const C=T=>{Pi.current(T)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{ei.current=qt.length>0?qt:i1},[qt]),v.useEffect(()=>{Ii.current=$t},[$t]),v.useEffect(()=>{if(!x.loaded||!Ye||!ft)return;const C=Pc(n,Ye.id,ft.id);_e(T=>{if(T.has(C))return T;const B=new Set(T);return B.add(C),B})},[n,x.loaded,Ye?.id,ft?.id]),v.useEffect(()=>()=>{Qr()},[]),v.useEffect(()=>{const C=Q2(g),T=tD(g);return()=>{C(),T()}},[g]),v.useEffect(()=>tO(C=>{const T=Ut(C.agentId).state,B=T.workspaces.flatMap(Ce=>Ce.tabs).find(Ce=>Ce.id===C.tabId),te=T.terminals[C.terminalId],fe=B?.title?.trim()||te?.title||C.commandName||"terminal",ce=document.visibilityState==="visible"&&mn(C.agentId,yi.current)&&C.tabId===hB(T);if(ce||$2({agentId:C.agentId,tabTitle:fe,commandName:C.commandName,terminalId:C.terminalId,outcome:C.outcome}),!ce&&document.visibilityState==="visible"&&Ii.current.enabled){const Ce=Ji.current+1;Ji.current=Ce;const We=ei.current;Lt({id:Ce,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:fe,commandName:C.commandName,outcome:C.outcome,assetSrc:We[Math.floor(Math.random()*We.length)]??WO})}}),[]),v.useEffect(()=>{if(!Rt||$t.persistUntilDismissed)return;const C=window.setTimeout(()=>{Lt(T=>T?.id===Rt.id?null:T)},$t.durationSeconds*1e3);return()=>window.clearTimeout(C)},[Rt,$t]),v.useEffect(()=>{SB(K),K&&Cn()},[K]),v.useEffect(()=>{let C=!1;async function T(){if(!Ut(n).loaded){da(n,!1,null);try{let te=null,fe=null;try{te=pB(y)}catch(lt){if(!(lt instanceof Uh))throw lt;fe=lt}const[ce,Ce]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),We=ce.terminals.length>0?ce.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!C){const lt=Ce.layout?lk(Ce.layout):null;if(!lt&&fe)throw fe;const ui=lt??te??{},_t=yv(We,void 0,ui.savedWorkspaces,ui.savedActiveWorkspaceId),xr=$m(_t);Gw(n,_t),Tc(n,Ce.revision,JSON.stringify(xr)),da(n,!0,null),!lt&&te&&Cr(xr,{baseRevision:Ce.revision})}}catch(te){!C&&!Ui(te)&&da(n,!0,ha(te))}}}return T(),()=>{C=!0}},[n,f,ie]);function Hi(){da(n,!1,null),G(C=>C+1)}function Cn(){je.current+=1,Fe.current+=1,Ee(null)}function $r(C){je.current+=1,Fe.current+=1,Ee(T=>T&&{...T,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Ms(){je.current+=1,Fe.current+=1;const C=w.workspaces.length+1,T=Vr();Ee({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&Nr(T)}function Cl(C){if(mn(C,n)){Ms();return}ge.current={agentId:C},s?.(C)}function Ns(C){if(K&&!z)return;const T=w.workspaces.find(te=>te.id===C);if(!T)return;je.current+=1,Fe.current+=1;const B=T.defaultCwd??ve?.cwd??"";Ee({mode:"edit",workspaceId:C,title:T.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Nr(B)}function Vr(){return Ye?.defaultCwd??ve?.cwd??""}async function Nr(C){const T=je.current+1;je.current=T;const B=C.trim();if(Ee(te=>te&&{...te,cwd:C,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const te=await f.createFileRoot({path:B}),fe=await f.listFiles({rootToken:te.rootToken,path:""});if(je.current!==T)return;Ee(ce=>ce&&{...ce,cwd:te.rootPath,browseRoot:{rootToken:te.rootToken,rootPath:te.rootPath},browseEntries:fe.entries.filter(Ce=>Ce.kind==="directory"),browseStatus:"idle",error:null})}catch(te){if(je.current!==T)return;Ee(fe=>fe&&{...fe,browseStatus:"idle",error:ha(te)})}}async function Ar(){const C=Le;if(!C)return;const T=C.title.trim(),B=C.cwd.trim();if(!T||!B){Ee({...C,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const te=Fe.current+1;Fe.current=te,Ee({...C,submitStatus:"submitting",error:null});try{const fe=await f.createFileRoot({path:B});if(Fe.current!==te)return;if(C.mode==="create"){const ce=w.workspaces.length+1;pt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ce}`,title:T,defaultCwd:fe.rootPath})}else C.workspaceId&&(pt({type:"workspace.renamed",workspaceId:C.workspaceId,title:T}),pt({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:fe.rootPath}));Ee(null)}catch(fe){if(Fe.current!==te)return;Ee(ce=>ce&&{...ce,submitStatus:"idle",error:ha(fe)})}}function cn(C){Fe.current+=1,Ee(C)}function Lr(C,T,B){if(C===T)return;const te=w.workspaces.some(ce=>ce.id===C),fe=w.workspaces.some(ce=>ce.id===T);!te||!fe||pt({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:T,placement:B})}function Gn(C,T){const B=w.workspaces.findIndex(fe=>fe.id===C),te=w.workspaces[B+T];B<0||!te||Lr(C,te.id,T<0?"before":"after")}function St(C,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),ze.current={sourceId:C,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function As(C){const T=ze.current;if(!T||T.pointerId!==C.pointerId)return;const B=Math.hypot(C.clientX-T.startX,C.clientY-T.startY);if(!T.active){if(B<qO)return;T.active=!0,de(T.sourceId)}const fe=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),ce=fe?.dataset.workspaceId??null;if(!fe||!ce||ce===T.sourceId||!w.workspaces.some(lt=>lt.id===ce)){T.targetId=null,Ae(null);return}const Ce=fe.getBoundingClientRect(),We=C.clientY<Ce.top+Ce.height/2?"before":"after";T.targetId=ce,T.placement=We,Ae({workspaceId:ce,placement:We})}function un(C){const T=ze.current;!T||T.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),ze.current=null,de(null),Ae(null),T.active&&T.targetId&&Lr(T.sourceId,T.targetId,T.placement))}function zn(C){const T=ze.current;T&&T.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),ze.current=null,de(null),Ae(null)}async function mr(){await vn(async()=>{const C=Ye?.defaultCwd?{cols:80,rows:24,cwd:Ye.defaultCwd}:{cols:80,rows:24},T=await f.createTerminal(C);pt({type:"terminal.created",terminal:T.terminal})})}async function gr(C){await vn(async()=>{const T=Vt?{parentTerminalId:Vt,cols:80,rows:24}:Ye?.defaultCwd?{cols:80,rows:24,cwd:Ye.defaultCwd}:{cols:80,rows:24},B=await f.createTerminal(T);pt({type:"terminal.split",terminal:B.terminal,direction:C})})}async function Ls(C){let T=Vt,B=Ze;const te=Ye?.defaultCwd?.trim();if(!T&&!te)throw new Error("No active pane is available.");const fe=await f.readFile(C);if(!T&&te){const We=await f.createTerminal({cols:80,rows:24,cwd:te});T=We.terminal.id,pt({type:"terminal.created",terminal:We.terminal})}if(T){pt({type:"pane.selected",terminalId:T});const We=Ut(n).state,lt=We.workspaces.find(_t=>_t.id===We.activeWorkspaceId)??We.workspaces[0],ui=lt?.tabs.find(_t=>_t.id===lt.activeTabId)??lt?.tabs[0];B=lt&&ui?Pc(n,lt.id,ui.id):null}const ce=`editor-${Date.now().toString(36)}-${oO(n)}`,Ce=bB(fe.path);Vm(n,We=>({...We,[ce]:{id:ce,title:Ce,rootToken:C.rootToken,path:fe.path,read:fe}})),B&&xe(We=>({...We,[B]:ok(ce)})),pt({type:"editor.split",editorId:ce,title:Ce,direction:"vertical"})}function po(C){Vm(n,T=>{const B={...T};return delete B[C],B}),pt({type:"editor.closed",editorId:C})}function Ta(C){vr([C])}function vr(C){const T=[...new Set(C)].filter(te=>w.terminals[te]);if(T.length===0)return;const B=T.length===1?w.terminals[T[0]]?.title||w.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;W(null),li({terminalIds:T,label:B,workspaceId:Ye?.id??w.activeWorkspaceId??null})}function _r(C,T){const B=Ki(C,T);if(!B)return!1;const te=C.filter(fe=>!B.detachedTerminalIds.includes(fe));if(B.detachedTerminalIds.length+te.length>gl)return W(gB(B.detachedTerminalIds.length)),!1;W(null);for(const fe of C)pt(B.id?{type:"terminal.detached",terminalId:fe,workspaceId:B.id}:{type:"terminal.detached",terminalId:fe});return!0}async function ri(C){await vn(async()=>{for(const T of C)await br(T),Bc(f.createWebSocketUrl(T)),Gd(T),pt({type:"terminal.closed",terminalId:T})})}async function Mi(C){const T=w.workspaces.find(B=>B.id===C);!T||w.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await vn(async()=>{const B=Ph(T),te=[];let fe=null;for(const Ce of B)try{await br(Ce)}catch(We){te.push(ha(We)),We instanceof On&&We.status===401&&!f.isAgent&&(fe=We)}finally{Bc(f.createWebSocketUrl(Ce)),Gd(Ce)}const ce=T.tabs.flatMap(Ce=>Av(Ce.root));if(ce.length>0){const Ce=new Set(ce);Vm(n,We=>{const lt={...We};for(const ui of Ce)delete lt[ui];return lt})}if(pt({type:"workspace.closed",workspaceId:C}),fe)throw fe;if(te.length>0)throw new Error(`Workspace was removed, but ${te.length} terminal session${te.length===1?"":"s"} may still be running. ${te[0]}`)})}async function mo(C){await vn(async()=>{await br(C),Bc(f.createWebSocketUrl(C)),Gd(C),pt({type:"terminal.closed",terminalId:C})})}async function Da(C,T){const B=T.trim();if(!B)return;let te=null;for(const fe of w.workspaces){const ce=fe.tabs.find(Ce=>Ce.id===C);if(ce){te=ce.activeTerminalId;break}}if(pt({type:"tab.renamed",tabId:C,title:B}),!!te)try{const fe=await f.renameTerminal(te,B);xn({type:"terminal.updated",terminal:fe.terminal})}catch(fe){da(n,!0,ha(fe))}}function Os(C){const T=w.terminals[C];T&&pt({type:"terminal.created",terminal:T})}async function br(C){try{await f.closeTerminal(C)}catch(T){if(T instanceof On&&T.status===404)return;throw T}}async function Bs(){await vn(async()=>{await d()})}async function vn(C){da(n,!0,null);try{await C()}catch(T){if(Ui(T))return;da(n,!0,ha(T))}}function Ui(C){return C instanceof On&&C.status===401&&!f.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function pt(C){Zo(n,C);const T=Ut(n),B=T.state;if(!T.loaded||B.workspaces.length===0)return;const te=$m(B);JSON.stringify(te)!==T.lastPersistedLayoutJson&&Na(te)}function xn(C){Zo(n,C)}function Yr(C,T,B,te){const fe=Pc(C,T,B);xe(ce=>({...ce,[fe]:te}))}function In(C){Ze&&xe(T=>({...T,[Ze]:C}))}function Or(C,T){const B=Vc(C);T?Yr(n,T.workspaceId,T.tabId,B):In(B),pt({type:"pane.selected",terminalId:C})}function Ra(C){In(C.key),C.type==="terminal"&&pt({type:"pane.selected",terminalId:C.terminalId})}function yr(C){if(be||jt||C.isComposing||C.key==="Process"||QO(C.target))return;const T=YO(C);if(!T)return;if(C.preventDefault(),C.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){Xr(T.type==="server.next"?1:-1);return}const B=Ut(n).state,te=B.workspaces.find(Ce=>Ce.id===B.activeWorkspaceId)??B.workspaces[0],fe=te?.tabs.find(Ce=>Ce.id===te.activeTabId)??te?.tabs[0];if(T.type==="split"){if(!fe)return;gr(T.direction);return}if(!te||!fe)return;if(T.type==="tab.previous"||T.type==="tab.next"){const Ce=ZO(te.tabs,fe.id,T.type==="tab.next"?1:-1);Ce&&pt({type:"tab.selected",tabId:Ce.id});return}if(T.type==="tab.index"){const Ce=te.tabs[T.index-1];Ce&&pt({type:"tab.selected",tabId:Ce.id});return}const ce=XO(fe.root,fe.activeTerminalId,T);ce&&Or(ce,{workspaceId:te.id,tabId:fe.id})}function go(C,T){if(!s||re.length===0)return;const B=re.findIndex(Ce=>mn(Ce,n)),fe=((B===-1?0:B)+C+re.length)%re.length,ce=re[fe]??null;mn(ce,n)||(T&&(oe.current={agentId:ce,edge:T}),s(ce))}function Xr(C){const T=Ut(n).state,B=T.workspaces;if(B.length===0){go(C,C===1?"first":"last");return}const te=B.findIndex(Ce=>Ce.id===T.activeWorkspaceId),ce=(te===-1?0:te)+C;if(ce>=0&&ce<B.length){pt({type:"workspace.selected",workspaceId:B[ce].id});return}go(C,C===1?"first":"last")}function xl(C,T){if(mn(C,n)){pt({type:"workspace.selected",workspaceId:T});return}ke.current={agentId:C,workspaceId:T},s?.(C)}function Ki(C,T){if(T)return w.workspaces.find(B=>B.id===T)??null;for(const B of C){const te=w.workspaces.find(ce=>ce.tabs.some(Ce=>ru(Ce).includes(B)));if(te)return te;const fe=w.workspaces.find(ce=>ce.detachedTerminalIds.includes(B));if(fe)return fe}return w.workspaces.find(B=>B.id===w.activeWorkspaceId)??w.workspaces[0]??null}function kl(C){e1(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function vo(C){if(!e1(C.dataTransfer))return;C.preventDefault();const T=vB(Ut(n).state),B=Me.current+1;if(Me.current=B,!T){Qn({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Qn({id:B,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Fi(B,T.id,C.dataTransfer)}async function Fi(C,T,B){try{const te=await OO(B);if(te.length===0)throw new Error("No files were found in the drop.");Yt(C,{id:C,status:"queued",fileCount:te.length,message:"Queued"},{terminalId:T,files:te})}catch(te){Yt(C,{id:C,status:"failed",fileCount:0,message:ha(te)},{terminalId:T})}finally{Zn()}}async function dn(C){const T=rt.current.find(ce=>ce.id===C);if(!T?.terminalId||!T.files||T.files.length===0)return;const B=T.terminalId,te=T.files,fe=new AbortController;st.current=C,Yt(C,{id:C,status:"uploading",fileCount:te.length,loaded:0,total:null,percent:null},{terminalId:B,files:te,abortController:fe});try{const ce=await rR({terminalId:B,files:te,signal:fe.signal,onProgress:ui=>{Yt(C,{id:C,status:"uploading",fileCount:te.length,loaded:ui.loaded,total:ui.total,percent:ui.percent},{terminalId:B,files:te,abortController:fe})}}),Ce=ce.failed>0?ce.uploaded>0?"partial":"failed":"success",We=ce.failed>0?_B(ce):void 0,lt={id:C,status:Ce,fileCount:te.length,response:ce};We&&(lt.message=We),Yt(C,lt,{terminalId:B,files:te})}catch(ce){Yt(C,{id:C,status:"failed",fileCount:te.length,message:fe.signal.aborted?"Upload canceled.":ha(ce)},{terminalId:B,files:te})}finally{st.current===C&&(st.current=null),Zn()}}function Zn(){if(st.current!==null)return;const C=rt.current.find(T=>T.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&dn(C.id)}function Qn(C){kn(T=>[...T,C])}function Yt(C,T,B={}){kn(te=>te.map(fe=>{if(fe.id!==C)return fe;const ce={...T},Ce=B.terminalId??fe.terminalId,We=B.files??fe.files;return Ce!==void 0&&(ce.terminalId=Ce),We!==void 0&&(ce.files=We),B.abortController!==void 0&&(ce.abortController=B.abortController),ce}))}function kn(C){const T=C(rt.current);rt.current=T,Ke(T)}function Ma(C){rt.current.find(B=>B.id===C)?.abortController?.abort(),st.current===C&&(st.current=null),kn(B=>B.filter(te=>te.id!==C)),Zn()}function Gr(){for(const C of rt.current)C.abortController?.abort();st.current=null,kn(()=>[])}function Zr(C){const T=rt.current.find(B=>B.id===C);if(T){if(T.status==="queued"){Ma(C);return}T.abortController?.abort()}}function Sr(C){const T=rt.current.find(te=>te.id===C);if(!T?.terminalId||!T.files||T.files.length===0)return;const B=En(T);if(B.length===0){Yt(C,{id:C,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Yt(C,{id:C,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:T.terminalId,files:B}),Zn()}function En(C){const T=C.files??[],B="response"in C?C.response:void 0;if(!B)return T;const te=B.results.filter(Ce=>Ce.status==="failed").map(Ce=>Ce.relativePath);if(te.length===0)return[];const fe=new Map;for(const Ce of T){const We=fe.get(Ce.relativePath)??[];We.push(Ce),fe.set(Ce.relativePath,We)}const ce=[];for(const Ce of te){const lt=fe.get(Ce)?.shift();lt&&ce.push(lt)}return ce}function js(C){const B=Ut(C.agentId).state.workspaces.find(te=>te.tabs.some(fe=>fe.id===C.tabId));B&&Yr(C.agentId,B.id,C.tabId,Vc(C.terminalId)),Zo(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),Xw(C.agentId,C.terminalId),mn(C.agentId,n)||s?.(C.agentId),Lt(null)}function wr(C){if(Oe.current=C,!mn(C.agentId,n)){s?s(C.agentId):Oe.current=null;return}hn()}function hn(){const C=Oe.current;if(!C||!mn(C.agentId,n)||!x.loaded)return;const T=Ut(C.agentId),B=dB(T.state,C.terminalId);Oe.current=null,B&&(Yr(C.agentId,B.workspaceId,B.tabId,Vc(C.terminalId)),Zo(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),Xw(C.agentId,C.terminalId))}function Na(C){const T=Ut(n).mutable.saveCoord;T.pendingLayoutSave=C,Dc(C,y),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const B=T.pendingLayoutSave;T.pendingLayoutSave=null,B&&Cr(B)},FO)}function Qr(){const C=Ut(n).mutable.saveCoord;C.saveTimer!==null&&(window.clearTimeout(C.saveTimer),C.saveTimer=null);const T=C.pendingLayoutSave;C.pendingLayoutSave=null,T&&(Dc(T,y),Cr(T))}function Cr(C,T={}){const B=Ut(n).mutable.saveCoord;B.nextPersistLayout=C,T.baseRevision!==void 0&&(B.queuedBaseRevision=T.baseRevision),!B.nextPersistQueued&&(B.nextPersistQueued=!0,B.persistChain=B.persistChain.then(async()=>{B.nextPersistQueued=!1;const te=B.nextPersistLayout,fe=B.queuedBaseRevision;B.nextPersistLayout=null,B.queuedBaseRevision=void 0,te&&await Jr(te,fe!==void 0?{baseRevision:fe}:{})}))}async function Jr(C,T={}){const B=Ut(n),te=T.baseRevision??B.layoutRevision,fe={layout:C,...typeof te=="number"?{baseRevision:te}:{}};try{const ce=await f.saveTerminalLayout(fe),Ce=ce.layout??C;Tc(n,ce.revision,JSON.stringify(Ce)),Dc(Ce,y);return}catch(ce){if(ce instanceof On&&ce.status===400&&ce.message===f2){mB(n,y),da(n,!0,ck());return}if(ce instanceof On&&ce.status===409)try{const Ce=await f.getTerminalLayout(),We=Ut(n).mutable.saveCoord;if(We.nextPersistLayout||We.pendingLayoutSave){const lt=Ce.layout?JSON.stringify(Ce.layout):Ut(n).lastPersistedLayoutJson;Tc(n,Ce.revision,lt);return}if(Ce.layout){const lt=Ut(n).state,ui=yv(Object.values(lt.terminals),void 0,Ce.layout.workspaces,Ce.layout.activeWorkspaceId),_t=$m(ui);Gw(n,ui),Tc(n,Ce.revision,JSON.stringify(_t)),Dc(_t,y)}else Tc(n,Ce.revision,B.lastPersistedLayoutJson);return}catch{}Dc(C,y)}}const zs=wB(o),Pn=!K||z,Si=Pn?F:"servers";function Jn(C){const T=C.active?x:Ut(C.agentId),B=C.active?w:T.state,te=C.active?x.loaded:T.loaded,fe=C.active?A:T.error;return p.jsxs("div",{className:`workspace-list-panel${C.active?" workspace-list-panel--active-server":""}`,"aria-label":`${C.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 ${C.label}`,title:"New workspace",onClick:()=>Cl(C.agentId),children:"+"})]}),te?fe?p.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(C.agentId),children:fe}):p.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(ce=>{const Ce=C.active&&ce.id===Ye?.id,We=Ph(ce).length,lt=C.active&&B.workspaces.length>1,ui=he?.workspaceId===ce.id&&ee!==ce.id?he.placement:null;return p.jsxs(nB,{workspaceId:ce.id,active:Ce,disabled:!C.active,reorderable:lt,dragging:ee===ce.id,dropPlacement:ui,children:[lt?p.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ce.id,title:"Drag to reorder","aria-label":`Reorder ${ce.title}`,"aria-grabbed":ee===ce.id,onPointerDown:_t=>St(ce.id,_t),onPointerMove:As,onPointerUp:un,onPointerCancel:zn,onKeyDown:_t=>{(_t.key==="ArrowUp"||_t.key==="ArrowDown")&&(_t.preventDefault(),_t.stopPropagation(),Gn(ce.id,_t.key==="ArrowUp"?-1:1))},onClick:_t=>_t.stopPropagation(),children:"::"}):null,p.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Ce?"page":void 0,title:ce.defaultCwd??void 0,onClick:()=>xl(C.agentId,ce.id),onDoubleClick:()=>{C.active&&Ns(ce.id)},children:[p.jsx("span",{className:"workspace-list-name",children:ce.title}),p.jsxs("small",{children:[ce.defaultCwd??"No folder"," · ",We," ",We===1?"session":"sessions"]})]}),C.active?p.jsxs("div",{className:"workspace-list-actions",children:[p.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ce.title}`,title:"Edit workspace",onClick:()=>Ns(ce.id),children:"..."}),p.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ce.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{Mi(ce.id)},children:"x"})]}):null]},ce.id)})}):p.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(C.agentId),children:"Open server to load workspaces"})]})}return p.jsx(a2,{sensors:xt,onDragStart:jn,onDragEnd:ni,onDragCancel:mi,children:p.jsxs("main",{className:"terminal-shell","data-collapsed":K,"data-sidebar-open":z,onDragOver:kl,onDrop:vo,children:[p.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>$(!1)}),p.jsxs("aside",{className:"workspace-sidebar",children:[p.jsxs("header",{className:"workspace-brand",children:[p.jsxs("div",{className:"workspace-brand-lockup",children:[Pn?p.jsx(h1,{height:20}):p.jsx(d1,{size:24}),c&&Pn?p.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),p.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":K?"Expand sidebar":"Collapse sidebar",title:K?"Expand sidebar":"Collapse sidebar",onClick:()=>Q(C=>!C),children:K?">":"<"}),p.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>$(!1),children:"x"})]}),p.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Si==="files"?"files":"servers"}`,children:[Pn?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:()=>{q("servers")},children:"Workspaces"}),p.jsx("button",{type:"button",role:"tab","aria-selected":F==="files",onClick:()=>{q("files")},children:"Files"})]}):null,Si==="servers"&&Pn?p.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:p.jsx(g0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:se,onServerLabelsChange:ln,renderServerChildren:Jn})}):null,Pn?null:p.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:p.jsx(g0,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:m,refreshToken:se,onServerLabelsChange:ln,compact:!0})}),Si==="files"?p.jsx(cR,{api:f,activeTerminalId:Vt,activeTerminalCwd:ve?.cwd??null,workspaceRootPath:Vt?null:Ye?.defaultCwd??null,onOpenFile:Ls},`${n??"local"}:${Ye?.id??"no-workspace"}`):null]}),p.jsxs("div",{className:"workspace-sidebar-footer",children:[Pn?p.jsx("span",{children:zs}):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(r1,{name:"settings"}),De.hasUpdates?p.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Pn?p.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{Bs()},children:p.jsx(r1,{name:"logout"})}):null]})]})]}),be?p.jsx(tR,{api:g,onClose:()=>Se(!1),updateAvailable:De.hasUpdates,onNotificationAssetsChanged:()=>{en()},onAgentRemoved:ci}):null,Le?p.jsx(JO,{dialog:Le,activePaneCwd:ve?.cwd??null,activeWorkspaceCwd:Ye?.defaultCwd??null,onChange:cn,onManualCwdChange:$r,onBrowse:Nr,onCancel:Cn,onSubmit:()=>{Ar()}}):null,p.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":ht?"true":void 0,children:[p.jsx(hO,{tabs:Ye?.tabs??[],activeTabId:Ye?.activeTabId??null,terminals:w.terminals,unreadCompletionTabIds:oi,detachedTerminals:Qt,onSelectTab:C=>pt({type:"tab.selected",tabId:C}),onCreateTab:()=>{mr()},onToggleWorkspaces:()=>$(C=>!C),onCloseTerminals:C=>vr(C),onReattachTerminal:C=>Os(C),onDeleteTerminal:C=>{mo(C)},onSplitVertical:()=>{gr("vertical")},onSplitHorizontal:()=>{gr("horizontal")},onRenameTab:(C,T)=>{Da(C,T)},activePaneAvailable:!!Vt}),ht?p.jsx(sB,{targets:nt,activeLeafKey:Et,terminals:w.terminals,editors:D,onSelect:Ra}):null,A?p.jsxs("div",{className:"workspace-error",role:"alert",children:[p.jsx("span",{children:A}),p.jsxs("div",{className:"workspace-error-actions",children:[p.jsx("button",{type:"button",onClick:Hi,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":O,children:[O?p.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!O&&!ft?p.jsx(iB,{onCreate:()=>{mr()}}):null,M.map(C=>{const T=mn(C,n);return p.jsx(VO,{agentId:C,serverName:R[Lv(C)]??(C===null?"Local":"Server"),active:T,activeServerApi:T?f:void 0,visitedTabKeys:ae,refreshCwdOnEnter:T,draggingTab:T?ot:null,mobileSplitFocus:Ue,mobileFocusedLeafByTabKey:Ne,onSelect:B=>{T&&Or(B)},onClose:B=>{T&&Ta(B)},onCloseEditor:B=>{T&&po(B)},onResize:(B,te)=>{T&&pt({type:"pane.resized",path:B,ratio:te})},onExit:(B,te)=>{T?xn({type:"terminal.exited",terminalId:B,exitCode:te}):Zo(C,{type:"terminal.exited",terminalId:B,exitCode:te})},onSnapshot:(B,te)=>{const fe={type:"terminal.updated",terminal:B,notifyCompletion:te?.notifyCompletion===!0};T?xn(fe):Zo(C,fe)},...m?{onAuthClose:B=>m({...B,source:B?.source??"terminal-ws-1008",activeAgentId:C})}:{}},_h(C))})]}),jt?p.jsx(rB,{label:jt.label,count:jt.terminalIds.length,warning:Z,onCancel:()=>{W(null),li(null)},onHide:()=>{_r(jt.terminalIds,jt.workspaceId)&&li(null)},onDelete:()=>{const C=jt.terminalIds;W(null),li(null),ri(C)}}):null,p.jsx(xO,{toast:Rt,onActivate:js,onDismiss:()=>Lt(null)}),p.jsx(vO,{uploads:V,onDismiss:Ma,onDismissAll:Gr,onRetry:Sr,onCancel:Zr})]})]})})}function VO({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:k,onExit:x,onSnapshot:w,onAuthClose:D}){const O=v.useMemo(()=>De=>Zx(e,De),[e]),A=v.useMemo(()=>()=>Ut(e),[e]),z=v.useSyncExternalStore(O,A,A),$=v.useMemo(()=>ol(e),[e]),K=s??$,Q=z.state,F=Q.workspaces.find(De=>De.id===Q.activeWorkspaceId)??Q.workspaces[0],q=F?.id??null,Se=(F?.tabs.find(De=>De.id===F.activeTabId)??F?.tabs[0])?.id??null;return!z.loaded||Q.workspaces.length===0?null:p.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:Q.workspaces.flatMap(De=>De.tabs.map(ie=>{const G=n&&De.id===q&&ie.id===Se,Z=Pc(e,De.id,ie.id),W=Hh(ie.root),re=m&&W.length>1?ak(W,ie.activeTerminalId,g[Z]):null;return!G&&!o.has(Z)?null:p.jsx("div",{className:"workspace-tab-surface","data-active":G,"aria-hidden":!G,children:p.jsx(vv,{node:ie.root,terminals:Q.terminals,editors:z.editors,api:K,activeTerminalId:ie.activeTerminalId,visible:G,refreshCwdOnEnter:G&&c,tabId:ie.id,codeServerContext:{serverKey:Lv(e),serverName:t,tabName:ie.title||Q.terminals[ie.activeTerminalId]?.title||"Terminal"},dropZoneActive:G&&d!==null,draggingTerminalId:G?d?.terminalId??null:null,mobileFocusLeafKey:re,onSelect:f,onClose:y,onCloseEditor:b,onResize:k,onExit:x,onSnapshot:w,...D?{onAuthClose:D}:{}})},`${De.id}:${ie.id}`)}))})}function YO(e){const t=oC(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=GO(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function XO(e,t,n){switch(n.type){case"pane.direction":return TO(e,t,n.direction);case"pane.index":return DO(e,n.index);default:return null}}function GO(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function ZO(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 Hh(e){return e.type==="pane"?[{key:Vc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:ok(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Hh(e.first),...Hh(e.second)]}function Av(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Av(e.first),...Av(e.second)]}function ak(e,t,n){if(n&&e.some(o=>o.key===n))return n;const s=t?Vc(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function Vc(e){return`terminal:${e}`}function ok(e){return`editor:${e}`}function QO(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 JO({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(x=>x.kind==="directory"),y=e.submitStatus==="submitting";function b(x){s(w=>w&&{...w,...x})}function k(x){x&&(b({cwd:x,error:null}),c(x))}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:x=>x.stopPropagation(),onSubmit:x=>{x.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:x=>b({title:x.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:x=>o(x.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:()=>k(t),disabled:y||!t,children:"Use active pane"}),p.jsx("button",{type:"button",onClick:()=>k(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(tB(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(x=>p.jsxs("button",{type:"button","aria-label":`Choose folder ${x.name}`,disabled:y,onClick:()=>{c(eB(g,x.path))},children:[p.jsx("span",{children:x.name}),p.jsx("small",{children:x.path})]},x.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 eB(e,t){return t?t.startsWith("/")?vh(t):vh(`${e||"/"}/${t}`):vh(e)}function tB(e){const t=vh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function vh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function iB({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 nB({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:c=null,children:d}){const{setNodeRef:m,isOver:g}=Vv({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 rB({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 sB({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(k=>k.key===t):-1,g=m>=0?m:0,f=e[g]??e[0],y=n1(f,n,s);function b(k){const x=(g+k+e.length)%e.length,w=e[x];w&&o(w)}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:k=>k.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((k,x)=>{const w=n1(k,n,s),D=aB(k,n,s),O=k.key===f.key;return p.jsxs("button",{type:"button","data-active":O,onClick:()=>{o(k),d(!1)},children:[p.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),p.jsxs("span",{className:"mobile-pane-sheet-copy",children:[p.jsx("strong",{children:w}),p.jsx("small",{children:D})]}),p.jsx("span",{className:"mobile-pane-sheet-type",children:k.type})]},k.key)})})]})}):null]})}function n1(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 aB(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 oB(e){const[t,n]=v.useState(()=>lB(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 lB(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function cB(){if(typeof window>"u")return null;const e=x2(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 uB(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Yh(t.focus)}function dB(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(ji(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function mn(e,t){return e===t}function hB(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 _h(e){return e??"__local__"}function Pc(e,t,n){return`${_h(e)}:${t}:${n}`}class Uh extends Error{constructor(){super(ck())}}function fB(e){return e?{workspaceKey:`${t1}:${e}`}:{workspaceKey:t1}}function pB(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(O1(n))throw new Uh;const s=L1(n);return s?lk(s):null}catch(n){if(n instanceof Uh)throw n;return null}}function lk(e){if(O1(e))throw new Uh;const t=L1(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Dc(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=Ut(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function gB(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${gl}. Re-open or delete hidden sessions before hiding more.`}function ck(){return`A saved terminal layout has more than ${gl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function vB(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 _B(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function bB(e){return e.split("/").filter(Boolean).pop()??e}function yB(){try{return localStorage.getItem(sk)==="true"}catch{return!1}}function SB(e){try{localStorage.setItem(sk,e?"true":"false")}catch{}}function Lv(e){return e??Yi}function Xm(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(o=>e[o]===t[o])}function wB(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 r1({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 ha(e){return e instanceof Error?e.message:"Request failed"}function CB({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),[k,x]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(O=>{D||(s(O.qrDataUrl),c(O.secret))}).catch(O=>{D||x(O instanceof Error?O.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function w(D){if(D.preventDefault(),!!o){f(!0),b(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(O){b(O instanceof Error?O.message:"Verification failed")}finally{f(!1)}}}return k?p.jsx("p",{className:"form-error",children:k}):!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:w,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 xB(e){return{source:Gm(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Gm(e.terminalId)}:{},...e?.detail?{detail:Gm(e.detail)}:{}}}function kB(e){return{invalidationSource:e.source}}function EB(e){yn("auth.session_invalid.request",uk(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Yv("session-invalid-request").catch(()=>{}))}function TB(e,t){yn("auth.session_invalid.result",{...uk(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Yv("session-invalid-result").catch(()=>{}))}function uk(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 Gm(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function DB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const o=v.useMemo(()=>e??Kh(),[e]),c=v.useMemo(()=>t??ol(null),[t]),[d,m]=v.useState(null),[g,f]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(z=>{A||(m(z),f(null))}).catch(z=>{A||(f(ro(z)),m(null))}),()=>{A=!0}},[o]);const k=AB(d);v.useEffect(()=>{const A=b.current;yn("auth.view",{view:k,previousView:A,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),A==="workspace"&&k!=="workspace"&&Yv(`auth-left-workspace-${k}`).catch(()=>{}),b.current=k},[d,k]);async function x(){const A=await o.getSession();m(A),f(null)}async function w(){Pm(),Ym(),ww(),f(null),m(null);try{await x()}catch(A){f(ro(A))}}function D(A){const z=xB(A);if(EB(z),y.current)return y.current;const $=(async()=>{f(null);try{const K=await o.getSession(kB(z));if(TB(z,K.authenticated),m(K),K.authenticated){UL();return}Pm(),Ym(),ww()}catch(K){f(ro(K))}finally{y.current=null}})();return y.current=$,$}if(k==="workspace")return p.jsx($O,{api:o,serverApi:c,activeAgentId:n,onSelectServer:s,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:A=>{D(A)},onLogout:async()=>{Pm(),Ym();const A=await o.logout();m(A)}});const O={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":k==="loading",children:[p.jsxs("header",{className:"auth-header",children:[p.jsxs("div",{className:"auth-brand",children:[p.jsx(d1,{size:26}),p.jsxs("div",{children:[p.jsx(h1,{height:17}),p.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),p.jsx("h1",{children:O[k]})]}),g?p.jsx("p",{className:"form-error",children:g}):null,k==="loading"?p.jsx("p",{className:"muted",children:"Checking session..."}):null,k==="loading"&&g?p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{w()},children:"Retry"}):null,k==="setup_password"?p.jsx(RB,{api:o,onSession:A=>{m(A)}}):null,k==="setup_totp"?p.jsx(CB,{api:o,onDone:()=>{x()}}):null,k==="login"?p.jsx(MB,{api:o,session:d,onSession:m,onRefresh:x}):null,k==="reauth"?p.jsx(NB,{api:o,session:d,onSession:m,onFullLogin:()=>m(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function RB({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(k){f(ro(k))}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 MB({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),[k,x]=v.useState(null),w=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function O(A){A.preventDefault(),b(!0),x(null);try{n(await e.login({password:o,...w?{otp:d}:{},rememberNetwork:g}))}catch(z){x(ro(z))}finally{b(!1)}}return p.jsxs("form",{className:"auth-form",onSubmit:O,children:[p.jsxs("label",{children:["Password",p.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),w?p.jsxs("label",{children:["Authenticator code",p.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:A=>m(A.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:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),k?p.jsx("p",{className:"form-error",children:k}):null,p.jsxs("div",{className:"button-row",children:[p.jsx("button",{type:"submit",disabled:y||o.length===0||w&&d.length!==6,children:"Unlock"}),p.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:y,children:"Refresh"})]})]})}function NB({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,k]=v.useState(!1),[x,w]=v.useState(!1),[D,O]=v.useState(null),A=Bi.useCallback(async($,K)=>{y(!0),O(null);try{n(await e.reauth({...$?{otp:$}:{},rememberNetwork:K}))}catch(Q){O(ro(Q))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let $=!1;k(!0),w(!1),O(null);const K=window.setTimeout(()=>{$||w(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(Q=>{$||n(Q)}).catch(Q=>{$||(O(ro(Q)),w(!0))}).finally(()=>{window.clearTimeout(K),$||k(!1)}),()=>{$=!0,window.clearTimeout(K)}}},[e,o,n]);async function z($){$.preventDefault(),await A(c,m)}return o&&b&&!x&&!D?p.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):p.jsxs("form",{className:"auth-form",onSubmit:z,children:[o&&x&&!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:$=>d($.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),p.jsxs("label",{className:"auth-checkbox",children:[p.jsx("input",{type:"checkbox",checked:m,onChange:$=>g($.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 AB(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ro(e){return e instanceof Error?e.message:"Request failed"}const s1="NTerminal",Ov="nterminal.activeAgentId";function LB(){const[e,t]=v.useState(()=>OB()),n=v.useMemo(()=>Kh(),[]),s=v.useMemo(()=>ol(e),[e]);v.useEffect(()=>{const c=()=>{const d=aO();document.title=d>0?`(${d}) ${s1}`:s1};return c(),sO(c)},[]);function o(c){BB(c),t(c)}return p.jsx(DB,{api:n,activeAgentId:e,serverApi:s,onSelectServer:o})}function OB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ov);return e&&e.trim()?e:null}catch{return null}}function BB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Ov,e);return}window.localStorage.removeItem(Ov)}catch{}}const a1=["gesturestart","gesturechange","gestureend"],jB=[".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(!PB(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||!IB(c.target))&&s(c)}for(const c of a1)n.addEventListener(c,s,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",s,t),()=>{for(const c of a1)n.removeEventListener(c,s,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",s,t)}}function IB(e){return e instanceof Element&&e.closest(jB)!==null}function PB(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}D2();PA();zB();Pv();HE.createRoot(document.getElementById("root")).render(p.jsx(Bi.StrictMode,{children:p.jsx(LB,{})}));export{Bi as R,NE as g,p as j};
|