nterminal 1.2.90 → 1.2.92
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/assets/brand/claude.webp +0 -0
- package/assets/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-DMOim4ku.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-Bkq8AHtC.js → TranscriptMarkdownBody-DZwdkUVR.js} +1 -1
- package/dist/client/assets/{index-BI8o0HfA.js → index-BV0uY07p.js} +1 -1
- package/dist/client/assets/index-D1CPRtOD.css +1 -0
- package/dist/client/assets/index-r59xBm5x.js +57 -0
- package/dist/client/brand/claude.webp +0 -0
- package/dist/client/brand/codex.webp +0 -0
- package/dist/client/index.html +2 -2
- package/dist/server/accounts/accountService.d.ts +70 -0
- package/dist/server/accounts/accountService.js +765 -0
- package/dist/server/accounts/accountService.js.map +1 -0
- package/dist/server/agent/agentRoutes.d.ts +2 -0
- package/dist/server/agent/agentRoutes.js +61 -0
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/http.d.ts +2 -1
- package/dist/server/http.js +6 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/accountRoutes.d.ts +9 -0
- package/dist/server/routes/accountRoutes.js +84 -0
- package/dist/server/routes/accountRoutes.js.map +1 -0
- package/dist/server/routes/agentManagementRoutes.js +35 -0
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/shared/protocol.d.ts +30 -0
- package/dist/shared/protocol.js.map +1 -1
- package/package.json +1 -1
- package/public/brand/claude.webp +0 -0
- package/public/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-4fzY6p-f.js +0 -1
- package/dist/client/assets/index-CiLqZsSA.css +0 -1
- package/dist/client/assets/index-Cr6EN3hl.js +0 -57
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-DMOim4ku.js","assets/index-BV0uY07p.js","assets/TranscriptMarkdownBody-DZwdkUVR.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"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).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 r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function r2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vm={exports:{}},Fc={};var W0;function a2(){if(W0)return Fc;W0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+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:r,key:u,ref:o!==void 0?o:null,props:c}}return Fc.Fragment=t,Fc.jsx=n,Fc.jsxs=n,Fc}var $0;function o2(){return $0||($0=1,Vm.exports=a2()),Vm.exports}var h=o2(),Ym={exports:{}},at={};var q0;function l2(){if(q0)return at;q0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function C(N){return N===null||typeof N!="object"?null:(N=w&&N[w]||N["@@iterator"],typeof N=="function"?N:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,B={};function A(N,W,ue){this.props=N,this.context=W,this.refs=B,this.updater=ue||S}A.prototype.isReactComponent={},A.prototype.setState=function(N,W){if(typeof N!="object"&&typeof N!="function"&&N!=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,N,W,"setState")},A.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function U(){}U.prototype=A.prototype;function Y(N,W,ue){this.props=N,this.context=W,this.refs=B,this.updater=ue||S}var K=Y.prototype=new U;K.constructor=Y,R(K,A.prototype),K.isPureReactComponent=!0;var se=Array.isArray;function Q(){}var z={H:null,A:null,T:null,S:null},_e=Object.prototype.hasOwnProperty;function ie(N,W,ue){var Ce=ue.ref;return{$$typeof:e,type:N,key:W,ref:Ce!==void 0?Ce:null,props:ue}}function ke(N,W){return ie(N.type,W,N.props)}function ne(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function X(N){var W={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(ue){return W[ue]})}var G=/\/+/g;function q(N,W){return typeof N=="object"&&N!==null&&N.key!=null?X(""+N.key):W.toString(36)}function oe(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(Q,Q):(N.status="pending",N.then(function(W){N.status==="pending"&&(N.status="fulfilled",N.value=W)},function(W){N.status==="pending"&&(N.status="rejected",N.reason=W)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function L(N,W,ue,Ce,Le){var Me=typeof N;(Me==="undefined"||Me==="boolean")&&(N=null);var Ne=!1;if(N===null)Ne=!0;else switch(Me){case"bigint":case"string":case"number":Ne=!0;break;case"object":switch(N.$$typeof){case e:case t:Ne=!0;break;case y:return Ne=N._init,L(Ne(N._payload),W,ue,Ce,Le)}}if(Ne)return Le=Le(N),Ne=Ce===""?"."+q(N,0):Ce,se(Le)?(ue="",Ne!=null&&(ue=Ne.replace(G,"$&/")+"/"),L(Le,W,ue,"",function(Ye){return Ye})):Le!=null&&(ne(Le)&&(Le=ke(Le,ue+(Le.key==null||N&&N.key===Le.key?"":(""+Le.key).replace(G,"$&/")+"/")+Ne)),W.push(Le)),1;Ne=0;var Oe=Ce===""?".":Ce+":";if(se(N))for(var Ve=0;Ve<N.length;Ve++)Ce=N[Ve],Me=Oe+q(Ce,Ve),Ne+=L(Ce,W,ue,Me,Le);else if(Ve=C(N),typeof Ve=="function")for(N=Ve.call(N),Ve=0;!(Ce=N.next()).done;)Ce=Ce.value,Me=Oe+q(Ce,Ve++),Ne+=L(Ce,W,ue,Me,Le);else if(Me==="object"){if(typeof N.then=="function")return L(oe(N),W,ue,Ce,Le);throw W=String(N),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return Ne}function M(N,W,ue){if(N==null)return N;var Ce=[],Le=0;return L(N,Ce,"","",function(Me){return W.call(ue,Me,Le++)}),Ce}function j(N){if(N._status===-1){var W=N._result;W=W(),W.then(function(ue){(N._status===0||N._status===-1)&&(N._status=1,N._result=ue)},function(ue){(N._status===0||N._status===-1)&&(N._status=2,N._result=ue)}),N._status===-1&&(N._status=0,N._result=W)}if(N._status===1)return N._result.default;throw N._result}var re=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},ye={map:M,forEach:function(N,W,ue){M(N,function(){W.apply(this,arguments)},ue)},count:function(N){var W=0;return M(N,function(){W++}),W},toArray:function(N){return M(N,function(W){return W})||[]},only:function(N){if(!ne(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return at.Activity=b,at.Children=ye,at.Component=A,at.Fragment=n,at.Profiler=o,at.PureComponent=Y,at.StrictMode=r,at.Suspense=g,at.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=z,at.__COMPILER_RUNTIME={__proto__:null,c:function(N){return z.H.useMemoCache(N)}},at.cache=function(N){return function(){return N.apply(null,arguments)}},at.cacheSignal=function(){return null},at.cloneElement=function(N,W,ue){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Ce=R({},N.props),Le=N.key;if(W!=null)for(Me in W.key!==void 0&&(Le=""+W.key),W)!_e.call(W,Me)||Me==="key"||Me==="__self"||Me==="__source"||Me==="ref"&&W.ref===void 0||(Ce[Me]=W[Me]);var Me=arguments.length-2;if(Me===1)Ce.children=ue;else if(1<Me){for(var Ne=Array(Me),Oe=0;Oe<Me;Oe++)Ne[Oe]=arguments[Oe+2];Ce.children=Ne}return ie(N.type,Le,Ce)},at.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:c,_context:N},N},at.createElement=function(N,W,ue){var Ce,Le={},Me=null;if(W!=null)for(Ce in W.key!==void 0&&(Me=""+W.key),W)_e.call(W,Ce)&&Ce!=="key"&&Ce!=="__self"&&Ce!=="__source"&&(Le[Ce]=W[Ce]);var Ne=arguments.length-2;if(Ne===1)Le.children=ue;else if(1<Ne){for(var Oe=Array(Ne),Ve=0;Ve<Ne;Ve++)Oe[Ve]=arguments[Ve+2];Le.children=Oe}if(N&&N.defaultProps)for(Ce in Ne=N.defaultProps,Ne)Le[Ce]===void 0&&(Le[Ce]=Ne[Ce]);return ie(N,Me,Le)},at.createRef=function(){return{current:null}},at.forwardRef=function(N){return{$$typeof:m,render:N}},at.isValidElement=ne,at.lazy=function(N){return{$$typeof:y,_payload:{_status:-1,_result:N},_init:j}},at.memo=function(N,W){return{$$typeof:p,type:N,compare:W===void 0?null:W}},at.startTransition=function(N){var W=z.T,ue={};z.T=ue;try{var Ce=N(),Le=z.S;Le!==null&&Le(ue,Ce),typeof Ce=="object"&&Ce!==null&&typeof Ce.then=="function"&&Ce.then(Q,re)}catch(Me){re(Me)}finally{W!==null&&ue.types!==null&&(W.types=ue.types),z.T=W}},at.unstable_useCacheRefresh=function(){return z.H.useCacheRefresh()},at.use=function(N){return z.H.use(N)},at.useActionState=function(N,W,ue){return z.H.useActionState(N,W,ue)},at.useCallback=function(N,W){return z.H.useCallback(N,W)},at.useContext=function(N){return z.H.useContext(N)},at.useDebugValue=function(){},at.useDeferredValue=function(N,W){return z.H.useDeferredValue(N,W)},at.useEffect=function(N,W){return z.H.useEffect(N,W)},at.useEffectEvent=function(N){return z.H.useEffectEvent(N)},at.useId=function(){return z.H.useId()},at.useImperativeHandle=function(N,W,ue){return z.H.useImperativeHandle(N,W,ue)},at.useInsertionEffect=function(N,W){return z.H.useInsertionEffect(N,W)},at.useLayoutEffect=function(N,W){return z.H.useLayoutEffect(N,W)},at.useMemo=function(N,W){return z.H.useMemo(N,W)},at.useOptimistic=function(N,W){return z.H.useOptimistic(N,W)},at.useReducer=function(N,W,ue){return z.H.useReducer(N,W,ue)},at.useRef=function(N){return z.H.useRef(N)},at.useState=function(N){return z.H.useState(N)},at.useSyncExternalStore=function(N,W,ue){return z.H.useSyncExternalStore(N,W,ue)},at.useTransition=function(){return z.H.useTransition()},at.version="19.2.6",at}var V0;function U_(){return V0||(V0=1,Ym.exports=l2()),Ym.exports}var v=U_();const Ni=r2(v);var Xm={exports:{}},Kc={},Gm={exports:{}},Zm={};var Y0;function c2(){return Y0||(Y0=1,(function(e){function t(L,M){var j=L.length;L.push(M);e:for(;0<j;){var re=j-1>>>1,ye=L[re];if(0<o(ye,M))L[re]=M,L[j]=ye,j=re;else break e}}function n(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var M=L[0],j=L.pop();if(j!==M){L[0]=j;e:for(var re=0,ye=L.length,N=ye>>>1;re<N;){var W=2*(re+1)-1,ue=L[W],Ce=W+1,Le=L[Ce];if(0>o(ue,j))Ce<ye&&0>o(Le,ue)?(L[re]=Le,L[Ce]=j,re=Ce):(L[re]=ue,L[W]=j,re=W);else if(Ce<ye&&0>o(Le,j))L[re]=Le,L[Ce]=j,re=Ce;else break e}}return M}function o(L,M){var j=L.sortIndex-M.sortIndex;return j!==0?j:L.id-M.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 u=Date,m=u.now();e.unstable_now=function(){return u.now()-m}}var g=[],p=[],y=1,b=null,w=3,C=!1,S=!1,R=!1,B=!1,A=typeof setTimeout=="function"?setTimeout:null,U=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function K(L){for(var M=n(p);M!==null;){if(M.callback===null)r(p);else if(M.startTime<=L)r(p),M.sortIndex=M.expirationTime,t(g,M);else break;M=n(p)}}function se(L){if(R=!1,K(L),!S)if(n(g)!==null)S=!0,Q||(Q=!0,X());else{var M=n(p);M!==null&&oe(se,M.startTime-L)}}var Q=!1,z=-1,_e=5,ie=-1;function ke(){return B?!0:!(e.unstable_now()-ie<_e)}function ne(){if(B=!1,Q){var L=e.unstable_now();ie=L;var M=!0;try{e:{S=!1,R&&(R=!1,U(z),z=-1),C=!0;var j=w;try{t:{for(K(L),b=n(g);b!==null&&!(b.expirationTime>L&&ke());){var re=b.callback;if(typeof re=="function"){b.callback=null,w=b.priorityLevel;var ye=re(b.expirationTime<=L);if(L=e.unstable_now(),typeof ye=="function"){b.callback=ye,K(L),M=!0;break t}b===n(g)&&r(g),K(L)}else r(g);b=n(g)}if(b!==null)M=!0;else{var N=n(p);N!==null&&oe(se,N.startTime-L),M=!1}}break e}finally{b=null,w=j,C=!1}M=void 0}}finally{M?X():Q=!1}}}var X;if(typeof Y=="function")X=function(){Y(ne)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,q=G.port2;G.port1.onmessage=ne,X=function(){q.postMessage(null)}}else X=function(){A(ne,0)};function oe(L,M){z=A(function(){L(e.unstable_now())},M)}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"):_e=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(L){switch(w){case 1:case 2:case 3:var M=3;break;default:M=w}var j=w;w=M;try{return L()}finally{w=j}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(L,M){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var j=w;w=L;try{return M()}finally{w=j}},e.unstable_scheduleCallback=function(L,M,j){var re=e.unstable_now();switch(typeof j=="object"&&j!==null?(j=j.delay,j=typeof j=="number"&&0<j?re+j:re):j=re,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=j+ye,L={id:y++,callback:M,priorityLevel:L,startTime:j,expirationTime:ye,sortIndex:-1},j>re?(L.sortIndex=j,t(p,L),n(g)===null&&L===n(p)&&(R?(U(z),z=-1):R=!0,oe(se,j-re))):(L.sortIndex=ye,t(g,L),S||C||(S=!0,Q||(Q=!0,X()))),L},e.unstable_shouldYield=ke,e.unstable_wrapCallback=function(L){var M=w;return function(){var j=w;w=M;try{return L.apply(this,arguments)}finally{w=j}}}})(Zm)),Zm}var X0;function u2(){return X0||(X0=1,Gm.exports=c2()),Gm.exports}var Qm={exports:{}},mn={};var G0;function d2(){if(G0)return mn;G0=1;var e=U_();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={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,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:y}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return mn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,mn.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return c(g,p,null,y)},mn.flushSync=function(g){var p=u.T,y=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=p,r.p=y,r.d.f()}},mn.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},mn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},mn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,C=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:C}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:C,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},mn.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=m(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},mn.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin);r.d.L(g,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},mn.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=m(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},mn.requestFormReset=function(g){r.d.r(g)},mn.unstable_batchedUpdates=function(g,p){return g(p)},mn.useFormState=function(g,p,y){return u.H.useFormState(g,p,y)},mn.useFormStatus=function(){return u.H.useHostTransitionStatus()},mn.version="19.2.6",mn}var Z0;function bC(){if(Z0)return Qm.exports;Z0=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(),Qm.exports=d2(),Qm.exports}var Q0;function h2(){if(Q0)return Kc;Q0=1;var e=u2(),t=U_(),n=bC();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" 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 s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function u(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,l=s;;){var d=a.return;if(d===null)break;var f=d.alternate;if(f===null){if(l=d.return,l!==null){a=l;continue}break}if(d.child===f.child){for(f=d.child;f;){if(f===a)return g(d),i;if(f===l)return g(d),s;f=f.sibling}throw Error(r(188))}if(a.return!==l.return)a=d,l=f;else{for(var _=!1,T=d.child;T;){if(T===a){_=!0,a=d,l=f;break}if(T===l){_=!0,l=d,a=f;break}T=T.sibling}if(!_){for(T=f.child;T;){if(T===a){_=!0,a=f,l=d;break}if(T===l){_=!0,l=f,a=d;break}T=T.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),_e=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ke=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function X(i){return i===null||typeof i!="object"?null:(i=ne&&i[ne]||i["@@iterator"],typeof i=="function"?i:null)}var G=Symbol.for("react.client.reference");function q(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===G?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case R:return"Fragment";case A:return"Profiler";case B:return"StrictMode";case se:return"Suspense";case Q:return"SuspenseList";case ie:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case S:return"Portal";case Y:return i.displayName||"Context";case U:return(i._context.displayName||"Context")+".Consumer";case K:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case z:return s=i.displayName||null,s!==null?s:q(i.type)||"Memo";case _e:s=i._payload,i=i._init;try{return q(i(s))}catch{}}return null}var oe=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j={pending:!1,data:null,method:null,action:null},re=[],ye=-1;function N(i){return{current:i}}function W(i){0>ye||(i.current=re[ye],re[ye]=null,ye--)}function ue(i,s){ye++,re[ye]=i.current,i.current=s}var Ce=N(null),Le=N(null),Me=N(null),Ne=N(null);function Oe(i,s){switch(ue(Me,s),ue(Le,i),ue(Ce,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?f0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=f0(s),i=p0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}W(Ce),ue(Ce,i)}function Ve(){W(Ce),W(Le),W(Me)}function Ye(i){i.memoizedState!==null&&ue(Ne,i);var s=Ce.current,a=p0(s,i.type);s!==a&&(ue(Le,i),ue(Ce,a))}function Be(i){Le.current===i&&(W(Ce),W(Le)),Ne.current===i&&(W(Ne),zc._currentValue=j)}var le,E;function V(i){if(le===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);le=s&&s[1]||"",E=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+le+i+E}var ge=!1;function Te(i,s){if(!i||ge)return"";ge=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var ve=function(){throw Error()};if(Object.defineProperty(ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ve,[])}catch(ce){var te=ce}Reflect.construct(i,[],ve)}else{try{ve.call()}catch(ce){te=ce}i.call(ve.prototype)}}else{try{throw Error()}catch(ce){te=ce}(ve=i())&&typeof ve.catch=="function"&&ve.catch(function(){})}}catch(ce){if(ce&&te&&typeof ce.stack=="string")return[ce.stack,te.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=l.DetermineComponentFrameRoot(),_=f[0],T=f[1];if(_&&T){var O=_.split(`
|
|
5
|
+
`),J=T.split(`
|
|
6
|
+
`);for(d=l=0;l<O.length&&!O[l].includes("DetermineComponentFrameRoot");)l++;for(;d<J.length&&!J[d].includes("DetermineComponentFrameRoot");)d++;if(l===O.length||d===J.length)for(l=O.length-1,d=J.length-1;1<=l&&0<=d&&O[l]!==J[d];)d--;for(;1<=l&&0<=d;l--,d--)if(O[l]!==J[d]){if(l!==1||d!==1)do if(l--,d--,0>d||O[l]!==J[d]){var fe=`
|
|
7
|
+
`+O[l].replace(" at new "," at ");return i.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",i.displayName)),fe}while(1<=l&&0<=d);break}}}finally{ge=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?V(a):""}function F(i,s){switch(i.tag){case 26:case 27:case 5:return V(i.type);case 16:return V("Lazy");case 13:return i.child!==s&&s!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return Te(i.type,!1);case 11:return Te(i.type.render,!1);case 1:return Te(i.type,!0);case 31:return V("Activity");default:return""}}function Se(i){try{var s="",a=null;do s+=F(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var xe=Object.prototype.hasOwnProperty,he=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,Ie=e.unstable_shouldYield,He=e.unstable_requestPaint,et=e.unstable_now,Mt=e.unstable_getCurrentPriorityLevel,pt=e.unstable_ImmediatePriority,kt=e.unstable_UserBlockingPriority,yt=e.unstable_NormalPriority,Qt=e.unstable_LowPriority,ci=e.unstable_IdlePriority,de=e.log,Ue=e.unstable_setDisableYieldValue,tt=null,Ge=null;function xt(i){if(typeof de=="function"&&Ue(i),Ge&&typeof Ge.setStrictMode=="function")try{Ge.setStrictMode(tt,i)}catch{}}var ot=Math.clz32?Math.clz32:ee,Hi=Math.log,_i=Math.LN2;function ee(i){return i>>>=0,i===0?32:31-(Hi(i)/_i|0)|0}var Pe=256,mt=262144,lt=4194304;function Dt(i){var s=i&42;if(s!==0)return s;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 Nt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var d=0,f=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var T=l&134217727;return T!==0?(l=T&~f,l!==0?d=Dt(l):(_&=T,_!==0?d=Dt(_):a||(a=T&~i,a!==0&&(d=Dt(a))))):(T=l&~f,T!==0?d=Dt(T):_!==0?d=Dt(_):a||(a=l&~i,a!==0&&(d=Dt(a)))),d===0?0:s!==0&&s!==d&&(s&f)===0&&(f=d&-d,a=s&-s,f>=a||f===32&&(a&4194048)!==0)?s:d}function Wt(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function ui(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+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 s+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 $t(){var i=lt;return lt<<=1,(lt&62914560)===0&&(lt=4194304),i}function zt(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function xi(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Lt(i,s,a,l,d,f){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 T=i.entanglements,O=i.expirationTimes,J=i.hiddenUpdates;for(a=_&~a;0<a;){var fe=31-ot(a),ve=1<<fe;T[fe]=0,O[fe]=-1;var te=J[fe];if(te!==null)for(J[fe]=null,fe=0;fe<te.length;fe++){var ce=te[fe];ce!==null&&(ce.lane&=-536870913)}a&=~ve}l!==0&&un(i,l,0),f!==0&&d===0&&i.tag!==0&&(i.suspendedLanes|=f&~(_&~s))}function un(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-ot(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function qt(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-ot(a),d=1<<l;d&s|i[l]&s&&(i[l]|=s),a&=~d}}function Ji(i,s){var a=s&-s;return a=(a&42)!==0?1:_n(a),(a&(i.suspendedLanes|s))!==0?0:a}function _n(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 dn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function si(){var i=M.p;return i!==0?i:(i=window.event,i===void 0?32:I0(i.type))}function en(i,s){var a=M.p;try{return M.p=i,s()}finally{M.p=a}}var bi=Math.random().toString(36).slice(2),ri="__reactFiber$"+bi,di="__reactProps$"+bi,bn="__reactContainer$"+bi,Hr="__reactEvents$"+bi,Yl="__reactListeners$"+bi,ir="__reactHandles$"+bi,Ur="__reactResources$"+bi,Yn="__reactMarker$"+bi;function qa(i){delete i[ri],delete i[di],delete i[Hr],delete i[Yl],delete i[ir]}function Xn(i){var s=i[ri];if(s)return s;for(var a=i.parentNode;a;){if(s=a[bn]||a[ri]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=S0(i);i!==null;){if(a=i[ri])return a;i=S0(i)}return s}i=a,a=i.parentNode}return null}function Ns(i){if(i=i[ri]||i[bn]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function Gn(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function As(i){var s=i[Ur];return s||(s=i[Ur]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Pt(i){i[Yn]=!0}var Va=new Set,Fr={};function Vt(i,s){Zn(i,s),Zn(i+"Capture",s)}function Zn(i,s){for(Fr[i]=s,i=0;i<s.length;i++)Va.add(s[i])}var yn=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]*$"),Kr={},Ya={};function gs(i){return xe.call(Ya,i)?!0:xe.call(Kr,i)?!1:yn.test(i)?Ya[i]=!0:(Kr[i]=!0,!1)}function Ls(i,s,a){if(gs(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function Wr(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function Sn(i,s,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(s,a,""+l)}}function Oi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Os(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Xa(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var d=l.get,f=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.call(this)},set:function(_){a=""+_,f.call(this,_)}}),Object.defineProperty(i,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function vs(i){if(!i._valueTracker){var s=Os(i)?"checked":"value";i._valueTracker=Xa(i,s,""+i[s])}}function hn(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Os(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function _s(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 Xl=/[\n"\\]/g;function ki(i){return i.replace(Xl,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function $r(i,s,a,l,d,f,_,T){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),s!=null?_==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Oi(s)):i.value!==""+Oi(s)&&(i.value=""+Oi(s)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),s!=null?qr(i,_,Oi(s)):a!=null?qr(i,_,Oi(a)):l!=null&&i.removeAttribute("value"),d==null&&f!=null&&(i.defaultChecked=!!f),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?i.name=""+Oi(T):i.removeAttribute("name")}function Dn(i,s,a,l,d,f,_,T){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(i.type=f),s!=null||a!=null){if(!(f!=="submit"&&f!=="reset"||s!=null)){vs(i);return}a=a!=null?""+Oi(a):"",s=s!=null?""+Oi(s):a,T||s===i.value||(i.value=s),i.defaultValue=s}l=l??d,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=T?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),vs(i)}function qr(i,s,a){s==="number"&&_s(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function nt(i,s,a,l){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Oi(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,l&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function nr(i,s,a){if(s!=null&&(s=""+Oi(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Oi(a):""}function sr(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(oe(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Oi(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),vs(i)}function tn(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var Uo=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 Vr(i,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":l?i.setProperty(s,a):typeof a!="number"||a===0||Uo.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function bs(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var d in s)l=s[d],s.hasOwnProperty(d)&&a[d]!==l&&Vr(i,d,l)}else for(var f in s)s.hasOwnProperty(f)&&Vr(i,f,s[f])}function rr(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 Fo=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"]]),Gl=/^[\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 ys(i){return Gl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Qn(){}var Ui=null;function Ga(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ss=null,ai=null;function Bs(i){var s=Ns(i);if(s&&(i=s.stateNode)){var a=i[di]||null;e:switch(i=s.stateNode,s.type){case"input":if($r(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+ki(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var d=l[di]||null;if(!d)throw Error(r(90));$r(l,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&hn(l)}break e;case"textarea":nr(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&nt(i,!!a.multiple,s,!1)}}}var fn=!1;function js(i,s,a){if(fn)return i(s,a);fn=!0;try{var l=i(s);return l}finally{if(fn=!1,(Ss!==null||ai!==null)&&(Xd(),Ss&&(s=Ss,i=ai,ai=Ss=null,Bs(s),i)))for(s=0;s<i.length;s++)Bs(i[s])}}function Rn(i,s){var a=i.stateNode;if(a===null)return null;var l=a[di]||null;if(l===null)return null;a=l[s];e:switch(s){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(r(231,s,typeof a));return a}var yi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yr=!1;if(yi)try{var ar={};Object.defineProperty(ar,"passive",{get:function(){Yr=!0}}),window.addEventListener("test",ar,ar),window.removeEventListener("test",ar,ar)}catch{Yr=!1}var Mn=null,Is=null,zs=null;function Xr(){if(zs)return zs;var i,s=Is,a=s.length,l,d="value"in Mn?Mn.value:Mn.textContent,f=d.length;for(i=0;i<a&&s[i]===d[i];i++);var _=a-i;for(l=1;l<=_&&s[a-l]===d[f-l];l++);return zs=d.slice(i,1<l?1-l:void 0)}function or(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function Ps(){return!0}function ws(){return!1}function Fi(i){function s(a,l,d,f,_){this._reactName=a,this._targetInst=d,this.type=l,this.nativeEvent=f,this.target=_,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(f):f[T]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?Ps:ws,this.isPropagationStopped=ws,this}return b(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ps)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ps)},persist:function(){},isPersistent:Ps}),s}var Jn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ki=Fi(Jn),es=b({},Jn,{view:0,detail:0}),Zl=Fi(es),Za,Qa,x,D=b({},es,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hs,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!==x&&(x&&i.type==="mousemove"?(Za=i.screenX-x.screenX,Qa=i.screenY-x.screenY):Qa=Za=0,x=i),Za)},movementY:function(i){return"movementY"in i?i.movementY:Qa}}),P=Fi(D),ae=b({},D,{dataTransfer:0}),we=Fi(ae),pe=b({},es,{relatedTarget:0}),Re=Fi(pe),Ze=b({},Jn,{animationName:0,elapsedTime:0,pseudoElement:0}),rt=Fi(Ze),Zt=b({},Jn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Wi=Fi(Zt),hi=b({},Jn,{data:0}),pn=Fi(hi),Ko={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ju={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"},ed={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function td(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=ed[i])?!!s[i]:!1}function Hs(){return td}var nn=b({},es,{key:function(i){if(i.key){var s=Ko[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=or(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Ju[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hs,charCode:function(i){return i.type==="keypress"?or(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?or(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Xf=Fi(nn),id=b({},D,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ql=Fi(id),nd=b({},es,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hs}),Gf=Fi(nd),sd=b({},Jn,{propertyName:0,elapsedTime:0,pseudoElement:0}),lr=Fi(sd),Jl=b({},D,{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}),Zf=Fi(Jl),Qf=b({},Jn,{newState:0,oldState:0}),Jf=Fi(Qf),ec=[9,13,27,32],Ja=yi&&"CompositionEvent"in window,cr=null;yi&&"documentMode"in document&&(cr=document.documentMode);var Wo=yi&&"TextEvent"in window&&!cr,tc=yi&&(!Ja||cr&&8<cr&&11>=cr),ic=" ",rd=!1;function nc(i,s){switch(i){case"keyup":return ec.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ad(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Gr=!1;function ep(i,s){switch(i){case"compositionend":return ad(s);case"keypress":return s.which!==32?null:(rd=!0,ic);case"textInput":return i=s.data,i===ic&&rd?null:i;default:return null}}function od(i,s){if(Gr)return i==="compositionend"||!Ja&&nc(i,s)?(i=Xr(),zs=Is=Mn=null,Gr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return tc&&s.locale!=="ko"?null:s.data;default:return null}}var sc={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 eo(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!sc[i.type]:s==="textarea"}function rc(i,s,a,l){Ss?ai?ai.push(l):ai=[l]:Ss=l,s=ih(s,"onChange"),0<s.length&&(a=new Ki("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var Zr=null,to=null;function ld(i){o0(i,0)}function io(i){var s=Gn(i);if(hn(s))return i}function ac(i,s){if(i==="change")return s}var cd=!1;if(yi){var $o;if(yi){var ts="oninput"in document;if(!ts){var ud=document.createElement("div");ud.setAttribute("oninput","return;"),ts=typeof ud.oninput=="function"}$o=ts}else $o=!1;cd=$o&&(!document.documentMode||9<document.documentMode)}function dd(){Zr&&(Zr.detachEvent("onpropertychange",oc),to=Zr=null)}function oc(i){if(i.propertyName==="value"&&io(to)){var s=[];rc(s,to,i,Ga(i)),js(ld,s)}}function tp(i,s,a){i==="focusin"?(dd(),Zr=s,to=a,Zr.attachEvent("onpropertychange",oc)):i==="focusout"&&dd()}function ip(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return io(to)}function ur(i,s){if(i==="click")return io(s)}function np(i,s){if(i==="input"||i==="change")return io(s)}function sp(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var wn=typeof Object.is=="function"?Object.is:sp;function Qr(i,s){if(wn(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var d=a[l];if(!xe.call(s,d)||!wn(i[d],s[d]))return!1}return!0}function Cs(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function hd(i,s){var a=Cs(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Cs(a)}}function fd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?fd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function pd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=_s(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=_s(i.document)}return s}function no(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var rp=yi&&"documentMode"in document&&11>=document.documentMode,dr=null,k=null,I=null,Ee=!1;function $e(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ee||dr==null||dr!==_s(l)||(l=dr,"selectionStart"in l&&no(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}),I&&Qr(I,l)||(I=l,l=ih(k,"onSelect"),0<l.length&&(s=new Ki("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=dr)))}function Ke(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var it={animationend:Ke("Animation","AnimationEnd"),animationiteration:Ke("Animation","AnimationIteration"),animationstart:Ke("Animation","AnimationStart"),transitionrun:Ke("Transition","TransitionRun"),transitionstart:Ke("Transition","TransitionStart"),transitioncancel:Ke("Transition","TransitionCancel"),transitionend:Ke("Transition","TransitionEnd")},ut={},ft={};yi&&(ft=document.createElement("div").style,"AnimationEvent"in window||(delete it.animationend.animation,delete it.animationiteration.animation,delete it.animationstart.animation),"TransitionEvent"in window||delete it.transitionend.transition);function qe(i){if(ut[i])return ut[i];if(!it[i])return i;var s=it[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in ft)return ut[i]=s[a];return i}var Yt=qe("animationend"),Ot=qe("animationiteration"),At=qe("animationstart"),Us=qe("transitionrun"),qo=qe("transitionstart"),Fs=qe("transitioncancel"),lc=qe("transitionend"),cc=new Map,ap="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(" ");ap.push("scrollEnd");function xs(i,s){cc.set(i,s),Vt(s,[i])}var md=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=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(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},is=[],Vo=0,op=0;function gd(){for(var i=Vo,s=op=Vo=0;s<i;){var a=is[s];is[s++]=null;var l=is[s];is[s++]=null;var d=is[s];is[s++]=null;var f=is[s];if(is[s++]=null,l!==null&&d!==null){var _=l.pending;_===null?d.next=d:(d.next=_.next,_.next=d),l.pending=d}f!==0&&Fb(a,d,f)}}function vd(i,s,a,l){is[Vo++]=i,is[Vo++]=s,is[Vo++]=a,is[Vo++]=l,op|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function lp(i,s,a,l){return vd(i,s,a,l),_d(i)}function so(i,s){return vd(i,null,null,s),_d(i)}function Fb(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var d=!1,f=i.return;f!==null;)f.childLanes|=a,l=f.alternate,l!==null&&(l.childLanes|=a),f.tag===22&&(i=f.stateNode,i===null||i._visibility&1||(d=!0)),i=f,f=f.return;return i.tag===3?(f=i.stateNode,d&&s!==null&&(d=31-ot(a),i=f.hiddenUpdates,l=i[d],l===null?i[d]=[s]:l.push(s),s.lane=a|536870912),f):null}function _d(i){if(50<Nc)throw Nc=0,vm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var Yo={};function FT(i,s,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=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(i,s,a,l){return new FT(i,s,a,l)}function cp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function hr(i,s){var a=i.alternate;return a===null?(a=zn(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,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,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function Kb(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,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,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function bd(i,s,a,l,d,f){var _=0;if(l=i,typeof i=="function")cp(i)&&(_=1);else if(typeof i=="string")_=VE(i,a,Ce.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ie:return i=zn(31,a,s,d),i.elementType=ie,i.lanes=f,i;case R:return ro(a.children,d,f,s);case B:_=8,d|=24;break;case A:return i=zn(12,a,s,d|2),i.elementType=A,i.lanes=f,i;case se:return i=zn(13,a,s,d),i.elementType=se,i.lanes=f,i;case Q:return i=zn(19,a,s,d),i.elementType=Q,i.lanes=f,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case U:_=9;break e;case K:_=11;break e;case z:_=14;break e;case _e:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return s=zn(_,a,s,d),s.elementType=i,s.type=l,s.lanes=f,s}function ro(i,s,a,l){return i=zn(7,i,l,s),i.lanes=a,i}function up(i,s,a){return i=zn(6,i,null,s),i.lanes=a,i}function Wb(i){var s=zn(18,null,null,0);return s.stateNode=i,s}function dp(i,s,a){return s=zn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var $b=new WeakMap;function ns(i,s){if(typeof i=="object"&&i!==null){var a=$b.get(i);return a!==void 0?a:(s={value:i,source:s,stack:Se(s)},$b.set(i,s),s)}return{value:i,source:s,stack:Se(s)}}var Xo=[],Go=0,yd=null,uc=0,ss=[],rs=0,Jr=null,Ks=1,Ws="";function fr(i,s){Xo[Go++]=uc,Xo[Go++]=yd,yd=i,uc=s}function qb(i,s,a){ss[rs++]=Ks,ss[rs++]=Ws,ss[rs++]=Jr,Jr=i;var l=Ks;i=Ws;var d=32-ot(l)-1;l&=~(1<<d),a+=1;var f=32-ot(s)+d;if(30<f){var _=d-d%5;f=(l&(1<<_)-1).toString(32),l>>=_,d-=_,Ks=1<<32-ot(s)+d|a<<d|l,Ws=f+i}else Ks=1<<f|a<<d|l,Ws=i}function hp(i){i.return!==null&&(fr(i,1),qb(i,1,0))}function fp(i){for(;i===yd;)yd=Xo[--Go],Xo[Go]=null,uc=Xo[--Go],Xo[Go]=null;for(;i===Jr;)Jr=ss[--rs],ss[rs]=null,Ws=ss[--rs],ss[rs]=null,Ks=ss[--rs],ss[rs]=null}function Vb(i,s){ss[rs++]=Ks,ss[rs++]=Ws,ss[rs++]=Jr,Ks=s.id,Ws=s.overflow,Jr=i}var sn=null,Jt=null,Ct=!1,ea=null,as=!1,pp=Error(r(519));function ta(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw dc(ns(s,i)),pp}function Yb(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[ri]=i,s[di]=l,a){case"dialog":bt("cancel",s),bt("close",s);break;case"iframe":case"object":case"embed":bt("load",s);break;case"video":case"audio":for(a=0;a<Lc.length;a++)bt(Lc[a],s);break;case"source":bt("error",s);break;case"img":case"image":case"link":bt("error",s),bt("load",s);break;case"details":bt("toggle",s);break;case"input":bt("invalid",s),Dn(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":bt("invalid",s);break;case"textarea":bt("invalid",s),sr(s,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||l.suppressHydrationWarning===!0||d0(s.textContent,a)?(l.popover!=null&&(bt("beforetoggle",s),bt("toggle",s)),l.onScroll!=null&&bt("scroll",s),l.onScrollEnd!=null&&bt("scrollend",s),l.onClick!=null&&(s.onclick=Qn),s=!0):s=!1,s||ta(i,!0)}function Xb(i){for(sn=i.return;sn;)switch(sn.tag){case 5:case 31:case 13:as=!1;return;case 27:case 3:as=!0;return;default:sn=sn.return}}function Zo(i){if(i!==sn)return!1;if(!Ct)return Xb(i),Ct=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Am(i.type,i.memoizedProps)),a=!a),a&&Jt&&ta(i),Xb(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Jt=y0(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Jt=y0(i)}else s===27?(s=Jt,ma(i.type)?(i=Im,Im=null,Jt=i):Jt=s):Jt=sn?ls(i.stateNode.nextSibling):null;return!0}function ao(){Jt=sn=null,Ct=!1}function mp(){var i=ea;return i!==null&&(On===null?On=i:On.push.apply(On,i),ea=null),i}function dc(i){ea===null?ea=[i]:ea.push(i)}var gp=N(null),oo=null,pr=null;function ia(i,s,a){ue(gp,s._currentValue),s._currentValue=a}function mr(i){i._currentValue=gp.current,W(gp)}function vp(i,s,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),i===a)break;i=i.return}}function _p(i,s,a,l){var d=i.child;for(d!==null&&(d.return=i);d!==null;){var f=d.dependencies;if(f!==null){var _=d.child;f=f.firstContext;e:for(;f!==null;){var T=f;f=d;for(var O=0;O<s.length;O++)if(T.context===s[O]){f.lanes|=a,T=f.alternate,T!==null&&(T.lanes|=a),vp(f.return,a,i),l||(_=null);break e}f=T.next}}else if(d.tag===18){if(_=d.return,_===null)throw Error(r(341));_.lanes|=a,f=_.alternate,f!==null&&(f.lanes|=a),vp(_,a,i),_=null}else _=d.child;if(_!==null)_.return=d;else for(_=d;_!==null;){if(_===i){_=null;break}if(d=_.sibling,d!==null){d.return=_.return,_=d;break}_=_.return}d=_}}function Qo(i,s,a,l){i=null;for(var d=s,f=!1;d!==null;){if(!f){if((d.flags&524288)!==0)f=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var _=d.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var T=d.type;wn(d.pendingProps.value,_.value)||(i!==null?i.push(T):i=[T])}}else if(d===Ne.current){if(_=d.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(i!==null?i.push(zc):i=[zc])}d=d.return}i!==null&&_p(s,i,a,l),s.flags|=262144}function Sd(i){for(i=i.firstContext;i!==null;){if(!wn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function lo(i){oo=i,pr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function rn(i){return Gb(oo,i)}function wd(i,s){return oo===null&&lo(i),Gb(i,s)}function Gb(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},pr===null){if(i===null)throw Error(r(308));pr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else pr=pr.next=s;return a}var KT=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},WT=e.unstable_scheduleCallback,$T=e.unstable_NormalPriority,Ti={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bp(){return{controller:new KT,data:new Map,refCount:0}}function hc(i){i.refCount--,i.refCount===0&&WT($T,function(){i.controller.abort()})}var fc=null,yp=0,Jo=0,el=null;function qT(i,s){if(fc===null){var a=fc=[];yp=0,Jo=Cm(),el={status:"pending",value:void 0,then:function(l){a.push(l)}}}return yp++,s.then(Zb,Zb),s}function Zb(){if(--yp===0&&fc!==null){el!==null&&(el.status="fulfilled");var i=fc;fc=null,Jo=0,el=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function VT(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(d){a.push(d)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var d=0;d<a.length;d++)(0,a[d])(s)},function(d){for(l.status="rejected",l.reason=d,d=0;d<a.length;d++)(0,a[d])(void 0)}),l}var Qb=L.S;L.S=function(i,s){BS=et(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&qT(i,s),Qb!==null&&Qb(i,s)};var co=N(null);function Sp(){var i=co.current;return i!==null?i:Xt.pooledCache}function Cd(i,s){s===null?ue(co,co.current):ue(co,s.pool)}function Jb(){var i=Sp();return i===null?null:{parent:Ti._currentValue,pool:i}}var tl=Error(r(460)),wp=Error(r(474)),xd=Error(r(542)),kd={then:function(){}};function ey(i){return i=i.status,i==="fulfilled"||i==="rejected"}function ty(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Qn,Qn),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,ny(i),i;default:if(typeof s.status=="string")s.then(Qn,Qn);else{if(i=Xt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var d=s;d.status="fulfilled",d.value=l}},function(l){if(s.status==="pending"){var d=s;d.status="rejected",d.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,ny(i),i}throw ho=s,tl}}function uo(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ho=a,tl):a}}var ho=null;function iy(){if(ho===null)throw Error(r(459));var i=ho;return ho=null,i}function ny(i){if(i===tl||i===xd)throw Error(r(483))}var il=null,pc=0;function Td(i){var s=pc;return pc+=1,il===null&&(il=[]),ty(il,i,s)}function mc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function Ed(i,s){throw s.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function sy(i){function s($,H){if(i){var Z=$.deletions;Z===null?($.deletions=[H],$.flags|=16):Z.push(H)}}function a($,H){if(!i)return null;for(;H!==null;)s($,H),H=H.sibling;return null}function l($){for(var H=new Map;$!==null;)$.key!==null?H.set($.key,$):H.set($.index,$),$=$.sibling;return H}function d($,H){return $=hr($,H),$.index=0,$.sibling=null,$}function f($,H,Z){return $.index=Z,i?(Z=$.alternate,Z!==null?(Z=Z.index,Z<H?($.flags|=67108866,H):Z):($.flags|=67108866,H)):($.flags|=1048576,H)}function _($){return i&&$.alternate===null&&($.flags|=67108866),$}function T($,H,Z,me){return H===null||H.tag!==6?(H=up(Z,$.mode,me),H.return=$,H):(H=d(H,Z),H.return=$,H)}function O($,H,Z,me){var Xe=Z.type;return Xe===R?fe($,H,Z.props.children,me,Z.key):H!==null&&(H.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===_e&&uo(Xe)===H.type)?(H=d(H,Z.props),mc(H,Z),H.return=$,H):(H=bd(Z.type,Z.key,Z.props,null,$.mode,me),mc(H,Z),H.return=$,H)}function J($,H,Z,me){return H===null||H.tag!==4||H.stateNode.containerInfo!==Z.containerInfo||H.stateNode.implementation!==Z.implementation?(H=dp(Z,$.mode,me),H.return=$,H):(H=d(H,Z.children||[]),H.return=$,H)}function fe($,H,Z,me,Xe){return H===null||H.tag!==7?(H=ro(Z,$.mode,me,Xe),H.return=$,H):(H=d(H,Z),H.return=$,H)}function ve($,H,Z){if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return H=up(""+H,$.mode,Z),H.return=$,H;if(typeof H=="object"&&H!==null){switch(H.$$typeof){case C:return Z=bd(H.type,H.key,H.props,null,$.mode,Z),mc(Z,H),Z.return=$,Z;case S:return H=dp(H,$.mode,Z),H.return=$,H;case _e:return H=uo(H),ve($,H,Z)}if(oe(H)||X(H))return H=ro(H,$.mode,Z,null),H.return=$,H;if(typeof H.then=="function")return ve($,Td(H),Z);if(H.$$typeof===Y)return ve($,wd($,H),Z);Ed($,H)}return null}function te($,H,Z,me){var Xe=H!==null?H.key:null;if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Xe!==null?null:T($,H,""+Z,me);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case C:return Z.key===Xe?O($,H,Z,me):null;case S:return Z.key===Xe?J($,H,Z,me):null;case _e:return Z=uo(Z),te($,H,Z,me)}if(oe(Z)||X(Z))return Xe!==null?null:fe($,H,Z,me,null);if(typeof Z.then=="function")return te($,H,Td(Z),me);if(Z.$$typeof===Y)return te($,H,wd($,Z),me);Ed($,Z)}return null}function ce($,H,Z,me,Xe){if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return $=$.get(Z)||null,T(H,$,""+me,Xe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case C:return $=$.get(me.key===null?Z:me.key)||null,O(H,$,me,Xe);case S:return $=$.get(me.key===null?Z:me.key)||null,J(H,$,me,Xe);case _e:return me=uo(me),ce($,H,Z,me,Xe)}if(oe(me)||X(me))return $=$.get(Z)||null,fe(H,$,me,Xe,null);if(typeof me.then=="function")return ce($,H,Z,Td(me),Xe);if(me.$$typeof===Y)return ce($,H,Z,wd(H,me),Xe);Ed(H,me)}return null}function Fe($,H,Z,me){for(var Xe=null,Tt=null,We=H,dt=H=0,wt=null;We!==null&&dt<Z.length;dt++){We.index>dt?(wt=We,We=null):wt=We.sibling;var Et=te($,We,Z[dt],me);if(Et===null){We===null&&(We=wt);break}i&&We&&Et.alternate===null&&s($,We),H=f(Et,H,dt),Tt===null?Xe=Et:Tt.sibling=Et,Tt=Et,We=wt}if(dt===Z.length)return a($,We),Ct&&fr($,dt),Xe;if(We===null){for(;dt<Z.length;dt++)We=ve($,Z[dt],me),We!==null&&(H=f(We,H,dt),Tt===null?Xe=We:Tt.sibling=We,Tt=We);return Ct&&fr($,dt),Xe}for(We=l(We);dt<Z.length;dt++)wt=ce(We,$,dt,Z[dt],me),wt!==null&&(i&&wt.alternate!==null&&We.delete(wt.key===null?dt:wt.key),H=f(wt,H,dt),Tt===null?Xe=wt:Tt.sibling=wt,Tt=wt);return i&&We.forEach(function(ya){return s($,ya)}),Ct&&fr($,dt),Xe}function Qe($,H,Z,me){if(Z==null)throw Error(r(151));for(var Xe=null,Tt=null,We=H,dt=H=0,wt=null,Et=Z.next();We!==null&&!Et.done;dt++,Et=Z.next()){We.index>dt?(wt=We,We=null):wt=We.sibling;var ya=te($,We,Et.value,me);if(ya===null){We===null&&(We=wt);break}i&&We&&ya.alternate===null&&s($,We),H=f(ya,H,dt),Tt===null?Xe=ya:Tt.sibling=ya,Tt=ya,We=wt}if(Et.done)return a($,We),Ct&&fr($,dt),Xe;if(We===null){for(;!Et.done;dt++,Et=Z.next())Et=ve($,Et.value,me),Et!==null&&(H=f(Et,H,dt),Tt===null?Xe=Et:Tt.sibling=Et,Tt=Et);return Ct&&fr($,dt),Xe}for(We=l(We);!Et.done;dt++,Et=Z.next())Et=ce(We,$,dt,Et.value,me),Et!==null&&(i&&Et.alternate!==null&&We.delete(Et.key===null?dt:Et.key),H=f(Et,H,dt),Tt===null?Xe=Et:Tt.sibling=Et,Tt=Et);return i&&We.forEach(function(s2){return s($,s2)}),Ct&&fr($,dt),Xe}function Ft($,H,Z,me){if(typeof Z=="object"&&Z!==null&&Z.type===R&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case C:e:{for(var Xe=Z.key;H!==null;){if(H.key===Xe){if(Xe=Z.type,Xe===R){if(H.tag===7){a($,H.sibling),me=d(H,Z.props.children),me.return=$,$=me;break e}}else if(H.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===_e&&uo(Xe)===H.type){a($,H.sibling),me=d(H,Z.props),mc(me,Z),me.return=$,$=me;break e}a($,H);break}else s($,H);H=H.sibling}Z.type===R?(me=ro(Z.props.children,$.mode,me,Z.key),me.return=$,$=me):(me=bd(Z.type,Z.key,Z.props,null,$.mode,me),mc(me,Z),me.return=$,$=me)}return _($);case S:e:{for(Xe=Z.key;H!==null;){if(H.key===Xe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a($,H.sibling),me=d(H,Z.children||[]),me.return=$,$=me;break e}else{a($,H);break}else s($,H);H=H.sibling}me=dp(Z,$.mode,me),me.return=$,$=me}return _($);case _e:return Z=uo(Z),Ft($,H,Z,me)}if(oe(Z))return Fe($,H,Z,me);if(X(Z)){if(Xe=X(Z),typeof Xe!="function")throw Error(r(150));return Z=Xe.call(Z),Qe($,H,Z,me)}if(typeof Z.then=="function")return Ft($,H,Td(Z),me);if(Z.$$typeof===Y)return Ft($,H,wd($,Z),me);Ed($,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a($,H.sibling),me=d(H,Z),me.return=$,$=me):(a($,H),me=up(Z,$.mode,me),me.return=$,$=me),_($)):a($,H)}return function($,H,Z,me){try{pc=0;var Xe=Ft($,H,Z,me);return il=null,Xe}catch(We){if(We===tl||We===xd)throw We;var Tt=zn(29,We,null,$.mode);return Tt.lanes=me,Tt.return=$,Tt}}}var fo=sy(!0),ry=sy(!1),na=!1;function Cp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xp(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function sa(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ra(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Rt&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,s=_d(i),Fb(i,null,a),s}return vd(i,l,s,a),_d(i)}function gc(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,qt(i,a)}}function kp(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var d=null,f=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};f===null?d=f=_:f=f.next=_,a=a.next}while(a!==null);f===null?d=f=s:f=f.next=s}else d=f=s;a={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:f,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var Tp=!1;function vc(){if(Tp){var i=el;if(i!==null)throw i}}function _c(i,s,a,l){Tp=!1;var d=i.updateQueue;na=!1;var f=d.firstBaseUpdate,_=d.lastBaseUpdate,T=d.shared.pending;if(T!==null){d.shared.pending=null;var O=T,J=O.next;O.next=null,_===null?f=J:_.next=J,_=O;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,T=fe.lastBaseUpdate,T!==_&&(T===null?fe.firstBaseUpdate=J:T.next=J,fe.lastBaseUpdate=O))}if(f!==null){var ve=d.baseState;_=0,fe=J=O=null,T=f;do{var te=T.lane&-536870913,ce=te!==T.lane;if(ce?(St&te)===te:(l&te)===te){te!==0&&te===Jo&&(Tp=!0),fe!==null&&(fe=fe.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var Fe=i,Qe=T;te=s;var Ft=a;switch(Qe.tag){case 1:if(Fe=Qe.payload,typeof Fe=="function"){ve=Fe.call(Ft,ve,te);break e}ve=Fe;break e;case 3:Fe.flags=Fe.flags&-65537|128;case 0:if(Fe=Qe.payload,te=typeof Fe=="function"?Fe.call(Ft,ve,te):Fe,te==null)break e;ve=b({},ve,te);break e;case 2:na=!0}}te=T.callback,te!==null&&(i.flags|=64,ce&&(i.flags|=8192),ce=d.callbacks,ce===null?d.callbacks=[te]:ce.push(te))}else ce={lane:te,tag:T.tag,payload:T.payload,callback:T.callback,next:null},fe===null?(J=fe=ce,O=ve):fe=fe.next=ce,_|=te;if(T=T.next,T===null){if(T=d.shared.pending,T===null)break;ce=T,T=ce.next,ce.next=null,d.lastBaseUpdate=ce,d.shared.pending=null}}while(!0);fe===null&&(O=ve),d.baseState=O,d.firstBaseUpdate=J,d.lastBaseUpdate=fe,f===null&&(d.shared.lanes=0),ua|=_,i.lanes=_,i.memoizedState=ve}}function ay(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function oy(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)ay(a[i],s)}var nl=N(null),Dd=N(0);function ly(i,s){i=xr,ue(Dd,i),ue(nl,s),xr=i|s.baseLanes}function Ep(){ue(Dd,xr),ue(nl,nl.current)}function Dp(){xr=Dd.current,W(nl),W(Dd)}var Pn=N(null),os=null;function aa(i){var s=i.alternate;ue(Si,Si.current&1),ue(Pn,i),os===null&&(s===null||nl.current!==null||s.memoizedState!==null)&&(os=i)}function Rp(i){ue(Si,Si.current),ue(Pn,i),os===null&&(os=i)}function cy(i){i.tag===22?(ue(Si,Si.current),ue(Pn,i),os===null&&(os=i)):oa()}function oa(){ue(Si,Si.current),ue(Pn,Pn.current)}function Hn(i){W(Pn),os===i&&(os=null),W(Si)}var Si=N(0);function Rd(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Bm(a)||jm(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var gr=0,ct=null,Ht=null,Ei=null,Md=!1,sl=!1,po=!1,Nd=0,bc=0,rl=null,YT=0;function fi(){throw Error(r(321))}function Mp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!wn(i[a],s[a]))return!1;return!0}function Np(i,s,a,l,d,f){return gr=f,ct=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,L.H=i===null||i.memoizedState===null?qy:qp,po=!1,f=a(l,d),po=!1,sl&&(f=dy(s,a,l,d)),uy(i),f}function uy(i){L.H=wc;var s=Ht!==null&&Ht.next!==null;if(gr=0,Ei=Ht=ct=null,Md=!1,bc=0,rl=null,s)throw Error(r(300));i===null||Di||(i=i.dependencies,i!==null&&Sd(i)&&(Di=!0))}function dy(i,s,a,l){ct=i;var d=0;do{if(sl&&(rl=null),bc=0,sl=!1,25<=d)throw Error(r(301));if(d+=1,Ei=Ht=null,i.updateQueue!=null){var f=i.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}L.H=Vy,f=s(a,l)}while(sl);return f}function XT(){var i=L.H,s=i.useState()[0];return s=typeof s.then=="function"?yc(s):s,i=i.useState()[0],(Ht!==null?Ht.memoizedState:null)!==i&&(ct.flags|=1024),s}function Ap(){var i=Nd!==0;return Nd=0,i}function Lp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Op(i){if(Md){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Md=!1}gr=0,Ei=Ht=ct=null,sl=!1,bc=Nd=0,rl=null}function Cn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ei===null?ct.memoizedState=Ei=i:Ei=Ei.next=i,Ei}function wi(){if(Ht===null){var i=ct.alternate;i=i!==null?i.memoizedState:null}else i=Ht.next;var s=Ei===null?ct.memoizedState:Ei.next;if(s!==null)Ei=s,Ht=i;else{if(i===null)throw ct.alternate===null?Error(r(467)):Error(r(310));Ht=i,i={memoizedState:Ht.memoizedState,baseState:Ht.baseState,baseQueue:Ht.baseQueue,queue:Ht.queue,next:null},Ei===null?ct.memoizedState=Ei=i:Ei=Ei.next=i}return Ei}function Ad(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function yc(i){var s=bc;return bc+=1,rl===null&&(rl=[]),i=ty(rl,i,s),s=ct,(Ei===null?s.memoizedState:Ei.next)===null&&(s=s.alternate,L.H=s===null||s.memoizedState===null?qy:qp),i}function Ld(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return yc(i);if(i.$$typeof===Y)return rn(i)}throw Error(r(438,String(i)))}function Bp(i){var s=null,a=ct.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=ct.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(d){return d.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Ad(),ct.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),l=0;l<i;l++)a[l]=ke;return s.index++,a}function vr(i,s){return typeof s=="function"?s(i):s}function Od(i){var s=wi();return jp(s,Ht,i)}function jp(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var d=i.baseQueue,f=l.pending;if(f!==null){if(d!==null){var _=d.next;d.next=f.next,f.next=_}s.baseQueue=d=f,l.pending=null}if(f=i.baseState,d===null)i.memoizedState=f;else{s=d.next;var T=_=null,O=null,J=s,fe=!1;do{var ve=J.lane&-536870913;if(ve!==J.lane?(St&ve)===ve:(gr&ve)===ve){var te=J.revertLane;if(te===0)O!==null&&(O=O.next={lane:0,revertLane:0,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),ve===Jo&&(fe=!0);else if((gr&te)===te){J=J.next,te===Jo&&(fe=!0);continue}else ve={lane:0,revertLane:J.revertLane,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},O===null?(T=O=ve,_=f):O=O.next=ve,ct.lanes|=te,ua|=te;ve=J.action,po&&a(f,ve),f=J.hasEagerState?J.eagerState:a(f,ve)}else te={lane:ve,revertLane:J.revertLane,gesture:J.gesture,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},O===null?(T=O=te,_=f):O=O.next=te,ct.lanes|=ve,ua|=ve;J=J.next}while(J!==null&&J!==s);if(O===null?_=f:O.next=T,!wn(f,i.memoizedState)&&(Di=!0,fe&&(a=el,a!==null)))throw a;i.memoizedState=f,i.baseState=_,i.baseQueue=O,l.lastRenderedState=f}return d===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Ip(i){var s=wi(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,d=a.pending,f=s.memoizedState;if(d!==null){a.pending=null;var _=d=d.next;do f=i(f,_.action),_=_.next;while(_!==d);wn(f,s.memoizedState)||(Di=!0),s.memoizedState=f,s.baseQueue===null&&(s.baseState=f),a.lastRenderedState=f}return[f,l]}function hy(i,s,a){var l=ct,d=wi(),f=Ct;if(f){if(a===void 0)throw Error(r(407));a=a()}else a=s();var _=!wn((Ht||d).memoizedState,a);if(_&&(d.memoizedState=a,Di=!0),d=d.queue,Hp(my.bind(null,l,d,i),[i]),d.getSnapshot!==s||_||Ei!==null&&Ei.memoizedState.tag&1){if(l.flags|=2048,al(9,{destroy:void 0},py.bind(null,l,d,a,s),null),Xt===null)throw Error(r(349));f||(gr&127)!==0||fy(l,s,a)}return a}function fy(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=ct.updateQueue,s===null?(s=Ad(),ct.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function py(i,s,a,l){s.value=a,s.getSnapshot=l,gy(s)&&vy(i)}function my(i,s,a){return a(function(){gy(s)&&vy(i)})}function gy(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!wn(i,a)}catch{return!0}}function vy(i){var s=so(i,2);s!==null&&Bn(s,i,2)}function zp(i){var s=Cn();if(typeof i=="function"){var a=i;if(i=a(),po){xt(!0);try{a()}finally{xt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:i},s}function _y(i,s,a,l){return i.baseState=a,jp(i,Ht,typeof l=="function"?l:vr)}function GT(i,s,a,l,d){if(Id(i))throw Error(r(485));if(i=s.action,i!==null){var f={payload:d,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){f.listeners.push(_)}};L.T!==null?a(!0):f.isTransition=!1,l(f),a=s.pending,a===null?(f.next=s.pending=f,by(s,f)):(f.next=a.next,s.pending=a.next=f)}}function by(i,s){var a=s.action,l=s.payload,d=i.state;if(s.isTransition){var f=L.T,_={};L.T=_;try{var T=a(d,l),O=L.S;O!==null&&O(_,T),yy(i,s,T)}catch(J){Pp(i,s,J)}finally{f!==null&&_.types!==null&&(f.types=_.types),L.T=f}}else try{f=a(d,l),yy(i,s,f)}catch(J){Pp(i,s,J)}}function yy(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Sy(i,s,l)},function(l){return Pp(i,s,l)}):Sy(i,s,a)}function Sy(i,s,a){s.status="fulfilled",s.value=a,wy(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,by(i,a)))}function Pp(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,wy(s),s=s.next;while(s!==l)}i.action=null}function wy(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function Cy(i,s){return s}function xy(i,s){if(Ct){var a=Xt.formState;if(a!==null){e:{var l=ct;if(Ct){if(Jt){t:{for(var d=Jt,f=as;d.nodeType!==8;){if(!f){d=null;break t}if(d=ls(d.nextSibling),d===null){d=null;break t}}f=d.data,d=f==="F!"||f==="F"?d:null}if(d){Jt=ls(d.nextSibling),l=d.data==="F!";break e}}ta(l)}l=!1}l&&(s=a[0])}}return a=Cn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cy,lastRenderedState:s},a.queue=l,a=Ky.bind(null,ct,l),l.dispatch=a,l=zp(!1),f=$p.bind(null,ct,!1,l.queue),l=Cn(),d={state:s,dispatch:null,action:i,pending:null},l.queue=d,a=GT.bind(null,ct,d,f,a),d.dispatch=a,l.memoizedState=i,[s,a,!1]}function ky(i){var s=wi();return Ty(s,Ht,i)}function Ty(i,s,a){if(s=jp(i,s,Cy)[0],i=Od(vr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=yc(s)}catch(_){throw _===tl?xd:_}else l=s;s=wi();var d=s.queue,f=d.dispatch;return a!==s.memoizedState&&(ct.flags|=2048,al(9,{destroy:void 0},ZT.bind(null,d,a),null)),[l,f,i]}function ZT(i,s){i.action=s}function Ey(i){var s=wi(),a=Ht;if(a!==null)return Ty(s,a,i);wi(),s=s.memoizedState,a=wi();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function al(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=ct.updateQueue,s===null&&(s=Ad(),ct.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,s.lastEffect=i),i}function Dy(){return wi().memoizedState}function Bd(i,s,a,l){var d=Cn();ct.flags|=i,d.memoizedState=al(1|s,{destroy:void 0},a,l===void 0?null:l)}function jd(i,s,a,l){var d=wi();l=l===void 0?null:l;var f=d.memoizedState.inst;Ht!==null&&l!==null&&Mp(l,Ht.memoizedState.deps)?d.memoizedState=al(s,f,a,l):(ct.flags|=i,d.memoizedState=al(1|s,f,a,l))}function Ry(i,s){Bd(8390656,8,i,s)}function Hp(i,s){jd(2048,8,i,s)}function QT(i){ct.flags|=4;var s=ct.updateQueue;if(s===null)s=Ad(),ct.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function My(i){var s=wi().memoizedState;return QT({ref:s,nextImpl:i}),function(){if((Rt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Ny(i,s){return jd(4,2,i,s)}function Ay(i,s){return jd(4,4,i,s)}function Ly(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function Oy(i,s,a){a=a!=null?a.concat([i]):null,jd(4,4,Ly.bind(null,s,i),a)}function Up(){}function By(i,s){var a=wi();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Mp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function jy(i,s){var a=wi();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Mp(s,l[1]))return l[0];if(l=i(),po){xt(!0);try{i()}finally{xt(!1)}}return a.memoizedState=[l,s],l}function Fp(i,s,a){return a===void 0||(gr&1073741824)!==0&&(St&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=IS(),ct.lanes|=i,ua|=i,a)}function Iy(i,s,a,l){return wn(a,s)?a:nl.current!==null?(i=Fp(i,a,l),wn(i,s)||(Di=!0),i):(gr&42)===0||(gr&1073741824)!==0&&(St&261930)===0?(Di=!0,i.memoizedState=a):(i=IS(),ct.lanes|=i,ua|=i,s)}function zy(i,s,a,l,d){var f=M.p;M.p=f!==0&&8>f?f:8;var _=L.T,T={};L.T=T,$p(i,!1,s,a);try{var O=d(),J=L.S;if(J!==null&&J(T,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var fe=VT(O,l);Sc(i,s,fe,Kn(i))}else Sc(i,s,l,Kn(i))}catch(ve){Sc(i,s,{then:function(){},status:"rejected",reason:ve},Kn())}finally{M.p=f,_!==null&&T.types!==null&&(_.types=T.types),L.T=_}}function JT(){}function Kp(i,s,a,l){if(i.tag!==5)throw Error(r(476));var d=Py(i).queue;zy(i,d,s,j,a===null?JT:function(){return Hy(i),a(l)})}function Py(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:j},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function Hy(i){var s=Py(i);s.next===null&&(s=i.alternate.memoizedState),Sc(i,s.next.queue,{},Kn())}function Wp(){return rn(zc)}function Uy(){return wi().memoizedState}function Fy(){return wi().memoizedState}function eE(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Kn();i=sa(a);var l=ra(s,i,a);l!==null&&(Bn(l,s,a),gc(l,s,a)),s={cache:bp()},i.payload=s;return}s=s.return}}function tE(i,s,a){var l=Kn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Id(i)?Wy(s,a):(a=lp(i,s,a,l),a!==null&&(Bn(a,i,l),$y(a,s,l)))}function Ky(i,s,a){var l=Kn();Sc(i,s,a,l)}function Sc(i,s,a,l){var d={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Id(i))Wy(s,d);else{var f=i.alternate;if(i.lanes===0&&(f===null||f.lanes===0)&&(f=s.lastRenderedReducer,f!==null))try{var _=s.lastRenderedState,T=f(_,a);if(d.hasEagerState=!0,d.eagerState=T,wn(T,_))return vd(i,s,d,0),Xt===null&&gd(),!1}catch{}if(a=lp(i,s,d,l),a!==null)return Bn(a,i,l),$y(a,s,l),!0}return!1}function $p(i,s,a,l){if(l={lane:2,revertLane:Cm(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Id(i)){if(s)throw Error(r(479))}else s=lp(i,a,l,2),s!==null&&Bn(s,i,2)}function Id(i){var s=i.alternate;return i===ct||s!==null&&s===ct}function Wy(i,s){sl=Md=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function $y(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,qt(i,a)}}var wc={readContext:rn,use:Ld,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useLayoutEffect:fi,useInsertionEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useSyncExternalStore:fi,useId:fi,useHostTransitionStatus:fi,useFormState:fi,useActionState:fi,useOptimistic:fi,useMemoCache:fi,useCacheRefresh:fi};wc.useEffectEvent=fi;var qy={readContext:rn,use:Ld,useCallback:function(i,s){return Cn().memoizedState=[i,s===void 0?null:s],i},useContext:rn,useEffect:Ry,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,Bd(4194308,4,Ly.bind(null,s,i),a)},useLayoutEffect:function(i,s){return Bd(4194308,4,i,s)},useInsertionEffect:function(i,s){Bd(4,2,i,s)},useMemo:function(i,s){var a=Cn();s=s===void 0?null:s;var l=i();if(po){xt(!0);try{i()}finally{xt(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=Cn();if(a!==void 0){var d=a(s);if(po){xt(!0);try{a(s)}finally{xt(!1)}}}else d=s;return l.memoizedState=l.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},l.queue=i,i=i.dispatch=tE.bind(null,ct,i),[l.memoizedState,i]},useRef:function(i){var s=Cn();return i={current:i},s.memoizedState=i},useState:function(i){i=zp(i);var s=i.queue,a=Ky.bind(null,ct,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:Up,useDeferredValue:function(i,s){var a=Cn();return Fp(a,i,s)},useTransition:function(){var i=zp(!1);return i=zy.bind(null,ct,i.queue,!0,!1),Cn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=ct,d=Cn();if(Ct){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Xt===null)throw Error(r(349));(St&127)!==0||fy(l,s,a)}d.memoizedState=a;var f={value:a,getSnapshot:s};return d.queue=f,Ry(my.bind(null,l,f,i),[i]),l.flags|=2048,al(9,{destroy:void 0},py.bind(null,l,f,a,s),null),a},useId:function(){var i=Cn(),s=Xt.identifierPrefix;if(Ct){var a=Ws,l=Ks;a=(l&~(1<<32-ot(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Nd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=YT++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:Wp,useFormState:xy,useActionState:xy,useOptimistic:function(i){var s=Cn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=$p.bind(null,ct,!0,a),a.dispatch=s,[i,s]},useMemoCache:Bp,useCacheRefresh:function(){return Cn().memoizedState=eE.bind(null,ct)},useEffectEvent:function(i){var s=Cn(),a={impl:i};return s.memoizedState=a,function(){if((Rt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},qp={readContext:rn,use:Ld,useCallback:By,useContext:rn,useEffect:Hp,useImperativeHandle:Oy,useInsertionEffect:Ny,useLayoutEffect:Ay,useMemo:jy,useReducer:Od,useRef:Dy,useState:function(){return Od(vr)},useDebugValue:Up,useDeferredValue:function(i,s){var a=wi();return Iy(a,Ht.memoizedState,i,s)},useTransition:function(){var i=Od(vr)[0],s=wi().memoizedState;return[typeof i=="boolean"?i:yc(i),s]},useSyncExternalStore:hy,useId:Uy,useHostTransitionStatus:Wp,useFormState:ky,useActionState:ky,useOptimistic:function(i,s){var a=wi();return _y(a,Ht,i,s)},useMemoCache:Bp,useCacheRefresh:Fy};qp.useEffectEvent=My;var Vy={readContext:rn,use:Ld,useCallback:By,useContext:rn,useEffect:Hp,useImperativeHandle:Oy,useInsertionEffect:Ny,useLayoutEffect:Ay,useMemo:jy,useReducer:Ip,useRef:Dy,useState:function(){return Ip(vr)},useDebugValue:Up,useDeferredValue:function(i,s){var a=wi();return Ht===null?Fp(a,i,s):Iy(a,Ht.memoizedState,i,s)},useTransition:function(){var i=Ip(vr)[0],s=wi().memoizedState;return[typeof i=="boolean"?i:yc(i),s]},useSyncExternalStore:hy,useId:Uy,useHostTransitionStatus:Wp,useFormState:Ey,useActionState:Ey,useOptimistic:function(i,s){var a=wi();return Ht!==null?_y(a,Ht,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Bp,useCacheRefresh:Fy};Vy.useEffectEvent=My;function Vp(i,s,a,l){s=i.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Yp={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Kn(),d=sa(l);d.payload=s,a!=null&&(d.callback=a),s=ra(i,d,l),s!==null&&(Bn(s,i,l),gc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Kn(),d=sa(l);d.tag=1,d.payload=s,a!=null&&(d.callback=a),s=ra(i,d,l),s!==null&&(Bn(s,i,l),gc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Kn(),l=sa(a);l.tag=2,s!=null&&(l.callback=s),s=ra(i,l,a),s!==null&&(Bn(s,i,a),gc(s,i,a))}};function Yy(i,s,a,l,d,f,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,f,_):s.prototype&&s.prototype.isPureReactComponent?!Qr(a,l)||!Qr(d,f):!0}function Xy(i,s,a,l){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==i&&Yp.enqueueReplaceState(s,s.state,null)}function mo(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var d in i)a[d]===void 0&&(a[d]=i[d])}return a}function Gy(i){md(i)}function Zy(i){console.error(i)}function Qy(i){md(i)}function zd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Jy(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function Xp(i,s,a){return a=sa(a),a.tag=3,a.payload={element:null},a.callback=function(){zd(i,s)},a}function eS(i){return i=sa(i),i.tag=3,i}function tS(i,s,a,l){var d=a.type.getDerivedStateFromError;if(typeof d=="function"){var f=l.value;i.payload=function(){return d(f)},i.callback=function(){Jy(s,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Jy(s,a,l),typeof d!="function"&&(da===null?da=new Set([this]):da.add(this));var T=l.stack;this.componentDidCatch(l.value,{componentStack:T!==null?T:""})})}function iE(i,s,a,l,d){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Qo(s,a,d,!0),a=Pn.current,a!==null){switch(a.tag){case 31:case 13:return os===null?Gd():a.alternate===null&&pi===0&&(pi=3),a.flags&=-257,a.flags|=65536,a.lanes=d,l===kd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),ym(i,l,d)),!1;case 22:return a.flags|=65536,l===kd?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([l]):a.add(l)),ym(i,l,d)),!1}throw Error(r(435,a.tag))}return ym(i,l,d),Gd(),!1}if(Ct)return s=Pn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=d,l!==pp&&(i=Error(r(422),{cause:l}),dc(ns(i,a)))):(l!==pp&&(s=Error(r(423),{cause:l}),dc(ns(s,a))),i=i.current.alternate,i.flags|=65536,d&=-d,i.lanes|=d,l=ns(l,a),d=Xp(i.stateNode,l,d),kp(i,d),pi!==4&&(pi=2)),!1;var f=Error(r(520),{cause:l});if(f=ns(f,a),Mc===null?Mc=[f]:Mc.push(f),pi!==4&&(pi=2),s===null)return!0;l=ns(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=d&-d,a.lanes|=i,i=Xp(a.stateNode,l,i),kp(a,i),!1;case 1:if(s=a.type,f=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(da===null||!da.has(f))))return a.flags|=65536,d&=-d,a.lanes|=d,d=eS(d),tS(d,i,a,l),kp(a,d),!1}a=a.return}while(a!==null);return!1}var Gp=Error(r(461)),Di=!1;function an(i,s,a,l){s.child=i===null?ry(s,null,a,l):fo(s,i.child,a,l)}function iS(i,s,a,l,d){a=a.render;var f=s.ref;if("ref"in l){var _={};for(var T in l)T!=="ref"&&(_[T]=l[T])}else _=l;return lo(s),l=Np(i,s,a,_,f,d),T=Ap(),i!==null&&!Di?(Lp(i,s,d),_r(i,s,d)):(Ct&&T&&hp(s),s.flags|=1,an(i,s,l,d),s.child)}function nS(i,s,a,l,d){if(i===null){var f=a.type;return typeof f=="function"&&!cp(f)&&f.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=f,sS(i,s,f,l,d)):(i=bd(a.type,null,l,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(f=i.child,!sm(i,d)){var _=f.memoizedProps;if(a=a.compare,a=a!==null?a:Qr,a(_,l)&&i.ref===s.ref)return _r(i,s,d)}return s.flags|=1,i=hr(f,l),i.ref=s.ref,i.return=s,s.child=i}function sS(i,s,a,l,d){if(i!==null){var f=i.memoizedProps;if(Qr(f,l)&&i.ref===s.ref)if(Di=!1,s.pendingProps=l=f,sm(i,d))(i.flags&131072)!==0&&(Di=!0);else return s.lanes=i.lanes,_r(i,s,d)}return Zp(i,s,a,l,d)}function rS(i,s,a,l){var d=l.children,f=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(f=f!==null?f.baseLanes|a:a,i!==null){for(l=s.child=i.child,d=0;l!==null;)d=d|l.lanes|l.childLanes,l=l.sibling;l=d&~f}else l=0,s.child=null;return aS(i,s,f,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Cd(s,f!==null?f.cachePool:null),f!==null?ly(s,f):Ep(),cy(s);else return l=s.lanes=536870912,aS(i,s,f!==null?f.baseLanes|a:a,a,l)}else f!==null?(Cd(s,f.cachePool),ly(s,f),oa(),s.memoizedState=null):(i!==null&&Cd(s,null),Ep(),oa());return an(i,s,d,a),s.child}function Cc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function aS(i,s,a,l,d){var f=Sp();return f=f===null?null:{parent:Ti._currentValue,pool:f},s.memoizedState={baseLanes:a,cachePool:f},i!==null&&Cd(s,null),Ep(),cy(s),i!==null&&Qo(i,s,l,!0),s.childLanes=d,null}function Pd(i,s){return s=Ud({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function oS(i,s,a){return fo(s,i.child,null,a),i=Pd(s,s.pendingProps),i.flags|=2,Hn(s),s.memoizedState=null,i}function nE(i,s,a){var l=s.pendingProps,d=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Ct){if(l.mode==="hidden")return i=Pd(s,l),s.lanes=536870912,Cc(null,i);if(Rp(s),(i=Jt)?(i=b0(i,as),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Jr!==null?{id:Ks,overflow:Ws}:null,retryLane:536870912,hydrationErrors:null},a=Wb(i),a.return=s,s.child=a,sn=s,Jt=null)):i=null,i===null)throw ta(s);return s.lanes=536870912,null}return Pd(s,l)}var f=i.memoizedState;if(f!==null){var _=f.dehydrated;if(Rp(s),d)if(s.flags&256)s.flags&=-257,s=oS(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Di||Qo(i,s,a,!1),d=(a&i.childLanes)!==0,Di||d){if(l=Xt,l!==null&&(_=Ji(l,a),_!==0&&_!==f.retryLane))throw f.retryLane=_,so(i,_),Bn(l,i,_),Gp;Gd(),s=oS(i,s,a)}else i=f.treeContext,Jt=ls(_.nextSibling),sn=s,Ct=!0,ea=null,as=!1,i!==null&&Vb(s,i),s=Pd(s,l),s.flags|=4096;return s}return i=hr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Hd(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function Zp(i,s,a,l,d){return lo(s),a=Np(i,s,a,l,void 0,d),l=Ap(),i!==null&&!Di?(Lp(i,s,d),_r(i,s,d)):(Ct&&l&&hp(s),s.flags|=1,an(i,s,a,d),s.child)}function lS(i,s,a,l,d,f){return lo(s),s.updateQueue=null,a=dy(s,l,a,d),uy(i),l=Ap(),i!==null&&!Di?(Lp(i,s,f),_r(i,s,f)):(Ct&&l&&hp(s),s.flags|=1,an(i,s,a,f),s.child)}function cS(i,s,a,l,d){if(lo(s),s.stateNode===null){var f=Yo,_=a.contextType;typeof _=="object"&&_!==null&&(f=rn(_)),f=new a(l,f),s.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=Yp,s.stateNode=f,f._reactInternals=s,f=s.stateNode,f.props=l,f.state=s.memoizedState,f.refs={},Cp(s),_=a.contextType,f.context=typeof _=="object"&&_!==null?rn(_):Yo,f.state=s.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Vp(s,a,_,l),f.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(_=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),_!==f.state&&Yp.enqueueReplaceState(f,f.state,null),_c(s,l,f,d),vc(),f.state=s.memoizedState),typeof f.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){f=s.stateNode;var T=s.memoizedProps,O=mo(a,T);f.props=O;var J=f.context,fe=a.contextType;_=Yo,typeof fe=="object"&&fe!==null&&(_=rn(fe));var ve=a.getDerivedStateFromProps;fe=typeof ve=="function"||typeof f.getSnapshotBeforeUpdate=="function",T=s.pendingProps!==T,fe||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(T||J!==_)&&Xy(s,f,l,_),na=!1;var te=s.memoizedState;f.state=te,_c(s,l,f,d),vc(),J=s.memoizedState,T||te!==J||na?(typeof ve=="function"&&(Vp(s,a,ve,l),J=s.memoizedState),(O=na||Yy(s,a,O,l,te,J,_))?(fe||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(s.flags|=4194308)):(typeof f.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=J),f.props=l,f.state=J,f.context=_,l=O):(typeof f.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{f=s.stateNode,xp(i,s),_=s.memoizedProps,fe=mo(a,_),f.props=fe,ve=s.pendingProps,te=f.context,J=a.contextType,O=Yo,typeof J=="object"&&J!==null&&(O=rn(J)),T=a.getDerivedStateFromProps,(J=typeof T=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(_!==ve||te!==O)&&Xy(s,f,l,O),na=!1,te=s.memoizedState,f.state=te,_c(s,l,f,d),vc();var ce=s.memoizedState;_!==ve||te!==ce||na||i!==null&&i.dependencies!==null&&Sd(i.dependencies)?(typeof T=="function"&&(Vp(s,a,T,l),ce=s.memoizedState),(fe=na||Yy(s,a,fe,l,te,ce,O)||i!==null&&i.dependencies!==null&&Sd(i.dependencies))?(J||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(l,ce,O),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(l,ce,O)),typeof f.componentDidUpdate=="function"&&(s.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof f.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ce),f.props=l,f.state=ce,f.context=O,l=fe):(typeof f.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),l=!1)}return f=l,Hd(i,s),l=(s.flags&128)!==0,f||l?(f=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:f.render(),s.flags|=1,i!==null&&l?(s.child=fo(s,i.child,null,d),s.child=fo(s,null,a,d)):an(i,s,a,d),s.memoizedState=f.state,i=s.child):i=_r(i,s,d),i}function uS(i,s,a,l){return ao(),s.flags|=256,an(i,s,a,l),s.child}var Qp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Jp(i){return{baseLanes:i,cachePool:Jb()}}function em(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Fn),i}function dS(i,s,a){var l=s.pendingProps,d=!1,f=(s.flags&128)!==0,_;if((_=f)||(_=i!==null&&i.memoizedState===null?!1:(Si.current&2)!==0),_&&(d=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,i===null){if(Ct){if(d?aa(s):oa(),(i=Jt)?(i=b0(i,as),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Jr!==null?{id:Ks,overflow:Ws}:null,retryLane:536870912,hydrationErrors:null},a=Wb(i),a.return=s,s.child=a,sn=s,Jt=null)):i=null,i===null)throw ta(s);return jm(i)?s.lanes=32:s.lanes=536870912,null}var T=l.children;return l=l.fallback,d?(oa(),d=s.mode,T=Ud({mode:"hidden",children:T},d),l=ro(l,d,a,null),T.return=s,l.return=s,T.sibling=l,s.child=T,l=s.child,l.memoizedState=Jp(a),l.childLanes=em(i,_,a),s.memoizedState=Qp,Cc(null,l)):(aa(s),tm(s,T))}var O=i.memoizedState;if(O!==null&&(T=O.dehydrated,T!==null)){if(f)s.flags&256?(aa(s),s.flags&=-257,s=im(i,s,a)):s.memoizedState!==null?(oa(),s.child=i.child,s.flags|=128,s=null):(oa(),T=l.fallback,d=s.mode,l=Ud({mode:"visible",children:l.children},d),T=ro(T,d,a,null),T.flags|=2,l.return=s,T.return=s,l.sibling=T,s.child=l,fo(s,i.child,null,a),l=s.child,l.memoizedState=Jp(a),l.childLanes=em(i,_,a),s.memoizedState=Qp,s=Cc(null,l));else if(aa(s),jm(T)){if(_=T.nextSibling&&T.nextSibling.dataset,_)var J=_.dgst;_=J,l=Error(r(419)),l.stack="",l.digest=_,dc({value:l,source:null,stack:null}),s=im(i,s,a)}else if(Di||Qo(i,s,a,!1),_=(a&i.childLanes)!==0,Di||_){if(_=Xt,_!==null&&(l=Ji(_,a),l!==0&&l!==O.retryLane))throw O.retryLane=l,so(i,l),Bn(_,i,l),Gp;Bm(T)||Gd(),s=im(i,s,a)}else Bm(T)?(s.flags|=192,s.child=i.child,s=null):(i=O.treeContext,Jt=ls(T.nextSibling),sn=s,Ct=!0,ea=null,as=!1,i!==null&&Vb(s,i),s=tm(s,l.children),s.flags|=4096);return s}return d?(oa(),T=l.fallback,d=s.mode,O=i.child,J=O.sibling,l=hr(O,{mode:"hidden",children:l.children}),l.subtreeFlags=O.subtreeFlags&65011712,J!==null?T=hr(J,T):(T=ro(T,d,a,null),T.flags|=2),T.return=s,l.return=s,l.sibling=T,s.child=l,Cc(null,l),l=s.child,T=i.child.memoizedState,T===null?T=Jp(a):(d=T.cachePool,d!==null?(O=Ti._currentValue,d=d.parent!==O?{parent:O,pool:O}:d):d=Jb(),T={baseLanes:T.baseLanes|a,cachePool:d}),l.memoizedState=T,l.childLanes=em(i,_,a),s.memoizedState=Qp,Cc(i.child,l)):(aa(s),a=i.child,i=a.sibling,a=hr(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,i!==null&&(_=s.deletions,_===null?(s.deletions=[i],s.flags|=16):_.push(i)),s.child=a,s.memoizedState=null,a)}function tm(i,s){return s=Ud({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function Ud(i,s){return i=zn(22,i,null,s),i.lanes=0,i}function im(i,s,a){return fo(s,i.child,null,a),i=tm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function hS(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),vp(i.return,s,a)}function nm(i,s,a,l,d,f){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:d,treeForkCount:f}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=d,_.treeForkCount=f)}function fS(i,s,a){var l=s.pendingProps,d=l.revealOrder,f=l.tail;l=l.children;var _=Si.current,T=(_&2)!==0;if(T?(_=_&1|2,s.flags|=128):_&=1,ue(Si,_),an(i,s,l,a),l=Ct?uc:0,!T&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&hS(i,a,s);else if(i.tag===19)hS(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&Rd(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),nm(s,!1,d,a,f,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&Rd(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}nm(s,!0,a,null,f,l);break;case"together":nm(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function _r(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),ua|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Qo(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=hr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=hr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function sm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Sd(i)))}function sE(i,s,a){switch(s.tag){case 3:Oe(s,s.stateNode.containerInfo),ia(s,Ti,i.memoizedState.cache),ao();break;case 27:case 5:Ye(s);break;case 4:Oe(s,s.stateNode.containerInfo);break;case 10:ia(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Rp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(aa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?dS(i,s,a):(aa(s),i=_r(i,s,a),i!==null?i.sibling:null);aa(s);break;case 19:var d=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Qo(i,s,a,!1),l=(a&s.childLanes)!==0),d){if(l)return fS(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),ue(Si,Si.current),l)break;return null;case 22:return s.lanes=0,rS(i,s,a,s.pendingProps);case 24:ia(s,Ti,i.memoizedState.cache)}return _r(i,s,a)}function pS(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Di=!0;else{if(!sm(i,a)&&(s.flags&128)===0)return Di=!1,sE(i,s,a);Di=(i.flags&131072)!==0}else Di=!1,Ct&&(s.flags&1048576)!==0&&qb(s,uc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=uo(s.elementType),s.type=i,typeof i=="function")cp(i)?(l=mo(i,l),s.tag=1,s=cS(null,s,i,l,a)):(s.tag=0,s=Zp(null,s,i,l,a));else{if(i!=null){var d=i.$$typeof;if(d===K){s.tag=11,s=iS(null,s,i,l,a);break e}else if(d===z){s.tag=14,s=nS(null,s,i,l,a);break e}}throw s=q(i)||i,Error(r(306,s,""))}}return s;case 0:return Zp(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,d=mo(l,s.pendingProps),cS(i,s,l,d,a);case 3:e:{if(Oe(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var f=s.memoizedState;d=f.element,xp(i,s),_c(s,l,null,a);var _=s.memoizedState;if(l=_.cache,ia(s,Ti,l),l!==f.cache&&_p(s,[Ti],a,!0),vc(),l=_.element,f.isDehydrated)if(f={element:l,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=f,s.memoizedState=f,s.flags&256){s=uS(i,s,l,a);break e}else if(l!==d){d=ns(Error(r(424)),s),dc(d),s=uS(i,s,l,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Jt=ls(i.firstChild),sn=s,Ct=!0,ea=null,as=!0,a=ry(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ao(),l===d){s=_r(i,s,a);break e}an(i,s,l,a)}s=s.child}return s;case 26:return Hd(i,s),i===null?(a=k0(s.type,null,s.pendingProps,null))?s.memoizedState=a:Ct||(a=s.type,i=s.pendingProps,l=nh(Me.current).createElement(a),l[ri]=s,l[di]=i,on(l,a,i),Pt(l),s.stateNode=l):s.memoizedState=k0(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return Ye(s),i===null&&Ct&&(l=s.stateNode=w0(s.type,s.pendingProps,Me.current),sn=s,as=!0,d=Jt,ma(s.type)?(Im=d,Jt=ls(l.firstChild)):Jt=d),an(i,s,s.pendingProps.children,a),Hd(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Ct&&((d=l=Jt)&&(l=OE(l,s.type,s.pendingProps,as),l!==null?(s.stateNode=l,sn=s,Jt=ls(l.firstChild),as=!1,d=!0):d=!1),d||ta(s)),Ye(s),d=s.type,f=s.pendingProps,_=i!==null?i.memoizedProps:null,l=f.children,Am(d,f)?l=null:_!==null&&Am(d,_)&&(s.flags|=32),s.memoizedState!==null&&(d=Np(i,s,XT,null,null,a),zc._currentValue=d),Hd(i,s),an(i,s,l,a),s.child;case 6:return i===null&&Ct&&((i=a=Jt)&&(a=BE(a,s.pendingProps,as),a!==null?(s.stateNode=a,sn=s,Jt=null,i=!0):i=!1),i||ta(s)),null;case 13:return dS(i,s,a);case 4:return Oe(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=fo(s,null,l,a):an(i,s,l,a),s.child;case 11:return iS(i,s,s.type,s.pendingProps,a);case 7:return an(i,s,s.pendingProps,a),s.child;case 8:return an(i,s,s.pendingProps.children,a),s.child;case 12:return an(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,ia(s,s.type,l.value),an(i,s,l.children,a),s.child;case 9:return d=s.type._context,l=s.pendingProps.children,lo(s),d=rn(d),l=l(d),s.flags|=1,an(i,s,l,a),s.child;case 14:return nS(i,s,s.type,s.pendingProps,a);case 15:return sS(i,s,s.type,s.pendingProps,a);case 19:return fS(i,s,a);case 31:return nE(i,s,a);case 22:return rS(i,s,a,s.pendingProps);case 24:return lo(s),l=rn(Ti),i===null?(d=Sp(),d===null&&(d=Xt,f=bp(),d.pooledCache=f,f.refCount++,f!==null&&(d.pooledCacheLanes|=a),d=f),s.memoizedState={parent:l,cache:d},Cp(s),ia(s,Ti,d)):((i.lanes&a)!==0&&(xp(i,s),_c(s,null,null,a),vc()),d=i.memoizedState,f=s.memoizedState,d.parent!==l?(d={parent:l,cache:l},s.memoizedState=d,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=d),ia(s,Ti,l)):(l=f.cache,ia(s,Ti,l),l!==d.cache&&_p(s,[Ti],a,!0))),an(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function br(i){i.flags|=4}function rm(i,s,a,l,d){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(d&335544128)===d)if(i.stateNode.complete)i.flags|=8192;else if(US())i.flags|=8192;else throw ho=kd,wp}else i.flags&=-16777217}function mS(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!M0(s))if(US())i.flags|=8192;else throw ho=kd,wp}function Fd(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?$t():536870912,i.lanes|=s,ul|=s)}function xc(i,s){if(!Ct)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.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?s||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function ei(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags&65011712,l|=d.flags&65011712,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function rE(i,s,a){var l=s.pendingProps;switch(fp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ei(s),null;case 1:return ei(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),mr(Ti),Ve(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Zo(s)?br(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,mp())),ei(s),null;case 26:var d=s.type,f=s.memoizedState;return i===null?(br(s),f!==null?(ei(s),mS(s,f)):(ei(s),rm(s,d,null,l,a))):f?f!==i.memoizedState?(br(s),ei(s),mS(s,f)):(ei(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&br(s),ei(s),rm(s,d,i,l,a)),null;case 27:if(Be(s),a=Me.current,d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ei(s),null}i=Ce.current,Zo(s)?Yb(s):(i=w0(d,l,a),s.stateNode=i,br(s))}return ei(s),null;case 5:if(Be(s),d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ei(s),null}if(f=Ce.current,Zo(s))Yb(s);else{var _=nh(Me.current);switch(f){case 1:f=_.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:f=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":f=_.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":f=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":f=_.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?f.multiple=!0:l.size&&(f.size=l.size);break;default:f=typeof l.is=="string"?_.createElement(d,{is:l.is}):_.createElement(d)}}f[ri]=s,f[di]=l;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)f.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=f;e:switch(on(f,d,l),d){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&br(s)}}return ei(s),rm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=Me.current,Zo(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,d=sn,d!==null)switch(d.tag){case 27:case 5:l=d.memoizedProps}i[ri]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||d0(i.nodeValue,a)),i||ta(s,!0)}else i=nh(i).createTextNode(l),i[ri]=s,s.stateNode=i}return ei(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=Zo(s),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[ri]=s}else ao(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ei(s),i=!1}else a=mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Hn(s),s):(Hn(s),null);if((s.flags&128)!==0)throw Error(r(558))}return ei(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=Zo(s),l!==null&&l.dehydrated!==null){if(i===null){if(!d)throw Error(r(318));if(d=s.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[ri]=s}else ao(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ei(s),d=!1}else d=mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return s.flags&256?(Hn(s),s):(Hn(s),null)}return Hn(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,d=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(d=l.alternate.memoizedState.cachePool.pool),f=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(f=l.memoizedState.cachePool.pool),f!==d&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Fd(s,s.updateQueue),ei(s),null);case 4:return Ve(),i===null&&Em(s.stateNode.containerInfo),ei(s),null;case 10:return mr(s.type),ei(s),null;case 19:if(W(Si),l=s.memoizedState,l===null)return ei(s),null;if(d=(s.flags&128)!==0,f=l.rendering,f===null)if(d)xc(l,!1);else{if(pi!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(f=Rd(i),f!==null){for(s.flags|=128,xc(l,!1),i=f.updateQueue,s.updateQueue=i,Fd(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)Kb(a,i),a=a.sibling;return ue(Si,Si.current&1|2),Ct&&fr(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&et()>Vd&&(s.flags|=128,d=!0,xc(l,!1),s.lanes=4194304)}else{if(!d)if(i=Rd(f),i!==null){if(s.flags|=128,d=!0,i=i.updateQueue,s.updateQueue=i,Fd(s,i),xc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!f.alternate&&!Ct)return ei(s),null}else 2*et()-l.renderingStartTime>Vd&&a!==536870912&&(s.flags|=128,d=!0,xc(l,!1),s.lanes=4194304);l.isBackwards?(f.sibling=s.child,s.child=f):(i=l.last,i!==null?i.sibling=f:s.child=f,l.last=f)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=et(),i.sibling=null,a=Si.current,ue(Si,d?a&1|2:a&1),Ct&&fr(s,l.treeForkCount),i):(ei(s),null);case 22:case 23:return Hn(s),Dp(),l=s.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(ei(s),s.subtreeFlags&6&&(s.flags|=8192)):ei(s),a=s.updateQueue,a!==null&&Fd(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),i!==null&&W(co),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),mr(Ti),ei(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function aE(i,s){switch(fp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return mr(Ti),Ve(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return Be(s),null;case 31:if(s.memoizedState!==null){if(Hn(s),s.alternate===null)throw Error(r(340));ao()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Hn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));ao()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return W(Si),null;case 4:return Ve(),null;case 10:return mr(s.type),null;case 22:case 23:return Hn(s),Dp(),i!==null&&W(co),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return mr(Ti),null;case 25:return null;default:return null}}function gS(i,s){switch(fp(s),s.tag){case 3:mr(Ti),Ve();break;case 26:case 27:case 5:Be(s);break;case 4:Ve();break;case 31:s.memoizedState!==null&&Hn(s);break;case 13:Hn(s);break;case 19:W(Si);break;case 10:mr(s.type);break;case 22:case 23:Hn(s),Dp(),i!==null&&W(co);break;case 24:mr(Ti)}}function kc(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var d=l.next;a=d;do{if((a.tag&i)===i){l=void 0;var f=a.create,_=a.inst;l=f(),_.destroy=l}a=a.next}while(a!==d)}}catch(T){jt(s,s.return,T)}}function la(i,s,a){try{var l=s.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var f=d.next;l=f;do{if((l.tag&i)===i){var _=l.inst,T=_.destroy;if(T!==void 0){_.destroy=void 0,d=s;var O=a,J=T;try{J()}catch(fe){jt(d,O,fe)}}}l=l.next}while(l!==f)}}catch(fe){jt(s,s.return,fe)}}function vS(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{oy(s,a)}catch(l){jt(i,i.return,l)}}}function _S(i,s,a){a.props=mo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){jt(i,s,l)}}function Tc(i,s){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(d){jt(i,s,d)}}function $s(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(d){jt(i,s,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(d){jt(i,s,d)}else a.current=null}function bS(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){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(d){jt(i,i.return,d)}}function am(i,s,a){try{var l=i.stateNode;DE(l,i.type,a,s),l[di]=s}catch(d){jt(i,i.return,d)}}function yS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ma(i.type)||i.tag===4}function om(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||yS(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&&ma(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 lm(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Qn));else if(l!==4&&(l===27&&ma(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(lm(i,s,a),i=i.sibling;i!==null;)lm(i,s,a),i=i.sibling}function Kd(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(l!==4&&(l===27&&ma(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Kd(i,s,a),i=i.sibling;i!==null;)Kd(i,s,a),i=i.sibling}function SS(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,d=s.attributes;d.length;)s.removeAttributeNode(d[0]);on(s,l,a),s[ri]=i,s[di]=a}catch(f){jt(i,i.return,f)}}var yr=!1,Ri=!1,cm=!1,wS=typeof WeakSet=="function"?WeakSet:Set,$i=null;function oE(i,s){if(i=i.containerInfo,Mm=uh,i=pd(i),no(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 d=l.anchorOffset,f=l.focusNode;l=l.focusOffset;try{a.nodeType,f.nodeType}catch{a=null;break e}var _=0,T=-1,O=-1,J=0,fe=0,ve=i,te=null;t:for(;;){for(var ce;ve!==a||d!==0&&ve.nodeType!==3||(T=_+d),ve!==f||l!==0&&ve.nodeType!==3||(O=_+l),ve.nodeType===3&&(_+=ve.nodeValue.length),(ce=ve.firstChild)!==null;)te=ve,ve=ce;for(;;){if(ve===i)break t;if(te===a&&++J===d&&(T=_),te===f&&++fe===l&&(O=_),(ce=ve.nextSibling)!==null)break;ve=te,te=ve.parentNode}ve=ce}a=T===-1||O===-1?null:{start:T,end:O}}else a=null}a=a||{start:0,end:0}}else a=null;for(Nm={focusedElem:i,selectionRange:a},uh=!1,$i=s;$i!==null;)if(s=$i,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,$i=i;else for(;$i!==null;){switch(s=$i,f=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)d=i[a],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&f!==null){i=void 0,a=s,d=f.memoizedProps,f=f.memoizedState,l=a.stateNode;try{var Fe=mo(a.type,d);i=l.getSnapshotBeforeUpdate(Fe,f),l.__reactInternalSnapshotBeforeUpdate=i}catch(Qe){jt(a,a.return,Qe)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Om(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Om(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(r(163))}if(i=s.sibling,i!==null){i.return=s.return,$i=i;break}$i=s.return}}function CS(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:wr(i,a),l&4&&kc(5,a);break;case 1:if(wr(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(_){jt(a,a.return,_)}else{var d=mo(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(d,s,i.__reactInternalSnapshotBeforeUpdate)}catch(_){jt(a,a.return,_)}}l&64&&vS(a),l&512&&Tc(a,a.return);break;case 3:if(wr(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{oy(i,s)}catch(_){jt(a,a.return,_)}}break;case 27:s===null&&l&4&&SS(a);case 26:case 5:wr(i,a),s===null&&l&4&&bS(a),l&512&&Tc(a,a.return);break;case 12:wr(i,a);break;case 31:wr(i,a),l&4&&TS(i,a);break;case 13:wr(i,a),l&4&&ES(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=gE.bind(null,a),jE(i,a))));break;case 22:if(l=a.memoizedState!==null||yr,!l){s=s!==null&&s.memoizedState!==null||Ri,d=yr;var f=Ri;yr=l,(Ri=s)&&!f?Cr(i,a,(a.subtreeFlags&8772)!==0):wr(i,a),yr=d,Ri=f}break;case 30:break;default:wr(i,a)}}function xS(i){var s=i.alternate;s!==null&&(i.alternate=null,xS(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&qa(s)),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 ii=null,Nn=!1;function Sr(i,s,a){for(a=a.child;a!==null;)kS(i,s,a),a=a.sibling}function kS(i,s,a){if(Ge&&typeof Ge.onCommitFiberUnmount=="function")try{Ge.onCommitFiberUnmount(tt,a)}catch{}switch(a.tag){case 26:Ri||$s(a,s),Sr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ri||$s(a,s);var l=ii,d=Nn;ma(a.type)&&(ii=a.stateNode,Nn=!1),Sr(i,s,a),Bc(a.stateNode),ii=l,Nn=d;break;case 5:Ri||$s(a,s);case 6:if(l=ii,d=Nn,ii=null,Sr(i,s,a),ii=l,Nn=d,ii!==null)if(Nn)try{(ii.nodeType===9?ii.body:ii.nodeName==="HTML"?ii.ownerDocument.body:ii).removeChild(a.stateNode)}catch(f){jt(a,s,f)}else try{ii.removeChild(a.stateNode)}catch(f){jt(a,s,f)}break;case 18:ii!==null&&(Nn?(i=ii,v0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),_l(i)):v0(ii,a.stateNode));break;case 4:l=ii,d=Nn,ii=a.stateNode.containerInfo,Nn=!0,Sr(i,s,a),ii=l,Nn=d;break;case 0:case 11:case 14:case 15:la(2,a,s),Ri||la(4,a,s),Sr(i,s,a);break;case 1:Ri||($s(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&_S(a,s,l)),Sr(i,s,a);break;case 21:Sr(i,s,a);break;case 22:Ri=(l=Ri)||a.memoizedState!==null,Sr(i,s,a),Ri=l;break;default:Sr(i,s,a)}}function TS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{_l(i)}catch(a){jt(s,s.return,a)}}}function ES(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{_l(i)}catch(a){jt(s,s.return,a)}}function lE(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new wS),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new wS),s;default:throw Error(r(435,i.tag))}}function Wd(i,s){var a=lE(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var d=vE.bind(null,i,l);l.then(d,d)}})}function An(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var d=a[l],f=i,_=s,T=_;e:for(;T!==null;){switch(T.tag){case 27:if(ma(T.type)){ii=T.stateNode,Nn=!1;break e}break;case 5:ii=T.stateNode,Nn=!1;break e;case 3:case 4:ii=T.stateNode.containerInfo,Nn=!0;break e}T=T.return}if(ii===null)throw Error(r(160));kS(f,_,d),ii=null,Nn=!1,f=d.alternate,f!==null&&(f.return=null),d.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)DS(s,i),s=s.sibling}var ks=null;function DS(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:An(s,i),Ln(i),l&4&&(la(3,i,i.return),kc(3,i),la(5,i,i.return));break;case 1:An(s,i),Ln(i),l&512&&(Ri||a===null||$s(a,a.return)),l&64&&yr&&(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 d=ks;if(An(s,i),Ln(i),l&512&&(Ri||a===null||$s(a,a.return)),l&4){var f=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,d=d.ownerDocument||d;t:switch(l){case"title":f=d.getElementsByTagName("title")[0],(!f||f[Yn]||f[ri]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=d.createElement(l),d.head.insertBefore(f,d.querySelector("head > title"))),on(f,l,a),f[ri]=i,Pt(f),l=f;break e;case"link":var _=D0("link","href",d).get(l+(a.href||""));if(_){for(var T=0;T<_.length;T++)if(f=_[T],f.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&f.getAttribute("rel")===(a.rel==null?null:a.rel)&&f.getAttribute("title")===(a.title==null?null:a.title)&&f.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(T,1);break t}}f=d.createElement(l),on(f,l,a),d.head.appendChild(f);break;case"meta":if(_=D0("meta","content",d).get(l+(a.content||""))){for(T=0;T<_.length;T++)if(f=_[T],f.getAttribute("content")===(a.content==null?null:""+a.content)&&f.getAttribute("name")===(a.name==null?null:a.name)&&f.getAttribute("property")===(a.property==null?null:a.property)&&f.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&f.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(T,1);break t}}f=d.createElement(l),on(f,l,a),d.head.appendChild(f);break;default:throw Error(r(468,l))}f[ri]=i,Pt(f),l=f}i.stateNode=l}else R0(d,i.type,i.stateNode);else i.stateNode=E0(d,l,i.memoizedProps);else f!==l?(f===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):f.count--,l===null?R0(d,i.type,i.stateNode):E0(d,l,i.memoizedProps)):l===null&&i.stateNode!==null&&am(i,i.memoizedProps,a.memoizedProps)}break;case 27:An(s,i),Ln(i),l&512&&(Ri||a===null||$s(a,a.return)),a!==null&&l&4&&am(i,i.memoizedProps,a.memoizedProps);break;case 5:if(An(s,i),Ln(i),l&512&&(Ri||a===null||$s(a,a.return)),i.flags&32){d=i.stateNode;try{tn(d,"")}catch(Fe){jt(i,i.return,Fe)}}l&4&&i.stateNode!=null&&(d=i.memoizedProps,am(i,d,a!==null?a.memoizedProps:d)),l&1024&&(cm=!0);break;case 6:if(An(s,i),Ln(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Fe){jt(i,i.return,Fe)}}break;case 3:if(ah=null,d=ks,ks=sh(s.containerInfo),An(s,i),ks=d,Ln(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{_l(s.containerInfo)}catch(Fe){jt(i,i.return,Fe)}cm&&(cm=!1,RS(i));break;case 4:l=ks,ks=sh(i.stateNode.containerInfo),An(s,i),Ln(i),ks=l;break;case 12:An(s,i),Ln(i);break;case 31:An(s,i),Ln(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 13:An(s,i),Ln(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(qd=et()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 22:d=i.memoizedState!==null;var O=a!==null&&a.memoizedState!==null,J=yr,fe=Ri;if(yr=J||d,Ri=fe||O,An(s,i),Ri=fe,yr=J,Ln(i),l&8192)e:for(s=i.stateNode,s._visibility=d?s._visibility&-2:s._visibility|1,d&&(a===null||O||yr||Ri||go(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){O=a=s;try{if(f=O.stateNode,d)_=f.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{T=O.stateNode;var ve=O.memoizedProps.style,te=ve!=null&&ve.hasOwnProperty("display")?ve.display:null;T.style.display=te==null||typeof te=="boolean"?"":(""+te).trim()}}catch(Fe){jt(O,O.return,Fe)}}}else if(s.tag===6){if(a===null){O=s;try{O.stateNode.nodeValue=d?"":O.memoizedProps}catch(Fe){jt(O,O.return,Fe)}}}else if(s.tag===18){if(a===null){O=s;try{var ce=O.stateNode;d?_0(ce,!0):_0(O.stateNode,!1)}catch(Fe){jt(O,O.return,Fe)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Wd(i,a))));break;case 19:An(s,i),Ln(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 30:break;case 21:break;default:An(s,i),Ln(i)}}function Ln(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(yS(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var d=a.stateNode,f=om(i);Kd(i,f,d);break;case 5:var _=a.stateNode;a.flags&32&&(tn(_,""),a.flags&=-33);var T=om(i);Kd(i,T,_);break;case 3:case 4:var O=a.stateNode.containerInfo,J=om(i);lm(i,J,O);break;default:throw Error(r(161))}}catch(fe){jt(i,i.return,fe)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function RS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;RS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function wr(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)CS(i,s.alternate,s),s=s.sibling}function go(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:la(4,s,s.return),go(s);break;case 1:$s(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&_S(s,s.return,a),go(s);break;case 27:Bc(s.stateNode);case 26:case 5:$s(s,s.return),go(s);break;case 22:s.memoizedState===null&&go(s);break;case 30:go(s);break;default:go(s)}i=i.sibling}}function Cr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,d=i,f=s,_=f.flags;switch(f.tag){case 0:case 11:case 15:Cr(d,f,a),kc(4,f);break;case 1:if(Cr(d,f,a),l=f,d=l.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(J){jt(l,l.return,J)}if(l=f,d=l.updateQueue,d!==null){var T=l.stateNode;try{var O=d.shared.hiddenCallbacks;if(O!==null)for(d.shared.hiddenCallbacks=null,d=0;d<O.length;d++)ay(O[d],T)}catch(J){jt(l,l.return,J)}}a&&_&64&&vS(f),Tc(f,f.return);break;case 27:SS(f);case 26:case 5:Cr(d,f,a),a&&l===null&&_&4&&bS(f),Tc(f,f.return);break;case 12:Cr(d,f,a);break;case 31:Cr(d,f,a),a&&_&4&&TS(d,f);break;case 13:Cr(d,f,a),a&&_&4&&ES(d,f);break;case 22:f.memoizedState===null&&Cr(d,f,a),Tc(f,f.return);break;case 30:break;default:Cr(d,f,a)}s=s.sibling}}function um(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&hc(a))}function dm(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&hc(i))}function Ts(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)MS(i,s,a,l),s=s.sibling}function MS(i,s,a,l){var d=s.flags;switch(s.tag){case 0:case 11:case 15:Ts(i,s,a,l),d&2048&&kc(9,s);break;case 1:Ts(i,s,a,l);break;case 3:Ts(i,s,a,l),d&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&hc(i)));break;case 12:if(d&2048){Ts(i,s,a,l),i=s.stateNode;try{var f=s.memoizedProps,_=f.id,T=f.onPostCommit;typeof T=="function"&&T(_,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(O){jt(s,s.return,O)}}else Ts(i,s,a,l);break;case 31:Ts(i,s,a,l);break;case 13:Ts(i,s,a,l);break;case 23:break;case 22:f=s.stateNode,_=s.alternate,s.memoizedState!==null?f._visibility&2?Ts(i,s,a,l):Ec(i,s):f._visibility&2?Ts(i,s,a,l):(f._visibility|=2,ol(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),d&2048&&um(_,s);break;case 24:Ts(i,s,a,l),d&2048&&dm(s.alternate,s);break;default:Ts(i,s,a,l)}}function ol(i,s,a,l,d){for(d=d&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var f=i,_=s,T=a,O=l,J=_.flags;switch(_.tag){case 0:case 11:case 15:ol(f,_,T,O,d),kc(8,_);break;case 23:break;case 22:var fe=_.stateNode;_.memoizedState!==null?fe._visibility&2?ol(f,_,T,O,d):Ec(f,_):(fe._visibility|=2,ol(f,_,T,O,d)),d&&J&2048&&um(_.alternate,_);break;case 24:ol(f,_,T,O,d),d&&J&2048&&dm(_.alternate,_);break;default:ol(f,_,T,O,d)}s=s.sibling}}function Ec(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,d=l.flags;switch(l.tag){case 22:Ec(a,l),d&2048&&um(l.alternate,l);break;case 24:Ec(a,l),d&2048&&dm(l.alternate,l);break;default:Ec(a,l)}s=s.sibling}}var Dc=8192;function ll(i,s,a){if(i.subtreeFlags&Dc)for(i=i.child;i!==null;)NS(i,s,a),i=i.sibling}function NS(i,s,a){switch(i.tag){case 26:ll(i,s,a),i.flags&Dc&&i.memoizedState!==null&&YE(a,ks,i.memoizedState,i.memoizedProps);break;case 5:ll(i,s,a);break;case 3:case 4:var l=ks;ks=sh(i.stateNode.containerInfo),ll(i,s,a),ks=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Dc,Dc=16777216,ll(i,s,a),Dc=l):ll(i,s,a));break;default:ll(i,s,a)}}function AS(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Rc(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,OS(l,i)}AS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)LS(i),i=i.sibling}function LS(i){switch(i.tag){case 0:case 11:case 15:Rc(i),i.flags&2048&&la(9,i,i.return);break;case 3:Rc(i);break;case 12:Rc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,$d(i)):Rc(i);break;default:Rc(i)}}function $d(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,OS(l,i)}AS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:la(8,s,s.return),$d(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,$d(s));break;default:$d(s)}i=i.sibling}}function OS(i,s){for(;$i!==null;){var a=$i;switch(a.tag){case 0:case 11:case 15:la(8,a,s);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:hc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,$i=l;else e:for(a=i;$i!==null;){l=$i;var d=l.sibling,f=l.return;if(xS(l),l===a){$i=null;break e}if(d!==null){d.return=f,$i=d;break e}$i=f}}}var cE={getCacheForType:function(i){var s=rn(Ti),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return rn(Ti).controller.signal}},uE=typeof WeakMap=="function"?WeakMap:Map,Rt=0,Xt=null,_t=null,St=0,Bt=0,Un=null,ca=!1,cl=!1,hm=!1,xr=0,pi=0,ua=0,vo=0,fm=0,Fn=0,ul=0,Mc=null,On=null,pm=!1,qd=0,BS=0,Vd=1/0,Yd=null,da=null,Bi=0,ha=null,dl=null,kr=0,mm=0,gm=null,jS=null,Nc=0,vm=null;function Kn(){return(Rt&2)!==0&&St!==0?St&-St:L.T!==null?Cm():si()}function IS(){if(Fn===0)if((St&536870912)===0||Ct){var i=mt;mt<<=1,(mt&3932160)===0&&(mt=262144),Fn=i}else Fn=536870912;return i=Pn.current,i!==null&&(i.flags|=32),Fn}function Bn(i,s,a){(i===Xt&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)&&(hl(i,0),fa(i,St,Fn,!1)),xi(i,a),((Rt&2)===0||i!==Xt)&&(i===Xt&&((Rt&2)===0&&(vo|=a),pi===4&&fa(i,St,Fn,!1)),qs(i))}function zS(i,s,a){if((Rt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Wt(i,s),d=l?fE(i,s):bm(i,s,!0),f=l;do{if(d===0){cl&&!l&&fa(i,s,0,!1);break}else{if(a=i.current.alternate,f&&!dE(a)){d=bm(i,s,!1),f=!1;continue}if(d===2){if(f=s,i.errorRecoveryDisabledLanes&f)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var T=i;d=Mc;var O=T.current.memoizedState.isDehydrated;if(O&&(hl(T,_).flags|=256),_=bm(T,_,!1),_!==2){if(hm&&!O){T.errorRecoveryDisabledLanes|=f,vo|=f,d=4;break e}f=On,On=d,f!==null&&(On===null?On=f:On.push.apply(On,f))}d=_}if(f=!1,d!==2)continue}}if(d===1){hl(i,0),fa(i,s,0,!0);break}e:{switch(l=i,f=d,f){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:fa(l,s,Fn,!ca);break e;case 2:On=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(d=qd+300-et(),10<d)){if(fa(l,s,Fn,!ca),Nt(l,0,!0)!==0)break e;kr=s,l.timeoutHandle=m0(PS.bind(null,l,a,On,Yd,pm,s,Fn,vo,ul,ca,f,"Throttled",-0,0),d);break e}PS(l,a,On,Yd,pm,s,Fn,vo,ul,ca,f,null,-0,0)}}break}while(!0);qs(i)}function PS(i,s,a,l,d,f,_,T,O,J,fe,ve,te,ce){if(i.timeoutHandle=-1,ve=s.subtreeFlags,ve&8192||(ve&16785408)===16785408){ve={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Qn},NS(s,f,ve);var Fe=(f&62914560)===f?qd-et():(f&4194048)===f?BS-et():0;if(Fe=XE(ve,Fe),Fe!==null){kr=f,i.cancelPendingCommit=Fe(VS.bind(null,i,s,f,a,l,d,_,T,O,fe,ve,null,te,ce)),fa(i,f,_,!J);return}}VS(i,s,f,a,l,d,_,T,O)}function dE(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var d=a[l],f=d.getSnapshot;d=d.value;try{if(!wn(f(),d))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function fa(i,s,a,l){s&=~fm,s&=~vo,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var d=s;0<d;){var f=31-ot(d),_=1<<f;l[f]=-1,d&=~_}a!==0&&un(i,a,s)}function Xd(){return(Rt&6)===0?(Ac(0),!1):!0}function _m(){if(_t!==null){if(Bt===0)var i=_t.return;else i=_t,pr=oo=null,Op(i),il=null,pc=0,i=_t;for(;i!==null;)gS(i.alternate,i),i=i.return;_t=null}}function hl(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,NE(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),kr=0,_m(),Xt=i,_t=a=hr(i.current,null),St=s,Bt=0,Un=null,ca=!1,cl=Wt(i,s),hm=!1,ul=Fn=fm=vo=ua=pi=0,On=Mc=null,pm=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var d=31-ot(l),f=1<<d;s|=i[d],l&=~f}return xr=s,gd(),a}function HS(i,s){ct=null,L.H=wc,s===tl||s===xd?(s=iy(),Bt=3):s===wp?(s=iy(),Bt=4):Bt=s===Gp?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Un=s,_t===null&&(pi=1,zd(i,ns(s,i.current)))}function US(){var i=Pn.current;return i===null?!0:(St&4194048)===St?os===null:(St&62914560)===St||(St&536870912)!==0?i===os:!1}function FS(){var i=L.H;return L.H=wc,i===null?wc:i}function KS(){var i=L.A;return L.A=cE,i}function Gd(){pi=4,ca||(St&4194048)!==St&&Pn.current!==null||(cl=!0),(ua&134217727)===0&&(vo&134217727)===0||Xt===null||fa(Xt,St,Fn,!1)}function bm(i,s,a){var l=Rt;Rt|=2;var d=FS(),f=KS();(Xt!==i||St!==s)&&(Yd=null,hl(i,s)),s=!1;var _=pi;e:do try{if(Bt!==0&&_t!==null){var T=_t,O=Un;switch(Bt){case 8:_m(),_=6;break e;case 3:case 2:case 9:case 6:Pn.current===null&&(s=!0);var J=Bt;if(Bt=0,Un=null,fl(i,T,O,J),a&&cl){_=0;break e}break;default:J=Bt,Bt=0,Un=null,fl(i,T,O,J)}}hE(),_=pi;break}catch(fe){HS(i,fe)}while(!0);return s&&i.shellSuspendCounter++,pr=oo=null,Rt=l,L.H=d,L.A=f,_t===null&&(Xt=null,St=0,gd()),_}function hE(){for(;_t!==null;)WS(_t)}function fE(i,s){var a=Rt;Rt|=2;var l=FS(),d=KS();Xt!==i||St!==s?(Yd=null,Vd=et()+500,hl(i,s)):cl=Wt(i,s);e:do try{if(Bt!==0&&_t!==null){s=_t;var f=Un;t:switch(Bt){case 1:Bt=0,Un=null,fl(i,s,f,1);break;case 2:case 9:if(ey(f)){Bt=0,Un=null,$S(s);break}s=function(){Bt!==2&&Bt!==9||Xt!==i||(Bt=7),qs(i)},f.then(s,s);break e;case 3:Bt=7;break e;case 4:Bt=5;break e;case 7:ey(f)?(Bt=0,Un=null,$S(s)):(Bt=0,Un=null,fl(i,s,f,7));break;case 5:var _=null;switch(_t.tag){case 26:_=_t.memoizedState;case 5:case 27:var T=_t;if(_?M0(_):T.stateNode.complete){Bt=0,Un=null;var O=T.sibling;if(O!==null)_t=O;else{var J=T.return;J!==null?(_t=J,Zd(J)):_t=null}break t}}Bt=0,Un=null,fl(i,s,f,5);break;case 6:Bt=0,Un=null,fl(i,s,f,6);break;case 8:_m(),pi=6;break e;default:throw Error(r(462))}}pE();break}catch(fe){HS(i,fe)}while(!0);return pr=oo=null,L.H=l,L.A=d,Rt=a,_t!==null?0:(Xt=null,St=0,gd(),pi)}function pE(){for(;_t!==null&&!Ie();)WS(_t)}function WS(i){var s=pS(i.alternate,i,xr);i.memoizedProps=i.pendingProps,s===null?Zd(i):_t=s}function $S(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=lS(a,s,s.pendingProps,s.type,void 0,St);break;case 11:s=lS(a,s,s.pendingProps,s.type.render,s.ref,St);break;case 5:Op(s);default:gS(a,s),s=_t=Kb(s,xr),s=pS(a,s,xr)}i.memoizedProps=i.pendingProps,s===null?Zd(i):_t=s}function fl(i,s,a,l){pr=oo=null,Op(s),il=null,pc=0;var d=s.return;try{if(iE(i,d,s,a,St)){pi=1,zd(i,ns(a,i.current)),_t=null;return}}catch(f){if(d!==null)throw _t=d,f;pi=1,zd(i,ns(a,i.current)),_t=null;return}s.flags&32768?(Ct||l===1?i=!0:cl||(St&536870912)!==0?i=!1:(ca=i=!0,(l===2||l===9||l===3||l===6)&&(l=Pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),qS(s,i)):Zd(s)}function Zd(i){var s=i;do{if((s.flags&32768)!==0){qS(s,ca);return}i=s.return;var a=rE(s.alternate,s,xr);if(a!==null){_t=a;return}if(s=s.sibling,s!==null){_t=s;return}_t=s=i}while(s!==null);pi===0&&(pi=5)}function qS(i,s){do{var a=aE(i.alternate,i);if(a!==null){a.flags&=32767,_t=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){_t=i;return}_t=i=a}while(i!==null);pi=6,_t=null}function VS(i,s,a,l,d,f,_,T,O){i.cancelPendingCommit=null;do Qd();while(Bi!==0);if((Rt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(f=s.lanes|s.childLanes,f|=op,Lt(i,a,f,_,T,O),i===Xt&&(_t=Xt=null,St=0),dl=s,ha=i,kr=a,mm=f,gm=d,jS=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,_E(yt,function(){return QS(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=L.T,L.T=null,d=M.p,M.p=2,_=Rt,Rt|=4;try{oE(i,s,a)}finally{Rt=_,M.p=d,L.T=l}}Bi=1,YS(),XS(),GS()}}function YS(){if(Bi===1){Bi=0;var i=ha,s=dl,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=L.T,L.T=null;var l=M.p;M.p=2;var d=Rt;Rt|=4;try{DS(s,i);var f=Nm,_=pd(i.containerInfo),T=f.focusedElem,O=f.selectionRange;if(_!==T&&T&&T.ownerDocument&&fd(T.ownerDocument.documentElement,T)){if(O!==null&&no(T)){var J=O.start,fe=O.end;if(fe===void 0&&(fe=J),"selectionStart"in T)T.selectionStart=J,T.selectionEnd=Math.min(fe,T.value.length);else{var ve=T.ownerDocument||document,te=ve&&ve.defaultView||window;if(te.getSelection){var ce=te.getSelection(),Fe=T.textContent.length,Qe=Math.min(O.start,Fe),Ft=O.end===void 0?Qe:Math.min(O.end,Fe);!ce.extend&&Qe>Ft&&(_=Ft,Ft=Qe,Qe=_);var $=hd(T,Qe),H=hd(T,Ft);if($&&H&&(ce.rangeCount!==1||ce.anchorNode!==$.node||ce.anchorOffset!==$.offset||ce.focusNode!==H.node||ce.focusOffset!==H.offset)){var Z=ve.createRange();Z.setStart($.node,$.offset),ce.removeAllRanges(),Qe>Ft?(ce.addRange(Z),ce.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),ce.addRange(Z))}}}}for(ve=[],ce=T;ce=ce.parentNode;)ce.nodeType===1&&ve.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<ve.length;T++){var me=ve[T];me.element.scrollLeft=me.left,me.element.scrollTop=me.top}}uh=!!Mm,Nm=Mm=null}finally{Rt=d,M.p=l,L.T=a}}i.current=s,Bi=2}}function XS(){if(Bi===2){Bi=0;var i=ha,s=dl,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=L.T,L.T=null;var l=M.p;M.p=2;var d=Rt;Rt|=4;try{CS(i,s.alternate,s)}finally{Rt=d,M.p=l,L.T=a}}Bi=3}}function GS(){if(Bi===4||Bi===3){Bi=0,He();var i=ha,s=dl,a=kr,l=jS;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Bi=5:(Bi=0,dl=ha=null,ZS(i,i.pendingLanes));var d=i.pendingLanes;if(d===0&&(da=null),dn(a),s=s.stateNode,Ge&&typeof Ge.onCommitFiberRoot=="function")try{Ge.onCommitFiberRoot(tt,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=L.T,d=M.p,M.p=2,L.T=null;try{for(var f=i.onRecoverableError,_=0;_<l.length;_++){var T=l[_];f(T.value,{componentStack:T.stack})}}finally{L.T=s,M.p=d}}(kr&3)!==0&&Qd(),qs(i),d=i.pendingLanes,(a&261930)!==0&&(d&42)!==0?i===vm?Nc++:(Nc=0,vm=i):Nc=0,Ac(0)}}function ZS(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,hc(s)))}function Qd(){return YS(),XS(),GS(),QS()}function QS(){if(Bi!==5)return!1;var i=ha,s=mm;mm=0;var a=dn(kr),l=L.T,d=M.p;try{M.p=32>a?32:a,L.T=null,a=gm,gm=null;var f=ha,_=kr;if(Bi=0,dl=ha=null,kr=0,(Rt&6)!==0)throw Error(r(331));var T=Rt;if(Rt|=4,LS(f.current),MS(f,f.current,_,a),Rt=T,Ac(0,!1),Ge&&typeof Ge.onPostCommitFiberRoot=="function")try{Ge.onPostCommitFiberRoot(tt,f)}catch{}return!0}finally{M.p=d,L.T=l,ZS(i,s)}}function JS(i,s,a){s=ns(a,s),s=Xp(i.stateNode,s,2),i=ra(i,s,2),i!==null&&(xi(i,2),qs(i))}function jt(i,s,a){if(i.tag===3)JS(i,i,a);else for(;s!==null;){if(s.tag===3){JS(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(da===null||!da.has(l))){i=ns(a,i),a=eS(2),l=ra(s,a,2),l!==null&&(tS(a,l,s,i),xi(l,2),qs(l));break}}s=s.return}}function ym(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new uE;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(a)||(hm=!0,d.add(a),i=mE.bind(null,i,s,a),s.then(i,i))}function mE(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Xt===i&&(St&a)===a&&(pi===4||pi===3&&(St&62914560)===St&&300>et()-qd?(Rt&2)===0&&hl(i,0):fm|=a,ul===St&&(ul=0)),qs(i)}function e0(i,s){s===0&&(s=$t()),i=so(i,s),i!==null&&(xi(i,s),qs(i))}function gE(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),e0(i,a)}function vE(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,d=i.memoizedState;d!==null&&(a=d.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),e0(i,a)}function _E(i,s){return he(i,s)}var Jd=null,pl=null,Sm=!1,eh=!1,wm=!1,pa=0;function qs(i){i!==pl&&i.next===null&&(pl===null?Jd=pl=i:pl=pl.next=i),eh=!0,Sm||(Sm=!0,yE())}function Ac(i,s){if(!wm&&eh){wm=!0;do for(var a=!1,l=Jd;l!==null;){if(i!==0){var d=l.pendingLanes;if(d===0)var f=0;else{var _=l.suspendedLanes,T=l.pingedLanes;f=(1<<31-ot(42|i)+1)-1,f&=d&~(_&~T),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(a=!0,s0(l,f))}else f=St,f=Nt(l,l===Xt?f:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(f&3)===0||Wt(l,f)||(a=!0,s0(l,f));l=l.next}while(a);wm=!1}}function bE(){t0()}function t0(){eh=Sm=!1;var i=0;pa!==0&&ME()&&(i=pa);for(var s=et(),a=null,l=Jd;l!==null;){var d=l.next,f=i0(l,s);f===0?(l.next=null,a===null?Jd=d:a.next=d,d===null&&(pl=a)):(a=l,(i!==0||(f&3)!==0)&&(eh=!0)),l=d}Bi!==0&&Bi!==5||Ac(i),pa!==0&&(pa=0)}function i0(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,d=i.expirationTimes,f=i.pendingLanes&-62914561;0<f;){var _=31-ot(f),T=1<<_,O=d[_];O===-1?((T&a)===0||(T&l)!==0)&&(d[_]=ui(T,s)):O<=s&&(i.expiredLanes|=T),f&=~T}if(s=Xt,a=St,a=Nt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&je(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Wt(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&je(l),dn(a)){case 2:case 8:a=kt;break;case 32:a=yt;break;case 268435456:a=ci;break;default:a=yt}return l=n0.bind(null,i),a=he(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&je(l),i.callbackPriority=2,i.callbackNode=null,2}function n0(i,s){if(Bi!==0&&Bi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Qd()&&i.callbackNode!==a)return null;var l=St;return l=Nt(i,i===Xt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(zS(i,l,s),i0(i,et()),i.callbackNode!=null&&i.callbackNode===a?n0.bind(null,i):null)}function s0(i,s){if(Qd())return null;zS(i,s,!0)}function yE(){AE(function(){(Rt&6)!==0?he(pt,bE):t0()})}function Cm(){if(pa===0){var i=Jo;i===0&&(i=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),pa=i}return pa}function r0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:ys(""+i)}function a0(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function SE(i,s,a,l,d){if(s==="submit"&&a&&a.stateNode===d){var f=r0((d[di]||null).action),_=l.submitter;_&&(s=(s=_[di]||null)?r0(s.formAction):_.getAttribute("formAction"),s!==null&&(f=s,_=null));var T=new Ki("action","action",null,l,d);i.push({event:T,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(pa!==0){var O=_?a0(d,_):new FormData(d);Kp(a,{pending:!0,data:O,method:d.method,action:f},null,O)}}else typeof f=="function"&&(T.preventDefault(),O=_?a0(d,_):new FormData(d),Kp(a,{pending:!0,data:O,method:d.method,action:f},f,O))},currentTarget:d}]})}}for(var xm=0;xm<ap.length;xm++){var km=ap[xm],wE=km.toLowerCase(),CE=km[0].toUpperCase()+km.slice(1);xs(wE,"on"+CE)}xs(Yt,"onAnimationEnd"),xs(Ot,"onAnimationIteration"),xs(At,"onAnimationStart"),xs("dblclick","onDoubleClick"),xs("focusin","onFocus"),xs("focusout","onBlur"),xs(Us,"onTransitionRun"),xs(qo,"onTransitionStart"),xs(Fs,"onTransitionCancel"),xs(lc,"onTransitionEnd"),Zn("onMouseEnter",["mouseout","mouseover"]),Zn("onMouseLeave",["mouseout","mouseover"]),Zn("onPointerEnter",["pointerout","pointerover"]),Zn("onPointerLeave",["pointerout","pointerover"]),Vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Vt("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(" "),xE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Lc));function o0(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],d=l.event;l=l.listeners;e:{var f=void 0;if(s)for(var _=l.length-1;0<=_;_--){var T=l[_],O=T.instance,J=T.currentTarget;if(T=T.listener,O!==f&&d.isPropagationStopped())break e;f=T,d.currentTarget=J;try{f(d)}catch(fe){md(fe)}d.currentTarget=null,f=O}else for(_=0;_<l.length;_++){if(T=l[_],O=T.instance,J=T.currentTarget,T=T.listener,O!==f&&d.isPropagationStopped())break e;f=T,d.currentTarget=J;try{f(d)}catch(fe){md(fe)}d.currentTarget=null,f=O}}}}function bt(i,s){var a=s[Hr];a===void 0&&(a=s[Hr]=new Set);var l=i+"__bubble";a.has(l)||(l0(s,i,2,!1),a.add(l))}function Tm(i,s,a){var l=0;s&&(l|=4),l0(a,i,l,s)}var th="_reactListening"+Math.random().toString(36).slice(2);function Em(i){if(!i[th]){i[th]=!0,Va.forEach(function(a){a!=="selectionchange"&&(xE.has(a)||Tm(a,!1,i),Tm(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[th]||(s[th]=!0,Tm("selectionchange",!1,s))}}function l0(i,s,a,l){switch(I0(s)){case 2:var d=QE;break;case 8:d=JE;break;default:d=Fm}a=d.bind(null,s,a,i),d=void 0,!Yr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),l?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function Dm(i,s,a,l,d){var f=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var T=l.stateNode.containerInfo;if(T===d)break;if(_===4)for(_=l.return;_!==null;){var O=_.tag;if((O===3||O===4)&&_.stateNode.containerInfo===d)return;_=_.return}for(;T!==null;){if(_=Xn(T),_===null)return;if(O=_.tag,O===5||O===6||O===26||O===27){l=f=_;continue e}T=T.parentNode}}l=l.return}js(function(){var J=f,fe=Ga(a),ve=[];e:{var te=cc.get(i);if(te!==void 0){var ce=Ki,Fe=i;switch(i){case"keypress":if(or(a)===0)break e;case"keydown":case"keyup":ce=Xf;break;case"focusin":Fe="focus",ce=Re;break;case"focusout":Fe="blur",ce=Re;break;case"beforeblur":case"afterblur":ce=Re;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":ce=P;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=we;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=Gf;break;case Yt:case Ot:case At:ce=rt;break;case lc:ce=lr;break;case"scroll":case"scrollend":ce=Zl;break;case"wheel":ce=Zf;break;case"copy":case"cut":case"paste":ce=Wi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=Ql;break;case"toggle":case"beforetoggle":ce=Jf}var Qe=(s&4)!==0,Ft=!Qe&&(i==="scroll"||i==="scrollend"),$=Qe?te!==null?te+"Capture":null:te;Qe=[];for(var H=J,Z;H!==null;){var me=H;if(Z=me.stateNode,me=me.tag,me!==5&&me!==26&&me!==27||Z===null||$===null||(me=Rn(H,$),me!=null&&Qe.push(Oc(H,me,Z))),Ft)break;H=H.return}0<Qe.length&&(te=new ce(te,Fe,null,a,fe),ve.push({event:te,listeners:Qe}))}}if((s&7)===0){e:{if(te=i==="mouseover"||i==="pointerover",ce=i==="mouseout"||i==="pointerout",te&&a!==Ui&&(Fe=a.relatedTarget||a.fromElement)&&(Xn(Fe)||Fe[bn]))break e;if((ce||te)&&(te=fe.window===fe?fe:(te=fe.ownerDocument)?te.defaultView||te.parentWindow:window,ce?(Fe=a.relatedTarget||a.toElement,ce=J,Fe=Fe?Xn(Fe):null,Fe!==null&&(Ft=c(Fe),Qe=Fe.tag,Fe!==Ft||Qe!==5&&Qe!==27&&Qe!==6)&&(Fe=null)):(ce=null,Fe=J),ce!==Fe)){if(Qe=P,me="onMouseLeave",$="onMouseEnter",H="mouse",(i==="pointerout"||i==="pointerover")&&(Qe=Ql,me="onPointerLeave",$="onPointerEnter",H="pointer"),Ft=ce==null?te:Gn(ce),Z=Fe==null?te:Gn(Fe),te=new Qe(me,H+"leave",ce,a,fe),te.target=Ft,te.relatedTarget=Z,me=null,Xn(fe)===J&&(Qe=new Qe($,H+"enter",Fe,a,fe),Qe.target=Z,Qe.relatedTarget=Ft,me=Qe),Ft=me,ce&&Fe)t:{for(Qe=kE,$=ce,H=Fe,Z=0,me=$;me;me=Qe(me))Z++;me=0;for(var Xe=H;Xe;Xe=Qe(Xe))me++;for(;0<Z-me;)$=Qe($),Z--;for(;0<me-Z;)H=Qe(H),me--;for(;Z--;){if($===H||H!==null&&$===H.alternate){Qe=$;break t}$=Qe($),H=Qe(H)}Qe=null}else Qe=null;ce!==null&&c0(ve,te,ce,Qe,!1),Fe!==null&&Ft!==null&&c0(ve,Ft,Fe,Qe,!0)}}e:{if(te=J?Gn(J):window,ce=te.nodeName&&te.nodeName.toLowerCase(),ce==="select"||ce==="input"&&te.type==="file")var Tt=ac;else if(eo(te))if(cd)Tt=np;else{Tt=ip;var We=tp}else ce=te.nodeName,!ce||ce.toLowerCase()!=="input"||te.type!=="checkbox"&&te.type!=="radio"?J&&rr(J.elementType)&&(Tt=ac):Tt=ur;if(Tt&&(Tt=Tt(i,J))){rc(ve,Tt,a,fe);break e}We&&We(i,te,J),i==="focusout"&&J&&te.type==="number"&&J.memoizedProps.value!=null&&qr(te,"number",te.value)}switch(We=J?Gn(J):window,i){case"focusin":(eo(We)||We.contentEditable==="true")&&(dr=We,k=J,I=null);break;case"focusout":I=k=dr=null;break;case"mousedown":Ee=!0;break;case"contextmenu":case"mouseup":case"dragend":Ee=!1,$e(ve,a,fe);break;case"selectionchange":if(rp)break;case"keydown":case"keyup":$e(ve,a,fe)}var dt;if(Ja)e:{switch(i){case"compositionstart":var wt="onCompositionStart";break e;case"compositionend":wt="onCompositionEnd";break e;case"compositionupdate":wt="onCompositionUpdate";break e}wt=void 0}else Gr?nc(i,a)&&(wt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(wt="onCompositionStart");wt&&(tc&&a.locale!=="ko"&&(Gr||wt!=="onCompositionStart"?wt==="onCompositionEnd"&&Gr&&(dt=Xr()):(Mn=fe,Is="value"in Mn?Mn.value:Mn.textContent,Gr=!0)),We=ih(J,wt),0<We.length&&(wt=new pn(wt,i,null,a,fe),ve.push({event:wt,listeners:We}),dt?wt.data=dt:(dt=ad(a),dt!==null&&(wt.data=dt)))),(dt=Wo?ep(i,a):od(i,a))&&(wt=ih(J,"onBeforeInput"),0<wt.length&&(We=new pn("onBeforeInput","beforeinput",null,a,fe),ve.push({event:We,listeners:wt}),We.data=dt)),SE(ve,i,J,a,fe)}o0(ve,s)})}function Oc(i,s,a){return{instance:i,listener:s,currentTarget:a}}function ih(i,s){for(var a=s+"Capture",l=[];i!==null;){var d=i,f=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||f===null||(d=Rn(i,a),d!=null&&l.unshift(Oc(i,d,f)),d=Rn(i,s),d!=null&&l.push(Oc(i,d,f))),i.tag===3)return l;i=i.return}return[]}function kE(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function c0(i,s,a,l,d){for(var f=s._reactName,_=[];a!==null&&a!==l;){var T=a,O=T.alternate,J=T.stateNode;if(T=T.tag,O!==null&&O===l)break;T!==5&&T!==26&&T!==27||J===null||(O=J,d?(J=Rn(a,f),J!=null&&_.unshift(Oc(a,J,O))):d||(J=Rn(a,f),J!=null&&_.push(Oc(a,J,O)))),a=a.return}_.length!==0&&i.push({event:s,listeners:_})}var TE=/\r\n?/g,EE=/\u0000|\uFFFD/g;function u0(i){return(typeof i=="string"?i:""+i).replace(TE,`
|
|
10
|
+
`).replace(EE,"")}function d0(i,s){return s=u0(s),u0(i)===s}function Ut(i,s,a,l,d,f){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||tn(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&tn(i,""+l);break;case"className":Wr(i,"class",l);break;case"tabIndex":Wr(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Wr(i,a,l);break;case"style":bs(i,l,f);break;case"data":if(s!=="object"){Wr(i,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ys(""+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 f=="function"&&(a==="formAction"?(s!=="input"&&Ut(i,s,"name",d.name,d,null),Ut(i,s,"formEncType",d.formEncType,d,null),Ut(i,s,"formMethod",d.formMethod,d,null),Ut(i,s,"formTarget",d.formTarget,d,null)):(Ut(i,s,"encType",d.encType,d,null),Ut(i,s,"method",d.method,d,null),Ut(i,s,"target",d.target,d,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ys(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Qn);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(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=ys(""+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":bt("beforetoggle",i),bt("toggle",i),Ls(i,"popover",l);break;case"xlinkActuate":Sn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Sn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Sn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Sn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Sn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Sn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Sn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Sn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Sn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Ls(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=Fo.get(a)||a,Ls(i,a,l))}}function Rm(i,s,a,l,d,f){switch(a){case"style":bs(i,l,f);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?tn(i,l):(typeof l=="number"||typeof l=="bigint")&&tn(i,""+l);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Qn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Fr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(d=a.endsWith("Capture"),s=a.slice(2,d?a.length-7:void 0),f=i[di]||null,f=f!=null?f[a]:null,typeof f=="function"&&i.removeEventListener(s,f,d),typeof l=="function")){typeof f!="function"&&f!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,d);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Ls(i,a,l)}}}function on(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",i),bt("load",i);var l=!1,d=!1,f;for(f in a)if(a.hasOwnProperty(f)){var _=a[f];if(_!=null)switch(f){case"src":l=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ut(i,s,f,_,a,null)}}d&&Ut(i,s,"srcSet",a.srcSet,a,null),l&&Ut(i,s,"src",a.src,a,null);return;case"input":bt("invalid",i);var T=f=_=d=null,O=null,J=null;for(l in a)if(a.hasOwnProperty(l)){var fe=a[l];if(fe!=null)switch(l){case"name":d=fe;break;case"type":_=fe;break;case"checked":O=fe;break;case"defaultChecked":J=fe;break;case"value":f=fe;break;case"defaultValue":T=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,s));break;default:Ut(i,s,l,fe,a,null)}}Dn(i,f,T,O,J,_,d,!1);return;case"select":bt("invalid",i),l=_=f=null;for(d in a)if(a.hasOwnProperty(d)&&(T=a[d],T!=null))switch(d){case"value":f=T;break;case"defaultValue":_=T;break;case"multiple":l=T;default:Ut(i,s,d,T,a,null)}s=f,a=_,i.multiple=!!l,s!=null?nt(i,!!l,s,!1):a!=null&&nt(i,!!l,a,!0);return;case"textarea":bt("invalid",i),f=d=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(T=a[_],T!=null))switch(_){case"value":l=T;break;case"defaultValue":d=T;break;case"children":f=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:Ut(i,s,_,T,a,null)}sr(i,l,d,f);return;case"option":for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null)&&(O==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":Ut(i,s,O,l,a,null));return;case"dialog":bt("beforetoggle",i),bt("toggle",i),bt("cancel",i),bt("close",i);break;case"iframe":case"object":bt("load",i);break;case"video":case"audio":for(l=0;l<Lc.length;l++)bt(Lc[l],i);break;case"image":bt("error",i),bt("load",i);break;case"details":bt("toggle",i);break;case"embed":case"source":case"link":bt("error",i),bt("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(J in a)if(a.hasOwnProperty(J)&&(l=a[J],l!=null))switch(J){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ut(i,s,J,l,a,null)}return;default:if(rr(s)){for(fe in a)a.hasOwnProperty(fe)&&(l=a[fe],l!==void 0&&Rm(i,s,fe,l,a,void 0));return}}for(T in a)a.hasOwnProperty(T)&&(l=a[T],l!=null&&Ut(i,s,T,l,a,null))}function DE(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,f=null,_=null,T=null,O=null,J=null,fe=null;for(ce in a){var ve=a[ce];if(a.hasOwnProperty(ce)&&ve!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":O=ve;default:l.hasOwnProperty(ce)||Ut(i,s,ce,null,l,ve)}}for(var te in l){var ce=l[te];if(ve=a[te],l.hasOwnProperty(te)&&(ce!=null||ve!=null))switch(te){case"type":f=ce;break;case"name":d=ce;break;case"checked":J=ce;break;case"defaultChecked":fe=ce;break;case"value":_=ce;break;case"defaultValue":T=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(r(137,s));break;default:ce!==ve&&Ut(i,s,te,ce,l,ve)}}$r(i,_,T,O,J,fe,f,d);return;case"select":ce=_=T=te=null;for(f in a)if(O=a[f],a.hasOwnProperty(f)&&O!=null)switch(f){case"value":break;case"multiple":ce=O;default:l.hasOwnProperty(f)||Ut(i,s,f,null,l,O)}for(d in l)if(f=l[d],O=a[d],l.hasOwnProperty(d)&&(f!=null||O!=null))switch(d){case"value":te=f;break;case"defaultValue":T=f;break;case"multiple":_=f;default:f!==O&&Ut(i,s,d,f,l,O)}s=T,a=_,l=ce,te!=null?nt(i,!!a,te,!1):!!l!=!!a&&(s!=null?nt(i,!!a,s,!0):nt(i,!!a,a?[]:"",!1));return;case"textarea":ce=te=null;for(T in a)if(d=a[T],a.hasOwnProperty(T)&&d!=null&&!l.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:Ut(i,s,T,null,l,d)}for(_ in l)if(d=l[_],f=a[_],l.hasOwnProperty(_)&&(d!=null||f!=null))switch(_){case"value":te=d;break;case"defaultValue":ce=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==f&&Ut(i,s,_,d,l,f)}nr(i,te,ce);return;case"option":for(var Fe in a)te=a[Fe],a.hasOwnProperty(Fe)&&te!=null&&!l.hasOwnProperty(Fe)&&(Fe==="selected"?i.selected=!1:Ut(i,s,Fe,null,l,te));for(O in l)te=l[O],ce=a[O],l.hasOwnProperty(O)&&te!==ce&&(te!=null||ce!=null)&&(O==="selected"?i.selected=te&&typeof te!="function"&&typeof te!="symbol":Ut(i,s,O,te,l,ce));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 Qe in a)te=a[Qe],a.hasOwnProperty(Qe)&&te!=null&&!l.hasOwnProperty(Qe)&&Ut(i,s,Qe,null,l,te);for(J in l)if(te=l[J],ce=a[J],l.hasOwnProperty(J)&&te!==ce&&(te!=null||ce!=null))switch(J){case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(137,s));break;default:Ut(i,s,J,te,l,ce)}return;default:if(rr(s)){for(var Ft in a)te=a[Ft],a.hasOwnProperty(Ft)&&te!==void 0&&!l.hasOwnProperty(Ft)&&Rm(i,s,Ft,void 0,l,te);for(fe in l)te=l[fe],ce=a[fe],!l.hasOwnProperty(fe)||te===ce||te===void 0&&ce===void 0||Rm(i,s,fe,te,l,ce);return}}for(var $ in a)te=a[$],a.hasOwnProperty($)&&te!=null&&!l.hasOwnProperty($)&&Ut(i,s,$,null,l,te);for(ve in l)te=l[ve],ce=a[ve],!l.hasOwnProperty(ve)||te===ce||te==null&&ce==null||Ut(i,s,ve,te,l,ce)}function h0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function RE(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var d=a[l],f=d.transferSize,_=d.initiatorType,T=d.duration;if(f&&T&&h0(_)){for(_=0,T=d.responseEnd,l+=1;l<a.length;l++){var O=a[l],J=O.startTime;if(J>T)break;var fe=O.transferSize,ve=O.initiatorType;fe&&h0(ve)&&(O=O.responseEnd,_+=fe*(O<T?1:(T-J)/(O-J)))}if(--l,s+=8*(f+_)/(d.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Mm=null,Nm=null;function nh(i){return i.nodeType===9?i:i.ownerDocument}function f0(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 p0(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function Am(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Lm=null;function ME(){var i=window.event;return i&&i.type==="popstate"?i===Lm?!1:(Lm=i,!0):(Lm=null,!1)}var m0=typeof setTimeout=="function"?setTimeout:void 0,NE=typeof clearTimeout=="function"?clearTimeout:void 0,g0=typeof Promise=="function"?Promise:void 0,AE=typeof queueMicrotask=="function"?queueMicrotask:typeof g0<"u"?function(i){return g0.resolve(null).then(i).catch(LE)}:m0;function LE(i){setTimeout(function(){throw i})}function ma(i){return i==="head"}function v0(i,s){var a=s,l=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(d),_l(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Bc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Bc(a);for(var f=a.firstChild;f;){var _=f.nextSibling,T=f.nodeName;f[Yn]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&f.rel.toLowerCase()==="stylesheet"||a.removeChild(f),f=_}}else a==="body"&&Bc(i.ownerDocument.body);a=d}while(a);_l(s)}function _0(i,s){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(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 Om(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Om(a),qa(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function OE(i,s,a,l){for(;i.nodeType===1;){var d=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Yn])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(f=i.getAttribute("rel"),f==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(f!==d.rel||i.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||i.getAttribute("title")!==(d.title==null?null:d.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(f=i.getAttribute("src"),(f!==(d.src==null?null:d.src)||i.getAttribute("type")!==(d.type==null?null:d.type)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&f&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var f=d.name==null?null:""+d.name;if(d.type==="hidden"&&i.getAttribute("name")===f)return i}else return i;if(i=ls(i.nextSibling),i===null)break}return null}function BE(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ls(i.nextSibling),i===null))return null;return i}function b0(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=ls(i.nextSibling),i===null))return null;return i}function Bm(i){return i.data==="$?"||i.data==="$~"}function jm(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function jE(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function ls(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var Im=null;function y0(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return ls(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function S0(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function w0(i,s,a){switch(s=nh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Bc(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);qa(i)}var cs=new Map,C0=new Set;function sh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Tr=M.d;M.d={f:IE,r:zE,D:PE,C:HE,L:UE,m:FE,X:WE,S:KE,M:$E};function IE(){var i=Tr.f(),s=Xd();return i||s}function zE(i){var s=Ns(i);s!==null&&s.tag===5&&s.type==="form"?Hy(s):Tr.r(i)}var ml=typeof document>"u"?null:document;function x0(i,s,a){var l=ml;if(l&&typeof s=="string"&&s){var d=ki(s);d='link[rel="'+i+'"][href="'+d+'"]',typeof a=="string"&&(d+='[crossorigin="'+a+'"]'),C0.has(d)||(C0.add(d),i={rel:i,crossOrigin:a,href:s},l.querySelector(d)===null&&(s=l.createElement("link"),on(s,"link",i),Pt(s),l.head.appendChild(s)))}}function PE(i){Tr.D(i),x0("dns-prefetch",i,null)}function HE(i,s){Tr.C(i,s),x0("preconnect",i,s)}function UE(i,s,a){Tr.L(i,s,a);var l=ml;if(l&&i&&s){var d='link[rel="preload"][as="'+ki(s)+'"]';s==="image"&&a&&a.imageSrcSet?(d+='[imagesrcset="'+ki(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(d+='[imagesizes="'+ki(a.imageSizes)+'"]')):d+='[href="'+ki(i)+'"]';var f=d;switch(s){case"style":f=gl(i);break;case"script":f=vl(i)}cs.has(f)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),cs.set(f,i),l.querySelector(d)!==null||s==="style"&&l.querySelector(jc(f))||s==="script"&&l.querySelector(Ic(f))||(s=l.createElement("link"),on(s,"link",i),Pt(s),l.head.appendChild(s)))}}function FE(i,s){Tr.m(i,s);var a=ml;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+ki(l)+'"][href="'+ki(i)+'"]',f=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=vl(i)}if(!cs.has(f)&&(i=b({rel:"modulepreload",href:i},s),cs.set(f,i),a.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ic(f)))return}l=a.createElement("link"),on(l,"link",i),Pt(l),a.head.appendChild(l)}}}function KE(i,s,a){Tr.S(i,s,a);var l=ml;if(l&&i){var d=As(l).hoistableStyles,f=gl(i);s=s||"default";var _=d.get(f);if(!_){var T={loading:0,preload:null};if(_=l.querySelector(jc(f)))T.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=cs.get(f))&&zm(i,a);var O=_=l.createElement("link");Pt(O),on(O,"link",i),O._p=new Promise(function(J,fe){O.onload=J,O.onerror=fe}),O.addEventListener("load",function(){T.loading|=1}),O.addEventListener("error",function(){T.loading|=2}),T.loading|=4,rh(_,s,l)}_={type:"stylesheet",instance:_,count:1,state:T},d.set(f,_)}}}function WE(i,s){Tr.X(i,s);var a=ml;if(a&&i){var l=As(a).hoistableScripts,d=vl(i),f=l.get(d);f||(f=a.querySelector(Ic(d)),f||(i=b({src:i,async:!0},s),(s=cs.get(d))&&Pm(i,s),f=a.createElement("script"),Pt(f),on(f,"link",i),a.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(d,f))}}function $E(i,s){Tr.M(i,s);var a=ml;if(a&&i){var l=As(a).hoistableScripts,d=vl(i),f=l.get(d);f||(f=a.querySelector(Ic(d)),f||(i=b({src:i,async:!0,type:"module"},s),(s=cs.get(d))&&Pm(i,s),f=a.createElement("script"),Pt(f),on(f,"link",i),a.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(d,f))}}function k0(i,s,a,l){var d=(d=Me.current)?sh(d):null;if(!d)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=gl(a.href),a=As(d).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,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=gl(a.href);var f=As(d).hoistableStyles,_=f.get(i);if(_||(d=d.ownerDocument||d,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(i,_),(f=d.querySelector(jc(i)))&&!f._p&&(_.instance=f,_.state.loading=5),cs.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},cs.set(i,a),f||qE(d,i,a,_.state))),s&&l===null)throw Error(r(528,""));return _}if(s&&l!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=vl(a),a=As(d).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function gl(i){return'href="'+ki(i)+'"'}function jc(i){return'link[rel="stylesheet"]['+i+"]"}function T0(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function qE(i,s,a,l){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=i.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),on(s,"link",a),Pt(s),i.head.appendChild(s))}function vl(i){return'[src="'+ki(i)+'"]'}function Ic(i){return"script[async]"+i}function E0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+ki(a.href)+'"]');if(l)return s.instance=l,Pt(l),l;var d=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Pt(l),on(l,"style",d),rh(l,a.precedence,i),s.instance=l;case"stylesheet":d=gl(a.href);var f=i.querySelector(jc(d));if(f)return s.state.loading|=4,s.instance=f,Pt(f),f;l=T0(a),(d=cs.get(d))&&zm(l,d),f=(i.ownerDocument||i).createElement("link"),Pt(f);var _=f;return _._p=new Promise(function(T,O){_.onload=T,_.onerror=O}),on(f,"link",l),s.state.loading|=4,rh(f,a.precedence,i),s.instance=f;case"script":return f=vl(a.src),(d=i.querySelector(Ic(f)))?(s.instance=d,Pt(d),d):(l=a,(d=cs.get(f))&&(l=b({},a),Pm(l,d)),i=i.ownerDocument||i,d=i.createElement("script"),Pt(d),on(d,"link",l),i.head.appendChild(d),s.instance=d);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,rh(l,a.precedence,i));return s.instance}function rh(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,f=d,_=0;_<l.length;_++){var T=l[_];if(T.dataset.precedence===s)f=T;else if(f!==d)break}f?f.parentNode.insertBefore(i,f.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function zm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Pm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var ah=null;function D0(i,s,a){if(ah===null){var l=new Map,d=ah=new Map;d.set(a,l)}else d=ah,l=d.get(a),l||(l=new Map,d.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),d=0;d<a.length;d++){var f=a[d];if(!(f[Yn]||f[ri]||i==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var _=f.getAttribute(s)||"";_=i+_;var T=l.get(_);T?T.push(f):l.set(_,[f])}}return l}function R0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function VE(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function M0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function YE(i,s,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 d=gl(l.href),f=s.querySelector(jc(d));if(f){s=f._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=oh.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=f,Pt(f);return}f=s.ownerDocument||s,l=T0(l),(d=cs.get(d))&&zm(l,d),f=f.createElement("link"),Pt(f);var _=f;_._p=new Promise(function(T,O){_.onload=T,_.onerror=O}),on(f,"link",l),a.instance=f}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=oh.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var Hm=0;function XE(i,s){return i.stylesheets&&i.count===0&&ch(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&ch(i,i.stylesheets),i.unsuspend){var f=i.unsuspend;i.unsuspend=null,f()}},6e4+s);0<i.imgBytes&&Hm===0&&(Hm=62500*RE());var d=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&ch(i,i.stylesheets),i.unsuspend)){var f=i.unsuspend;i.unsuspend=null,f()}},(i.imgBytes>Hm?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function oh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ch(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var lh=null;function ch(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,lh=new Map,s.forEach(GE,i),lh=null,oh.call(i))}function GE(i,s){if(!(s.state.loading&4)){var a=lh.get(i);if(a)var l=a.get(null);else{a=new Map,lh.set(i,a);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<d.length;f++){var _=d[f];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}d=s.instance,_=d.getAttribute("data-precedence"),f=a.get(_)||l,f===l&&a.set(null,d),a.set(_,d),this.count++,l=oh.bind(this),d.addEventListener("load",l),d.addEventListener("error",l),f?f.parentNode.insertBefore(d,f.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(d,i.firstChild)),s.state.loading|=4}}var zc={$$typeof:Y,Provider:null,Consumer:null,_currentValue:j,_currentValue2:j,_threadCount:0};function ZE(i,s,a,l,d,f,_,T,O){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=zt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zt(0),this.hiddenUpdates=zt(null),this.identifierPrefix=l,this.onUncaughtError=d,this.onCaughtError=f,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=O,this.incompleteTransitions=new Map}function N0(i,s,a,l,d,f,_,T,O,J,fe,ve){return i=new ZE(i,s,a,_,O,J,fe,ve,T),s=1,f===!0&&(s|=24),f=zn(3,null,null,s),i.current=f,f.stateNode=i,s=bp(),s.refCount++,i.pooledCache=s,s.refCount++,f.memoizedState={element:l,isDehydrated:a,cache:s},Cp(f),i}function A0(i){return i?(i=Yo,i):Yo}function L0(i,s,a,l,d,f){d=A0(d),l.context===null?l.context=d:l.pendingContext=d,l=sa(s),l.payload={element:a},f=f===void 0?null:f,f!==null&&(l.callback=f),a=ra(i,l,s),a!==null&&(Bn(a,i,s),gc(a,i,s))}function O0(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function Um(i,s){O0(i,s),(i=i.alternate)&&O0(i,s)}function B0(i){if(i.tag===13||i.tag===31){var s=so(i,67108864);s!==null&&Bn(s,i,67108864),Um(i,67108864)}}function j0(i){if(i.tag===13||i.tag===31){var s=Kn();s=_n(s);var a=so(i,s);a!==null&&Bn(a,i,s),Um(i,s)}}var uh=!0;function QE(i,s,a,l){var d=L.T;L.T=null;var f=M.p;try{M.p=2,Fm(i,s,a,l)}finally{M.p=f,L.T=d}}function JE(i,s,a,l){var d=L.T;L.T=null;var f=M.p;try{M.p=8,Fm(i,s,a,l)}finally{M.p=f,L.T=d}}function Fm(i,s,a,l){if(uh){var d=Km(l);if(d===null)Dm(i,s,l,dh,a),z0(i,l);else if(t2(d,i,s,a,l))l.stopPropagation();else if(z0(i,l),s&4&&-1<e2.indexOf(i)){for(;d!==null;){var f=Ns(d);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var _=Dt(f.pendingLanes);if(_!==0){var T=f;for(T.pendingLanes|=2,T.entangledLanes|=2;_;){var O=1<<31-ot(_);T.entanglements[1]|=O,_&=~O}qs(f),(Rt&6)===0&&(Vd=et()+500,Ac(0))}}break;case 31:case 13:T=so(f,2),T!==null&&Bn(T,f,2),Xd(),Um(f,2)}if(f=Km(l),f===null&&Dm(i,s,l,dh,a),f===d)break;d=f}d!==null&&l.stopPropagation()}else Dm(i,s,l,null,a)}}function Km(i){return i=Ga(i),Wm(i)}var dh=null;function Wm(i){if(dh=null,i=Xn(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=u(s),i!==null)return i;i=null}else if(a===31){if(i=m(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return dh=i,null}function I0(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(Mt()){case pt:return 2;case kt:return 8;case yt:case Qt:return 32;case ci:return 268435456;default:return 32}default:return 32}}var $m=!1,ga=null,va=null,_a=null,Pc=new Map,Hc=new Map,ba=[],e2="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 z0(i,s){switch(i){case"focusin":case"focusout":ga=null;break;case"dragenter":case"dragleave":va=null;break;case"mouseover":case"mouseout":_a=null;break;case"pointerover":case"pointerout":Pc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hc.delete(s.pointerId)}}function Uc(i,s,a,l,d,f){return i===null||i.nativeEvent!==f?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:f,targetContainers:[d]},s!==null&&(s=Ns(s),s!==null&&B0(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function t2(i,s,a,l,d){switch(s){case"focusin":return ga=Uc(ga,i,s,a,l,d),!0;case"dragenter":return va=Uc(va,i,s,a,l,d),!0;case"mouseover":return _a=Uc(_a,i,s,a,l,d),!0;case"pointerover":var f=d.pointerId;return Pc.set(f,Uc(Pc.get(f)||null,i,s,a,l,d)),!0;case"gotpointercapture":return f=d.pointerId,Hc.set(f,Uc(Hc.get(f)||null,i,s,a,l,d)),!0}return!1}function P0(i){var s=Xn(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){i.blockedOn=s,en(i.priority,function(){j0(a)});return}}else if(s===31){if(s=m(a),s!==null){i.blockedOn=s,en(i.priority,function(){j0(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function hh(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Km(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Ui=l,a.target.dispatchEvent(l),Ui=null}else return s=Ns(a),s!==null&&B0(s),i.blockedOn=a,!1;s.shift()}return!0}function H0(i,s,a){hh(i)&&a.delete(s)}function i2(){$m=!1,ga!==null&&hh(ga)&&(ga=null),va!==null&&hh(va)&&(va=null),_a!==null&&hh(_a)&&(_a=null),Pc.forEach(H0),Hc.forEach(H0)}function fh(i,s){i.blockedOn===s&&(i.blockedOn=null,$m||($m=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,i2)))}var ph=null;function U0(i){ph!==i&&(ph=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ph===i&&(ph=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],d=i[s+2];if(typeof l!="function"){if(Wm(l||a)===null)continue;break}var f=Ns(a);f!==null&&(i.splice(s,3),s-=3,Kp(f,{pending:!0,data:d,method:a.method,action:l},l,d))}}))}function _l(i){function s(O){return fh(O,i)}ga!==null&&fh(ga,i),va!==null&&fh(va,i),_a!==null&&fh(_a,i),Pc.forEach(s),Hc.forEach(s);for(var a=0;a<ba.length;a++){var l=ba[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<ba.length&&(a=ba[0],a.blockedOn===null);)P0(a),a.blockedOn===null&&ba.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var d=a[l],f=a[l+1],_=d[di]||null;if(typeof f=="function")_||U0(a);else if(_){var T=null;if(f&&f.hasAttribute("formAction")){if(d=f,_=f[di]||null)T=_.formAction;else if(Wm(d)!==null)continue}else T=_.action;typeof T=="function"?a[l+1]=T:(a.splice(l,3),l-=3),U0(a)}}}function F0(){function i(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(_){return d=_})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,d=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),d!==null&&(d(),d=null)}}}function qm(i){this._internalRoot=i}mh.prototype.render=qm.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Kn();L0(a,l,i,s,null,null)},mh.prototype.unmount=qm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;L0(i.current,2,null,i,null,null),Xd(),s[bn]=null}};function mh(i){this._internalRoot=i}mh.prototype.unstable_scheduleHydration=function(i){if(i){var s=si();i={blockedOn:null,target:i,priority:s};for(var a=0;a<ba.length&&s!==0&&s<ba[a].priority;a++);ba.splice(a,0,i),a===0&&P0(i)}};var K0=t.version;if(K0!=="19.2.6")throw Error(r(527,K0,"19.2.6"));M.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var n2={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gh.isDisabled&&gh.supportsFiber)try{tt=gh.inject(n2),Ge=gh}catch{}}return Kc.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",d=Gy,f=Zy,_=Qy;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(f=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=N0(i,1,!1,null,null,a,l,null,d,f,_,F0),i[bn]=s.current,Em(i),new qm(s)},Kc.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,d="",f=Gy,_=Zy,T=Qy,O=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(f=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(T=a.onRecoverableError),a.formState!==void 0&&(O=a.formState)),s=N0(i,1,!0,s,a??null,l,d,O,f,_,T,F0),s.context=A0(null),a=s.current,l=Kn(),l=_n(l),d=sa(l),d.callback=null,ra(a,d,l),a=l,s.current.lanes=a,xi(s,a),qs(s),i[bn]=s.current,Em(i),new mh(s)},Kc.version="19.2.6",Kc}var J0;function f2(){if(J0)return Xm.exports;J0=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(),Xm.exports=h2(),Xm.exports}var p2=f2();class _o extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function yC(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let u=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{u||(u=!0,m(),o(b))},p=b=>{u||(u=!0,m(),c(b))},y=()=>{t.abort(),p(new _o(0,"Upload aborted."))};if(e.signal?.aborted){p(new _o(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST",e.endpoint??"/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{p(new _o(t.status,"Invalid upload response."))}return}p(new _o(t.status,m2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new _o(0,"Upload failed.")),t.onabort=()=>p(new _o(0,"Upload aborted.")),t.ontimeout=()=>p(new _o(0,"Upload timed out.")),t.send(n)})}function m2(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class kn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function kf(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${Gs(t)}`),setupPassword:t=>De(e,"/api/auth/password",Je("POST",t)),login:t=>De(e,"/api/auth/login",Je("POST",t)),reauth:t=>De(e,"/api/auth/reauth",Je("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",Je("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",Je("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Sl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",Je("POST",t)),removeNetwork:async t=>{await Sl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",Je("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",Je("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,Je("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",Je("PATCH",{name:t})),removeAgent:async t=>{await Sl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${Gs(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",Je("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",Je("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",Je("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",Je("POST",t)),listFiles:t=>De(e,"/api/files/list",Je("POST",t)),readFile:t=>De(e,"/api/files/read",Je("POST",t)),writeFile:t=>De(e,"/api/files/write",Je("POST",t)),createFileEntry:t=>De(e,"/api/files/create",Je("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",Je("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",Je("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",Je("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",Je("POST",t)),previewFile:t=>SC(e,"/api/files/preview",Je("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",Je("POST",t)),closeTerminal:async t=>{await Sl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,Je("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${Gs(n)}`),getTerminalTranscriptHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Gs(n)}`),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${Gs(r)}`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",Je("PUT",t)),deleteNotificationAsset:async t=>{await Sl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?Gs({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",Je("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",Je("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",Je("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",Je("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",Je("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",Je("POST",t))}}function ko(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(r={})=>De(t,n("terminals"),Je("POST",r)),closeTerminal:async r=>{await Sl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>De(t,n(`terminals/${encodeURIComponent(r)}`),Je("PATCH",{title:o})),getTerminalHistory:(r,o={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${Gs(o)}`),getTerminalTranscriptHistory:(r,o={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Gs(o)}`),getTerminalTranscriptSource:r=>De(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>De(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${Gs(c)}`),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:r=>De(t,n("terminal-layout"),Je("PUT",r)),createFileRoot:r=>De(t,n("files/root"),Je("POST",r)),listFiles:r=>De(t,n("files/list"),Je("POST",r)),readFile:r=>De(t,n("files/read"),Je("POST",r)),writeFile:r=>De(t,n("files/write"),Je("POST",r)),createFileEntry:r=>De(t,n("files/create"),Je("POST",r)),moveFileEntry:r=>De(t,n("files/move"),Je("POST",r)),previewDeleteFileEntry:r=>De(t,n("files/delete-preview"),Je("POST",r)),deleteFileEntry:r=>De(t,n("files/delete"),Je("POST",r)),openFileInTerminal:r=>De(t,n("files/open"),Je("POST",r)),previewFile:r=>SC(t,n("files/preview"),Je("POST",r)),uploadComposeAttachments:r=>yC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>De(t,n("attachments/limits")),deleteComposeAttachments:r=>De(t,n("attachments/delete"),Je("POST",r)),getCodeServerStatus:(r={})=>De(t,`${n("code-server/status")}${Gs(r)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>De(t,n("code-server/open"),Je("POST",r)),stopCodeServer:(r={})=>De(t,n("code-server/stop"),Je("POST",r)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getAccounts:()=>De(t,n("accounts")),selectAccount:(r,o)=>De(t,n(`accounts/${r}/select`),Je("POST",{profileId:o})),removeAccount:(r,o)=>De(t,n(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>De(t,n(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(r,o)=>De(t,n(`accounts/${r}/login/complete`),Je("POST",{label:o})),cancelAccountLogin:r=>De(t,n(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>De(t,n(`accounts/${r}/refresh`),Je("POST",o?{profileId:o}:{})),createWebSocketUrl:(r,o=window.location.href)=>g2(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function g2(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 Gs(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 De(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await F_(r);try{return await r.json()}catch{throw new kn(r.status,"invalid_json_response")}}async function Sl(e,t,n){const r=await e(t,n);await F_(r)}async function SC(e,t,n){const r=await e(t,n);return await F_(r),r.blob()}async function F_(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new kn(e.status,t)}const K_="nterminal.theme.id",wC="nterminal.theme.accent",Yg="nterminal:theme",Qh=[{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",...ew({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",...ew({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Ol="midnight";function Tf(e){return Qh.some(t=>t.id===e)?e:Ol}function W_(e){return Qh.find(t=>t.id===e)??Qh[0]}function ja(){if(typeof window>"u")return Ol;try{const e=window.localStorage.getItem(K_);return e?Tf(e):S2(window.localStorage.getItem(wC))}catch{return Ol}}function v2(e){const t=Tf(e);if(typeof window<"u"){try{window.localStorage.setItem(K_,t)}catch{}$_(t),window.dispatchEvent(new CustomEvent(Yg,{detail:t}))}return t}function $_(e=ja()){if(typeof document>"u")return;const t=W_(Tf(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),ht(n,"--nt-bg",t.tokens.bg),ht(n,"--nt-bg-2",t.tokens.bg2),ht(n,"--nt-bg-sidebar",t.tokens.bgSidebar),ht(n,"--nt-line",t.tokens.line),ht(n,"--nt-line-2",t.tokens.line2),ht(n,"--nt-fg",t.tokens.fg),ht(n,"--nt-fg-2",t.tokens.fg2),ht(n,"--nt-fg-3",t.tokens.fg3),ht(n,"--nt-fg-4",t.tokens.fg4),ht(n,"--nt-accent",t.tokens.accent),ht(n,"--nt-accent-soft",t.tokens.accentSoft),ht(n,"--nt-accent-glow",t.tokens.accentGlow),ht(n,"--nt-on-accent",t.tokens.onAccent),ht(n,"--nt-ok",t.tokens.ok),ht(n,"--nt-danger",t.tokens.danger),ht(n,"--nt-on-danger",t.tokens.onDanger),ht(n,"--nt-danger-soft",t.tokens.dangerSoft),ht(n,"--nt-danger-line",t.tokens.dangerLine),ht(n,"--nt-warning",t.tokens.warning),ht(n,"--nt-warn",t.tokens.warning),ht(n,"--nt-warning-soft",t.tokens.warningSoft),ht(n,"--nt-warning-glow",t.tokens.warningGlow),ht(n,"--nt-scrim",t.tokens.scrim),ht(n,"--nt-scrim-soft",t.tokens.scrimSoft),ht(n,"--nt-shadow",t.tokens.shadow),ht(n,"--nt-shadow-strong",t.tokens.shadowStrong),ht(n,"--nt-floating-bg",t.tokens.floatingBg),ht(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),ht(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),ht(n,"--nt-subtle-fill",t.tokens.subtleFill),ht(n,"--nt-hover-fill",t.tokens.hoverFill),ht(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),ht(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),ht(n,"--nt-transcript-user",t.tokens.transcriptUser),ht(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),ht(n,"--nt-transcript-tool",t.tokens.transcriptTool),ht(n,"--nt-transcript-command",t.tokens.transcriptCommand),ht(n,"--nt-transcript-code",t.tokens.transcriptCode),ht(n,"--nt-transcript-search",t.tokens.transcriptSearch),ht(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),ht(n,"--nt-qr-bg",t.tokens.qrBg)}function _2(e=ja()){return W_(Tf(e)).xterm}function q_(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===K_||n.key===wC)&&($_(ja()),e())};return window.addEventListener(Yg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Yg,e),window.removeEventListener("storage",t)}}function ht(e,t,n){e.style.setProperty(t,n)}function ew(e){const t=b2(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 b2(e){const t=[];for(let n=16;n<=e;n+=1)t.push(y2(n));return t}function y2(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return tw(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return tw(t,t,t)}return"#000000"}function tw(e,t,n){return`#${Jm(e)}${Jm(t)}${Jm(n)}`}function Jm(e){return e.toString(16).padStart(2,"0")}function S2(e){return e==="signal-red"?"signal-red":Ol}function CC(){const e=v.useSyncExternalStore(q_,ja,()=>Ol);return W_(e).mode==="light"?"-light":""}function xC({size:e=22}){const t=CC();return h.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function kC({height:e=18}){const t=CC(),n=Math.round(243/34*e);return h.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var iu=bC();const Ef=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Hl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function V_(e){return"nodeType"in e}function In(e){var t,n;return e?Hl(e)?e:V_(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Y_(e){const{Document:t}=In(e);return e instanceof t}function $u(e){return Hl(e)?!1:e instanceof In(e).HTMLElement}function TC(e){return e instanceof In(e).SVGElement}function Ul(e){return e?Hl(e)?e.document:V_(e)?Y_(e)?e:$u(e)||TC(e)?e.ownerDocument:document:document:document}const Ia=Ef?v.useLayoutEffect:v.useEffect;function X_(e){const t=v.useRef(e);return Ia(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function w2(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ku(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Ia(()=>{n.current!==e&&(n.current=e)},t),n}function qu(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Jh(e){const t=X_(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Xg(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let eg={};function Df(e,t){return v.useMemo(()=>{if(t)return t;const n=eg[e]==null?0:eg[e]+1;return eg[e]=n,e+"-"+n},[e,t])}function EC(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,u)=>{const m=Object.entries(u);for(const[g,p]of m){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const Ml=EC(1),ef=EC(-1);function C2(e){return"clientX"in e&&"clientY"in e}function DC(e){if(!e)return!1;const{KeyboardEvent:t}=In(e.target);return t&&e instanceof t}function x2(e){if(!e)return!1;const{TouchEvent:t}=In(e.target);return t&&e instanceof t}function Gg(e){if(x2(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 C2(e)?{x:e.clientX,y:e.clientY}:null}const Zg=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[Zg.Translate.toString(e),Zg.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),iw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function k2(e){return e.matches(iw)?e:e.querySelector(iw)}const T2={display:"none"};function E2(e){let{id:t,value:n}=e;return Ni.createElement("div",{id:t,style:T2},n)}function D2(e){let{id:t,announcement:n,ariaLiveType:r="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 Ni.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function R2(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const RC=v.createContext(null);function M2(e){const t=v.useContext(RC);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function N2(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(u=>{var m;return(m=u[o])==null?void 0:m.call(u,c)})},[e]),t]}const A2={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
|
+
`},L2={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 O2(e){let{announcements:t=L2,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=A2}=e;const{announce:c,announcement:u}=R2(),m=Df("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),M2(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:C}=b;t.onDragMove&&c(t.onDragMove({active:w,over:C}))},onDragOver(b){let{active:w,over:C}=b;c(t.onDragOver({active:w,over:C}))},onDragEnd(b){let{active:w,over:C}=b;c(t.onDragEnd({active:w,over:C}))},onDragCancel(b){let{active:w,over:C}=b;c(t.onDragCancel({active:w,over:C}))}}),[c,t])),!g)return null;const y=Ni.createElement(Ni.Fragment,null,Ni.createElement(E2,{id:r,value:o.draggable}),Ni.createElement(D2,{id:m,announcement:u}));return n?iu.createPortal(y,n):y}var zi;(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"})(zi||(zi={}));function tf(){}function nw(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function B2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Ds=Object.freeze({x:0,y:0});function j2(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function I2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function z2(e,t){const n=Math.max(t.top,e.top),r=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),u=o-r,m=c-n;if(r<o&&n<c){const g=t.width*t.height,p=e.width*e.height,y=u*m,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const P2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,m=n.get(u);if(m){const g=z2(m,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(j2)};function H2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function MC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ds}function U2(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((u,m)=>({...u,top:u.top+e*m.y,bottom:u.bottom+e*m.y,left:u.left+e*m.x,right:u.right+e*m.x}),{...n})}}const F2=U2(1);function K2(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 W2(e,t,n){const r=K2(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:m}=r,g=e.left-u-(1-o)*parseFloat(n),p=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:p,right:g+y,bottom:p+b,left:g}}const $2={ignoreTransform:!1};function Vu(e,t){t===void 0&&(t=$2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=In(e).getComputedStyle(e);p&&(n=W2(n,p,y))}const{top:r,left:o,width:c,height:u,bottom:m,right:g}=n;return{top:r,left:o,width:c,height:u,bottom:m,right:g}}function sw(e){return Vu(e,{ignoreTransform:!0})}function q2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function V2(e,t){return t===void 0&&(t=In(e).getComputedStyle(e)),t.position==="fixed"}function Y2(e,t){t===void 0&&(t=In(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 G_(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Y_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!$u(o)||TC(o)||n.includes(o))return n;const c=In(e).getComputedStyle(o);return o!==e&&Y2(o,c)&&n.push(o),V2(o,c)?n:r(o.parentNode)}return e?r(e):n}function NC(e){const[t]=G_(e,1);return t??null}function tg(e){return!Ef||!e?null:Hl(e)?e:V_(e)?Y_(e)||e===Ul(e).scrollingElement?window:$u(e)?e:null:null}function AC(e){return Hl(e)?e.scrollX:e.scrollLeft}function LC(e){return Hl(e)?e.scrollY:e.scrollTop}function Qg(e){return{x:AC(e),y:LC(e)}}var Vi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vi||(Vi={}));function OC(e){return!Ef||!e?!1:e===document.scrollingElement}function BC(e){const t={x:0,y:0},n=OC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,u=e.scrollTop>=r.y,m=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:u,isRight:m,maxScroll:r,minScroll:t}}const X2={x:.2,y:.2};function G2(e,t,n,r,o){let{top:c,left:u,right:m,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=X2);const{isTop:p,isBottom:y,isLeft:b,isRight:w}=BC(e),C={x:0,y:0},S={x:0,y:0},R={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+R.height?(C.y=Vi.Backward,S.y=r*Math.abs((t.top+R.height-c)/R.height)):!y&&g>=t.bottom-R.height&&(C.y=Vi.Forward,S.y=r*Math.abs((t.bottom-R.height-g)/R.height)),!w&&m>=t.right-R.width?(C.x=Vi.Forward,S.x=r*Math.abs((t.right-R.width-m)/R.width)):!b&&u<=t.left+R.width&&(C.x=Vi.Backward,S.x=r*Math.abs((t.left+R.width-u)/R.width)),{direction:C,speed:S}}function Z2(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function jC(e){return e.reduce((t,n)=>Ml(t,Qg(n)),Ds)}function Q2(e){return e.reduce((t,n)=>t+AC(n),0)}function J2(e){return e.reduce((t,n)=>t+LC(n),0)}function eD(e,t){if(t===void 0&&(t=Vu),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);NC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const tD=[["x",["left","right"],Q2],["y",["top","bottom"],J2]];class Z_{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 r=G_(n),o=jC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,m]of tD)for(const g of u)Object.defineProperty(this,g,{get:()=>{const p=m(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function iD(e){const{EventTarget:t}=In(e);return e instanceof t?e:Ul(e)}function ig(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var hs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(hs||(hs={}));function rw(e){e.preventDefault()}function nD(e){e.stopPropagation()}var Gt;(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"})(Gt||(Gt={}));const IC={start:[Gt.Space,Gt.Enter],cancel:[Gt.Esc],end:[Gt.Space,Gt.Enter,Gt.Tab]},sD=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Gt.Right:return{...n,x:n.x+25};case Gt.Left:return{...n,x:n.x-25};case Gt.Down:return{...n,y:n.y+25};case Gt.Up:return{...n,y:n.y-25}}};class zC{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 fu(Ul(n)),this.windowListeners=new fu(In(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(hs.Resize,this.handleCancel),this.windowListeners.add(hs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(hs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&eD(r),n(Ds)}handleKeyDown(t){if(DC(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=IC,coordinateGetter:u=sD,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:p}=r.current,y=p?{x:p.left,y:p.top}:Ds;this.referenceCoordinates||(this.referenceCoordinates=y);const b=u(t,{active:n,context:r.current,currentCoordinates:y});if(b){const w=ef(b,y),C={x:0,y:0},{scrollableAncestors:S}=r.current;for(const R of S){const B=t.code,{isTop:A,isRight:U,isLeft:Y,isBottom:K,maxScroll:se,minScroll:Q}=BC(R),z=Z2(R),_e={x:Math.min(B===Gt.Right?z.right-z.width/2:z.right,Math.max(B===Gt.Right?z.left:z.left+z.width/2,b.x)),y:Math.min(B===Gt.Down?z.bottom-z.height/2:z.bottom,Math.max(B===Gt.Down?z.top:z.top+z.height/2,b.y))},ie=B===Gt.Right&&!U||B===Gt.Left&&!Y,ke=B===Gt.Down&&!K||B===Gt.Up&&!A;if(ie&&_e.x!==b.x){const ne=R.scrollLeft+w.x,X=B===Gt.Right&&ne<=se.x||B===Gt.Left&&ne>=Q.x;if(X&&!w.y){R.scrollTo({left:ne,behavior:m});return}X?C.x=R.scrollLeft-ne:C.x=B===Gt.Right?R.scrollLeft-se.x:R.scrollLeft-Q.x,C.x&&R.scrollBy({left:-C.x,behavior:m});break}else if(ke&&_e.y!==b.y){const ne=R.scrollTop+w.y,X=B===Gt.Down&&ne<=se.y||B===Gt.Up&&ne>=Q.y;if(X&&!w.x){R.scrollTo({top:ne,behavior:m});return}X?C.y=R.scrollTop-ne:C.y=B===Gt.Down?R.scrollTop-se.y:R.scrollTop-Q.y,C.y&&R.scrollBy({top:-C.y,behavior:m});break}}this.handleMove(t,Ml(ef(b,this.referenceCoordinates),C))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(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()}}zC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=IC,onActivation:o}=t,{active:c}=n;const{code:u}=e.nativeEvent;if(r.start.includes(u)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function aw(e){return!!(e&&"distance"in e)}function ow(e){return!!(e&&"delay"in e)}class Q_{constructor(t,n,r){var o;r===void 0&&(r=iD(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:u}=c;this.props=t,this.events=n,this.document=Ul(u),this.documentListeners=new fu(this.document),this.listeners=new fu(r),this.windowListeners=new fu(In(u)),this.initialCoordinates=(o=Gg(c))!=null?o:Ds,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:r}}}=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(hs.Resize,this.handleCancel),this.windowListeners.add(hs.DragStart,rw),this.windowListeners.add(hs.VisibilityChange,this.handleCancel),this.windowListeners.add(hs.ContextMenu,rw),this.documentListeners.add(hs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ow(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(aw(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:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(hs.Click,nD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(hs.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=Gg(t))!=null?n:Ds,p=ef(o,g);if(!r&&m){if(aw(m)){if(m.tolerance!=null&&ig(p,m.tolerance))return this.handleCancel();if(ig(p,m.distance))return this.handleStart()}if(ow(m)&&ig(p,m.tolerance))return this.handleCancel();this.handlePending(m,p);return}t.cancelable&&t.preventDefault(),u(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===Gt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const rD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class PC extends Q_{constructor(t){const{event:n}=t,r=Ul(n.target);super(t,rD,r)}}PC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const aD={move:{name:"mousemove"},end:{name:"mouseup"}};var Jg;(function(e){e[e.RightClick=2]="RightClick"})(Jg||(Jg={}));class HC extends Q_{constructor(t){super(t,aD,Ul(t.event.target))}}HC.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Jg.RightClick?!1:(r?.({event:n}),!0)}}];const ng={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class UC extends Q_{constructor(t){super(t,ng)}static setup(){return window.addEventListener(ng.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ng.move.name,t)};function t(){}}}UC.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var pu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(pu||(pu={}));var nf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(nf||(nf={}));function oD(e){let{acceleration:t,activator:n=pu.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:m=nf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:w}=e;const C=cD({delta:b,disabled:!c}),[S,R]=w2(),B=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),U=v.useMemo(()=>{switch(n){case pu.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case pu.DraggableRect:return o}},[n,o,g]),Y=v.useRef(null),K=v.useCallback(()=>{const Q=Y.current;if(!Q)return;const z=B.current.x*A.current.x,_e=B.current.y*A.current.y;Q.scrollBy(z,_e)},[]),se=v.useMemo(()=>m===nf.TreeOrder?[...p].reverse():p,[m,p]);v.useEffect(()=>{if(!c||!p.length||!U){R();return}for(const Q of se){if(r?.(Q)===!1)continue;const z=p.indexOf(Q),_e=y[z];if(!_e)continue;const{direction:ie,speed:ke}=G2(Q,_e,U,t,w);for(const ne of["x","y"])C[ne][ie[ne]]||(ke[ne]=0,ie[ne]=0);if(ke.x>0||ke.y>0){R(),Y.current=Q,S(K,u),B.current=ke,A.current=ie;return}}B.current={x:0,y:0},A.current={x:0,y:0},R()},[t,K,r,R,c,u,JSON.stringify(U),JSON.stringify(C),S,p,se,y,JSON.stringify(w)])}const lD={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function cD(e){let{delta:t,disabled:n}=e;const r=Xg(t);return qu(o=>{if(n||!r||!o)return lD;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.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,r])}function uD(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return qu(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function dD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...n,...c]},[]),[e,t])}var Tu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Tu||(Tu={}));var ev;(function(e){e.Optimized="optimized"})(ev||(ev={}));const lw=new Map;function hD(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:m,measure:g,strategy:p}=o,y=v.useRef(e),b=B(),w=ku(b),C=v.useCallback(function(A){A===void 0&&(A=[]),!w.current&&u(U=>U===null?A:U.concat(A.filter(Y=>!U.includes(Y))))},[w]),S=v.useRef(null),R=qu(A=>{if(b&&!n)return lw;if(!A||A===lw||y.current!==e||c!=null){const U=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){U.set(Y.id,Y.rect.current);continue}const K=Y.node.current,se=K?new Z_(g(K),K):null;Y.rect.current=se,se&&U.set(Y.id,se)}return U}return A},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||C()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||S.current!==null||(S.current=setTimeout(()=>{C(),S.current=null},m))},[m,b,C,...r]),{droppableRects:R,measureDroppableContainers:C,measuringScheduled:c!=null};function B(){switch(p){case Tu.Always:return!1;case Tu.BeforeDragging:return n;default:return!n}}}function FC(e,t){return qu(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function fD(e,t){return FC(e,t)}function pD(e){let{callback:t,disabled:n}=e;const r=X_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Rf(e){let{callback:t,disabled:n}=e;const r=X_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function mD(e){return new Z_(Vu(e),e)}function cw(e,t,n){t===void 0&&(t=mD);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const u=pD({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Rf({callback:c});return Ia(()=>{c(),e?(m?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),u?.disconnect())},[e]),r}function gD(e){const t=FC(e);return MC(e,t)}const uw=[];function vD(e){const t=v.useRef(e),n=qu(r=>e?r&&r!==uw&&e&&t.current&&e.parentNode===t.current.parentNode?r:G_(e):uw,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function _D(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=tg(c.target);u&&n(m=>m?(m.set(u,Qg(u)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const m=e.map(g=>{const p=tg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Qg(p)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),r.current=e}return()=>{u(e),u(c)};function u(m){m.forEach(g=>{const p=tg(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>Ml(c,u),Ds):jC(e):Ds,[e,t])}function dw(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==Ds;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ef(e,n.current):Ds}function bD(e){v.useEffect(()=>{if(!Ef)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function yD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=u=>{c(u,t)},n},{}),[e,t])}function KC(e){return v.useMemo(()=>e?q2(e):null,[e])}const hw=[];function SD(e,t){t===void 0&&(t=Vu);const[n]=e,r=KC(n?In(n):null),[o,c]=v.useState(hw);function u(){c(()=>e.length?e.map(g=>OC(g)?r:new Z_(t(g),g)):hw)}const m=Rf({callback:u});return Ia(()=>{m?.disconnect(),u(),e.forEach(g=>m?.observe(g))},[e]),o}function wD(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return $u(t)?t:e}function CD(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if($u(y)){r(b=>{const w=t(y);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=Rf({callback:o}),u=v.useCallback(p=>{const y=wD(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[m,g]=Jh(u);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const xD=[{sensor:PC,options:{}},{sensor:zC,options:{}}],kD={current:{}},Bh={draggable:{measure:sw},droppable:{measure:sw,strategy:Tu.WhileDragging,frequency:ev.Optimized},dragOverlay:{measure:Vu}};class mu 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,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const TD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:tf},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bh,measureDroppableContainers:tf,windowRect:null,measuringScheduled:!1},ED={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:tf,draggableNodes:new Map,over:null,measureDroppableContainers:tf},Mf=v.createContext(ED),DD=v.createContext(TD);function RD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mu}}}function MD(e,t){switch(t.type){case zi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case zi.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 zi.DragEnd:case zi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case zi.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new mu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case zi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const u=new mu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case zi.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new mu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function ND(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Mf),c=Xg(r),u=Xg(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!DC(c)||document.activeElement===c.target)return;const m=o.get(u);if(!m)return;const{activatorNode:g,node:p}=m;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=k2(y);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function AD(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function LD(e){return v.useMemo(()=>({draggable:{...Bh.draggable,...e?.draggable},droppable:{...Bh.droppable,...e?.droppable},dragOverlay:{...Bh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function OD(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:m}=typeof o=="boolean"?{x:o,y:o}:o;Ia(()=>{if(!u&&!m||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=n(p),b=MC(y,r);if(u||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=NC(p);w&&w.scrollBy({top:b.y,left:b.x})}},[t,u,m,r,n])}const WC=v.createContext({...Ds,scaleX:1,scaleY:1});var Ea;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ea||(Ea={}));const BD=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:m,autoScroll:g=!0,children:p,sensors:y=xD,collisionDetection:b=P2,measuring:w,modifiers:C,...S}=t;const R=v.useReducer(MD,void 0,RD),[B,A]=R,[U,Y]=N2(),[K,se]=v.useState(Ea.Uninitialized),Q=K===Ea.Initialized,{draggable:{active:z,nodes:_e,translate:ie},droppable:{containers:ke}}=B,ne=z!=null?_e.get(z):null,X=v.useRef({initial:null,translated:null}),G=v.useMemo(()=>{var lt;return z!=null?{id:z,data:(lt=ne?.data)!=null?lt:kD,rect:X}:null},[z,ne]),q=v.useRef(null),[oe,L]=v.useState(null),[M,j]=v.useState(null),re=ku(S,Object.values(S)),ye=Df("DndDescribedBy",u),N=v.useMemo(()=>ke.getEnabled(),[ke]),W=LD(w),{droppableRects:ue,measureDroppableContainers:Ce,measuringScheduled:Le}=hD(N,{dragging:Q,dependencies:[ie.x,ie.y],config:W.droppable}),Me=uD(_e,z),Ne=v.useMemo(()=>M?Gg(M):null,[M]),Oe=mt(),Ve=fD(Me,W.draggable.measure);OD({activeNode:z!=null?_e.get(z):null,config:Oe.layoutShiftCompensation,initialRect:Ve,measure:W.draggable.measure});const Ye=cw(Me,W.draggable.measure,Ve),Be=cw(Me?Me.parentElement:null),le=v.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:ue,draggableNodes:_e,draggingNode:null,draggingNodeRect:null,droppableContainers:ke,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),E=ke.getNodeFor((n=le.current.over)==null?void 0:n.id),V=CD({measure:W.dragOverlay.measure}),ge=(r=V.nodeRef.current)!=null?r:Me,Te=Q?(o=V.rect)!=null?o:Ye:null,F=!!(V.nodeRef.current&&V.rect),Se=gD(F?null:Ye),xe=KC(ge?In(ge):null),he=vD(Q?E??Me:null),je=SD(he),Ie=AD(C,{transform:{x:ie.x-Se.x,y:ie.y-Se.y,scaleX:1,scaleY:1},activatorEvent:M,active:G,activeNodeRect:Ye,containerNodeRect:Be,draggingNodeRect:Te,over:le.current.over,overlayNodeRect:V.rect,scrollableAncestors:he,scrollableAncestorRects:je,windowRect:xe}),He=Ne?Ml(Ne,ie):null,et=_D(he),Mt=dw(et),pt=dw(et,[Ye]),kt=Ml(Ie,Mt),yt=Te?F2(Te,Ie):null,Qt=G&&yt?b({active:G,collisionRect:yt,droppableRects:ue,droppableContainers:N,pointerCoordinates:He}):null,ci=I2(Qt,"id"),[de,Ue]=v.useState(null),tt=F?Ie:Ml(Ie,pt),Ge=H2(tt,(c=de?.rect)!=null?c:null,Ye),xt=v.useRef(null),ot=v.useCallback((lt,Dt)=>{let{sensor:Nt,options:Wt}=Dt;if(q.current==null)return;const ui=_e.get(q.current);if(!ui)return;const $t=lt.nativeEvent,zt=new Nt({active:q.current,activeNode:ui,event:$t,options:Wt,context:le,onAbort(Lt){if(!_e.get(Lt))return;const{onDragAbort:qt}=re.current,Ji={id:Lt};qt?.(Ji),U({type:"onDragAbort",event:Ji})},onPending(Lt,un,qt,Ji){if(!_e.get(Lt))return;const{onDragPending:dn}=re.current,si={id:Lt,constraint:un,initialCoordinates:qt,offset:Ji};dn?.(si),U({type:"onDragPending",event:si})},onStart(Lt){const un=q.current;if(un==null)return;const qt=_e.get(un);if(!qt)return;const{onDragStart:Ji}=re.current,_n={activatorEvent:$t,active:{id:un,data:qt.data,rect:X}};iu.unstable_batchedUpdates(()=>{Ji?.(_n),se(Ea.Initializing),A({type:zi.DragStart,initialCoordinates:Lt,active:un}),U({type:"onDragStart",event:_n}),L(xt.current),j($t)})},onMove(Lt){A({type:zi.DragMove,coordinates:Lt})},onEnd:xi(zi.DragEnd),onCancel:xi(zi.DragCancel)});xt.current=zt;function xi(Lt){return async function(){const{active:qt,collisions:Ji,over:_n,scrollAdjustedTranslate:dn}=le.current;let si=null;if(qt&&dn){const{cancelDrop:en}=re.current;si={activatorEvent:$t,active:qt,collisions:Ji,delta:dn,over:_n},Lt===zi.DragEnd&&typeof en=="function"&&await Promise.resolve(en(si))&&(Lt=zi.DragCancel)}q.current=null,iu.unstable_batchedUpdates(()=>{A({type:Lt}),se(Ea.Uninitialized),Ue(null),L(null),j(null),xt.current=null;const en=Lt===zi.DragEnd?"onDragEnd":"onDragCancel";if(si){const bi=re.current[en];bi?.(si),U({type:en,event:si})}})}}},[_e]),Hi=v.useCallback((lt,Dt)=>(Nt,Wt)=>{const ui=Nt.nativeEvent,$t=_e.get(Wt);if(q.current!==null||!$t||ui.dndKit||ui.defaultPrevented)return;const zt={active:$t};lt(Nt,Dt.options,zt)===!0&&(ui.dndKit={capturedBy:Dt.sensor},q.current=Wt,ot(Nt,Dt))},[_e,ot]),_i=dD(y,Hi);bD(y),Ia(()=>{Ye&&K===Ea.Initializing&&se(Ea.Initialized)},[Ye,K]),v.useEffect(()=>{const{onDragMove:lt}=re.current,{active:Dt,activatorEvent:Nt,collisions:Wt,over:ui}=le.current;if(!Dt||!Nt)return;const $t={active:Dt,activatorEvent:Nt,collisions:Wt,delta:{x:kt.x,y:kt.y},over:ui};iu.unstable_batchedUpdates(()=>{lt?.($t),U({type:"onDragMove",event:$t})})},[kt.x,kt.y]),v.useEffect(()=>{const{active:lt,activatorEvent:Dt,collisions:Nt,droppableContainers:Wt,scrollAdjustedTranslate:ui}=le.current;if(!lt||q.current==null||!Dt||!ui)return;const{onDragOver:$t}=re.current,zt=Wt.get(ci),xi=zt&&zt.rect.current?{id:zt.id,rect:zt.rect.current,data:zt.data,disabled:zt.disabled}:null,Lt={active:lt,activatorEvent:Dt,collisions:Nt,delta:{x:ui.x,y:ui.y},over:xi};iu.unstable_batchedUpdates(()=>{Ue(xi),$t?.(Lt),U({type:"onDragOver",event:Lt})})},[ci]),Ia(()=>{le.current={activatorEvent:M,active:G,activeNode:Me,collisionRect:yt,collisions:Qt,droppableRects:ue,draggableNodes:_e,draggingNode:ge,draggingNodeRect:Te,droppableContainers:ke,over:de,scrollableAncestors:he,scrollAdjustedTranslate:kt},X.current={initial:Te,translated:yt}},[G,Me,Qt,yt,_e,ge,Te,ue,ke,de,he,kt]),oD({...Oe,delta:ie,draggingRect:yt,pointerCoordinates:He,scrollableAncestors:he,scrollableAncestorRects:je});const ee=v.useMemo(()=>({active:G,activeNode:Me,activeNodeRect:Ye,activatorEvent:M,collisions:Qt,containerNodeRect:Be,dragOverlay:V,draggableNodes:_e,droppableContainers:ke,droppableRects:ue,over:de,measureDroppableContainers:Ce,scrollableAncestors:he,scrollableAncestorRects:je,measuringConfiguration:W,measuringScheduled:Le,windowRect:xe}),[G,Me,Ye,M,Qt,Be,V,_e,ke,ue,de,Ce,he,je,W,Le,xe]),Pe=v.useMemo(()=>({activatorEvent:M,activators:_i,active:G,activeNodeRect:Ye,ariaDescribedById:{draggable:ye},dispatch:A,draggableNodes:_e,over:de,measureDroppableContainers:Ce}),[M,_i,G,Ye,A,ye,_e,de,Ce]);return Ni.createElement(RC.Provider,{value:Y},Ni.createElement(Mf.Provider,{value:Pe},Ni.createElement(DD.Provider,{value:ee},Ni.createElement(WC.Provider,{value:Ge},p)),Ni.createElement(ND,{disabled:m?.restoreFocus===!1})),Ni.createElement(O2,{...m,hiddenTextDescribedById:ye}));function mt(){const lt=oe?.autoScrollEnabled===!1,Dt=typeof g=="object"?g.enabled===!1:g===!1,Nt=Q&&!lt&&!Dt;return typeof g=="object"?{...g,enabled:Nt}:{enabled:Nt}}}),jD=v.createContext(null),fw="button",ID="Draggable";function $C(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=Df(ID),{activators:u,activatorEvent:m,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:w}=v.useContext(Mf),{role:C=fw,roleDescription:S="draggable",tabIndex:R=0}=o??{},B=g?.id===t,A=v.useContext(B?WC:jD),[U,Y]=Jh(),[K,se]=Jh(),Q=yD(u,t),z=ku(n);Ia(()=>(b.set(t,{id:t,key:c,node:U,activatorNode:K,data:z}),()=>{const ie=b.get(t);ie&&ie.key===c&&b.delete(t)}),[b,t]);const _e=v.useMemo(()=>({role:C,tabIndex:R,"aria-disabled":r,"aria-pressed":B&&C===fw?!0:void 0,"aria-roledescription":S,"aria-describedby":y.draggable}),[r,C,R,B,S,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:p,attributes:_e,isDragging:B,listeners:r?void 0:Q,node:U,over:w,setNodeRef:Y,setActivatorNodeRef:se,transform:A}}const zD="Droppable",PD={timeout:25};function J_(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=Df(zD),{active:u,dispatch:m,over:g,measureDroppableContainers:p}=v.useContext(Mf),y=v.useRef({disabled:n}),b=v.useRef(!1),w=v.useRef(null),C=v.useRef(null),{disabled:S,updateMeasurementsFor:R,timeout:B}={...PD,...o},A=ku(R??r),U=v.useCallback(()=>{if(!b.current){b.current=!0;return}C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),C.current=null},B)},[B]),Y=Rf({callback:U,disabled:S||!u}),K=v.useCallback((_e,ie)=>{Y&&(ie&&(Y.unobserve(ie),b.current=!1),_e&&Y.observe(_e))},[Y]),[se,Q]=Jh(K),z=ku(t);return v.useEffect(()=>{!Y||!se.current||(Y.disconnect(),b.current=!1,Y.observe(se.current))},[se,Y]),v.useEffect(()=>(m({type:zi.RegisterDroppable,element:{id:r,key:c,disabled:n,node:se,rect:w,data:z}}),()=>m({type:zi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:zi.SetDroppableDisabled,id:r,key:c,disabled:n}),y.current.disabled=n)},[r,c,n,m]),{active:u,rect:w,isOver:g?.id===r,node:se,over:g,setNodeRef:Q}}const HD=128,UD=512,Fl=100,FD="too_many_detached_terminals",KD=64,WD=4096;function qC(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>HD)return null;const n=t.workspaces.map($D);if(n.some(u=>u===null))return null;const r=n,o=new Set,c=new Set;for(const u of r){if(o.has(u.id))return null;o.add(u.id);for(const m of u.tabs){if(c.has(m.id))return null;c.add(m.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function VC(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 r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>Fl}):!1}function $D(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>UD)return null;const n=t.tabs.map(qD);if(n.some(o=>o===null))return null;const r=GD(t.detachedTerminalIds,Fl);return r===null?null:{id:t.id,title:t.title,defaultCwd:XD(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function qD(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=VD(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function VD(e){if(!e||typeof e!="object")return null;let t=0;return tv(e,1,()=>(t+=1,t<=WD))}function tv(e,t,n){if(!e||typeof e!="object"||t>KD||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=tv(r.first,t+1,n),c=tv(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:YD(r.ratio),first:o,second:c}}function YD(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function XD(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function GD(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const YC=[{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"}],ZD="nterminal-focus",QD=/^[A-Za-z0-9_.:-]{1,128}$/;function JD(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(ZD)!=="terminal"?null:Nf({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Nf(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!pw(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!pw(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function pw(e){return typeof e=="string"&&QD.test(e)}const Yi="__main__",XC=128,eR=600*1e3,GC="nterminal.clientDiagnostics.v1",ZC="nterminal.terminalDiagnosticsCursor.v1",Af=150,tR=24,iR=160,nR=48*1024,sR="terminal-connection-recovery";let mw=!1,Wc=null,$c=null,sg=0;function rR(){mw||typeof window>"u"||(mw=!0,vn("page.load",{navigation:wR(),visibility:document.visibilityState,online:navigator.onLine,viewport:ix(),standalone:SR()}),document.addEventListener("visibilitychange",()=>{vn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{vn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{vn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>vn("network.online")),window.addEventListener("offline",()=>vn("network.offline")),window.addEventListener("focus",()=>vn("window.focus")),window.addEventListener("blur",()=>vn("window.blur")),window.addEventListener("error",e=>{vn("runtime.error",{message:e.message,source:CR(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{vn("runtime.unhandledrejection",{reason:xR(e.reason)})}))}function vn(e,t={}){const n={id:pR(),at:new Date().toISOString(),event:Eu(e,80),data:tx({...t,visibility:t.visibility??bR(),online:t.online??yR(),viewport:t.viewport??ix()})},r=eb();return r.push(n),hR(r.slice(-Af)),n}function eb(){try{const e=window.localStorage.getItem(GC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(fR).filter(n=>n!==null).slice(-Af):[]}catch{return[]}}async function tb(e,t=fetch){if(Wc)return Wc;const n=eb(),r={reason:Eu(e,80),events:n},o=JSON.stringify(r);Wc=(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 Wc}finally{Wc=null}}function Lf(){return QC().events.length>0}async function aR(e=fetch){if($c)return $c;$c=oR(e);try{return await $c}finally{$c=null}}async function oR(e){const t=QC();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(dR(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function QC(){const e=JC(),t=eb().filter(o=>lR(o)&&uR(o,e)),n=[];let r=gw([]);for(const o of t){const c=[...n,o],u=gw(c);if(cR(u)>nR)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function gw(e){return JSON.stringify({reason:sR,events:e})}function lR(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function cR(e){return new TextEncoder().encode(e).byteLength}function uR(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(ex(e))}function JC(){try{const e=window.localStorage.getItem(ZC);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-Af):[]}}catch{return null}}function dR(e){const t=e.at(-1);if(!t)return;const n=JC(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(ex(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-Af)};try{window.localStorage.setItem(ZC,JSON.stringify(o))}catch{}}function hR(e){try{window.localStorage.setItem(GC,JSON.stringify(e))}catch{}}function fR(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:Eu(t.id,128)}:{},at:t.at.slice(0,40),event:Eu(t.event,80),...t.data&&typeof t.data=="object"?{data:tx(t.data)}:{}}}function pR(){return sg=(sg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${sg.toString(36)}`.slice(0,128)}function ex(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function tx(e){const t={};for(const[n,r]of Object.entries(e).slice(0,tR)){const o=Eu(n,64);if(!o||mR(o))continue;const c=gR(r);c!==void 0&&(t[o]=c)}return t}function mR(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function gR(e){if(typeof e=="string")return vR(e,iR);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Eu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function vR(e,t){return _R(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function _R(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 bR(){return typeof document>"u"?void 0:document.visibilityState}function yR(){return typeof navigator>"u"?void 0:navigator.onLine}function ix(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function SR(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function wR(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function CR(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 xR(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const nx="nterminal.notifications.completionEnabled",ib="nterminal.notifications.completionToastEnabled",nb="nterminal.notifications.completionToastDurationSeconds",sb="nterminal.notifications.completionToastPersistent",iv="nterminal:completion-toast-display",nv="nterminal:notification-focus",gu=6.5,sv=2,rv=60;function Of(){return typeof window<"u"&&"Notification"in window}function rb(){try{return window.localStorage.getItem(nx)==="true"}catch{return!1}}function vw(e){try{window.localStorage.setItem(nx,e?"true":"false")}catch{}}function Mo(){return{enabled:DR(),durationSeconds:ER(),persistUntilDismissed:RR()}}function kR(e){if(typeof window<"u"){try{window.localStorage.setItem(ib,e?"true":"false")}catch{}ab()}return Mo()}function _w(e){const t=rx(e);if(typeof window<"u"){try{window.localStorage.setItem(nb,String(t))}catch{}ab()}return Mo()}function TR(e){if(typeof window<"u"){try{window.localStorage.setItem(sb,e?"true":"false")}catch{}ab()}return Mo()}function sx(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===ib||n.key===nb||n.key===sb)&&e()};return window.addEventListener(iv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(iv,e),window.removeEventListener("storage",t)}}function Kl(){return Of()?window.Notification.permission:"unsupported"}function ER(){if(typeof window>"u")return gu;try{const e=window.localStorage.getItem(nb);return e===null?gu:rx(Number(e))}catch{return gu}}function DR(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(ib)!=="false"}catch{return!0}}function RR(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sb)==="true"}catch{return!1}}function rx(e){if(!Number.isFinite(e))return gu;const t=Math.round(e*2)/2;return Math.max(sv,Math.min(rv,t))}function ab(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(iv))}async function ax(){if(!Of())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Kl()}}function MR(e){if(!Of()||Kl()!=="granted"||!rb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=Nf({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:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),NR(r)})}catch{}}function NR(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(nv,{detail:e}))}const bw="nterminal.push.clientId",AR=2e4,yw=[5e3,3e4,12e4];function Ar(){try{const e=window.localStorage.getItem(bw);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${ov()}`;return window.localStorage.setItem(bw,t),t}catch{return`client-${ov()}`}}function LR(){return`page-${ov()}`}function Bf(){const e=typeof window<"u"&&window.isSecureContext===!0,t=HR(),n=UR(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function OR(e,t){const n=Bf();if(!n.supported)throw new Error(n.reason);if((Kl()==="granted"?"granted":await ax())!=="granted")throw new Error("permission_denied");const o=Ar(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await KR(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:cx(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:lx(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:ox(n.deviceKind),alwaysNotify:t})}async function BR(e){const t=Bf();if(!t.supported||Kl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Ar(),c=await WR(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&av(r,u.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&av(r,m.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:cx(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:lx(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:ox(t.deviceKind),alwaysNotify:!1}),!0}function jR(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=y=>{t||n||(n=!0,BR(e).then(b=>{r=0,b&&vn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(vn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&r<yw.length){const w=yw[r++];o=window.setTimeout(()=>{o=null,u("retry")},w)}}).finally(()=>{n=!1}))},m=y=>{c(),r=0,u(y)},g=()=>m("online"),p=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function IR(e){const t=Ar();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 zR(e,t){await e.updatePushNotificationDevice({clientId:Ar(),alwaysNotify:t})}function PR(e){if(typeof window>"u")return()=>{};const t=Ar(),n=LR();let r=null,o=!1;const c=(p=!0)=>{const y=Bf();e.updatePushPresence({clientId:t,pageId:n,visibilityState:FR(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:rb()&&Kl()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),AR))},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),u(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function HR(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function UR(){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 ox(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function FR(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function lx(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function KR(e,t){const n=await e.pushManager.getSubscription();return n?av(n,t)?n:(await n.unsubscribe(),null):null}function av(e,t){const n=e.options.applicationServerKey;return n?ux(n)===t:!0}async function WR(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return ux(t)}function cx(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let u=0;u<r.length;u+=1)c[u]=r.charCodeAt(u);return o}function ux(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function ov(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Nr(e,t){const n=[Yi,...t.map(u=>u.id)],r=new Set(n),o=new Set,c=[];for(const u of e??[])!r.has(u)||o.has(u)||(o.add(u),c.push(u));for(const u of n)o.has(u)||c.push(u);return c}function $R(e,t){return Nr(e,t).map(n=>n===Yi?null:n)}function qR(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function VR(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Sw="Local",YR=3e4,XR=2,GR=6,dx="nterminal.serverList.viewMode.v1";function ZR(){try{return window.localStorage.getItem(dx)==="list"?"list":"stats"}catch{return"stats"}}function QR(e){try{window.localStorage.setItem(dx,e)}catch{}}function JR(e,t){const n=new Map(e.map(r=>[r.id,r]));return Nr(t,e).flatMap(r=>{if(r===Yi)return[{kind:"main",id:Yi}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function ww(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function hx(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${ps(e.value.cpuPercent)} ${ob(e.value)}`,`MEM ${ps(e.value.memoryPercent)} ${Br(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${ps(e.value.diskPercent)} ${Br(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${ps(e.value.swapPercent)} ${Br(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function Cw(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${ps(e.value.cpuPercent)} (${ob(e.value)})`,`RAM ${ps(e.value.memoryPercent)} (${Br(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${ps(e.value.diskPercent)} (${Br(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${ps(e.value.swapPercent)} (${Br(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function eM(e,t){const n=hx(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function ps(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function ob(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`:`${lv(e.cpuPercent/100*t)}/${t} cores`}function Br(e,t){return!xw(e)||!xw(t)?"–/–":tM(e,t)}function tM(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${lv(e/r)}/${lv(t/r)} ${n}`}function lv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function xw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function vh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function iM(e){return[{label:"CPU",percent:ps(e.cpuPercent),detail:ob(e),tone:vh(e.cpuPercent)},{label:"MEM",percent:ps(e.memoryPercent),detail:Br(e.memoryUsedBytes,e.memoryTotalBytes),tone:vh(e.memoryPercent)},{label:"DISK",percent:ps(e.diskPercent),detail:Br(e.diskUsedBytes,e.diskTotalBytes),tone:vh(e.diskPercent)},{label:"SWAP",percent:ps(e.swapPercent),detail:Br(e.swapUsedBytes,e.swapTotalBytes),tone:vh(e.swapPercent)}]}function nM({entry:e}){return e?.status==="offline"?h.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?h.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=>h.jsxs("span",{className:"server-list-stat-cell",children:[h.jsxs("span",{className:"server-list-stat-head",children:[h.jsx("span",{className:"server-list-stat-label",children:t}),h.jsx("span",{className:"server-list-stat-value",children:"–"})]}),h.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):h.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:Cw(e),"aria-label":Cw(e),children:iM(e.value).map(t=>h.jsxs("span",{className:"server-list-stat-cell",children:[h.jsxs("span",{className:"server-list-stat-head",children:[h.jsx("span",{className:"server-list-stat-label",children:t.label}),h.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),h.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function kw({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,onManageAccounts:u,renderServerChildren:m,compact:g=!1}){const[p,y]=v.useState([]),[b,w]=v.useState([Yi]),[C,S]=v.useState(null),[R,B]=v.useState(null),[A,U]=v.useState(""),Y=v.useRef(null),[K,se]=v.useState(()=>ZR()),[Q,z]=v.useState(null),[_e,ie]=v.useState(null),[ke,ne]=v.useState({}),X=v.useRef({}),G=v.useRef(0),q=v.useRef([]),oe=v.useRef([Yi]),L=v.useRef(null);v.useEffect(()=>{q.current=p},[p]),v.useEffect(()=>{const le=Nr(b,p);oe.current=le,ww(le,b)||w(le)},[p,b]),v.useEffect(()=>{let le=!1;return e.listAgents().then(E=>{le||(y(E.agents),w(Nr(E.serverOrder,E.agents)))}).catch(()=>{}),e.getMainInfo().then(E=>{le||S(E.name)}).catch(()=>{}),()=>{le=!0}},[e,o]),v.useEffect(()=>{R&&(Y.current?.focus(),Y.current?.select())},[R]),v.useEffect(()=>{let le=!1;function E(){const ge=[{key:Yi,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...p.map(F=>({key:F.id,load:()=>e.getAgentStats(F.id),probe:async()=>(await e.pingAgent(F.id)).ok}))],Te=new Set(ge.map(F=>F.key));for(const F of Object.keys(X.current))Te.has(F)||delete X.current[F];ne(F=>{const Se={};for(const xe of Te)xe in F&&(Se[xe]=F[xe]);return Se});for(const F of ge)F.load().then(Se=>{le||(X.current[F.key]=0,ne(xe=>Te.has(F.key)?{...xe,[F.key]:{status:"online",value:Se,stale:!1}}:xe))}).catch(async Se=>{if(le)return;if(Se instanceof kn&&Se.status===401&&F.key===Yi){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(F.key===Yi&&Se instanceof kn){X.current[F.key]=0,ne(he=>{if(!Te.has(F.key))return he;const je=he[F.key];return{...he,[F.key]:{status:"online",value:je?.value??null,stale:!0}}});return}if(F.probe)try{if(await F.probe()){if(le)return;X.current[F.key]=0,ne(he=>{if(!Te.has(F.key))return he;const je=he[F.key];return{...he,[F.key]:{status:"online",value:je?.value??null,stale:!0}}});return}}catch(he){if(le)return;if(he instanceof kn&&he.status===401){r?.({source:F.key===Yi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const xe=(X.current[F.key]??0)+1;X.current[F.key]=xe,xe>=XR&&ne(he=>Te.has(F.key)?{...he,[F.key]:{status:"offline",value:he[F.key]?.value??null,stale:!0}}:he)})}E();const V=window.setInterval(E,YR);return()=>{le=!0,window.clearInterval(V)}},[e,p,r]);function M(le){le==="main"?(U(C??""),B({kind:"main"})):(U(le.name),B({kind:"agent",id:le.id}))}async function j(){if(!R)return;const le=A.trim(),E=R;if(B(null),E.kind==="main"){const V=le||"";try{const ge=await e.renameMain(V);S(ge.name)}catch{}}else{if(!le)return;const V=p.find(ge=>ge.id===E.id)?.name;y(ge=>ge.map(Te=>Te.id===E.id?{...Te,name:le}:Te));try{await e.renameAgent(E.id,le)}catch{V!==void 0&&y(ge=>ge.map(Te=>Te.id===E.id?{...Te,name:V}:Te))}}}function re(){B(null)}function ye(le){se(le),QR(le)}function N(le,E,V){if(le===E)return;const ge=Nr(oe.current,q.current),Te=ge.findIndex(He=>He===le),F=ge.findIndex(He=>He===E);if(Te<0||F<0)return;const Se=[...ge],[xe]=Se.splice(Te,1);if(!xe)return;const he=Se.findIndex(He=>He===E);if(he<0)return;const je=V==="before"?he:he+1;if(Se.splice(je,0,xe),ww(Se,ge))return;const Ie=G.current+1;G.current=Ie,oe.current=Se,w(Se),e.reorderAgents(Se).then(He=>{if(G.current===Ie){q.current=He.agents;const et=Nr(He.serverOrder,He.agents);oe.current=et,y(He.agents),w(et)}}).catch(async()=>{if(G.current===Ie)try{const He=await e.listAgents();if(G.current===Ie){q.current=He.agents;const et=Nr(He.serverOrder,He.agents);oe.current=et,y(He.agents),w(et)}}catch{G.current===Ie&&(oe.current=ge,w(ge))}})}function W(le,E){const V=Nr(oe.current,q.current),ge=V.findIndex(F=>F===le),Te=V[ge+E];ge<0||!Te||N(le,Te,E<0?"before":"after")}function ue(le,E){E.pointerType==="mouse"&&E.button!==0||(E.stopPropagation(),L.current={sourceId:le,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function Ce(le){const E=L.current;if(!E||E.pointerId!==le.pointerId)return;const V=Math.hypot(le.clientX-E.startX,le.clientY-E.startY);if(!E.active){if(V<GR)return;E.active=!0,z(E.sourceId)}const Te=document.elementFromPoint(le.clientX,le.clientY)?.closest("[data-server-id]"),F=Te?.dataset.serverId??null;if(!Te||!F||F===E.sourceId){E.targetId=null,ie(null);return}const Se=Te.getBoundingClientRect(),xe=le.clientY<Se.top+Se.height/2?"before":"after";E.targetId=F,E.placement=xe,ie({serverId:F,placement:xe})}function Le(le){const E=L.current;!E||E.pointerId!==le.pointerId||(le.stopPropagation(),le.currentTarget.releasePointerCapture?.(le.pointerId),L.current=null,z(null),ie(null),E.active&&E.targetId&&N(E.sourceId,E.targetId,E.placement))}function Me(le){const E=L.current;E&&E.pointerId===le.pointerId&&le.currentTarget.releasePointerCapture?.(le.pointerId),L.current=null,z(null),ie(null)}const Ne=C?.trim()||Sw,Oe=R?.kind==="main",Ve=K==="stats",Ye=JR(p,b),Be=Ye.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:Ne},...p.map(le=>({agentId:le.id,label:le.name}))])},[p,Ne,c]),g?h.jsx("div",{className:"server-list server-list--compact",children:Ye.map(le=>{const E=le.kind==="main",V=E?Ne:le.agent.name,ge=E?Yi:le.id,Te=ke[ge],F=hx(Te);return h.jsxs("button",{type:"button",className:`server-list-chip${(E?t===null:t===le.id)?" server-list-chip--active":""}`,onClick:()=>n(E?null:le.id),"aria-label":`${V}${F?` — ${F}`:""}`,title:`${V}${F?` — ${F}`:""}`,children:[h.jsx("span",{className:"server-list-chip-initial",children:VR(V)}),h.jsx("span",{className:"server-list-chip-pip","data-status":qR(Te)})]},le.id)})}):h.jsxs("div",{className:`server-list server-list--${K}`,children:[h.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[h.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="list",onClick:()=>ye("list"),title:"Show server names only",children:"List"}),h.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="stats",onClick:()=>ye("stats"),title:"Show resource usage",children:"Stats"})]}),Ye.map(le=>{const E=le.kind==="main",V=E?Ne:le.agent.name,ge=E?Yi:le.id,Te=E?t===null:t===le.id,F=E?Oe:R?.kind==="agent"&&R.id===le.id,Se=m?.({agentId:E?null:le.id,serverId:le.id,label:V,active:Te}),xe=_e?.serverId===le.id&&Q!==le.id?` server-list-section--drop-target server-list-section--drop-${_e.placement}`:"";return h.jsxs("section",{className:`server-list-section${xe}`,"aria-label":`${V} server`,children:[h.jsx("div",{className:["server-list-row",Q===le.id?"server-list-row--dragging":"",_e?.serverId===le.id&&Q!==le.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":le.id,children:F?h.jsxs(h.Fragment,{children:[Be?h.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,h.jsx("form",{className:"server-list-editor",onSubmit:he=>{he.preventDefault(),j()},children:h.jsx("input",{ref:Y,"aria-label":E?"Rename main server":`Rename ${V}`,value:A,onChange:he=>U(he.target.value),onBlur:()=>{j()},onKeyDown:he=>{he.key==="Escape"&&(he.preventDefault(),re())},placeholder:E?Sw:void 0})})]}):h.jsxs(h.Fragment,{children:[Be?h.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":le.id,title:"Drag to reorder","aria-label":`Reorder ${V}`,"aria-grabbed":Q===le.id,onPointerDown:he=>ue(le.id,he),onPointerMove:Ce,onPointerUp:Le,onPointerCancel:Me,onKeyDown:he=>{(he.key==="ArrowUp"||he.key==="ArrowDown")&&(he.preventDefault(),he.stopPropagation(),W(le.id,he.key==="ArrowUp"?-1:1))},onClick:he=>he.stopPropagation(),children:"::"}):null,h.jsxs("div",{className:`server-list-item${Te?" server-list-item--active":""}`,title:eM(V,ke[ge]),children:[h.jsxs("div",{className:"server-list-item-header",children:[h.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(E?null:le.id),onDoubleClick:he=>{he.preventDefault(),M(E?"main":{id:le.id,name:V})},children:[h.jsx("span",{className:"server-list-dot"}),h.jsx("span",{className:"server-list-name",title:E?void 0:le.agent.url??"Outbound connection to main",children:V})]}),u?h.jsx("span",{className:"server-list-provider-actions","aria-label":`${V} account management`,children:["codex","claude"].map(he=>h.jsx("button",{type:"button",className:"server-list-provider-button",title:`Manage ${he==="codex"?"Codex":"Claude"} accounts`,"aria-label":`Manage ${he==="codex"?"Codex":"Claude"} accounts on ${V}`,onClick:()=>u({agentId:E?null:le.id,label:V},he),children:h.jsx("img",{src:`/brand/${he}.webp`,alt:""})},he))}):null]}),Ve?h.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(E?null:le.id),children:h.jsx(nM,{entry:ke[ge]})}):null]})]})}),Se?h.jsx("div",{className:"server-list-children",children:Se}):null]},le.id)})]})}function sM({provider:e,serverLabel:t,api:n,onClose:r,onLoginStarted:o}){const[c,u]=v.useState(null),[m,g]=v.useState(!0),[p,y]=v.useState(null),[b,w]=v.useState(null),[C,S]=v.useState(""),[R,B]=v.useState(()=>Date.now()),A=v.useRef(0),U=v.useCallback(async()=>{const z=++A.current;g(!0),w(null);try{const _e=await n.getAccounts();z===A.current&&u(_e)}catch(_e){z===A.current&&w(rg(_e))}finally{z===A.current&&g(!1)}},[n]);v.useEffect(()=>(U(),()=>{A.current+=1}),[U]),v.useEffect(()=>{const z=_e=>{_e.key==="Escape"&&!p&&r()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[r,p]),v.useEffect(()=>{const z=window.setInterval(()=>B(Date.now()),6e4);return()=>window.clearInterval(z)},[]);const Y=v.useMemo(()=>c?.providers.find(z=>z.provider===e)??null,[e,c]);async function K(z,_e){const ie=++A.current;g(!1),y(z),w(null);try{const ke=await _e();ie===A.current&&u(ke)}catch(ke){ie===A.current&&w(rg(ke))}finally{ie===A.current&&y(null)}}async function se(){y("login"),w(null);try{const z=await n.beginAccountLogin(e);o(z.terminal),await U()}catch(z){w(rg(z))}finally{y(null)}}const Q=e==="codex"?"Codex":"Claude";return h.jsx("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:z=>{z.target===z.currentTarget&&!p&&r()},children:h.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${Q} accounts on ${t}`,children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"account-dialog-title",children:[h.jsx(aM,{provider:e}),h.jsxs("div",{children:[h.jsxs("h2",{children:[Q," accounts"]}),h.jsx("p",{children:t})]})]}),h.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",onClick:r,disabled:!!p,children:"x"})]}),h.jsxs("div",{className:"account-dialog-scroll",children:[m?h.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,!m&&Y?h.jsx(rM,{provider:e,status:Y,pendingAction:p,clock:R,label:C,onLabelChange:S,onSelect:z=>{K(`select:${z}`,()=>n.selectAccount(e,z))},onDelete:z=>{K(`delete:${z}`,()=>n.removeAccount(e,z))},onRefresh:z=>{K(`refresh:${z}`,()=>n.refreshAccount(e,z))},onBeginLogin:()=>{se()},onCompleteLogin:()=>{K("complete",()=>n.completeAccountLogin(e,C))},onCancelLogin:()=>{K("cancel",()=>n.cancelAccountLogin(e))}}):null,b?h.jsx("p",{className:"account-dialog-error",role:"alert",children:b}):null]}),h.jsxs("footer",{className:"account-dialog-footer",children:[h.jsx("button",{type:"button",onClick:()=>{U()},disabled:m||!!p,children:"Refresh"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!p,children:"Close"})]})]})})}function rM({provider:e,status:t,pendingAction:n,clock:r,label:o,onLabelChange:c,onSelect:u,onDelete:m,onRefresh:g,onBeginLogin:p,onCompleteLogin:y,onCancelLogin:b}){const w=t.runningPanes.length>0;return t.pendingLogin?h.jsxs("div",{className:"account-dialog-section",children:[h.jsx("p",{children:t.pendingLogin.ready?"Login completed in the new terminal. Name the account to keep it in this server vault.":"Complete sign-in in the login terminal, then return here to save the account."}),t.pendingLogin.ready?h.jsxs("label",{className:"account-dialog-label",children:["Account name",h.jsx("input",{value:o,onChange:C=>c(C.target.value),placeholder:`${e==="codex"?"Codex":"Claude"} account`,maxLength:80})]}):null,h.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready?h.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:y,children:"Save account"}):null,h.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:b,children:"Cancel and restore previous"})]})]}):h.jsxs(h.Fragment,{children:[w?h.jsxs("div",{className:"account-dialog-running",role:"status",children:[h.jsxs("strong",{children:["Exit ",e==="codex"?"Codex":"Claude"," before changing accounts."]}),t.runningPanes.map(C=>h.jsxs("span",{children:[h.jsx("b",{children:C.title}),h.jsx("small",{children:C.cwd})]},C.terminalId))]}):null,h.jsxs("div",{className:"account-dialog-section",children:[h.jsxs("div",{className:"account-dialog-section-heading",children:[h.jsx("span",{children:"Saved accounts"}),h.jsx("button",{type:"button",className:"primary-button",disabled:w||!!n,onClick:p,children:"Add account"})]}),t.profiles.length===0?h.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map(C=>{const S=C.id===t.activeProfileId;return h.jsxs("article",{className:`account-profile${S?" account-profile--active":""}`,children:[h.jsxs("div",{children:[h.jsx("strong",{children:C.label}),h.jsxs("small",{title:lM(C.expiresAt),children:[S?"Active":"Saved"," · ",oM(C.expiresAt,r)]})]}),h.jsxs("div",{className:"account-profile-actions",children:[h.jsx("button",{type:"button",disabled:w||!!n||S,onClick:()=>u(C.id),children:"Use"}),h.jsx("button",{type:"button",disabled:S&&w||!!n,onClick:()=>g(C.id),children:"Refresh"}),h.jsx("button",{type:"button",className:"danger-button",disabled:!!n||S,onClick:()=>m(C.id),children:"Remove"})]})]},C.id)})]})]})}function aM({provider:e}){return h.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function oM(e,t=Date.now()){if(!e||!Number.isFinite(Date.parse(e)))return"Session expiry unavailable";const n=Math.ceil((Date.parse(e)-t)/6e4);if(n<=0)return"Session expired";const r=Math.floor(n/1440),o=Math.floor(n%1440/60),c=n%60;return`Session ${[r?`${r}d`:null,o?`${o}h`:null,`${c}m`].filter(Boolean).join(" ")} remaining`}function lM(e){return!e||!Number.isFinite(Date.parse(e))?"Session expiry timestamp unavailable":`Session expires ${new Date(e).toLocaleString()}`}function rg(e){return e instanceof kn?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",account_operation_busy:"Another account operation is in progress. Try again shortly.",account_process_check_unavailable:"Could not verify running CLI processes. No account was switched.",account_credential_changed:"Credentials changed during refresh. Refresh the account list before trying again.",account_login_already_pending:"Finish or cancel the current sign-in first.",account_login_not_complete:"The provider login has not finished yet.",account_refresh_failed:"The provider rejected this refresh. Sign in again to update the account.",account_refresh_unavailable:"The provider refresh endpoint is temporarily unavailable.",preview_mode:"Account changes are disabled in preview mode."}[e.message]??"The account operation could not be completed.":"The account operation could not be completed."}function cM({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[m,g]=v.useState(null),[p,y]=v.useState(""),[b,w]=v.useState("");async function C(){try{const[A,U,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(U.networks),u(Y.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{C()},[]);async function S(A){await e.revokeDevice(A),await C()}async function R(A){await e.removeNetwork(A),await C()}async function B(A){A.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),w(""),await C()}catch(U){g(U instanceof Error?U.message:"Failed to add network")}}return h.jsxs(h.Fragment,{children:[m?h.jsx("p",{className:"form-error",children:m}):null,h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Trusted devices"}),h.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?h.jsx("p",{className:"muted",children:"No trusted devices."}):h.jsx("ul",{className:"security-list",children:t.map(A=>h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsxs("span",{className:"security-item-label",children:[A.label,A.current?h.jsx("span",{className:"security-badge",children:"this device"}):null]}),h.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),h.jsx("button",{type:"button",className:"security-remove",onClick:()=>{S(A.id)},children:"revoke"})]},A.id))})]}),h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Trusted networks"}),h.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?h.jsx("p",{className:"muted",children:"No trusted networks."}):h.jsx("ul",{className:"security-list",children:r.map(A=>h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?h.jsx("span",{className:"security-item-meta",children:A.label}):null]}),h.jsx("button",{type:"button",className:"security-remove",onClick:()=>{R(A.id)},children:"remove"})]},A.id))}),h.jsxs("form",{className:"security-add-form",onSubmit:B,children:[h.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:A=>y(A.currentTarget.value),required:!0}),h.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>w(A.currentTarget.value)}),h.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Two-factor authentication"}),h.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."}),h.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await C()},children:"Disable 2FA"})]}):null]})}const uM=1500,lb="nterminal.terminal.fontSize",cb="nterminal.terminal.fontFamily",cv="nterminal:terminal-font-size",uv="nterminal:terminal-font-family",dv=11,hv=20,To=14,sf=[{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:[]}],Bl="meslo";fv(Bl);async function ag(e=To,t=Bl){if(typeof document>"u"||!document.fonts)return;const n=mx(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,uM)})])}function fx(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return To;const n=Math.round(t);return Math.max(dv,Math.min(hv,n))}function px(e){return sf.some(t=>t.id===e)?e:Bl}function fv(e){return mx(e).cssFamily}function mx(e){return sf.find(t=>t.id===e)??sf[0]}function pv(){if(typeof window>"u")return To;try{const e=window.localStorage.getItem(lb);return e?fx(e):To}catch{return To}}function mv(){if(typeof window>"u")return Bl;try{return px(window.localStorage.getItem(cb))}catch{return Bl}}function _h(e){const t=fx(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lb,String(t))}catch{}return window.dispatchEvent(new CustomEvent(cv,{detail:t})),t}function dM(e){const t=px(e);if(typeof window>"u")return t;try{window.localStorage.setItem(cb,t)}catch{}return window.dispatchEvent(new CustomEvent(uv,{detail:t})),t}function gx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===lb&&e()};return window.addEventListener(cv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(cv,e),window.removeEventListener("storage",t)}}function vx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cb&&e()};return window.addEventListener(uv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(uv,e),window.removeEventListener("storage",t)}}const ub="nterminal.terminal.showScrollProgress",gv="nterminal:terminal-scroll-progress",db="nterminal.terminal.tmuxScrollback.shell",hb="nterminal.terminal.tmuxScrollback.agent",fb="nterminal.terminal.tmuxScrollback.overrides",Du="nterminal:terminal-tmux-scrollback",hM=200;function vv(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(ub)!=="false"}catch{return!0}}function fM(e){if(typeof window<"u"){try{window.localStorage.setItem(ub,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(gv,{detail:e}))}return e}function _x(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ub&&e()};return window.addEventListener(gv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(gv,e),window.removeEventListener("storage",t)}}function _v(){return bx(db,!0)}function pM(e){return yx(db,e,Du)}function bv(){return bx(hb,!0)}function mM(e){return yx(hb,e,Du)}function jh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===db||n.key===hb||n.key===fb)&&e()};return window.addEventListener(Du,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Du,e),window.removeEventListener("storage",t)}}function og(e){const n=Sx()[e];return typeof n=="boolean"?n:null}function gM(e,t){if(typeof window<"u"){try{const n=Sx(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-hM);window.localStorage.setItem(fb,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Du,{detail:{terminalId:e,enabled:t}}))}return t}function bx(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 yx(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 Sx(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(fb);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const pb="nterminal.shortcuts.workspace.v1",yv="nterminal:workspace-shortcuts",Ru=[{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:"subagents.toggle",label:"Toggle view agents",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],jf={"server.previous":mi("ArrowUp",{ctrlKey:!0}),"server.next":mi("ArrowDown",{ctrlKey:!0}),"tab.previous":mi("ArrowLeft",{ctrlKey:!0}),"tab.next":mi("ArrowRight",{ctrlKey:!0}),"tab.index":mi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":mi("KeyH",{altKey:!0}),"subagents.toggle":mi("KeyA",{altKey:!0}),"scrollback.toggle":mi("KeyS",{altKey:!0})},vM={"server.previous":mi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":mi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":mi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":mi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":mi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":mi("KeyH",{altKey:!0}),"subagents.toggle":mi("KeyA",{altKey:!0}),"scrollback.toggle":mi("KeyS",{altKey:!0})};function No(){const e=xx(jf);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(pb);if(!t)return e;const n=JSON.parse(t);for(const r of Ru){const o=n[r.id];if(kM(o)){const c=kx(o,r);xM(c,vM[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Tw(){return JSON.stringify(No())}function _M(e,t){const n=No(),r=Ru.find(o=>o.id===e);return r&&(n[e]=kx(t,r),mb(n)),n}function bM(e){const t=No();return t[e]={...jf[e]},mb(t),t}function yM(){const e=xx(jf);return mb(e),e}function vu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===pb&&e()};return window.addEventListener(yv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(yv,e),window.removeEventListener("storage",t)}}function SM(e,t){const n=Dx(e);return!n||EM(n)||t.indexed&&Ex(e)===null||t.requiresPrimaryModifier&&!Tx(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function wx(e){const t=No();for(const n of Ru){const r=t[n.id];if(!(!r||!TM(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=Ex(e);if(o!==null)return{id:n.id,index:o};continue}if(Dx(e)===r.code)return{id:n.id,index:null}}}return null}function _u(e){return Cx(No()[e])}function Cx(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(DM(e.code)),t.join("+")}const wM=()=>_u("split.right"),CM=()=>_u("split.down");function mi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function xx(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function xM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function mb(e){if(!(typeof window>"u")){try{window.localStorage.setItem(pb,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(yv))}}function kx(e,t){return t.requiresPrimaryModifier&&!Tx(e)?{...jf[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Tx(e){return e.ctrlKey||e.altKey||e.metaKey}function kM(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 TM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Ex(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 Dx(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 EM(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function DM(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 RM="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 MM(e="nterminal",t=new Date){return{reason:"permission",message:RM,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function NM(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 Rx=3600*1e3,AM="local",Sv=new Set,Na=new Map;let za={checking:!1,hasUpdates:!1,lastCheckedAt:null},gb=null,bu=null,rf=0,Ta=null;function LM(e){return Sv.add(e),()=>{Sv.delete(e)}}function Ew(){return za}function OM(e){const t=PM();gb=e,vb(),wv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!Pa(e,t))return;const r=za.lastCheckedAt;(r===null||Date.now()-r>=Rx)&&wv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),Pa(e,t)&&zM()}}function BM(e,t){Na.set(e,Mx(t)),jl({...za,hasUpdates:_b(),lastCheckedAt:Date.now()})}function lg(e){e===void 0?Na.clear():Na.set(e,!1),jl({...za,hasUpdates:_b()})}async function wv(e,t){if(!Pa(e,t))return;if(Ta&&Ta.api===e&&Ta.runId===t)return Ta.promise;jl({...za,checking:!0});const n=jM(e,t).finally(()=>{Ta?.promise===n&&(Ta=null),Pa(e,t)&&(jl({...za,checking:!1,lastCheckedAt:Date.now()}),IM(e,t))});return Ta={api:e,runId:t,promise:n},n}async function jM(e,t){try{const n=await e.listAgents();if(!Pa(e,t))return;const r=[{key:AM,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const u=await c.check();o.set(c.key,Mx(u))}catch{o.set(c.key,Na.get(c.key)??!1)}})),!Pa(e,t))return;Na.clear();for(const[c,u]of o)Na.set(c,u);jl({...za,hasUpdates:_b()})}catch{}}function IM(e,t){Pa(e,t)&&(vb(),bu=window.setTimeout(()=>{bu=null,Pa(e,t)&&wv(e,t)},Rx))}function zM(){rf+=1,vb(),gb=null,Ta=null,Na.clear(),jl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function vb(){bu!==null&&(window.clearTimeout(bu),bu=null)}function PM(){return rf+=1,rf}function Pa(e,t){return gb===e&&rf===t}function Mx(e){return e.updateAvailable===!0}function _b(){return Array.from(Na.values()).some(Boolean)}function jl(e){za=e;for(const t of Array.from(Sv))t()}const HM=e=>new Promise(t=>setTimeout(t,e));function UM({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[u,m]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[w,C]=v.useState({});function S(M,j){c(re=>({...re,[M]:{...re[M],...j}}))}function R(M,j){C(re=>({...re,[M]:{status:re[M]?.status??null,busy:re[M]?.busy??!1,error:re[M]?.error??null,...j}}))}const B=M=>M.id===null?e.getVersion():e.getAgentVersion(M.id),A=M=>M.id===null?e.checkUpdate():e.checkAgentUpdate(M.id),U=M=>M.id===null?e.runUpdate():e.runAgentUpdate(M.id),Y=M=>M.id===null?e:ko(M.id);v.useEffect(()=>{let M=!1;return e.listAgents().then(async j=>{if(M)return;let re="Local";try{re=(await e.getMainInfo()).name?.trim()||re}catch{}if(M)return;const ye=new Map(j.agents.map(W=>[W.id,W])),N=Nr(j.serverOrder,j.agents).flatMap(W=>{if(W===Yi)return[{key:"local",id:null,name:re}];const ue=ye.get(W);return ue?[{key:ue.id,id:ue.id,name:ue.name}]:[]});r(N);for(const W of N)B(W).then(ue=>S(W.key,{version:ue,manualUpdate:ue.manualUpdate??null})).catch(ue=>S(W.key,{error:ue instanceof Error?ue.message:"unreachable"})),q(W)}).catch(()=>{}),()=>{M=!0}},[]);async function K(M){S(M.key,{busy:!0,status:"checking…",error:void 0});try{const j=await A(M);BM(M.key,j),S(M.key,{latestVersion:j.latestVersion,updateAvailable:j.updateAvailable,status:ne(j),...j.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(j){S(M.key,{busy:!1,error:j instanceof Error?j.message:"check failed"})}}async function se(){m(!0),await Promise.all(n.map(M=>K(M))),m(!1)}async function Q(M,j){const re=Date.now()+18e4;for(;Date.now()<re;){await HM(3e3);try{const ye=await B(M);if(j&&ye.runningVersion!==j.runningVersion)return ye}catch{}}return null}async function z(M){let j=o[M.key]?.version;if(!j)try{j=await B(M),S(M.key,{version:j,manualUpdate:j.manualUpdate??null})}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}S(M.key,{busy:!0,status:"updating…",error:void 0});let re;try{re=await U(M)}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!re.ok){const N=re.manualUpdate??(NM(re.message)?MM():null);return N?(S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(S(M.key,{busy:!1,status:void 0,error:re.message}),"failed")}if(!re.changed)return S(M.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),lg(M.key),"unchanged";S(M.key,{status:"restarting…"});const ye=await Q(M,j);return ye?(S(M.key,{busy:!1,version:ye,updateAvailable:!1,status:"updated",manualUpdate:ye.manualUpdate??null}),lg(M.key),M.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(S(M.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function _e(M){if(!(M.id===null||!window.confirm([`Delete secondary server "${M.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
|
+
`)))){S(M.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const re=await e.uninstallAgent(M.id);r(ye=>ye.filter(N=>N.key!==M.key)),c(ye=>{const N={...ye};return delete N[M.key],N}),lg(M.key),t?.(M.id),p(re.message)}catch(re){S(M.key,{busy:!1,status:void 0,error:re instanceof Error?re.message:"delete failed"})}}}async function ie(){m(!0),p(null);const M=n.filter(ue=>ue.id!==null),j=n.find(ue=>ue.id===null),re=await Promise.all(M.map(ue=>z(ue))),ye=re.filter(ue=>ue==="failed").length;let N=re.filter(ue=>ue==="manual").length,W=null;if(j&&(W=await z(j),W==="manual"&&(N+=1),W==="updated")){ye>0&&p("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&&N>0?p("Some servers failed and some need manual update. Check each marked row."):ye>0?p("Some secondary servers failed to update. Check their rows and retry."):N>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function ke(M){return M?M.error?M.error:M.status?M.status:M.manualUpdate?"manual update required":M.version?`v${M.version.version}`:"…":"…"}function ne(M){return M.error?M.error:typeof M.updateAvailable=="boolean"?M.updateAvailable?`latest v${M.latestVersion??"available"}`:"up to date":"unknown"}function X(M){const j=M?.version;return j?`npm package v${j.runningVersion}`:""}async function G(M,j){try{await KM(j),S(M,{copiedCommand:!0}),window.setTimeout(()=>S(M,{copiedCommand:!1}),1800)}catch(re){S(M,{error:re instanceof Error?re.message:"copy failed"})}}async function q(M,j=!1){try{const re=await Y(M).getCodeServerStatus(j?{checkLatest:!0}:void 0);R(M.key,{status:re,error:null})}catch(re){R(M.key,{error:re instanceof Error?re.message:"code-server status failed"})}}async function oe(M,j){if(j==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${M.name} and stop its running VS Code sessions?`))return;const re=Y(M);R(M.key,{busy:!0,error:null});try{if(j==="install"){const ye=await re.installCodeServer();R(M.key,{status:ye.status})}else if(j==="update"){const ye=await re.updateCodeServer();R(M.key,{status:ye.status})}else if(j==="stop")R(M.key,{status:await re.stopCodeServer()});else{const ye=await re.uninstallCodeServer();R(M.key,{status:ye.status})}}catch(ye){R(M.key,{error:ye instanceof Error?ye.message:"code-server action failed"})}finally{R(M.key,{busy:!1})}}const L=n.filter(M=>w[M.key]?.status?.job?.status==="running").map(M=>M.key).join("|");return v.useEffect(()=>{const M=n.filter(re=>w[re.key]?.status?.job?.status==="running");if(M.length===0)return;const j=window.setInterval(()=>{for(const re of M)q(re)},1e3);return()=>window.clearInterval(j)},[L]),h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Servers"}),h.jsxs("div",{className:"update-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{se()},disabled:u,children:"Check for updates"}),h.jsx("button",{type:"button",onClick:()=>{ie()},disabled:u,children:"Update all"})]}),g?h.jsx("p",{className:"settings-status",children:g}):null,y?h.jsxs("div",{className:"server-reload-required",role:"status",children:[h.jsx("span",{children:"Main server update is ready."}),h.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,h.jsx("ul",{className:"security-list",children:n.map(M=>{const j=o[M.key],re=X(j),ye=j?.manualUpdate??null,N=w[M.key]??{status:null,busy:!1,error:null},W=j?.version!==void 0&&j?.updateAvailable!==!1&&!j?.busy&&!u,ue=M.id!==null&&!j?.busy&&!u;return h.jsxs("li",{children:[h.jsxs("div",{className:"server-row-main",children:[h.jsxs("div",{children:[h.jsxs("span",{className:"security-item-label",children:[M.name,M.id===null?h.jsx("span",{className:"security-badge",children:"Main"}):null]}),h.jsxs("span",{className:"security-item-meta",children:[re?`${re} — `:"",ke(j)]})]}),ye?h.jsxs("div",{className:"server-manual-update",children:[h.jsx("span",{children:ye.message}),h.jsxs("div",{className:"server-manual-command",children:[h.jsx("code",{children:ye.command}),h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{G(M.key,ye.command)},children:j?.copiedCommand?"Copied":"Copy"})]})]}):null,h.jsx(FM,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{q(M,!0)},onInstall:()=>{oe(M,"install")},onUpdate:()=>{oe(M,"update")},onStop:()=>{oe(M,"stop")},onUninstall:()=>{oe(M,"uninstall")}})]}),h.jsxs("div",{className:"server-row-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{z(M)},disabled:!W,children:j?.busy?"…":"Update"}),M.id!==null?h.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{_e(M)},disabled:!ue,children:"Delete"}):null]})]},M.key)})})]})}function FM({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onStop:u,onUninstall:m}){const g=e?.job??null,p=g?.status==="running",y=e!==null,b=e?.installed===!0,w=(e?.instances.length??0)>0,C=e?.supported!==!1,S=e===null&&!n;return h.jsxs("div",{className:"server-code-addon",children:[h.jsxs("div",{children:[h.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),h.jsxs("span",{className:"security-item-meta",children:[C?S?"checking...":b?`code-server v${e?.version??"unknown"}${w?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?h.jsx("p",{className:"settings-error",children:n}):null,g?h.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
|
|
16
|
+
`):`${g.action} ${g.status}`}):null,h.jsxs("div",{className:"server-code-addon-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:t||p||!C,children:"Check"}),b?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||p||!C,children:e?.updateAvailable?"Update code-server":"Reinstall"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!w,children:"Stop"}),h.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||p,children:"Uninstall"})]}):h.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:!y||S||t||p||!C,children:"Install code-server"})]})]})}async function KM(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 bh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function WM({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??kf(),[t]),[u,m]=v.useState(()=>pv()),[g,p]=v.useState(()=>mv()),[y,b]=v.useState(()=>vv()),[w,C]=v.useState(()=>_v()),[S,R]=v.useState(()=>bv()),[B,A]=v.useState(()=>ja()),[U,Y]=v.useState(()=>No()),[K,se]=v.useState(null),[Q,z]=v.useState(null),[_e,ie]=v.useState("appearance"),[ke,ne]=v.useState(()=>rb()),[X,G]=v.useState(()=>Mo()),[q,oe]=v.useState(()=>Kl()),[L,M]=v.useState([]),[j,re]=v.useState([]),[ye,N]=v.useState([]),[W,ue]=v.useState(5*1024*1024),[Ce,Le]=v.useState(!1),[Me,Ne]=v.useState(null),[Oe,Ve]=v.useState(null),[Ye,Be]=v.useState(!1),[le,E]=v.useState(null),[V,ge]=v.useState(null),Te=v.useRef(null),F=v.useRef(null),Se=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),xe=v.useMemo(()=>new Set(j),[j]),he=!qM(j,ye),je=v.useMemo(()=>Bf(),[]),Ie=Oe?.displayMode==="standalone"&&(Oe.deviceKind==="mobile"||Oe.deviceKind==="tablet");v.useEffect(()=>gx(()=>m(pv())),[]),v.useEffect(()=>vx(()=>p(mv())),[]),v.useEffect(()=>_x(()=>b(vv())),[]),v.useEffect(()=>jh(()=>{C(_v()),R(bv())}),[]),v.useEffect(()=>q_(()=>A(ja())),[]),v.useEffect(()=>vu(()=>Y(No())),[]),v.useEffect(()=>sx(()=>G(Mo())),[]),v.useEffect(()=>{if(!K)return;const ee=Ru.find(mt=>mt.id===K);if(!ee)return;const Pe=mt=>{if(mt.preventDefault(),mt.stopPropagation(),mt.key==="Escape"){se(null),z(null);return}const lt=SM(mt,ee);if(!lt){z($M(ee));return}Y(_M(K,lt)),se(null),z(null)};return window.addEventListener("keydown",Pe,!0),()=>window.removeEventListener("keydown",Pe,!0)},[K]),v.useEffect(()=>{let ee=!1;return c.listNotificationAssets().then(Pe=>{ee||Qt(Pe)}).catch(Pe=>{ee||Ne(wl(Pe))}),()=>{ee=!0}},[c]),v.useEffect(()=>{let ee=!1;return c.getPushNotificationStatus(Ar()).then(Pe=>{ee||(Ve(Pe.currentDevice),E(null))}).catch(Pe=>{ee||E(wl(Pe))}),()=>{ee=!0}},[c]);function He(ee){m(_h(Number(ee)))}function et(ee){G(_w(Number(ee)))}function Mt(ee){ie(ee);const Pe=F.current,mt=Se.current[ee];if(!Pe||!mt)return;const lt=Math.max(0,Dw(mt,Pe)-12);typeof Pe.scrollTo=="function"?Pe.scrollTo({top:lt,behavior:"smooth"}):Pe.scrollTop=lt}function pt(){const ee=F.current;if(!ee)return;if(ee.scrollTop+ee.clientHeight>=ee.scrollHeight-2){ie(bh[bh.length-1].id);return}let Pe="appearance";const mt=ee.scrollTop+Math.min(180,Math.max(48,ee.clientHeight*.28));for(const lt of bh){const Dt=Se.current[lt.id];Dt&&Dw(Dt,ee)<=mt&&(Pe=lt.id)}ie(Pe)}function kt(ee){Y(bM(ee)),se(null),z(null)}function yt(){Y(yM()),se(null),z(null)}function Qt(ee){const Pe=ee.assets.filter(mt=>mt.enabled).map(mt=>mt.id);M(ee.assets),re(Pe),N(Pe),ue(ee.maxFileBytes),Ne(null)}async function ci(){if(ke){vw(!1),ne(!1);return}let ee=q;ee==="default"&&(ee=await ax(),oe(ee)),ee==="granted"&&(vw(!0),ne(!0))}async function de(){Be(!0),E(null),ge(null);try{if(Oe)await IR(c),Ve(null);else{await OR(c,!1);const ee=await c.getPushNotificationStatus(Ar());Ve(ee.currentDevice)}}catch(ee){E(ug(ee))}finally{Be(!1)}}async function Ue(ee){Be(!0),E(null),ge(null);try{await zR(c,ee);const Pe=await c.getPushNotificationStatus(Ar());Ve(Pe.currentDevice)}catch(Pe){E(ug(Pe))}finally{Be(!1)}}async function tt(){Be(!0),E(null),ge(null);try{await c.testPushNotification({clientId:Ar()}),ge("Test notification accepted by the push service.")}catch(ee){E(ug(ee))}finally{Be(!1)}}async function Ge(ee){const Pe=ee?.[0];if(Pe){if(Pe.size>W){Ne(`File must be ${cg(W)} or smaller.`),ot();return}if(Pe.type!=="video/mp4"&&Pe.type!=="video/webm"){Ne("Upload an MP4 or WebM video."),ot();return}Le(!0),Ne(null);try{await c.uploadNotificationAsset(Pe),Qt(await c.listNotificationAssets()),r?.()}catch(mt){Ne(wl(mt))}finally{Le(!1),ot()}}}async function xt(ee){Le(!0),Ne(null);try{await c.deleteNotificationAsset(ee),Qt(await c.listNotificationAssets()),r?.()}catch(Pe){Ne(wl(Pe))}finally{Le(!1)}}function ot(){Te.current&&(Te.current.value="")}function Hi(ee,Pe){const mt=new Set(j);if(Pe?mt.add(ee):mt.delete(ee),mt.size===0){Ne("Keep at least one toast video selected.");return}Ne(null),re(Array.from(mt))}async function _i(){if(j.length===0){Ne("Keep at least one toast video selected.");return}Le(!0),Ne(null);try{const ee=await c.updateNotificationAssetSelection({enabledAssetIds:j});Qt(ee),r?.()}catch(ee){Ne(wl(ee))}finally{Le(!1)}}return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:h.jsxs("div",{className:"security-panel settings-panel",onClick:ee=>ee.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{children:"Settings"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),h.jsxs("div",{className:"settings-layout",children:[h.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:bh.map(ee=>h.jsxs("button",{type:"button","data-active":_e===ee.id?"true":"false","aria-current":_e===ee.id?"true":void 0,onClick:()=>Mt(ee.id),children:[ee.label,ee.id==="servers"&&n?h.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ee.id))}),h.jsxs("div",{ref:F,className:"settings-content",onScroll:pt,children:[h.jsxs("section",{id:"settings-appearance",ref:ee=>{Se.current.appearance=ee},className:"security-section settings-section",children:[h.jsx("h3",{children:"Appearance"}),h.jsx("div",{className:"settings-section-heading",children:h.jsxs("div",{children:[h.jsx("span",{className:"settings-control-title",children:"Theme"}),h.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),h.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Qh.map(ee=>h.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":B===ee.id,"data-active":B===ee.id?"true":"false",onClick:()=>A(v2(ee.id)),style:{"--settings-theme-bg":ee.tokens.bg,"--settings-theme-bg-2":ee.tokens.bg2,"--settings-theme-sidebar":ee.tokens.bgSidebar,"--settings-theme-line":ee.tokens.line,"--settings-theme-fg":ee.tokens.fg,"--settings-theme-fg-2":ee.tokens.fg2,"--settings-theme-accent":ee.tokens.accent,"--settings-theme-xterm-bg":ee.xterm.background,"--settings-theme-xterm-fg":ee.xterm.foreground,"--settings-theme-xterm-selection":ee.xterm.selectionBackground},children:[h.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[h.jsxs("span",{className:"settings-theme-preview-sidebar",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]}),h.jsxs("span",{className:"settings-theme-preview-main",children:[h.jsxs("span",{className:"settings-theme-preview-tabs",children:[h.jsx("span",{}),h.jsx("span",{})]}),h.jsxs("span",{className:"settings-theme-preview-terminal",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]})]})]}),h.jsxs("span",{className:"settings-theme-card-copy",children:[h.jsx("strong",{children:ee.label}),h.jsx("small",{children:ee.description})]})]},ee.id))}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Font size"}),h.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),h.jsx("input",{type:"range",min:dv,max:hv,step:1,value:u,"aria-label":"Terminal font size",onChange:ee=>He(ee.currentTarget.value)})]}),h.jsxs("div",{className:"settings-stepper-row",children:[h.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(_h(u-1)),children:"-"}),h.jsx("input",{type:"number",min:dv,max:hv,step:1,value:u,"aria-label":"Terminal font size value",onChange:ee=>He(ee.currentTarget.value)}),h.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(_h(u+1)),children:"+"}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(_h(To)),children:"Reset"})]}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Font family"}),h.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:ee=>p(dM(ee.currentTarget.value)),children:sf.map(ee=>h.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:y,onChange:ee=>b(fM(ee.currentTarget.checked))}),"Show scroll progress"]}),h.jsx("div",{className:"settings-section-heading",children:h.jsxs("div",{children:[h.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),h.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:w,onChange:ee=>C(pM(ee.currentTarget.checked))}),"Shell panes"]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:S,onChange:ee=>R(mM(ee.currentTarget.checked))}),"Codex/Claude panes"]})]}),h.jsxs("section",{id:"settings-shortcuts",ref:ee=>{Se.current.shortcuts=ee},className:"security-section settings-section",children:[h.jsxs("div",{className:"settings-section-heading",children:[h.jsx("h3",{children:"Shortcuts"}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:yt,children:"Reset all"})]}),h.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),Q?h.jsx("p",{className:"settings-error",children:Q}):null,h.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Ru.map(ee=>{const Pe=K===ee.id;return h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsx("span",{className:"settings-shortcut-label",children:ee.label}),h.jsx("span",{className:"settings-shortcut-group",children:ee.group})]}),h.jsxs("div",{className:"settings-shortcut-actions",children:[h.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Pe?"true":"false",onClick:()=>{se(ee.id),z(null)},children:Pe?"Press keys…":Cx(U[ee.id])}),h.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>kt(ee.id),children:"Reset"})]})]},ee.id)})})]}),h.jsxs("section",{id:"settings-notifications",ref:ee=>{Se.current.notifications=ee},className:"security-section settings-section",children:[h.jsx("h3",{children:"Notifications"}),Of()?h.jsxs(h.Fragment,{children:[h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:ke&&q==="granted",onChange:()=>{ci()},disabled:q==="denied"}),"System notification when page is hidden"]}),q==="denied"?h.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."}):h.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):h.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),h.jsxs("div",{className:"settings-subsection",children:[h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:!!Oe,onChange:()=>{de()},disabled:Ye||!je.supported}),"Installed app push notifications"]}),h.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."}),je.supported?null:h.jsx("p",{className:"muted",children:Ih(je.reason)}),Oe?h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:"muted",children:["Registered as ",Oe.label,". Last active ",new Date(Oe.lastActiveAt).toLocaleString(),"."]}),h.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{tt()},disabled:Ye,children:"Send test notification"})]}):null,Ie?h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:Oe?.alwaysNotify===!0,onChange:ee=>{Ue(ee.currentTarget.checked)},disabled:Ye||!Oe}),"Always notify this mobile device"]}):null,le?h.jsx("p",{className:"form-error",children:le}):null,V?h.jsx("p",{className:"muted",role:"status",children:V}):null]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:X.enabled,onChange:ee=>G(kR(ee.currentTarget.checked))}),"Show animated completion toast"]}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Toast duration"}),h.jsx("span",{className:"settings-control-value",children:X.persistUntilDismissed?"Until closed":`${X.durationSeconds}s`}),h.jsx("input",{type:"range",min:sv,max:rv,step:.5,value:X.durationSeconds,disabled:!X.enabled||X.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ee=>et(ee.currentTarget.value)})]}),h.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[h.jsx("input",{type:"number",min:sv,max:rv,step:.5,value:X.durationSeconds,disabled:!X.enabled||X.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ee=>et(ee.currentTarget.value)}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!X.enabled||X.persistUntilDismissed,onClick:()=>G(_w(gu)),children:"Reset"})]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:X.persistUntilDismissed,disabled:!X.enabled,onChange:ee=>G(TR(ee.currentTarget.checked))}),"Keep toast until dismissed"]}),h.jsxs("div",{className:"settings-assets-header",children:[h.jsx("span",{children:"Toast videos"}),h.jsxs("span",{children:[cg(W)," max"]})]}),h.jsx("input",{ref:Te,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ee=>{Ge(ee.currentTarget.files)}}),h.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Ce,onClick:()=>Te.current?.click(),children:"Upload video"}),Me?h.jsx("p",{className:"settings-error",children:Me}):null,L.length>0?h.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:L.map(ee=>h.jsxs("li",{"data-enabled":xe.has(ee.id)?"true":"false",children:[h.jsxs("label",{className:"settings-asset-choice",children:[h.jsx("input",{type:"checkbox",checked:xe.has(ee.id),disabled:Ce,"aria-label":`Use ${ee.filename}`,onChange:Pe=>Hi(ee.id,Pe.currentTarget.checked)}),h.jsx("video",{src:ee.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),h.jsxs("span",{className:"settings-asset-copy",children:[h.jsx("span",{children:ee.filename}),h.jsx("small",{children:ee.source==="built-in"?"Built-in":cg(ee.size)})]})]}),ee.source==="uploaded"?h.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Ce,"aria-label":`Delete ${ee.filename}`,onClick:()=>{xt(ee.id)},children:"x"}):null]},ee.id))}):h.jsx("p",{className:"muted",children:"Built-in videos will be used."}),h.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Ce||L.length===0||!he,onClick:()=>{_i()},children:"Save selected videos"})]}),h.jsx("div",{id:"settings-security",ref:ee=>{Se.current.security=ee},className:"settings-section-group",children:h.jsx(cM,{api:c})}),h.jsx("div",{id:"settings-servers",ref:ee=>{Se.current.servers=ee},className:"settings-section-group",children:h.jsx(UM,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Dw(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function cg(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 wl(e){return e instanceof Error?e.message:"Request failed."}function Ih(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 ug(e){const t=wl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Ih("not_standalone"):t==="insecure"?Ih("insecure"):t==="not_mobile"?Ih("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 $M(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 qM(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const VM="modulepreload",YM=function(e){return"/"+e},Rw={},bb=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");o=g(n.map(p=>{if(p=YM(p),p in Rw)return;Rw[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":VM,y||(w.as="script"),w.crossOrigin="",w.href=p,m&&w.setAttribute("nonce",m),document.head.appendChild(w),y)return new Promise((C,S)=>{w.addEventListener("load",C),w.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(u){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=u,window.dispatchEvent(m),!m.defaultPrevented)throw u}return o.then(u=>{for(const m of u||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},XM=v.lazy(()=>bb(()=>import("./MarkdownPreview-DMOim4ku.js"),__vite__mapDeps([0,1])));function GM({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[m,g]=v.useState(""),[p,y]=v.useState({}),[b,w]=v.useState(()=>new Set),[C,S]=v.useState(null),[R,B]=v.useState({type:"empty"}),[A,U]=v.useState("idle"),[Y,K]=v.useState(null),se=v.useRef(null),Q=v.useRef(null),z=v.useRef(!1),_e=v.useRef(0),ie=v.useRef(null);ie.current===null&&t&&(ie.current=t);const ke=ie.current,ne=r?QM(r):t?Mw(t,n):null,X=c?[c.rootPath,m].filter(Boolean).join("/"):"",G=C?.path??null;v.useEffect(()=>(z.current=!0,()=>{z.current=!1,_e.current+=1,Be()}),[]),v.useEffect(()=>{ie.current=t,Q.current=null,q(ne)},[e]),v.useEffect(()=>{r&&ne!==Q.current&&oe(r,ne)},[r,ne]),v.useEffect(()=>{if(r||!ke||t!==ke)return;const F=Mw(ke,n);F!==Q.current&&L(ke,F)},[ke,t,n,r]);async function q(F=ne){if(r){await oe(r,F);return}await L(t,F)}async function oe(F,Se=ne){const xe=le();if(Q.current=Se,Be(),u(null),g(""),y({}),w(new Set),S(null),B({type:"empty"}),K(null),!F){U("idle");return}U("loading");try{const he=await e.createFileRoot({path:F});if(!E(xe))return;u({rootToken:he.rootToken,rootPath:he.rootPath});const je=await e.listFiles({rootToken:he.rootToken,path:""});if(!E(xe))return;re(je),U("idle")}catch(he){E(xe)&&(K(Er(he)),U("idle"))}}async function L(F,Se=ne){const xe=le();if(Q.current=Se,Be(),u(null),g(""),y({}),w(new Set),S(null),B({type:"empty"}),K(null),!F){U("idle");return}U("loading");try{const he=await e.createFileRoot({terminalId:F});if(!E(xe))return;u({rootToken:he.rootToken,rootPath:he.rootPath});const je=await e.listFiles({rootToken:he.rootToken,path:""});if(!E(xe))return;re(je),U("idle")}catch(he){if(await V(he,xe))return;E(xe)&&(K(Er(he)),U("idle"))}}async function M(F=m,Se=c){if(!Se)return;const xe=le();U("loading"),K(null);try{const he=await e.listFiles({rootToken:Se.rootToken,path:F});if(!E(xe))return;re(he),U("idle")}catch(he){if(await V(he,xe))return;E(xe)&&(K(Er(he)),U("idle"))}}async function j(){if(r){await oe(r,ne);return}ie.current=t,await L(t,ne)}function re(F){y(Se=>({...Se,[F.path]:JM(F.entries)}))}async function ye(F){if(!(!dg(F)||!c)){if(S(F),K(null),F.kind==="directory"){g(F.path),Ye(),await W(F);return}if(g(bo(F.path)),F.editable){await Ce(F);return}F.previewKind!=="none"&&await Me(F,F.previewKind)}}async function N(F){if(!(!dg(F)||!c)){if(S(F),K(null),F.kind==="directory"){g(F.path),Ye(),await W(F);return}if(g(bo(F.path)),F.editable){await Le(F);return}F.previewKind!=="none"&&await Me(F,F.previewKind)}}async function W(F){if(b.has(F.path)){w(Se=>{const xe=new Set(Se);return xe.delete(F.path),xe});return}w(Se=>new Set(Se).add(F.path)),await M(F.path)}function ue(F,Se){F.key==="Enter"&&(F.preventDefault(),N(Se))}async function Ce(F){if(!c)return;const Se=le();U("loading"),Be();try{const xe=await e.readFile({rootToken:c.rootToken,path:F.path});if(!E(Se))return;B({type:"text-preview",file:F,read:xe}),U("idle")}catch(xe){if(await V(xe,Se))return;E(Se)&&(K(Er(xe)),U("idle"))}}async function Le(F){if(!c)return;const Se=le();U("loading");try{await o({rootToken:c.rootToken,path:F.path,...t?{terminalId:t}:{}}),E(Se)&&U("idle")}catch(xe){if(await V(xe,Se))return;E(Se)&&(K(Er(xe)),U("idle"))}}async function Me(F,Se){if(!c)return;const xe=le();U("loading"),Be();try{const he=await e.previewFile({rootToken:c.rootToken,path:F.path});if(!E(xe))return;const je=URL.createObjectURL(he);if(!E(xe)){URL.revokeObjectURL(je);return}se.current=je,B({type:"preview",file:F,previewKind:Se,url:je}),U("idle")}catch(he){if(await V(he,xe))return;E(xe)&&(K(Er(he)),U("idle"))}}async function Ne(F){if(!c)return;const Se=F==="file"?"New file":"New folder",xe=window.prompt(Se,""),he=C?C.kind==="directory"?C.path:bo(C.path):m,je=Nw(xe,he);if(je){K(null);try{const Ie=await e.createFileEntry({rootToken:c.rootToken,path:je,kind:F});S(Ie.entry),await M(he)}catch(Ie){if(await V(Ie))return;K(Er(Ie))}}}async function Oe(){if(!c||!C)return;const F=window.prompt("Move selected entry",C.path),Se=Nw(F,"");if(!Se||Se===C.path)return;const xe=bo(C.path),he=bo(Se);K(null);try{const je=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:C.path,destinationPath:Se});S(je.entry),g(je.entry.kind==="directory"?je.entry.path:bo(je.entry.path)),Ye(),await M(xe),he!==xe&&await M(he)}catch(je){if(await V(je))return;K(Er(je))}}async function Ve(){if(!c||!C)return;const F=C.path,Se=bo(F);K(null);try{const xe=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:C.path}),he=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${he}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:C.path,previewToken:xe.previewToken}),S(null),g(Se),w(je=>{const Ie=new Set(je);for(const He of je)(He===F||He.startsWith(`${F}/`))&&Ie.delete(He);return Ie}),Ye(),await M(Se)}catch(xe){if(await V(xe))return;K(Er(xe))}}function Ye(){_e.current+=1,Be(),B({type:"empty"})}function Be(){se.current&&(URL.revokeObjectURL(se.current),se.current=null)}function le(){return _e.current+=1,_e.current}function E(F){return z.current&&F===_e.current}async function V(F,Se){return eN(F)?(Se!==void 0&&!E(Se)||await q(ne),!0):!1}function ge(F,Se){const xe=dg(F),he=F.kind==="directory"&&b.has(F.path),je=p[F.path]??[],Ie={"--file-tree-depth":Se};return h.jsxs(Ni.Fragment,{children:[h.jsxs("button",{type:"button",className:"file-entry-button","data-kind":F.kind,"data-expanded":he,"data-active":G===F.path,disabled:!xe,style:Ie,"aria-expanded":F.kind==="directory"?he:void 0,"aria-label":`${F.kind==="directory"?"Open folder":"Open file"} ${F.name}`,title:F.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ye(F)},onDoubleClick:()=>{N(F)},onKeyDown:He=>ue(He,F),children:[h.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:F.kind==="directory"?he?"▾":"▸":""}),h.jsx("span",{className:"file-entry-name",children:F.name}),h.jsx("small",{children:ZM(F)})]}),he?h.jsx("div",{className:"file-tree-children",role:"group",children:je.map(He=>ge(He,Se+1))}):null]},F.path)}const Te=p[""]??[];return h.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[h.jsxs("header",{className:"file-explorer-header",children:[h.jsx("div",{className:"file-explorer-path",title:X,children:X||"No active pane"}),h.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[h.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{j()},children:"↻"}),h.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ne("file")},children:"+"}),h.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ne("directory")},children:"▣"})]})]}),Y?h.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,h.jsxs("div",{className:"file-explorer-layout",children:[h.jsx("div",{className:"file-tree","aria-label":X?`Files in ${X}`:"Files",children:Te.map(F=>ge(F,0))}),h.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[h.jsxs("div",{className:"file-detail-header",children:[h.jsx("strong",{children:C?.name??"detail"}),h.jsxs("div",{className:"file-detail-actions",children:[h.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!C,onClick:()=>{Oe()},children:"Move"}),h.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!C,onClick:()=>{Ve()},children:"Delete"})]})]}),A==="loading"?h.jsx("div",{className:"file-detail-empty",children:"loading"}):null,R.type==="empty"&&A!=="loading"?h.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,R.type==="preview"?h.jsxs("div",{className:"file-preview-frame",children:[R.previewKind==="image"?h.jsx("img",{src:R.url,alt:R.file.name}):null,R.previewKind==="pdf"?h.jsx("iframe",{src:R.url,title:R.file.name}):null]}):null,R.type==="text-preview"&&R.read.language==="markdown"?h.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${R.file.name}`,children:h.jsx(v.Suspense,{fallback:h.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:h.jsx(XM,{content:R.read.content})})}):null,R.type==="text-preview"&&R.read.language==="text"?h.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${R.file.name}`,children:R.read.content}):null]})]})]})}function dg(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function ZM(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Mw(e,t){return`${e}\0${t??""}`}function QM(e){return`workspace\0${e}`}function JM(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 bo(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Nw(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 Er(e){return e instanceof Error?e.message:"Request failed"}function eN(e){return e instanceof kn&&e.status===409&&e.message==="terminal_cwd_changed"}const tN=v.lazy(()=>bb(()=>import("./MarkdownPreview-DMOim4ku.js"),__vite__mapDeps([0,1])));function Aw({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,m]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[w,C]=v.useState(!1),[S,R]=v.useState("edit"),B=v.useRef(t),A=v.useRef(t.read),U=v.useRef(t.read.content),Y=v.useRef(!1),K=v.useRef(!1),se=v.useRef(0),Q=u!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(K.current=!0,()=>{K.current=!1,se.current+=1}),[]),v.useEffect(()=>{se.current+=1,Y.current=!1,B.current=t,A.current=t.read,U.current=t.read.content,c(t.read),m(t.read.content),p("idle"),b(null),C(!1),R("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{U.current=u},[u]),v.useEffect(()=>{if(u===o.content||w)return;const ne=window.setInterval(()=>{!Y.current&&U.current!==A.current.content&&z()},1e3);return()=>window.clearInterval(ne)},[u===o.content,w,t.id]);async function z(){if(Y.current)return;const ne=U.current,X=A.current;if(ne===X.content)return;const G=B.current,q=se.current;Y.current=!0,p("saving"),b(null),C(!1);try{const oe=await e.writeFile({rootToken:G.rootToken,path:G.path,content:ne,expectedVersion:X.version});if(!K.current||q!==se.current)return;const L={...X,content:ne,version:oe.version};A.current=L,c(L),p(U.current===ne?"saved":"idle")}catch(oe){if(!K.current||q!==se.current)return;if(oe instanceof kn&&oe.status===409){C(!0),p("idle");return}b(iN(oe)),p("idle")}finally{q===se.current&&(Y.current=!1)}}const _e=g==="saving"?"saving":g==="saved"?"saved":o.language,ie=o.language==="markdown",ke=ie&&S==="preview";return h.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[h.jsxs("header",{className:"editor-pane-header",children:[h.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),h.jsx("strong",{children:t.title}),h.jsx("span",{className:"terminal-pane-spacer"}),h.jsx("span",{className:"terminal-pane-state",children:_e}),h.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!Q,onClick:()=>{z()},children:"Save"}),ie?h.jsx("button",{type:"button","aria-label":`${ke?"Edit":"Preview"} ${t.title}`,onClick:()=>R(ne=>ne==="preview"?"edit":"preview"),children:ke?"Edit":"Preview"}):null,n?h.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?h.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,w?h.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ke?h.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:h.jsx(v.Suspense,{fallback:h.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:h.jsx(tN,{content:u})})}):h.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ne=>{const X=ne.target.value;U.current=X,m(X),p("idle"),b(null),C(!1)}})]})}function iN(e){return e instanceof Error?e.message:"Request failed"}var nN=2,sN=1,rN=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),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),u={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=u.top+u.bottom,g=u.right+u.left,p=r-m,y=o-g-t;return{cols:Math.max(nN,Math.floor(y/e.css.cell.width)),rows:Math.max(sN,Math.floor(p/e.css.cell.height))}}};var Nx=Object.defineProperty,aN=Object.getOwnPropertyDescriptor,oN=(e,t)=>{for(var n in t)Nx(e,n,{get:t[n],enumerable:!0})},vi=(e,t,n,r)=>{for(var o=r>1?void 0:r?aN(t,n):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,n,o):u(o))||o);return r&&o&&Nx(t,n,o),o},ze=(e,t)=>(n,r)=>t(n,r,e),Lw="Terminal input",Cv={get:()=>Lw,set:e=>Lw=e},Ow="Too much output to announce, navigate to rows manually to read",xv={get:()=>Ow,set:e=>Ow=e};function lN(e){return e.replace(/\r?\n/g,"\r")}function cN(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function uN(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function dN(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Ax(o,t,n,r)}}function Ax(e,t,n,r){e=lN(e),e=cN(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Lx(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.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 Bw(e,t,n,r,o){Lx(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Da(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function If(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var hN=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=n)return this._interim=u,r;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[r++]=(u-55296)*1024+m-56320+65536:(t[r++]=u,t[r++]=m);continue}u!==65279&&(t[r++]=u)}return r}},fN=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,u,m,g=0,p=0;if(this.interim[0]){let w=!1,C=this.interim[0];C&=(C&224)===192?31:(C&240)===224?15:7;let S=0,R;for(;(R=this.interim[++S]&63)&&S<4;)C<<=6,C|=R;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=B-S;for(;p<A;){if(p>=n)return 0;if(R=e[p++],(R&192)!==128){p--,w=!0;break}else this.interim[S++]=R,C<<=6,C|=R&63}w||(B===2?C<128?p--:t[r++]=C:B===3?C<2048||C>=55296&&C<=57343||C===65279||(t[r++]=C):C<65536||C>1114111||(t[r++]=C)),this.interim.fill(0)}let y=n-4,b=p;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((u=e[b+2])&128)&&!((m=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=u,t[r++]=m,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=u,r;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(u&63)<<6|m&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},Ox="",Ma=" ",Yu=class Bx{constructor(){this.fg=0,this.bg=0,this.extended=new af}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 Bx;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}},af=class jx{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 jx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ms=class Ix extends Yu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new af,this.combinedData=""}static fromCharData(t){let n=new Ix;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?Da(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 r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-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()]}},jw="di$target",kv="di$dependencies",hg=new Map;function pN(e){return e[kv]||[]}function Qi(e){if(hg.has(e))return hg.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");mN(t,n,o)};return t._id=e,hg.set(e,t),t}function mN(e,t,n){t[jw]===t?t[kv].push({id:e,index:n}):(t[kv]=[{id:e,index:n}],t[jw]=t)}var Tn=Qi("BufferService"),zx=Qi("CoreMouseService"),Io=Qi("CoreService"),gN=Qi("CharsetService"),yb=Qi("InstantiationService"),Px=Qi("LogService"),En=Qi("OptionsService"),Hx=Qi("OscLinkService"),vN=Qi("UnicodeService"),Xu=Qi("DecorationService"),Tv=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 r=[],o=this._optionsService.rawOptions.linkHandler,c=new ms,u=n.getTrimmedLength(),m=-1,g=-1,p=!1;for(let y=0;y<u;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 p=c.extended.urlId!==m;else g!==-1&&(p=!0);if(p||g!==-1&&y===u-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:y+(!p&&y===u-1?1:0),y:e}},C=!1;if(!o?.allowNonHttpProtocols)try{let S=new URL(b);["http:","https:"].includes(S.protocol)||(C=!0)}catch{C=!0}C||r.push({text:b,range:w,activate:(S,R)=>o?o.activate(S,R,w):_N(S,R),hover:(S,R)=>o?.hover?.(S,R,w),leave:(S,R)=>o?.leave?.(S,R,w)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(r)}};Tv=vi([ze(0,Tn),ze(1,En),ze(2,Hx)],Tv);function _N(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 zf=Qi("CharSizeService"),zr=Qi("CoreBrowserService"),Sb=Qi("MouseService"),Pr=Qi("RenderService"),bN=Qi("SelectionService"),Ux=Qi("CharacterJoinerService"),Wl=Qi("ThemeService"),Fx=Qi("LinkProviderService"),yN=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Iw.isErrorNoTelemetry(e)?new Iw(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)}},SN=new yN;function zh(e){wN(e)||SN.onUnexpectedError(e)}var Ev="Canceled";function wN(e){return e instanceof CN?!0:e instanceof Error&&e.name===Ev&&e.message===Ev}var CN=class extends Error{constructor(){super(Ev),this.name=this.message}};function xN(e){return new Error(`Illegal argument: ${e}`)}var Iw=class Dv extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Dv)return t;let n=new Dv;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Rv=class Kx extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Kx.prototype)}};function Wn(e,t=0){return e[e.length-(1+t)]}var kN;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(kN||={});function TN(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var Wx;(e=>{function t(K){return K&&typeof K=="object"&&typeof K[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(K){yield K}e.single=o;function c(K){return t(K)?K:o(K)}e.wrap=c;function u(K){return K||n}e.from=u;function*m(K){for(let se=K.length-1;se>=0;se--)yield K[se]}e.reverse=m;function g(K){return!K||K[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(K){return K[Symbol.iterator]().next().value}e.first=p;function y(K,se){let Q=0;for(let z of K)if(se(z,Q++))return!0;return!1}e.some=y;function b(K,se){for(let Q of K)if(se(Q))return Q}e.find=b;function*w(K,se){for(let Q of K)se(Q)&&(yield Q)}e.filter=w;function*C(K,se){let Q=0;for(let z of K)yield se(z,Q++)}e.map=C;function*S(K,se){let Q=0;for(let z of K)yield*se(z,Q++)}e.flatMap=S;function*R(...K){for(let se of K)yield*se}e.concat=R;function B(K,se,Q){let z=Q;for(let _e of K)z=se(z,_e);return z}e.reduce=B;function*A(K,se,Q=K.length){for(se<0&&(se+=K.length),Q<0?Q+=K.length:Q>K.length&&(Q=K.length);se<Q;se++)yield K[se]}e.slice=A;function U(K,se=Number.POSITIVE_INFINITY){let Q=[];if(se===0)return[Q,K];let z=K[Symbol.iterator]();for(let _e=0;_e<se;_e++){let ie=z.next();if(ie.done)return[Q,e.empty()];Q.push(ie.value)}return[Q,{[Symbol.iterator](){return z}}]}e.consume=U;async function Y(K){let se=[];for await(let Q of K)se.push(Q);return Promise.resolve(se)}e.asyncToArray=Y})(Wx||={});function Ao(e){if(Wx.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}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 EN(...e){return ni(()=>Ao(e))}function ni(e){return{dispose:TN(()=>{e()})}}var $x=class qx{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ao(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?qx.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)}};$x.DISABLE_DISPOSED_WARNING=!1;var Aa=$x,vt=class{constructor(){this._store=new Aa,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)}};vt.None=Object.freeze({dispose(){}});var Il=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}},Lr=typeof window=="object"?window:globalThis,Mv=class Nv{constructor(t){this.element=t,this.next=Nv.Undefined,this.prev=Nv.Undefined}};Mv.Undefined=new Mv(void 0);var oi=Mv,zw=class{constructor(){this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===oi.Undefined}clear(){let e=this._first;for(;e!==oi.Undefined;){let t=e.next;e.prev=oi.Undefined,e.next=oi.Undefined,e=t}this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new oi(e);if(this._first===oi.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 r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==oi.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==oi.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==oi.Undefined&&e.next!==oi.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===oi.Undefined&&e.next===oi.Undefined?(this._first=oi.Undefined,this._last=oi.Undefined):e.next===oi.Undefined?(this._last=this._last.prev,this._last.next=oi.Undefined):e.prev===oi.Undefined&&(this._first=this._first.next,this._first.prev=oi.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==oi.Undefined;)yield e.element,e=e.next}},DN=globalThis.performance&&typeof globalThis.performance.now=="function",RN=class Vx{static create(t){return new Vx(t)}constructor(t){this._now=DN&&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}},cn;(e=>{e.None=()=>vt.None;function t(X,G){return b(X,()=>{},0,void 0,!0,void 0,G)}e.defer=t;function n(X){return(G,q=null,oe)=>{let L=!1,M;return M=X(j=>{if(!L)return M?M.dispose():L=!0,G.call(q,j)},null,oe),L&&M.dispose(),M}}e.once=n;function r(X,G,q){return p((oe,L=null,M)=>X(j=>oe.call(L,G(j)),null,M),q)}e.map=r;function o(X,G,q){return p((oe,L=null,M)=>X(j=>{G(j),oe.call(L,j)},null,M),q)}e.forEach=o;function c(X,G,q){return p((oe,L=null,M)=>X(j=>G(j)&&oe.call(L,j),null,M),q)}e.filter=c;function u(X){return X}e.signal=u;function m(...X){return(G,q=null,oe)=>{let L=EN(...X.map(M=>M(j=>G.call(q,j))));return y(L,oe)}}e.any=m;function g(X,G,q,oe){let L=q;return r(X,M=>(L=G(L,M),L),oe)}e.reduce=g;function p(X,G){let q,oe={onWillAddFirstListener(){q=X(L.fire,L)},onDidRemoveLastListener(){q?.dispose()}},L=new Ae(oe);return G?.add(L),L.event}function y(X,G){return G instanceof Array?G.push(X):G&&G.add(X),X}function b(X,G,q=100,oe=!1,L=!1,M,j){let re,ye,N,W=0,ue,Ce={leakWarningThreshold:M,onWillAddFirstListener(){re=X(Me=>{W++,ye=G(ye,Me),oe&&!N&&(Le.fire(ye),ye=void 0),ue=()=>{let Ne=ye;ye=void 0,N=void 0,(!oe||W>1)&&Le.fire(Ne),W=0},typeof q=="number"?(clearTimeout(N),N=setTimeout(ue,q)):N===void 0&&(N=0,queueMicrotask(ue))})},onWillRemoveListener(){L&&W>0&&ue?.()},onDidRemoveLastListener(){ue=void 0,re.dispose()}},Le=new Ae(Ce);return j?.add(Le),Le.event}e.debounce=b;function w(X,G=0,q){return e.debounce(X,(oe,L)=>oe?(oe.push(L),oe):[L],G,void 0,!0,void 0,q)}e.accumulate=w;function C(X,G=(oe,L)=>oe===L,q){let oe=!0,L;return c(X,M=>{let j=oe||!G(M,L);return oe=!1,L=M,j},q)}e.latch=C;function S(X,G,q){return[e.filter(X,G,q),e.filter(X,oe=>!G(oe),q)]}e.split=S;function R(X,G=!1,q=[],oe){let L=q.slice(),M=X(ye=>{L?L.push(ye):re.fire(ye)});oe&&oe.add(M);let j=()=>{L?.forEach(ye=>re.fire(ye)),L=null},re=new Ae({onWillAddFirstListener(){M||(M=X(ye=>re.fire(ye)),oe&&oe.add(M))},onDidAddFirstListener(){L&&(G?setTimeout(j):j())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return oe&&oe.add(re),re.event}e.buffer=R;function B(X,G){return(q,oe,L)=>{let M=G(new U);return X(function(j){let re=M.evaluate(j);re!==A&&q.call(oe,re)},void 0,L)}}e.chain=B;let A=Symbol("HaltChainable");class U{constructor(){this.steps=[]}map(G){return this.steps.push(G),this}forEach(G){return this.steps.push(q=>(G(q),q)),this}filter(G){return this.steps.push(q=>G(q)?q:A),this}reduce(G,q){let oe=q;return this.steps.push(L=>(oe=G(oe,L),oe)),this}latch(G=(q,oe)=>q===oe){let q=!0,oe;return this.steps.push(L=>{let M=q||!G(L,oe);return q=!1,oe=L,M?L:A}),this}evaluate(G){for(let q of this.steps)if(G=q(G),G===A)break;return G}}function Y(X,G,q=oe=>oe){let oe=(...re)=>j.fire(q(...re)),L=()=>X.on(G,oe),M=()=>X.removeListener(G,oe),j=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:M});return j.event}e.fromNodeEventEmitter=Y;function K(X,G,q=oe=>oe){let oe=(...re)=>j.fire(q(...re)),L=()=>X.addEventListener(G,oe),M=()=>X.removeEventListener(G,oe),j=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:M});return j.event}e.fromDOMEventEmitter=K;function se(X){return new Promise(G=>n(X)(G))}e.toPromise=se;function Q(X){let G=new Ae;return X.then(q=>{G.fire(q)},()=>{G.fire(void 0)}).finally(()=>{G.dispose()}),G.event}e.fromPromise=Q;function z(X,G){return X(q=>G.fire(q))}e.forward=z;function _e(X,G,q){return G(q),X(oe=>G(oe))}e.runAndSubscribe=_e;class ie{constructor(G,q){this._observable=G,this._counter=0,this._hasChanged=!1;let oe={onWillAddFirstListener:()=>{G.addObserver(this)},onDidRemoveLastListener:()=>{G.removeObserver(this)}};this.emitter=new Ae(oe),q&&q.add(this.emitter)}beginUpdate(G){this._counter++}handlePossibleChange(G){}handleChange(G,q){this._hasChanged=!0}endUpdate(G){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ke(X,G){return new ie(X,G).emitter.event}e.fromObservable=ke;function ne(X){return(G,q,oe)=>{let L=0,M=!1,j={beginUpdate(){L++},endUpdate(){L--,L===0&&(X.reportChanges(),M&&(M=!1,G.call(q)))},handlePossibleChange(){},handleChange(){M=!0}};X.addObserver(j),X.reportChanges();let re={dispose(){X.removeObserver(j)}};return oe instanceof Aa?oe.add(re):Array.isArray(oe)&&oe.push(re),re}}e.fromObservableLight=ne})(cn||={});var Av=class Lv{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Lv._idPool++}`,Lv.all.add(this)}start(t){this._stopWatch=new RN,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}}};Av.all=new Set,Av._idPool=0;var MN=Av,NN=-1,Yx=class Xx{constructor(t,n,r=(Xx._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)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=r*.5;let[c,u]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(m),console.warn(c);let g=new ON(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[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};Yx._idPool=1;var AN=Yx,LN=class Gx{constructor(t){this.value=t}static create(){let t=new Error;return new Gx(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
+
`).slice(2).join(`
|
|
24
|
+
`))}},ON=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},BN=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},jN=0,fg=class{constructor(e){this.value=e,this.id=jN++}},IN=2,zN,Ae=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new AN(e?.onListenerError??zh,this._options?.leakWarningThreshold??NN):void 0,this._perfMon=this._options?._profName?new MN(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 u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new BN(`${u}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||zh)(g),vt.None}if(this._disposed)return vt.None;t&&(e=e.bind(t));let r=new fg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=LN.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof fg?(this._deliveryQueue??=new PN,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=ni(()=>{o?.(),this._removeListener(r)});return n instanceof Aa?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 r=this._deliveryQueue.current===this;if(this._size*IN<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||zh;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_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 fg)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}},PN=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}},Ov=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ae,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ae,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 r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}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 r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Ov.INSTANCE=new Ov;var wb=Ov;function HN(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}wb.INSTANCE.onDidChangeZoomLevel;function UN(e){return wb.INSTANCE.getZoomFactor(e)}wb.INSTANCE.onDidChangeFullscreen;var $l=typeof navigator=="object"?navigator.userAgent:"",Bv=$l.indexOf("Firefox")>=0,FN=$l.indexOf("AppleWebKit")>=0,Cb=$l.indexOf("Chrome")>=0,KN=!Cb&&$l.indexOf("Safari")>=0;$l.indexOf("Electron/")>=0;$l.indexOf("Android")>=0;var pg=!1;if(typeof Lr.matchMedia=="function"){let e=Lr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Lr.matchMedia("(display-mode: fullscreen)");pg=e.matches,HN(Lr,e,({matches:n})=>{pg&&t.matches||(pg=n)})}var kl="en",jv=!1,Iv=!1,Ph=!1,Zx=!1,yh,Hh=kl,Pw=kl,WN,Rr,Eo=globalThis,Vn;typeof Eo.vscode<"u"&&typeof Eo.vscode.process<"u"?Vn=Eo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Vn=process);var $N=typeof Vn?.versions?.electron=="string",qN=$N&&Vn?.type==="renderer";if(typeof Vn=="object"){jv=Vn.platform==="win32",Iv=Vn.platform==="darwin",Ph=Vn.platform==="linux",Ph&&Vn.env.SNAP&&Vn.env.SNAP_REVISION,Vn.env.CI||Vn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yh=kl,Hh=kl;let e=Vn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);yh=t.userLocale,Pw=t.osLocale,Hh=t.resolvedLanguage||kl,WN=t.languagePack?.translationsConfigFile}catch{}Zx=!0}else typeof navigator=="object"&&!qN?(Rr=navigator.userAgent,jv=Rr.indexOf("Windows")>=0,Iv=Rr.indexOf("Macintosh")>=0,(Rr.indexOf("Macintosh")>=0||Rr.indexOf("iPad")>=0||Rr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ph=Rr.indexOf("Linux")>=0,Rr?.indexOf("Mobi")>=0,Hh=globalThis._VSCODE_NLS_LANGUAGE||kl,yh=navigator.language.toLowerCase(),Pw=yh):console.error("Unable to resolve platform.");var Qx=jv,Qs=Iv,VN=Ph,Hw=Zx,er=Rr,Sa=Hh,YN;(e=>{function t(){return Sa}e.value=t;function n(){return Sa.length===2?Sa==="en":Sa.length>=3?Sa[0]==="e"&&Sa[1]==="n"&&Sa[2]==="-":!1}e.isDefaultVariant=n;function r(){return Sa==="en"}e.isDefault=r})(YN||={});var XN=typeof Eo.postMessage=="function"&&!Eo.importScripts;(()=>{if(XN){let e=[];Eo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Eo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var GN=!!(er&&er.indexOf("Chrome")>=0);er&&er.indexOf("Firefox")>=0;!GN&&er&&er.indexOf("Safari")>=0;er&&er.indexOf("Edg/")>=0;er&&er.indexOf("Android")>=0;var bl=typeof navigator=="object"?navigator:{};Hw||document.queryCommandSupported&&document.queryCommandSupported("copy")||bl&&bl.clipboard&&bl.clipboard.writeText,Hw||bl&&bl.clipboard&&bl.clipboard.readText;var xb=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}},mg=new xb,Uw=new xb,Fw=new xb,ZN=new Array(230),Jx;(e=>{function t(m){return mg.keyCodeToStr(m)}e.toString=t;function n(m){return mg.strToKeyCode(m)}e.fromString=n;function r(m){return Uw.keyCodeToStr(m)}e.toUserSettingsUS=r;function o(m){return Fw.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return Uw.strToKeyCode(m)||Fw.strToKeyCode(m)}e.fromUserSettings=c;function u(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 mg.keyCodeToStr(m)}e.toElectronAccelerator=u})(Jx||={});var QN=class ek{constructor(t,n,r,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof ek&&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",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new JN([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},JN=class{constructor(e){if(e.length===0)throw xN("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 eA(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Jx.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Bv)switch(t){case 59:return 85;case 60:if(VN)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qs)return 57;break}else if(FN&&(Qs&&t===93||!Qs&&t===92))return 57;return ZN[t]||0}var tA=Qs?256:2048,iA=512,nA=1024,sA=Qs?2048:256,Kw=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=eA(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|=tA),this.altKey&&(t|=iA),this.shiftKey&&(t|=nA),this.metaKey&&(t|=sA),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new QN(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ww=new WeakMap;function rA(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 aA=class{static getSameOriginWindowChain(e){let t=Ww.get(e);if(!t){t=[],Ww.set(e,t);let n=e,r;do r=rA(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(n+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,r+=m.left}return{top:n,left:r}}},Sh=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=aA.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},$w=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 r=!1;if(Cb){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*u):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?Bv&&!Qs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")KN&&Qx?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*u):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?Bv&&!Qs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},tk=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),oA;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof lA?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:cn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:tk})})(oA||={});var lA=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?tk:(this._emitter||(this._emitter=new Ae),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},kb=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 Rv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Rv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},cA=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 Rv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=ni(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},uA;(e=>{async function t(r){let o,c=await Promise.all(r.map(u=>u.then(m=>m,m=>{o||(o=m)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(u){c(u)}})}e.withAsyncBody=n})(uA||={});var qw=class ds{static fromArray(t){return new ds(n=>{n.emitMany(t)})}static fromPromise(t){return new ds(async n=>{n.emitMany(await t)})}static fromPromises(t){return new ds(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new ds(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Ae,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.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 cn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new ds(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return ds.map(this,t)}static filter(t,n){return new ds(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return ds.filter(this,t)}static coalesce(t){return ds.filter(t,n=>!!n)}coalesce(){return ds.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return ds.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())}};qw.EMPTY=qw.fromArray([]);var{getWindow:Zs,getWindowId:dA,onDidRegisterWindow:hA}=(function(){let e=new Map,t={window:Lr,disposables:new Aa};e.set(Lr.vscodeWindowId,t);let n=new Ae,r=new Ae,o=new Ae;function c(u,m){return(typeof u=="number"?e.get(u):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return vt.None;let m=new Aa,g={window:u,disposables:m.add(new Aa)};return e.set(u.vscodeWindowId,g),m.add(ni(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),m.add(st(u,qi.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:c,getWindow(u){let m=u;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:Lr},getDocument(u){return Zs(u).document}}})(),fA=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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 st(e,t,n,r){return new fA(e,t,n,r)}var Vw=function(e,t,n,r){return st(e,t,n,r)},Tb,pA=class extends cA{constructor(e){super(),this.defaultTarget=e&&Zs(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Yw=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){zh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let u=e.get(c)??[];for(t.set(c,u),e.set(c,[]),r.set(c,!0);u.length>0;)u.sort(Yw.sort),u.shift().execute();r.set(c,!1)};Tb=(c,u,m=0)=>{let g=dA(c),p=new Yw(u,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function mA(e){let t=e.getBoundingClientRect(),n=Zs(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var qi={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"},gA=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=jn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=jn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=jn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=jn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=jn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=jn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=jn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=jn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=jn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=jn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=jn(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=jn(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=jn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=jn(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 jn(e){return typeof e=="number"?`${e}px`:e}function yu(e){return new gA(e)}var ik=class{constructor(){this._hooks=new Aa,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,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(ni(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Zs(e)}this._hooks.add(st(c,qi.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(st(c,qi.POINTER_UP,u=>this.stopMonitoring(!0)))}};function vA(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[c]}}var Xs;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Xs||={});var nu=class gn extends vt{constructor(){super(),this.dispatched=!1,this.targets=new zw,this.ignoreTargets=new zw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(cn.runAndSubscribe(hA,({window:t,disposables:n})=>{n.add(st(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(st(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(st(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Lr,disposables:this._store}))}static addTarget(t){if(!gn.isTouchDevice())return vt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.targets.push(t);return ni(n)}static ignoreTarget(t){if(!gn.isTouchDevice())return vt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.ignoreTargets.push(t);return ni(n)}static isTouchDevice(){return"ontouchstart"in Lr||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 r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);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 u=this.newGestureEvent(Xs.Start,c.target);u.pageX=c.pageX,u.pageY=c.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=n.changedTouches.length;c<u;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],p=Date.now()-g.initialTimeStamp;if(p<gn.HOLD_DELAY&&Math.abs(g.initialPageX-Wn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Wn(g.rollingPageY))<30){let y=this.newGestureEvent(Xs.Tap,g.initialTarget);y.pageX=Wn(g.rollingPageX),y.pageY=Wn(g.rollingPageY),this.dispatchEvent(y)}else if(p>=gn.HOLD_DELAY&&Math.abs(g.initialPageX-Wn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Wn(g.rollingPageY))<30){let y=this.newGestureEvent(Xs.Contextmenu,g.initialTarget);y.pageX=Wn(g.rollingPageX),y.pageY=Wn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Wn(g.rollingPageX),b=Wn(g.rollingPageY),w=Wn(g.rollingTimestamps)-g.rollingTimestamps[0],C=y-g.rollingPageX[0],S=b-g.rollingPageY[0],R=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,R,r,Math.abs(C)/w,C>0?1:-1,y,Math.abs(S)/w,S>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Xs.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Xs.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>gn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Xs.Change||t.type===Xs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,u,m,g,p){this.handle=Tb(t,()=>{let y=Date.now(),b=y-r,w=0,C=0,S=!0;o+=gn.SCROLL_FRICTION*b,m+=gn.SCROLL_FRICTION*b,o>0&&(S=!1,w=c*o*b),m>0&&(S=!1,C=g*m*b);let R=this.newGestureEvent(Xs.Change);R.translationX=w,R.translationY=C,n.forEach(B=>B.dispatchEvent(R)),S||this.inertia(t,n,y,o,c,u+w,m,g,p+C)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let u=this.activeTouches[c.identifier],m=this.newGestureEvent(Xs.Change,u.initialTarget);m.translationX=c.pageX-Wn(u.rollingPageX),m.translationY=c.pageY-Wn(u.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(c.pageX),u.rollingPageY.push(c.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};nu.SCROLL_FRICTION=-.005,nu.HOLD_DELAY=700,nu.CLEAR_TAP_COUNT_TIME=400,vi([vA],nu,"isTouchDevice",1);var _A=nu,Eb=class extends vt{onclick(e,t){this._register(st(e,qi.CLICK,n=>t(new Sh(Zs(e),n))))}onmousedown(e,t){this._register(st(e,qi.MOUSE_DOWN,n=>t(new Sh(Zs(e),n))))}onmouseover(e,t){this._register(st(e,qi.MOUSE_OVER,n=>t(new Sh(Zs(e),n))))}onmouseleave(e,t){this._register(st(e,qi.MOUSE_LEAVE,n=>t(new Sh(Zs(e),n))))}onkeydown(e,t){this._register(st(e,qi.KEY_DOWN,n=>t(new Kw(n))))}onkeyup(e,t){this._register(st(e,qi.KEY_UP,n=>t(new Kw(n))))}oninput(e,t){this._register(st(e,qi.INPUT,t))}onblur(e,t){this._register(st(e,qi.BLUR,t))}onfocus(e,t){this._register(st(e,qi.FOCUS,t))}onchange(e,t){this._register(st(e,qi.CHANGE,t))}ignoreGesture(e){return _A.ignoreTarget(e)}},Xw=11,bA=class extends Eb{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=Xw+"px",this.domNode.style.height=Xw+"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 ik),this._register(Vw(this.bgDomNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Vw(this.domNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new pA),this._pointerdownScheduleRepeatTimer=this._register(new kb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Zs(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()}},yA=class zv{constructor(t,n,r,o,c,u,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,u=u|0,m=m|0),this.rawScrollLeft=o,this.rawScrollTop=m,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),c<0&&(c=0),m+c>u&&(m=u-c),m<0&&(m=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=u,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 zv(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 zv(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 r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,u=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:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:u,scrollHeightChanged:m,scrollTopChanged:g}}},SA=class extends vt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new yA(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 r;t?r=new Zw(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Zw.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)))}},Gw=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function gg(e,t){let n=t-e;return function(r){return e+n*xA(r)}}function wA(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Zw=class Pv{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,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,r){if(Math.abs(t-n)>2.5*r){let o,c;return t<n?(o=t+.75*r,c=n-.75*r):(o=t-.75*r,c=n+.75*r),wA(gg(t,o),gg(c,n),.33)}return gg(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 r=this.scrollLeft(n),o=this.scrollTop(n);return new Gw(r,o,!1)}return new Gw(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Pv.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new Pv(t,n,o,r)}};function CA(e){return Math.pow(e,3)}function xA(e){return 1-CA(1-e)}var kA=class extends vt{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 kb)}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":"")))}},TA=140,nk=class extends Eb{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 kA(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ik),this._shouldRender=!0,this.domNode=yu(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(st(this.domNode.domNode,qi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new bA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=yu(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 r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(st(this.slider.domNode,qi.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(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?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=mA(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),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),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),u=Math.abs(c-n);if(Qx&&u>TA){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let m=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.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()}},sk=class Hv{constructor(t,n,r,o,c,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Hv(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,r,o,c){let u=Math.max(0,r-t),m=Math.max(0,u-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*m/o))),y=(m-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Hv._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,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},EA=class extends nk{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new sk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.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}},DA=class extends nk{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new sk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.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}},RA=500,Qw=50,MA=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Uv=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,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Cb){let n=Zs(t.browserEvent),r=UN(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,c=new MA(t,n,r);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 r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),p=Math.max(Math.min(c,m),1),y=Math.max(o,u),b=Math.max(c,m);y%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Uv.INSTANCE=new Uv;var NA=Uv,AA=class extends Eb{constructor(e,t,n){super(),this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ae),this.onWillScroll=this._onWillScroll.event,this._options=OA(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new DA(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new EA(this._scrollable,this._options,r)),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=yu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=yu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=yu(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 kb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ao(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Qs&&(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 $w(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ao(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new $w(n))};this._mouseWheelToDispose.push(st(this._listenOnDomNode,qi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=NA.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 u=!Qs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!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 p=Qw*o,y=m.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=Qw*c,y=m.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));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 r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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,r=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_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(),RA)}},LA=class extends AA{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 OA(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,Qs&&(t.className+=" mac"),t}var Fv=class extends vt{constructor(e,t,n,r,o,c,u,m){super(),this._bufferService=n,this._optionsService=u,this._renderService=m,this._onRequestScrollLines=this._register(new Ae),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new SA({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Tb(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new LA(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(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(cn.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ni(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ni(()=>this._styleElement.remove())),this._register(cn.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(p=>this._handleScroll(p)))}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}};Fv=vi([ze(2,Tn),ze(3,zr),ze(4,zx),ze(5,Wl),ze(6,En),ze(7,Pr)],Fv);var Kv=class extends vt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,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(ni(()=>{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()}};Kv=vi([ze(1,Tn),ze(2,zr),ze(3,Xu),ze(4,Pr)],Kv);var BA=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)}},Vs={full:0,left:0,center:0,right:0},wa={full:0,left:0,center:0,right:0},qc={full:0,left:0,center:0,right:0},of=class extends vt{constructor(e,t,n,r,o,c,u,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=m,this._colorZoneStore=new BA,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(ni(()=>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);wa.full=this._canvas.width,wa.left=e,wa.center=t,wa.right=e,this._refreshDrawHeightConstants(),qc.full=1,qc.left=1,qc.center=1+wa.left,qc.right=1+wa.left+wa.center}_refreshDrawHeightConstants(){Vs.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);Vs.left=t,Vs.center=t,Vs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vs.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(qc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Vs[e.position||"full"]/2),wa[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Vs[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}))}};of=vi([ze(2,Tn),ze(3,Xu),ze(4,Pr),ze(5,En),ze(6,Wl),ze(7,zr)],of);var be;(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=""))(be||={});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 rk;(e=>e.ST=`${be.ESC}\\`)(rk||={});var Wv=class{constructor(e,t,n,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,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(`${be.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,r=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=r+"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=r+"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)}}};Wv=vi([ze(2,Tn),ze(3,En),ze(4,Io),ze(5,Pr)],Wv);var Xi=0,Gi=0,Zi=0,gi=0,Jw={css:"#00000000",rgba:0},Ai;(e=>{function t(o,c,u,m){return m!==void 0?`#${yo(o)}${yo(c)}${yo(u)}${yo(m)}`:`#${yo(o)}${yo(c)}${yo(u)}`}e.toCss=t;function n(o,c,u,m=255){return(o<<24|c<<16|u<<8|m)>>>0}e.toRgba=n;function r(o,c,u,m){return{css:e.toCss(o,c,u,m),rgba:e.toRgba(o,c,u,m)}}e.toColor=r})(Ai||={});var ti;(e=>{function t(g,p){if(gi=(p.rgba&255)/255,gi===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,w=p.rgba>>8&255,C=g.rgba>>24&255,S=g.rgba>>16&255,R=g.rgba>>8&255;Xi=C+Math.round((y-C)*gi),Gi=S+Math.round((b-S)*gi),Zi=R+Math.round((w-R)*gi);let B=Ai.toCss(Xi,Gi,Zi),A=Ai.toRgba(Xi,Gi,Zi);return{css:B,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,y){let b=Fh.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return Ai.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Xi,Gi,Zi]=Fh.toChannels(p),{css:Ai.toCss(Xi,Gi,Zi),rgba:p}}e.opaque=o;function c(g,p){return gi=Math.round(p*255),[Xi,Gi,Zi]=Fh.toChannels(g.rgba),{css:Ai.toCss(Xi,Gi,Zi,gi),rgba:Ai.toRgba(Xi,Gi,Zi,gi)}}e.opacity=c;function u(g,p){return gi=g.rgba&255,c(g,gi*p/255)}e.multiplyOpacity=u;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(ti||={});var li;(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 r(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),Ai.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),gi=parseInt(o.slice(4,5).repeat(2),16),Ai.toColor(Xi,Gi,Zi,gi);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]),gi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Ai.toColor(Xi,Gi,Zi,gi);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,gi]=t.getImageData(0,0,1,1).data,gi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ai.toRgba(Xi,Gi,Zi,gi),css:o}}e.toColor=r})(li||={});var xn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let u=r/255,m=o/255,g=c/255,p=u<=.03928?u/12.92:Math.pow((u+.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 p*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(xn||={});var Fh;(e=>{function t(u,m){if(gi=(m&255)/255,gi===1)return m;let g=m>>24&255,p=m>>16&255,y=m>>8&255,b=u>>24&255,w=u>>16&255,C=u>>8&255;return Xi=b+Math.round((g-b)*gi),Gi=w+Math.round((p-w)*gi),Zi=C+Math.round((y-C)*gi),Ai.toRgba(Xi,Gi,Zi)}e.blend=t;function n(u,m,g){let p=xn.relativeLuminance(u>>8),y=xn.relativeLuminance(m>>8);if(Dr(p,y)<g){if(y<p){let C=r(u,m,g),S=Dr(p,xn.relativeLuminance(C>>8));if(S<g){let R=o(u,m,g),B=Dr(p,xn.relativeLuminance(R>>8));return S>B?C:R}return C}let b=o(u,m,g),w=Dr(p,xn.relativeLuminance(b>>8));if(w<g){let C=r(u,m,g),S=Dr(p,xn.relativeLuminance(C>>8));return w>S?b:C}return b}}e.ensureContrastRatio=n;function r(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,w=m>>24&255,C=m>>16&255,S=m>>8&255,R=Dr(xn.relativeLuminance2(w,C,S),xn.relativeLuminance2(p,y,b));for(;R<g&&(w>0||C>0||S>0);)w-=Math.max(0,Math.ceil(w*.1)),C-=Math.max(0,Math.ceil(C*.1)),S-=Math.max(0,Math.ceil(S*.1)),R=Dr(xn.relativeLuminance2(w,C,S),xn.relativeLuminance2(p,y,b));return(w<<24|C<<16|S<<8|255)>>>0}e.reduceLuminance=r;function o(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,w=m>>24&255,C=m>>16&255,S=m>>8&255,R=Dr(xn.relativeLuminance2(w,C,S),xn.relativeLuminance2(p,y,b));for(;R<g&&(w<255||C<255||S<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),R=Dr(xn.relativeLuminance2(w,C,S),xn.relativeLuminance2(p,y,b));return(w<<24|C<<16|S<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(Fh||={});function yo(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Dr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var jA=class extends Yu{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()]}},lf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ms}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=[],r=t.translateToString(!0),o=0,c=0,u=0,m=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,u,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=p,u=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ma.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,u,c,t,o);for(let y=0;y<p.length;y++)n.push(p[y])}return n}_getJoinedRanges(e,t,n,r,o){let c=e.substring(t,n),u=[];try{u=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 p=0;p<g.length;p++)lf._mergeRanges(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,u=e[r];if(u){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),p=t.getString(m).length||Ma.length;if(g!==0){if(!o&&u[0]<=c&&(u[0]=m,o=!0),u[1]<=c){if(u[1]=m,u=e[++r],!u)break;u[0]<=c?(u[0]=m,o=!0):o=!1}c+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,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}};lf=vi([ze(0,Tn)],lf);function IA(e){return 57508<=e&&e<=57558}function zA(e){return 9472<=e&&e<=9631}function PA(e){return IA(e)||zA(e)}function HA(){return{css:{canvas:wh(),cell:wh()},device:{canvas:wh(),cell:wh(),char:{width:0,height:0,left:0,top:0}}}}function wh(){return{width:0,height:0}}var $v=class{constructor(e,t,n,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new ms,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,u,m,g,p,y){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),C=this._themeService.colors,S=e.getNoBgTrimmedLength();n&&S<c+1&&(S=c+1);let R,B=0,A="",U=0,Y=0,K=0,se=0,Q=!1,z=0,_e=!1,ie=0,ke=0,ne=[],X=p!==-1&&y!==-1;for(let G=0;G<S;G++){e.loadCell(G,this._workCell);let q=this._workCell.getWidth();if(q===0)continue;let oe=!1,L=G>=ke,M=G,j=this._workCell;if(w.length>0&&G===w[0][0]&&L){let E=w.shift(),V=this._isCellInSelection(E[0],t);for(U=E[0]+1;U<E[1];U++)L&&=V===this._isCellInSelection(U,t);L&&=!n||c<E[0]||c>=E[1],L?(oe=!0,j=new jA(this._workCell,e.translateToString(!0,E[0],E[1]),E[1]-E[0]),M=E[1]-1,q=j.getWidth()):ke=E[1]}let re=this._isCellInSelection(G,t),ye=n&&G===c,N=X&&G>=p&&G<=y,W=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,E=>{W=!0});let ue=j.getChars()||Ma;if(ue===" "&&(j.isUnderline()||j.isOverline())&&(ue=" "),ie=q*m-g.get(ue,j.isBold(),j.isItalic()),!R)R=this._document.createElement("span");else if(B&&(re&&_e||!re&&!_e&&j.bg===Y)&&(re&&_e&&C.selectionForeground||j.fg===K)&&j.extended.ext===se&&N===Q&&ie===z&&!ye&&!oe&&!W&&L){j.isInvisible()?A+=Ma:A+=ue,B++;continue}else B&&(R.textContent=A),R=this._document.createElement("span"),B=0,A="";if(Y=j.bg,K=j.fg,se=j.extended.ext,Q=N,z=ie,_e=re,oe&&c>=G&&c<=M&&(c=G),!this._coreService.isCursorHidden&&ye&&this._coreService.isCursorInitialized){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ne.push("xterm-cursor-blink"),ne.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline");break}}if(j.isBold()&&ne.push("xterm-bold"),j.isItalic()&&ne.push("xterm-italic"),j.isDim()&&ne.push("xterm-dim"),j.isInvisible()?A=Ma:A=j.getChars()||Ma,j.isUnderline()&&(ne.push(`xterm-underline-${j.extended.underlineStyle}`),A===" "&&(A=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())R.style.textDecorationColor=`rgb(${Yu.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let E=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&E<8&&(E+=8),R.style.textDecorationColor=C.ansi[E].css}j.isOverline()&&(ne.push("xterm-overline"),A===" "&&(A=" ")),j.isStrikethrough()&&ne.push("xterm-strikethrough"),N&&(R.style.textDecoration="underline");let Ce=j.getFgColor(),Le=j.getFgColorMode(),Me=j.getBgColor(),Ne=j.getBgColorMode(),Oe=!!j.isInverse();if(Oe){let E=Ce;Ce=Me,Me=E;let V=Le;Le=Ne,Ne=V}let Ve,Ye,Be=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,E=>{E.options.layer!=="top"&&Be||(E.backgroundColorRGB&&(Ne=50331648,Me=E.backgroundColorRGB.rgba>>8&16777215,Ve=E.backgroundColorRGB),E.foregroundColorRGB&&(Le=50331648,Ce=E.foregroundColorRGB.rgba>>8&16777215,Ye=E.foregroundColorRGB),Be=E.options.layer==="top")}),!Be&&re&&(Ve=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,Me=Ve.rgba>>8&16777215,Ne=50331648,Be=!0,C.selectionForeground&&(Le=50331648,Ce=C.selectionForeground.rgba>>8&16777215,Ye=C.selectionForeground)),Be&&ne.push("xterm-decoration-top");let le;switch(Ne){case 16777216:case 33554432:le=C.ansi[Me],ne.push(`xterm-bg-${Me}`);break;case 50331648:le=Ai.toColor(Me>>16,Me>>8&255,Me&255),this._addStyle(R,`background-color:#${e1((Me>>>0).toString(16),"0",6)}`);break;default:Oe?(le=C.foreground,ne.push("xterm-bg-257")):le=C.background}switch(Ve||j.isDim()&&(Ve=ti.multiplyOpacity(le,.5)),Le){case 16777216:case 33554432:j.isBold()&&Ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ce+=8),this._applyMinimumContrast(R,le,C.ansi[Ce],j,Ve,void 0)||ne.push(`xterm-fg-${Ce}`);break;case 50331648:let E=Ai.toColor(Ce>>16&255,Ce>>8&255,Ce&255);this._applyMinimumContrast(R,le,E,j,Ve,Ye)||this._addStyle(R,`color:#${e1(Ce.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(R,le,C.foreground,j,Ve,Ye)||Oe&&ne.push("xterm-fg-257")}ne.length&&(R.className=ne.join(" "),ne.length=0),!ye&&!oe&&!W&&L?B++:R.textContent=A,ie!==this.defaultSpacing&&(R.style.letterSpacing=`${ie}px`),b.push(R),G=M}return R&&B&&(R.textContent=A),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||PA(r.getCode()))return!1;let u=this._getContrastCache(r),m;if(!o&&!c&&(m=u.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);m=ti.ensureContrastRatio(o||t,c||n,g),u.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,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};$v=vi([ze(1,Ux),ze(2,En),ze(3,zr),ze(4,Io),ze(5,Xu),ze(6,Wl)],$v);function e1(e,t,n){for(;e.length<n;)e=t+e;return e}var UA=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.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,r,o,c],this._container.appendChild(n),this._container.appendChild(r),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,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),n&&(u|=2),c=this._measure(e,u),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}},FA=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,r=!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,u=n[1]-o,m=Math.max(c,0),g=Math.min(u,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=u,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 KA(){return new FA}var vg="xterm-dom-renderer-owner-",us="xterm-rows",Ch="xterm-fg-",t1="xterm-bg-",Vc="xterm-focus",xh="xterm-selection",WA=1,qv=class extends vt{constructor(e,t,n,r,o,c,u,m,g,p,y,b,w,C){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=u,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=w,this._themeService=C,this._terminalClass=WA++,this._rowElements=[],this._selectionRenderModel=KA(),this.onRequestRedraw=this._register(new Ae).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(us),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(xh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=HA(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance($v,document),this._element.classList.add(vg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(ni(()=>{this._element.classList.remove(vg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new UA(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} .${us} 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} .${us} { 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} .${us} .xterm-dim { color: ${ti.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}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 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} .${us}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${us}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${us}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${us} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${us} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${us} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${us} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${us} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${xh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${xh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${xh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Ch}${c} { color: ${u.css}; }${this._terminalSelector} .${Ch}${c}.xterm-dim { color: ${ti.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${t1}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Ch}257 { color: ${ti.opaque(e.background).css}; }${this._terminalSelector} .${Ch}257.xterm-dim { color: ${ti.multiplyOpacity(ti.opaque(e.background),.5).css}; }${this._terminalSelector} .${t1}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 r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Vc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vc),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 r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=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],u-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,p));let y=u-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==u){let b=o===u?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${u}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,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,u,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${vg}${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,r,o,c){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),o=Math.min(o,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,p=Math.min(m.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let C=n;C<=r;++C){let S=C+m.ydisp,R=this._rowElements[C],B=m.lines.get(S);if(!R||!B)break;R.replaceChildren(...this._rowFactory.createRow(B,S,S===g,b,w,p,y,this.dimensions.css.cell.width,this._widthCache,c?C===n?e:0:-1,c?(C===r?t:o)-1:-1))}}};qv=vi([ze(7,yb),ze(8,zf),ze(9,En),ze(10,Tn),ze(11,Io),ze(12,zr),ze(13,Wl)],qv);var Vv=class extends vt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ae),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new qA(this._optionsService))}catch{this._measureStrategy=this._register(new $A(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())}};Vv=vi([ze(2,En)],Vv);var ak=class extends vt{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)}},$A=class extends ak{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}},qA=class extends ak{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}},VA=class extends vt{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 YA(this._window)),this._onDprChange=this._register(new Ae),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ae),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(cn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(st(this._textarea,"focus",()=>this._isFocused=!0)),this._register(st(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}},YA=class extends vt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Il),this._onDprChange=this._register(new Ae),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ni(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=st(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)}},XA=class extends vt{constructor(){super(),this.linkProviders=[],this._register(ni(()=>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 Db(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function GA(e,t,n,r,o,c,u,m,g){if(!c)return;let p=Db(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),p[1]=Math.ceil(p[1]/m),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var Yv=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return GA(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Db(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])}}};Yv=vi([ze(0,Pr),ze(1,zf)],Yv);var ZA=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=[]}},ok={};oN(ok,{getSafariVersion:()=>JA,isChromeOS:()=>dk,isFirefox:()=>lk,isIpad:()=>eL,isIphone:()=>tL,isLegacyEdge:()=>QA,isLinux:()=>Rb,isMac:()=>cf,isNode:()=>Pf,isSafari:()=>ck,isWindows:()=>uk});var Pf=typeof process<"u"&&"title"in process,Gu=Pf?"node":navigator.userAgent,Zu=Pf?"node":navigator.platform,lk=Gu.includes("Firefox"),QA=Gu.includes("Edge"),ck=/^((?!chrome|android).)*safari/i.test(Gu);function JA(){if(!ck)return 0;let e=Gu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Zu),eL=Zu==="iPad",tL=Zu==="iPhone",uk=["Windows","Win16","Win32","WinCE"].includes(Zu),Rb=Zu.indexOf("Linux")>=0,dk=/\bCrOS\b/.test(Gu),hk=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,r=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){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},iL=class extends hk{_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())}}},nL=class extends hk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},uf=!Pf&&"requestIdleCallback"in window?nL:iL,sL=class{constructor(){this._queue=new uf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Xv=class extends vt{constructor(e,t,n,r,o,c,u,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new Il),this._pausedResizeTask=new sL,this._observerDisposable=this._register(new Il),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 Ae),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ae),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ae),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ae),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ZA((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new rL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ni(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ni(()=>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 r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.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()}};Xv=vi([ze(2,En),ze(3,zf),ze(4,Io),ze(5,Xu),ze(6,Tn),ze(7,zr),ze(8,Wl)],Xv);var rL=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 aL(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return cL(o,c,e,t,n,r)+Hf(c,t,n,r)+uL(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",Nu(Math.abs(o-e),Mu(u,r));u=c>t?"D":"C";let m=Math.abs(c-t),g=lL(c>t?e:o,n)+(m-1)*n.cols+1+oL(c>t?o:e);return Nu(g,Mu(u,r))}function oL(e,t){return e-1}function lL(e,t){return t.cols-e}function cL(e,t,n,r,o,c){return Hf(t,r,o,c).length===0?"":Nu(pk(e,t,e,t-Lo(t,o),!1,o).length,Mu("D",c))}function Hf(e,t,n,r){let o=e-Lo(e,n),c=t-Lo(t,n),u=Math.abs(o-c)-dL(e,t,n);return Nu(u,Mu(fk(e,t),r))}function uL(e,t,n,r,o,c){let u;Hf(t,r,o,c).length>0?u=r-Lo(r,o):u=t;let m=r,g=hL(e,t,n,r,o,c);return Nu(pk(e,u,n,m,g==="C",o).length,Mu(g,c))}function dL(e,t,n){let r=0,o=e-Lo(e,n),c=t-Lo(t,n);for(let u=0;u<Math.abs(o-c);u++){let m=fk(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*u)?.isWrapped&&r++}return r}function Lo(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function hL(e,t,n,r,o,c){let u;return Hf(n,r,o,c).length>0?u=r-Lo(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function fk(e,t){return e>t?"A":"B"}function pk(e,t,n,r,o,c){let u=e,m=t,g="";for(;(u!==n||m!==r)&&m>=0&&m<c.buffer.lines.length;)u+=o?1:-1,o&&u>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,u),u=0,e=0,m++):!o&&u<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),u=c.cols-1,e=u,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,u)}function Mu(e,t){let n=t?"O":"[";return be.ESC+n+e}function Nu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var fL=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 i1(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 _g=50,pL=15,mL=50,gL=500,vL=" ",_L=new RegExp(vL,"g"),Gv=class extends vt{constructor(e,t,n,r,o,c,u,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=u,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ms,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ae),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ae),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ae),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ae),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new fL(this._bufferService),this._activeSelectionMode=0,this._register(ni(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.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,r=[];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 u=e[1];u<=t[1];u++){let m=n.translateBufferLineToString(u,!0,o,c);r.push(m)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let u=n.lines.get(c),m=n.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=m:r.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(_L," ")).join(uk?`\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())),Rb&&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,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_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=i1(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=Db(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,-_g),_g),t/=_g,t/Math.abs(t)+Math.round(t*(pL-1)))}shouldForceSelection(e){return cf?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(),mL)}_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&&!(cf&&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 r=n.lines.get(this._model.selectionEnd[1]);r&&r.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<gL&&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 r=aL(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!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 r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(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,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let u=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,p=e[0]-m,y=0,b=0,w=0,C=0;if(u.charAt(m)===" "){for(;m>0&&u.charAt(m-1)===" ";)m--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let B=e[0],A=e[0];c.getWidth(B)===0&&(y++,B--),c.getWidth(A)===2&&(b++,A++);let U=c.getString(A).length;for(U>1&&(C+=U-1,g+=U-1);B>0&&m>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,B--):Y>1&&(w+=Y-1,m-=Y-1),m--,B--}for(;A<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,A++):Y>1&&(C+=Y-1,g+=Y-1),g++,A++}}g++;let S=m+p-y+w,R=Math.min(this._bufferService.cols,g-m+y+b-w-C);if(!(!t&&u.slice(m,g).trim()==="")){if(n&&S===0&&c.getCodePoint(0)!==32){let B=o.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let U=this._bufferService.cols-A.start;S-=U,R+=U}}}if(r&&S+R===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=o.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(R+=A.length)}}return{start:S,length:R}}}_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=i1(n,this._bufferService.cols)}};Gv=vi([ze(3,Tn),ze(4,Io),ze(5,Sb),ze(6,En),ze(7,Pr),ze(8,zr)],Gv);var n1=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={}}},s1=class{constructor(){this._color=new n1,this._css=new n1}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()}},ji=Object.freeze((()=>{let e=[li.toColor("#2e3436"),li.toColor("#cc0000"),li.toColor("#4e9a06"),li.toColor("#c4a000"),li.toColor("#3465a4"),li.toColor("#75507b"),li.toColor("#06989a"),li.toColor("#d3d7cf"),li.toColor("#555753"),li.toColor("#ef2929"),li.toColor("#8ae234"),li.toColor("#fce94f"),li.toColor("#729fcf"),li.toColor("#ad7fa8"),li.toColor("#34e2e2"),li.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:Ai.toCss(r,o,c),rgba:Ai.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ai.toCss(r,r,r),rgba:Ai.toRgba(r,r,r)})}return e})()),wo=li.toColor("#ffffff"),su=li.toColor("#000000"),r1=li.toColor("#ffffff"),a1=su,Yc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},bL=wo,Zv=class extends vt{constructor(e){super(),this._optionsService=e,this._contrastCache=new s1,this._halfContrastCache=new s1,this._onChangeColors=this._register(new Ae),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wo,background:su,cursor:r1,cursorAccent:a1,selectionForeground:void 0,selectionBackgroundTransparent:Yc,selectionBackgroundOpaque:ti.blend(su,Yc),selectionInactiveBackgroundTransparent:Yc,selectionInactiveBackgroundOpaque:ti.blend(su,Yc),scrollbarSliderBackground:ti.opacity(wo,.2),scrollbarSliderHoverBackground:ti.opacity(wo,.4),scrollbarSliderActiveBackground:ti.opacity(wo,.5),overviewRulerBorder:wo,ansi:ji.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=Kt(e.foreground,wo),t.background=Kt(e.background,su),t.cursor=ti.blend(t.background,Kt(e.cursor,r1)),t.cursorAccent=ti.blend(t.background,Kt(e.cursorAccent,a1)),t.selectionBackgroundTransparent=Kt(e.selectionBackground,Yc),t.selectionBackgroundOpaque=ti.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ti.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Kt(e.selectionForeground,Jw):void 0,t.selectionForeground===Jw&&(t.selectionForeground=void 0),ti.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ti.opacity(t.selectionBackgroundTransparent,.3)),ti.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ti.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Kt(e.scrollbarSliderBackground,ti.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Kt(e.scrollbarSliderHoverBackground,ti.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Kt(e.scrollbarSliderActiveBackground,ti.opacity(t.foreground,.5)),t.overviewRulerBorder=Kt(e.overviewRulerBorder,bL),t.ansi=ji.slice(),t.ansi[0]=Kt(e.black,ji[0]),t.ansi[1]=Kt(e.red,ji[1]),t.ansi[2]=Kt(e.green,ji[2]),t.ansi[3]=Kt(e.yellow,ji[3]),t.ansi[4]=Kt(e.blue,ji[4]),t.ansi[5]=Kt(e.magenta,ji[5]),t.ansi[6]=Kt(e.cyan,ji[6]),t.ansi[7]=Kt(e.white,ji[7]),t.ansi[8]=Kt(e.brightBlack,ji[8]),t.ansi[9]=Kt(e.brightRed,ji[9]),t.ansi[10]=Kt(e.brightGreen,ji[10]),t.ansi[11]=Kt(e.brightYellow,ji[11]),t.ansi[12]=Kt(e.brightBlue,ji[12]),t.ansi[13]=Kt(e.brightMagenta,ji[13]),t.ansi[14]=Kt(e.brightCyan,ji[14]),t.ansi[15]=Kt(e.brightWhite,ji[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Kt(e.extendedAnsi[r],ji[r+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()}}};Zv=vi([ze(0,En)],Zv);function Kt(e,t){if(e!==void 0)try{return li.toColor(e)}catch{}return t}var yL=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)}},SL=class{constructor(){this._services=new yL,this._services.set(yb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=pN(e).sort((c,u)=>c.index-u.index),r=[];for(let c of n){let u=this._services.get(c.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(u)}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,...r)}},wL={trace:0,debug:1,info:2,warn:3,error:4,off:5},CL="xterm.js: ",Qv=class extends vt{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=wL[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?"":CL)+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)}};Qv=vi([ze(0,En)],Qv);var o1=class extends vt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ae),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ae),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ae),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 r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}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 r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},gt=3,Mi=Object.freeze(new Yu),kh=0,bg=2,ru=class mk{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*gt);let o=n||ms.fromCharData([0,Ox,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*gt+0],r=n&2097151;return[this._data[t*gt+1],n&2097152?this._combined[t]:r?Da(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*gt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*gt+0]=t|2097152|n[2]<<22):this._data[t*gt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*gt+0]>>22}hasWidth(t){return this._data[t*gt+0]&12582912}getFg(t){return this._data[t*gt+1]}getBg(t){return this._data[t*gt+2]}hasContent(t){return this._data[t*gt+0]&4194303}getCodePoint(t){let n=this._data[t*gt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*gt+0]&2097152}getString(t){let n=this._data[t*gt+0];return n&2097152?this._combined[t]:n&2097151?Da(n&2097151):""}isProtected(t){return this._data[t*gt+2]&536870912}loadCell(t,n){return kh=t*gt,n.content=this._data[kh+0],n.fg=this._data[kh+1],n.bg=this._data[kh+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*gt+0]=n.content,this._data[t*gt+1]=n.fg,this._data[t*gt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*gt+0]=n|r<<22,this._data[t*gt+1]=o.fg,this._data[t*gt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*gt+0];o&2097152?this._combined[t]+=Da(n):o&2097151?(this._combined[t]=Da(o&2097151)+Da(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*gt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new ms;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,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new ms;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,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*bg<this._data.buffer.byteLength;let r=t*gt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);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,r);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let m=parseInt(o[u],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let u=0;u<c.length;u++){let m=parseInt(c[u],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,r*4*bg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*bg<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 r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,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 mk(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*gt+0]&4194303)return t+(this._data[t*gt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*gt+0]&4194303||this._data[t*gt+2]&50331648)return t+(this._data[t*gt+0]>>22);return 0}copyCellsFrom(t,n,r,o,c){let u=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<gt;p++)this._data[(r+g)*gt+p]=u[(n+g)*gt+p];u[(n+g)*gt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<gt;p++)this._data[(r+g)*gt+p]=u[(n+g)*gt+p];u[(n+g)*gt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let p=parseInt(m[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<r;){let u=this._data[n*gt+0],m=u&2097151,g=u&2097152?this._combined[n]:m?Da(m):Ma;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function xL(e,t,n,r,o,c){let u=[];for(let m=0;m<e.length-1;m++){let g=m,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=m&&r<g){m+=y.length-1;continue}let b=0,w=Au(y,b,t),C=1,S=0;for(;C<y.length;){let B=Au(y,C,t),A=B-S,U=n-w,Y=Math.min(A,U);y[b].copyCellsFrom(y[C],S,w,Y,!1),w+=Y,w===n&&(b++,w=0),S+=Y,S===B&&(C++,S=0),w===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,w++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(w,n,o);let R=0;for(let B=y.length-1;B>0&&(B>b||y[B].getTrimmedLength()===0);B--)R++;R>0&&(u.push(m+y.length-R),u.push(R)),m+=y.length-1}return u}function kL(e,t){let n=[],r=0,o=t[r],c=0;for(let u=0;u<e.length;u++)if(o===u){let m=t[++r];e.onDeleteEmitter.fire({index:u-c,amount:m}),u+=m-1,c+=m,o=t[++r]}else n.push(u);return{layout:n,countRemoved:c}}function TL(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function EL(e,t,n){let r=[],o=e.map((g,p)=>Au(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,m=0;for(;m<o;){if(o-m<n){r.push(o-m);break}c+=n;let g=Au(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let y=p?n-1:n;r.push(y),m+=y}return r}function Au(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var gk=class vk{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=vk._nextId++,this._onDispose=this.register(new Ae),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ao(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};gk._nextId=1;var DL=gk,Pi={},Co=Pi.B;Pi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Pi.A={"#":"£"};Pi.B=void 0;Pi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pi.C=Pi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pi.E=Pi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pi.H=Pi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var l1=4294967295,c1=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=Mi.clone(),this.savedCharset=Co,this.markers=[],this._nullCell=ms.fromCharData([0,Ox,1,0]),this._whitespaceCell=ms.fromCharData([0,Ma,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new uf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new o1(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 af),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 af),this._whitespaceCell}getBlankLine(e,t){return new ru(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>l1?l1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Mi);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 o1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Mi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let c=0;if(this._rows<t)for(let u=this._rows;u<t;u++)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 ru(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 ru(e,n)));else for(let u=this._rows;u>t;u--)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 u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,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++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.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,r=xL(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Mi),n);if(r.length>0){let o=kL(this.lines,r);TL(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Mi),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ru(e,r))):(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,r=this.getNullCell(Mi),o=[],c=0;for(let u=this.lines.length-1;u>=0;u--){let m=this.lines.get(u);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&u>0;)m=this.lines.get(--u),g.unshift(m);if(!n){let Y=this.ybase+this.y;if(Y>=u&&Y<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=EL(g,this._cols,e),b=y.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let C=[];for(let Y=0;Y<b;Y++){let K=this.getBlankLine(Mi,!0);C.push(K)}C.length>0&&(o.push({start:u+g.length+c,newLines:C}),c+=C.length),g.push(...C);let S=y.length-1,R=y[S];R===0&&(S--,R=y[S]);let B=g.length-b-1,A=p;for(;B>=0;){let Y=Math.min(A,R);if(g[S]===void 0)break;if(g[S].copyCellsFrom(g[B],A-Y,R-Y,Y,!0),R-=Y,R===0&&(S--,R=y[S]),A-=Y,A===0){B--;let K=Math.max(B,0);A=Au(g,K,this._cols)}}for(let Y=0;Y<g.length;Y++)y[Y]<e&&g[Y].setCell(y[Y],r);let U=b-w;for(;U-- >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 u=[],m=[];for(let R=0;R<this.lines.length;R++)m.push(this.lines.get(R));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let R=Math.min(this.lines.maxLength-1,g+c-1);R>=0;R--)if(b&&b.start>p+w){for(let B=b.newLines.length-1;B>=0;B--)this.lines.set(R--,b.newLines[B]);R++,u.push({index:p+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++y]}else this.lines.set(R,m[p--]);let C=0;for(let R=u.length-1;R>=0;R--)u[R].index+=C,this.lines.onInsertEmitter.fire(u[R]),C+=u[R].amount;let S=Math.max(0,g+c-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}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 DL(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)}},RL=class extends vt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ae),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 c1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c1(!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)}},_k=2,bk=1,Jv=class extends vt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ae),this.onResize=this._onResize.event,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,_k),this.rows=Math.max(e.rawOptions.rows||0,bk),this.buffers=this._register(new RL(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,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;c===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=c-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(c,r.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 r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Jv=vi([ze(0,En)],Jv);var yl={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:cf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ML=["normal","bold","100","200","300","400","500","600","700","800","900"],NL=class extends vt{constructor(e){super(),this._onOptionChange=this._register(new Ae),this.onOptionChange=this._onOptionChange.event;let t={...yl};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ni(()=>{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 yl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in yl))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=yl[e]),!AL(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=yl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=ML.includes(t)?t:yl[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 AL(e){return e==="block"||e==="underline"||e==="bar"}function au(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&au(e[r],t-1);return n}var u1=Object.freeze({insertMode:!1}),d1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),e_=class extends vt{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 Ae),this.onData=this._onData.event,this._onUserInput=this._register(new Ae),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ae),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ae),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=au(u1),this.decPrivateModes=au(d1)}reset(){this.modes=au(u1),this.decPrivateModes=au(d1)}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(r=>r.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))}};e_=vi([ze(0,Tn),ze(1,Px),ze(2,En)],e_);var h1={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 yg(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 Sg=String.fromCharCode,f1={DEFAULT:e=>{let t=[yg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Sg(t[0])}${Sg(t[1])}${Sg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yg(e,!0)};${e.x};${e.y}${t}`}},t_=class extends vt{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 Ae),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(h1))this.addProtocol(r,h1[r]);for(let r of Object.keys(f1))this.addEncoding(r,f1[r]);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 r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+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)}};t_=vi([ze(0,Tn),ze(1,Io),ze(2,En)],t_);var wg=[[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]],LL=[[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]],Ii;function OL(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var BL=class{constructor(){if(this.version="6",!Ii){Ii=new Uint8Array(65536),Ii.fill(1),Ii[0]=0,Ii.fill(0,1,32),Ii.fill(0,127,160),Ii.fill(2,4352,4448),Ii[9001]=2,Ii[9002]=2,Ii.fill(2,11904,42192),Ii[12351]=1,Ii.fill(2,44032,55204),Ii.fill(2,63744,64256),Ii.fill(2,65040,65050),Ii.fill(2,65072,65136),Ii.fill(2,65280,65377),Ii.fill(2,65504,65511);for(let e=0;e<wg.length;++e)Ii.fill(0,wg[e][0],wg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ii[e]:OL(e,LL)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=xo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return xo.createPropertyValue(0,n,r)}},xo=class Kh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ae,this.onChange=this._onChange.event;let t=new BL;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,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?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,r=0,o=t.length;for(let c=0;c<o;++c){let u=t.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=o)return n+this.wcwidth(u);let p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let m=this.charProperties(u,r),g=Kh.extractWidth(m);Kh.extractShouldJoin(m)&&(g-=Kh.extractWidth(r)),n+=g,r=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},jL=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 p1(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 Xc=2147483647,IL=256,yk=class i_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>IL)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 i_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];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 i_(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 r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,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>Xc?Xc: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>Xc?Xc: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,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Xc):t}},Gc=[],zL=class{constructor(){this._state=0,this._active=Gc,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 r=n.indexOf(t);r!==-1&&n.splice(r,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=Gc}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=Gc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gc,!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",If(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].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 r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-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,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Gc,this._id=-1,this._state=0}}},$n=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+=If(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}},Zc=[],PL=class{constructor(){this._handlers=Object.create(null),this._active=Zc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Zc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,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=Zc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Zc,!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",If(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Zc,this._ident=0}},ou=new yk;ou.addParam(0);var m1=class{constructor(e){this._handler=e,this._data="",this._params=ou,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ou,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=If(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=ou,this._data="",this._hitLimit=!1,n));return this._params=ou,this._data="",this._hitLimit=!1,t}},HL=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},fs=160,UL=(function(){let e=new HL(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in c)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,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(r,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(r,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(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(fs,0,2,0),e.add(fs,8,5,8),e.add(fs,6,0,6),e.add(fs,11,0,11),e.add(fs,13,13,13),e})(),FL=class extends vt{constructor(e=UL){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 yk,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},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(ni(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new zL),this._dcsParser=this._register(new PL),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 r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,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 r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.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 r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.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,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,u;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&&(u=m[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===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(r=e[m],o=this._transitions.table[this.currentState<<8|(r<160?r:fs)],o>>4){case 2:for(let w=m+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<fs){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<fs){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<fs){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<fs){this._printHandler(e,m,w),m=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:m,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,m),u;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++m<t&&(r=e[m])>47&&r<60);m--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(u=y[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,y,b,o,m),u;b<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let w=m+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<fs){this._dcsParser.put(e,m,w),m=w-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,m),u;r===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 w=m+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<fs){this._oscParser.put(e,m,w),m=w-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},KL=/^([\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})$/,WL=/^[\da-f]+$/;function g1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=KL.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),WL.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return r}}function Cg(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function $L(e,t=16){let[n,r,o]=e;return`rgb:${Cg(n,t)}/${Cg(r,t)}/${Cg(o,t)}`}var qL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ca=131072,v1=10;function _1(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 b1=5e3,y1=0,VL=class extends vt{constructor(e,t,n,r,o,c,u,m,g=new FL){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=u,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new hN,this._utf8Decoder=new fN,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.clone(),this._onRequestBell=this._register(new Ae),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ae),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ae),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ae),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ae),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ae),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ae),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ae),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ae),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ae),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ae),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ae),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 n_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,b)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(be.BEL,()=>this.bell()),this._parser.setExecuteHandler(be.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(be.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(be.BS,()=>this.backspace()),this._parser.setExecuteHandler(be.HT,()=>this.tab()),this._parser.setExecuteHandler(be.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(be.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 $n(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new $n(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new $n(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new $n(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new $n(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new $n(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new $n(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new $n(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new $n(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new $n(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new $n(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new $n(p=>this.restoreCursorColor(p))),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 p in Pi)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new m1((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),b1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${b1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ca&&(c=this._parseStack.position+Ca)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ca&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ca))),u||this._dirtyRowTracker.clearRange(),e.length>Ca)for(let p=c;p<e.length;p+=Ca){let y=p+Ca<e.length?p+Ca:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(n),n}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||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 r,o,c=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=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 w=this._parser.precedingJoinState;for(let C=t;C<n;++C){if(r=e[C],r<127&&c){let A=c[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let S=this._unicodeService.charProperties(r,w);o=xo.extractWidth(S);let R=xo.extractShouldJoin(S),B=R?xo.extractWidth(w):0;if(w=S,u&&this._onA11yChar.fire(Da(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>m){if(g){let A=b,U=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&b instanceof ru&&b.copyCellsFrom(A,U,0,B,!1);U<m;)A.setCellFromCodepoint(U++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(R&&this._activeBuffer.x){let A=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-A,r,o);for(let U=o-B;--U>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=w,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=>_1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new m1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $n(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,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(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 r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+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,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,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(Mi));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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.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,r=xo.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*n),m=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;u[m++]=y,p+=y>65535?2:1}let g=m;for(let p=1;p<n;++p)u.copyWithin(g,0,m),g+=m;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(be.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(be.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(be.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(be.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(be.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,Co),this._charsetService.setgCharset(1,Co),this._charsetService.setgCharset(2,Co),this._charsetService.setgCharset(3,Co);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;(R=>(R[R.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",R[R.SET=1]="SET",R[R.RESET=2]="RESET",R[R.PERMANENTLY_SET=3]="PERMANENTLY_SET",R[R.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,u=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:p,alt:y}=m,b=this._optionsService.rawOptions,w=(R,B)=>(u.triggerDataEvent(`${be.ESC}[${t?"":"?"}${R};${B}$y`),!0),C=R=>R?1:2,S=e.params[0];return t?S===2?w(S,4):S===4?w(S,C(u.modes.insertMode)):S===12?w(S,3):S===20?w(S,C(b.convertEol)):w(S,0):S===1?w(S,C(r.applicationCursorKeys)):S===3?w(S,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):S===6?w(S,C(r.origin)):S===7?w(S,C(r.wraparound)):S===8?w(S,3):S===9?w(S,C(o==="X10")):S===12?w(S,C(b.cursorBlink)):S===25?w(S,C(!u.isCursorHidden)):S===45?w(S,C(r.reverseWraparound)):S===66?w(S,C(r.applicationKeypad)):S===67?w(S,4):S===1e3?w(S,C(o==="VT200")):S===1002?w(S,C(o==="DRAG")):S===1003?w(S,C(o==="ANY")):S===1004?w(S,C(r.sendFocus)):S===1005?w(S,4):S===1006?w(S,C(c==="SGR")):S===1015?w(S,4):S===1016?w(S,C(c==="SGR_PIXELS")):S===1048?w(S,1):S===47||S===1047||S===1049?w(S,C(p===y)):S===2004?w(S,C(r.bracketedPasteMode)):S===2026?w(S,C(r.synchronizedOutput)):w(S,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=Yu.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let u=e.getSubParams(t+c),m=0;do r[1]===5&&(o=1),r[c+m+1+o]=u[m];while(++m<u.length&&m+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[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=Mi.fg,e.bg=Mi.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,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Mi.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Mi.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Mi.fg&16777215,r.bg&=-67108864,r.bg|=Mi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${be.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${be.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(`${be.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=Mi.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(!_1(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(`${be.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>v1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>v1&&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 r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(S1(c))if(o==="?")t.push({type:0,index:c});else{let u=g1(o);u&&t.push({type:1,index:c,color:u})}}}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(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,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 r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=g1(n[r]);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 r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);S1(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,Co),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(qL[e[0]],Pi[e[1]]||Co),!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=Mi.clone(),this._eraseAttrDataInternal=Mi.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 ms;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,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${be.ESC}${u}${be.ESC}\\`),!0),r=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${r.scrollTop+1};${r.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)}},n_=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&&(y1=e,e=t,t=y1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};n_=vi([ze(0,Tn)],n_);function S1(e){return 0<=e&&e<256}var YL=5e7,w1=12,XL=50,GL=class extends vt{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 Ae),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 r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>YL)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 r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let u=m=>performance.now()-n>=w1?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=w1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>XL&&(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()}},s_=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,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}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)))}};s_=vi([ze(0,Tn)],s_);var C1=!1,ZL=class extends vt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Il),this._onBinary=this._register(new Ae),this.onBinary=this._onBinary.event,this._onData=this._register(new Ae),this.onData=this._onData.event,this._onLineFeed=this._register(new Ae),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ae),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ae),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ae),this._instantiationService=new SL,this.optionsService=this._register(new NL(e)),this._instantiationService.setService(En,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Jv)),this._instantiationService.setService(Tn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qv)),this._instantiationService.setService(Px,this._logService),this.coreService=this._register(this._instantiationService.createInstance(e_)),this._instantiationService.setService(Io,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(t_)),this._instantiationService.setService(zx,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(xo)),this._instantiationService.setService(vN,this.unicodeService),this._charsetService=this._instantiationService.createInstance(jL),this._instantiationService.setService(gN,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(s_),this._instantiationService.setService(Hx,this._oscLinkService),this._inputHandler=this._register(new VL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(cn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(cn.forward(this._bufferService.onResize,this._onResize)),this._register(cn.forward(this.coreService.onData,this._onData)),this._register(cn.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 GL((t,n)=>this._inputHandler.parse(t,n))),this._register(cn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ae),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&&!C1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),C1=!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,_k),t=Math.max(t,bk),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(p1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(p1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ni(()=>{for(let t of e)t.dispose()})}}},QL={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 JL(e,t,n,r){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=be.ESC+"OA":o.key=be.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=be.ESC+"OD":o.key=be.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=be.ESC+"OC":o.key=be.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=be.ESC+"OB":o.key=be.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":be.DEL,e.altKey&&(o.key=be.ESC+o.key);break;case 9:if(e.shiftKey){o.key=be.ESC+"[Z";break}o.key=be.HT,o.cancel=!0;break;case 13:o.key=e.altKey?be.ESC+be.CR:be.CR,o.cancel=!0;break;case 27:o.key=be.ESC,e.altKey&&(o.key=be.ESC+be.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"D":t?o.key=be.ESC+"OD":o.key=be.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"C":t?o.key=be.ESC+"OC":o.key=be.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"A":t?o.key=be.ESC+"OA":o.key=be.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"B":t?o.key=be.ESC+"OB":o.key=be.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=be.ESC+"[2~");break;case 46:c?o.key=be.ESC+"[3;"+(c+1)+"~":o.key=be.ESC+"[3~";break;case 36:c?o.key=be.ESC+"[1;"+(c+1)+"H":t?o.key=be.ESC+"OH":o.key=be.ESC+"[H";break;case 35:c?o.key=be.ESC+"[1;"+(c+1)+"F":t?o.key=be.ESC+"OF":o.key=be.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=be.ESC+"[5;"+(c+1)+"~":o.key=be.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=be.ESC+"[6;"+(c+1)+"~":o.key=be.ESC+"[6~";break;case 112:c?o.key=be.ESC+"[1;"+(c+1)+"P":o.key=be.ESC+"OP";break;case 113:c?o.key=be.ESC+"[1;"+(c+1)+"Q":o.key=be.ESC+"OQ";break;case 114:c?o.key=be.ESC+"[1;"+(c+1)+"R":o.key=be.ESC+"OR";break;case 115:c?o.key=be.ESC+"[1;"+(c+1)+"S":o.key=be.ESC+"OS";break;case 116:c?o.key=be.ESC+"[15;"+(c+1)+"~":o.key=be.ESC+"[15~";break;case 117:c?o.key=be.ESC+"[17;"+(c+1)+"~":o.key=be.ESC+"[17~";break;case 118:c?o.key=be.ESC+"[18;"+(c+1)+"~":o.key=be.ESC+"[18~";break;case 119:c?o.key=be.ESC+"[19;"+(c+1)+"~":o.key=be.ESC+"[19~";break;case 120:c?o.key=be.ESC+"[20;"+(c+1)+"~":o.key=be.ESC+"[20~";break;case 121:c?o.key=be.ESC+"[21;"+(c+1)+"~":o.key=be.ESC+"[21~";break;case 122:c?o.key=be.ESC+"[23;"+(c+1)+"~":o.key=be.ESC+"[23~";break;case 123:c?o.key=be.ESC+"[24;"+(c+1)+"~":o.key=be.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=be.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=be.DEL:e.keyCode===219?o.key=be.ESC:e.keyCode===220?o.key=be.FS:e.keyCode===221&&(o.key=be.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=QL[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=be.ESC+u;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=be.ESC+g}else if(e.keyCode===32)o.key=be.ESC+(e.ctrlKey?be.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=be.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=be.US),e.key==="@"&&(o.key=be.NUL));break}return o}var Ci=0,e3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new uf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new uf,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,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,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||(Ci=this._search(t),Ci===-1)||this._getKey(this._array[Ci])!==t)return!1;do if(this._array[Ci]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ci),!0;while(++Ci<this._array.length&&this._getKey(this._array[Ci])===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),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=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&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do yield this._array[Ci];while(++Ci<this._array.length&&this._getKey(this._array[Ci])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do t(this._array[Ci]);while(++Ci<this._array.length&&this._getKey(this._array[Ci])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},xg=0,x1=0,t3=class extends vt{constructor(){super(),this._decorations=new e3(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ae),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ae),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ni(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new i3(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.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 r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{xg=o.options.x??0,x1=xg+(o.options.width??1),e>=xg&&e<x1&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},i3=class extends Aa{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ae),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ae),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=li.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=li.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},n3=1e3,s3=class{constructor(e,t=n3){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 r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-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)}},k1=20,df=class extends vt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,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 s3(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(st(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ni(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<k1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===k1+1&&(this._liveRegion.textContent+=xv.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,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),u=[],m=c?.translateToString(!0,void 0,void 0,u)||"",g=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(m.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=m,this._rowColumns.set(p,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=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!==r)return;let u,m;if(t===0?(u=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(u=this._rowElements.shift(),m=n,this._rowContainer.removeChild(u)),u.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 r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:m,offset:g})=>{let p=m instanceof Text?m.parentNode:m,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++y,w=0),{row:y,column:w}},c=o(t),u=o(n);if(!(!c||!u)){if(c.row>u.row||c.row===u.row&&c.column>=u.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(u.row-c.row)*this._terminal.cols-c.column+u.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 r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};df=vi([ze(1,yb),ze(2,zr),ze(3,Pr)],df);var r_=class extends vt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ae),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ae),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ni(()=>{Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(st(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(st(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(st(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(st(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 r=0;r<n.length;r++){let o=n[r];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(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(m=>({link:m}));this._activeProviderReplies?.set(r,u),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let u=o[c],m=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=m;p<=g;p++){if(n.has(p)){o.splice(c--,1);break}n.add(p)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=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&&r){let c=r.find(u=>this._linkAtPosition(u.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 u=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(u){n=!0,this._handleNewLink(u);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&&r3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ao(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=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>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,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,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-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,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};r_=vi([ze(1,Sb),ze(2,Pr),ze(3,Tn),ze(4,Fx)],r_);function r3(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 a3=class extends ZL{constructor(e={}){super(e),this._linkifier=this._register(new Il),this.browser=ok,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Il),this._onCursorMove=this._register(new Ae),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ae),this.onKey=this._onKey.event,this._onRender=this._register(new Ae),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ae),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ae),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ae),this.onBell=this._onBell.event,this._onFocus=this._register(new Ae),this._onBlur=this._register(new Ae),this._onA11yCharEmitter=this._register(new Ae),this._onA11yTabEmitter=this._register(new Ae),this._onWillOpen=this._register(new Ae),this._setup(),this._decorationService=this._instantiationService.createInstance(t3),this._instantiationService.setService(Xu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(XA),this._instantiationService.setService(Fx,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Tv)),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(cn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(cn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(cn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(cn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ni(()=>{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,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=ti.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${be.ESC}]${r};${$L(o)}${rk.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Ai.toColor(...t.color));else{let c=n;this._themeService.modifyColors(u=>u[c]=Ai.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(df,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(be.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(be.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),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,u=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=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(st(this.element,"copy",t=>{this.hasSelection()&&uN(t,this._selectionService)}));let e=t=>dN(t,this.textarea,this.coreService,this.optionsService);this._register(st(this.textarea,"paste",e)),this._register(st(this.element,"paste",e)),lk?this._register(st(this.element,"mousedown",t=>{t.button===2&&Bw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(st(this.element,"contextmenu",t=>{Bw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Rb&&this._register(st(this.element,"auxclick",t=>{t.button===1&&Lx(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(st(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(st(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(st(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(st(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(st(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(st(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(st(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(st(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",Cv.get()),dk||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(VA,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zr,this._coreBrowserService),this._register(st(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(st(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Vv,this._document,this._helperContainer),this._instantiationService.setService(zf,this._charSizeService),this._themeService=this._instantiationService.createInstance(Zv),this._instantiationService.setService(Wl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lf),this._instantiationService.setService(Ux,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Xv,this.rows,this.screenElement)),this._instantiationService.setService(Pr,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(Wv,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yv),this._instantiationService.setService(Sb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(r_,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(Fv,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(Gv,this.element,this.screenElement,r)),this._instantiationService.setService(bN,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(cn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Kv,this.screenElement)),this._register(st(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(df,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(of,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(of,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qv,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)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 p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.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?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(st(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(st(t,"wheel",c=>{if(!r.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 u=be.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!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){Ax(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=JL(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),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===be.ETX||n.key===be.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)&&(o3(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(Mi));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(be.ESC+"[I"):this.coreService.triggerDataEvent(be.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(`${be.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${be.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function o3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var l3=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)}},c3=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 ms)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},T1=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 c3(t)}getNullCell(){return new ms}},u3=class extends vt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ae),this.onBufferChange=this._onBufferChange.event,this._normal=new T1(this._core.buffers.normal,"normal"),this._alternate=new T1(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)}},d3=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,r)=>t(n,r.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)}},h3=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}},f3=["cols","rows"],Ys=0,p3=class extends vt{constructor(e){super(),this._core=this._register(new a3(e)),this._addonManager=this._register(new l3),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(f3.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 d3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new h3(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 u3(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 Cv.get()},set promptLabel(e){Cv.set(e)},get tooMuchOutput(){return xv.get()},set tooMuchOutput(e){xv.set(e)}}}_verifyIntegers(...e){for(Ys of e)if(Ys===1/0||isNaN(Ys)||Ys%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ys of e)if(Ys&&(Ys===1/0||isNaN(Ys)||Ys%1!==0||Ys<0))throw new Error("This API only accepts positive integers")}};const m3=Ni.lazy(()=>bb(()=>import("./TranscriptMarkdownBody-DZwdkUVR.js"),__vite__mapDeps([2,1])));function Sk({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=u.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let m=-1;return h.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,p)=>{const y=g.kind==="user"?++m:null,b=n===p?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return h.jsxs("section",{ref:w=>{w?u.current.set(p,w):u.current.delete(p)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":p,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?h.jsx("div",{className:"transcript-entry-header",children:wk(g.header,t)}):null,g.body?h.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?h.jsx(E1,{text:g.body,searchQuery:t}):h.jsx(Ni.Suspense,{fallback:h.jsx(E1,{text:g.body,searchQuery:t}),children:h.jsx(m3,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function E1({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
32
|
+
`)?e.slice(0,-1).split(`
|
|
33
|
+
`):e.split(`
|
|
34
|
+
`);return h.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>h.jsx("span",{className:`transcript-line transcript-line-${y3(r,o===0||n[o-1]?.trim()==="")}`,children:wk(r,t)},o))})}function wk(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let u=0,m=r.indexOf(o);for(;m!==-1;){m>u&&c.push(e.slice(u,m));const g=m+n.length;c.push(h.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),u=g,m=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function g3(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(n);for(;c!==-1;)o+=1,c=r.indexOf(n,c+n.length);return o}function Ck(e){const t=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function u(){const m=v3(c).join(`
|
|
36
|
+
`);(r||m)&&n.push({header:r,body:m,kind:o}),r=null,o="plain",c=[]}for(const m of t.split(`
|
|
37
|
+
`)){const g=_3(m);g?(u(),r=m,o=g):c.push(m)}return u(),n}function v3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function _3(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 b3(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
38
|
+
${o.body}`:o.body,u=g3(c,t);for(let m=0;m<u;m+=1)n.push({entryIndex:r,matchIndexInEntry:m})}return n}function y3(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||Tk(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 Oo(e){return e==="codex"?"Codex":"Claude"}function a_(e,t,n={}){const r=`[nterminal] ${Oo(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
+
`).replace(/\r/g,`
|
|
40
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
41
|
+
|
|
42
|
+
`).trimEnd(),c=xk(o),u=n.includeTools?c:kk(c);return u?`${u}
|
|
43
|
+
`:""}function xk(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 r=S3(n);return r?`[${r}]`:t})}function S3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=Qc(t.getMonth()+1),o=Qc(t.getDate()),c=Qc(t.getHours()),u=Qc(t.getMinutes()),m=Qc(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${m}`}function Qc(e){return e.toString().padStart(2,"0")}function hf(e,t){return e.map(n=>t?n:kk(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
44
|
+
`)?n:`${n}
|
|
45
|
+
`).join("")}function kk(e){if(!e)return"";const t=e.split(`
|
|
46
|
+
`),n=[];let r=!1,o=!1,c=!0;for(const u of t){const m=u.trim()==="",g=c?w3(u):null;if(g&&(r=g==="tool",o=!1),Tk(u)){o=!0,c=!1;continue}if(o){m?(o=!1,r||n.push(u),c=!0):c=!1;continue}r||n.push(u),c=m}return n.join(`
|
|
47
|
+
`).replace(/\n{3,}/g,`
|
|
48
|
+
|
|
49
|
+
`).trimEnd()}function w3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function Tk(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Mb(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Th(e,t){return e===null?t===null:t!==null&&Mb(e,t)}const C3=5e3,x3=200,k3=1200,T3=4,E3=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const u=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(!1),[w,C]=v.useState(null),[S,R]=v.useState(null),[B,A]=v.useState(null),[U,Y]=v.useState(()=>new Set),[K,se]=v.useState(!1),[Q,z]=v.useState(!1),[_e,ie]=v.useState([]),[ke,ne]=v.useState(null),[X,G]=v.useState(!1),[q,oe]=v.useState(!1),[L,M]=v.useState(!1),[j,re]=v.useState(null),ye=w?.find(E=>E.id===B)??null;v.useEffect(()=>{function E(V){V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),c())}return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[c]);const N=v.useCallback(async()=>{try{const E=await n.getTerminalSubagents(t);if(R(null),C(V=>V&&A3(V,E.subagents)?V:E.subagents),!b.current){const V=E.subagents.find(ge=>ge.hasTranscript);V&&(b.current=!0,A(ge=>ge??V.id))}}catch(E){R(E instanceof Error?E.message:"Failed to load subagents."),C(V=>V??[])}},[n,t]);v.useEffect(()=>{N();const E=window.setInterval(()=>{document.hidden||N()},C3);function V(){document.hidden||N()}return document.addEventListener("visibilitychange",V),()=>{window.clearInterval(E),document.removeEventListener("visibilitychange",V)}},[N]),v.useEffect(()=>{m.current+=1;const E=m.current;return g.current=!1,p.current=!0,y.current=null,ie([]),ne(null),G(!1),re(null),B&&W(null,"initial",E),()=>{m.current===E&&(m.current+=1)}},[n,t,B,Q]),v.useLayoutEffect(()=>{const E=u.current;if(!E)return;if(p.current){if(q||_e.length===0)return;p.current=!1;const ge=()=>{E.scrollTop=E.scrollHeight};ge(),window.requestAnimationFrame?.(ge);return}const V=y.current;V!==null&&(y.current=null,E.scrollTop+=E.scrollHeight-V)},[_e,q,Q]);async function W(E,V,ge=m.current){const Te=B;if(!(!Te||g.current)){g.current=!0,V==="initial"?oe(!0):(M(!0),y.current=u.current?.scrollHeight??null),re(null);try{let F=E,Se=0,xe=0,he=[];for(;m.current===ge;){const je=await n.getTerminalSubagentTranscriptHistory(t,Te,{...F?{cursor:F}:{},limit:x3,maxLines:k3,includeTools:Q});if(m.current!==ge)return;if(!je.source){if(xe<1){xe+=1,await new Promise(He=>setTimeout(He,600));continue}re("Subagent transcript is unavailable.");return}const Ie=a_(je.output,je.source.provider,{includeTools:Q});if(ne(je.cursor),G(!!(je.hasMore&&je.cursor)),Ie&&(he=[Ie,...he],hf(he,Q))){ie(He=>V==="older"?[...he,...He]:he);return}if(!je.hasMore||!je.cursor||Se>=T3){he.length>0&&ie(He=>V==="older"?[...he,...He]:he);return}F=je.cursor,Se+=1}}catch(F){if(m.current!==ge)return;re(F instanceof Error?F.message:"Failed to load subagent transcript.")}finally{m.current===ge&&(g.current=!1,oe(!1),M(!1))}}}function ue(){const E=u.current;E&&(E.scrollTop>72||!X||!ke||g.current||W(ke,"older"))}function Ce(E){Y(V=>{const ge=new Set(V);return ge.delete(E)||ge.add(E),ge})}function Le(E){b.current=!0,se(!0),E.id!==B&&A(E.id),Me(E.id)}function Me(E){const V=M3(w??[],E);V.length!==0&&Y(ge=>{if(V.every(F=>ge.has(F)))return ge;const Te=new Set(ge);for(const F of V)Te.add(F);return Te})}function Ne(){m.current+=1;const E=m.current;g.current=!1,p.current=!0,y.current=null,ie([]),ne(null),G(!1),re(null),W(null,"initial",E)}const Oe=v.useMemo(()=>hf(_e,Q),[_e,Q]),Ve=v.useMemo(()=>Ck(Oe),[Oe]),Ye=w===null;v.useEffect(()=>{if(q||L||!X||!ke||g.current)return;const E=u.current;!E||_e.length===0||E.scrollHeight<=E.clientHeight+4&&W(ke,"older")},[_e,X,ke,q,L]);const Be=w?.filter(E=>E.state==="working").length??0,le=v.useMemo(()=>Rk(D3(w??[]),U),[w,U]);return h.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),c()},children:h.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":K?"transcript":"list",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"transcript-dialog-title",children:[h.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?h.jsx("span",{className:"subagents-count",children:Be>0?`${Be} working · ${w.length} total`:`${w.length} total`}):null]}),h.jsxs("span",{title:r.sessionId,children:[Oo(r.provider)," session ",r.sessionId]})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),h.jsxs("div",{className:"subagents-body",children:[h.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[Ye?h.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Ye&&S?h.jsx("div",{className:"subagents-list-status subagents-list-error",children:S}):null,!Ye&&!S&&w!==null&&w.length===0?h.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,le.map(E=>{const V=E.subagent,ge=U.has(V.id);return h.jsxs("div",{className:"subagent-row-wrap",style:E.level>0?{paddingLeft:`${Math.min(E.level,4)*14}px`}:void 0,children:[E.nestedCount>0?h.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":ge,"aria-label":`${ge?"Collapse":"Expand"} ${E.nestedCount} nested subagents of ${V.name}`,title:E.nestedWorkingCount>0?`${E.nestedCount} nested · ${E.nestedWorkingCount} working`:`${E.nestedCount} nested`,onClick:()=>Ce(V.id),children:[h.jsx("span",{"aria-hidden":"true",children:ge?"▾":"▸"}),h.jsx("span",{className:"subagent-expander-count","data-working":E.nestedWorkingCount>0?"true":"false",children:E.nestedCount})]}):h.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),h.jsxs("button",{type:"button",className:"subagent-row","data-selected":V.id===B?"true":"false","data-state":V.state,disabled:!V.hasTranscript,title:V.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Le(V),children:[h.jsx("span",{className:"subagent-row-dot","data-state":V.state,"aria-hidden":"true"}),h.jsxs("span",{className:"subagent-row-main",children:[h.jsxs("span",{className:"subagent-row-title",children:[h.jsx("strong",{children:V.name}),h.jsx("span",{className:"subagent-row-badge","data-kind":V.kind,children:V.kind==="cross"?Oo(V.provider):V.provider})]}),V.description?h.jsx("span",{className:"subagent-row-description",children:V.description}):null,h.jsxs("span",{className:"subagent-row-meta",children:[L3(V.state),V.model?` · ${V.model}`:"",V.updatedAt?` · ${O3(V.updatedAt)}`:"",E.nestedCount>0&&!ge?` · ${E.nestedCount} nested${E.nestedWorkingCount>0?` (${E.nestedWorkingCount} working)`:""}`:""]})]})]})]},V.id)})]}),h.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[h.jsxs("div",{className:"subagents-transcript-controls",children:[h.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>se(!1),children:"‹ List"}),h.jsx("span",{className:"subagents-transcript-name",children:ye?ye.name:"Select a subagent"}),h.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[h.jsx("input",{type:"checkbox",checked:Q,onChange:E=>z(E.currentTarget.checked)}),"Show tool output"]}),h.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!ye,onClick:Ne,children:"↻"})]}),ye?h.jsx("div",{className:"subagents-transcript-hint",children:N3(ye)}):null,h.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:ue,children:[L?h.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!q&&X?h.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Oe?h.jsx(Sk,{entries:Ve,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,q?h.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!q&&ye&&!Oe&&!j?X&&ke?h.jsxs("div",{className:"transcript-dialog-status",children:[Q?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",h.jsx("button",{type:"button",onClick:()=>{W(ke,"older")},disabled:L,children:"Search earlier entries"})]}):h.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!ye&&!Ye&&!Oe?h.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,j?h.jsx("div",{className:"transcript-dialog-error",children:j}):null]})]})]})]})})});function D3(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=R3(r,t);o?o.children.push(r):n.push(r)}for(const r of n)Ek(r);return Dk(n),n}function R3(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const u=c.subagent.parentId;c=u?t.get(u):void 0}return r}function Ek(e){let t=0,n=0;for(const r of e.children)Ek(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,Dk(e.children)}function Dk(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function Rk(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...Rk(o.children,t,n+1));return r}function M3(e,t){const n=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function N3(e){return e.kind==="cross"?'"User" entries are the prompt the parent session passed to codex exec, not operator input.':e.provider==="codex"?"Codex forks the parent thread to start a teammate; the inherited history is hidden here. Coordinator instructions are stored encrypted by Codex, so they show as placeholders.":`"User" entries are the parent session's instructions and tool results, not operator input.`}function A3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function L3(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function O3(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}class B3{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():Lk.has(t)?this.acceptConsonant(t):Ok.has(t)?this.acceptVowel(t):P3(t)&&this.canReplacePendingWith(t)?(this.pending=R1(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(Bk.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=z3.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=I3.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=D1.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 r=this.pending.final,o=M1({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=D1.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=R1(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=M1(this.pending);return this.pending=null,t}}const ff=44032,pf=21,Tl=28,j3=19*pf*Tl,Mk=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Nk=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],Ak=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Lk=Nb(Mk),Ok=Nb(Nk),Bk=Nb(Ak),I3=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),jk=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],z3=new Map(jk),D1=new Map(jk.map(([e,t])=>[t,[e[0],e[1]]]));function Nb(e){return new Map(e.map((t,n)=>[t,n]))}function P3(e){const t=e.codePointAt(0);return t!==void 0&&t>=ff&&t<ff+j3}function R1(e){const t=e.codePointAt(0)-ff,n=Math.floor(t/(pf*Tl)),r=Math.floor(t%(pf*Tl)/Tl),o=t%Tl,c={initial:Mk[n],vowel:Nk[r]};return o===0?c:{...c,final:Ak[o]}}function M1(e){if(!e.vowel)return e.initial;const t=Lk.get(e.initial),n=Ok.get(e.vowel),r=e.final?Bk.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(ff+(t*pf+n)*Tl+r)}const H3=[{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 U3({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return h.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[h.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"}),H3.map(u=>h.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),h.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const F3={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function K3(e){return F3[e]}function W3(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const Ik="--nterminal-viewport-height",zk="--nterminal-keyboard-inset-bottom",Pk="data-nterminal-keyboard-visible",Uf="data-nterminal-compose-open",mf="nterminal:viewport-refresh",$3=120;function q3(e=window){const t=e.document.documentElement,n=e.visualViewport,r=Q3(e);function o(){Ab(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(mf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(mf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(Ik),t.style.removeProperty(zk),t.removeAttribute(Pk)}}function Ab(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=o_(e),o=V3(e,r);return o!==null&&N1(t,Ik,`${o}px`),N1(t,zk,`${n}px`),Y3(t,Pk,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function o_(e=window){const t=X3(e);return{keyboardInsetBottom:t,keyboardVisible:t>$3}}function V3(e,t){if((e.document.documentElement.hasAttribute(Uf)||t)&&Do(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Do(n)?n:Do(e.innerHeight)?e.innerHeight:null}function Do(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function N1(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function Y3(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function X3(e){return Math.max(G3(e),Z3(e))}function G3(e){const t=e.visualViewport?.height;if(!Do(t)||!Do(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 Z3(e){if(!Do(e.innerHeight))return 0;const n=Hk(e)?.boundingRect?.height;return!Do(n)||n>=e.innerHeight*.8?0:Math.round(n)}function Hk(e){return e.navigator.virtualKeyboard}function Q3(e){const t=Hk(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Qu=new Map,Lu=new Map,J3=Object.freeze({open:!1,text:""});function eO(e){let t=Lu.get(e);return t||(t=new Set,Lu.set(e,t)),t}function Uk(e){const t=Lu.get(e);if(t)for(const n of Array.from(t))n()}function Nl(e){return Qu.get(e)??J3}function tO(e,t){const n=eO(e);return n.add(t),()=>{n.delete(t)}}function iO(e,t){const n=Nl(e);n.open!==t&&(Qu.set(e,{...n,open:t}),Uk(e))}function nO(e,t){const n=Nl(e);n.text!==t&&(Qu.set(e,{...n,text:t}),Uk(e))}function Eh(e){Qu.delete(e),Lu.delete(e)}function A1(){Qu.clear(),Lu.clear()}const Ha=new Map,Ou=new Map,gf=new Map,sO=Object.freeze([]);function Bu(e){return Ha.get(e)??sO}function rO(e,t){let n=Ou.get(e);return n||(n=new Set,Ou.set(e,n)),n.add(t),()=>n?.delete(t)}function kg(e,t){t.length!==0&&(Ha.set(e,[...Bu(e),...t]),Ff(e))}function Tg(e){const t=gf.get(e)??1;return gf.set(e,t+1),`attach${t}`}function l_(e){gf.delete(e)}function Jc(e,t,n){const r=Bu(e);r.length!==0&&(Ha.set(e,r.map(o=>t.has(o.id)?n(o):o)),Ff(e))}function Dh(e,t){const n=Bu(e);n.find(c=>c.id===t)?.cancel?.();const o=n.filter(c=>c.id!==t);o.length!==n.length&&(o.length===0?Ha.delete(e):Ha.set(e,o),Ff(e))}function Fk(e){const t=Ha.get(e);if(t){for(const n of t)n.cancel?.();Ha.delete(e),Ff(e)}}function lu(e){Fk(e),l_(e),Ou.delete(e)}function L1(){for(const e of Array.from(Ha.keys()))lu(e);Ou.clear(),gf.clear()}function Ff(e){for(const t of Array.from(Ou.get(e)??[]))t()}class aO extends Error{constructor(t){super(t),this.name="UploadDropError"}}function El(e){return e?Array.from(e.types??[]).includes("Files")||Vk(e.items).some(n=>n.kind==="file")?!0:Yk(e.files).length>0:!1}async function Kk(e){const t=Vk(e.items).filter(n=>n.kind==="file");return t.length>0?oO(t):lO(e.files)}async function oO(e){const t=[];for(const n of e){const r=hO(n);if(r){await Wk(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:$k(o),file:o});continue}throw new aO("Folder upload is not supported by this browser.")}return t}function lO(e){return Yk(e).map(t=>({relativePath:$k(t),file:t}))}async function Wk(e,t,n){const r=pO(t,e.name);if(e.isFile){const u=await cO(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await uO(o);for(const u of c)await Wk(u,r,n)}function cO(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function uO(e){const t=[];for(;;){const n=await dO(e);if(n.length===0)return t;t.push(...n)}}function dO(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function $k(e){const t=e.webkitRelativePath;return qk(typeof t=="string"&&t?t:e.name)}function hO(e){const t=e.webkitGetAsEntry?.();return fO(t)?t:null}function fO(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 pO(e,t){return qk(e?`${e}/${t}`:t)}function qk(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Vk(e){return e?Array.from(e):[]}function Yk(e){return e?Array.from(e):[]}const mO=120,gO="\x1B[200~",vO="\x1B[201~";function Eg(e,t){const n=t.stripTrailingLineBreaks===!1?e:Lb(e),r=bO(n);return r?t.bracketedPasteMode?`${gO}${r}${vO}`:r:""}function _O(e){return e==="queue"?" ":"\r"}function Lb(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function bO(e){return e.replace(/\r\n/g,`
|
|
50
|
+
`).replace(/\r/g,`
|
|
51
|
+
`).replace(/\n/g,"\r")}const yO=420,SO=3e3,O1=650,wO=80,CO=3,xO=10,kO=50*1024*1024,TO=100*1024*1024,EO={maxFiles:xO,maxFileBytes:kO,maxBatchBytes:TO},Wh=new Set;let Al=null;function DO({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const m=v.useMemo(()=>E=>tO(e,E),[e]),g=v.useMemo(()=>()=>Nl(e),[e]),p=v.useSyncExternalStore(m,g,g),{open:y,text:b}=p,w=v.useMemo(()=>E=>rO(e,E),[e]),C=v.useMemo(()=>()=>Bu(e),[e]),S=v.useSyncExternalStore(w,C,C),[R,B]=v.useState(EO),[A,U]=v.useState(!1),Y=v.useRef(null),K=v.useRef(null),se=v.useRef(null),Q=v.useRef(null),z=v.useRef(new Map),_e=v.useRef(c),ie=v.useRef(u),ke=v.useRef(null),ne=v.useRef({start:0,end:0});_e.current=c,ie.current=u,v.useEffect(()=>()=>{ke.current?.(),ke.current=null},[]),v.useEffect(()=>{if(!y||!_e.current)return;let E=!0;return _e.current().then(V=>{E&&B(V)}).catch(()=>{}),()=>{E=!1}},[y,e]),v.useLayoutEffect(()=>{if(!(!y||!$h()))return BO(e),()=>jO(e)},[y,e]),v.useLayoutEffect(()=>{const E=Y.current?.closest(".terminal-pane");if(!E)return;function V(){E?.removeAttribute("data-compose-open"),E?.style.removeProperty("--compose-drawer-panel-height")}if(!y){V();return}const ge=K.current;E.setAttribute("data-compose-open","true");function Te(){const he=ge?.getBoundingClientRect().height??0;he>0&&E?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(he)}px`)}Te();const F=[window.setTimeout(Te,0),window.setTimeout(Te,180),window.setTimeout(Te,260)],Se=window.requestAnimationFrame?.(Te)??null,xe=typeof ResizeObserver=="function"&&ge?new ResizeObserver(Te):null;return xe&&ge&&xe.observe(ge),()=>{for(const he of F)window.clearTimeout(he);Se!==null&&window.cancelAnimationFrame?.(Se),xe?.disconnect(),V()}},[y]),v.useEffect(()=>{if(!y){ke.current?.(),ke.current=null;return}Ng(se.current),Ye()},[y]);function X(E){iO(e,E)}function G(E){nO(e,E)}function q(){OO(Y.current),X(!1),I1()}function oe(E="send"){const V=S.filter(Te=>Te.status==="uploaded"&&Te.path);if(r||S.some(Te=>Te.status==="uploading"||Te.status==="failed")||!b&&V.length===0)return;const ge=NO(b,S);if(ge.parts.some(Te=>Te.kind==="image"||Te.value.trim())&&t(ge,E)){if(G(""),Fk(e),l_(e),$h()){se.current?.blur(),I1();return}window.setTimeout(()=>se.current?.focus(),mO+20)}}async function L(E){if(r||E.length===0)return;const V=Bu(e).filter(Ie=>Ie.status!=="failed"),ge=V.reduce((Ie,He)=>Ie+He.file.size,0);let Te=0,F=V.length;const Se=[],xe=E.filter((Ie,He)=>{const et=ge+Te+Ie.file.size,Mt=Ie.file.size>R.maxFileBytes?`File exceeds the ${j1(R.maxFileBytes)} attachment limit.`:F>=R.maxFiles?`A compose message can include up to ${R.maxFiles} attachments.`:et>R.maxBatchBytes?`Compose attachments cannot exceed ${j1(R.maxBatchBytes)} in total.`:null;return Mt?(Se.push({id:Rg(He),reference:Tg(e),file:Ie.file,relativePath:B1(Ie.relativePath,Ie.file.name),status:"failed",error:Mt}),!1):(F+=1,Te+=Ie.file.size,!0)});if(Se.length>0&&kg(e,Se),xe.length===0)return;const he=new Map,je=xe.map((Ie,He)=>{const et=Rg(He),Mt=new AbortController;return he.set(et,Mt),{id:et,reference:Tg(e),file:Ie.file,relativePath:B1(Ie.relativePath,Ie.file.name),status:"uploading",loaded:0,total:Ie.file.size,cancel:()=>Mt.abort()}});kg(e,je),Be(je.map(Ie=>Ie.reference));for(const Ie of je)z.current.set(Ie.id,he.get(Ie.id));await Promise.all(je.map(async Ie=>{const He=he.get(Ie.id),et=new Set([Ie.id]);try{const pt=(await o([{relativePath:Ie.relativePath,file:Ie.file}],{signal:He.signal,onProgress:kt=>{Jc(e,et,yt=>({...yt,loaded:kt.loaded,total:kt.total}))}})).results[0];if(He.signal.aborted){const kt=ie.current;pt?.status==="uploaded"&&pt.attachmentId&&kt&&kt([pt.attachmentId]).catch(()=>{});return}Jc(e,et,kt=>{const{error:yt,cancel:Qt,...ci}=kt;return pt?.status==="uploaded"&&pt.path?{...ci,status:"uploaded",...pt.attachmentId?{attachmentId:pt.attachmentId}:{},path:pt.path,loaded:pt.size??kt.file.size,total:pt.size??kt.file.size}:{...ci,status:"failed",error:pt?.error??"upload_failed"}})}catch(Mt){const pt=He.signal.aborted?"Upload canceled.":Mg(Mt);Jc(e,et,kt=>{const{cancel:yt,...Qt}=kt;return{...Qt,status:"failed",error:pt}})}finally{z.current.get(Ie.id)===He&&z.current.delete(Ie.id)}}))}function M(E){if(E.status!=="removing"){if(le(E.reference),E.status!=="uploaded"&&E.status!=="failed"||!E.attachmentId||!ie.current){z.current.delete(E.id),Dh(e,E.id);return}re([E])}}function j(){G(""),l_(e);const E=S.filter(V=>!!(V.path&&V.attachmentId));for(const V of S)E.includes(V)||(z.current.delete(V.id),Dh(e,V.id));E.length>0&&re(E)}function re(E){const V=E.flatMap(Te=>Te.attachmentId?[Te.attachmentId]:[]);if(V.length===0||!ie.current){for(const Te of E)Dh(e,Te.id);return}const ge=new Set(E.map(Te=>Te.id));Jc(e,ge,Te=>{const{error:F,...Se}=Te;return{...Se,status:"removing"}}),ie.current(V).then(()=>{for(const Te of E)Dh(e,Te.id)}).catch(Te=>{Jc(e,ge,F=>({...F,status:"failed",error:`Could not remove attachment: ${Mg(Te)}`}))})}function ye(E){const V=Array.from(E.currentTarget.files??[]).map(ge=>({relativePath:ge.name,file:ge}));E.currentTarget.value="",L(V)}function N(E){const V=Array.from(E.clipboardData.files??[]);V.length!==0&&L(V.map(ge=>({relativePath:ge.name,file:ge})))}function W(E){r||!El(E.dataTransfer)||(E.preventDefault(),E.stopPropagation(),E.dataTransfer.dropEffect="copy",U(!0))}function ue(E){r||!El(E.dataTransfer)||(E.preventDefault(),E.stopPropagation(),U(!0))}function Ce(E){if(!El(E.dataTransfer))return;const V=E.relatedTarget;V instanceof Node&&E.currentTarget.contains(V)||U(!1)}function Le(E){El(E.dataTransfer)&&(E.preventDefault(),E.stopPropagation(),U(!1),Kk(E.dataTransfer).then(L).catch(V=>{const ge={id:Rg(0),reference:Tg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:Mg(V)};kg(e,[ge])}))}const Me=S.some(E=>E.status==="uploading"),Ne=S.some(E=>E.status==="failed"),Oe=S.filter(E=>E.status==="uploaded"&&E.path).length,Ve=!r&&!Me&&!Ne&&(!!b||Oe>0);function Ye(){$h()&&(ke.current?.(),ke.current=IO())}function Be(E){if(E.length===0)return;const V=E.map(Mt=>`@${Mt}`).join(" "),ge=Nl(e).text,Te=Math.min(ne.current.start,ge.length),F=Math.min(Math.max(Te,ne.current.end),ge.length),Se=ge.slice(0,Te),xe=ge.slice(F),he=Se&&!/\s$/.test(Se)?" ":"",je=xe&&!/^\s/.test(xe)?" ":"",Ie=`${he}${V}${je}`,He=`${Se}${Ie}${xe}`,et=Se.length+Ie.length;ne.current={start:et,end:et},G(He),window.requestAnimationFrame(()=>{const Mt=se.current;Mt&&(Ng(Mt),Mt.setSelectionRange(et,et))})}function le(E){const V=Nl(e).text,ge=V.replace(new RegExp(`@${LO(E)}(?![A-Za-z0-9_])`,"g"),"");ge!==V&&G(ge.replace(/[ \t]{2,}/g," "))}return h.jsxs("div",{ref:Y,className:"compose-drawer","data-open":y?"true":"false",children:[h.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":y?"true":void 0,tabIndex:y?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>X(!0),children:[h.jsx("span",{"aria-hidden":"true",children:"▴"}),h.jsx("span",{children:"compose"}),b||S.length>0?h.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),h.jsxs("div",{ref:K,className:"compose-drawer-panel","aria-hidden":y?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:ue,onDragOver:W,onDragLeave:Ce,onDrop:Le,children:[A?h.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,h.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:y?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:q,children:[h.jsx("span",{"aria-hidden":"true",children:"▾"}),h.jsx("span",{className:"compose-drawer-title",children:"compose"}),h.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"}),h.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),h.jsx("textarea",{ref:se,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:y?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:E=>{ne.current={start:E.target.selectionStart,end:E.target.selectionEnd},G(E.target.value)},onSelect:E=>{ne.current={start:E.currentTarget.selectionStart,end:E.currentTarget.selectionEnd}},onPaste:N,onFocus:Ye,onKeyDown:E=>{if(E.key==="Enter"&&(E.metaKey||E.ctrlKey)){if(E.preventDefault(),E.shiftKey){n&&oe("queue");return}oe("send");return}E.key==="Escape"&&(E.preventDefault(),q())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),h.jsx("input",{ref:Q,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:ye}),S.length>0?h.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:S.map(E=>h.jsx(RO,{attachment:E,onRemove:()=>M(E)},E.id))}):null,h.jsxs("div",{className:"compose-drawer-actions",children:[h.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:y?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>Q.current?.click(),disabled:r,children:"+"}),h.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:y?0:-1,onClick:()=>{j(),Ng(se.current),Ye()},disabled:!b&&S.length===0,children:"Clear"}),n?h.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:y?0:-1,title:Ne?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>oe("queue"),disabled:!Ve,children:"Queue"}):null,h.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:y?0:-1,title:Ne?"Remove failed attachments before sending.":void 0,onClick:()=>oe("send"),disabled:!Ve,children:"Send"})]})]})]})}function RO({attachment:e,onRemove:t}){const n=MO(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return h.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?h.jsx("img",{src:n,alt:""}):h.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),h.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),h.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),h.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),h.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function MO(e,t){const n=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n}function NO(e,t){const n=new Map(t.map(m=>[m.reference,m])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let c=0,u;for(;(u=o.exec(e))!==null;){const m=n.get(u[1]);m&&(Dg(r,e.slice(c,u.index)),m.status==="uploaded"&&m.path&&(AO(m)?r.push({kind:"image",path:m.path}):Dg(r,m.path)),c=o.lastIndex)}return Dg(r,e.slice(c)),{parts:r}}function Dg(e,t){if(!t)return;const n=e.at(-1);if(n?.kind==="text"){n.value+=t;return}e.push({kind:"text",value:t})}function AO(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function LO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function B1(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Rg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function Mg(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function j1(e){return e%(1024*1024)===0?`${e/(1024*1024)} MB`:e>=1024*1024?`${Math.round(e/(1024*1024)*10)/10} MB`:`${Math.ceil(e/1024)} KB`}function OO(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Ng(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function $h(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function I1(){if(!$h())return;const e=Dl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function BO(e){Al!==null&&(window.clearTimeout(Al),Al=null),Wh.add(e),document.documentElement.setAttribute(Uf,"true"),Dl()}function jO(e){if(Wh.delete(e),Wh.size>0||Al!==null){Dl();return}Al=window.setTimeout(()=>{if(Al=null,Wh.size>0){Dl();return}document.documentElement.removeAttribute(Uf),Dl()},yO),Dl()}function IO(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,m=zO();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(w){if(!e){if(w<O1&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,wO)}}function b(){if(e)return;g();const w=Ab(),C=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),C>=SO||C>=O1&&o>=CO){p();return}y(C)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),p}function Dl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Ab()}function zO(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function PO(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(FO(u))return u.preventDefault(),u.stopPropagation(),HO(e),!1;if(UO(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(KO(u)){const m=c_(e);return m?(u.preventDefault(),u.stopPropagation(),u_(m),!1):!0}return WO(u)?(u.preventDefault(),u.stopPropagation(),$O(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const m=c_(e);if(m){if(u.clipboardData){u.clipboardData.setData("text/plain",m),u.preventDefault();return}u.preventDefault(),u_(m)}},c=u=>{const m=u.clipboardData?.getData("text/plain");if(!m)return;const g=Lb(m);u.preventDefault(),u.stopImmediatePropagation(),Xk(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",c,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function HO(e){const t=c_(e);t&&await u_(t)}function UO(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function FO(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 KO(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function WO(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 $O(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;Xk(e,Lb(n),t)}catch{}}function Xk(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function c_(e){return e.hasSelection()?e.getSelection():qO(e.element??null)}function qO(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 r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function u_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}VO(e)}function VO(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 YO=[4,10,11,12];function XO(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>z1(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>z1(r)),e.parser.registerCsiHandler({final:"n"},r=>GO(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>ZO(r)),e.parser.registerCsiHandler({final:"t"},r=>QO(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...YO.map(r=>e.parser.registerOscHandler(r,o=>JO(o)))];return{dispose(){for(const r of n)r.dispose()}}}function z1(e){return Kf(e)===0}function GO(e){const t=Kf(e);return t===5||t===6}function ZO(e){return Kf(e)===6}function QO(e){const t=Kf(e);return t===14||t===16||t===18}function JO(e){return e.split(";").some(t=>t==="?")}function Kf(e){const t=e[0];return typeof t=="number"?t:0}const Rs=new Map,Ag=2*1024*1024,e5=1500,P1=25e3,t5=2500,i5=2500,n5=1e3,s5=2e3,r5=3e4,a5=16*1024*1024,d_=256,Gk=eR-3e4,o5=3e3,Zk=1e4,l5=3e3,h_=16*1024*1024,Wf=4*1024*1024,vf=25,c5=1e3,u5=3e3,Lg=8,d5=100,Qk=1e3,H1=[2e3,5e3,15e3,6e4];let h5=0,f5=0,Og=0,Bg=null,qh=!1,f_=0,Vh=0,La=!1,U1=!1,Su=null,F1=!1,p_=0,ju=document.visibilityState!=="hidden";const _f=new Set;let Ll=null,wu=0;const p5=new TextEncoder,m5=I5();function g5(e,t){_5(),k5(),Lf()&&Or(0);let n=Rs.get(e);n||(n=S5(e),Rs.set(e,n),ql(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Bb(n));const o=(m,g)=>E5(n,m,g),c=m=>{m?(n.foregroundAttachments.add(r),bf(),tT(n)):(n.foregroundAttachments.delete(r),m_())},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),m_()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function cu(e){const t=Rs.get(e);t&&(j5(t),Rs.delete(e),m_())}function v5(e){const t=Rs.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Ka(t),Es(t),tr(t),Wa(t),Js(t,"reconnecting"),$a(t);const n=t.socket;return t.socket=null,Ra(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),ql(t),!0}function _5(){if(F1)return;F1=!0;const e=()=>{if(document.visibilityState==="hidden"){ju=!1,p_+=1,iT(),eT(),b5();return}Ob(),wu=Date.now(),bf()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),bf()}function bf(){Ll!==null||document.visibilityState==="hidden"||!Jk()||typeof window.requestAnimationFrame!="function"||(Ll=window.requestAnimationFrame(()=>{if(Ll=null,document.visibilityState==="hidden")return;const e=Date.now(),t=wu>0?e-wu:0;if(wu=e,t>=s5){for(const n of Rs.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&Ua("terminal.connection.foreground_gap",n,{gapMs:t});Ob(void 0,{foregroundOnly:!0})}bf()}))}function Jk(){for(const e of Rs.values())if(e.foregroundAttachments.size>0)return!0;return!1}function m_(){Jk()||(eT(),wu=0)}function eT(){Ll!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Ll),Ll=null}function tT(e){if(document.visibilityState!=="hidden"){if(!ju||e?.heartbeatSuspended){Ob(e);return}e&&g_(e)}}function Ob(e,t={}){if(document.visibilityState==="hidden")return;ju=!0;const n=++p_;iT();const r=Array.from(Rs.values()).filter(m=>!m.exited&&m.reconnectEnabled&&m.status!=="unauthorized"),o=r.filter(m=>m===e||m.foregroundAttachments.size>0||R5(m)),c=new Set(o),u=r.filter(m=>!c.has(m));for(const m of o)g_(m);if(!t.foregroundOnly)for(let m=0;m<u.length;m+=Lg){const g=u.slice(m,m+Lg),p=Math.floor(m/Lg)*d5,y=window.setTimeout(()=>{if(_f.delete(y),!(n!==p_||!ju||document.visibilityState==="hidden"))for(const b of g)g_(b)},p);_f.add(y)}}function iT(){for(const e of _f)window.clearTimeout(e);_f.clear()}function g_(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,ql(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<n5)return Promise.resolve("alive");Js(e,"reconnecting"),$a(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++h5).toString(36)}`;let o;const c=new Promise(m=>{o=m}),u={socket:t,nonce:r,timeout:0,promise:c,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(Ua("terminal.connection.resume_timeout",e,{pendingInputs:Oa(e)}),Js(e,"reconnecting"),Ba(e))},t5);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{Js(e,"reconnecting"),Ba(e)}return c}function b5(){ju=!1;for(const e of Rs.values())e.heartbeatSuspended=!0,Ka(e),Es(e),tr(e),Wa(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,Js(e,"skipped"),$a(e)}function y5(){La=!1,Lf()&&Or(0);for(const e of Rs.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ka(e),Es(e),tr(e),Wa(e),Js(e,"reconnecting"),$a(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ra(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ql(e)}}function jg(){for(const e of Array.from(Rs.keys()))cu(e)}function S5(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,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:vf,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments: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 ql(e){if(!e.reconnectEnabled)return;Ra(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Es(e),tr(e),Wa(e),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,Ka(e),Es(e),Ra(e,"connected"),Fa(e,t),nT(e,t),e.isAlive=!0,K1(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let c=null;try{c=JSON.parse(o)}catch{return}if(!c||typeof c.type!="string")return;if($5(c)){q5(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),La&&(La=!1,Lf()&&Or(0));return}if(e.inputProtocolMode==="unknown"&&aT(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),Oa(e)>0&&Ua("terminal.connection.resume_alive",e,{pendingInputs:Oa(e)}),Js(e,"alive"),Fa(e,t),K1(e),Bo(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(zu(e),Ua("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:Oa(e)}),Ba(e));return}if(c.type==="input_ack"){U5(e,t,c);return}if(c.type==="input_received"){F5(e,t,c);return}if(c.type==="error"&&K5(e,c),c.type==="input_ack_confirmed"){Y5(e,c);return}const u=C5(e,c);if(Iu(e,{type:"message",message:u}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;Bb(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Ka(e),Es(e),tr(e),Wa(e),Js(e,"reconnecting"),$a(e),r.code===1008){e.reconnectEnabled=!1,Ra(e,w5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=r5)&&(e.lastUpgradeAuthProbeAt=o,Iu(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Ra(e,"closed");return}Ra(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,ql(e)},e5)}}),t.addEventListener("error",()=>{})}function K1(e){if($a(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(),r=n-e.heartbeatTickAt>P1*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},P1)}function $a(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function w5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function C5(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,r)=>n+jr(r),0),W1(e),e.exited&&Yh(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=jr(t.data),W1(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Yh(e)),t):(t.type==="exit"&&(e.exited=!0,Yh(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function W1(e){for(;e.outputBytes>Ag&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=jr(t)}e.outputBytes>Ag&&e.output.length===1&&(e.output[0]=G5(e.output[0],Ag),e.outputBytes=jr(e.output[0]))}function Ra(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 Oa(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function x5(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function Ua(e,t,n={}){vn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:Oa(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??x5(t)}),f_+=1,Vh=0,Or(Qk)}function k5(){if(U1)return;U1=!0;const e=()=>{document.visibilityState==="hidden"||La||Lf()&&Or(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Or(e){if(qh){Su=Su===null?e:Math.min(Su,e);return}Bg!==null||La||document.visibilityState==="hidden"||navigator.onLine===!1||(Bg=window.setTimeout(()=>{Bg=null,T5()},e))}async function T5(){if(qh||La||document.visibilityState==="hidden"||navigator.onLine===!1)return;qh=!0;const e=f_;try{const t=await aR();if(t.outcome==="auth_blocked"){La=!0;return}if(t.outcome==="retryable"){const n=H1[Math.min(Vh,H1.length-1)];Vh+=1,Or(n);return}if(Vh=0,t.outcome==="sent"&&t.hasMore){Or(0);return}}finally{qh=!1;const t=Su;Su=null,t!==null&&Or(t),f_!==e&&!La&&Or(Qk)}}function E5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=P5(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=jr(o);if(c>a5)return"rejected";const u=n.durability!=="live-only",m={message:r,encoded:o,bytes:c,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:u};if(!H5(e,m))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(Ua("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:Oa(e)}),tT(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Wf))return!u&&r.type==="input"?"rejected":D5(e,r)?(p&&g&&Fa(e,g),"queued"):e.pendingOut.length>=d_||e.pendingOutBytes+c>h_?"rejected":(e.pendingOut.push(m),e.pendingOutBytes+=c,q1(e,m),p&&g&&Fa(e,g),"queued");if(p){q1(e,m);try{return g.send(o),rT(e,m),"sent"}catch{if(b&&u&&e.pendingOut.length<d_&&e.pendingOutBytes+c<=h_)return e.pendingOut.push(m),e.pendingOutBytes+=c,g.close(),"queued";zo(e,m),g.close()}}return"rejected"}function Fa(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Es(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Wf){X5(e,t),N5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){nT(e,t);return}try{t.send(r.encoded),rT(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=vf,n=!0}e.outboundFlushDelayMs=vf,Es(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&Iu(e,{type:"outbound_flushed"})})}function D5(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 r=null;if(t.type==="resize"&&n.message.type==="resize")r=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 u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=jr(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function Ka(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=vf}function Es(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function yf(e){return e.pendingOut.some(t=>t.message.type==="input")}function R5(e){return yf(e)||e.unackedInputs.size>0}function M5(e){if(!yf(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function N5(e,t){e.outboundStallWatchdog!==null||!yf(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!yf(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Wf;if(!n&&!r){Fa(e,t);return}M5(e),Ba(e)},u5))}function tr(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function nT(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&Ba(e)},l5))}function sT(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function zu(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function Wa(e){sT(e),zu(e)}function Bo(e){sT(e),v_(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=$1(e),r=A5(e),o=O5(e);if(n===null&&r===null&&o===null){zu(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+o5,u=Math.max(0,Math.min(c,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(v_(e,{notifyImmediately:!0})){Bo(e);return}if(L5(e),$1(e)===null){Bo(e);return}B5(e,t)},u)}function A5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+Zk;t=t===null?r:Math.min(t,r)}return t}function L5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<Zk||(n.writeSlowReported=!0,Ua("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function $1(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function O5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+Gk;t=t===null?r:Math.min(t,r)}return t}function B5(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Wf){Ba(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++f5).toString(36)}`;Ua("terminal.input.delivery_probe_started",e,{pendingInputs:Oa(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(Ua("terminal.input.delivery_probe_timeout",e,{pendingInputs:Oa(e)}),zu(e),Ba(e))},i5);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{zu(e),Ba(e)}}function Js(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Ba(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ka(e),Es(e),tr(e),Wa(e),Js(e,"reconnecting"),$a(e);const t=e.socket;e.socket=null,Ra(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ql(e)}function j5(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ka(e),Es(e),tr(e),Wa(e),Js(e,"skipped"),$a(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Yh(e),e.listeners.clear()}function I5(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function z5(){return Og=(Og+1)%Number.MAX_SAFE_INTEGER,`${m5}-${Og.toString(36)}`.slice(0,XC)}function P5(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=z5();return n.length===0||n.length>XC?null:{...t,messageId:n}}function H5(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<d_&&e.unackedInputBytes+t.bytes<=h_)}function q1(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function zo(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 U5(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&__(e,t,c);return}if(zo(e,r),Bo(e),!jb(e.inputProtocolMode)||!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),__(e,t,o)}function F5(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",Bo(e))}function K5(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(zo(e,n),Bo(e))}function rT(e,t){if(t.message.type!=="input"||!t.message.messageId||!jb(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",Bo(e)}function W5(e){if(v_(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){zo(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function v_(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=Gk&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&zo(e,u)}return o>0&&(lT(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&Bb(e)),!0}function $5(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function q5(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){aT(e,t);return}tr(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(W5(e),V5(e,t)):c!==null&&(oT(e),cT(e)),Fa(e,t)}function aT(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",tr(e),e.serverInstanceId=null,oT(e),cT(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;zo(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=jr(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}Fa(e,t)}}function oT(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&zo(e,o)}n>0&&lT(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function lT(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Bb(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 Yh(e){Ka(e),Es(e),tr(e),Wa(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function __(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!jb(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function jb(e){return e==="ack"||e==="receipt-ack"}function V5(e,t){for(const n of e.pendingAckReceipts.values())if(__(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function Y5(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function cT(e){e.pendingAckReceipts.clear()}function X5(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(c5,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Fa(e,t)},n)}function jr(e){return p5.encode(e).byteLength}function G5(e,t){if(jr(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);jr(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const Z5=[0,50,150,350],Q5=[100,300,750],J5=2,eB=[300,1200,2500],tB=1e3,iB=1e5,nB="",b_="\x1B[?1049l\x1B[?1047l\x1B[?47l",sB=new Set(["47","1047","1049"]),rB=400,aB=9,oB=9,lB=32,cB=1.42,uB=2,dB=24,hB=720,fB=60,pB=1260,mB=6,gB=2,V1=[500,1500,3e3,5e3,8e3],Y1=15e3,vB=2,_B=1e3,X1="Do not take action. Wait for my next input.",Sf=6e4,bB=Sf+5*6e4,G1=Sf+6e4,yB=40,Rh=240,SB=5e3,Cu=new Map,Cl=new Map;function Z1({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:m,onSelect:g,onClose:p,onExit:y,onSnapshot:b,onAuthClose:w}){const C=v.useSyncExternalStore(gx,pv,()=>To),S=v.useSyncExternalStore(vx,mv,()=>Bl),R=v.useSyncExternalStore(_x,vv,()=>!0),B=v.useSyncExternalStore(jh,_v,()=>!0),A=v.useSyncExternalStore(jh,bv,()=>!0),U=v.useSyncExternalStore(q_,ja,()=>Ol),Y=v.useSyncExternalStore(vu,()=>_u("history.toggle"),()=>"Alt+H"),K=v.useSyncExternalStore(vu,()=>_u("scrollback.toggle"),()=>"Alt+S"),se=v.useSyncExternalStore(vu,()=>_u("subagents.toggle"),()=>"Alt+A"),Q=v.useRef(null),z=v.useRef(null),_e=v.useRef(null),ie=v.useRef(null),ke=v.useRef(null),ne=v.useRef(e.id),X=v.useRef({onExit:y,onSnapshot:b}),G=v.useRef(t.createWebSocketUrl),q=v.useRef(w),oe=v.useRef(null),L=v.useRef(null),M=v.useRef(null),j=v.useRef(!1),re=v.useRef(new Map),ye=v.useRef(new Map),N=v.useRef(new Set),W=v.useRef([]),ue=v.useRef(!1),Ce=v.useRef(null),Le=v.useRef(0),Me=v.useRef(!1),Ne=v.useRef(!1),Oe=v.useRef(!1),Ve=v.useRef({terminalId:e.id,enabled:!1}),Ye=v.useRef([]),Be=v.useRef([]),le=v.useRef(0),E=v.useRef(!1),V=v.useRef(null),ge=v.useRef(0),Te=v.useRef(0),F=v.useRef(null),Se=v.useRef(null),xe=v.useRef(!1),he=v.useRef(!1),je=v.useRef(!1),Ie=v.useRef(null),He=v.useRef(!1),et=v.useRef(null),Mt=v.useRef(null),pt=v.useRef(!1),kt=v.useRef(!1),yt=v.useRef(!1),Qt=v.useRef(!1),ci=v.useRef(!1),de=v.useRef(!1),Ue=v.useRef(!1),tt=v.useRef(n),Ge=v.useRef(r),xt=v.useRef(c),ot=v.useRef(C),Hi=v.useRef(S),_i=v.useRef(!1),ee=v.useRef(!1),Pe=v.useRef(null),mt=v.useRef(0),lt=v.useRef(0),Dt=v.useRef(e.id),Nt=v.useRef(()=>{}),Wt=v.useRef(null),ui=v.useRef(null),$t=v.useRef(!1),zt=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),xi=v.useRef(0),Lt=v.useRef(null),un=v.useRef(0),qt=v.useRef(null),Ji=v.useRef(0),_n=v.useRef(!1),dn=v.useRef(!1),si=v.useRef(null),en=v.useRef(null),[,bi]=v.useState("connecting"),[ri,di]=v.useState(!1),[bn,Hr]=v.useState(null),[Yl,ir]=v.useState(!1),[Ur,Yn]=v.useState(null),[qa,Xn]=v.useState(!1),[Ns,Gn]=v.useState(!1),[As,Pt]=v.useState(!1),[Va,Fr]=v.useState(!1),[Vt,Zn]=v.useState(null),yn=e.agentCache&&Vt&&e.agentCache.source.provider===Vt.provider&&e.agentCache.source.sessionId===Vt.sessionId?e.agentCache:null,[Kr,Ya]=v.useState(()=>Date.now()),[gs,Ls]=v.useState(!1),[Wr,Sn]=v.useState(null),[Oi,Os]=v.useState(!1),[Xa,vs]=v.useState(!1),[hn,_s]=v.useState(null),[Xl,ki]=v.useState(!1),[$r,Dn]=v.useState(!1),[qr,nt]=v.useState(null),[nr,sr]=v.useState(null),tn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Uo,Vr]=v.useState(()=>og(e.id)),bs=Vt?.provider??e.agentStatus?.provider??null,rr=bs!==null||xl(e.currentCommand),Fo=bs==="claude"||pT(e.currentCommand),Gl=bs!==null||xl(e.currentCommand),ys=e.capabilities?.tmuxScrollback===!0,Ui=ys&&(Uo??(Gl?A:B)),[Ga,Ss]=v.useState(!1);v.useLayoutEffect(()=>{tt.current=n},[n]),v.useLayoutEffect(()=>{Ge.current=r},[r]),v.useLayoutEffect(()=>{xt.current=c},[c]),v.useLayoutEffect(()=>{ot.current=C},[C]),v.useLayoutEffect(()=>{Hi.current=S},[S]),v.useLayoutEffect(()=>{_i.current=Oi},[Oi]),v.useLayoutEffect(()=>{ee.current=Xa},[Xa]),v.useLayoutEffect(()=>{Pe.current=Vt},[Vt]);const ai=v.useCallback((k,I={})=>{!k&&I.preserveOnNull||(Th(Pe.current,k)||(lt.current+=1),Pe.current=k,Zn(Ee=>Ee&&k&&Ee.provider===k.provider&&Ee.sessionId===k.sessionId?Ee:k))},[]),Bs=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),fn=v.useCallback(()=>{const k=Pe.current,I=lt.current;k&&(async()=>{let Ee=k;try{Ee=await Bs()??Ee}catch{}Ee&&Dt.current===e.id&<.current===I&&Th(k,Pe.current)&&(ai(Ee,{preserveOnNull:!0}),Wt.current=Pg(e.id,Ee),vs(!1),Os(!0))})()},[ai,Bs,e.id]),js=v.useCallback(()=>{Pe.current&&(Os(!1),vs(!0))},[]),Rn=v.useCallback(async(k={})=>{const I=await J1(tn,t,k);return _s(I),I},[tn,t]),yi=v.useCallback((k,I="info")=>{qt.current!==null&&window.clearTimeout(qt.current),sr({id:un.current++,message:k,tone:I}),qt.current=window.setTimeout(()=>{sr(null),qt.current=null},3200)},[]),Yr=v.useCallback(()=>{const k=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Ee=m?.tabName.trim()||e.title||"Terminal",$e=hn?.instances.find(ut=>ut.cwd===e.cwd);if($e&&eC(Mh(k,$e.id))){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if($e&&Ig(Mh(k,$e.id),$e.url)){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ke=null;const it=()=>((!Ke||dT(Ke))&&(Ke=window.open("about:blank","_blank"),wB(Ke)),Ke);hn?.installed!==!0&&it(),Dn(!0),nt(null),(async()=>{let ut=hn;if(ut?.installed||(ut=await Rn({force:!0})),!ut?.installed||ut.supported===!1){zg(Ke),ki(!0);return}const ft=ut.instances.find(Ot=>Ot.cwd===e.cwd);if(ft){const Ot=Mh(k,ft.id);if(tC(Ke,Ot,ft.url)||Ig(Ot,ft.url)!==null){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const qe=it();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Ee}),targetPopup:qe}})().then(ut=>{if(!ut)return;const{response:ft,targetPopup:qe}=ut;y_(tn,ft.status),_s(ft.status);const Yt=Mh(k,ft.instance.id);if(eC(Yt)){zg(qe),yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}tC(qe,Yt,ft.url)||Ig(Yt,ft.url)?yi("Opening VS Code..."):yi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ut=>{zg(Ke),ki(!0),nt(Nh(ut))}).finally(()=>Dn(!1))},[m?.serverName,m?.tabName,tn,hn,Rn,t,yi,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return J1(tn,t).then(I=>{k||_s(I)}).catch(()=>{}),()=>{k=!0}},[tn,t]),v.useEffect(()=>{if(hn?.job?.status!=="running")return;const k=window.setInterval(()=>{Rn({force:!0}).catch(I=>nt(Nh(I)))},1e3);return()=>window.clearInterval(k)},[hn?.job?.status,Rn]),v.useEffect(()=>()=>{qt.current!==null&&window.clearTimeout(qt.current)},[]),v.useLayoutEffect(()=>{Nt.current=fn},[fn]),v.useLayoutEffect(()=>{ui.current=yn},[yn]),v.useLayoutEffect(()=>{$t.current=gs},[gs]),v.useLayoutEffect(()=>{_n.current=rr},[rr]),v.useLayoutEffect(()=>{dn.current=Fo},[Fo]),v.useLayoutEffect(()=>{const k=Ve.current;Ne.current=Ui,Oe.current=ys,Ve.current={terminalId:e.id,enabled:Ui},nC(Q.current,Ui),k.terminalId===e.id&&k.enabled&&!Ui&&to(),Ui||Pt(!1)},[e.id,Ui,ys]),v.useEffect(()=>{Vr(og(e.id)),Le.current=0,Me.current=!1,Pt(!1),eo()},[e.id]),v.useEffect(()=>jh(()=>{Vr(og(e.id))}),[e.id]),v.useEffect(()=>()=>{$o()},[]),v.useEffect(()=>{ke.current?.(r&&e.status==="running"),r&&e.status==="running"&&Ki()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&Cs("auto")},[n,r,e.status]),v.useEffect(()=>{X.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{G.current=t.createWebSocketUrl,q.current=w},[t,w]),v.useLayoutEffect(()=>{ne.current=e.id,Ue.current=!1,Fr(!1)},[e.id]),v.useEffect(()=>{let k=!1,I=null,Ee=0;const $e=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ke=$e||WB(e.currentCommand),it=$e||xl(e.currentCommand);function ut(){I!==null&&(window.clearTimeout(I),I=null)}function ft(Yt){if(k)return;let Ot;if(Yt)Ot=Y1;else if(Ee<V1.length){if(!Ke)return;Ot=V1[Ee++]}else{if(!it)return;Ot=Y1}I=window.setTimeout(()=>{I=null,qe()},Ot)}async function qe(){try{const Yt=Pe.current!==null,Ot=await Bs();if(k)return;if(Ot){mt.current=0,ai(Ot),ft(!0);return}mt.current+=1;const At=!!(Yt&&Ke&&mt.current<vB);ai(null,{preserveOnNull:At}),ft(At)}catch(Yt){if(k)return;Hg(Yt)&&ai(null),ft(!1)}}return Dt.current!==e.id&&(Dt.current=e.id,lt.current+=1,Pe.current=null,mt.current=0,Zn(null)),e.status!=="running"?(lt.current+=1,Pe.current=null,mt.current=0,Zn(null),()=>{k=!0,ut()}):(qe(),()=>{k=!0,ut()})},[ai,Bs,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=Pg(e.id,Vt),I=Wt.current;I!==null&&k!==null&&I!==k&&(Se.current=null,xe.current=!1,he.current=!1,_i.current&&Os(!1),vs(!1)),Wt.current=k},[e.id,Vt?.provider,Vt?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!Vt){Ls(!1);return}const k=window.setInterval(()=>{Ya(Date.now())},_B);return()=>{window.clearInterval(k)}},[e.status,Vt?.provider,Vt?.sessionId]),v.useEffect(()=>{const k=kB(yn);zt.current.key!==k&&(zt.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[yn?.expiresAt,yn?.source?.provider,yn?.source?.sessionId]),v.useEffect(()=>{if(!gs||!yn||yn.status!=="ready")return;const k=hT(yn,Kr);if(k===null||k<=0)return;const I=zt.current;!I.warnedFiveMinutes&&k<=bB&&k>G1&&(I.warnedFiveMinutes=!0,ts({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!I.warnedOneMinute&&k<=G1&&k>Sf&&(I.warnedOneMinute=!0,ts({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&k<=Sf&&oc()},[gs,Kr,yn,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(I){if(!tt.current||!Ge.current||I.isComposing||I.key==="Process"||DB(I.target))return;const Ee=wx(I);if(Ee?.id==="history.toggle"&&Pe.current){I.preventDefault(),I.stopPropagation(),_i.current?Os(!1):Nt.current();return}if(Ee?.id==="subagents.toggle"&&Pe.current){I.preventDefault(),I.stopPropagation(),ee.current?vs(!1):js();return}if(Ee?.id==="scrollback.toggle"&&Oe.current){I.preventDefault(),I.stopPropagation(),ac();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=z.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&bi("closed")},[e.status]),v.useEffect(()=>{const k=z.current;k&&(k.options.fontSize=C,ag(C,Hi.current).then(()=>{ot.current===C&&hi()}))},[C]),v.useEffect(()=>{const k=z.current;k&&(k.options.fontFamily=fv(S),ag(ot.current,S).then(()=>{Hi.current===S&&hi()}))},[S]),v.useEffect(()=>{const k=z.current;k&&(k.options.theme=Q1(U))},[U]),v.useEffect(()=>{const k=Q.current;if(!k)return;let I=!1,Ee=null,$e=null,Ke=null,it=null,ut=null,ft=null,qe=null;oe.current=null,ci.current=!1,de.current=!1,He.current=!1,Ju(),ed(),Mn(),ue.current=!1;const Yt=ot.current,Ot=Hi.current,At=new p3({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:fv(Ot),fontSize:Yt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:iB,theme:{...Q1(ja())}}),Us=new rN;return At.loadAddon(Us),it=XO(At),z.current=At,_e.current=Us,ag(Yt,Ot).then(()=>{if(I)return;At.open(k),nC(k,Ne.current),ci.current=!0,Ee=PO(At,{onPasteText:sp,onInterrupt:np,shouldInterruptPlainCtrlC:()=>dn.current}),Ge.current&&tt.current&&e.status==="running"&&Cs("auto"),hi(),ut=GB(k,At,()=>ot.current*1.2,Hs,Fs=>{ws(Fs)},Ja,cr,()=>Ne.current,Zr),ft=VB(k,At,Hs,Fs=>{ws(Fs)},Ja,cr,()=>Ne.current,Zr);const qo=new B3;$e=At.onData(Fs=>{if(Ue.current){const cc=W3(Fs);if(cc){no(!1),ur(cc);return}}const lc=qo.accept(Fs);lc&&ur(lc)}),Ke=At.onScroll(Fs=>{if(kt.current||Qt.current||yt.current){nn();return}Ql(),qn(At)&&lr({scrollToBottom:!0}),Hs(),!Ne.current&&Fs<=3&&ws()}),qe=new ResizeObserver(()=>{x()}),qe.observe(k),de.current&&(or(),de.current=!1,hi()),Wi()}),()=>{ld(ie.current,{updateUi:!1}),I=!0,ci.current=!1,de.current=!1,Ju(),ed(),L.current=null,M.current=null,j.current=!1,td(),ue.current=!1,id(),yt.current=!1,E.current=!1,ge.current+=1,Te.current+=1,V.current=null,si.current=null,en.current=null,je.current=!1,Ie.current=null,di(!1),ut?.(),ft?.(),qe?.disconnect(),Ee?.dispose(),$e?.dispose(),Ke?.dispose(),it?.dispose(),At.dispose(),z.current=null,_e.current=null}},[e.id]),v.useEffect(()=>{const k=G.current(e.id),I=g5(k,ar);return ie.current=I.send,ke.current=I.setForeground,I.setForeground(Ge.current&&e.status==="running"),bi(I.status),I.status==="connected"&&hi(),I.snapshot&&(X.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),z.current&&(hi(),Is(I.output,I.history),hi())),()=>{ld(I.send,{updateUi:!1}),I.setForeground(!1),I.detach(),ie.current=null,ke.current=null}},[e.id,e.status]);function ar(k){if(k.type==="status"){bi(k.status),k.status==="unauthorized"&&q.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(hi(),pn());return}if(k.type==="upgrade_rejected"){q.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){ue.current&&(ue.current=!1,Qr());return}Zl(k.message)}function Mn(k=[],I=null){Ye.current=[],Be.current=Ah(k),le.current=0,E.current=!1,V.current=null,yt.current=!1,ge.current+=1,F.current=I,Se.current=null,xe.current=!1,he.current=!1,je.current=!1,Ie.current=null,de.current=!1,si.current=null,en.current=null,et.current=null,pt.current=!1,di(!1),Hr(null),ir(!1),Yn(null),Xn(!1),Gn(!1)}function Is(k=[],I=null){if(yt.current||E.current){en.current={output:k,history:I,appendFromLiveOutputIndex:Be.current.length};return}Mn(k,I),Xr()}function zs(){if(yt.current||E.current)return!1;const k=en.current;if(!k)return!1;const I=Be.current.slice(k.appendFromLiveOutputIndex);return en.current=null,Mn([...k.output,...I],k.history),Xr(),!0}function Xr(){if(!z.current||!ci.current){de.current=!0;return}de.current=!1,or()}async function or(){const k=z.current;if(!k)return;const I=Lh(k,pt.current),Ee=I?Be.current.length:le.current,$e=await Ps(k,{liveOutputLimit:Ee,scrollToBottom:I});z.current===k&&(nn(),$e&&pn())}function Ps(k,I={}){return new Promise(Ee=>{yt.current=!0,E.current=!1;const $e=ge.current+1;ge.current=$e;const Ke=Math.max(0,Math.min(I.liveOutputLimit??Be.current.length,Be.current.length)),it=I.historyPages??Ye.current,ut=()=>z.current===k&&ge.current===$e,ft=()=>ut()&&(I.isCurrent?.()??!0),qe=()=>{ut()&&(yt.current=!1),Ee(!1)},Yt=()=>{if(!ft()){qe();return}try{le.current=Ke,I.scrollToBottom&&Wo(k)}finally{if(yt.current=!1,zs()){Ee(!1);return}const At=sd();At?lr(At):I.applyDeferredSnapshot!==!1&&ec(),Ee(!0)}},Ot=()=>{if(!ft()){qe();return}k.clear();const At=Ah([...it,...Be.current.slice(0,Ke)]);if(At.length===0){Yt();return}for(let Us=0;Us<At.length;Us+=1){const qo=At[Us];Us===At.length-1?k.write(qo,Yt):k.write(qo)}};if(k.buffer.active.type==="alternate"){k.write(b_,Ot);return}Ot()})}async function ws(k=0){const I=z.current;if(je.current||!I)return;if(Jl(I)){nn();return}const Ee=F.current,$e=Te.current,Ke=Symbol("history-load"),it=()=>z.current===I&&Te.current===$e;Ie.current=Ke,je.current=!0,di(!0);const ut=I.buffer.active.viewportY;try{let ft=!!(Ee&&!Ee.hasMore);if(!ft)try{const qe=await t.getTerminalHistory(e.id,{beforeLine:Ee?.startLine??0,...Ee?.snapshotHistorySize!==void 0?{snapshotHistorySize:Ee.snapshotHistorySize}:{},...Ee?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ee.snapshotHistoryLimit}:{},...Ee?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ee.snapshotHistoryToken}:{},...Ee?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ee.snapshotPaneWidth}:{},limit:tB});if(!it()||F.current!==Ee)return;const Yt=()=>it()&&F.current===Ee;if(qe.invalidated){es();return}const Ot=qe.hasMore&&qe.snapshotHistorySize!==void 0&&qe.snapshotPaneWidth!==void 0,At={startLine:qe.startLine,endLine:qe.endLine,hasMore:Ot,...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 Jn(I,qe.output,ut,k)&&Yt()&&(F.current=At);return}if(!Yt())return;F.current=At,ft=!Ot}catch(qe){ft=it()&&Hg(qe)}if(ft){if(!it()||Jl(I)){nn();return}await Fi(I,ut,k,it)}}catch{}finally{Ie.current===Ke&&(Ie.current=null,je.current=!1,di(!1))}}async function Fi(k,I,Ee,$e){if(!$e()||xe.current||he.current)return;const Ke=Pe.current,it=lt.current,ut=Se.current,ft=()=>$e()&<.current===it&&Th(Ke,Pe.current)&&Se.current===ut;try{const qe=await t.getTerminalTranscriptHistory(e.id,{...ut?{cursor:ut}:{},limit:rB}),Yt=qe.output.map(xk);if(!qe.source||qe.terminalId!==e.id||!ft())return;if(Ke&&!Mb(Ke,qe.source)){Se.current=null,xe.current=!1,he.current=!1,ai(qe.source);return}if(Yt.length===0){ai(qe.source),Se.current=qe.cursor,he.current=!qe.hasMore||!qe.cursor;return}await Jn(k,Yt,I,Ee,ft)&&ft()&&(ai(qe.source),Se.current=qe.cursor,he.current=!qe.hasMore||!qe.cursor)}catch(qe){ft()&&Hg(qe)&&(xe.current=!0)}}async function Jn(k,I,Ee,$e,Ke){if(Jl(k)||Ke&&!Ke())return nn(),!1;const it=Ye.current,ut=[...I,...it],ft=$B(I),qe=ge.current+1,Yt=await Ps(k,{liveOutputLimit:le.current,scrollToBottom:!1,historyPages:ut,applyDeferredSnapshot:!1,...Ke?{isCurrent:Ke}:{}}),Ot=Ke!==void 0&&!Ke();return!Yt||Ot||z.current!==k?(Ot&&z.current===k&&ge.current===qe&&await Ps(k,{liveOutputLimit:le.current,scrollToBottom:!1,historyPages:it,applyDeferredSnapshot:!1})&&z.current===k&&(tc(k,Ee),pt.current=!qn(k),Hs()),!1):(Ye.current=ut,tc(k,Math.max(0,Ee+ft+Math.min(0,$e))),pt.current=!qn(k),Hs(),!0)}v.useEffect(()=>{const k=window.visualViewport;function I(){document.visibilityState!=="hidden"&&Ki()}function Ee(){Ki()}function $e(){Ki()}function Ke(){x()}function it(){P()}return document.addEventListener("visibilitychange",I),window.addEventListener("pageshow",Ee),window.addEventListener("online",$e),window.addEventListener("resize",Ke),window.addEventListener(mf,it),k?.addEventListener("resize",Ke),k?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",I),window.removeEventListener("pageshow",Ee),window.removeEventListener("online",$e),window.removeEventListener("resize",Ke),window.removeEventListener(mf,it),k?.removeEventListener("resize",Ke),k?.removeEventListener("scroll",Ke)}},[e.id]);function Ki(){document.visibilityState==="hidden"||!Ge.current||(pn(),hi())}function es(){const k=G.current(e.id);Te.current+=1,He.current=!0,si.current=null,bi("reconnecting"),hi(),v5(k)}function Zl(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Te.current+=1,X.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Ee=He.current;He.current=!1;const $e=z.current;if(!$e)return;if(hi(),Ee){Za(k.output,k.history??null);return}if(Zf($e,k.terminal)){Jf(k.output,k.history??null),nn(),hi();return}Is(k.output,k.history??null),hi();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){X.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Ee=mT(k.data);if(!Ee)return;Be.current.push(Ee),z.current&&ci.current?lr({scrollToBottom:!0}):de.current=!0;return}const I=z.current;if(I){if(k.type==="exit"&&k.terminalId===e.id){X.current.onExit(k.exitCode),bi("closed");return}k.type==="error"&&I.writeln(`\r
|
|
52
|
+
[nterminal] ${k.message}`)}}function Za(k,I){Is(k,I),hi()}function Qa(k=25){if(document.visibilityState==="hidden"||!Ge.current||re.current.has(k))return;const I=window.setTimeout(()=>{re.current.delete(k),!D()&&ep()},k);re.current.set(k,I)}function x(){D()||Wi()}function D(){const k=pe();return k&&ae(k)?(j.current=!0,M.current=k,!0):k&&we(k)?(j.current=!1,M.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(j.current=!1,M.current=null),!1)}function P(){if(!j.current)return;const k=pe();k&&(k.composeOpen||k.keyboardVisible)||(j.current=!1,M.current=null)}function ae(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const I=L.current;return I?Zt(k.windowWidth,I.windowWidth)&&Zt(k.visualViewportWidth,I.visualViewportWidth)&&Zt(k.containerWidth,I.containerWidth):!1}function we(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const I=M.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:Zt(k.windowWidth,I.windowWidth)&&Zt(k.visualViewportWidth,I.visualViewportWidth)&&Zt(k.containerWidth,I.containerWidth)}function pe(){const k=Q.current;if(!k||k.isConnected===!1)return null;const I=k.getBoundingClientRect(),Ee=rt(window.innerWidth)??0,$e=rt(window.visualViewport?.width)??Ee,Ke=rt(I.width)??rt(k.clientWidth)??Ee;if(Ee<=0||$e<=0||Ke<=0)return null;const{keyboardVisible:it}=o_(),ut=document.documentElement.hasAttribute(Uf),ft=Re()||it;return{windowWidth:Ee,visualViewportWidth:$e,containerWidth:Ke,composeOpen:ut,keyboardVisible:it,mobileLike:ft}}function Re(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Ze(){return o_().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function rt(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function Zt(k,I){return Math.abs(k-I)<=J5}function Wi(){for(const k of Z5)Qa(k)}function hi(){oe.current=null,Wi()}function pn(){if(Ko(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{N.current.delete(k),Ko();const I=window.requestAnimationFrame(()=>{N.current.delete(I),Ko()});N.current.add(I)});N.current.add(k)}for(const k of Q5){if(ye.current.has(k))continue;const I=window.setTimeout(()=>{ye.current.delete(k),Ko()},k);ye.current.set(k,I)}}function Ko(){const k=z.current;if(!(!k||!ci.current||document.visibilityState==="hidden"||!Ge.current||Q.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function Ju(){for(const k of re.current.values())window.clearTimeout(k);re.current.clear()}function ed(){for(const k of ye.current.values())window.clearTimeout(k);ye.current.clear();for(const k of N.current)window.cancelAnimationFrame(k);N.current.clear()}function td(){for(const k of W.current)window.clearTimeout(k);W.current=[]}function Hs(){if(nn(),!et.current){ir(!1);return}ir(!0),id(),Mt.current=window.setTimeout(()=>{Mt.current=null,ir(!1)},1200)}function nn(){const k=z.current,I=k?qB(k):null;if(et.current=I,Hr(I),Gn(!!(k&&I)),Xn(!!(k&&I&&!qn(k))),I||!k||!Xf()){Yn(null);return}Yn({alternate:k.buffer.active.type==="alternate"})}function Xf(){const k=F.current;return Ye.current.length>0||!!k?.hasMore}function id(){Mt.current!==null&&(window.clearTimeout(Mt.current),Mt.current=null)}function Ql(){const k=z.current;k&&(pt.current=!qn(k),nn())}function nd(k){V.current=Ug(V.current,k)}function Gf(k){const I=V.current;return V.current=null,Ug(I,k)}function sd(){const k=V.current;return V.current=null,k}function lr(k={}){const I=z.current;if(!I||!ci.current){de.current=!0;return}if(si.current&&!yt.current&&!E.current&&qn(I)){ec();return}if(yt.current){nd(k);return}if(E.current){nd(k);return}const Ee=Gf(k);if(!Ee.force&&!Lh(I,pt.current)){nn();return}E.current=!0;const $e=ge.current,Ke=()=>{if(z.current!==I||ge.current!==$e)return;if(!Ee.force&&!Lh(I,pt.current)){if(E.current=!1,zs())return;nn();return}const it=le.current,ut=Be.current[it];if(ut===void 0){if(E.current=!1,zs())return;Ee.scrollToBottom&&Wo(I),nn();const ft=sd();ft?lr(Ug(Ee,ft)):ec();return}I.write(ut,()=>{z.current!==I||ge.current!==$e||(le.current=it+1,Ke())})};Ke()}function Jl(k){return si.current!==null||!qn(k)&&(Qf()||E.current||yt.current)}function Zf(k,I){return(I?.agentStatus?.provider==="codex"||I?.agentStatus?.provider==="claude"||_n.current||xl(I?.currentCommand))&&!qn(k)}function Qf(){return le.current<Be.current.length}function Jf(k,I){si.current={output:k,history:I,appendFromLiveOutputIndex:Be.current.length}}function ec(){const k=z.current,I=si.current;if(!k||!I||!qn(k)||E.current||yt.current)return;const Ee=Ah(I.output),$e=Ah(Be.current.slice(I.appendFromLiveOutputIndex));si.current=null,Is([...Ee,...$e],I.history),hi()}function Ja(){Qt.current=!0}function cr(){Ql(),Qt.current=!1;const k=z.current;k&&qn(k)&&lr({scrollToBottom:!0})}function Wo(k){ic(()=>sC(k))&&(pt.current=!1)}function tc(k,I){ic(()=>(k.scrollToLine(I),!0))}function ic(k){kt.current=!0;try{return k()}finally{kt.current=!1}}function rd(){const k=z.current;if(!k)return;const I=()=>{Ne.current&&(io(ie.current),Pt(!1)),sC(k),pt.current=!1,nn(),lr({force:!0,scrollToBottom:!0}),Cs("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(b_,I);return}I()}function nc(k){const I=z.current,Ee=Q.current;if(!I||!Ee)return;const $e=Ee.getBoundingClientRect();if($e.height<=0)return;const Ke=Math.max(0,Math.min(1,(k-$e.top)/$e.height)),it=Math.round(I.buffer.active.baseY*Ke);Ja();try{I.scrollToLine(it)}finally{cr()}pt.current=!qn(I),nn(),Hs(),it<=3&&ws()}function ad(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),nc(k.clientY)}function Gr(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),nc(k.clientY))}function ep(){const k=z.current,I=_e.current;if(!(!k||!I)&&!(document.visibilityState==="hidden"||!Ge.current||Q.current?.isConnected===!1))try{const Ee=Lh(k,pt.current),$e=pe();I.fit(),$e&&(L.current=$e),Ee&&Wo(k),k.refresh(0,Math.max(0,k.rows-1)),nn();const Ke={cols:k.cols,rows:k.rows},it=oe.current;if(it&&it.cols===Ke.cols&&it.rows===Ke.rows)return;sc({type:"resize",terminalId:e.id,cols:Ke.cols,rows:Ke.rows})&&(oe.current=Ke)}catch{}}function od(k,I){const Ee=ie.current;return Ee?Ee(k,I):"rejected"}function sc(k){return od(k)!=="rejected"}function eo(){Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null)}function rc(){eo();const k=Math.max(-Rh,Math.min(Rh,Le.current));if(Le.current=0,k===0)return!1;const I=sc({type:"scrollback_scroll",terminalId:e.id,lines:k});return I&&(Me.current=!0,k<0&&Pt(!0)),I}function Zr(k){if(!Ne.current||k===0)return;const I=Le.current+k;Le.current=Math.max(-Rh,Math.min(Rh,I)),Ce.current===null&&(Ce.current=window.setTimeout(()=>{Ce.current=null,rc()},yB))}function to(){io(ie.current)}function ld(k=ie.current,I={}){const Ee=Me.current;eo(),Le.current=0,Me.current=!1,I.updateUi!==!1&&Pt(!1),Ee&&k?.({type:"cancel_scrollback",terminalId:e.id})}function io(k){eo(),Le.current=0,Me.current=!1,Pt(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function ac(){if(!Oe.current)return;const k=!Ne.current;Vr(gM(ne.current,k)),ip()}function cd(){const k=!$t.current;$t.current=k,Ls(k),ts({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function $o(){Lt.current!==null&&(window.clearTimeout(Lt.current),Lt.current=null)}function ts(k,I={}){$o();const Ee=xi.current+1;xi.current=Ee,Sn({...k,id:Ee}),!I.sticky&&(Lt.current=window.setTimeout(()=>{Lt.current=null,Sn($e=>$e?.id===Ee?null:$e)},12e3))}function ud(){zt.current.skipped=!0,ts({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function dd(){$t.current=!1,Ls(!1),ts({tone:"skipped",message:"Cache keep-alive off"})}async function oc(){const k=zt.current;if(k.sent||k.skipped)return;const I=tp();if(k.sent=!0,I){ts({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}if(ur(`${X1}\r`,{userInitiated:!1})==="rejected"){ts({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}ts({tone:"success",message:"Cache keep-alive sent",detail:X1})}function tp(){const k=ui.current,I=Pe.current;return $t.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!I?"Transcript cache status is unavailable.":k.source.provider!==I.provider||k.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Oo(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Nl(e.id).text.trim()?"Compose has an unsent draft.":RB(Q.current)?"Pane input is focused.":Date.now()-Ji.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function ip(){const k=z.current;k&&(Wo(k),nn())}function ur(k,I={}){rc();const Ee=Me.current;lr({force:!0,scrollToBottom:!0});const $e=od({type:"input",terminalId:e.id,data:k,...Ee?{cancelScrollbackMode:!0}:{}},{durability:I.userInitiated===!1?"live-only":"durable"});return $e==="rejected"?(I.userInitiated!==!1&&yi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),$e):(I.userInitiated!==!1&&(Ji.current=Date.now()),Ee&&(Me.current=!1,Pt(!1)),KB(k)&&($e==="sent"?Qr():$e==="queued"&&(ue.current=!0)),$e)}function np(){Ue.current&&no(!1),ur(nB)}function sp(k){const I=Eg(k,{bracketedPasteMode:z.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&ur(I)}function wn(k,I){const Ee=z.current?.modes.bracketedPasteMode===!0,$e=bs==="codex"||bs==="claude"||xl(e.currentCommand),Ke=k.parts.map(it=>it.kind==="image"&&$e?Eg(it.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Eg(it.kind==="image"?it.path:it.value,{bracketedPasteMode:Ee,stripTrailingLineBreaks:!1})).join("");return Ke?ur(`${Ke}${_O(I)}`)!=="rejected":!1}function Qr(){!xt.current||!tt.current||(td(),W.current=eB.map(k=>{const I=window.setTimeout(()=>{W.current=W.current.filter(Ee=>Ee!==I),xt.current&&tt.current&&sc({type:"refresh_cwd",terminalId:e.id})},k);return I}))}function Cs(k="terminal-interaction"){_i.current||Ze()&&(k==="auto"||k==="scroll-action")||z.current?.focus()}const hd=v.useCallback(()=>{Os(!1)},[]),fd=v.useCallback(async()=>{const k=Pe.current,I=lt.current;try{const Ee=await t.getTerminalTranscriptSource(e.id);if(!Ee.source||Dt.current!==e.id||lt.current!==I||!Th(k,Pe.current))return;Se.current=null,xe.current=!1,he.current=!1,ai(Ee.source),Wt.current=Pg(e.id,Ee.source)}catch{}},[ai,t,e.id]);function pd(){Fr(k=>{const I=!k;return Ue.current=I,I}),Cs("input-action")}function no(k){Ue.current=k,Fr(k)}function rp(k){Ue.current&&no(!1),ur(K3(k)),Cs("input-action")}async function dr(k="install"){Dn(!0),nt(null);try{const I=k==="update"?await t.updateCodeServer():await t.installCodeServer();y_(tn,I.status),_s(I.status)}catch(I){nt(Nh(I))}finally{Dn(!1)}}return h.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Ui?"true":"false",onMouseDown:()=>{n||g()},children:[h.jsx(MB,{terminal:e,canClose:o,tabId:u,transcriptSource:Vt,transcriptShortcutLabel:Y,subagentsShortcutLabel:se,transcriptCacheStatus:yn,transcriptCacheNow:Kr,cacheKeepAliveEnabled:gs,codeServerAvailable:!0,codeServerInstallState:hn===null?"unknown":hn.installed?"installed":"missing",codeServerBusy:$r||hn?.job?.status==="running",codeServerSupported:hn?.supported!==!1,scrollbackShortcutLabel:K,tmuxScrollbackSupported:ys,tmuxScrollbackEnabled:Ui,onToggleCacheKeepAlive:cd,onOpenCodeServer:Yr,onToggleTmuxScrollback:ac,onOpenTranscript:fn,onOpenSubagents:js,onReload:es,onClose:p}),h.jsx("div",{className:"xterm-container",ref:Q}),ri?h.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:h.jsx("span",{"aria-hidden":"true"})}):null,R&&!Ui&&bn?h.jsxs("div",{className:"terminal-scroll-progress","data-active":Yl,"aria-hidden":"true",children:[bn.current,"/",bn.total]}):R&&!Ui&&Ur?h.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ur.alternate?"alternate":"normal","aria-hidden":"true",children:[Ur.alternate?"alt ":"","0/?"]}):null,qa||Ui&&As?h.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),rd()},children:"↓"}):null,Ns&&!Ui?h.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:ad,onPointerMove:Gr,children:h.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Ga?h.jsx(U3,{ctrlActive:Va,onCtrl:pd,onStandaloneKey:rp,onPreserveFocus:()=>Cs("input-action"),onHide:()=>Ss(!1)}):h.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),Cs("input-action")},onPointerDown:k=>{k.stopPropagation(),Cs("input-action")},onClick:()=>Ss(!0),children:"⌨"}):null,h.jsx(DO,{terminalId:e.id,onSubmit:wn,onUploadAttachments:(k,I)=>t.uploadComposeAttachments({terminalId:e.id,files:k,signal:I.signal,onProgress:I.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:k=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:k})}:{},queueAvailable:bs==="codex"||fT(e.currentCommand),disabled:e.status!=="running"}),h.jsx(OB,{toast:Wr,onSendNow:()=>{oc()},onSkipOnce:ud,onTurnOff:dd,onDismiss:()=>Sn(null)}),Oi&&Vt?h.jsx(BB,{terminalId:e.id,serverApi:t,source:Vt,fontSize:C,onClose:hd,onReloadLatest:fd}):null,Xa&&Vt?h.jsx(E3,{terminalId:e.id,serverApi:t,source:Vt,fontSize:C,onClose:()=>vs(!1)}):null,nr?h.jsx(AB,{notice:nr}):null,Xl?h.jsx(NB,{status:hn,busy:$r,error:qr,onInstall:()=>{dr("install")},onUpdate:()=>{dr("update")},onOpen:Yr,onRefresh:()=>{Rn({checkLatest:!0}).catch(k=>nt(Nh(k)))},onClose:()=>ki(!1)}):null]})}function Q1(e){return _2(e)}async function J1(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=Cl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=SB)return u.status;if(u?.inflight&&(!r||u.inflightCheckLatest))return u.inflight;let m;return m=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(y_(e,g),g)).catch(g=>{const p=Cl.get(e);throw p?.inflight===m&&(p.status?Cl.set(e,{status:p.status,fetchedAt:p.fetchedAt}):Cl.delete(e)),g}),Cl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:r}),m}function y_(e,t){Cl.set(e,{status:t,fetchedAt:Date.now()})}function Mh(e,t){return`${e}:${t}`}function uT(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function eC(e){const t=Cu.get(e);if(!t)return!1;try{return t.closed?(Cu.delete(e),!1):(t.focus(),!0)}catch{return Cu.delete(e),!1}}function Ig(e,t){const n=window.open(t,uT(e));if(!n)return null;Cu.set(e,n);try{n.focus()}catch{}return n}function tC(e,t,n){if(!e||dT(e))return!1;try{return e.name=uT(t),e.location.href=n,Cu.set(t,e),e.focus(),!0}catch{return!1}}function wB(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 dT(e){if(!e)return!0;try{return e.closed}catch{return!0}}function zg(e){if(e)try{e.closed||e.close()}catch{}}function CB(e,t,n){const r=xB(e,t),o=iC(r*Math.max(1,n),fB,pB);return{limit:iC(Math.ceil(o/uB),dB,hB),maxLines:o}}function xB(e,t){const n=e?.clientHeight??0;if(n<=0)return lB;const r=Math.max(10,t*cB);return Math.max(1,Math.floor(n/r))}function iC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function kB(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Pg(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function hT(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 TB(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function EB(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 r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),u=r%24;return u>0?`${c}d ${u}h`:`${c}d`}function DB(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Nh(e){return e instanceof kn||e instanceof Error?e.message:"Something went wrong."}function RB(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function MB({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:m,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:y,codeServerBusy:b,codeServerSupported:w,scrollbackShortcutLabel:C,tmuxScrollbackSupported:S,tmuxScrollbackEnabled:R,onToggleCacheKeepAlive:B,onOpenCodeServer:A,onToggleTmuxScrollback:U,onOpenTranscript:Y,onOpenSubagents:K,onReload:se,onClose:Q}){const z=$C({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),_e={cursor:n?"grab":"default",opacity:z.isDragging?.5:void 0};return h.jsxs("header",{ref:z.setNodeRef,className:"terminal-pane-header",style:_e,"data-dragging":z.isDragging,...z.attributes,...z.listeners,children:[h.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),h.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),h.jsx("span",{className:"terminal-pane-spacer"}),p?h.jsx("button",{type:"button",className:"terminal-pane-code","data-state":y,"data-busy":b?"true":"false",disabled:!w||b,title:y==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":y==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),A()},children:h.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?h.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${Oo(r.provider)} transcript history`,"aria-label":`View ${Oo(r.provider)} transcript history`,onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),Y()},children:[h.jsx("span",{className:"pane-button-label-full",children:"View history"}),h.jsx("span",{className:"pane-button-label-short",children:"History"}),h.jsx("kbd",{children:o})]}):null,r?h.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),K()},children:[h.jsx("span",{className:"pane-button-label-full",children:"View agents"}),h.jsx("span",{className:"pane-button-label-short",children:"Agents"}),h.jsx("kbd",{children:c})]}):null,r?h.jsx(LB,{status:u,now:m,keepAliveEnabled:g,onToggle:B}):null,e.status==="exited"?h.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,S&&e.status==="running"?h.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":R?"true":"false","aria-pressed":R,"aria-label":`Toggle tmux scrollback (${C})`,title:R?`Scroll input uses tmux scrollback (${C}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${C}).`,onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),U()},children:[R?h.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.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"}),h.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"})]}):h.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.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"}),h.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),h.jsx("kbd",{children:C})]}):null,e.status==="running"?h.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),se()},children:"↻"}):null,t?h.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),Q()},children:"x"}):null]})}function NB({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:m}){const g=e?.job??null,p=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,w=e===null&&t,C=e?.updateAvailable===!0,S=y?"VS Code add-on":"Install VS Code add-on";return h.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":S,onClick:m,children:h.jsxs("section",{className:"security-panel code-server-dialog",onClick:R=>R.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{children:[h.jsx("h2",{children:S}),h.jsx("p",{children:w?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),h.jsxs("div",{className:"code-server-dialog-scroll",children:[h.jsxs("div",{className:"code-server-dialog-body",children:[h.jsxs("p",{children:["NTerminal installs code-server under ",h.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?h.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:h.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?h.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?h.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[h.jsxs("div",{className:"code-server-progress-heading",children:[h.jsx("span",{children:g.action}),h.jsx("strong",{children:g.status})]}),h.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
53
|
+
`):"Preparing..."})]}):null]}),h.jsxs("div",{className:"code-server-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!b,children:"Check"}),y?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:C?"Update":"Reinstall"}),h.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):h.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function AB({notice:e}){return h.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function LB({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=hT(e,t),c=TB(e,o),u=o===null?"?":EB(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 h.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(),r()},children:[h.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),h.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),h.jsx("span",{children:u})]})}function OB({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return h.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[h.jsxs("header",{children:[h.jsx("strong",{children:e.message}),h.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?h.jsx("p",{children:e.detail}):null,c?h.jsxs("div",{className:"cache-keepalive-toast-actions",children:[h.jsx("button",{type:"button",onClick:t,children:"Send now"}),h.jsx("button",{type:"button",onClick:n,children:"Skip once"}),h.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const BB=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const m=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),w=v.useRef(""),C=v.useRef(null),S=v.useRef(null),[R,B]=v.useState([]),[A,U]=v.useState(!1),[Y,K]=v.useState(""),[se,Q]=v.useState(-1),[z,_e]=v.useState(!1),[ie,ke]=v.useState(-1),[ne,X]=v.useState(null),[G,q]=v.useState(null),[oe,L]=v.useState(!1),[M,j]=v.useState(!0),[re,ye]=v.useState(!1),[N,W]=v.useState(null),[ue,Ce]=v.useState(!1);v.useEffect(()=>{function de(Ue){Ue.key==="Escape"&&(Ue.preventDefault(),Ue.stopPropagation(),c())}return document.addEventListener("keydown",de,!0),()=>document.removeEventListener("keydown",de,!0)},[c]),v.useEffect(()=>{g.current+=1;const de=g.current;return p.current=!1,y.current=!0,b.current=null,C.current=null,S.current=null,B([]),q(null),L(!1),W(null),Ce(!1),Q(-1),ke(-1),X(null),He(null,"initial",de),()=>{g.current===de&&(g.current+=1)}},[n,A,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const de=m.current;if(!de)return;if(y.current){if(M||R.length===0)return;y.current=!1;const tt=()=>{de.scrollTop=de.scrollHeight};tt(),window.requestAnimationFrame?.(tt);return}const Ue=b.current;Ue!==null&&(b.current=null,de.scrollTop+=de.scrollHeight-Ue)},[R,M,A]);const Le=Oo(r.provider),Me=hf(R,A),Ne=Ck(Me),Oe=jB(Ne),Ve=Oe.map(de=>de.key).join(""),Ye=ne?Oe.find(de=>de.key===ne)?.entryIndex??null:null,Be=Y.trim().length>0,le=b3(Ne,Y),E=le.length,V=E>0?se>=0&&se<E?se:0:-1,ge=V>=0?le[V]?.entryIndex??null:null,Te=V>=0?le[V]??null:null,F=Be?ge:Ye,Se=Be?ge===null?null:"search":Ye===null?null:"prompt",xe=Me?Me.split(`
|
|
54
|
+
`).length-1:0,he=Oe.length>0&&ie>=0&&ie<Oe.length?ie:Oe.length-1,je=ne??(he>=0?Oe[he]?.key??null:null),Ie=Be?E>0?`${V+1}/${E} ${E===1?"match":"matches"} · ${xe} ${xe===1?"line":"lines"}`:`0 matches · ${xe} ${xe===1?"line":"lines"}`:Oe.length>0?`${he+1}/${Oe.length} prompts · ${xe} ${xe===1?"line":"lines"}`:`0 prompts · ${xe} ${xe===1?"line":"lines"}`;v.useEffect(()=>{const de=Y.trim().toLowerCase();Q(Ue=>!de||E===0?-1:w.current!==de?0:Ue>=0&&Ue<E?Ue:0),w.current=de},[Y,E]),v.useEffect(()=>{if(Be){X(null);return}ne&&!Oe.some(de=>de.key===ne)&&X(null),ke(de=>{if(Oe.length===0)return S.current=null,-1;const Ue=S.current?Oe.findIndex(Ge=>Ge.key===S.current):-1,tt=Ue>=0?Ue:de>=0&&de<Oe.length?de:Oe.length-1;return S.current=Oe[tt]?.key??null,tt})},[ne,Be,Ve]),v.useEffect(()=>{const de=C.current;if(!de||Oe.length===0)return;C.current=null;const Ue=de.anchorKey?Oe.findIndex(Ge=>Ge.key===de.anchorKey):-1,tt=Ue>0?Ue-1:0;yt(tt)},[Ve]);async function He(de,Ue,tt=g.current){if(!p.current){p.current=!0,Ue==="initial"?j(!0):(ye(!0),b.current=m.current?.scrollHeight??null),W(null);try{await et(de,Ue,tt)}catch(Ge){if(g.current!==tt)return;W(Ge instanceof Error?Ge.message:"Failed to load transcript history.")}finally{g.current===tt&&(p.current=!1,j(!1),ye(!1))}}}async function et(de,Ue,tt){let Ge=de,xt=0,ot=[];const Hi=Ue==="initial"&&r.provider!=="claude"?gB:mB;for(;g.current===tt;){const _i=await n.getTerminalTranscriptHistory(t,{...Ge?{cursor:Ge}:{},...CB(m.current,o,Ue==="initial"?aB:oB),includeTools:A});if(g.current!==tt)return;if(!_i.source){W("Transcript source is temporarily unavailable.");return}if(!Mb(r,_i.source)){Ce(!0),L(!1);return}const ee=a_(_i.output,r.provider,{includeTools:A}),Pe=Mt(_i,Ue,ot,ee);if(ee&&(ot=[ee,...ot],Pe))return;if(!_i.hasMore||!_i.cursor||xt>=Hi){ot.length>0&&B(mt=>Ue==="older"?[...ot,...mt]:ot);return}Ge=_i.cursor,xt+=1}}function Mt(de,Ue,tt,Ge=a_(de.output,r.provider,{includeTools:A})){if(q(de.cursor),L(!!(de.hasMore&&de.cursor)),!Ge)return!1;const xt=[Ge,...tt];return hf(xt,A)?(B(ot=>Ue==="older"?[...xt,...ot]:xt),!0):!1}function pt(){const de=m.current;de&&(ci(),!(de.scrollTop>72||!oe||!G||p.current)&&He(G,"older"))}function kt(de){E!==0&&Q(Ue=>{const tt=V>=0?V:de>0?-1:0;return((Ue>=0&&Ue<E?Ue:tt)+de+E)%E})}function yt(de){const Ue=Oe[de];Ue&&(S.current=Ue.key,ke(de),X(Ue.key))}async function Qt(de){if(Oe.length===0){de<0&&oe&&G&&!p.current&&(C.current={anchorKey:null},await He(G,"older"));return}const tt=(ie>=0&&ie<Oe.length?ie:de<0?Oe.length-1:-1)+de;if(tt>=0&&tt<Oe.length){yt(tt);return}de<0&&tt<0&&oe&&G&&!p.current&&(C.current={anchorKey:Oe[0]?.key??null},await He(G,"older"))}function ci(){if(Be)return;const de=m.current;if(!de)return;const tt=de.getBoundingClientRect().top+Math.min(140,Math.max(48,de.clientHeight*.28));let Ge=null;for(const xt of UB(de)){const ot=FB(xt);if(ot!==null)if(xt.getBoundingClientRect().top<=tt)Ge=ot;else break}if(Ge!==null){const xt=Oe[Ge]?.key??null;S.current=xt,ke(Ge),ne&&ne!==xt&&X(null)}}return h.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:de=>de.stopPropagation(),onMouseDown:de=>de.stopPropagation(),onClick:de=>{de.stopPropagation(),c()},children:h.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:de=>de.stopPropagation(),onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"transcript-dialog-title",children:[h.jsxs("h2",{id:"transcript-dialog-title",children:[Le," JSONL"]}),h.jsx("span",{title:r.sessionId,children:r.sessionId})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),h.jsxs("div",{className:"transcript-dialog-controls",children:[h.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[h.jsx("input",{type:"checkbox",checked:A,onChange:de=>U(de.currentTarget.checked)}),"Show tool output"]}),h.jsx("label",{className:"transcript-search",children:h.jsx("input",{type:"search",value:Y,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:de=>K(de.currentTarget.value),onKeyDown:de=>{de.key==="Enter"&&(de.preventDefault(),Be?kt(de.shiftKey?-1:1):Qt(de.shiftKey?-1:1))}})}),h.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":z,"aria-label":"Toggle prompt list",onClick:()=>_e(de=>!de),disabled:Oe.length===0,children:"List"}),h.jsxs("div",{className:"transcript-search-actions","aria-label":Be?"Search result navigation":"Prompt navigation",children:[h.jsx("button",{type:"button",onClick:()=>Be?kt(-1):void Qt(-1),disabled:Be?E===0:Oe.length===0&&!oe,"aria-label":Be?"Previous search match":"Previous user prompt",title:Be?"Previous search match":"Previous user prompt",children:"Prev"}),h.jsx("button",{type:"button",onClick:()=>Be?kt(1):void Qt(1),disabled:Be?E===0:Oe.length===0,"aria-label":Be?"Next search match":"Next user prompt",title:Be?"Next search match":"Next user prompt",children:"Next"})]}),h.jsx("span",{className:"transcript-result-count",children:Ie})]}),z?h.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Oe.length>0?Oe.map((de,Ue)=>h.jsxs("button",{type:"button",className:je===de.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>yt(Ue),children:[h.jsx("span",{children:de.timestampLabel}),h.jsx("strong",{children:de.snippet})]},`${de.key}:${Ue}`)):h.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,h.jsxs("div",{ref:m,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:pt,children:[re?h.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!M&&oe?h.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Me?h.jsx(Sk,{entries:Ne,searchQuery:Y,activeEntryIndex:F,activeEntryMode:Se,activeSearchMatch:Te,fontSize:o}):null,M?h.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,ue?h.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",h.jsx("button",{type:"button",onClick:()=>{u()},children:"Load current session"})]}):null,!ue&&!M&&!Me&&!N?oe&&G?h.jsxs("div",{className:"transcript-dialog-status",children:[A?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",h.jsx("button",{type:"button",onClick:()=>{He(G,"older")},disabled:re,children:"Search earlier entries"})]}):h.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,N?h.jsx("div",{className:"transcript-dialog-error",children:N}):null]})]})})});function jB(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:IB(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=n.get(c.contentKey)??0;n.set(c.contentKey,u+1),r.set(o,JSON.stringify([c.contentKey,u]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:PB(o.entry.body),timestampLabel:HB(o.entry.header)}))}function IB(e){return JSON.stringify([e.header??"",e.body.length,zB(e.body)])}function zB(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 PB(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function HB(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function UB(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function FB(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 KB(e){return e.includes("\r")||e.includes(`
|
|
55
|
+
`)}function Hg(e){return e instanceof kn&&e.status===404}function xl(e){return fT(e)||pT(e)}function fT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function pT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function WB(e){if(xl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function $B(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Ah(e){const t=[];for(const n of e){const r=mT(n);r&&t.push(r)}return t}function mT(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!sB.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function Ug(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function qB(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 nC(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 qn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Lh(e,t){return!t||qn(e)}function sC(e){return qn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function VB(e,t,n,r,o,c,u,m){const g=p=>{const y=XB(p);if(y!==0){if(u()){if(QB(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),m(y);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),YB(t,y,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function YB(e,t,n,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(b_,u);return}u()}function XB(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 r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function GB(e,t,n,r,o,c,u,m,g){let p=null,y=0;const b={passive:!1};function w(R){p=Fg(R),y=0}function C(R){const B=Fg(R);if(B===null){p=null,y=0;return}if(p===null){p=B;return}const A=B.clientY-p.clientY;if(p=B,R.cancelable&&R.preventDefault(),A===0)return;if(ZB(t)&&JB(t,B,-A)){y=0;return}y-=A/n();const U=y<0?Math.ceil(y):Math.floor(y);if(U!==0){if(y-=U,m()){g(U);return}c();try{t.scrollLines(U)}finally{u()}r(),U<0&&t.buffer.active.viewportY<=3&&o(U)}}function S(R){if(R.touches.length>0){p=Fg(R);return}p=null,y=0}return e.addEventListener("touchstart",w,b),e.addEventListener("touchmove",C,b),e.addEventListener("touchend",S),e.addEventListener("touchcancel",S),()=>{e.removeEventListener("touchstart",w,b),e.removeEventListener("touchmove",C,b),e.removeEventListener("touchend",S),e.removeEventListener("touchcancel",S)}}function Fg(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function ZB(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function QB(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function JB(e,t,n){const r=e.element;return r?(r.dispatchEvent(e4(t,n)),!0):!1}function e4(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function S_({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:m,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:w=[],totalPanes:C,onSelect:S,onClose:R,onResize:B,onExit:A,onSnapshot:U,onCloseEditor:Y,onAuthClose:K}){const se=C??w_(e);if(w.length===0&&b){const ie=C_(e),ke=ie.some(ne=>ne.key===b)?b:ie[0]?.key;if(ie.length>1&&ke)return h.jsx("div",{className:"mobile-focused-split",children:ie.map(ne=>{const X=ne.key===ke;if(ne.type==="editor"){const q=n[ne.editorId];return h.jsx("div",{className:"mobile-focused-pane","data-active":X,"aria-hidden":!X,children:q?h.jsx(Aw,{api:r,editor:q,canClose:se>1,onClose:()=>Y(ne.editorId)}):h.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ne.key)}const G=t[ne.terminalId];return G?h.jsx("div",{className:"mobile-focused-pane","data-active":X,"aria-hidden":!X,children:h.jsx(Z1,{terminal:G,serverApi:r,active:X,visible:c&&X,canClose:se>1,refreshCwdOnEnter:u&&X,tabId:m,codeServerContext:g,onSelect:()=>S(ne.terminalId),onClose:()=>R(ne.terminalId),onExit:q=>A(ne.terminalId,q),onSnapshot:U,...K?{onAuthClose:K}:{}})},ne.key):h.jsx("div",{className:"mobile-focused-pane","data-active":X,"aria-hidden":!X,children:h.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ne.key)})})}if(e.type==="pane"){const ie=t[e.terminalId];if(!ie)return h.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ke=h.jsx(Z1,{terminal:ie,serverApi:r,active:e.terminalId===o,visible:c,canClose:se>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>S(e.terminalId),onClose:()=>R(e.terminalId),onExit:X=>A(e.terminalId,X),onSnapshot:U,...K?{onAuthClose:K}:{}});return p&&y!==e.terminalId?h.jsxs("div",{className:"pane-drop-host",children:[ke,h.jsx(Oh,{terminalId:e.terminalId,side:"top"}),h.jsx(Oh,{terminalId:e.terminalId,side:"right"}),h.jsx(Oh,{terminalId:e.terminalId,side:"bottom"}),h.jsx(Oh,{terminalId:e.terminalId,side:"left"})]}):ke}if(e.type==="editor"){const ie=n[e.editorId];return ie?h.jsx(Aw,{api:r,editor:ie,canClose:se>1,onClose:()=>Y(e.editorId)}):h.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const Q=Math.max(.1,Math.min(.9,e.ratio)),z=1-Q,_e=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${Q}fr) 1px minmax(0, ${z}fr)`}:{gridTemplateRows:`minmax(0, ${Q}fr) 1px minmax(0, ${z}fr)`};return h.jsxs("div",{className:"split-pane","data-direction":e.direction,style:_e,children:[h.jsx("div",{className:"split-cell",children:h.jsx(S_,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,0],totalPanes:se,onSelect:S,onClose:R,onResize:B,onExit:A,onSnapshot:U,onCloseEditor:Y,...K?{onAuthClose:K}:{}})}),h.jsx(t4,{direction:e.direction,path:w,onResize:B}),h.jsx("div",{className:"split-cell",children:h.jsx(S_,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,1],totalPanes:se,onSelect:S,onClose:R,onResize:B,onExit:A,onSnapshot:U,onCloseEditor:Y,...K?{onAuthClose:K}:{}})})]})}function Oh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=J_({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return h.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function t4({direction:e,path:t,onResize:n}){function r(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 u=c.parentElement;if(!u)return;const m=u.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 p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return h.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:h.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function w_(e){return e.type==="pane"||e.type==="editor"?1:w_(e.first)+w_(e.second)}function C_(e){return e.type==="pane"?[{key:i4(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:n4(e.editorId),type:"editor",editorId:e.editorId}]:[...C_(e.first),...C_(e.second)]}function i4(e){return`terminal:${e}`}function n4(e){return`editor:${e}`}const $f="workspace-default",s4="NTerminal";function r4(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function a4(e,t){switch(t.type){case"workspace.hydrated":return x_(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return o4(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return d4(e,t.workspaceId);case"workspace.selected":return gT(e,t.workspaceId);case"workspace.renamed":return l4(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return c4(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return u4(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return vT(e,t.terminal);case"terminal.split":return h4(e,t.terminal,t.direction);case"terminal.updated":return C4(e,t.terminal);case"terminal.exited":return x4(e,t.terminalId,t.exitCode);case"terminal.closed":return yT(e,t.terminalId);case"terminal.detached":return k4(e,t.terminalId,t.workspaceId);case"editor.split":return f4(e,t.editorId,t.title,t.direction);case"editor.closed":return T4(e,t.editorId);case"pane.selected":return S4(e,t.terminalId);case"pane.resized":return w4(e,t.path,t.ratio);case"tab.selected":return m4(e,t.tabId);case"tab.renamed":return y4(e,t.tabId,t.title);case"tab.reordered":return Ib(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return g4(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return _T(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return bT(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return v4(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return p4(e);default:return e}}function o4(e,t){if(e.workspaces.some(r=>r.id===t.id))return gT(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Ms(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function gT(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function l4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.title===r?u:(o=!0,{...u,title:r}));return o?{...e,workspaces:c}:e}function c4(e,t,n){const r=Ms(n);let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.defaultCwd===r?u:(o=!0,{...u,defaultCwd:r}));return o?{...e,workspaces:c}:e}function u4(e,t,n,r){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 u=e.workspaces.slice(),[m]=u.splice(o,1);if(!m)return e;const g=u.findIndex(b=>b.id===n);if(g<0)return e;const p=r==="before"?g:g+1,y=u.slice();return y.splice(p,0,m),b4(e.workspaces,y)?e:{...e,workspaces:y}}function d4(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),r=new Set(n?wf(n):[]),o={...e.terminals};for(const m of r)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),u=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:u,terminals:o}}function vT(e,t){const n=wT(e),r=Po(n)??Vf(),o=ET(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Ms(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:TT(c,t.id))}}function h4(e,t,n){const r=Po(e),o=r?qf(r):void 0;if(!r||!o)return vT(e,t);const c=o.activeTerminalId,u=Hu(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===r.id?{...m,defaultCwd:m.defaultCwd??Ms(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:TT(m,t.id))}}function f4(e,t,n,r){const o=Po(e),c=o?qf(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,m=Hu(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:m,activeTerminalId:u}:p)}:g)}}function p4(e){const t=Po(e),n=t?qf(t):void 0;return n?yT(e,n.activeTerminalId):e}function m4(e,t){const n=Po(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function Ib(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const u=o.tabs.slice(),[m]=u.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(u.length,n)),p=u.slice();return p.splice(g,0,m),_4(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function g4(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(S=>S.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=zl(y.root,n);if(!b){const S=g.tabs.filter((R,B)=>B!==p);return{...g,tabs:S}}const w={...y,root:b,activeTerminalId:Li(b)[0]??y.activeTerminalId},C=g.tabs.slice();return C[p]=w,{...g,tabs:C}});const u=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(R=>Li(R.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:n},w={type:"split",direction:u,ratio:.5,first:m?b:{type:"pane",terminalId:r},second:m?{type:"pane",terminalId:r}:b},C=Hu(y.root,r,w),S=g.tabs.slice();return S[p]={...y,root:C,activeTerminalId:n},{...g,tabs:S,activeTabId:y.id}}),wT({...e,workspaces:c})}function _T(e,t,n,r){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const A=e.workspaces[B].tabs.findIndex(U=>U.id===t);if(A>=0){o=B,c=A;break}}if(o<0)return e;const u=e.workspaces[o],m=u.tabs[c],g=Li(m.root);if(!g.includes(n))return e;if(g.length===1)return Ib(e,t,r);const p=zl(m.root,n);if(!p)return e;const y={...m,root:p,activeTerminalId:Li(p)[0]??m.activeTerminalId},b=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},C=u.tabs.slice();C[c]=y;const S=Math.max(0,Math.min(C.length,r));C.splice(S,0,w);const R=e.workspaces.slice();return R[o]={...u,tabs:C,activeTabId:w.id},{...e,workspaces:R}}function bT(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=CT(e.workspaces,t),c=e.workspaces.find(p=>p.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:Ib(e,t,r);const u=Li(o.tab.root),m=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Ho({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===n){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??Ms(m?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!u.includes(w)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function v4(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(C=>C.id===r),u=CT(e.workspaces,t);if(!c||!u||!e.terminals[n]||!Li(u.tab.root).includes(n))return e;if(u.workspace.id===r)return _T(e,t,n,o);if(Li(u.tab.root).length===1)return bT(e,t,r,o);const g=zl(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:Li(g)[0]??u.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}},w=e.workspaces.map(C=>{if(C.id===u.workspace.id)return Ho({...C,tabs:C.tabs.map(S=>S.id===t?p:S)});if(C.id===r){const S=C.tabs.slice(),R=Math.max(0,Math.min(S.length,o));return S.splice(R,0,b),{...C,defaultCwd:C.defaultCwd??Ms(y.cwd),detachedTerminalIds:C.detachedTerminalIds.filter(B=>B!==n),tabs:S,activeTabId:b.id}}return C});return{...e,workspaces:w,activeWorkspaceId:r}}function _4(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 b4(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 y4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>{let m=!1;const g=u.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,m=!0,{...p,title:r}));return m?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function S4(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>Pl(c.root,t))),r=n?.tabs.find(o=>Pl(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function w4(e,t,n){const r=Po(e),o=r?qf(r):void 0;if(!r||!o)return e;const c=M_(o.root,t,MT(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===r.id?{...u,tabs:u.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:u)}}function x_(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,m=!!(n&&n.some(b=>DT(b))||t&&t.some(b=>RT(b)));let g=E4(t,n,c,u);g.length===0&&(g=[Vf()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??$f;for(const b of e)if(!u.has(b.id)){if(m)g=M4(g,y,b.id,b);else{const w=ET(b);g=A4(g,y,w,b)}u.add(b.id)}return{workspaces:g.map(b=>Ho(N4(b,o))),activeWorkspaceId:p,terminals:o}}function Pu(e){return Li(e.root)}function k_(e){return N_(e.root)}function wf(e){return zb([...e.tabs.flatMap(t=>Li(t.root)),...e.detachedTerminalIds])}function Kg(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=D_(o.root);return c?[{...o,root:c}]:[]});return Ho({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function C4(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>Pl(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function x4(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function yT(e,t){const n={...e.terminals};return delete n[t],ST(e,t,n)}function k4(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??D4(e,t)?.id??R4(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??$f,o=e.workspaces.find(c=>c.id===r);return!o||!kT(o,t)?e:ST(e,t,{...e.terminals},{detachToWorkspaceId:r})}function ST(e,t,n,r={}){let o=e.workspaces.map(u=>{const m=[];for(const g of u.tabs){const p=zl(g.root,t);if(!p)continue;const y=Li(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:p,activeTerminalId:b})}return Ho({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:m})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?xT(u,t,n[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function T4(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const m=T_(u.root,t);if(!m)continue;const g=Li(m),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:m,activeTerminalId:p})}return Ho({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function E4(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)DT(c)&&o.push(rC(c,n,r));if(o.length>0)return o}return[rC({...Vf(),tabs:e??[]},n,r)]}function rC(e,t,n){const r=[];for(const c of e.tabs){if(!RT(c))continue;const u=E_(c.root,t);if(!u)continue;const m=Li(u);for(const p of m)n.add(p);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&r.push({...c,root:u,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return Ho({...e,defaultCwd:Ms(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function wT(e){return Po(e)?e:{...e,workspaces:[Vf()],activeWorkspaceId:$f}}function Po(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function qf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function CT(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function D4(e,t){return e.workspaces.find(n=>n.tabs.some(r=>Pl(r.root,t)))}function R4(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function M4(e,t,n,r){return e.map(o=>o.id===t?xT(o,n,r):o)}function xT(e,t,n){return kT(e,t)?{...e,defaultCwd:e.defaultCwd??Ms(n?.cwd),detachedTerminalIds:zb([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function kT(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Fl}function TT(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function N4(e,t){if(e.defaultCwd)return e;const n=wf(e).find(o=>!!t[o]),r=n?Ms(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Vf(){return{id:$f,title:s4,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ho(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Ms(e.defaultCwd),detachedTerminalIds:zb(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function A4(e,t,n,r){const o=Li(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Ms(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function ET(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Hu(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Hu(e.first,t,n),second:Hu(e.second,t,n)}}function zl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=zl(e.first,t),r=zl(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function T_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=T_(e.first,t),r=T_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function E_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=E_(e.first,t),r=E_(e.second,t);return n&&r?{...e,ratio:MT(e.ratio),first:n,second:r}:n??r}function D_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=D_(e.first),n=D_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function DT(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 RT(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&R_(t.root)}function R_(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")&&R_(t.first)&&R_(t.second):!1}function M_(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[r,...o]=t;if(r===0){const c=M_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=M_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function MT(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Ms(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function zb(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function Pl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Pl(e.first,t)||Pl(e.second,t)}function Li(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Li(e.first),...Li(e.second)]}function N_(e){return e.type==="pane"||e.type==="editor"?1:N_(e.first)+N_(e.second)}const Ir=new Map,Uu=new Map,Fu=new Map,Ku=new Map,Wu=new Map,A_=new Set;let NT=0;function jo(e){return e??"__local__"}function L4(e){return{agentId:e,state:r4(),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 It(e){const t=jo(e);let n=Ir.get(t);return n||(n=L4(e),Ir.set(t,n)),n}function AT(e,t){const n=jo(e);let r=Uu.get(n);return r||(r=new Set,Uu.set(n,r)),r.add(t),()=>{r.delete(t)}}function O4(e){const t=jo(e),n=Uu.get(t);if(n)for(const r of Array.from(n))r()}function Vl(e,t,n=!0){const r=Ir.get(jo(e)),o=n&&aC(r)!==aC(t);Ir.set(jo(e),t),O4(e),o&&Hb()}function L_(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function Pb(e,t){const n=e.state.workspaces.find(u=>u.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const u of n.tabs)for(const m of Li(u.root))r.add(m);let o=0,c=0;for(const u of r)L_(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(c+=1);return{workingTerminalCount:o,unreadCompletionCount:c}}function aC(e){return e?e.state.workspaces.map(t=>{const n=Pb(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function LT(e){return!!(e&&e.state.workspaces.some(t=>{const n=Pb(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function Hb(){NT+=1;for(const e of Array.from(A_))e()}function B4(e){return A_.add(e),()=>{A_.delete(e)}}function oC(){return NT}function j4(e,t){return Pb(It(e),t)}const O_=new Set;function I4(e){return O_.add(e),()=>{O_.delete(e)}}function So(e,t){const n=It(e),r=jo(e),o=P4(n.state,t);t.type==="workspace.hydrated"&&(Fu.delete(r),Ku.delete(r),Wu.delete(r));const c=a4(n.state,t);let u=n.unreadCompletions,m=null;if(t.type==="terminal.updated"){const y=n.state.terminals[t.terminal.id],b=q4(r),w=V4(r),C=H4(r);if(t.terminal.agentStatus){const S=t.terminal.agentStatus.state,R=t.terminal.agentStatus.sessionId,B=C.get(t.terminal.id),A=!!(y&&(y.currentCommand!==t.terminal.currentCommand||y.agentStatus?.provider!==t.terminal.agentStatus.provider||z4(B,R)));A&&(w.delete(t.terminal.id),b.delete(t.terminal.id),C.delete(t.terminal.id)),R&&C.set(t.terminal.id,R),t.notifyCompletion===!0&&(S==="working"?(w.add(t.terminal.id),b.delete(t.terminal.id)):S==="unknown"&&t.terminal.activity==="busy"&&b.add(t.terminal.id)),!A&&(S==="done"||S==="stopped")&&(w.has(t.terminal.id)||b.has(t.terminal.id))&&(m=uC(c,t.terminal.id,y?.currentCommand??null,S==="stopped"?"stopped":"finished"),w.delete(t.terminal.id),b.delete(t.terminal.id)),S==="idle"&&(w.delete(t.terminal.id),b.delete(t.terminal.id))}else{y?.agentStatus&&(w.delete(t.terminal.id),C.delete(t.terminal.id));const S=y?.activity==="busy",R=t.terminal.activity==="busy",B=t.terminal.activity==="idle";t.notifyCompletion===!0&&R&&b.add(t.terminal.id),t.notifyCompletion===!0&&S&&B&&b.has(t.terminal.id)&&(m=uC(c,t.terminal.id,y?.currentCommand??null,"finished")),(B||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(m){const S=OT(c,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==c.activeWorkspaceId)&&(u.has(t.terminal.id)||(u=new Set(u),u.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),w.delete(t.terminal.id),C.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let y=null;if(t.type==="tab.selected")y=U4(c,t.tabId)?.tab??null;else{const w=c.workspaces.find(C=>C.id===t.workspaceId);y=w?.tabs.find(C=>C.id===w.activeTabId)??null}const b=y?Li(y.root):[];if(b.some(w=>u.has(w))){const w=new Set(u);for(const C of b)w.delete(C);u=w}}const g=c!==n.state,p=u!==n.unreadCompletions;if((g||p)&&Vl(e,{...n,state:c,unreadCompletions:u},o||p),p&&Yf(),m)for(const y of Array.from(O_))y({agentId:e,...m})}function z4(e,t){return e!==void 0&&t!==void 0&&e!==t}function P4(e,t){switch(t.type){case"terminal.updated":return L_(e.terminals[t.terminal.id])!==L_(t.terminal);case"workspace.renamed":case"workspace.defaultCwdChanged":case"workspace.reordered":case"editor.split":case"editor.closed":case"pane.selected":case"pane.resized":case"tab.renamed":case"tab.reordered":return!1;default:return!0}}function H4(e){let t=Wu.get(e);return t||(t=new Map,Wu.set(e,t)),t}function OT(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Li(r.root).includes(t))return{workspace:n,tab:r};return null}function U4(e,t){for(const n of e.workspaces){const r=n.tabs.find(o=>o.id===t);if(r)return{workspace:n,tab:r}}return null}const B_=new Set;function F4(e){return B_.add(e),()=>{B_.delete(e)}}function K4(){let e=0;for(const t of Ir.values())e+=t.unreadCompletions.size;return e}function Yf(){for(const e of Array.from(B_))e()}function lC(e,t){const n=It(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Vl(e,{...n,unreadCompletions:r}),Yf()}function cC(e,t){const n=It(e);t!==n.state&&Vl(e,{...n,state:t})}function Wg(e,t){const n=It(e),r=t(n.editors);r!==n.editors&&Vl(e,{...n,editors:r},!1)}function xa(e,t,n){const r=It(e);r.loaded===t&&r.error===n||Vl(e,{...r,loaded:t,error:n},!1)}function eu(e,t,n){const r=It(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Vl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1)}function W4(e){const t=It(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function $4(e){const t=jo(e),n=Ir.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=LT(n);Ir.delete(t),Uu.delete(t),Fu.delete(t),Ku.delete(t),Wu.delete(t),r&&Yf(),o&&Hb()}function $g(){let e=!1,t=!1;for(const n of Ir.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),LT(n)&&(t=!0)}Ir.clear(),Uu.clear(),Fu.clear(),Ku.clear(),Wu.clear(),e&&Yf(),t&&Hb()}function q4(e){let t=Fu.get(e);return t||(t=new Set,Fu.set(e,t)),t}function V4(e){let t=Ku.get(e);return t||(t=new Set,Ku.set(e,t)),t}function uC(e,t,n,r){const o=OT(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function j_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of Pu(e)){const m=t[u];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(r=!0,n=!0,!o&&m.currentCommand&&(o=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Ub(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function I_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function Y4(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function X4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:u,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:w,onRenameTab:C,activePaneAvailable:S}){const[R,B]=v.useState(null),[A,U]=v.useState(!1),[Y,K]=v.useState(null),se=v.useRef(null),Q=e.findIndex(q=>q.id===t),z=Q>=0?e[Q]:e[0]??null,_e=z?j_(z,n):null,ie=z?k_(z):0,ke=z?I_(z,n):"No tab";v.useEffect(()=>{se.current?.focus(),se.current?.select()},[R?.tabId]),v.useEffect(()=>{if(!A)return;const q=oe=>{oe.key==="Escape"&&U(!1)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[A]),v.useEffect(()=>{A&&e.length===0&&U(!1)},[A,e.length]);function ne(q,oe){B({tabId:q,title:oe})}function X(){if(!R)return;const q=R.title.trim();q&&C(R.tabId,q),B(null)}function G(){return h.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[h.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${wM()}`,onClick:b,disabled:!S,children:h.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),h.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${CM()}`,onClick:w,disabled:!S,children:h.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return h.jsxs(h.Fragment,{children:[h.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[h.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:h.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]})}),h.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:ke,onClick:()=>U(!0),disabled:e.length===0,children:[_e?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":_e.state,"aria-hidden":"true",title:Ub(_e)}):null,h.jsx("span",{children:ke}),h.jsxs("small",{children:[Q>=0?Q+1:0,"/",e.length||0,ie>1?` / ${ie}`:""]})]}),h.jsxs("div",{className:"terminal-tab-list",children:[e.map((q,oe)=>{const L=Pu(q),M=k_(q),j=I_(q,n),re=q.id===t,ye=R?.tabId===q.id,N=j_(q,n),W=r?.has(q.id)??!1;return h.jsxs(Ni.Fragment,{children:[h.jsx(dC,{index:oe}),h.jsx(G4,{tab:q,active:re,editing:ye,title:j,paneCount:M,terminalIds:L,canClose:e.length>1,editValue:ye?R.title:null,editInputRef:ye?se:null,activity:N,unread:W,onSelect:()=>c(q.id),onBeginRename:()=>ne(q.id,j),onCloseAll:()=>g(L),onCommitRename:X,onCancelRename:()=>B(null),onRenameChange:ue=>B({tabId:q.id,title:ue})})]},q.id)}),h.jsx(dC,{index:e.length}),h.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:u,children:"+"}),(o?.length??0)>0?h.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(q=>h.jsx(Q4,{terminal:q,onReattach:()=>p?.(q.id),onDelete:()=>K(q)},q.id))}):null]}),h.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:u,children:"+"}),S?G():null]}),A?h.jsx(Z4,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:R,editInputRef:se,onClose:()=>U(!1),onSelectTab:q=>{c(q),U(!1)},onCreateTab:()=>{u(),U(!1)},onBeginRename:ne,onCloseTerminals:q=>{g(q),U(!1)},onCommitRename:X,onCancelRename:()=>B(null),onRenameChange:(q,oe)=>B({tabId:q,title:oe}),onReattachTerminal:q=>{p?.(q),U(!1)},onDeleteTerminal:q=>{K(q),U(!1)}}):null,Y?h.jsx(J4,{terminal:Y,onCancel:()=>K(null),onConfirm:()=>{y?.(Y.id),K(null)}}):null]})}function G4({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:m,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:w,onCommitRename:C,onCancelRename:S,onRenameChange:R}){const{attributes:B,listeners:A,setNodeRef:U,transform:Y,isDragging:K}=$C({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),se={transform:Zg.Translate.toString(Y),opacity:K?.4:void 0,zIndex:K?2:void 0};return h.jsxs("div",{ref:U,className:"terminal-tab","data-active":t,"data-dragging":K,"data-unread":p?"true":void 0,style:se,...B,...A,children:[g?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Ub(g)}):null,n&&m&&u!==null?h.jsxs("form",{className:"terminal-tab-editor",onSubmit:Q=>{Q.preventDefault(),C()},children:[h.jsx("input",{ref:m,"aria-label":`Rename ${r}`,value:u,onBlur:C,onChange:Q=>R(Q.target.value),onKeyDown:Q=>{if(Q.key==="Enter"){Q.preventDefault(),C();return}Q.key==="Escape"&&(Q.preventDefault(),S())}}),h.jsx("small",{children:o})]}):h.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:Q=>{Q.preventDefault(),b()},children:[h.jsx("span",{children:r}),h.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?h.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),w()},children:"x"}):null]})}function Z4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:u,onClose:m,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:w,onCancelRename:C,onRenameChange:S,onReattachTerminal:R,onDeleteTerminal:B}){const A=v.useRef(null);return v.useEffect(()=>{A.current?.scrollIntoView?.({block:"nearest"})},[t]),h.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:h.jsxs("section",{className:"mobile-tab-sheet",onClick:U=>U.stopPropagation(),children:[h.jsxs("header",{children:[h.jsxs("div",{children:[h.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),h.jsxs("small",{children:[e.length," open"]})]}),h.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[h.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),h.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),h.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((U,Y)=>{const K=Pu(U),se=k_(U),Q=I_(U,n),z=U.id===t,_e=c?.tabId===U.id,ie=j_(U,n),ke=r?.has(U.id)??!1;return h.jsxs("div",{ref:z?A:null,className:"mobile-tab-sheet-row","data-active":z,"data-unread":ke?"true":void 0,children:[_e&&c?h.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ne=>{ne.preventDefault(),w()},children:h.jsx("input",{ref:u,"aria-label":`Rename ${Q}`,value:c.title,onBlur:w,onChange:ne=>S(U.id,ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),w();return}ne.key==="Escape"&&(ne.preventDefault(),C())}})}):h.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${Q}`,onClick:()=>g(U.id),children:[h.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),h.jsxs("span",{className:"mobile-tab-sheet-copy",children:[h.jsx("strong",{children:Q}),h.jsx("small",{children:Y4(U,n,se,ie)})]}),h.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ie?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":ie.state,"aria-hidden":"true",title:Ub(ie)}):null,h.jsx("span",{children:se})]})]}),h.jsxs("div",{className:"mobile-tab-sheet-actions",children:[_e?h.jsx("button",{type:"button","aria-label":`Done renaming ${Q}`,onClick:w,children:"Done"}):h.jsx("button",{type:"button","aria-label":`Rename ${Q}`,onClick:()=>y(U.id,Q),children:"Rename"}),e.length>1?h.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${Q}`,onClick:()=>b(K),children:"×"}):null]})]},U.id)}),(o?.length??0)>0?h.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[h.jsx("span",{children:"Detached"}),(o??[]).map(U=>{const Y=U.title||U.cwd||U.id.slice(0,8);return h.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[h.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>R(U.id),children:[h.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),h.jsxs("span",{className:"mobile-tab-sheet-copy",children:[h.jsx("strong",{children:Y}),h.jsx("small",{children:U.cwd})]}),h.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),h.jsx("div",{className:"mobile-tab-sheet-actions",children:h.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>B(U),children:"×"})})]},U.id)})]}):null]})]})})}function dC({index:e}){const{setNodeRef:t,isOver:n}=J_({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return h.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function Q4({terminal:e,onReattach:t,onDelete:n}){const r=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 h.jsxs("span",{className:"terminal-detached-pill",title:o,children:[h.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),h.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function J4({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:h.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),h.jsxs("section",{className:"terminal-delete-dialog-body",children:[h.jsx("p",{children:"Delete this terminal?"}),h.jsx("span",{children:r}),h.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),h.jsxs("div",{className:"terminal-delete-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),h.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function e6({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return h.jsxs("aside",{className:`upload-toast upload-toast-${r6(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[h.jsxs("header",{className:"upload-toast-header",children:[h.jsx("strong",{children:e.length===1?Xh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),h.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),h.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>h.jsx(t6,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function t6({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return h.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Xh(e),children:[h.jsxs("div",{className:"upload-queue-item-header",children:[h.jsx("strong",{children:Xh(e)}),h.jsxs("div",{className:"upload-queue-actions",children:[m?h.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?h.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,h.jsx("button",{type:"button","aria-label":`Dismiss ${Xh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?h.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?h.jsx(i6,{toast:e}):null,c&&"message"in e&&e.message?h.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?h.jsx(n6,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?h.jsx("p",{children:e.message}):null]})}function i6({toast:e}){const t=e.percent===null?a6(e.loaded):`${e.percent}%`;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"upload-progress-row",children:[h.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),h.jsx("span",{children:t})]}),h.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:h.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function n6({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?h.jsx("ul",{className:"upload-result-list",children:c.map((u,m)=>h.jsx(s6,{result:u},`${u.relativePath}-${m}`))}):null,e.results.length>c.length?h.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function s6({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return h.jsxs("li",{"data-status":e.status,children:[h.jsx("span",{className:"upload-result-path",children:t}),n?h.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?h.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Xh(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 r6(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 a6(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function o6({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return h.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:m,children:[h.jsxs("header",{className:"completion-toast-header",children:[h.jsxs("div",{className:"completion-toast-copy",children:[h.jsx("strong",{children:r.tabTitle}),h.jsx("span",{children:c})]}),h.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),h.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const l6=du(0,0,1,1),Mr=1e-6;function c6(e){return BT(e).map(t=>t.terminalId)}function BT(e){return uu(e,l6).sort(f6).map((t,n)=>({...t,index:n+1}))}function u6(e,t,n){const r=BT(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>h6(o,u,n)).filter(u=>u!==null).sort(p6)[0]?.entry.terminalId??null:null}function d6(e,t){return!Number.isInteger(t)||t<1?null:c6(e)[t-1]??null}function uu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=m6(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...uu(e.first,du(t.left,t.top,o,t.bottom)),...uu(e.second,du(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...uu(e.first,du(t.left,t.top,t.right,r)),...uu(e.second,du(t.left,r,t.right,t.bottom))]}function h6(e,t,n){const r=e.bounds,o=t.bounds,c=hC(r.left,r.right,o.left,o.right),u=hC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Mr||u<=Mr?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"right":return o.centerX<=r.centerX+Mr||u<=Mr?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"up":return o.centerY>=r.centerY-Mr||c<=Mr?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Mr||c<=Mr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function f6(e,t){return Rl(e.bounds.top,t.bounds.top)||Rl(e.bounds.left,t.bounds.left)}function p6(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)<=Mr?0:n}function hC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function du(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function m6(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const fC="nterminal.terminalWorkspaces.v2",jT="nterminal.sidebarCollapsed.v1",g6=75,pC=YC.map(e=>e.url),v6=YC[0].url,_6=6;function b6({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??kf(),[e]),p=v.useMemo(()=>t??ko(null),[t]),y=v.useMemo(()=>F6(n),[n]),b=v.useMemo(()=>x=>AT(n,x),[n]),w=v.useMemo(()=>()=>It(n),[n]),C=v.useSyncExternalStore(b,w,w),S=C.state,R=C.editors,B=!C.loaded,A=C.error,[U,Y]=v.useState(!1),[K,se]=v.useState(()=>X6()),[Q,z]=v.useState("servers"),[_e,ie]=v.useState(!1),[ke,ne]=v.useState(null),X=v.useMemo(()=>ko(ke?.agentId??null),[ke?.agentId]),G=v.useSyncExternalStore(LM,Ew,Ew);v.useSyncExternalStore(vu,Tw,Tw);const[q,oe]=v.useState(0),[L,M]=v.useState(null),[j,re]=v.useState(()=>[null]),[ye,N]=v.useState(()=>({[Yi]:"Local"})),[W,ue]=v.useState(0),[Ce,Le]=v.useState(()=>[n]),[Me,Ne]=v.useState(()=>new Set),[Oe,Ve]=v.useState({}),[Ye,Be]=v.useState(null),le=v.useRef(0),E=v.useRef(0),[V,ge]=v.useState(null),[Te,F]=v.useState(null),Se=v.useRef(null),xe=v.useRef(0),he=v.useRef(null),je=v.useRef(null),Ie=v.useRef(null),He=v.useRef(null),et=v.useRef(()=>{}),[Mt,pt]=v.useState(null),kt=B2(nw(HC,{activationConstraint:{distance:8}}),nw(UC,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>OM(g),[g]);function yt(x){const D=x.active.data.current;if(D){if(D.kind==="tab"&&typeof D.tabId=="string"&&typeof D.terminalId=="string"){pt({tabId:D.tabId,terminalId:D.terminalId});return}D.kind==="pane"&&typeof D.sourceTabId=="string"&&typeof D.terminalId=="string"&&pt({tabId:D.sourceTabId,terminalId:D.terminalId})}}function Qt(x){pt(null);const D=x.active.data.current,P=x.over?.data.current;if(!(!D||!P||typeof D.terminalId!="string")){if(D.kind==="tab"&&typeof D.tabId=="string"){if(P.kind==="tab-position"&&typeof P.index=="number"){nt({type:"tab.reordered",sourceTabId:D.tabId,targetIndex:P.index});return}if(P.kind==="workspace"&&typeof P.workspaceId=="string"){nt({type:"tab.moved_to_workspace",sourceTabId:D.tabId,targetWorkspaceId:P.workspaceId});return}P.kind==="pane-zone"&&typeof P.terminalId=="string"&&(P.side==="top"||P.side==="right"||P.side==="bottom"||P.side==="left")&&nt({type:"tab.dropped_into_pane",sourceTabId:D.tabId,sourceTerminalId:D.terminalId,targetTerminalId:P.terminalId,side:P.side});return}if(D.kind==="pane"&&typeof D.sourceTabId=="string"){if(P.kind==="tab-position"&&typeof P.index=="number"){nt({type:"terminal.extracted_to_tab",sourceTabId:D.sourceTabId,sourceTerminalId:D.terminalId,targetIndex:P.index});return}if(P.kind==="workspace"&&typeof P.workspaceId=="string"){nt({type:"terminal.extracted_to_workspace",sourceTabId:D.sourceTabId,sourceTerminalId:D.terminalId,targetWorkspaceId:P.workspaceId});return}P.kind==="pane-zone"&&typeof P.terminalId=="string"&&(P.side==="top"||P.side==="right"||P.side==="bottom"||P.side==="left")&&nt({type:"tab.dropped_into_pane",sourceTabId:D.sourceTabId,sourceTerminalId:D.terminalId,targetTerminalId:P.terminalId,side:P.side})}}}function ci(){pt(null)}const de=S.workspaces.find(x=>x.id===S.activeWorkspaceId)??S.workspaces[0],Ue=de?.tabs.find(x=>x.id===de.activeTabId)??de?.tabs[0],tt=Ue?.activeTerminalId??null,Ge=tt?S.terminals[tt]:void 0,xt=j6("(max-width: 760px)"),ot=v.useMemo(()=>Ue?Cf(Ue.root):[],[Ue]),Hi=de&&Ue?hu(n,de.id,Ue.id):null,_i=Ue?IT(ot,Ue.activeTerminalId,Hi?Oe[Hi]:void 0):null,ee=xt&&ot.length>1,Pe=v.useMemo(()=>(de?.detachedTerminalIds??[]).flatMap(x=>{const D=S.terminals[x];return D?[D]:[]}),[de?.detachedTerminalIds,S.terminals]),mt=v.useMemo(()=>{const x=new Set;for(const D of de?.tabs??[])Pu(D).some(P=>C.unreadCompletions.has(P))&&x.add(D.id);return x},[de?.tabs,C.unreadCompletions]);v.useSyncExternalStore(B4,oC,oC);const[lt,Dt]=v.useState([]),Nt=v.useRef([]),Wt=v.useRef(null),[ui,$t]=v.useState(null),[zt,xi]=v.useState(null),[Lt,un]=v.useState([]),[qt,Ji]=v.useState(()=>Mo()),_n=v.useRef(0),dn=v.useRef(n),si=v.useRef(pC),en=v.useRef(qt),bi=v.useRef(()=>{});bi.current=bs,et.current=zs;const ri=v.useCallback(async()=>{try{const x=await g.listNotificationAssets();un(x.assets.filter(D=>D.enabled).map(D=>D.url))}catch{un([])}},[g]),di=v.useCallback(x=>{N(D=>{const P={...D};for(const ae of x)P[P_(ae.agentId)]=ae.label;return qg(D,P)?D:P})},[]);v.useEffect(()=>{Le(x=>x.some(D=>ln(D,n))?x:[...x,n])},[n]);const bn=v.useCallback(x=>{const D=It(x),P=ko(x);for(const ae of Object.keys(D.state.terminals))cu(P.createWebSocketUrl(ae)),Eh(ae),lu(ae);$4(x),Le(ae=>ae.filter(we=>!ln(we,x))),Ne(ae=>{const we=`${Zh(x)}:`;let pe=!1;const Re=new Set;for(const Ze of ae){if(Ze.startsWith(we)){pe=!0;continue}Re.add(Ze)}return pe?Re:ae}),Ve(ae=>{const we=`${Zh(x)}:`;let pe=!1;const Re={};for(const[Ze,rt]of Object.entries(ae)){if(Ze.startsWith(we)){pe=!0;continue}Re[Ze]=rt}return pe?Re:ae})},[]);v.useEffect(()=>{let x=!1;return g.getMainInfo().then(D=>{if(x)return;const P=D.name?.trim()||"Local";N(ae=>{const we={...ae,[Yi]:P};return qg(ae,we)?ae:we})}).catch(()=>{}),g.listAgents().then(D=>{if(!x){const P=D.agents.map(we=>we.id),ae=$R(D.serverOrder,D.agents);N(we=>{const pe={[Yi]:we[Yi]??"Local"};for(const Re of D.agents)pe[Re.id]=Re.name;return qg(we,pe)?we:pe}),n!==null&&!P.includes(n)&&(bn(n),r?.(null)),re(ae)}}).catch(()=>{}),()=>{x=!0}},[n,g,bn,r,W]);const Hr=v.useCallback(x=>{bn(x),ue(D=>D+1),ln(x,dn.current)&&r?.(null)},[bn,r]);v.useEffect(()=>{re(x=>x.some(D=>ln(D,n))?x:[...x,n])},[n]),v.useEffect(()=>{dn.current=n},[n]),v.useEffect(()=>{M(null)},[n]),v.useEffect(()=>{const x=he.current;if(!x)return;if(!ln(x.agentId,n)){he.current=null;return}if(!C.loaded||S.workspaces.length===0)return;he.current=null;const D=x.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];D&&D.id!==S.activeWorkspaceId&&nt({type:"workspace.selected",workspaceId:D.id})},[n,C.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const x=je.current;if(x){if(!ln(x.agentId,n)){je.current=null;return}C.loaded&&(je.current=null,S.workspaces.some(D=>D.id===x.workspaceId)&&nt({type:"workspace.selected",workspaceId:x.workspaceId}))}},[n,C.loaded,S.workspaces]),v.useEffect(()=>{const x=Ie.current;if(x){if(!ln(x.agentId,n)){Ie.current=null;return}C.loaded&&(Ie.current=null,C.error||Yn())}},[n,C.error,C.loaded]),v.useEffect(()=>{Xr()},[n,C.loaded,S]),v.useEffect(()=>{const x=()=>{const ae=z6();ae&&et.current(ae)},D=ae=>{const we=P6(ae.data);we&&et.current(we)},P=ae=>{const we=Nf(ae.detail);we&&et.current(we)};return x(),window.addEventListener("hashchange",x),window.addEventListener(nv,P),navigator.serviceWorker?.addEventListener?.("message",D),()=>{window.removeEventListener("hashchange",x),window.removeEventListener(nv,P),navigator.serviceWorker?.removeEventListener?.("message",D)}},[]),v.useEffect(()=>{ri()},[ri]),v.useEffect(()=>sx(()=>Ji(Mo())),[]),v.useEffect(()=>{const x=D=>{bi.current(D)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{si.current=Lt.length>0?Lt:pC},[Lt]),v.useEffect(()=>{en.current=qt},[qt]),v.useEffect(()=>{if(!C.loaded||!de||!Ue)return;const x=hu(n,de.id,Ue.id);Ne(D=>{if(D.has(x))return D;const P=new Set(D);return P.add(x),P})},[n,C.loaded,de?.id,Ue?.id]),v.useEffect(()=>()=>{Ps()},[]),v.useEffect(()=>{const x=jR(g),D=PR(g);return()=>{x(),D()}},[g]),v.useEffect(()=>I4(x=>{const D=It(x.agentId).state,P=D.workspaces.flatMap(Re=>Re.tabs).find(Re=>Re.id===x.tabId),ae=D.terminals[x.terminalId],we=P?.title?.trim()||ae?.title||x.commandName||"terminal",pe=document.visibilityState==="visible"&&ln(x.agentId,dn.current)&&x.tabId===U6(D);if(pe||MR({agentId:x.agentId,tabTitle:we,commandName:x.commandName,terminalId:x.terminalId,outcome:x.outcome}),!pe&&document.visibilityState==="visible"&&en.current.enabled){const Re=_n.current+1;_n.current=Re;const Ze=si.current;$t({id:Re,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:we,commandName:x.commandName,outcome:x.outcome,assetSrc:Ze[Math.floor(Math.random()*Ze.length)]??v6})}}),[]),v.useEffect(()=>{if(!ui||qt.persistUntilDismissed)return;const x=window.setTimeout(()=>{$t(D=>D?.id===ui.id?null:D)},qt.durationSeconds*1e3);return()=>window.clearTimeout(x)},[ui,qt]),v.useEffect(()=>{G6(K),K&&ir()},[K]),v.useEffect(()=>{let x=!1;async function D(){if(!It(n).loaded){xa(n,!1,null);try{let ae=null,we=null;try{ae=K6(y)}catch(rt){if(!(rt instanceof xf))throw rt;we=rt}const[pe,Re]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Ze=pe.terminals.length>0?pe.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!x){const rt=Re.layout?PT(Re.layout):null;if(!rt&&we)throw we;const Zt=rt??ae??{},Wi=x_(Ze,void 0,Zt.savedWorkspaces,Zt.savedActiveWorkspaceId),hi=Kg(Wi);cC(n,Wi),eu(n,Re.revision,JSON.stringify(hi)),xa(n,!0,null),!rt&&ae&&ws(hi,{baseRevision:Re.revision})}}catch(ae){!x&&!qr(ae)&&xa(n,!0,ka(ae))}}}return D(),()=>{x=!0}},[n,p,q]);function Yl(){xa(n,!1,null),oe(x=>x+1)}function ir(){le.current+=1,E.current+=1,Be(null)}function Ur(x){le.current+=1,E.current+=1,Be(D=>D&&{...D,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Yn(){le.current+=1,E.current+=1;const x=S.workspaces.length+1,D=Ns();Be({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:D,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),D&&Gn(D)}function qa(x){if(ln(x,n)){Yn();return}Ie.current={agentId:x},r?.(x)}function Xn(x){if(K&&!U)return;const D=S.workspaces.find(ae=>ae.id===x);if(!D)return;le.current+=1,E.current+=1;const P=D.defaultCwd??Ge?.cwd??"";Be({mode:"edit",workspaceId:x,title:D.title,cwd:P,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),P&&Gn(P)}function Ns(){return de?.defaultCwd??Ge?.cwd??""}async function Gn(x){const D=le.current+1;le.current=D;const P=x.trim();if(Be(ae=>ae&&{...ae,cwd:x,browseStatus:P?"loading":"idle",browseRoot:null,browseEntries:[],error:P?null:"Choose a default working directory."}),!!P)try{const ae=await p.createFileRoot({path:P}),we=await p.listFiles({rootToken:ae.rootToken,path:""});if(le.current!==D)return;Be(pe=>pe&&{...pe,cwd:ae.rootPath,browseRoot:{rootToken:ae.rootToken,rootPath:ae.rootPath},browseEntries:we.entries.filter(Re=>Re.kind==="directory"),browseStatus:"idle",error:null})}catch(ae){if(le.current!==D)return;Be(we=>we&&{...we,browseStatus:"idle",error:ka(ae)})}}async function As(){const x=Ye;if(!x)return;const D=x.title.trim(),P=x.cwd.trim();if(!D||!P){Be({...x,submitStatus:"idle",error:D?"Choose a default working directory.":"Workspace name is required."});return}const ae=E.current+1;E.current=ae,Be({...x,submitStatus:"submitting",error:null});try{const we=await p.createFileRoot({path:P});if(E.current!==ae)return;if(x.mode==="create"){const pe=S.workspaces.length+1;nt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${pe}`,title:D,defaultCwd:we.rootPath})}else x.workspaceId&&(nt({type:"workspace.renamed",workspaceId:x.workspaceId,title:D}),nt({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:we.rootPath}));Be(null)}catch(we){if(E.current!==ae)return;Be(pe=>pe&&{...pe,submitStatus:"idle",error:ka(we)})}}function Pt(x){E.current+=1,Be(x)}function Va(x,D,P){if(x===D)return;const ae=S.workspaces.some(pe=>pe.id===x),we=S.workspaces.some(pe=>pe.id===D);!ae||!we||nt({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:D,placement:P})}function Fr(x,D){const P=S.workspaces.findIndex(we=>we.id===x),ae=S.workspaces[P+D];P<0||!ae||Va(x,ae.id,D<0?"before":"after")}function Vt(x,D){D.pointerType==="mouse"&&D.button!==0||(D.preventDefault(),D.stopPropagation(),Se.current={sourceId:x,pointerId:D.pointerId,startX:D.clientX,startY:D.clientY,active:!1,targetId:null,placement:"after"},D.currentTarget.setPointerCapture?.(D.pointerId))}function Zn(x){const D=Se.current;if(!D||D.pointerId!==x.pointerId)return;const P=Math.hypot(x.clientX-D.startX,x.clientY-D.startY);if(!D.active){if(P<_6)return;D.active=!0,ge(D.sourceId)}const we=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),pe=we?.dataset.workspaceId??null;if(!we||!pe||pe===D.sourceId||!S.workspaces.some(rt=>rt.id===pe)){D.targetId=null,F(null);return}const Re=we.getBoundingClientRect(),Ze=x.clientY<Re.top+Re.height/2?"before":"after";D.targetId=pe,D.placement=Ze,F({workspaceId:pe,placement:Ze})}function yn(x){const D=Se.current;!D||D.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),Se.current=null,ge(null),F(null),D.active&&D.targetId&&Va(D.sourceId,D.targetId,D.placement))}function Kr(x){const D=Se.current;D&&D.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),Se.current=null,ge(null),F(null)}async function Ya(){await Dn(async()=>{const x=de?.defaultCwd?{cols:80,rows:24,cwd:de.defaultCwd}:{cols:80,rows:24},D=await p.createTerminal(x);nt({type:"terminal.created",terminal:D.terminal})})}async function gs(x){await Dn(async()=>{const D=tt?{parentTerminalId:tt,cols:80,rows:24}:de?.defaultCwd?{cols:80,rows:24,cwd:de.defaultCwd}:{cols:80,rows:24},P=await p.createTerminal(D);nt({type:"terminal.split",terminal:P.terminal,direction:x})})}async function Ls(x){let D=tt,P=Hi;const ae=de?.defaultCwd?.trim();if(!D&&!ae)throw new Error("No active pane is available.");const we=await p.readFile(x);if(!D&&ae){const Ze=await p.createTerminal({cols:80,rows:24,cwd:ae});D=Ze.terminal.id,nt({type:"terminal.created",terminal:Ze.terminal})}if(D){nt({type:"pane.selected",terminalId:D});const Ze=It(n).state,rt=Ze.workspaces.find(Wi=>Wi.id===Ze.activeWorkspaceId)??Ze.workspaces[0],Zt=rt?.tabs.find(Wi=>Wi.id===rt.activeTabId)??rt?.tabs[0];P=rt&&Zt?hu(n,rt.id,Zt.id):null}const pe=`editor-${Date.now().toString(36)}-${W4(n)}`,Re=Y6(we.path);Wg(n,Ze=>({...Ze,[pe]:{id:pe,title:Re,rootToken:x.rootToken,path:we.path,read:we}})),P&&Ve(Ze=>({...Ze,[P]:zT(pe)})),nt({type:"editor.split",editorId:pe,title:Re,direction:"vertical"})}function Wr(x){Wg(n,D=>{const P={...D};return delete P[x],P}),nt({type:"editor.closed",editorId:x})}function Sn(x){Oi([x])}function Oi(x){const D=[...new Set(x)].filter(ae=>S.terminals[ae]);if(D.length===0)return;const P=D.length===1?S.terminals[D[0]]?.title||S.terminals[D[0]]?.cwd||D[0]:`${D.length} panes`;M(null),xi({terminalIds:D,label:P,workspaceId:de?.id??S.activeWorkspaceId??null})}function Os(x,D){const P=ys(x,D);if(!P)return!1;const ae=x.filter(we=>!P.detachedTerminalIds.includes(we));if(P.detachedTerminalIds.length+ae.length>Fl)return M($6(P.detachedTerminalIds.length)),!1;M(null);for(const we of x)nt(P.id?{type:"terminal.detached",terminalId:we,workspaceId:P.id}:{type:"terminal.detached",terminalId:we});return!0}async function Xa(x){await Dn(async()=>{for(const D of x)await ki(D),cu(p.createWebSocketUrl(D)),Eh(D),lu(D),nt({type:"terminal.closed",terminalId:D})})}async function vs(x){const D=S.workspaces.find(P=>P.id===x);!D||S.workspaces.length<=1||window.confirm(`Delete workspace "${D.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Dn(async()=>{const P=wf(D),ae=[];let we=null;for(const Re of P)try{await ki(Re)}catch(Ze){ae.push(ka(Ze)),Ze instanceof kn&&Ze.status===401&&!p.isAgent&&(we=Ze)}finally{cu(p.createWebSocketUrl(Re)),Eh(Re),lu(Re)}const pe=D.tabs.flatMap(Re=>z_(Re.root));if(pe.length>0){const Re=new Set(pe);Wg(n,Ze=>{const rt={...Ze};for(const Zt of Re)delete rt[Zt];return rt})}if(nt({type:"workspace.closed",workspaceId:x}),we)throw we;if(ae.length>0)throw new Error(`Workspace was removed, but ${ae.length} terminal session${ae.length===1?"":"s"} may still be running. ${ae[0]}`)})}async function hn(x){await Dn(async()=>{await ki(x),cu(p.createWebSocketUrl(x)),Eh(x),lu(x),nt({type:"terminal.closed",terminalId:x})})}async function _s(x,D){const P=D.trim();if(!P)return;let ae=null;for(const we of S.workspaces){const pe=we.tabs.find(Re=>Re.id===x);if(pe){ae=pe.activeTerminalId;break}}if(nt({type:"tab.renamed",tabId:x,title:P}),!!ae)try{const we=await p.renameTerminal(ae,P);nr({type:"terminal.updated",terminal:we.terminal})}catch(we){xa(n,!0,ka(we))}}function Xl(x){const D=S.terminals[x];D&&nt({type:"terminal.created",terminal:D})}async function ki(x){try{await p.closeTerminal(x)}catch(D){if(D instanceof kn&&D.status===404)return;throw D}}async function $r(){await Dn(async()=>{await u()})}async function Dn(x){xa(n,!0,null);try{await x()}catch(D){if(qr(D))return;xa(n,!0,ka(D))}}function qr(x){return x instanceof kn&&x.status===401&&!p.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function nt(x){So(n,x);const D=It(n),P=D.state;if(!D.loaded||P.workspaces.length===0)return;const ae=Kg(P);JSON.stringify(ae)!==D.lastPersistedLayoutJson&&or(ae)}function nr(x){So(n,x)}function sr(x,D,P,ae){const we=hu(x,D,P);Ve(pe=>({...pe,[we]:ae}))}function tn(x){Hi&&Ve(D=>({...D,[Hi]:x}))}function Uo(x,D){const P=xu(x);D?sr(n,D.workspaceId,D.tabId,P):tn(P),nt({type:"pane.selected",terminalId:x})}function Vr(x){tn(x.key),x.type==="terminal"&&nt({type:"pane.selected",terminalId:x.terminalId})}function bs(x){if(_e||zt||x.isComposing||x.key==="Process"||k6(x.target))return;const D=S6(x);if(!D)return;if(x.preventDefault(),x.stopPropagation(),D.type==="server.previous"||D.type==="server.next"){Fo(D.type==="server.next"?1:-1);return}const P=It(n).state,ae=P.workspaces.find(Re=>Re.id===P.activeWorkspaceId)??P.workspaces[0],we=ae?.tabs.find(Re=>Re.id===ae.activeTabId)??ae?.tabs[0];if(D.type==="split"){if(!we)return;gs(D.direction);return}if(!ae||!we)return;if(D.type==="tab.previous"||D.type==="tab.next"){const Re=x6(ae.tabs,we.id,D.type==="tab.next"?1:-1);Re&&nt({type:"tab.selected",tabId:Re.id});return}if(D.type==="tab.index"){const Re=ae.tabs[D.index-1];Re&&nt({type:"tab.selected",tabId:Re.id});return}const pe=w6(we.root,we.activeTerminalId,D);pe&&Uo(pe,{workspaceId:ae.id,tabId:we.id})}function rr(x,D){if(!r||j.length===0)return;const P=j.findIndex(Re=>ln(Re,n)),we=((P===-1?0:P)+x+j.length)%j.length,pe=j[we]??null;ln(pe,n)||(D&&(he.current={agentId:pe,edge:D}),r(pe))}function Fo(x){const D=It(n).state,P=D.workspaces;if(P.length===0){rr(x,x===1?"first":"last");return}const ae=P.findIndex(Re=>Re.id===D.activeWorkspaceId),pe=(ae===-1?0:ae)+x;if(pe>=0&&pe<P.length){nt({type:"workspace.selected",workspaceId:P[pe].id});return}rr(x,x===1?"first":"last")}function Gl(x,D){if(ln(x,n)){nt({type:"workspace.selected",workspaceId:D});return}je.current={agentId:x,workspaceId:D},r?.(x)}function ys(x,D){if(D)return S.workspaces.find(P=>P.id===D)??null;for(const P of x){const ae=S.workspaces.find(pe=>pe.tabs.some(Re=>Pu(Re).includes(P)));if(ae)return ae;const we=S.workspaces.find(pe=>pe.detachedTerminalIds.includes(P));if(we)return we}return S.workspaces.find(P=>P.id===S.activeWorkspaceId)??S.workspaces[0]??null}function Qn(x){El(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function Ui(x){if(!El(x.dataTransfer))return;x.preventDefault();const D=q6(It(n).state),P=xe.current+1;if(xe.current=P,!D){Bs({id:P,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Bs({id:P,status:"queued",fileCount:0,terminalId:D.id,message:"Preparing upload..."}),Ga(P,D.id,x.dataTransfer)}async function Ga(x,D,P){try{const ae=await Kk(P);if(ae.length===0)throw new Error("No files were found in the drop.");fn(x,{id:x,status:"queued",fileCount:ae.length,message:"Queued"},{terminalId:D,files:ae})}catch(ae){fn(x,{id:x,status:"failed",fileCount:0,message:ka(ae)},{terminalId:D})}finally{ai()}}async function Ss(x){const D=Nt.current.find(pe=>pe.id===x);if(!D?.terminalId||!D.files||D.files.length===0)return;const P=D.terminalId,ae=D.files,we=new AbortController;Wt.current=x,fn(x,{id:x,status:"uploading",fileCount:ae.length,loaded:0,total:null,percent:null},{terminalId:P,files:ae,abortController:we});try{const pe=await yC({terminalId:P,files:ae,signal:we.signal,onProgress:Zt=>{fn(x,{id:x,status:"uploading",fileCount:ae.length,loaded:Zt.loaded,total:Zt.total,percent:Zt.percent},{terminalId:P,files:ae,abortController:we})}}),Re=pe.failed>0?pe.uploaded>0?"partial":"failed":"success",Ze=pe.failed>0?V6(pe):void 0,rt={id:x,status:Re,fileCount:ae.length,response:pe};Ze&&(rt.message=Ze),fn(x,rt,{terminalId:P,files:ae})}catch(pe){fn(x,{id:x,status:"failed",fileCount:ae.length,message:we.signal.aborted?"Upload canceled.":ka(pe)},{terminalId:P,files:ae})}finally{Wt.current===x&&(Wt.current=null),ai()}}function ai(){if(Wt.current!==null)return;const x=Nt.current.find(D=>D.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&Ss(x.id)}function Bs(x){js(D=>[...D,x])}function fn(x,D,P={}){js(ae=>ae.map(we=>{if(we.id!==x)return we;const pe={...D},Re=P.terminalId??we.terminalId,Ze=P.files??we.files;return Re!==void 0&&(pe.terminalId=Re),Ze!==void 0&&(pe.files=Ze),P.abortController!==void 0&&(pe.abortController=P.abortController),pe}))}function js(x){const D=x(Nt.current);Nt.current=D,Dt(D)}function Rn(x){Nt.current.find(P=>P.id===x)?.abortController?.abort(),Wt.current===x&&(Wt.current=null),js(P=>P.filter(ae=>ae.id!==x)),ai()}function yi(){for(const x of Nt.current)x.abortController?.abort();Wt.current=null,js(()=>[])}function Yr(x){const D=Nt.current.find(P=>P.id===x);if(D){if(D.status==="queued"){Rn(x);return}D.abortController?.abort()}}function ar(x){const D=Nt.current.find(ae=>ae.id===x);if(!D?.terminalId||!D.files||D.files.length===0)return;const P=Mn(D);if(P.length===0){fn(x,{id:x,status:"failed",fileCount:D.fileCount,message:"No failed files are available to retry."},{terminalId:D.terminalId,files:D.files});return}fn(x,{id:x,status:"queued",fileCount:P.length,message:"Queued"},{terminalId:D.terminalId,files:P}),ai()}function Mn(x){const D=x.files??[],P="response"in x?x.response:void 0;if(!P)return D;const ae=P.results.filter(Re=>Re.status==="failed").map(Re=>Re.relativePath);if(ae.length===0)return[];const we=new Map;for(const Re of D){const Ze=we.get(Re.relativePath)??[];Ze.push(Re),we.set(Re.relativePath,Ze)}const pe=[];for(const Re of ae){const rt=we.get(Re)?.shift();rt&&pe.push(rt)}return pe}function Is(x){const P=It(x.agentId).state.workspaces.find(ae=>ae.tabs.some(we=>we.id===x.tabId));P&&sr(x.agentId,P.id,x.tabId,xu(x.terminalId)),So(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),lC(x.agentId,x.terminalId),ln(x.agentId,n)||r?.(x.agentId),$t(null)}function zs(x){if(He.current=x,!ln(x.agentId,n)){r?r(x.agentId):He.current=null;return}Xr()}function Xr(){const x=He.current;if(!x||!ln(x.agentId,n)||!C.loaded)return;const D=It(x.agentId),P=H6(D.state,x.terminalId);He.current=null,P&&(sr(x.agentId,P.workspaceId,P.tabId,xu(x.terminalId)),So(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),lC(x.agentId,x.terminalId))}function or(x){const D=It(n).mutable.saveCoord;D.pendingLayoutSave=x,tu(x,y),D.saveTimer!==null&&window.clearTimeout(D.saveTimer),D.saveTimer=window.setTimeout(()=>{D.saveTimer=null;const P=D.pendingLayoutSave;D.pendingLayoutSave=null,P&&ws(P)},g6)}function Ps(){const x=It(n).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const D=x.pendingLayoutSave;x.pendingLayoutSave=null,D&&(tu(D,y),ws(D))}function ws(x,D={}){const P=It(n).mutable.saveCoord;P.nextPersistLayout=x,D.baseRevision!==void 0&&(P.queuedBaseRevision=D.baseRevision),!P.nextPersistQueued&&(P.nextPersistQueued=!0,P.persistChain=P.persistChain.then(async()=>{P.nextPersistQueued=!1;const ae=P.nextPersistLayout,we=P.queuedBaseRevision;P.nextPersistLayout=null,P.queuedBaseRevision=void 0,ae&&await Fi(ae,we!==void 0?{baseRevision:we}:{})}))}async function Fi(x,D={}){const P=It(n),ae=D.baseRevision??P.layoutRevision,we={layout:x,...typeof ae=="number"?{baseRevision:ae}:{}};try{const pe=await p.saveTerminalLayout(we),Re=pe.layout??x;eu(n,pe.revision,JSON.stringify(Re)),tu(Re,y);return}catch(pe){if(pe instanceof kn&&pe.status===400&&pe.message===FD){W6(n,y),xa(n,!0,HT());return}if(pe instanceof kn&&pe.status===409)try{const Re=await p.getTerminalLayout(),Ze=It(n).mutable.saveCoord;if(Ze.nextPersistLayout||Ze.pendingLayoutSave){const rt=Re.layout?JSON.stringify(Re.layout):It(n).lastPersistedLayoutJson;eu(n,Re.revision,rt);return}if(Re.layout){const rt=It(n).state,Zt=x_(Object.values(rt.terminals),void 0,Re.layout.workspaces,Re.layout.activeWorkspaceId),Wi=Kg(Zt);cC(n,Zt),eu(n,Re.revision,JSON.stringify(Wi)),tu(Wi,y)}else eu(n,Re.revision,P.lastPersistedLayoutJson);return}catch{}tu(x,y)}}const Jn=Z6(o),Ki=!K||U,es=Ki?Q:"servers";function Zl(x){const D=x.active?C:It(x.agentId),P=x.active?S:D.state,ae=x.active?C.loaded:D.loaded,we=x.active?A:D.error;return h.jsxs("div",{className:`workspace-list-panel${x.active?" workspace-list-panel--active-server":""}`,"aria-label":`${x.label} workspaces`,children:[h.jsxs("div",{className:"workspace-list-header",children:[h.jsx("span",{children:"Workspaces"}),h.jsx("button",{type:"button","aria-label":`New workspace on ${x.label}`,title:"New workspace",onClick:()=>qa(x.agentId),children:"+"})]}),ae?we?h.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(x.agentId),children:we}):h.jsx("div",{className:"workspace-list-items",children:P.workspaces.map(pe=>{const Re=x.active&&pe.id===de?.id,Ze=wf(pe).length,rt=j4(x.agentId,pe.id),Zt=M6(rt),Wi=x.active&&P.workspaces.length>1,hi=Te?.workspaceId===pe.id&&V!==pe.id?Te.placement:null;return h.jsxs(A6,{workspaceId:pe.id,active:Re,disabled:!x.active,reorderable:Wi,dragging:V===pe.id,dropPlacement:hi,working:rt.workingTerminalCount>0,unread:rt.unreadCompletionCount>0,children:[Wi?h.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":pe.id,title:"Drag to reorder","aria-label":`Reorder ${pe.title}`,"aria-grabbed":V===pe.id,onPointerDown:pn=>Vt(pe.id,pn),onPointerMove:Zn,onPointerUp:yn,onPointerCancel:Kr,onKeyDown:pn=>{(pn.key==="ArrowUp"||pn.key==="ArrowDown")&&(pn.preventDefault(),pn.stopPropagation(),Fr(pe.id,pn.key==="ArrowUp"?-1:1))},onClick:pn=>pn.stopPropagation(),children:"::"}):null,h.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Re?"page":void 0,title:pe.defaultCwd??void 0,onClick:()=>Gl(x.agentId,pe.id),onDoubleClick:()=>{x.active&&Xn(pe.id)},children:[h.jsxs("span",{className:"workspace-list-title-row",children:[h.jsx("span",{className:"workspace-list-name",children:pe.title}),rt.workingTerminalCount>0||rt.unreadCompletionCount>0?h.jsxs("span",{className:"workspace-list-attention",title:Zt,"aria-label":Zt,children:[rt.workingTerminalCount>0?h.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,rt.unreadCompletionCount>0?h.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:R6(rt.unreadCompletionCount)}):null]}):null]}),h.jsxs("small",{children:[pe.defaultCwd??"No folder"," · ",Ze," ",Ze===1?"session":"sessions"]})]}),x.active?h.jsxs("div",{className:"workspace-list-actions",children:[h.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${pe.title}`,title:"Edit workspace",onClick:()=>Xn(pe.id),children:"..."}),h.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${pe.title}`,title:"Delete workspace",disabled:P.workspaces.length<=1,onClick:()=>{vs(pe.id)},children:"x"})]}):null]},pe.id)})}):h.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(x.agentId),children:"Open server to load workspaces"})]})}function Za(x,D){ne({...x,provider:D})}function Qa(x,D){if(ln(x,n)){nt({type:"terminal.created",terminal:D});return}So(x,{type:"terminal.created",terminal:D}),r?.(x)}return h.jsx(BD,{sensors:kt,onDragStart:yt,onDragEnd:Qt,onDragCancel:ci,children:h.jsxs("main",{className:"terminal-shell","data-collapsed":K,"data-sidebar-open":U,onDragOver:Qn,onDrop:Ui,children:[h.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),h.jsxs("aside",{className:"workspace-sidebar",children:[h.jsxs("header",{className:"workspace-brand",children:[h.jsxs("div",{className:"workspace-brand-lockup",children:[Ki?h.jsx(kC,{height:20}):h.jsx(xC,{size:24}),c&&Ki?h.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),h.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":K?"Expand sidebar":"Collapse sidebar",title:K?"Expand sidebar":"Collapse sidebar",onClick:()=>se(x=>!x),children:K?">":"<"}),h.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),h.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${es==="files"?"files":"servers"}`,children:[Ki?h.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[h.jsx("button",{type:"button",role:"tab","aria-selected":Q==="servers",onClick:()=>{z("servers")},children:"Workspaces"}),h.jsx("button",{type:"button",role:"tab","aria-selected":Q==="files",onClick:()=>{z("files")},children:"Files"})]}):null,es==="servers"&&Ki?h.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:h.jsx(kw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:W,onServerLabelsChange:di,onManageAccounts:Za,renderServerChildren:Zl})}):null,Ki?null:h.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:h.jsx(kw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:W,onServerLabelsChange:di,compact:!0})}),es==="files"?h.jsx(GM,{api:p,activeTerminalId:tt,activeTerminalCwd:Ge?.cwd??null,workspaceRootPath:tt?null:de?.defaultCwd??null,onOpenFile:Ls},`${n??"local"}:${de?.id??"no-workspace"}`):null]}),h.jsxs("div",{className:"workspace-sidebar-footer",children:[Ki?h.jsx("span",{children:Jn}):null,h.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[h.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ie(!0),children:[h.jsx(gC,{name:"settings"}),G.hasUpdates?h.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Ki?h.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{$r()},children:h.jsx(gC,{name:"logout"})}):null]})]})]}),_e?h.jsx(WM,{api:g,onClose:()=>ie(!1),updateAvailable:G.hasUpdates,onNotificationAssetsChanged:()=>{ri()},onAgentRemoved:Hr}):null,ke?h.jsx(sM,{provider:ke.provider,serverLabel:ke.label,api:X,onClose:()=>ne(null),onLoginStarted:x=>Qa(ke.agentId,x)}):null,Ye?h.jsx(T6,{dialog:Ye,activePaneCwd:Ge?.cwd??null,activeWorkspaceCwd:de?.defaultCwd??null,onChange:Pt,onManualCwdChange:Ur,onBrowse:Gn,onCancel:ir,onSubmit:()=>{As()}}):null,h.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":ee?"true":void 0,children:[h.jsx(X4,{tabs:de?.tabs??[],activeTabId:de?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:mt,detachedTerminals:Pe,onSelectTab:x=>nt({type:"tab.selected",tabId:x}),onCreateTab:()=>{Ya()},onToggleWorkspaces:()=>Y(x=>!x),onCloseTerminals:x=>Oi(x),onReattachTerminal:x=>Xl(x),onDeleteTerminal:x=>{hn(x)},onSplitVertical:()=>{gs("vertical")},onSplitHorizontal:()=>{gs("horizontal")},onRenameTab:(x,D)=>{_s(x,D)},activePaneAvailable:!!tt}),ee?h.jsx(O6,{targets:ot,activeLeafKey:_i,terminals:S.terminals,editors:R,onSelect:Vr}):null,A?h.jsxs("div",{className:"workspace-error",role:"alert",children:[h.jsx("span",{children:A}),h.jsxs("div",{className:"workspace-error-actions",children:[h.jsx("button",{type:"button",onClick:Yl,children:"Retry"}),n!==null&&r?h.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,h.jsxs("section",{className:"workspace-body","aria-busy":B,children:[B?h.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!B&&!Ue?h.jsx(N6,{onCreate:()=>{Ya()}}):null,Ce.map(x=>{const D=ln(x,n);return h.jsx(y6,{agentId:x,serverName:ye[P_(x)]??(x===null?"Local":"Server"),active:D,activeServerApi:D?p:void 0,visitedTabKeys:Me,refreshCwdOnEnter:D,draggingTab:D?Mt:null,mobileSplitFocus:xt,mobileFocusedLeafByTabKey:Oe,onSelect:P=>{D&&Uo(P)},onClose:P=>{D&&Sn(P)},onCloseEditor:P=>{D&&Wr(P)},onResize:(P,ae)=>{D&&nt({type:"pane.resized",path:P,ratio:ae})},onExit:(P,ae)=>{D?nr({type:"terminal.exited",terminalId:P,exitCode:ae}):So(x,{type:"terminal.exited",terminalId:P,exitCode:ae})},onSnapshot:(P,ae)=>{const we={type:"terminal.updated",terminal:P,notifyCompletion:ae?.notifyCompletion===!0};D?nr(we):So(x,we)},...m?{onAuthClose:P=>m({...P,source:P?.source??"terminal-ws-1008",activeAgentId:x})}:{}},Zh(x))})]}),zt?h.jsx(L6,{label:zt.label,count:zt.terminalIds.length,warning:L,onCancel:()=>{M(null),xi(null)},onHide:()=>{Os(zt.terminalIds,zt.workspaceId)&&xi(null)},onDelete:()=>{const x=zt.terminalIds;M(null),xi(null),Xa(x)}}):null,h.jsx(o6,{toast:ui,onActivate:Is,onDismiss:()=>$t(null)}),h.jsx(e6,{uploads:lt,onDismiss:Rn,onDismissAll:yi,onRetry:ar,onCancel:Yr})]})]})})}function y6({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:y,onCloseEditor:b,onResize:w,onExit:C,onSnapshot:S,onAuthClose:R}){const B=v.useMemo(()=>ke=>AT(e,ke),[e]),A=v.useMemo(()=>()=>It(e),[e]),U=v.useSyncExternalStore(B,A,A),Y=v.useMemo(()=>ko(e),[e]),K=r??Y,se=U.state,Q=se.workspaces.find(ke=>ke.id===se.activeWorkspaceId)??se.workspaces[0],z=Q?.id??null,ie=(Q?.tabs.find(ke=>ke.id===Q.activeTabId)??Q?.tabs[0])?.id??null;return!U.loaded||se.workspaces.length===0?null:h.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:se.workspaces.flatMap(ke=>ke.tabs.map(ne=>{const X=n&&ke.id===z&&ne.id===ie,G=hu(e,ke.id,ne.id),q=Cf(ne.root),oe=m&&q.length>1?IT(q,ne.activeTerminalId,g[G]):null;return!X&&!o.has(G)?null:h.jsx("div",{className:"workspace-tab-surface","data-active":X,"aria-hidden":!X,children:h.jsx(S_,{node:ne.root,terminals:se.terminals,editors:U.editors,api:K,activeTerminalId:ne.activeTerminalId,visible:X,refreshCwdOnEnter:X&&c,tabId:ne.id,codeServerContext:{serverKey:P_(e),serverName:t,tabName:ne.title||se.terminals[ne.activeTerminalId]?.title||"Terminal"},dropZoneActive:X&&u!==null,draggingTerminalId:X?u?.terminalId??null:null,mobileFocusLeafKey:oe,onSelect:p,onClose:y,onCloseEditor:b,onResize:w,onExit:C,onSnapshot:S,...R?{onAuthClose:R}:{}})},ne.id)}))})}function S6(e){const t=wx(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=C6(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function w6(e,t,n){switch(n.type){case"pane.direction":return u6(e,t,n.direction);case"pane.index":return d6(e,n.index);default:return null}}function C6(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function x6(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function Cf(e){return e.type==="pane"?[{key:xu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:zT(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Cf(e.first),...Cf(e.second)]}function z_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...z_(e.first),...z_(e.second)]}function IT(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?xu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function xu(e){return`terminal:${e}`}function zT(e){return`editor:${e}`}function k6(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 T6({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(C=>C.kind==="directory"),y=e.submitStatus==="submitting";function b(C){r(S=>S&&{...S,...C})}function w(C){C&&(b({cwd:C,error:null}),c(C))}return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:h.jsxs("form",{className:"security-panel workspace-dialog",onClick:C=>C.stopPropagation(),onSubmit:C=>{C.preventDefault(),y||m()},children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),h.jsxs("section",{className:"workspace-dialog-body",children:[h.jsxs("label",{className:"workspace-dialog-field",children:[h.jsx("span",{children:"Name"}),h.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:C=>b({title:C.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),h.jsxs("label",{className:"workspace-dialog-field",children:[h.jsx("span",{children:"Default cwd"}),h.jsxs("div",{className:"workspace-dialog-path-row",children:[h.jsx("input",{value:e.cwd,disabled:y,onChange:C=>o(C.currentTarget.value),placeholder:"/home/user/project"}),h.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),h.jsxs("div",{className:"workspace-dialog-quick-actions",children:[h.jsx("button",{type:"button",onClick:()=>w(t),disabled:y||!t,children:"Use active pane"}),h.jsx("button",{type:"button",onClick:()=>w(n),disabled:y||!n,children:"Use current workspace"})]}),h.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[h.jsxs("div",{className:"workspace-dialog-browser-header",children:[h.jsx("span",{title:g,children:g||"No folder selected"}),h.jsx("button",{type:"button",onClick:()=>{c(D6(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?h.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?h.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?h.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(C=>h.jsxs("button",{type:"button","aria-label":`Choose folder ${C.name}`,disabled:y,onClick:()=>{c(E6(g,C.path))},children:[h.jsx("span",{children:C.name}),h.jsx("small",{children:C.path})]},C.path))}):null]}),e.error?h.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),h.jsxs("div",{className:"workspace-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),h.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function E6(e,t){return t?t.startsWith("/")?Gh(t):Gh(`${e||"/"}/${t}`):Gh(e)}function D6(e){const t=Gh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Gh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function R6(e){return e>99?"99+":String(e)}function M6(e){const t=[];return e.workingTerminalCount>0&&t.push(`${e.workingTerminalCount} ${e.workingTerminalCount===1?"pane is":"panes are"} working`),e.unreadCompletionCount>0&&t.push(`${e.unreadCompletionCount} unreviewed completion${e.unreadCompletionCount===1?"":"s"}`),t.join(" · ")}function N6({onCreate:e}){return h.jsxs("div",{className:"empty-workspace",children:[h.jsx("span",{children:"No terminal is open."}),h.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function A6({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,working:u=!1,unread:m=!1,children:g}){const{setNodeRef:p,isOver:y}=J_({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),b=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",u?"workspace-list-item--working":"",m?"workspace-list-item--unread":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return h.jsx("div",{ref:p,className:b,"data-workspace-id":e,"data-drop-over":y?"true":void 0,children:g})}function L6({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:h.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),h.jsxs("section",{className:"terminal-delete-dialog-body",children:[h.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),h.jsx("span",{children:e}),h.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?h.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),h.jsxs("div",{className:"terminal-delete-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),h.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function O6({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(w=>w.key===t):-1,g=m>=0?m:0,p=e[g]??e[0],y=mC(p,n,r);function b(w){const C=(g+w+e.length)%e.length,S=e[C];S&&o(S)}return h.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[h.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),h.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),h.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?h.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:h.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[h.jsxs("header",{children:[h.jsx("strong",{children:"Panes"}),h.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),h.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,C)=>{const S=mC(w,n,r),R=B6(w,n,r),B=w.key===p.key;return h.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(w),u(!1)},children:[h.jsx("span",{className:"mobile-pane-sheet-index",children:C+1}),h.jsxs("span",{className:"mobile-pane-sheet-copy",children:[h.jsx("strong",{children:S}),h.jsx("small",{children:R})]}),h.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function mC(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function B6(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function j6(e){const[t,n]=v.useState(()=>I6(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function I6(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function z6(){if(typeof window>"u")return null;const e=JD(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 P6(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Nf(t.focus)}function H6(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Li(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function ln(e,t){return e===t}function U6(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function Zh(e){return e??"__local__"}function hu(e,t,n){return`${Zh(e)}:${t}:${n}`}class xf extends Error{constructor(){super(HT())}}function F6(e){return e?{workspaceKey:`${fC}:${e}`}:{workspaceKey:fC}}function K6(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(VC(n))throw new xf;const r=qC(n);return r?PT(r):null}catch(n){if(n instanceof xf)throw n;return null}}function PT(e){if(VC(e))throw new xf;const t=qC(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function tu(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function W6(e,t){const n=It(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function $6(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Fl}. Re-open or delete hidden sessions before hiding more.`}function HT(){return`A saved terminal layout has more than ${Fl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function q6(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],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function V6(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function Y6(e){return e.split("/").filter(Boolean).pop()??e}function X6(){try{return localStorage.getItem(jT)==="true"}catch{return!1}}function G6(e){try{localStorage.setItem(jT,e?"true":"false")}catch{}}function P_(e){return e??Yi}function qg(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function Z6(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 r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function gC({name:e}){return h.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h9"}),h.jsx("path",{d:"M17 7h3"}),h.jsx("circle",{cx:"15",cy:"7",r:"2"}),h.jsx("path",{d:"M4 12h3"}),h.jsx("path",{d:"M11 12h9"}),h.jsx("circle",{cx:"9",cy:"12",r:"2"}),h.jsx("path",{d:"M4 17h9"}),h.jsx("path",{d:"M17 17h3"}),h.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M10 6H6v12h4"}),h.jsx("path",{d:"M13 8l4 4-4 4"}),h.jsx("path",{d:"M8 12h9"})]}):null]})}function ka(e){return e instanceof Error?e.message:"Request failed"}function Q6({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[w,C]=v.useState(null);v.useEffect(()=>{let R=!1;return e.setupTotp().then(B=>{R||(r(B.qrDataUrl),c(B.secret))}).catch(B=>{R||C(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{R=!0}},[e]);async function S(R){if(R.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(B){b(B instanceof Error?B.message:"Verification failed")}finally{p(!1)}}}return w?h.jsx("p",{className:"form-error",children:w}):!n||!o?h.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):h.jsxs("div",{className:"totp-setup",children:[h.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."}),h.jsx("div",{className:"totp-qr-container",children:h.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),h.jsxs("details",{className:"totp-secret-details",children:[h.jsx("summary",{children:"Can't scan? Enter manually"}),h.jsx("p",{className:"totp-secret-text",children:o})]}),h.jsxs("form",{className:"auth-form",onSubmit:S,children:[h.jsxs("label",{children:["Verification code",h.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:R=>m(R.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?h.jsx("p",{className:"form-error",children:y}):null,h.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function J6(e){return{source:Vg(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Vg(e.terminalId)}:{},...e?.detail?{detail:Vg(e.detail)}:{}}}function ej(e){return{invalidationSource:e.source}}function tj(e){vn("auth.session_invalid.request",UT(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),tb("session-invalid-request").catch(()=>{}))}function ij(e,t){vn("auth.session_invalid.result",{...UT(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),tb("session-invalid-result").catch(()=>{}))}function UT(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 Vg(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function nj({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??kf(),[e]),c=v.useMemo(()=>t??ko(null),[t]),[u,m]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(U=>{A||(m(U),p(null))}).catch(U=>{A||(p(Ro(U)),m(null))}),()=>{A=!0}},[o]);const w=oj(u);v.useEffect(()=>{const A=b.current;vn("auth.view",{view:w,previousView:A,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),A==="workspace"&&w!=="workspace"&&tb(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[u,w]);async function C(){const A=await o.getSession();m(A),p(null)}async function S(){jg(),$g(),A1(),L1(),p(null),m(null);try{await C()}catch(A){p(Ro(A))}}function R(A){const U=J6(A);if(tj(U),y.current)return y.current;const Y=(async()=>{p(null);try{const K=await o.getSession(ej(U));if(ij(U,K.authenticated),m(K),K.authenticated){y5();return}jg(),$g(),A1(),L1()}catch(K){p(Ro(K))}finally{y.current=null}})();return y.current=Y,Y}if(w==="workspace")return h.jsx(b6,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:A=>{R(A)},onLogout:async()=>{jg(),$g();const A=await o.logout();m(A)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return h.jsxs("main",{className:"auth-screen",children:[h.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[h.jsx("div",{className:"auth-grid"}),h.jsx("div",{className:"auth-glow"})]}),h.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[h.jsxs("header",{className:"auth-header",children:[h.jsxs("div",{className:"auth-brand",children:[h.jsx(xC,{size:26}),h.jsxs("div",{children:[h.jsx(kC,{height:17}),h.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),h.jsx("h1",{children:B[w]})]}),g?h.jsx("p",{className:"form-error",children:g}):null,w==="loading"?h.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{S()},children:"Retry"}):null,w==="setup_password"?h.jsx(sj,{api:o,onSession:A=>{m(A)}}):null,w==="setup_totp"?h.jsx(Q6,{api:o,onDone:()=>{C()}}):null,w==="login"?h.jsx(rj,{api:o,session:u,onSession:m,onRefresh:C}):null,w==="reauth"?h.jsx(aj,{api:o,session:u,onSession:m,onFullLogin:()=>m(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function sj({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,m]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),m(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(w){p(Ro(w))}finally{m(!1)}}return h.jsxs("form",{className:"auth-form",onSubmit:y,children:[h.jsxs("label",{children:["Password",h.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),h.jsxs("label",{children:["Confirm password",h.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?h.jsx("p",{className:"form-error",children:g}):null,h.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function rj({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[w,C]=v.useState(null),S=t?.totpEnabled??!1,R=t?.currentIpWhitelisted??!1;async function B(A){A.preventDefault(),b(!0),C(null);try{n(await e.login({password:o,...S?{otp:u}:{},rememberNetwork:g}))}catch(U){C(Ro(U))}finally{b(!1)}}return h.jsxs("form",{className:"auth-form",onSubmit:B,children:[h.jsxs("label",{children:["Password",h.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),S?h.jsxs("label",{children:["Authenticator code",h.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:A=>m(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,R?null:h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:g,onChange:A=>p(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?h.jsx("p",{className:"form-error",children:w}):null,h.jsxs("div",{className:"button-row",children:[h.jsx("button",{type:"submit",disabled:y||o.length===0||S&&u.length!==6,children:"Unlock"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function aj({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[m,g]=v.useState(!1),[p,y]=v.useState(!1),[b,w]=v.useState(!1),[C,S]=v.useState(!1),[R,B]=v.useState(null),A=Ni.useCallback(async(Y,K)=>{y(!0),B(null);try{n(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:K}))}catch(se){B(Ro(se))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let Y=!1;w(!0),S(!1),B(null);const K=window.setTimeout(()=>{Y||S(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(se=>{Y||n(se)}).catch(se=>{Y||(B(Ro(se)),S(!0))}).finally(()=>{window.clearTimeout(K),Y||w(!1)}),()=>{Y=!0,window.clearTimeout(K)}}},[e,o,n]);async function U(Y){Y.preventDefault(),await A(c,m)}return o&&b&&!C&&!R?h.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):h.jsxs("form",{className:"auth-form",onSubmit:U,children:[o&&C&&!R?h.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,h.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),h.jsxs("label",{children:["Authenticator code",h.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>u(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:m,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),R?h.jsx("p",{className:"form-error",children:R}):null,h.jsxs("div",{className:"button-row",children:[h.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function oj(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 vC="NTerminal",H_="nterminal.activeAgentId";function lj(){const[e,t]=v.useState(()=>cj()),n=v.useMemo(()=>kf(),[]),r=v.useMemo(()=>ko(e),[e]);v.useEffect(()=>{const c=()=>{const u=K4();document.title=u>0?`(${u}) ${vC}`:vC};return c(),F4(c)},[]);function o(c){uj(c),t(c)}return h.jsx(nj,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function cj(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(H_);return e&&e.trim()?e:null}catch{return null}}function uj(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(H_,e);return}window.localStorage.removeItem(H_)}catch{}}const _C=["gesturestart","gesturechange","gestureend"],dj=[".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 hj(e=window){if(!pj(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const u=c.touches;!u||u.length===0||(u.length>1||!fj(c.target))&&r(c)}for(const c of _C)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of _C)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function fj(e){return e instanceof Element&&e.closest(dj)!==null}function pj(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}rR();q3();hj();$_();p2.createRoot(document.getElementById("root")).render(h.jsx(Ni.StrictMode,{children:h.jsx(lj,{})}));export{Ni as R,r2 as g,h as j};
|