nterminal 1.2.66 → 1.2.67

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.
Files changed (36) hide show
  1. package/dist/client/assets/MarkdownPreview-BDn9o2c8.js +1 -0
  2. package/dist/client/assets/{TranscriptMarkdownBody-Ct0CseQH.js → TranscriptMarkdownBody-BHQbyM6J.js} +1 -1
  3. package/dist/client/assets/{index-DC8H8aYn.js → index-BXCYmdDY.js} +1 -1
  4. package/dist/client/assets/index-BgvJmNhz.js +55 -0
  5. package/dist/client/assets/index-Br4cNNw1.css +1 -0
  6. package/dist/client/index.html +2 -2
  7. package/dist/server/agent/agentRoutes.js +13 -1
  8. package/dist/server/agent/agentRoutes.js.map +1 -1
  9. package/dist/server/config.d.ts +2 -0
  10. package/dist/server/config.js +10 -0
  11. package/dist/server/config.js.map +1 -1
  12. package/dist/server/index.js +4 -2
  13. package/dist/server/index.js.map +1 -1
  14. package/dist/server/routes/agentManagementRoutes.js +5 -0
  15. package/dist/server/routes/agentManagementRoutes.js.map +1 -1
  16. package/dist/server/routes/authRoutes.js +8 -5
  17. package/dist/server/routes/authRoutes.js.map +1 -1
  18. package/dist/server/routes/terminalWebSocket.js +13 -1
  19. package/dist/server/routes/terminalWebSocket.js.map +1 -1
  20. package/dist/server/routes/updateRoutes.js +3 -0
  21. package/dist/server/routes/updateRoutes.js.map +1 -1
  22. package/dist/server/terminal/PtyAdapter.d.ts +2 -0
  23. package/dist/server/terminal/TerminalManager.d.ts +7 -1
  24. package/dist/server/terminal/TerminalManager.js +29 -4
  25. package/dist/server/terminal/TerminalManager.js.map +1 -1
  26. package/dist/server/terminal/TmuxPtyAdapter.d.ts +6 -0
  27. package/dist/server/terminal/TmuxPtyAdapter.js +87 -0
  28. package/dist/server/terminal/TmuxPtyAdapter.js.map +1 -1
  29. package/dist/shared/protocol.d.ts +8 -0
  30. package/dist/shared/protocol.js +27 -6
  31. package/dist/shared/protocol.js.map +1 -1
  32. package/dist/shared/types.d.ts +4 -0
  33. package/package.json +1 -1
  34. package/dist/client/assets/MarkdownPreview-BBxs32JK.js +0 -1
  35. package/dist/client/assets/index-CCAlcWtm.js +0 -55
  36. package/dist/client/assets/index-fCHYZN40.css +0 -1
@@ -1,55 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-BBxs32JK.js","assets/index-DC8H8aYn.js","assets/TranscriptMarkdownBody-Ct0CseQH.js"])))=>i.map(i=>d[i]);
2
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(o){if(o.ep)return;o.ep=!0;const c=r(o);fetch(o.href,c)}})();function sE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mf={exports:{}},vo={};var lb;function aE(){if(lb)return vo;lb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,o,c){var h=null;if(c!==void 0&&(h=""+c),o.key!==void 0&&(h=""+o.key),"key"in o){c={};for(var p in o)p!=="key"&&(c[p]=o[p])}else c=o;return o=c.ref,{$$typeof:e,type:s,key:h,ref:o!==void 0?o:null,props:c}}return vo.Fragment=t,vo.jsx=r,vo.jsxs=r,vo}var ob;function lE(){return ob||(ob=1,Mf.exports=aE()),Mf.exports}var m=lE(),Nf={exports:{}},Ze={};var cb;function oE(){if(cb)return Ze;cb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=S&&R[S]||R["@@iterator"],typeof R=="function"?R:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,B={};function L(R,G,se){this.props=R,this.context=G,this.refs=B,this.updater=se||k}L.prototype.isReactComponent={},L.prototype.setState=function(R,G){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,G,"setState")},L.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function A(){}A.prototype=L.prototype;function W(R,G,se){this.props=R,this.context=G,this.refs=B,this.updater=se||k}var K=W.prototype=new A;K.constructor=W,T(K,L.prototype),K.isPureReactComponent=!0;var J=Array.isArray;function ne(){}var le={H:null,A:null,T:null,S:null},oe=Object.prototype.hasOwnProperty;function ve(R,G,se){var _e=se.ref;return{$$typeof:e,type:R,key:G,ref:_e!==void 0?_e:null,props:se}}function P(R,G){return ve(R.type,G,R.props)}function I(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function F(R){var G={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(se){return G[se]})}var H=/\/+/g;function j(R,G){return typeof R=="object"&&R!==null&&R.key!=null?F(""+R.key):G.toString(36)}function re(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(ne,ne):(R.status="pending",R.then(function(G){R.status==="pending"&&(R.status="fulfilled",R.value=G)},function(G){R.status==="pending"&&(R.status="rejected",R.reason=G)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function M(R,G,se,_e,fe){var we=typeof R;(we==="undefined"||we==="boolean")&&(R=null);var Ne=!1;if(R===null)Ne=!0;else switch(we){case"bigint":case"string":case"number":Ne=!0;break;case"object":switch(R.$$typeof){case e:case t:Ne=!0;break;case b:return Ne=R._init,M(Ne(R._payload),G,se,_e,fe)}}if(Ne)return fe=fe(R),Ne=_e===""?"."+j(R,0):_e,J(fe)?(se="",Ne!=null&&(se=Ne.replace(H,"$&/")+"/"),M(fe,G,se,"",function(ee){return ee})):fe!=null&&(I(fe)&&(fe=P(fe,se+(fe.key==null||R&&R.key===fe.key?"":(""+fe.key).replace(H,"$&/")+"/")+Ne)),G.push(fe)),1;Ne=0;var je=_e===""?".":_e+":";if(J(R))for(var Ve=0;Ve<R.length;Ve++)_e=R[Ve],we=je+j(_e,Ve),Ne+=M(_e,G,se,we,fe);else if(Ve=w(R),typeof Ve=="function")for(R=Ve.call(R),Ve=0;!(_e=R.next()).done;)_e=_e.value,we=je+j(_e,Ve++),Ne+=M(_e,G,se,we,fe);else if(we==="object"){if(typeof R.then=="function")return M(re(R),G,se,_e,fe);throw G=String(R),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return Ne}function V(R,G,se){if(R==null)return R;var _e=[],fe=0;return M(R,_e,"","",function(we){return G.call(se,we,fe++)}),_e}function Z(R){if(R._status===-1){var G=R._result;G=G(),G.then(function(se){(R._status===0||R._status===-1)&&(R._status=1,R._result=se)},function(se){(R._status===0||R._status===-1)&&(R._status=2,R._result=se)}),R._status===-1&&(R._status=0,R._result=G)}if(R._status===1)return R._result.default;throw R._result}var Ce=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},ke={map:V,forEach:function(R,G,se){V(R,function(){G.apply(this,arguments)},se)},count:function(R){var G=0;return V(R,function(){G++}),G},toArray:function(R){return V(R,function(G){return G})||[]},only:function(R){if(!I(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ze.Activity=y,Ze.Children=ke,Ze.Component=L,Ze.Fragment=r,Ze.Profiler=o,Ze.PureComponent=W,Ze.StrictMode=s,Ze.Suspense=g,Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=le,Ze.__COMPILER_RUNTIME={__proto__:null,c:function(R){return le.H.useMemoCache(R)}},Ze.cache=function(R){return function(){return R.apply(null,arguments)}},Ze.cacheSignal=function(){return null},Ze.cloneElement=function(R,G,se){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var _e=T({},R.props),fe=R.key;if(G!=null)for(we in G.key!==void 0&&(fe=""+G.key),G)!oe.call(G,we)||we==="key"||we==="__self"||we==="__source"||we==="ref"&&G.ref===void 0||(_e[we]=G[we]);var we=arguments.length-2;if(we===1)_e.children=se;else if(1<we){for(var Ne=Array(we),je=0;je<we;je++)Ne[je]=arguments[je+2];_e.children=Ne}return ve(R.type,fe,_e)},Ze.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},Ze.createElement=function(R,G,se){var _e,fe={},we=null;if(G!=null)for(_e in G.key!==void 0&&(we=""+G.key),G)oe.call(G,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(fe[_e]=G[_e]);var Ne=arguments.length-2;if(Ne===1)fe.children=se;else if(1<Ne){for(var je=Array(Ne),Ve=0;Ve<Ne;Ve++)je[Ve]=arguments[Ve+2];fe.children=je}if(R&&R.defaultProps)for(_e in Ne=R.defaultProps,Ne)fe[_e]===void 0&&(fe[_e]=Ne[_e]);return ve(R,we,fe)},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(R){return{$$typeof:p,render:R}},Ze.isValidElement=I,Ze.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:Z}},Ze.memo=function(R,G){return{$$typeof:f,type:R,compare:G===void 0?null:G}},Ze.startTransition=function(R){var G=le.T,se={};le.T=se;try{var _e=R(),fe=le.S;fe!==null&&fe(se,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(ne,Ce)}catch(we){Ce(we)}finally{G!==null&&se.types!==null&&(G.types=se.types),le.T=G}},Ze.unstable_useCacheRefresh=function(){return le.H.useCacheRefresh()},Ze.use=function(R){return le.H.use(R)},Ze.useActionState=function(R,G,se){return le.H.useActionState(R,G,se)},Ze.useCallback=function(R,G){return le.H.useCallback(R,G)},Ze.useContext=function(R){return le.H.useContext(R)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(R,G){return le.H.useDeferredValue(R,G)},Ze.useEffect=function(R,G){return le.H.useEffect(R,G)},Ze.useEffectEvent=function(R){return le.H.useEffectEvent(R)},Ze.useId=function(){return le.H.useId()},Ze.useImperativeHandle=function(R,G,se){return le.H.useImperativeHandle(R,G,se)},Ze.useInsertionEffect=function(R,G){return le.H.useInsertionEffect(R,G)},Ze.useLayoutEffect=function(R,G){return le.H.useLayoutEffect(R,G)},Ze.useMemo=function(R,G){return le.H.useMemo(R,G)},Ze.useOptimistic=function(R,G){return le.H.useOptimistic(R,G)},Ze.useReducer=function(R,G,se){return le.H.useReducer(R,G,se)},Ze.useRef=function(R){return le.H.useRef(R)},Ze.useState=function(R){return le.H.useState(R)},Ze.useSyncExternalStore=function(R,G,se){return le.H.useSyncExternalStore(R,G,se)},Ze.useTransition=function(){return le.H.useTransition()},Ze.version="19.2.6",Ze}var ub;function Hm(){return ub||(ub=1,Nf.exports=oE()),Nf.exports}var v=Hm();const Ti=sE(v);var Af={exports:{}},yo={},Lf={exports:{}},Bf={};var hb;function cE(){return hb||(hb=1,(function(e){function t(M,V){var Z=M.length;M.push(V);e:for(;0<Z;){var Ce=Z-1>>>1,ke=M[Ce];if(0<o(ke,V))M[Ce]=V,M[Z]=ke,Z=Ce;else break e}}function r(M){return M.length===0?null:M[0]}function s(M){if(M.length===0)return null;var V=M[0],Z=M.pop();if(Z!==V){M[0]=Z;e:for(var Ce=0,ke=M.length,R=ke>>>1;Ce<R;){var G=2*(Ce+1)-1,se=M[G],_e=G+1,fe=M[_e];if(0>o(se,Z))_e<ke&&0>o(fe,se)?(M[Ce]=fe,M[_e]=Z,Ce=_e):(M[Ce]=se,M[G]=Z,Ce=G);else if(_e<ke&&0>o(fe,Z))M[Ce]=fe,M[_e]=Z,Ce=_e;else break e}}return V}function o(M,V){var Z=M.sortIndex-V.sortIndex;return Z!==0?Z:M.id-V.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 h=Date,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],b=1,y=null,S=3,w=!1,k=!1,T=!1,B=!1,L=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,W=typeof setImmediate<"u"?setImmediate:null;function K(M){for(var V=r(f);V!==null;){if(V.callback===null)s(f);else if(V.startTime<=M)s(f),V.sortIndex=V.expirationTime,t(g,V);else break;V=r(f)}}function J(M){if(T=!1,K(M),!k)if(r(g)!==null)k=!0,ne||(ne=!0,F());else{var V=r(f);V!==null&&re(J,V.startTime-M)}}var ne=!1,le=-1,oe=5,ve=-1;function P(){return B?!0:!(e.unstable_now()-ve<oe)}function I(){if(B=!1,ne){var M=e.unstable_now();ve=M;var V=!0;try{e:{k=!1,T&&(T=!1,A(le),le=-1),w=!0;var Z=S;try{t:{for(K(M),y=r(g);y!==null&&!(y.expirationTime>M&&P());){var Ce=y.callback;if(typeof Ce=="function"){y.callback=null,S=y.priorityLevel;var ke=Ce(y.expirationTime<=M);if(M=e.unstable_now(),typeof ke=="function"){y.callback=ke,K(M),V=!0;break t}y===r(g)&&s(g),K(M)}else s(g);y=r(g)}if(y!==null)V=!0;else{var R=r(f);R!==null&&re(J,R.startTime-M),V=!1}}break e}finally{y=null,S=Z,w=!1}V=void 0}}finally{V?F():ne=!1}}}var F;if(typeof W=="function")F=function(){W(I)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=I,F=function(){j.postMessage(null)}}else F=function(){L(I,0)};function re(M,V){le=L(function(){M(e.unstable_now())},V)}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(M){M.callback=null},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):oe=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(M){switch(S){case 1:case 2:case 3:var V=3;break;default:V=S}var Z=S;S=V;try{return M()}finally{S=Z}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(M,V){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var Z=S;S=M;try{return V()}finally{S=Z}},e.unstable_scheduleCallback=function(M,V,Z){var Ce=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Ce+Z:Ce):Z=Ce,M){case 1:var ke=-1;break;case 2:ke=250;break;case 5:ke=1073741823;break;case 4:ke=1e4;break;default:ke=5e3}return ke=Z+ke,M={id:b++,callback:V,priorityLevel:M,startTime:Z,expirationTime:ke,sortIndex:-1},Z>Ce?(M.sortIndex=Z,t(f,M),r(g)===null&&M===r(f)&&(T?(A(le),le=-1):T=!0,re(J,Z-Ce))):(M.sortIndex=ke,t(g,M),k||w||(k=!0,ne||(ne=!0,F()))),M},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(M){var V=S;return function(){var Z=S;S=V;try{return M.apply(this,arguments)}finally{S=Z}}}})(Bf)),Bf}var db;function uE(){return db||(db=1,Lf.exports=cE()),Lf.exports}var Of={exports:{}},Qi={};var fb;function hE(){if(fb)return Qi;fb=1;var e=Hm();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var s={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:g,containerInfo:f,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Qi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,Qi.createPortal=function(g,f){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,b)},Qi.flushSync=function(g){var f=h.T,b=s.p;try{if(h.T=null,s.p=2,g)return g()}finally{h.T=f,s.p=b,s.d.f()}},Qi.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},Qi.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},Qi.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:w}):b==="script"&&s.d.X(g,{crossOrigin:y,integrity:S,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Qi.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},Qi.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);s.d.L(g,b,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Qi.preloadModule=function(g,f){if(typeof g=="string")if(f){var b=p(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},Qi.requestFormReset=function(g){s.d.r(g)},Qi.unstable_batchedUpdates=function(g,f){return g(f)},Qi.useFormState=function(g,f,b){return h.H.useFormState(g,f,b)},Qi.useFormStatus=function(){return h.H.useHostTransitionStatus()},Qi.version="19.2.6",Qi}var pb;function _0(){if(pb)return Of.exports;pb=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(),Of.exports=hE(),Of.exports}var mb;function dE(){if(mb)return yo;mb=1;var e=uE(),t=Hm(),r=_0();function s(i){var n="https://react.dev/errors/"+i;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+n+" 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 n=i,a=i;if(i.alternate)for(;n.return;)n=n.return;else{i=n;do n=i,(n.flags&4098)!==0&&(a=n.return),i=n.return;while(i)}return n.tag===3?a:null}function h(i){if(i.tag===13){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function p(i){if(i.tag===31){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(s(188));return n!==i?null:i}for(var a=i,l=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===l)return g(u),n;d=d.sibling}throw Error(s(188))}if(a.return!==l.return)a=u,l=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,l=d;break}if(C===l){_=!0,l=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,l=u;break}if(C===l){_=!0,l=d,a=u;break}C=C.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==l)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:n}function b(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=b(i),n!==null)return n;i=i.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),W=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),oe=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function F(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var H=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===H?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case L:return"Profiler";case B:return"StrictMode";case J:return"Suspense";case ne:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case k:return"Portal";case W:return i.displayName||"Context";case A:return(i._context.displayName||"Context")+".Consumer";case K:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case le:return n=i.displayName||null,n!==null?n:j(i.type)||"Memo";case oe:n=i._payload,i=i._init;try{return j(i(n))}catch{}}return null}var re=Array.isArray,M=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Ce=[],ke=-1;function R(i){return{current:i}}function G(i){0>ke||(i.current=Ce[ke],Ce[ke]=null,ke--)}function se(i,n){ke++,Ce[ke]=i.current,i.current=n}var _e=R(null),fe=R(null),we=R(null),Ne=R(null);function je(i,n){switch(se(we,n),se(fe,i),se(_e,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?My(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=My(n),i=Ny(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}G(_e),se(_e,i)}function Ve(){G(_e),G(fe),G(we)}function ee(i){i.memoizedState!==null&&se(Ne,i);var n=_e.current,a=Ny(n,i.type);n!==a&&(se(fe,i),se(_e,a))}function me(i){fe.current===i&&(G(_e),G(fe)),Ne.current===i&&(G(Ne),po._currentValue=Z)}var De,be;function Re(i){if(De===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);De=n&&n[1]||"",be=-1<a.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+De+i+be}var ze=!1;function Ke(i,n){if(!i||ze)return"";ze=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(Q){var X=Q}Reflect.construct(i,[],he)}else{try{he.call()}catch(Q){X=Q}i.call(he.prototype)}}else{try{throw Error()}catch(Q){X=Q}(he=i())&&typeof he.catch=="function"&&he.catch(function(){})}}catch(Q){if(Q&&X&&typeof Q.stack=="string")return[Q.stack,X.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=l.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var N=_.split(`
5
- `),$=C.split(`
6
- `);for(u=l=0;l<N.length&&!N[l].includes("DetermineComponentFrameRoot");)l++;for(;u<$.length&&!$[u].includes("DetermineComponentFrameRoot");)u++;if(l===N.length||u===$.length)for(l=N.length-1,u=$.length-1;1<=l&&0<=u&&N[l]!==$[u];)u--;for(;1<=l&&0<=u;l--,u--)if(N[l]!==$[u]){if(l!==1||u!==1)do if(l--,u--,0>u||N[l]!==$[u]){var ae=`
7
- `+N[l].replace(" at new "," at ");return i.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",i.displayName)),ae}while(1<=l&&0<=u);break}}}finally{ze=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Re(a):""}function ce(i,n){switch(i.tag){case 26:case 27:case 5:return Re(i.type);case 16:return Re("Lazy");case 13:return i.child!==n&&n!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return Ke(i.type,!1);case 11:return Ke(i.type.render,!1);case 1:return Ke(i.type,!0);case 31:return Re("Activity");default:return""}}function xe(i){try{var n="",a=null;do n+=ce(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
8
- Error generating stack: `+l.message+`
9
- `+l.stack}}var Le=Object.prototype.hasOwnProperty,Ae=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,Y=e.unstable_shouldYield,Te=e.unstable_requestPaint,He=e.unstable_now,vt=e.unstable_getCurrentPriorityLevel,yi=e.unstable_ImmediatePriority,Ri=e.unstable_UserBlockingPriority,ge=e.unstable_NormalPriority,We=e.unstable_LowPriority,dt=e.unstable_IdlePriority,rt=e.log,Ft=e.unstable_setDisableYieldValue,zt=null,ii=null;function qt(i){if(typeof rt=="function"&&Ft(i),ii&&typeof ii.setStrictMode=="function")try{ii.setStrictMode(zt,i)}catch{}}var gt=Math.clz32?Math.clz32:Qn,Yi=Math.log,gn=Math.LN2;function Qn(i){return i>>>=0,i===0?32:31-(Yi(i)/gn|0)|0}var Mt=256,Ii=262144,yt=4194304;function bt(i){var n=i&42;if(n!==0)return n;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Et(i,n,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=l&134217727;return C!==0?(l=C&~d,l!==0?u=bt(l):(_&=C,_!==0?u=bt(_):a||(a=C&~i,a!==0&&(u=bt(a))))):(C=l&~d,C!==0?u=bt(C):_!==0?u=bt(_):a||(a=l&~i,a!==0&&(u=bt(a)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,a=n&-n,d>=a||d===32&&(a&4194048)!==0)?n:u}function Mi(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function ui(i,n){switch(i){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 Xt(){var i=yt;return yt<<=1,(yt&62914560)===0&&(yt=4194304),i}function hi(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function bi(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ut(i,n,a,l,u,d){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 C=i.entanglements,N=i.expirationTimes,$=i.hiddenUpdates;for(a=_&~a;0<a;){var ae=31-gt(a),he=1<<ae;C[ae]=0,N[ae]=-1;var X=$[ae];if(X!==null)for($[ae]=null,ae=0;ae<X.length;ae++){var Q=X[ae];Q!==null&&(Q.lane&=-536870913)}a&=~he}l!==0&&Ni(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function Ni(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-gt(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ni(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-gt(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function Si(i,n){var a=n&-n;return a=(a&42)!==0?1:_n(a),(a&(i.suspendedLanes|n))!==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 en(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function tn(){var i=V.p;return i!==0?i:(i=window.event,i===void 0?32:eb(i.type))}function vn(i,n){var a=V.p;try{return V.p=i,n()}finally{V.p=a}}var Xi=Math.random().toString(36).slice(2),$t="__reactFiber$"+Xi,wi="__reactProps$"+Xi,Ln="__reactContainer$"+Xi,Is="__reactEvents$"+Xi,Nl="__reactListeners$"+Xi,Qr="__reactHandles$"+Xi,Da="__reactResources$"+Xi,Bn="__reactMarker$"+Xi;function On(i){delete i[$t],delete i[wi],delete i[Is],delete i[Nl],delete i[Qr]}function zn(i){var n=i[$t];if(n)return n;for(var a=i.parentNode;a;){if(n=a[Ln]||a[$t]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=Hy(i);i!==null;){if(a=i[$t])return a;i=Hy(i)}return n}i=a,a=i.parentNode}return null}function Bt(i){if(i=i[$t]||i[Ln]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function Jn(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(s(33))}function yn(i){var n=i[Da];return n||(n=i[Da]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Ot(i){i[Bn]=!0}var di=new Set,Ra={};function bn(i,n){er(i,n),er(i+"Capture",n)}function er(i,n){for(Ra[i]=n,i=0;i<n.length;i++)di.add(n[i])}var Ma=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]*$"),Na={},Ks={};function tr(i){return Le.call(Ks,i)?!0:Le.call(Na,i)?!1:Ma.test(i)?Ks[i]=!0:(Na[i]=!0,!1)}function hr(i,n,a){if(tr(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function dr(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function ln(i,n,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(n,a,""+l)}}function ri(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Jr(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function st(i,n,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,d=l.set;return Object.defineProperty(i,n,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,n,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function ir(i){if(!i._valueTracker){var n=Jr(i)?"checked":"value";i._valueTracker=st(i,n,""+i[n])}}function Er(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=Jr(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function kr(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 Ws=/[\n"\\]/g;function Gi(i){return i.replace(Ws,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function es(i,n,a,l,u,d,_,C){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),n!=null?_==="number"?(n===0&&i.value===""||i.value!=n)&&(i.value=""+ri(n)):i.value!==""+ri(n)&&(i.value=""+ri(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?qs(i,_,ri(n)):a!=null?qs(i,_,ri(a)):l!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+ri(C):i.removeAttribute("name")}function Fs(i,n,a,l,u,d,_,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),n!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){ir(i);return}a=a!=null?""+ri(a):"",n=n!=null?""+ri(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=C?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),ir(i)}function qs(i,n,a){n==="number"&&kr(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function fr(i,n,a,l){if(i=i.options,n){n={};for(var u=0;u<a.length;u++)n["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=n.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+ri(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function ts(i,n,a){if(n!=null&&(n=""+ri(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+ri(a):""}function nr(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(s(92));if(re(l)){if(1<l.length)throw Error(s(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=ri(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),ir(i)}function pr(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Al=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 Aa(i,n,a){var l=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":l?i.setProperty(n,a):typeof a!="number"||a===0||Al.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Zi(i,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in n)l=n[u],n.hasOwnProperty(u)&&a[u]!==l&&Aa(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&Aa(i,d,n[d])}function is(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 jn=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"]]),Tr=/^[\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 Dr(i){return Tr.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function D(){}var te=null;function Ue(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var $e=null,Ye=null;function tt(i){var n=Bt(i);if(n&&(i=n.stateNode)){var a=i[wi]||null;e:switch(i=n.stateNode,n.type){case"input":if(es(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Gi(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[wi]||null;if(!u)throw Error(s(90));es(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)l=a[n],l.form===i.form&&Er(l)}break e;case"textarea":ts(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&fr(i,!!a.multiple,n,!1)}}}var It=!1;function si(i,n,a){if(It)return i(n,a);It=!0;try{var l=i(n);return l}finally{if(It=!1,($e!==null||Ye!==null)&&(Zc(),$e&&(n=$e,i=Ye,Ye=$e=null,tt(n),i)))for(n=0;n<i.length;n++)tt(i[n])}}function St(i,n){var a=i.stateNode;if(a===null)return null;var l=a[wi]||null;if(l===null)return null;a=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var wt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ki=!1;if(wt)try{var Gt={};Object.defineProperty(Gt,"passive",{get:function(){Ki=!0}}),window.addEventListener("test",Gt,Gt),window.removeEventListener("test",Gt,Gt)}catch{Ki=!1}var Sn=null,x=null,E=null;function z(){if(E)return E;var i,n=x,a=n.length,l,u="value"in Sn?Sn.value:Sn.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&n[a-l]===u[d-l];l++);return E=u.slice(i,1<l?1-l:void 0)}function ie(i){var n=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&n===13&&(i=13)):i=n,i===10&&(i=13),32<=i||i===13?i:0}function ye(){return!0}function pe(){return!1}function Se(i){function n(a,l,u,d,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(a=i[C],this[C]=a?a(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?ye:pe,this.isPropagationStopped=pe,this}return y(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ye)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ye)},persist:function(){},isPersistent:ye}),n}var Fe={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},at=Se(Fe),Zt=y({},Fe,{view:0,detail:0}),ai=Se(Zt),La,Ah,Ll,mc=y({},Zt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bh,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!==Ll&&(Ll&&i.type==="mousemove"?(La=i.screenX-Ll.screenX,Ah=i.screenY-Ll.screenY):Ah=La=0,Ll=i),La)},movementY:function(i){return"movementY"in i?i.movementY:Ah}}),Lg=Se(mc),rC=y({},mc,{dataTransfer:0}),sC=Se(rC),aC=y({},Zt,{relatedTarget:0}),Lh=Se(aC),lC=y({},Fe,{animationName:0,elapsedTime:0,pseudoElement:0}),oC=Se(lC),cC=y({},Fe,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),uC=Se(cC),hC=y({},Fe,{data:0}),Bg=Se(hC),dC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fC={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"},pC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=pC[i])?!!n[i]:!1}function Bh(){return mC}var gC=y({},Zt,{key:function(i){if(i.key){var n=dC[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=ie(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?fC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bh,charCode:function(i){return i.type==="keypress"?ie(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ie(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),_C=Se(gC),vC=y({},mc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Og=Se(vC),yC=y({},Zt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bh}),bC=Se(yC),SC=y({},Fe,{propertyName:0,elapsedTime:0,pseudoElement:0}),wC=Se(SC),CC=y({},mc,{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}),xC=Se(CC),EC=y({},Fe,{newState:0,oldState:0}),kC=Se(EC),TC=[9,13,27,32],Oh=wt&&"CompositionEvent"in window,Bl=null;wt&&"documentMode"in document&&(Bl=document.documentMode);var DC=wt&&"TextEvent"in window&&!Bl,zg=wt&&(!Oh||Bl&&8<Bl&&11>=Bl),jg=" ",Hg=!1;function Pg(i,n){switch(i){case"keyup":return TC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ug(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ba=!1;function RC(i,n){switch(i){case"compositionend":return Ug(n);case"keypress":return n.which!==32?null:(Hg=!0,jg);case"textInput":return i=n.data,i===jg&&Hg?null:i;default:return null}}function MC(i,n){if(Ba)return i==="compositionend"||!Oh&&Pg(i,n)?(i=z(),E=x=Sn=null,Ba=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return zg&&n.locale!=="ko"?null:n.data;default:return null}}var NC={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 Ig(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!NC[i.type]:n==="textarea"}function Kg(i,n,a,l){$e?Ye?Ye.push(l):Ye=[l]:$e=l,n=ru(n,"onChange"),0<n.length&&(a=new at("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var Ol=null,zl=null;function AC(i){xy(i,0)}function gc(i){var n=Jn(i);if(Er(n))return i}function Wg(i,n){if(i==="change")return n}var Fg=!1;if(wt){var zh;if(wt){var jh="oninput"in document;if(!jh){var qg=document.createElement("div");qg.setAttribute("oninput","return;"),jh=typeof qg.oninput=="function"}zh=jh}else zh=!1;Fg=zh&&(!document.documentMode||9<document.documentMode)}function $g(){Ol&&(Ol.detachEvent("onpropertychange",Vg),zl=Ol=null)}function Vg(i){if(i.propertyName==="value"&&gc(zl)){var n=[];Kg(n,zl,i,Ue(i)),si(AC,n)}}function LC(i,n,a){i==="focusin"?($g(),Ol=n,zl=a,Ol.attachEvent("onpropertychange",Vg)):i==="focusout"&&$g()}function BC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return gc(zl)}function OC(i,n){if(i==="click")return gc(n)}function zC(i,n){if(i==="input"||i==="change")return gc(n)}function jC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var wn=typeof Object.is=="function"?Object.is:jC;function jl(i,n){if(wn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),l=Object.keys(n);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!Le.call(n,u)||!wn(i[u],n[u]))return!1}return!0}function Yg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Xg(i,n){var a=Yg(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=n&&l>=n)return{node:a,offset:n-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Yg(a)}}function Gg(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?Gg(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function Zg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=kr(i.document);n instanceof i.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)i=n.contentWindow;else break;n=kr(i.document)}return n}function Hh(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n&&(n==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||n==="textarea"||i.contentEditable==="true")}var HC=wt&&"documentMode"in document&&11>=document.documentMode,Oa=null,Ph=null,Hl=null,Uh=!1;function Qg(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Uh||Oa==null||Oa!==kr(l)||(l=Oa,"selectionStart"in l&&Hh(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}),Hl&&jl(Hl,l)||(Hl=l,l=ru(Ph,"onSelect"),0<l.length&&(n=new at("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=Oa)))}function $s(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var za={animationend:$s("Animation","AnimationEnd"),animationiteration:$s("Animation","AnimationIteration"),animationstart:$s("Animation","AnimationStart"),transitionrun:$s("Transition","TransitionRun"),transitionstart:$s("Transition","TransitionStart"),transitioncancel:$s("Transition","TransitionCancel"),transitionend:$s("Transition","TransitionEnd")},Ih={},Jg={};wt&&(Jg=document.createElement("div").style,"AnimationEvent"in window||(delete za.animationend.animation,delete za.animationiteration.animation,delete za.animationstart.animation),"TransitionEvent"in window||delete za.transitionend.transition);function Vs(i){if(Ih[i])return Ih[i];if(!za[i])return i;var n=za[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in Jg)return Ih[i]=n[a];return i}var e_=Vs("animationend"),t_=Vs("animationiteration"),i_=Vs("animationstart"),PC=Vs("transitionrun"),UC=Vs("transitionstart"),IC=Vs("transitioncancel"),n_=Vs("transitionend"),r_=new Map,Kh="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(" ");Kh.push("scrollEnd");function rr(i,n){r_.set(i,n),bn(n,[i])}var _c=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Hn=[],ja=0,Wh=0;function vc(){for(var i=ja,n=Wh=ja=0;n<i;){var a=Hn[n];Hn[n++]=null;var l=Hn[n];Hn[n++]=null;var u=Hn[n];Hn[n++]=null;var d=Hn[n];if(Hn[n++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}d!==0&&s_(a,u,d)}}function yc(i,n,a,l){Hn[ja++]=i,Hn[ja++]=n,Hn[ja++]=a,Hn[ja++]=l,Wh|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Fh(i,n,a,l){return yc(i,n,a,l),bc(i)}function Ys(i,n){return yc(i,null,null,n),bc(i)}function s_(i,n,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,l=d.alternate,l!==null&&(l.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&n!==null&&(u=31-gt(a),i=d.hiddenUpdates,l=i[u],l===null?i[u]=[n]:l.push(n),n.lane=a|536870912),d):null}function bc(i){if(50<ao)throw ao=0,Jd=null,Error(s(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var Ha={};function KC(i,n,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=n,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 Cn(i,n,a,l){return new KC(i,n,a,l)}function qh(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Rr(i,n){var a=i.alternate;return a===null?(a=Cn(i.tag,n,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=n,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,n=i.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function a_(i,n){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=n,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,n=a.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),i}function Sc(i,n,a,l,u,d){var _=0;if(l=i,typeof i=="function")qh(i)&&(_=1);else if(typeof i=="string")_=Vx(i,a,_e.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=Cn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case T:return Xs(a.children,u,d,n);case B:_=8,u|=24;break;case L:return i=Cn(12,a,n,u|2),i.elementType=L,i.lanes=d,i;case J:return i=Cn(13,a,n,u),i.elementType=J,i.lanes=d,i;case ne:return i=Cn(19,a,n,u),i.elementType=ne,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case W:_=10;break e;case A:_=9;break e;case K:_=11;break e;case le:_=14;break e;case oe:_=16,l=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),l=null}return n=Cn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function Xs(i,n,a,l){return i=Cn(7,i,l,n),i.lanes=a,i}function $h(i,n,a){return i=Cn(6,i,null,n),i.lanes=a,i}function l_(i){var n=Cn(18,null,null,0);return n.stateNode=i,n}function Vh(i,n,a){return n=Cn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var o_=new WeakMap;function Pn(i,n){if(typeof i=="object"&&i!==null){var a=o_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:xe(n)},o_.set(i,n),n)}return{value:i,source:n,stack:xe(n)}}var Pa=[],Ua=0,wc=null,Pl=0,Un=[],In=0,ns=null,mr=1,gr="";function Mr(i,n){Pa[Ua++]=Pl,Pa[Ua++]=wc,wc=i,Pl=n}function c_(i,n,a){Un[In++]=mr,Un[In++]=gr,Un[In++]=ns,ns=i;var l=mr;i=gr;var u=32-gt(l)-1;l&=~(1<<u),a+=1;var d=32-gt(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,mr=1<<32-gt(n)+u|a<<u|l,gr=d+i}else mr=1<<d|a<<u|l,gr=i}function Yh(i){i.return!==null&&(Mr(i,1),c_(i,1,0))}function Xh(i){for(;i===wc;)wc=Pa[--Ua],Pa[Ua]=null,Pl=Pa[--Ua],Pa[Ua]=null;for(;i===ns;)ns=Un[--In],Un[In]=null,gr=Un[--In],Un[In]=null,mr=Un[--In],Un[In]=null}function u_(i,n){Un[In++]=mr,Un[In++]=gr,Un[In++]=ns,mr=n.id,gr=n.overflow,ns=i}var Wi=null,jt=null,ft=!1,rs=null,Kn=!1,Gh=Error(s(519));function ss(i){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ul(Pn(n,i)),Gh}function h_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[$t]=i,n[wi]=l,a){case"dialog":ot("cancel",n),ot("close",n);break;case"iframe":case"object":case"embed":ot("load",n);break;case"video":case"audio":for(a=0;a<oo.length;a++)ot(oo[a],n);break;case"source":ot("error",n);break;case"img":case"image":case"link":ot("error",n),ot("load",n);break;case"details":ot("toggle",n);break;case"input":ot("invalid",n),Fs(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ot("invalid",n);break;case"textarea":ot("invalid",n),nr(n,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||l.suppressHydrationWarning===!0||Dy(n.textContent,a)?(l.popover!=null&&(ot("beforetoggle",n),ot("toggle",n)),l.onScroll!=null&&ot("scroll",n),l.onScrollEnd!=null&&ot("scrollend",n),l.onClick!=null&&(n.onclick=D),n=!0):n=!1,n||ss(i,!0)}function d_(i){for(Wi=i.return;Wi;)switch(Wi.tag){case 5:case 31:case 13:Kn=!1;return;case 27:case 3:Kn=!0;return;default:Wi=Wi.return}}function Ia(i){if(i!==Wi)return!1;if(!ft)return d_(i),ft=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||mf(i.type,i.memoizedProps)),a=!a),a&&jt&&ss(i),d_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));jt=jy(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));jt=jy(i)}else n===27?(n=jt,ys(i.type)?(i=bf,bf=null,jt=i):jt=n):jt=Wi?Fn(i.stateNode.nextSibling):null;return!0}function Gs(){jt=Wi=null,ft=!1}function Zh(){var i=rs;return i!==null&&(hn===null?hn=i:hn.push.apply(hn,i),rs=null),i}function Ul(i){rs===null?rs=[i]:rs.push(i)}var Qh=R(null),Zs=null,Nr=null;function as(i,n,a){se(Qh,n._currentValue),n._currentValue=a}function Ar(i){i._currentValue=Qh.current,G(Qh)}function Jh(i,n,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),i===a)break;i=i.return}}function ed(i,n,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=u;for(var N=0;N<n.length;N++)if(C.context===n[N]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),Jh(d.return,a,i),l||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),Jh(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function Ka(i,n,a,l){i=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var C=u.type;wn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Ne.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(po):i=[po])}u=u.return}i!==null&&ed(n,i,a,l),n.flags|=262144}function Cc(i){for(i=i.firstContext;i!==null;){if(!wn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Qs(i){Zs=i,Nr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Fi(i){return f_(Zs,i)}function xc(i,n){return Zs===null&&Qs(i),f_(i,n)}function f_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Nr===null){if(i===null)throw Error(s(308));Nr=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Nr=Nr.next=n;return a}var WC=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},FC=e.unstable_scheduleCallback,qC=e.unstable_NormalPriority,fi={$$typeof:W,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function td(){return{controller:new WC,data:new Map,refCount:0}}function Il(i){i.refCount--,i.refCount===0&&FC(qC,function(){i.controller.abort()})}var Kl=null,id=0,Wa=0,Fa=null;function $C(i,n){if(Kl===null){var a=Kl=[];id=0,Wa=af(),Fa={status:"pending",value:void 0,then:function(l){a.push(l)}}}return id++,n.then(p_,p_),n}function p_(){if(--id===0&&Kl!==null){Fa!==null&&(Fa.status="fulfilled");var i=Kl;Kl=null,Wa=0,Fa=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function VC(i,n){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var m_=M.S;M.S=function(i,n){Qv=He(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&$C(i,n),m_!==null&&m_(i,n)};var Js=R(null);function nd(){var i=Js.current;return i!==null?i:Nt.pooledCache}function Ec(i,n){n===null?se(Js,Js.current):se(Js,n.pool)}function g_(){var i=nd();return i===null?null:{parent:fi._currentValue,pool:i}}var qa=Error(s(460)),rd=Error(s(474)),kc=Error(s(542)),Tc={then:function(){}};function __(i){return i=i.status,i==="fulfilled"||i==="rejected"}function v_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(D,D),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,b_(i),i;default:if(typeof n.status=="string")n.then(D,D);else{if(i=Nt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=n,i.status="pending",i.then(function(l){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=l}},function(l){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,b_(i),i}throw ta=n,qa}}function ea(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ta=a,qa):a}}var ta=null;function y_(){if(ta===null)throw Error(s(459));var i=ta;return ta=null,i}function b_(i){if(i===qa||i===kc)throw Error(s(483))}var $a=null,Wl=0;function Dc(i){var n=Wl;return Wl+=1,$a===null&&($a=[]),v_($a,i,n)}function Fl(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Rc(i,n){throw n.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(n),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function S_(i){function n(U,O){if(i){var q=U.deletions;q===null?(U.deletions=[O],U.flags|=16):q.push(O)}}function a(U,O){if(!i)return null;for(;O!==null;)n(U,O),O=O.sibling;return null}function l(U){for(var O=new Map;U!==null;)U.key!==null?O.set(U.key,U):O.set(U.index,U),U=U.sibling;return O}function u(U,O){return U=Rr(U,O),U.index=0,U.sibling=null,U}function d(U,O,q){return U.index=q,i?(q=U.alternate,q!==null?(q=q.index,q<O?(U.flags|=67108866,O):q):(U.flags|=67108866,O)):(U.flags|=1048576,O)}function _(U){return i&&U.alternate===null&&(U.flags|=67108866),U}function C(U,O,q,ue){return O===null||O.tag!==6?(O=$h(q,U.mode,ue),O.return=U,O):(O=u(O,q),O.return=U,O)}function N(U,O,q,ue){var qe=q.type;return qe===T?ae(U,O,q.props.children,ue,q.key):O!==null&&(O.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===oe&&ea(qe)===O.type)?(O=u(O,q.props),Fl(O,q),O.return=U,O):(O=Sc(q.type,q.key,q.props,null,U.mode,ue),Fl(O,q),O.return=U,O)}function $(U,O,q,ue){return O===null||O.tag!==4||O.stateNode.containerInfo!==q.containerInfo||O.stateNode.implementation!==q.implementation?(O=Vh(q,U.mode,ue),O.return=U,O):(O=u(O,q.children||[]),O.return=U,O)}function ae(U,O,q,ue,qe){return O===null||O.tag!==7?(O=Xs(q,U.mode,ue,qe),O.return=U,O):(O=u(O,q),O.return=U,O)}function he(U,O,q){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=$h(""+O,U.mode,q),O.return=U,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case w:return q=Sc(O.type,O.key,O.props,null,U.mode,q),Fl(q,O),q.return=U,q;case k:return O=Vh(O,U.mode,q),O.return=U,O;case oe:return O=ea(O),he(U,O,q)}if(re(O)||F(O))return O=Xs(O,U.mode,q,null),O.return=U,O;if(typeof O.then=="function")return he(U,Dc(O),q);if(O.$$typeof===W)return he(U,xc(U,O),q);Rc(U,O)}return null}function X(U,O,q,ue){var qe=O!==null?O.key:null;if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return qe!==null?null:C(U,O,""+q,ue);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case w:return q.key===qe?N(U,O,q,ue):null;case k:return q.key===qe?$(U,O,q,ue):null;case oe:return q=ea(q),X(U,O,q,ue)}if(re(q)||F(q))return qe!==null?null:ae(U,O,q,ue,null);if(typeof q.then=="function")return X(U,O,Dc(q),ue);if(q.$$typeof===W)return X(U,O,xc(U,q),ue);Rc(U,q)}return null}function Q(U,O,q,ue,qe){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return U=U.get(q)||null,C(O,U,""+ue,qe);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case w:return U=U.get(ue.key===null?q:ue.key)||null,N(O,U,ue,qe);case k:return U=U.get(ue.key===null?q:ue.key)||null,$(O,U,ue,qe);case oe:return ue=ea(ue),Q(U,O,q,ue,qe)}if(re(ue)||F(ue))return U=U.get(q)||null,ae(O,U,ue,qe,null);if(typeof ue.then=="function")return Q(U,O,q,Dc(ue),qe);if(ue.$$typeof===W)return Q(U,O,q,xc(O,ue),qe);Rc(O,ue)}return null}function Be(U,O,q,ue){for(var qe=null,pt=null,Pe=O,Je=O=0,ht=null;Pe!==null&&Je<q.length;Je++){Pe.index>Je?(ht=Pe,Pe=null):ht=Pe.sibling;var mt=X(U,Pe,q[Je],ue);if(mt===null){Pe===null&&(Pe=ht);break}i&&Pe&&mt.alternate===null&&n(U,Pe),O=d(mt,O,Je),pt===null?qe=mt:pt.sibling=mt,pt=mt,Pe=ht}if(Je===q.length)return a(U,Pe),ft&&Mr(U,Je),qe;if(Pe===null){for(;Je<q.length;Je++)Pe=he(U,q[Je],ue),Pe!==null&&(O=d(Pe,O,Je),pt===null?qe=Pe:pt.sibling=Pe,pt=Pe);return ft&&Mr(U,Je),qe}for(Pe=l(Pe);Je<q.length;Je++)ht=Q(Pe,U,Je,q[Je],ue),ht!==null&&(i&&ht.alternate!==null&&Pe.delete(ht.key===null?Je:ht.key),O=d(ht,O,Je),pt===null?qe=ht:pt.sibling=ht,pt=ht);return i&&Pe.forEach(function(xs){return n(U,xs)}),ft&&Mr(U,Je),qe}function Xe(U,O,q,ue){if(q==null)throw Error(s(151));for(var qe=null,pt=null,Pe=O,Je=O=0,ht=null,mt=q.next();Pe!==null&&!mt.done;Je++,mt=q.next()){Pe.index>Je?(ht=Pe,Pe=null):ht=Pe.sibling;var xs=X(U,Pe,mt.value,ue);if(xs===null){Pe===null&&(Pe=ht);break}i&&Pe&&xs.alternate===null&&n(U,Pe),O=d(xs,O,Je),pt===null?qe=xs:pt.sibling=xs,pt=xs,Pe=ht}if(mt.done)return a(U,Pe),ft&&Mr(U,Je),qe;if(Pe===null){for(;!mt.done;Je++,mt=q.next())mt=he(U,mt.value,ue),mt!==null&&(O=d(mt,O,Je),pt===null?qe=mt:pt.sibling=mt,pt=mt);return ft&&Mr(U,Je),qe}for(Pe=l(Pe);!mt.done;Je++,mt=q.next())mt=Q(Pe,U,Je,mt.value,ue),mt!==null&&(i&&mt.alternate!==null&&Pe.delete(mt.key===null?Je:mt.key),O=d(mt,O,Je),pt===null?qe=mt:pt.sibling=mt,pt=mt);return i&&Pe.forEach(function(rE){return n(U,rE)}),ft&&Mr(U,Je),qe}function Dt(U,O,q,ue){if(typeof q=="object"&&q!==null&&q.type===T&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case w:e:{for(var qe=q.key;O!==null;){if(O.key===qe){if(qe=q.type,qe===T){if(O.tag===7){a(U,O.sibling),ue=u(O,q.props.children),ue.return=U,U=ue;break e}}else if(O.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===oe&&ea(qe)===O.type){a(U,O.sibling),ue=u(O,q.props),Fl(ue,q),ue.return=U,U=ue;break e}a(U,O);break}else n(U,O);O=O.sibling}q.type===T?(ue=Xs(q.props.children,U.mode,ue,q.key),ue.return=U,U=ue):(ue=Sc(q.type,q.key,q.props,null,U.mode,ue),Fl(ue,q),ue.return=U,U=ue)}return _(U);case k:e:{for(qe=q.key;O!==null;){if(O.key===qe)if(O.tag===4&&O.stateNode.containerInfo===q.containerInfo&&O.stateNode.implementation===q.implementation){a(U,O.sibling),ue=u(O,q.children||[]),ue.return=U,U=ue;break e}else{a(U,O);break}else n(U,O);O=O.sibling}ue=Vh(q,U.mode,ue),ue.return=U,U=ue}return _(U);case oe:return q=ea(q),Dt(U,O,q,ue)}if(re(q))return Be(U,O,q,ue);if(F(q)){if(qe=F(q),typeof qe!="function")throw Error(s(150));return q=qe.call(q),Xe(U,O,q,ue)}if(typeof q.then=="function")return Dt(U,O,Dc(q),ue);if(q.$$typeof===W)return Dt(U,O,xc(U,q),ue);Rc(U,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,O!==null&&O.tag===6?(a(U,O.sibling),ue=u(O,q),ue.return=U,U=ue):(a(U,O),ue=$h(q,U.mode,ue),ue.return=U,U=ue),_(U)):a(U,O)}return function(U,O,q,ue){try{Wl=0;var qe=Dt(U,O,q,ue);return $a=null,qe}catch(Pe){if(Pe===qa||Pe===kc)throw Pe;var pt=Cn(29,Pe,null,U.mode);return pt.lanes=ue,pt.return=U,pt}}}var ia=S_(!0),w_=S_(!1),ls=!1;function sd(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ad(i,n){i=i.updateQueue,n.updateQueue===i&&(n.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function os(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function cs(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(_t&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,n=bc(i),s_(i,null,a),n}return yc(i,l,n,a),bc(i)}function ql(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ni(i,a)}}function ld(i,n){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=n:d=d.next=n}else u=d=n;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var od=!1;function $l(){if(od){var i=Fa;if(i!==null)throw i}}function Vl(i,n,a,l){od=!1;var u=i.updateQueue;ls=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var N=C,$=N.next;N.next=null,_===null?d=$:_.next=$,_=N;var ae=i.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==_&&(C===null?ae.firstBaseUpdate=$:C.next=$,ae.lastBaseUpdate=N))}if(d!==null){var he=u.baseState;_=0,ae=$=N=null,C=d;do{var X=C.lane&-536870913,Q=X!==C.lane;if(Q?(ut&X)===X:(l&X)===X){X!==0&&X===Wa&&(od=!0),ae!==null&&(ae=ae.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Be=i,Xe=C;X=n;var Dt=a;switch(Xe.tag){case 1:if(Be=Xe.payload,typeof Be=="function"){he=Be.call(Dt,he,X);break e}he=Be;break e;case 3:Be.flags=Be.flags&-65537|128;case 0:if(Be=Xe.payload,X=typeof Be=="function"?Be.call(Dt,he,X):Be,X==null)break e;he=y({},he,X);break e;case 2:ls=!0}}X=C.callback,X!==null&&(i.flags|=64,Q&&(i.flags|=8192),Q=u.callbacks,Q===null?u.callbacks=[X]:Q.push(X))}else Q={lane:X,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?($=ae=Q,N=he):ae=ae.next=Q,_|=X;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;Q=C,C=Q.next,Q.next=null,u.lastBaseUpdate=Q,u.shared.pending=null}}while(!0);ae===null&&(N=he),u.baseState=N,u.firstBaseUpdate=$,u.lastBaseUpdate=ae,d===null&&(u.shared.lanes=0),ps|=_,i.lanes=_,i.memoizedState=he}}function C_(i,n){if(typeof i!="function")throw Error(s(191,i));i.call(n)}function x_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)C_(a[i],n)}var Va=R(null),Mc=R(0);function E_(i,n){i=Ir,se(Mc,i),se(Va,n),Ir=i|n.baseLanes}function cd(){se(Mc,Ir),se(Va,Va.current)}function ud(){Ir=Mc.current,G(Va),G(Mc)}var xn=R(null),Wn=null;function us(i){var n=i.alternate;se(li,li.current&1),se(xn,i),Wn===null&&(n===null||Va.current!==null||n.memoizedState!==null)&&(Wn=i)}function hd(i){se(li,li.current),se(xn,i),Wn===null&&(Wn=i)}function k_(i){i.tag===22?(se(li,li.current),se(xn,i),Wn===null&&(Wn=i)):hs()}function hs(){se(li,li.current),se(xn,xn.current)}function En(i){G(xn),Wn===i&&(Wn=null),G(li)}var li=R(0);function Nc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||vf(a)||yf(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Lr=0,Qe=null,kt=null,pi=null,Ac=!1,Ya=!1,na=!1,Lc=0,Yl=0,Xa=null,YC=0;function Qt(){throw Error(s(321))}function dd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!wn(i[a],n[a]))return!1;return!0}function fd(i,n,a,l,u,d){return Lr=d,Qe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,M.H=i===null||i.memoizedState===null?cv:Dd,na=!1,d=a(l,u),na=!1,Ya&&(d=D_(n,a,l,u)),T_(i),d}function T_(i){M.H=Zl;var n=kt!==null&&kt.next!==null;if(Lr=0,pi=kt=Qe=null,Ac=!1,Yl=0,Xa=null,n)throw Error(s(300));i===null||mi||(i=i.dependencies,i!==null&&Cc(i)&&(mi=!0))}function D_(i,n,a,l){Qe=i;var u=0;do{if(Ya&&(Xa=null),Yl=0,Ya=!1,25<=u)throw Error(s(301));if(u+=1,pi=kt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}M.H=uv,d=n(a,l)}while(Ya);return d}function XC(){var i=M.H,n=i.useState()[0];return n=typeof n.then=="function"?Xl(n):n,i=i.useState()[0],(kt!==null?kt.memoizedState:null)!==i&&(Qe.flags|=1024),n}function pd(){var i=Lc!==0;return Lc=0,i}function md(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function gd(i){if(Ac){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Ac=!1}Lr=0,pi=kt=Qe=null,Ya=!1,Yl=Lc=0,Xa=null}function nn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return pi===null?Qe.memoizedState=pi=i:pi=pi.next=i,pi}function oi(){if(kt===null){var i=Qe.alternate;i=i!==null?i.memoizedState:null}else i=kt.next;var n=pi===null?Qe.memoizedState:pi.next;if(n!==null)pi=n,kt=i;else{if(i===null)throw Qe.alternate===null?Error(s(467)):Error(s(310));kt=i,i={memoizedState:kt.memoizedState,baseState:kt.baseState,baseQueue:kt.baseQueue,queue:kt.queue,next:null},pi===null?Qe.memoizedState=pi=i:pi=pi.next=i}return pi}function Bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xl(i){var n=Yl;return Yl+=1,Xa===null&&(Xa=[]),i=v_(Xa,i,n),n=Qe,(pi===null?n.memoizedState:pi.next)===null&&(n=n.alternate,M.H=n===null||n.memoizedState===null?cv:Dd),i}function Oc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Xl(i);if(i.$$typeof===W)return Fi(i)}throw Error(s(438,String(i)))}function _d(i){var n=null,a=Qe.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Qe.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=Bc(),Qe.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),l=0;l<i;l++)a[l]=P;return n.index++,a}function Br(i,n){return typeof n=="function"?n(i):n}function zc(i){var n=oi();return vd(n,kt,i)}function vd(i,n,a){var l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=a;var u=i.baseQueue,d=l.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,l.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,N=null,$=n,ae=!1;do{var he=$.lane&-536870913;if(he!==$.lane?(ut&he)===he:(Lr&he)===he){var X=$.revertLane;if(X===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),he===Wa&&(ae=!0);else if((Lr&X)===X){$=$.next,X===Wa&&(ae=!0);continue}else he={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},N===null?(C=N=he,_=d):N=N.next=he,Qe.lanes|=X,ps|=X;he=$.action,na&&a(d,he),d=$.hasEagerState?$.eagerState:a(d,he)}else X={lane:he,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},N===null?(C=N=X,_=d):N=N.next=X,Qe.lanes|=he,ps|=he;$=$.next}while($!==null&&$!==n);if(N===null?_=d:N.next=C,!wn(d,i.memoizedState)&&(mi=!0,ae&&(a=Fa,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,l.lastRenderedState=d}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function yd(i){var n=oi(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,d=n.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);wn(d,n.memoizedState)||(mi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function R_(i,n,a){var l=Qe,u=oi(),d=ft;if(d){if(a===void 0)throw Error(s(407));a=a()}else a=n();var _=!wn((kt||u).memoizedState,a);if(_&&(u.memoizedState=a,mi=!0),u=u.queue,wd(A_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||pi!==null&&pi.memoizedState.tag&1){if(l.flags|=2048,Ga(9,{destroy:void 0},N_.bind(null,l,u,a,n),null),Nt===null)throw Error(s(349));d||(Lr&127)!==0||M_(l,n,a)}return a}function M_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Qe.updateQueue,n===null?(n=Bc(),Qe.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function N_(i,n,a,l){n.value=a,n.getSnapshot=l,L_(n)&&B_(i)}function A_(i,n,a){return a(function(){L_(n)&&B_(i)})}function L_(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!wn(i,a)}catch{return!0}}function B_(i){var n=Ys(i,2);n!==null&&dn(n,i,2)}function bd(i){var n=nn();if(typeof i=="function"){var a=i;if(i=a(),na){qt(!0);try{a()}finally{qt(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:i},n}function O_(i,n,a,l){return i.baseState=a,vd(i,kt,typeof l=="function"?l:Br)}function GC(i,n,a,l,u){if(Pc(i))throw Error(s(485));if(i=n.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};M.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,z_(n,d)):(d.next=a.next,n.pending=a.next=d)}}function z_(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=M.T,_={};M.T=_;try{var C=a(u,l),N=M.S;N!==null&&N(_,C),j_(i,n,C)}catch($){Sd(i,n,$)}finally{d!==null&&_.types!==null&&(d.types=_.types),M.T=d}}else try{d=a(u,l),j_(i,n,d)}catch($){Sd(i,n,$)}}function j_(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){H_(i,n,l)},function(l){return Sd(i,n,l)}):H_(i,n,a)}function H_(i,n,a){n.status="fulfilled",n.value=a,P_(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,z_(i,a)))}function Sd(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,P_(n),n=n.next;while(n!==l)}i.action=null}function P_(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function U_(i,n){return n}function I_(i,n){if(ft){var a=Nt.formState;if(a!==null){e:{var l=Qe;if(ft){if(jt){t:{for(var u=jt,d=Kn;u.nodeType!==8;){if(!d){u=null;break t}if(u=Fn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){jt=Fn(u.nextSibling),l=u.data==="F!";break e}}ss(l)}l=!1}l&&(n=a[0])}}return a=nn(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:U_,lastRenderedState:n},a.queue=l,a=av.bind(null,Qe,l),l.dispatch=a,l=bd(!1),d=Td.bind(null,Qe,!1,l.queue),l=nn(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=GC.bind(null,Qe,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function K_(i){var n=oi();return W_(n,kt,i)}function W_(i,n,a){if(n=vd(i,n,U_)[0],i=zc(Br)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=Xl(n)}catch(_){throw _===qa?kc:_}else l=n;n=oi();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Qe.flags|=2048,Ga(9,{destroy:void 0},ZC.bind(null,u,a),null)),[l,d,i]}function ZC(i,n){i.action=n}function F_(i){var n=oi(),a=kt;if(a!==null)return W_(n,a,i);oi(),n=n.memoizedState,a=oi();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function Ga(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Qe.updateQueue,n===null&&(n=Bc(),Qe.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,n.lastEffect=i),i}function q_(){return oi().memoizedState}function jc(i,n,a,l){var u=nn();Qe.flags|=i,u.memoizedState=Ga(1|n,{destroy:void 0},a,l===void 0?null:l)}function Hc(i,n,a,l){var u=oi();l=l===void 0?null:l;var d=u.memoizedState.inst;kt!==null&&l!==null&&dd(l,kt.memoizedState.deps)?u.memoizedState=Ga(n,d,a,l):(Qe.flags|=i,u.memoizedState=Ga(1|n,d,a,l))}function $_(i,n){jc(8390656,8,i,n)}function wd(i,n){Hc(2048,8,i,n)}function QC(i){Qe.flags|=4;var n=Qe.updateQueue;if(n===null)n=Bc(),Qe.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function V_(i){var n=oi().memoizedState;return QC({ref:n,nextImpl:i}),function(){if((_t&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function Y_(i,n){return Hc(4,2,i,n)}function X_(i,n){return Hc(4,4,i,n)}function G_(i,n){if(typeof n=="function"){i=i();var a=n(i);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return i=i(),n.current=i,function(){n.current=null}}function Z_(i,n,a){a=a!=null?a.concat([i]):null,Hc(4,4,G_.bind(null,n,i),a)}function Cd(){}function Q_(i,n){var a=oi();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&dd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function J_(i,n){var a=oi();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&dd(n,l[1]))return l[0];if(l=i(),na){qt(!0);try{i()}finally{qt(!1)}}return a.memoizedState=[l,n],l}function xd(i,n,a){return a===void 0||(Lr&1073741824)!==0&&(ut&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=ey(),Qe.lanes|=i,ps|=i,a)}function ev(i,n,a,l){return wn(a,n)?a:Va.current!==null?(i=xd(i,a,l),wn(i,n)||(mi=!0),i):(Lr&42)===0||(Lr&1073741824)!==0&&(ut&261930)===0?(mi=!0,i.memoizedState=a):(i=ey(),Qe.lanes|=i,ps|=i,n)}function tv(i,n,a,l,u){var d=V.p;V.p=d!==0&&8>d?d:8;var _=M.T,C={};M.T=C,Td(i,!1,n,a);try{var N=u(),$=M.S;if($!==null&&$(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var ae=VC(N,l);Gl(i,n,ae,Dn(i))}else Gl(i,n,l,Dn(i))}catch(he){Gl(i,n,{then:function(){},status:"rejected",reason:he},Dn())}finally{V.p=d,_!==null&&C.types!==null&&(_.types=C.types),M.T=_}}function JC(){}function Ed(i,n,a,l){if(i.tag!==5)throw Error(s(476));var u=iv(i).queue;tv(i,u,n,Z,a===null?JC:function(){return nv(i),a(l)})}function iv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:Z},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function nv(i){var n=iv(i);n.next===null&&(n=i.alternate.memoizedState),Gl(i,n.next.queue,{},Dn())}function kd(){return Fi(po)}function rv(){return oi().memoizedState}function sv(){return oi().memoizedState}function ex(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Dn();i=os(a);var l=cs(n,i,a);l!==null&&(dn(l,n,a),ql(l,n,a)),n={cache:td()},i.payload=n;return}n=n.return}}function tx(i,n,a){var l=Dn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Pc(i)?lv(n,a):(a=Fh(i,n,a,l),a!==null&&(dn(a,i,l),ov(a,n,l)))}function av(i,n,a){var l=Dn();Gl(i,n,a,l)}function Gl(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Pc(i))lv(n,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var _=n.lastRenderedState,C=d(_,a);if(u.hasEagerState=!0,u.eagerState=C,wn(C,_))return yc(i,n,u,0),Nt===null&&vc(),!1}catch{}if(a=Fh(i,n,u,l),a!==null)return dn(a,i,l),ov(a,n,l),!0}return!1}function Td(i,n,a,l){if(l={lane:2,revertLane:af(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Pc(i)){if(n)throw Error(s(479))}else n=Fh(i,a,l,2),n!==null&&dn(n,i,2)}function Pc(i){var n=i.alternate;return i===Qe||n!==null&&n===Qe}function lv(i,n){Ya=Ac=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function ov(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ni(i,a)}}var Zl={readContext:Fi,use:Oc,useCallback:Qt,useContext:Qt,useEffect:Qt,useImperativeHandle:Qt,useLayoutEffect:Qt,useInsertionEffect:Qt,useMemo:Qt,useReducer:Qt,useRef:Qt,useState:Qt,useDebugValue:Qt,useDeferredValue:Qt,useTransition:Qt,useSyncExternalStore:Qt,useId:Qt,useHostTransitionStatus:Qt,useFormState:Qt,useActionState:Qt,useOptimistic:Qt,useMemoCache:Qt,useCacheRefresh:Qt};Zl.useEffectEvent=Qt;var cv={readContext:Fi,use:Oc,useCallback:function(i,n){return nn().memoizedState=[i,n===void 0?null:n],i},useContext:Fi,useEffect:$_,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,jc(4194308,4,G_.bind(null,n,i),a)},useLayoutEffect:function(i,n){return jc(4194308,4,i,n)},useInsertionEffect:function(i,n){jc(4,2,i,n)},useMemo:function(i,n){var a=nn();n=n===void 0?null:n;var l=i();if(na){qt(!0);try{i()}finally{qt(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=nn();if(a!==void 0){var u=a(n);if(na){qt(!0);try{a(n)}finally{qt(!1)}}}else u=n;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=tx.bind(null,Qe,i),[l.memoizedState,i]},useRef:function(i){var n=nn();return i={current:i},n.memoizedState=i},useState:function(i){i=bd(i);var n=i.queue,a=av.bind(null,Qe,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:Cd,useDeferredValue:function(i,n){var a=nn();return xd(a,i,n)},useTransition:function(){var i=bd(!1);return i=tv.bind(null,Qe,i.queue,!0,!1),nn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Qe,u=nn();if(ft){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),Nt===null)throw Error(s(349));(ut&127)!==0||M_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,$_(A_.bind(null,l,d,i),[i]),l.flags|=2048,Ga(9,{destroy:void 0},N_.bind(null,l,d,a,n),null),a},useId:function(){var i=nn(),n=Nt.identifierPrefix;if(ft){var a=gr,l=mr;a=(l&~(1<<32-gt(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Lc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=YC++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:kd,useFormState:I_,useActionState:I_,useOptimistic:function(i){var n=nn();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Td.bind(null,Qe,!0,a),a.dispatch=n,[i,n]},useMemoCache:_d,useCacheRefresh:function(){return nn().memoizedState=ex.bind(null,Qe)},useEffectEvent:function(i){var n=nn(),a={impl:i};return n.memoizedState=a,function(){if((_t&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Dd={readContext:Fi,use:Oc,useCallback:Q_,useContext:Fi,useEffect:wd,useImperativeHandle:Z_,useInsertionEffect:Y_,useLayoutEffect:X_,useMemo:J_,useReducer:zc,useRef:q_,useState:function(){return zc(Br)},useDebugValue:Cd,useDeferredValue:function(i,n){var a=oi();return ev(a,kt.memoizedState,i,n)},useTransition:function(){var i=zc(Br)[0],n=oi().memoizedState;return[typeof i=="boolean"?i:Xl(i),n]},useSyncExternalStore:R_,useId:rv,useHostTransitionStatus:kd,useFormState:K_,useActionState:K_,useOptimistic:function(i,n){var a=oi();return O_(a,kt,i,n)},useMemoCache:_d,useCacheRefresh:sv};Dd.useEffectEvent=V_;var uv={readContext:Fi,use:Oc,useCallback:Q_,useContext:Fi,useEffect:wd,useImperativeHandle:Z_,useInsertionEffect:Y_,useLayoutEffect:X_,useMemo:J_,useReducer:yd,useRef:q_,useState:function(){return yd(Br)},useDebugValue:Cd,useDeferredValue:function(i,n){var a=oi();return kt===null?xd(a,i,n):ev(a,kt.memoizedState,i,n)},useTransition:function(){var i=yd(Br)[0],n=oi().memoizedState;return[typeof i=="boolean"?i:Xl(i),n]},useSyncExternalStore:R_,useId:rv,useHostTransitionStatus:kd,useFormState:F_,useActionState:F_,useOptimistic:function(i,n){var a=oi();return kt!==null?O_(a,kt,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:_d,useCacheRefresh:sv};uv.useEffectEvent=V_;function Rd(i,n,a,l){n=i.memoizedState,a=a(l,n),a=a==null?n:y({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Md={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=os(l);u.payload=n,a!=null&&(u.callback=a),n=cs(i,u,l),n!==null&&(dn(n,i,l),ql(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=os(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=cs(i,u,l),n!==null&&(dn(n,i,l),ql(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Dn(),l=os(a);l.tag=2,n!=null&&(l.callback=n),n=cs(i,l,a),n!==null&&(dn(n,i,a),ql(n,i,a))}};function hv(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!jl(a,l)||!jl(u,d):!0}function dv(i,n,a,l){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,l),n.state!==i&&Md.enqueueReplaceState(n,n.state,null)}function ra(i,n){var a=n;if("ref"in n){a={};for(var l in n)l!=="ref"&&(a[l]=n[l])}if(i=i.defaultProps){a===n&&(a=y({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function fv(i){_c(i)}function pv(i){console.error(i)}function mv(i){_c(i)}function Uc(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function gv(i,n,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Nd(i,n,a){return a=os(a),a.tag=3,a.payload={element:null},a.callback=function(){Uc(i,n)},a}function _v(i){return i=os(i),i.tag=3,i}function vv(i,n,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=l.value;i.payload=function(){return u(d)},i.callback=function(){gv(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){gv(n,a,l),typeof u!="function"&&(ms===null?ms=new Set([this]):ms.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function ix(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&Ka(n,a,u,!0),a=xn.current,a!==null){switch(a.tag){case 31:case 13:return Wn===null?Qc():a.alternate===null&&Jt===0&&(Jt=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Tc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([l]):n.add(l),nf(i,l,u)),!1;case 22:return a.flags|=65536,l===Tc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([l]):a.add(l)),nf(i,l,u)),!1}throw Error(s(435,a.tag))}return nf(i,l,u),Qc(),!1}if(ft)return n=xn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==Gh&&(i=Error(s(422),{cause:l}),Ul(Pn(i,a)))):(l!==Gh&&(n=Error(s(423),{cause:l}),Ul(Pn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=Pn(l,a),u=Nd(i.stateNode,l,u),ld(i,u),Jt!==4&&(Jt=2)),!1;var d=Error(s(520),{cause:l});if(d=Pn(d,a),so===null?so=[d]:so.push(d),Jt!==4&&(Jt=2),n===null)return!0;l=Pn(l,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Nd(a.stateNode,l,i),ld(a,i),!1;case 1:if(n=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(ms===null||!ms.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=_v(u),vv(u,i,a,l),ld(a,u),!1}a=a.return}while(a!==null);return!1}var Ad=Error(s(461)),mi=!1;function qi(i,n,a,l){n.child=i===null?w_(n,null,a,l):ia(n,i.child,a,l)}function yv(i,n,a,l,u){a=a.render;var d=n.ref;if("ref"in l){var _={};for(var C in l)C!=="ref"&&(_[C]=l[C])}else _=l;return Qs(n),l=fd(i,n,a,_,d,u),C=pd(),i!==null&&!mi?(md(i,n,u),Or(i,n,u)):(ft&&C&&Yh(n),n.flags|=1,qi(i,n,l,u),n.child)}function bv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!qh(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Sv(i,n,d,l,u)):(i=Sc(a.type,null,l,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!Ud(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:jl,a(_,l)&&i.ref===n.ref)return Or(i,n,u)}return n.flags|=1,i=Rr(d,l),i.ref=n.ref,i.return=n,n.child=i}function Sv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(jl(d,l)&&i.ref===n.ref)if(mi=!1,n.pendingProps=l=d,Ud(i,u))(i.flags&131072)!==0&&(mi=!0);else return n.lanes=i.lanes,Or(i,n,u)}return Ld(i,n,a,l,u)}function wv(i,n,a,l){var u=l.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(l=n.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~d}else l=0,n.child=null;return Cv(i,n,d,a,l)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Ec(n,d!==null?d.cachePool:null),d!==null?E_(n,d):cd(),k_(n);else return l=n.lanes=536870912,Cv(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Ec(n,d.cachePool),E_(n,d),hs(),n.memoizedState=null):(i!==null&&Ec(n,null),cd(),hs());return qi(i,n,u,a),n.child}function Ql(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Cv(i,n,a,l,u){var d=nd();return d=d===null?null:{parent:fi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Ec(n,null),cd(),k_(n),i!==null&&Ka(i,n,l,!0),n.childLanes=u,null}function Ic(i,n){return n=Wc({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function xv(i,n,a){return ia(n,i.child,null,a),i=Ic(n,n.pendingProps),i.flags|=2,En(n),n.memoizedState=null,i}function nx(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(ft){if(l.mode==="hidden")return i=Ic(n,l),n.lanes=536870912,Ql(null,i);if(hd(n),(i=jt)?(i=zy(i,Kn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:ns!==null?{id:mr,overflow:gr}:null,retryLane:536870912,hydrationErrors:null},a=l_(i),a.return=n,n.child=a,Wi=n,jt=null)):i=null,i===null)throw ss(n);return n.lanes=536870912,null}return Ic(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(hd(n),u)if(n.flags&256)n.flags&=-257,n=xv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(s(558));else if(mi||Ka(i,n,a,!1),u=(a&i.childLanes)!==0,mi||u){if(l=Nt,l!==null&&(_=Si(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,Ys(i,_),dn(l,i,_),Ad;Qc(),n=xv(i,n,a)}else i=d.treeContext,jt=Fn(_.nextSibling),Wi=n,ft=!0,rs=null,Kn=!1,i!==null&&u_(n,i),n=Ic(n,l),n.flags|=4096;return n}return i=Rr(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function Kc(i,n){var a=n.ref;if(a===null)i!==null&&i.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function Ld(i,n,a,l,u){return Qs(n),a=fd(i,n,a,l,void 0,u),l=pd(),i!==null&&!mi?(md(i,n,u),Or(i,n,u)):(ft&&l&&Yh(n),n.flags|=1,qi(i,n,a,u),n.child)}function Ev(i,n,a,l,u,d){return Qs(n),n.updateQueue=null,a=D_(n,l,a,u),T_(i),l=pd(),i!==null&&!mi?(md(i,n,d),Or(i,n,d)):(ft&&l&&Yh(n),n.flags|=1,qi(i,n,a,d),n.child)}function kv(i,n,a,l,u){if(Qs(n),n.stateNode===null){var d=Ha,_=a.contextType;typeof _=="object"&&_!==null&&(d=Fi(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Md,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},sd(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Fi(_):Ha,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Rd(n,a,_,l),d.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&Md.enqueueReplaceState(d,d.state,null),Vl(n,l,d,u),$l(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,N=ra(a,C);d.props=N;var $=d.context,ae=a.contextType;_=Ha,typeof ae=="object"&&ae!==null&&(_=Fi(ae));var he=a.getDerivedStateFromProps;ae=typeof he=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,ae||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||$!==_)&&dv(n,d,l,_),ls=!1;var X=n.memoizedState;d.state=X,Vl(n,l,d,u),$l(),$=n.memoizedState,C||X!==$||ls?(typeof he=="function"&&(Rd(n,a,he,l),$=n.memoizedState),(N=ls||hv(n,a,N,l,X,$,_))?(ae||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=$),d.props=l,d.state=$,d.context=_,l=N):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,ad(i,n),_=n.memoizedProps,ae=ra(a,_),d.props=ae,he=n.pendingProps,X=d.context,$=a.contextType,N=Ha,typeof $=="object"&&$!==null&&(N=Fi($)),C=a.getDerivedStateFromProps,($=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==he||X!==N)&&dv(n,d,l,N),ls=!1,X=n.memoizedState,d.state=X,Vl(n,l,d,u),$l();var Q=n.memoizedState;_!==he||X!==Q||ls||i!==null&&i.dependencies!==null&&Cc(i.dependencies)?(typeof C=="function"&&(Rd(n,a,C,l),Q=n.memoizedState),(ae=ls||hv(n,a,ae,l,X,Q,N)||i!==null&&i.dependencies!==null&&Cc(i.dependencies))?($||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,Q,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,Q,N)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Q),d.props=l,d.state=Q,d.context=N,l=ae):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&X===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,Kc(i,n),l=(n.flags&128)!==0,d||l?(d=n.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&l?(n.child=ia(n,i.child,null,u),n.child=ia(n,null,a,u)):qi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Or(i,n,u),i}function Tv(i,n,a,l){return Gs(),n.flags|=256,qi(i,n,a,l),n.child}var Bd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Od(i){return{baseLanes:i,cachePool:g_()}}function zd(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=Tn),i}function Dv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(li.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(ft){if(u?us(n):hs(),(i=jt)?(i=zy(i,Kn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:ns!==null?{id:mr,overflow:gr}:null,retryLane:536870912,hydrationErrors:null},a=l_(i),a.return=n,n.child=a,Wi=n,jt=null)):i=null,i===null)throw ss(n);return yf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(hs(),u=n.mode,C=Wc({mode:"hidden",children:C},u),l=Xs(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=Od(a),l.childLanes=zd(i,_,a),n.memoizedState=Bd,Ql(null,l)):(us(n),jd(n,C))}var N=i.memoizedState;if(N!==null&&(C=N.dehydrated,C!==null)){if(d)n.flags&256?(us(n),n.flags&=-257,n=Hd(i,n,a)):n.memoizedState!==null?(hs(),n.child=i.child,n.flags|=128,n=null):(hs(),C=l.fallback,u=n.mode,l=Wc({mode:"visible",children:l.children},u),C=Xs(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,ia(n,i.child,null,a),l=n.child,l.memoizedState=Od(a),l.childLanes=zd(i,_,a),n.memoizedState=Bd,n=Ql(null,l));else if(us(n),yf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var $=_.dgst;_=$,l=Error(s(419)),l.stack="",l.digest=_,Ul({value:l,source:null,stack:null}),n=Hd(i,n,a)}else if(mi||Ka(i,n,a,!1),_=(a&i.childLanes)!==0,mi||_){if(_=Nt,_!==null&&(l=Si(_,a),l!==0&&l!==N.retryLane))throw N.retryLane=l,Ys(i,l),dn(_,i,l),Ad;vf(C)||Qc(),n=Hd(i,n,a)}else vf(C)?(n.flags|=192,n.child=i.child,n=null):(i=N.treeContext,jt=Fn(C.nextSibling),Wi=n,ft=!0,rs=null,Kn=!1,i!==null&&u_(n,i),n=jd(n,l.children),n.flags|=4096);return n}return u?(hs(),C=l.fallback,u=n.mode,N=i.child,$=N.sibling,l=Rr(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,$!==null?C=Rr($,C):(C=Xs(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,Ql(null,l),l=n.child,C=i.child.memoizedState,C===null?C=Od(a):(u=C.cachePool,u!==null?(N=fi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=g_(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=zd(i,_,a),n.memoizedState=Bd,Ql(i.child,l)):(us(n),a=i.child,i=a.sibling,a=Rr(a,{mode:"visible",children:l.children}),a.return=n,a.sibling=null,i!==null&&(_=n.deletions,_===null?(n.deletions=[i],n.flags|=16):_.push(i)),n.child=a,n.memoizedState=null,a)}function jd(i,n){return n=Wc({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function Wc(i,n){return i=Cn(22,i,null,n),i.lanes=0,i}function Hd(i,n,a){return ia(n,i.child,null,a),i=jd(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Rv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),Jh(i.return,n,a)}function Pd(i,n,a,l,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function Mv(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=li.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,se(li,_),qi(i,n,l,a),l=ft?Pl:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Rv(i,a,n);else if(i.tag===19)Rv(i,a,n);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break e;for(;i.sibling===null;){if(i.return===null||i.return===n)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=n.child,u=null;a!==null;)i=a.alternate,i!==null&&Nc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),Pd(n,!1,u,a,d,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Nc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Pd(n,!0,a,null,d,l);break;case"together":Pd(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Or(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),ps|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(Ka(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(s(153));if(n.child!==null){for(i=n.child,a=Rr(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Rr(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function Ud(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Cc(i)))}function rx(i,n,a){switch(n.tag){case 3:je(n,n.stateNode.containerInfo),as(n,fi,i.memoizedState.cache),Gs();break;case 27:case 5:ee(n);break;case 4:je(n,n.stateNode.containerInfo);break;case 10:as(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,hd(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(us(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Dv(i,n,a):(us(n),i=Or(i,n,a),i!==null?i.sibling:null);us(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(Ka(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Mv(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),se(li,li.current),l)break;return null;case 22:return n.lanes=0,wv(i,n,a,n.pendingProps);case 24:as(n,fi,i.memoizedState.cache)}return Or(i,n,a)}function Nv(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)mi=!0;else{if(!Ud(i,a)&&(n.flags&128)===0)return mi=!1,rx(i,n,a);mi=(i.flags&131072)!==0}else mi=!1,ft&&(n.flags&1048576)!==0&&c_(n,Pl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=ea(n.elementType),n.type=i,typeof i=="function")qh(i)?(l=ra(i,l),n.tag=1,n=kv(null,n,i,l,a)):(n.tag=0,n=Ld(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===K){n.tag=11,n=yv(null,n,i,l,a);break e}else if(u===le){n.tag=14,n=bv(null,n,i,l,a);break e}}throw n=j(i)||i,Error(s(306,n,""))}}return n;case 0:return Ld(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=ra(l,n.pendingProps),kv(i,n,l,u,a);case 3:e:{if(je(n,n.stateNode.containerInfo),i===null)throw Error(s(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,ad(i,n),Vl(n,l,null,a);var _=n.memoizedState;if(l=_.cache,as(n,fi,l),l!==d.cache&&ed(n,[fi],a,!0),$l(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Tv(i,n,l,a);break e}else if(l!==u){u=Pn(Error(s(424)),n),Ul(u),n=Tv(i,n,l,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,jt=Fn(i.firstChild),Wi=n,ft=!0,rs=null,Kn=!0,a=w_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Gs(),l===u){n=Or(i,n,a);break e}qi(i,n,l,a)}n=n.child}return n;case 26:return Kc(i,n),i===null?(a=Ky(n.type,null,n.pendingProps,null))?n.memoizedState=a:ft||(a=n.type,i=n.pendingProps,l=su(we.current).createElement(a),l[$t]=n,l[wi]=i,$i(l,a,i),Ot(l),n.stateNode=l):n.memoizedState=Ky(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return ee(n),i===null&&ft&&(l=n.stateNode=Py(n.type,n.pendingProps,we.current),Wi=n,Kn=!0,u=jt,ys(n.type)?(bf=u,jt=Fn(l.firstChild)):jt=u),qi(i,n,n.pendingProps.children,a),Kc(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&ft&&((u=l=jt)&&(l=Bx(l,n.type,n.pendingProps,Kn),l!==null?(n.stateNode=l,Wi=n,jt=Fn(l.firstChild),Kn=!1,u=!0):u=!1),u||ss(n)),ee(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,mf(u,d)?l=null:_!==null&&mf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=fd(i,n,XC,null,null,a),po._currentValue=u),Kc(i,n),qi(i,n,l,a),n.child;case 6:return i===null&&ft&&((i=a=jt)&&(a=Ox(a,n.pendingProps,Kn),a!==null?(n.stateNode=a,Wi=n,jt=null,i=!0):i=!1),i||ss(n)),null;case 13:return Dv(i,n,a);case 4:return je(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=ia(n,null,l,a):qi(i,n,l,a),n.child;case 11:return yv(i,n,n.type,n.pendingProps,a);case 7:return qi(i,n,n.pendingProps,a),n.child;case 8:return qi(i,n,n.pendingProps.children,a),n.child;case 12:return qi(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,as(n,n.type,l.value),qi(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,Qs(n),u=Fi(u),l=l(u),n.flags|=1,qi(i,n,l,a),n.child;case 14:return bv(i,n,n.type,n.pendingProps,a);case 15:return Sv(i,n,n.type,n.pendingProps,a);case 19:return Mv(i,n,a);case 31:return nx(i,n,a);case 22:return wv(i,n,a,n.pendingProps);case 24:return Qs(n),l=Fi(fi),i===null?(u=nd(),u===null&&(u=Nt,d=td(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},sd(n),as(n,fi,u)):((i.lanes&a)!==0&&(ad(i,n),Vl(n,null,null,a),$l()),u=i.memoizedState,d=n.memoizedState,u.parent!==l?(u={parent:l,cache:l},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),as(n,fi,l)):(l=d.cache,as(n,fi,l),l!==u.cache&&ed(n,[fi],a,!0))),qi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function zr(i){i.flags|=4}function Id(i,n,a,l,u){if((n=(i.mode&32)!==0)&&(n=!1),n){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(ry())i.flags|=8192;else throw ta=Tc,rd}else i.flags&=-16777217}function Av(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Vy(n))if(ry())i.flags|=8192;else throw ta=Tc,rd}function Fc(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?Xt():536870912,i.lanes|=n,el|=n)}function Jl(i,n){if(!ft)switch(i.tailMode){case"hidden":n=i.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.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?n||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function Ht(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,n}function sx(i,n,a){var l=n.pendingProps;switch(Xh(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ht(n),null;case 1:return Ht(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Ar(fi),Ve(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ia(n)?zr(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Zh())),Ht(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(zr(n),d!==null?(Ht(n),Av(n,d)):(Ht(n),Id(n,u,null,l,a))):d?d!==i.memoizedState?(zr(n),Ht(n),Av(n,d)):(Ht(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&zr(n),Ht(n),Id(n,u,i,l,a)),null;case 27:if(me(n),a=we.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zr(n);else{if(!l){if(n.stateNode===null)throw Error(s(166));return Ht(n),null}i=_e.current,Ia(n)?h_(n):(i=Py(u,l,a),n.stateNode=i,zr(n))}return Ht(n),null;case 5:if(me(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zr(n);else{if(!l){if(n.stateNode===null)throw Error(s(166));return Ht(n),null}if(d=_e.current,Ia(n))h_(n);else{var _=su(we.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?d.multiple=!0:l.size&&(d.size=l.size);break;default:d=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}d[$t]=n,d[wi]=l;e:for(_=n.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===n)break e;for(;_.sibling===null;){if(_.return===null||_.return===n)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}n.stateNode=d;e:switch($i(d,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&zr(n)}}return Ht(n),Id(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&zr(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(s(166));if(i=we.current,Ia(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Wi,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[$t]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Dy(i.nodeValue,a)),i||ss(n,!0)}else i=su(i).createTextNode(l),i[$t]=n,n.stateNode=i}return Ht(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Ia(n),a!==null){if(i===null){if(!l)throw Error(s(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[$t]=n}else Gs(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ht(n),i=!1}else a=Zh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(En(n),n):(En(n),null);if((n.flags&128)!==0)throw Error(s(558))}return Ht(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Ia(n),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[$t]=n}else Gs(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ht(n),u=!1}else u=Zh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(En(n),n):(En(n),null)}return En(n),(n.flags&128)!==0?(n.lanes=a,n):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=n.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==u&&(l.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),Fc(n,n.updateQueue),Ht(n),null);case 4:return Ve(),i===null&&uf(n.stateNode.containerInfo),Ht(n),null;case 10:return Ar(n.type),Ht(n),null;case 19:if(G(li),l=n.memoizedState,l===null)return Ht(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)Jl(l,!1);else{if(Jt!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Nc(i),d!==null){for(n.flags|=128,Jl(l,!1),i=d.updateQueue,n.updateQueue=i,Fc(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)a_(a,i),a=a.sibling;return se(li,li.current&1|2),ft&&Mr(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&He()>Xc&&(n.flags|=128,u=!0,Jl(l,!1),n.lanes=4194304)}else{if(!u)if(i=Nc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,Fc(n,i),Jl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!ft)return Ht(n),null}else 2*He()-l.renderingStartTime>Xc&&a!==536870912&&(n.flags|=128,u=!0,Jl(l,!1),n.lanes=4194304);l.isBackwards?(d.sibling=n.child,n.child=d):(i=l.last,i!==null?i.sibling=d:n.child=d,l.last=d)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=He(),i.sibling=null,a=li.current,se(li,u?a&1|2:a&1),ft&&Mr(n,l.treeForkCount),i):(Ht(n),null);case 22:case 23:return En(n),ud(),l=n.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(a&536870912)!==0&&(n.flags&128)===0&&(Ht(n),n.subtreeFlags&6&&(n.flags|=8192)):Ht(n),a=n.updateQueue,a!==null&&Fc(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==a&&(n.flags|=2048),i!==null&&G(Js),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Ar(fi),Ht(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function ax(i,n){switch(Xh(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Ar(fi),Ve(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return me(n),null;case 31:if(n.memoizedState!==null){if(En(n),n.alternate===null)throw Error(s(340));Gs()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(En(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(s(340));Gs()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return G(li),null;case 4:return Ve(),null;case 10:return Ar(n.type),null;case 22:case 23:return En(n),ud(),i!==null&&G(Js),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Ar(fi),null;case 25:return null;default:return null}}function Lv(i,n){switch(Xh(n),n.tag){case 3:Ar(fi),Ve();break;case 26:case 27:case 5:me(n);break;case 4:Ve();break;case 31:n.memoizedState!==null&&En(n);break;case 13:En(n);break;case 19:G(li);break;case 10:Ar(n.type);break;case 22:case 23:En(n),ud(),i!==null&&G(Js);break;case 24:Ar(fi)}}function eo(i,n){try{var a=n.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var d=a.create,_=a.inst;l=d(),_.destroy=l}a=a.next}while(a!==u)}}catch(C){xt(n,n.return,C)}}function ds(i,n,a){try{var l=n.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){var _=l.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var N=a,$=C;try{$()}catch(ae){xt(u,N,ae)}}}l=l.next}while(l!==d)}}catch(ae){xt(n,n.return,ae)}}function Bv(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{x_(n,a)}catch(l){xt(i,i.return,l)}}}function Ov(i,n,a){a.props=ra(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){xt(i,n,l)}}function to(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){xt(i,n,u)}}function _r(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){xt(i,n,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){xt(i,n,u)}else a.current=null}function zv(i){var n=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){xt(i,i.return,u)}}function Kd(i,n,a){try{var l=i.stateNode;Dx(l,i.type,a,n),l[wi]=n}catch(u){xt(i,i.return,u)}}function jv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Wd(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||jv(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&&ys(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 Fd(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(i),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=D));else if(l!==4&&(l===27&&ys(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(Fd(i,n,a),i=i.sibling;i!==null;)Fd(i,n,a),i=i.sibling}function qc(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(l!==4&&(l===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(qc(i,n,a),i=i.sibling;i!==null;)qc(i,n,a),i=i.sibling}function Hv(i){var n=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);$i(n,l,a),n[$t]=i,n[wi]=a}catch(d){xt(i,i.return,d)}}var jr=!1,gi=!1,qd=!1,Pv=typeof WeakSet=="function"?WeakSet:Set,Ai=null;function lx(i,n){if(i=i.containerInfo,ff=du,i=Zg(i),Hh(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,d=l.focusNode;l=l.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,N=-1,$=0,ae=0,he=i,X=null;t:for(;;){for(var Q;he!==a||u!==0&&he.nodeType!==3||(C=_+u),he!==d||l!==0&&he.nodeType!==3||(N=_+l),he.nodeType===3&&(_+=he.nodeValue.length),(Q=he.firstChild)!==null;)X=he,he=Q;for(;;){if(he===i)break t;if(X===a&&++$===u&&(C=_),X===d&&++ae===l&&(N=_),(Q=he.nextSibling)!==null)break;he=X,X=he.parentNode}he=Q}a=C===-1||N===-1?null:{start:C,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(pf={focusedElem:i,selectionRange:a},du=!1,Ai=n;Ai!==null;)if(n=Ai,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Ai=i;else for(;Ai!==null;){switch(n=Ai,d=n.alternate,i=n.flags,n.tag){case 0:if((i&4)!==0&&(i=n.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&d!==null){i=void 0,a=n,u=d.memoizedProps,d=d.memoizedState,l=a.stateNode;try{var Be=ra(a.type,u);i=l.getSnapshotBeforeUpdate(Be,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(Xe){xt(a,a.return,Xe)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)_f(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":_f(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=n.sibling,i!==null){i.return=n.return,Ai=i;break}Ai=n.return}}function Uv(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Pr(i,a),l&4&&eo(5,a);break;case 1:if(Pr(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){xt(a,a.return,_)}else{var u=ra(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){xt(a,a.return,_)}}l&64&&Bv(a),l&512&&to(a,a.return);break;case 3:if(Pr(i,a),l&64&&(i=a.updateQueue,i!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{x_(i,n)}catch(_){xt(a,a.return,_)}}break;case 27:n===null&&l&4&&Hv(a);case 26:case 5:Pr(i,a),n===null&&l&4&&zv(a),l&512&&to(a,a.return);break;case 12:Pr(i,a);break;case 31:Pr(i,a),l&4&&Wv(i,a);break;case 13:Pr(i,a),l&4&&Fv(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=gx.bind(null,a),zx(i,a))));break;case 22:if(l=a.memoizedState!==null||jr,!l){n=n!==null&&n.memoizedState!==null||gi,u=jr;var d=gi;jr=l,(gi=n)&&!d?Ur(i,a,(a.subtreeFlags&8772)!==0):Pr(i,a),jr=u,gi=d}break;case 30:break;default:Pr(i,a)}}function Iv(i){var n=i.alternate;n!==null&&(i.alternate=null,Iv(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&On(n)),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 Kt=null,on=!1;function Hr(i,n,a){for(a=a.child;a!==null;)Kv(i,n,a),a=a.sibling}function Kv(i,n,a){if(ii&&typeof ii.onCommitFiberUnmount=="function")try{ii.onCommitFiberUnmount(zt,a)}catch{}switch(a.tag){case 26:gi||_r(a,n),Hr(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:gi||_r(a,n);var l=Kt,u=on;ys(a.type)&&(Kt=a.stateNode,on=!1),Hr(i,n,a),uo(a.stateNode),Kt=l,on=u;break;case 5:gi||_r(a,n);case 6:if(l=Kt,u=on,Kt=null,Hr(i,n,a),Kt=l,on=u,Kt!==null)if(on)try{(Kt.nodeType===9?Kt.body:Kt.nodeName==="HTML"?Kt.ownerDocument.body:Kt).removeChild(a.stateNode)}catch(d){xt(a,n,d)}else try{Kt.removeChild(a.stateNode)}catch(d){xt(a,n,d)}break;case 18:Kt!==null&&(on?(i=Kt,By(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),ol(i)):By(Kt,a.stateNode));break;case 4:l=Kt,u=on,Kt=a.stateNode.containerInfo,on=!0,Hr(i,n,a),Kt=l,on=u;break;case 0:case 11:case 14:case 15:ds(2,a,n),gi||ds(4,a,n),Hr(i,n,a);break;case 1:gi||(_r(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Ov(a,n,l)),Hr(i,n,a);break;case 21:Hr(i,n,a);break;case 22:gi=(l=gi)||a.memoizedState!==null,Hr(i,n,a),gi=l;break;default:Hr(i,n,a)}}function Wv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{ol(i)}catch(a){xt(n,n.return,a)}}}function Fv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{ol(i)}catch(a){xt(n,n.return,a)}}function ox(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new Pv),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new Pv),n;default:throw Error(s(435,i.tag))}}function $c(i,n){var a=ox(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=_x.bind(null,i,l);l.then(u,u)}})}function cn(i,n){var a=n.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(ys(C.type)){Kt=C.stateNode,on=!1;break e}break;case 5:Kt=C.stateNode,on=!1;break e;case 3:case 4:Kt=C.stateNode.containerInfo,on=!0;break e}C=C.return}if(Kt===null)throw Error(s(160));Kv(d,_,u),Kt=null,on=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)qv(n,i),n=n.sibling}var sr=null;function qv(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:cn(n,i),un(i),l&4&&(ds(3,i,i.return),eo(3,i),ds(5,i,i.return));break;case 1:cn(n,i),un(i),l&512&&(gi||a===null||_r(a,a.return)),l&64&&jr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=sr;if(cn(n,i),un(i),l&512&&(gi||a===null||_r(a,a.return)),l&4){var d=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Bn]||d[$t]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(l),u.head.insertBefore(d,u.querySelector("head > title"))),$i(d,l,a),d[$t]=i,Ot(d),l=d;break e;case"link":var _=qy("link","href",u).get(l+(a.href||""));if(_){for(var C=0;C<_.length;C++)if(d=_[C],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(C,1);break t}}d=u.createElement(l),$i(d,l,a),u.head.appendChild(d);break;case"meta":if(_=qy("meta","content",u).get(l+(a.content||""))){for(C=0;C<_.length;C++)if(d=_[C],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(C,1);break t}}d=u.createElement(l),$i(d,l,a),u.head.appendChild(d);break;default:throw Error(s(468,l))}d[$t]=i,Ot(d),l=d}i.stateNode=l}else $y(u,i.type,i.stateNode);else i.stateNode=Fy(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?$y(u,i.type,i.stateNode):Fy(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Kd(i,i.memoizedProps,a.memoizedProps)}break;case 27:cn(n,i),un(i),l&512&&(gi||a===null||_r(a,a.return)),a!==null&&l&4&&Kd(i,i.memoizedProps,a.memoizedProps);break;case 5:if(cn(n,i),un(i),l&512&&(gi||a===null||_r(a,a.return)),i.flags&32){u=i.stateNode;try{pr(u,"")}catch(Be){xt(i,i.return,Be)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Kd(i,u,a!==null?a.memoizedProps:u)),l&1024&&(qd=!0);break;case 6:if(cn(n,i),un(i),l&4){if(i.stateNode===null)throw Error(s(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Be){xt(i,i.return,Be)}}break;case 3:if(ou=null,u=sr,sr=au(n.containerInfo),cn(n,i),sr=u,un(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{ol(n.containerInfo)}catch(Be){xt(i,i.return,Be)}qd&&(qd=!1,$v(i));break;case 4:l=sr,sr=au(i.stateNode.containerInfo),cn(n,i),un(i),sr=l;break;case 12:cn(n,i),un(i);break;case 31:cn(n,i),un(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,$c(i,l)));break;case 13:cn(n,i),un(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Yc=He()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,$c(i,l)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,$=jr,ae=gi;if(jr=$||u,gi=ae||N,cn(n,i),gi=ae,jr=$,un(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||N||jr||gi||sa(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){N=a=n;try{if(d=N.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=N.stateNode;var he=N.memoizedProps.style,X=he!=null&&he.hasOwnProperty("display")?he.display:null;C.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(Be){xt(N,N.return,Be)}}}else if(n.tag===6){if(a===null){N=n;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Be){xt(N,N.return,Be)}}}else if(n.tag===18){if(a===null){N=n;try{var Q=N.stateNode;u?Oy(Q,!0):Oy(N.stateNode,!1)}catch(Be){xt(N,N.return,Be)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===i)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,$c(i,a))));break;case 19:cn(n,i),un(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,$c(i,l)));break;case 30:break;case 21:break;default:cn(n,i),un(i)}}function un(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(jv(l)){a=l;break}l=l.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,d=Wd(i);qc(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(pr(_,""),a.flags&=-33);var C=Wd(i);qc(i,C,_);break;case 3:case 4:var N=a.stateNode.containerInfo,$=Wd(i);Fd(i,$,N);break;default:throw Error(s(161))}}catch(ae){xt(i,i.return,ae)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function $v(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;$v(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Pr(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Uv(i,n.alternate,n),n=n.sibling}function sa(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:ds(4,n,n.return),sa(n);break;case 1:_r(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&Ov(n,n.return,a),sa(n);break;case 27:uo(n.stateNode);case 26:case 5:_r(n,n.return),sa(n);break;case 22:n.memoizedState===null&&sa(n);break;case 30:sa(n);break;default:sa(n)}i=i.sibling}}function Ur(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Ur(u,d,a),eo(4,d);break;case 1:if(Ur(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch($){xt(l,l.return,$)}if(l=d,u=l.updateQueue,u!==null){var C=l.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)C_(N[u],C)}catch($){xt(l,l.return,$)}}a&&_&64&&Bv(d),to(d,d.return);break;case 27:Hv(d);case 26:case 5:Ur(u,d,a),a&&l===null&&_&4&&zv(d),to(d,d.return);break;case 12:Ur(u,d,a);break;case 31:Ur(u,d,a),a&&_&4&&Wv(u,d);break;case 13:Ur(u,d,a),a&&_&4&&Fv(u,d);break;case 22:d.memoizedState===null&&Ur(u,d,a),to(d,d.return);break;case 30:break;default:Ur(u,d,a)}n=n.sibling}}function $d(i,n){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Il(a))}function Vd(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Il(i))}function ar(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Vv(i,n,a,l),n=n.sibling}function Vv(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:ar(i,n,a,l),u&2048&&eo(9,n);break;case 1:ar(i,n,a,l);break;case 3:ar(i,n,a,l),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Il(i)));break;case 12:if(u&2048){ar(i,n,a,l),i=n.stateNode;try{var d=n.memoizedProps,_=d.id,C=d.onPostCommit;typeof C=="function"&&C(_,n.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){xt(n,n.return,N)}}else ar(i,n,a,l);break;case 31:ar(i,n,a,l);break;case 13:ar(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?ar(i,n,a,l):io(i,n):d._visibility&2?ar(i,n,a,l):(d._visibility|=2,Za(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&$d(_,n);break;case 24:ar(i,n,a,l),u&2048&&Vd(n.alternate,n);break;default:ar(i,n,a,l)}}function Za(i,n,a,l,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,N=l,$=_.flags;switch(_.tag){case 0:case 11:case 15:Za(d,_,C,N,u),eo(8,_);break;case 23:break;case 22:var ae=_.stateNode;_.memoizedState!==null?ae._visibility&2?Za(d,_,C,N,u):io(d,_):(ae._visibility|=2,Za(d,_,C,N,u)),u&&$&2048&&$d(_.alternate,_);break;case 24:Za(d,_,C,N,u),u&&$&2048&&Vd(_.alternate,_);break;default:Za(d,_,C,N,u)}n=n.sibling}}function io(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,l=n,u=l.flags;switch(l.tag){case 22:io(a,l),u&2048&&$d(l.alternate,l);break;case 24:io(a,l),u&2048&&Vd(l.alternate,l);break;default:io(a,l)}n=n.sibling}}var no=8192;function Qa(i,n,a){if(i.subtreeFlags&no)for(i=i.child;i!==null;)Yv(i,n,a),i=i.sibling}function Yv(i,n,a){switch(i.tag){case 26:Qa(i,n,a),i.flags&no&&i.memoizedState!==null&&Yx(a,sr,i.memoizedState,i.memoizedProps);break;case 5:Qa(i,n,a);break;case 3:case 4:var l=sr;sr=au(i.stateNode.containerInfo),Qa(i,n,a),sr=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=no,no=16777216,Qa(i,n,a),no=l):Qa(i,n,a));break;default:Qa(i,n,a)}}function Xv(i){var n=i.alternate;if(n!==null&&(i=n.child,i!==null)){n.child=null;do n=i.sibling,i.sibling=null,i=n;while(i!==null)}}function ro(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Ai=l,Zv(l,i)}Xv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Gv(i),i=i.sibling}function Gv(i){switch(i.tag){case 0:case 11:case 15:ro(i),i.flags&2048&&ds(9,i,i.return);break;case 3:ro(i);break;case 12:ro(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,Vc(i)):ro(i);break;default:ro(i)}}function Vc(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Ai=l,Zv(l,i)}Xv(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:ds(8,n,n.return),Vc(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Vc(n));break;default:Vc(n)}i=i.sibling}}function Zv(i,n){for(;Ai!==null;){var a=Ai;switch(a.tag){case 0:case 11:case 15:ds(8,a,n);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:Il(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Ai=l;else e:for(a=i;Ai!==null;){l=Ai;var u=l.sibling,d=l.return;if(Iv(l),l===a){Ai=null;break e}if(u!==null){u.return=d,Ai=u;break e}Ai=d}}}var cx={getCacheForType:function(i){var n=Fi(fi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Fi(fi).controller.signal}},ux=typeof WeakMap=="function"?WeakMap:Map,_t=0,Nt=null,lt=null,ut=0,Ct=0,kn=null,fs=!1,Ja=!1,Yd=!1,Ir=0,Jt=0,ps=0,aa=0,Xd=0,Tn=0,el=0,so=null,hn=null,Gd=!1,Yc=0,Qv=0,Xc=1/0,Gc=null,ms=null,Ci=0,gs=null,tl=null,Kr=0,Zd=0,Qd=null,Jv=null,ao=0,Jd=null;function Dn(){return(_t&2)!==0&&ut!==0?ut&-ut:M.T!==null?af():tn()}function ey(){if(Tn===0)if((ut&536870912)===0||ft){var i=Ii;Ii<<=1,(Ii&3932160)===0&&(Ii=262144),Tn=i}else Tn=536870912;return i=xn.current,i!==null&&(i.flags|=32),Tn}function dn(i,n,a){(i===Nt&&(Ct===2||Ct===9)||i.cancelPendingCommit!==null)&&(il(i,0),_s(i,ut,Tn,!1)),bi(i,a),((_t&2)===0||i!==Nt)&&(i===Nt&&((_t&2)===0&&(aa|=a),Jt===4&&_s(i,ut,Tn,!1)),vr(i))}function ty(i,n,a){if((_t&6)!==0)throw Error(s(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Mi(i,n),u=l?fx(i,n):tf(i,n,!0),d=l;do{if(u===0){Ja&&!l&&_s(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!hx(a)){u=tf(i,n,!1),d=!1;continue}if(u===2){if(d=n,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){n=_;e:{var C=i;u=so;var N=C.current.memoizedState.isDehydrated;if(N&&(il(C,_).flags|=256),_=tf(C,_,!1),_!==2){if(Yd&&!N){C.errorRecoveryDisabledLanes|=d,aa|=d,u=4;break e}d=hn,hn=u,d!==null&&(hn===null?hn=d:hn.push.apply(hn,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){il(i,0),_s(i,n,0,!0);break}e:{switch(l=i,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:_s(l,n,Tn,!fs);break e;case 2:hn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(u=Yc+300-He(),10<u)){if(_s(l,n,Tn,!fs),Et(l,0,!0)!==0)break e;Kr=n,l.timeoutHandle=Ay(iy.bind(null,l,a,hn,Gc,Gd,n,Tn,aa,el,fs,d,"Throttled",-0,0),u);break e}iy(l,a,hn,Gc,Gd,n,Tn,aa,el,fs,d,null,-0,0)}}break}while(!0);vr(i)}function iy(i,n,a,l,u,d,_,C,N,$,ae,he,X,Q){if(i.timeoutHandle=-1,he=n.subtreeFlags,he&8192||(he&16785408)===16785408){he={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:D},Yv(n,d,he);var Be=(d&62914560)===d?Yc-He():(d&4194048)===d?Qv-He():0;if(Be=Xx(he,Be),Be!==null){Kr=d,i.cancelPendingCommit=Be(uy.bind(null,i,n,d,a,l,u,_,C,N,ae,he,null,X,Q)),_s(i,d,_,!$);return}}uy(i,n,d,a,l,u,_,C,N)}function hx(i){for(var n=i;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],d=u.getSnapshot;u=u.value;try{if(!wn(d(),u))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function _s(i,n,a,l){n&=~Xd,n&=~aa,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-gt(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&Ni(i,a,n)}function Zc(){return(_t&6)===0?(lo(0),!1):!0}function ef(){if(lt!==null){if(Ct===0)var i=lt.return;else i=lt,Nr=Zs=null,gd(i),$a=null,Wl=0,i=lt;for(;i!==null;)Lv(i.alternate,i),i=i.return;lt=null}}function il(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Nx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Kr=0,ef(),Nt=i,lt=a=Rr(i.current,null),ut=n,Ct=0,kn=null,fs=!1,Ja=Mi(i,n),Yd=!1,el=Tn=Xd=aa=ps=Jt=0,hn=so=null,Gd=!1,(n&8)!==0&&(n|=n&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=n;0<l;){var u=31-gt(l),d=1<<u;n|=i[u],l&=~d}return Ir=n,vc(),a}function ny(i,n){Qe=null,M.H=Zl,n===qa||n===kc?(n=y_(),Ct=3):n===rd?(n=y_(),Ct=4):Ct=n===Ad?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,lt===null&&(Jt=1,Uc(i,Pn(n,i.current)))}function ry(){var i=xn.current;return i===null?!0:(ut&4194048)===ut?Wn===null:(ut&62914560)===ut||(ut&536870912)!==0?i===Wn:!1}function sy(){var i=M.H;return M.H=Zl,i===null?Zl:i}function ay(){var i=M.A;return M.A=cx,i}function Qc(){Jt=4,fs||(ut&4194048)!==ut&&xn.current!==null||(Ja=!0),(ps&134217727)===0&&(aa&134217727)===0||Nt===null||_s(Nt,ut,Tn,!1)}function tf(i,n,a){var l=_t;_t|=2;var u=sy(),d=ay();(Nt!==i||ut!==n)&&(Gc=null,il(i,n)),n=!1;var _=Jt;e:do try{if(Ct!==0&&lt!==null){var C=lt,N=kn;switch(Ct){case 8:ef(),_=6;break e;case 3:case 2:case 9:case 6:xn.current===null&&(n=!0);var $=Ct;if(Ct=0,kn=null,nl(i,C,N,$),a&&Ja){_=0;break e}break;default:$=Ct,Ct=0,kn=null,nl(i,C,N,$)}}dx(),_=Jt;break}catch(ae){ny(i,ae)}while(!0);return n&&i.shellSuspendCounter++,Nr=Zs=null,_t=l,M.H=u,M.A=d,lt===null&&(Nt=null,ut=0,vc()),_}function dx(){for(;lt!==null;)ly(lt)}function fx(i,n){var a=_t;_t|=2;var l=sy(),u=ay();Nt!==i||ut!==n?(Gc=null,Xc=He()+500,il(i,n)):Ja=Mi(i,n);e:do try{if(Ct!==0&&lt!==null){n=lt;var d=kn;t:switch(Ct){case 1:Ct=0,kn=null,nl(i,n,d,1);break;case 2:case 9:if(__(d)){Ct=0,kn=null,oy(n);break}n=function(){Ct!==2&&Ct!==9||Nt!==i||(Ct=7),vr(i)},d.then(n,n);break e;case 3:Ct=7;break e;case 4:Ct=5;break e;case 7:__(d)?(Ct=0,kn=null,oy(n)):(Ct=0,kn=null,nl(i,n,d,7));break;case 5:var _=null;switch(lt.tag){case 26:_=lt.memoizedState;case 5:case 27:var C=lt;if(_?Vy(_):C.stateNode.complete){Ct=0,kn=null;var N=C.sibling;if(N!==null)lt=N;else{var $=C.return;$!==null?(lt=$,Jc($)):lt=null}break t}}Ct=0,kn=null,nl(i,n,d,5);break;case 6:Ct=0,kn=null,nl(i,n,d,6);break;case 8:ef(),Jt=6;break e;default:throw Error(s(462))}}px();break}catch(ae){ny(i,ae)}while(!0);return Nr=Zs=null,M.H=l,M.A=u,_t=a,lt!==null?0:(Nt=null,ut=0,vc(),Jt)}function px(){for(;lt!==null&&!Y();)ly(lt)}function ly(i){var n=Nv(i.alternate,i,Ir);i.memoizedProps=i.pendingProps,n===null?Jc(i):lt=n}function oy(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=Ev(a,n,n.pendingProps,n.type,void 0,ut);break;case 11:n=Ev(a,n,n.pendingProps,n.type.render,n.ref,ut);break;case 5:gd(n);default:Lv(a,n),n=lt=a_(n,Ir),n=Nv(a,n,Ir)}i.memoizedProps=i.pendingProps,n===null?Jc(i):lt=n}function nl(i,n,a,l){Nr=Zs=null,gd(n),$a=null,Wl=0;var u=n.return;try{if(ix(i,u,n,a,ut)){Jt=1,Uc(i,Pn(a,i.current)),lt=null;return}}catch(d){if(u!==null)throw lt=u,d;Jt=1,Uc(i,Pn(a,i.current)),lt=null;return}n.flags&32768?(ft||l===1?i=!0:Ja||(ut&536870912)!==0?i=!1:(fs=i=!0,(l===2||l===9||l===3||l===6)&&(l=xn.current,l!==null&&l.tag===13&&(l.flags|=16384))),cy(n,i)):Jc(n)}function Jc(i){var n=i;do{if((n.flags&32768)!==0){cy(n,fs);return}i=n.return;var a=sx(n.alternate,n,Ir);if(a!==null){lt=a;return}if(n=n.sibling,n!==null){lt=n;return}lt=n=i}while(n!==null);Jt===0&&(Jt=5)}function cy(i,n){do{var a=ax(i.alternate,i);if(a!==null){a.flags&=32767,lt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){lt=i;return}lt=i=a}while(i!==null);Jt=6,lt=null}function uy(i,n,a,l,u,d,_,C,N){i.cancelPendingCommit=null;do eu();while(Ci!==0);if((_t&6)!==0)throw Error(s(327));if(n!==null){if(n===i.current)throw Error(s(177));if(d=n.lanes|n.childLanes,d|=Wh,Ut(i,a,d,_,C,N),i===Nt&&(lt=Nt=null,ut=0),tl=n,gs=i,Kr=a,Zd=d,Qd=u,Jv=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,vx(ge,function(){return my(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=M.T,M.T=null,u=V.p,V.p=2,_=_t,_t|=4;try{lx(i,n,a)}finally{_t=_,V.p=u,M.T=l}}Ci=1,hy(),dy(),fy()}}function hy(){if(Ci===1){Ci=0;var i=gs,n=tl,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=M.T,M.T=null;var l=V.p;V.p=2;var u=_t;_t|=4;try{qv(n,i);var d=pf,_=Zg(i.containerInfo),C=d.focusedElem,N=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&Gg(C.ownerDocument.documentElement,C)){if(N!==null&&Hh(C)){var $=N.start,ae=N.end;if(ae===void 0&&(ae=$),"selectionStart"in C)C.selectionStart=$,C.selectionEnd=Math.min(ae,C.value.length);else{var he=C.ownerDocument||document,X=he&&he.defaultView||window;if(X.getSelection){var Q=X.getSelection(),Be=C.textContent.length,Xe=Math.min(N.start,Be),Dt=N.end===void 0?Xe:Math.min(N.end,Be);!Q.extend&&Xe>Dt&&(_=Dt,Dt=Xe,Xe=_);var U=Xg(C,Xe),O=Xg(C,Dt);if(U&&O&&(Q.rangeCount!==1||Q.anchorNode!==U.node||Q.anchorOffset!==U.offset||Q.focusNode!==O.node||Q.focusOffset!==O.offset)){var q=he.createRange();q.setStart(U.node,U.offset),Q.removeAllRanges(),Xe>Dt?(Q.addRange(q),Q.extend(O.node,O.offset)):(q.setEnd(O.node,O.offset),Q.addRange(q))}}}}for(he=[],Q=C;Q=Q.parentNode;)Q.nodeType===1&&he.push({element:Q,left:Q.scrollLeft,top:Q.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<he.length;C++){var ue=he[C];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}du=!!ff,pf=ff=null}finally{_t=u,V.p=l,M.T=a}}i.current=n,Ci=2}}function dy(){if(Ci===2){Ci=0;var i=gs,n=tl,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=M.T,M.T=null;var l=V.p;V.p=2;var u=_t;_t|=4;try{Uv(i,n.alternate,n)}finally{_t=u,V.p=l,M.T=a}}Ci=3}}function fy(){if(Ci===4||Ci===3){Ci=0,Te();var i=gs,n=tl,a=Kr,l=Jv;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ci=5:(Ci=0,tl=gs=null,py(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(ms=null),en(a),n=n.stateNode,ii&&typeof ii.onCommitFiberRoot=="function")try{ii.onCommitFiberRoot(zt,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=M.T,u=V.p,V.p=2,M.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{M.T=n,V.p=u}}(Kr&3)!==0&&eu(),vr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===Jd?ao++:(ao=0,Jd=i):ao=0,lo(0)}}function py(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Il(n)))}function eu(){return hy(),dy(),fy(),my()}function my(){if(Ci!==5)return!1;var i=gs,n=Zd;Zd=0;var a=en(Kr),l=M.T,u=V.p;try{V.p=32>a?32:a,M.T=null,a=Qd,Qd=null;var d=gs,_=Kr;if(Ci=0,tl=gs=null,Kr=0,(_t&6)!==0)throw Error(s(331));var C=_t;if(_t|=4,Gv(d.current),Vv(d,d.current,_,a),_t=C,lo(0,!1),ii&&typeof ii.onPostCommitFiberRoot=="function")try{ii.onPostCommitFiberRoot(zt,d)}catch{}return!0}finally{V.p=u,M.T=l,py(i,n)}}function gy(i,n,a){n=Pn(a,n),n=Nd(i.stateNode,n,2),i=cs(i,n,2),i!==null&&(bi(i,2),vr(i))}function xt(i,n,a){if(i.tag===3)gy(i,i,a);else for(;n!==null;){if(n.tag===3){gy(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ms===null||!ms.has(l))){i=Pn(a,i),a=_v(2),l=cs(n,a,2),l!==null&&(vv(a,l,n,i),bi(l,2),vr(l));break}}n=n.return}}function nf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new ux;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(a)||(Yd=!0,u.add(a),i=mx.bind(null,i,n,a),n.then(i,i))}function mx(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Nt===i&&(ut&a)===a&&(Jt===4||Jt===3&&(ut&62914560)===ut&&300>He()-Yc?(_t&2)===0&&il(i,0):Xd|=a,el===ut&&(el=0)),vr(i)}function _y(i,n){n===0&&(n=Xt()),i=Ys(i,n),i!==null&&(bi(i,n),vr(i))}function gx(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),_y(i,a)}function _x(i,n){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(s(314))}l!==null&&l.delete(n),_y(i,a)}function vx(i,n){return Ae(i,n)}var tu=null,rl=null,rf=!1,iu=!1,sf=!1,vs=0;function vr(i){i!==rl&&i.next===null&&(rl===null?tu=rl=i:rl=rl.next=i),iu=!0,rf||(rf=!0,bx())}function lo(i,n){if(!sf&&iu){sf=!0;do for(var a=!1,l=tu;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var d=0;else{var _=l.suspendedLanes,C=l.pingedLanes;d=(1<<31-gt(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Sy(l,d))}else d=ut,d=Et(l,l===Nt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||Mi(l,d)||(a=!0,Sy(l,d));l=l.next}while(a);sf=!1}}function yx(){vy()}function vy(){iu=rf=!1;var i=0;vs!==0&&Mx()&&(i=vs);for(var n=He(),a=null,l=tu;l!==null;){var u=l.next,d=yy(l,n);d===0?(l.next=null,a===null?tu=u:a.next=u,u===null&&(rl=a)):(a=l,(i!==0||(d&3)!==0)&&(iu=!0)),l=u}Ci!==0&&Ci!==5||lo(i),vs!==0&&(vs=0)}function yy(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-gt(d),C=1<<_,N=u[_];N===-1?((C&a)===0||(C&l)!==0)&&(u[_]=ui(C,n)):N<=n&&(i.expiredLanes|=C),d&=~C}if(n=Nt,a=ut,a=Et(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(Ct===2||Ct===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ie(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Mi(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&Ie(l),en(a)){case 2:case 8:a=Ri;break;case 32:a=ge;break;case 268435456:a=dt;break;default:a=ge}return l=by.bind(null,i),a=Ae(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&Ie(l),i.callbackPriority=2,i.callbackNode=null,2}function by(i,n){if(Ci!==0&&Ci!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(eu()&&i.callbackNode!==a)return null;var l=ut;return l=Et(i,i===Nt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(ty(i,l,n),yy(i,He()),i.callbackNode!=null&&i.callbackNode===a?by.bind(null,i):null)}function Sy(i,n){if(eu())return null;ty(i,n,!0)}function bx(){Ax(function(){(_t&6)!==0?Ae(yi,yx):vy()})}function af(){if(vs===0){var i=Wa;i===0&&(i=Mt,Mt<<=1,(Mt&261888)===0&&(Mt=256)),vs=i}return vs}function wy(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Dr(""+i)}function Cy(i,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,i.id&&a.setAttribute("form",i.id),n.parentNode.insertBefore(a,n),i=new FormData(i),a.parentNode.removeChild(a),i}function Sx(i,n,a,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=wy((u[wi]||null).action),_=l.submitter;_&&(n=(n=_[wi]||null)?wy(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new at("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(vs!==0){var N=_?Cy(u,_):new FormData(u);Ed(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(C.preventDefault(),N=_?Cy(u,_):new FormData(u),Ed(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var lf=0;lf<Kh.length;lf++){var of=Kh[lf],wx=of.toLowerCase(),Cx=of[0].toUpperCase()+of.slice(1);rr(wx,"on"+Cx)}rr(e_,"onAnimationEnd"),rr(t_,"onAnimationIteration"),rr(i_,"onAnimationStart"),rr("dblclick","onDoubleClick"),rr("focusin","onFocus"),rr("focusout","onBlur"),rr(PC,"onTransitionRun"),rr(UC,"onTransitionStart"),rr(IC,"onTransitionCancel"),rr(n_,"onTransitionEnd"),er("onMouseEnter",["mouseout","mouseover"]),er("onMouseLeave",["mouseout","mouseover"]),er("onPointerEnter",["pointerout","pointerover"]),er("onPointerLeave",["pointerout","pointerover"]),bn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),bn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),bn("onBeforeInput",["compositionend","keypress","textInput","paste"]),bn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),bn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),bn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oo="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(" "),xx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(oo));function xy(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var d=void 0;if(n)for(var _=l.length-1;0<=_;_--){var C=l[_],N=C.instance,$=C.currentTarget;if(C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(ae){_c(ae)}u.currentTarget=null,d=N}else for(_=0;_<l.length;_++){if(C=l[_],N=C.instance,$=C.currentTarget,C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(ae){_c(ae)}u.currentTarget=null,d=N}}}}function ot(i,n){var a=n[Is];a===void 0&&(a=n[Is]=new Set);var l=i+"__bubble";a.has(l)||(Ey(n,i,2,!1),a.add(l))}function cf(i,n,a){var l=0;n&&(l|=4),Ey(a,i,l,n)}var nu="_reactListening"+Math.random().toString(36).slice(2);function uf(i){if(!i[nu]){i[nu]=!0,di.forEach(function(a){a!=="selectionchange"&&(xx.has(a)||cf(a,!1,i),cf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[nu]||(n[nu]=!0,cf("selectionchange",!1,n))}}function Ey(i,n,a,l){switch(eb(n)){case 2:var u=Qx;break;case 8:u=Jx;break;default:u=Ef}a=u.bind(null,n,a,i),u=void 0,!Ki||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(n,a,{capture:!0,passive:u}):i.addEventListener(n,a,!0):u!==void 0?i.addEventListener(n,a,{passive:u}):i.addEventListener(n,a,!1)}function hf(i,n,a,l,u){var d=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var C=l.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=l.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=zn(C),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){l=d=_;continue e}C=C.parentNode}}l=l.return}si(function(){var $=d,ae=Ue(a),he=[];e:{var X=r_.get(i);if(X!==void 0){var Q=at,Be=i;switch(i){case"keypress":if(ie(a)===0)break e;case"keydown":case"keyup":Q=_C;break;case"focusin":Be="focus",Q=Lh;break;case"focusout":Be="blur",Q=Lh;break;case"beforeblur":case"afterblur":Q=Lh;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":Q=Lg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Q=sC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Q=bC;break;case e_:case t_:case i_:Q=oC;break;case n_:Q=wC;break;case"scroll":case"scrollend":Q=ai;break;case"wheel":Q=xC;break;case"copy":case"cut":case"paste":Q=uC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Q=Og;break;case"toggle":case"beforetoggle":Q=kC}var Xe=(n&4)!==0,Dt=!Xe&&(i==="scroll"||i==="scrollend"),U=Xe?X!==null?X+"Capture":null:X;Xe=[];for(var O=$,q;O!==null;){var ue=O;if(q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||q===null||U===null||(ue=St(O,U),ue!=null&&Xe.push(co(O,ue,q))),Dt)break;O=O.return}0<Xe.length&&(X=new Q(X,Be,null,a,ae),he.push({event:X,listeners:Xe}))}}if((n&7)===0){e:{if(X=i==="mouseover"||i==="pointerover",Q=i==="mouseout"||i==="pointerout",X&&a!==te&&(Be=a.relatedTarget||a.fromElement)&&(zn(Be)||Be[Ln]))break e;if((Q||X)&&(X=ae.window===ae?ae:(X=ae.ownerDocument)?X.defaultView||X.parentWindow:window,Q?(Be=a.relatedTarget||a.toElement,Q=$,Be=Be?zn(Be):null,Be!==null&&(Dt=c(Be),Xe=Be.tag,Be!==Dt||Xe!==5&&Xe!==27&&Xe!==6)&&(Be=null)):(Q=null,Be=$),Q!==Be)){if(Xe=Lg,ue="onMouseLeave",U="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(Xe=Og,ue="onPointerLeave",U="onPointerEnter",O="pointer"),Dt=Q==null?X:Jn(Q),q=Be==null?X:Jn(Be),X=new Xe(ue,O+"leave",Q,a,ae),X.target=Dt,X.relatedTarget=q,ue=null,zn(ae)===$&&(Xe=new Xe(U,O+"enter",Be,a,ae),Xe.target=q,Xe.relatedTarget=Dt,ue=Xe),Dt=ue,Q&&Be)t:{for(Xe=Ex,U=Q,O=Be,q=0,ue=U;ue;ue=Xe(ue))q++;ue=0;for(var qe=O;qe;qe=Xe(qe))ue++;for(;0<q-ue;)U=Xe(U),q--;for(;0<ue-q;)O=Xe(O),ue--;for(;q--;){if(U===O||O!==null&&U===O.alternate){Xe=U;break t}U=Xe(U),O=Xe(O)}Xe=null}else Xe=null;Q!==null&&ky(he,X,Q,Xe,!1),Be!==null&&Dt!==null&&ky(he,Dt,Be,Xe,!0)}}e:{if(X=$?Jn($):window,Q=X.nodeName&&X.nodeName.toLowerCase(),Q==="select"||Q==="input"&&X.type==="file")var pt=Wg;else if(Ig(X))if(Fg)pt=zC;else{pt=BC;var Pe=LC}else Q=X.nodeName,!Q||Q.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?$&&is($.elementType)&&(pt=Wg):pt=OC;if(pt&&(pt=pt(i,$))){Kg(he,pt,a,ae);break e}Pe&&Pe(i,X,$),i==="focusout"&&$&&X.type==="number"&&$.memoizedProps.value!=null&&qs(X,"number",X.value)}switch(Pe=$?Jn($):window,i){case"focusin":(Ig(Pe)||Pe.contentEditable==="true")&&(Oa=Pe,Ph=$,Hl=null);break;case"focusout":Hl=Ph=Oa=null;break;case"mousedown":Uh=!0;break;case"contextmenu":case"mouseup":case"dragend":Uh=!1,Qg(he,a,ae);break;case"selectionchange":if(HC)break;case"keydown":case"keyup":Qg(he,a,ae)}var Je;if(Oh)e:{switch(i){case"compositionstart":var ht="onCompositionStart";break e;case"compositionend":ht="onCompositionEnd";break e;case"compositionupdate":ht="onCompositionUpdate";break e}ht=void 0}else Ba?Pg(i,a)&&(ht="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(ht="onCompositionStart");ht&&(zg&&a.locale!=="ko"&&(Ba||ht!=="onCompositionStart"?ht==="onCompositionEnd"&&Ba&&(Je=z()):(Sn=ae,x="value"in Sn?Sn.value:Sn.textContent,Ba=!0)),Pe=ru($,ht),0<Pe.length&&(ht=new Bg(ht,i,null,a,ae),he.push({event:ht,listeners:Pe}),Je?ht.data=Je:(Je=Ug(a),Je!==null&&(ht.data=Je)))),(Je=DC?RC(i,a):MC(i,a))&&(ht=ru($,"onBeforeInput"),0<ht.length&&(Pe=new Bg("onBeforeInput","beforeinput",null,a,ae),he.push({event:Pe,listeners:ht}),Pe.data=Je)),Sx(he,i,$,a,ae)}xy(he,n)})}function co(i,n,a){return{instance:i,listener:n,currentTarget:a}}function ru(i,n){for(var a=n+"Capture",l=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=St(i,a),u!=null&&l.unshift(co(i,u,d)),u=St(i,n),u!=null&&l.push(co(i,u,d))),i.tag===3)return l;i=i.return}return[]}function Ex(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function ky(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,N=C.alternate,$=C.stateNode;if(C=C.tag,N!==null&&N===l)break;C!==5&&C!==26&&C!==27||$===null||(N=$,u?($=St(a,d),$!=null&&_.unshift(co(a,$,N))):u||($=St(a,d),$!=null&&_.push(co(a,$,N)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var kx=/\r\n?/g,Tx=/\u0000|\uFFFD/g;function Ty(i){return(typeof i=="string"?i:""+i).replace(kx,`
10
- `).replace(Tx,"")}function Dy(i,n){return n=Ty(n),Ty(i)===n}function Tt(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||pr(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&pr(i,""+l);break;case"className":dr(i,"class",l);break;case"tabIndex":dr(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":dr(i,a,l);break;case"style":Zi(i,l,d);break;case"data":if(n!=="object"){dr(i,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Dr(""+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 d=="function"&&(a==="formAction"?(n!=="input"&&Tt(i,n,"name",u.name,u,null),Tt(i,n,"formEncType",u.formEncType,u,null),Tt(i,n,"formMethod",u.formMethod,u,null),Tt(i,n,"formTarget",u.formTarget,u,null)):(Tt(i,n,"encType",u.encType,u,null),Tt(i,n,"method",u.method,u,null),Tt(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Dr(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=D);break;case"onScroll":l!=null&&ot("scroll",i);break;case"onScrollEnd":l!=null&&ot("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=Dr(""+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":ot("beforetoggle",i),ot("toggle",i),hr(i,"popover",l);break;case"xlinkActuate":ln(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":ln(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":ln(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":ln(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":ln(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":ln(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":ln(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":ln(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":ln(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":hr(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=jn.get(a)||a,hr(i,a,l))}}function df(i,n,a,l,u,d){switch(a){case"style":Zi(i,l,d);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(s(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof l=="string"?pr(i,l):(typeof l=="number"||typeof l=="bigint")&&pr(i,""+l);break;case"onScroll":l!=null&&ot("scroll",i);break;case"onScrollEnd":l!=null&&ot("scrollend",i);break;case"onClick":l!=null&&(i.onclick=D);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ra.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),n=a.slice(2,u?a.length-7:void 0),d=i[wi]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof l=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):hr(i,a,l)}}}function $i(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",i),ot("load",i);var l=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Tt(i,n,d,_,a,null)}}u&&Tt(i,n,"srcSet",a.srcSet,a,null),l&&Tt(i,n,"src",a.src,a,null);return;case"input":ot("invalid",i);var C=d=_=u=null,N=null,$=null;for(l in a)if(a.hasOwnProperty(l)){var ae=a[l];if(ae!=null)switch(l){case"name":u=ae;break;case"type":_=ae;break;case"checked":N=ae;break;case"defaultChecked":$=ae;break;case"value":d=ae;break;case"defaultValue":C=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(s(137,n));break;default:Tt(i,n,l,ae,a,null)}}Fs(i,d,C,N,$,_,u,!1);return;case"select":ot("invalid",i),l=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(C=a[u],C!=null))switch(u){case"value":d=C;break;case"defaultValue":_=C;break;case"multiple":l=C;default:Tt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?fr(i,!!l,n,!1):a!=null&&fr(i,!!l,a,!0);return;case"textarea":ot("invalid",i),d=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":l=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:Tt(i,n,_,C,a,null)}nr(i,l,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(l=a[N],l!=null)&&(N==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":Tt(i,n,N,l,a,null));return;case"dialog":ot("beforetoggle",i),ot("toggle",i),ot("cancel",i),ot("close",i);break;case"iframe":case"object":ot("load",i);break;case"video":case"audio":for(l=0;l<oo.length;l++)ot(oo[l],i);break;case"image":ot("error",i),ot("load",i);break;case"details":ot("toggle",i);break;case"embed":case"source":case"link":ot("error",i),ot("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($ in a)if(a.hasOwnProperty($)&&(l=a[$],l!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Tt(i,n,$,l,a,null)}return;default:if(is(n)){for(ae in a)a.hasOwnProperty(ae)&&(l=a[ae],l!==void 0&&df(i,n,ae,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&Tt(i,n,C,l,a,null))}function Dx(i,n,a,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,C=null,N=null,$=null,ae=null;for(Q in a){var he=a[Q];if(a.hasOwnProperty(Q)&&he!=null)switch(Q){case"checked":break;case"value":break;case"defaultValue":N=he;default:l.hasOwnProperty(Q)||Tt(i,n,Q,null,l,he)}}for(var X in l){var Q=l[X];if(he=a[X],l.hasOwnProperty(X)&&(Q!=null||he!=null))switch(X){case"type":d=Q;break;case"name":u=Q;break;case"checked":$=Q;break;case"defaultChecked":ae=Q;break;case"value":_=Q;break;case"defaultValue":C=Q;break;case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(s(137,n));break;default:Q!==he&&Tt(i,n,X,Q,l,he)}}es(i,_,C,N,$,ae,d,u);return;case"select":Q=_=C=X=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":Q=N;default:l.hasOwnProperty(d)||Tt(i,n,d,null,l,N)}for(u in l)if(d=l[u],N=a[u],l.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":X=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==N&&Tt(i,n,u,d,l,N)}n=C,a=_,l=Q,X!=null?fr(i,!!a,X,!1):!!l!=!!a&&(n!=null?fr(i,!!a,n,!0):fr(i,!!a,a?[]:"",!1));return;case"textarea":Q=X=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!l.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Tt(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":X=u;break;case"defaultValue":Q=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&Tt(i,n,_,u,l,d)}ts(i,X,Q);return;case"option":for(var Be in a)X=a[Be],a.hasOwnProperty(Be)&&X!=null&&!l.hasOwnProperty(Be)&&(Be==="selected"?i.selected=!1:Tt(i,n,Be,null,l,X));for(N in l)X=l[N],Q=a[N],l.hasOwnProperty(N)&&X!==Q&&(X!=null||Q!=null)&&(N==="selected"?i.selected=X&&typeof X!="function"&&typeof X!="symbol":Tt(i,n,N,X,l,Q));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Xe in a)X=a[Xe],a.hasOwnProperty(Xe)&&X!=null&&!l.hasOwnProperty(Xe)&&Tt(i,n,Xe,null,l,X);for($ in l)if(X=l[$],Q=a[$],l.hasOwnProperty($)&&X!==Q&&(X!=null||Q!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(s(137,n));break;default:Tt(i,n,$,X,l,Q)}return;default:if(is(n)){for(var Dt in a)X=a[Dt],a.hasOwnProperty(Dt)&&X!==void 0&&!l.hasOwnProperty(Dt)&&df(i,n,Dt,void 0,l,X);for(ae in l)X=l[ae],Q=a[ae],!l.hasOwnProperty(ae)||X===Q||X===void 0&&Q===void 0||df(i,n,ae,X,l,Q);return}}for(var U in a)X=a[U],a.hasOwnProperty(U)&&X!=null&&!l.hasOwnProperty(U)&&Tt(i,n,U,null,l,X);for(he in l)X=l[he],Q=a[he],!l.hasOwnProperty(he)||X===Q||X==null&&Q==null||Tt(i,n,he,X,l,Q)}function Ry(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Rx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&Ry(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var N=a[l],$=N.startTime;if($>C)break;var ae=N.transferSize,he=N.initiatorType;ae&&Ry(he)&&(N=N.responseEnd,_+=ae*(N<C?1:(C-$)/(N-$)))}if(--l,n+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return n/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var ff=null,pf=null;function su(i){return i.nodeType===9?i:i.ownerDocument}function My(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 Ny(i,n){if(i===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&n==="foreignObject"?0:i}function mf(i,n){return i==="textarea"||i==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var gf=null;function Mx(){var i=window.event;return i&&i.type==="popstate"?i===gf?!1:(gf=i,!0):(gf=null,!1)}var Ay=typeof setTimeout=="function"?setTimeout:void 0,Nx=typeof clearTimeout=="function"?clearTimeout:void 0,Ly=typeof Promise=="function"?Promise:void 0,Ax=typeof queueMicrotask=="function"?queueMicrotask:typeof Ly<"u"?function(i){return Ly.resolve(null).then(i).catch(Lx)}:Ay;function Lx(i){setTimeout(function(){throw i})}function ys(i){return i==="head"}function By(i,n){var a=n,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),ol(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")uo(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,uo(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[Bn]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&uo(i.ownerDocument.body);a=u}while(a);ol(n)}function Oy(i,n){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(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 _f(i){var n=i.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":_f(a),On(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Bx(i,n,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Bn])switch(n){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(n==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=Fn(i.nextSibling),i===null)break}return null}function Ox(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Fn(i.nextSibling),i===null))return null;return i}function zy(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=Fn(i.nextSibling),i===null))return null;return i}function vf(i){return i.data==="$?"||i.data==="$~"}function yf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function zx(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var l=function(){n(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function Fn(i){for(;i!=null;i=i.nextSibling){var n=i.nodeType;if(n===1||n===3)break;if(n===8){if(n=i.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return i}var bf=null;function jy(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return Fn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function Hy(i){i=i.previousSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return i;n--}else a!=="/$"&&a!=="/&"||n++}i=i.previousSibling}return null}function Py(i,n,a){switch(n=su(a),i){case"html":if(i=n.documentElement,!i)throw Error(s(452));return i;case"head":if(i=n.head,!i)throw Error(s(453));return i;case"body":if(i=n.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function uo(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);On(i)}var qn=new Map,Uy=new Set;function au(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Wr=V.d;V.d={f:jx,r:Hx,D:Px,C:Ux,L:Ix,m:Kx,X:Fx,S:Wx,M:qx};function jx(){var i=Wr.f(),n=Zc();return i||n}function Hx(i){var n=Bt(i);n!==null&&n.tag===5&&n.type==="form"?nv(n):Wr.r(i)}var sl=typeof document>"u"?null:document;function Iy(i,n,a){var l=sl;if(l&&typeof n=="string"&&n){var u=Gi(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),Uy.has(u)||(Uy.add(u),i={rel:i,crossOrigin:a,href:n},l.querySelector(u)===null&&(n=l.createElement("link"),$i(n,"link",i),Ot(n),l.head.appendChild(n)))}}function Px(i){Wr.D(i),Iy("dns-prefetch",i,null)}function Ux(i,n){Wr.C(i,n),Iy("preconnect",i,n)}function Ix(i,n,a){Wr.L(i,n,a);var l=sl;if(l&&i&&n){var u='link[rel="preload"][as="'+Gi(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Gi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Gi(a.imageSizes)+'"]')):u+='[href="'+Gi(i)+'"]';var d=u;switch(n){case"style":d=al(i);break;case"script":d=ll(i)}qn.has(d)||(i=y({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),qn.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(ho(d))||n==="script"&&l.querySelector(fo(d))||(n=l.createElement("link"),$i(n,"link",i),Ot(n),l.head.appendChild(n)))}}function Kx(i,n){Wr.m(i,n);var a=sl;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Gi(l)+'"][href="'+Gi(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=ll(i)}if(!qn.has(d)&&(i=y({rel:"modulepreload",href:i},n),qn.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(fo(d)))return}l=a.createElement("link"),$i(l,"link",i),Ot(l),a.head.appendChild(l)}}}function Wx(i,n,a){Wr.S(i,n,a);var l=sl;if(l&&i){var u=yn(l).hoistableStyles,d=al(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(ho(d)))C.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":n},a),(a=qn.get(d))&&Sf(i,a);var N=_=l.createElement("link");Ot(N),$i(N,"link",i),N._p=new Promise(function($,ae){N.onload=$,N.onerror=ae}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,lu(_,n,l)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function Fx(i,n){Wr.X(i,n);var a=sl;if(a&&i){var l=yn(a).hoistableScripts,u=ll(i),d=l.get(u);d||(d=a.querySelector(fo(u)),d||(i=y({src:i,async:!0},n),(n=qn.get(u))&&wf(i,n),d=a.createElement("script"),Ot(d),$i(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function qx(i,n){Wr.M(i,n);var a=sl;if(a&&i){var l=yn(a).hoistableScripts,u=ll(i),d=l.get(u);d||(d=a.querySelector(fo(u)),d||(i=y({src:i,async:!0,type:"module"},n),(n=qn.get(u))&&wf(i,n),d=a.createElement("script"),Ot(d),$i(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Ky(i,n,a,l){var u=(u=we.current)?au(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=al(a.href),a=yn(u).hoistableStyles,l=a.get(n),l||(l={type:"style",instance:null,count:0,state:null},a.set(n,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=al(a.href);var d=yn(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(ho(i)))&&!d._p&&(_.instance=d,_.state.loading=5),qn.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},qn.set(i,a),d||$x(u,i,a,_.state))),n&&l===null)throw Error(s(528,""));return _}if(n&&l!==null)throw Error(s(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=ll(a),a=yn(u).hoistableScripts,l=a.get(n),l||(l={type:"script",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function al(i){return'href="'+Gi(i)+'"'}function ho(i){return'link[rel="stylesheet"]['+i+"]"}function Wy(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function $x(i,n,a,l){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=i.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),$i(n,"link",a),Ot(n),i.head.appendChild(n))}function ll(i){return'[src="'+Gi(i)+'"]'}function fo(i){return"script[async]"+i}function Fy(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+Gi(a.href)+'"]');if(l)return n.instance=l,Ot(l),l;var u=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Ot(l),$i(l,"style",u),lu(l,a.precedence,i),n.instance=l;case"stylesheet":u=al(a.href);var d=i.querySelector(ho(u));if(d)return n.state.loading|=4,n.instance=d,Ot(d),d;l=Wy(a),(u=qn.get(u))&&Sf(l,u),d=(i.ownerDocument||i).createElement("link"),Ot(d);var _=d;return _._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),$i(d,"link",l),n.state.loading|=4,lu(d,a.precedence,i),n.instance=d;case"script":return d=ll(a.src),(u=i.querySelector(fo(d)))?(n.instance=u,Ot(u),u):(l=a,(u=qn.get(d))&&(l=y({},a),wf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),Ot(u),$i(u,"link",l),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,lu(l,a.precedence,i));return n.instance}function lu(i,n,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,d=u,_=0;_<l.length;_++){var C=l[_];if(C.dataset.precedence===n)d=C;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(i,n.firstChild))}function Sf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function wf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var ou=null;function qy(i,n,a){if(ou===null){var l=new Map,u=ou=new Map;u.set(a,l)}else u=ou,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Bn]||d[$t]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=l.get(_);C?C.push(d):l.set(_,[d])}}return l}function $y(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function Vx(i,n,a){if(a===1||n.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(i=n.disabled,typeof n.precedence=="string"&&i==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Vy(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Yx(i,n,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=al(l.href),d=n.querySelector(ho(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=cu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,Ot(d);return}d=n.ownerDocument||n,l=Wy(l),(u=qn.get(u))&&Sf(l,u),d=d.createElement("link"),Ot(d);var _=d;_._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),$i(d,"link",l),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=cu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var Cf=0;function Xx(i,n){return i.stylesheets&&i.count===0&&hu(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&hu(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&Cf===0&&(Cf=62500*Rx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&hu(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>Cf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function cu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)hu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var uu=null;function hu(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,uu=new Map,n.forEach(Gx,i),uu=null,cu.call(i))}function Gx(i,n){if(!(n.state.loading&4)){var a=uu.get(i);if(a)var l=a.get(null);else{a=new Map,uu.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||l,d===l&&a.set(null,u),a.set(_,u),this.count++,l=cu.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var po={$$typeof:W,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function Zx(i,n,a,l,u,d,_,C,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hi(0),this.hiddenUpdates=hi(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function Yy(i,n,a,l,u,d,_,C,N,$,ae,he){return i=new Zx(i,n,a,_,N,$,ae,he,C),n=1,d===!0&&(n|=24),d=Cn(3,null,null,n),i.current=d,d.stateNode=i,n=td(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},sd(d),i}function Xy(i){return i?(i=Ha,i):Ha}function Gy(i,n,a,l,u,d){u=Xy(u),l.context===null?l.context=u:l.pendingContext=u,l=os(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=cs(i,l,n),a!==null&&(dn(a,i,n),ql(a,i,n))}function Zy(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function xf(i,n){Zy(i,n),(i=i.alternate)&&Zy(i,n)}function Qy(i){if(i.tag===13||i.tag===31){var n=Ys(i,67108864);n!==null&&dn(n,i,67108864),xf(i,67108864)}}function Jy(i){if(i.tag===13||i.tag===31){var n=Dn();n=_n(n);var a=Ys(i,n);a!==null&&dn(a,i,n),xf(i,n)}}var du=!0;function Qx(i,n,a,l){var u=M.T;M.T=null;var d=V.p;try{V.p=2,Ef(i,n,a,l)}finally{V.p=d,M.T=u}}function Jx(i,n,a,l){var u=M.T;M.T=null;var d=V.p;try{V.p=8,Ef(i,n,a,l)}finally{V.p=d,M.T=u}}function Ef(i,n,a,l){if(du){var u=kf(l);if(u===null)hf(i,n,l,fu,a),tb(i,l);else if(tE(u,i,n,a,l))l.stopPropagation();else if(tb(i,l),n&4&&-1<eE.indexOf(i)){for(;u!==null;){var d=Bt(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=bt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var N=1<<31-gt(_);C.entanglements[1]|=N,_&=~N}vr(d),(_t&6)===0&&(Xc=He()+500,lo(0))}}break;case 31:case 13:C=Ys(d,2),C!==null&&dn(C,d,2),Zc(),xf(d,2)}if(d=kf(l),d===null&&hf(i,n,l,fu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else hf(i,n,l,null,a)}}function kf(i){return i=Ue(i),Tf(i)}var fu=null;function Tf(i){if(fu=null,i=zn(i),i!==null){var n=c(i);if(n===null)i=null;else{var a=n.tag;if(a===13){if(i=h(n),i!==null)return i;i=null}else if(a===31){if(i=p(n),i!==null)return i;i=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;i=null}else n!==i&&(i=null)}}return fu=i,null}function eb(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(vt()){case yi:return 2;case Ri:return 8;case ge:case We:return 32;case dt:return 268435456;default:return 32}default:return 32}}var Df=!1,bs=null,Ss=null,ws=null,mo=new Map,go=new Map,Cs=[],eE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function tb(i,n){switch(i){case"focusin":case"focusout":bs=null;break;case"dragenter":case"dragleave":Ss=null;break;case"mouseover":case"mouseout":ws=null;break;case"pointerover":case"pointerout":mo.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":go.delete(n.pointerId)}}function _o(i,n,a,l,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:l,nativeEvent:d,targetContainers:[u]},n!==null&&(n=Bt(n),n!==null&&Qy(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function tE(i,n,a,l,u){switch(n){case"focusin":return bs=_o(bs,i,n,a,l,u),!0;case"dragenter":return Ss=_o(Ss,i,n,a,l,u),!0;case"mouseover":return ws=_o(ws,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return mo.set(d,_o(mo.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,go.set(d,_o(go.get(d)||null,i,n,a,l,u)),!0}return!1}function ib(i){var n=zn(i.target);if(n!==null){var a=c(n);if(a!==null){if(n=a.tag,n===13){if(n=h(a),n!==null){i.blockedOn=n,vn(i.priority,function(){Jy(a)});return}}else if(n===31){if(n=p(a),n!==null){i.blockedOn=n,vn(i.priority,function(){Jy(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function pu(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=kf(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);te=l,a.target.dispatchEvent(l),te=null}else return n=Bt(a),n!==null&&Qy(n),i.blockedOn=a,!1;n.shift()}return!0}function nb(i,n,a){pu(i)&&a.delete(n)}function iE(){Df=!1,bs!==null&&pu(bs)&&(bs=null),Ss!==null&&pu(Ss)&&(Ss=null),ws!==null&&pu(ws)&&(ws=null),mo.forEach(nb),go.forEach(nb)}function mu(i,n){i.blockedOn===n&&(i.blockedOn=null,Df||(Df=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,iE)))}var gu=null;function rb(i){gu!==i&&(gu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){gu===i&&(gu=null);for(var n=0;n<i.length;n+=3){var a=i[n],l=i[n+1],u=i[n+2];if(typeof l!="function"){if(Tf(l||a)===null)continue;break}var d=Bt(a);d!==null&&(i.splice(n,3),n-=3,Ed(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function ol(i){function n(N){return mu(N,i)}bs!==null&&mu(bs,i),Ss!==null&&mu(Ss,i),ws!==null&&mu(ws,i),mo.forEach(n),go.forEach(n);for(var a=0;a<Cs.length;a++){var l=Cs[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Cs.length&&(a=Cs[0],a.blockedOn===null);)ib(a),a.blockedOn===null&&Cs.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],d=a[l+1],_=u[wi]||null;if(typeof d=="function")_||rb(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[wi]||null)C=_.formAction;else if(Tf(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),rb(a)}}}function sb(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Rf(i){this._internalRoot=i}_u.prototype.render=Rf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(s(409));var a=n.current,l=Dn();Gy(a,l,i,n,null,null)},_u.prototype.unmount=Rf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Gy(i.current,2,null,i,null,null),Zc(),n[Ln]=null}};function _u(i){this._internalRoot=i}_u.prototype.unstable_scheduleHydration=function(i){if(i){var n=tn();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Cs.length&&n!==0&&n<Cs[a].priority;a++);Cs.splice(a,0,i),a===0&&ib(i)}};var ab=t.version;if(ab!=="19.2.6")throw Error(s(527,ab,"19.2.6"));V.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(n),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var nE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var vu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!vu.isDisabled&&vu.supportsFiber)try{zt=vu.inject(nE),ii=vu}catch{}}return yo.createRoot=function(i,n){if(!o(i))throw Error(s(299));var a=!1,l="",u=fv,d=pv,_=mv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=Yy(i,1,!1,null,null,a,l,null,u,d,_,sb),i[Ln]=n.current,uf(i),new Rf(n)},yo.hydrateRoot=function(i,n,a){if(!o(i))throw Error(s(299));var l=!1,u="",d=fv,_=pv,C=mv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(C=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),n=Yy(i,1,!0,n,a??null,l,u,N,d,_,C,sb),n.context=Xy(null),a=n.current,l=Dn(),l=_n(l),u=os(l),u.callback=null,cs(a,u,l),a=l,n.current.lanes=a,bi(n,a),vr(n),i[Ln]=n.current,uf(i),new _u(n)},yo.version="19.2.6",yo}var gb;function fE(){if(gb)return Af.exports;gb=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(),Af.exports=dE(),Af.exports}var pE=fE();class or extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}status}function fh(e=fetch){return{getSession:(t={})=>Oe(e,`/api/auth/session${Io(t)}`),setupPassword:t=>Oe(e,"/api/auth/password",ct("POST",t)),login:t=>Oe(e,"/api/auth/login",ct("POST",t)),reauth:t=>Oe(e,"/api/auth/reauth",ct("POST",t)),logout:()=>Oe(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Oe(e,"/api/client-diagnostics",ct("POST",t)),setupTotp:()=>Oe(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Oe(e,"/api/auth/totp/activate",ct("POST",t)),disableTotp:()=>Oe(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Oe(e,"/api/auth/devices"),revokeDevice:async t=>{await hl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Oe(e,"/api/auth/networks"),addNetwork:t=>Oe(e,"/api/auth/networks",ct("POST",t)),removeNetwork:async t=>{await hl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Oe(e,"/api/agents"),addAgent:t=>Oe(e,"/api/agents",ct("POST",t)),reorderAgents:t=>Oe(e,"/api/agents/order",ct("PUT",{serverIds:t})),renameAgent:(t,r)=>Oe(e,`/api/agents/${encodeURIComponent(t)}`,ct("PATCH",{name:r})),getMainInfo:()=>Oe(e,"/api/main"),renameMain:t=>Oe(e,"/api/main",ct("PATCH",{name:t})),removeAgent:async t=>{await hl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Oe(e,"/api/stats"),getAgentStats:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Oe(e,"/api/version"),checkUpdate:()=>Oe(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Oe(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Oe(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Oe(e,"/api/terminals"),getTerminalLayout:()=>Oe(e,"/api/terminal-layout"),saveTerminalLayout:t=>Oe(e,"/api/terminal-layout",ct("PUT",t)),createFileRoot:t=>Oe(e,"/api/files/root",ct("POST",t)),listFiles:t=>Oe(e,"/api/files/list",ct("POST",t)),readFile:t=>Oe(e,"/api/files/read",ct("POST",t)),writeFile:t=>Oe(e,"/api/files/write",ct("POST",t)),createFileEntry:t=>Oe(e,"/api/files/create",ct("POST",t)),moveFileEntry:t=>Oe(e,"/api/files/move",ct("POST",t)),previewDeleteFileEntry:t=>Oe(e,"/api/files/delete-preview",ct("POST",t)),deleteFileEntry:t=>Oe(e,"/api/files/delete",ct("POST",t)),openFileInTerminal:t=>Oe(e,"/api/files/open",ct("POST",t)),previewFile:t=>v0(e,"/api/files/preview",ct("POST",t)),createTerminal:(t={})=>Oe(e,"/api/terminals",ct("POST",t)),closeTerminal:async t=>{await hl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,r)=>Oe(e,`/api/terminals/${encodeURIComponent(t)}`,ct("PATCH",{title:r})),getTerminalHistory:(t,r={})=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/history${Io(r)}`),getTerminalTranscriptHistory:(t,r={})=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Io(r)}`),getTerminalTranscriptSource:t=>Oe(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Oe(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const r=new FormData;return r.append("asset",t),Oe(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:r})},updateNotificationAssetSelection:t=>Oe(e,"/api/notification-assets/selection",ct("PUT",t)),deleteNotificationAsset:async t=>{await hl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function Yo(e,t=fetch){const r=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Oe(t,r("terminals")),createTerminal:(s={})=>Oe(t,r("terminals"),ct("POST",s)),closeTerminal:async s=>{await hl(t,r(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>Oe(t,r(`terminals/${encodeURIComponent(s)}`),ct("PATCH",{title:o})),getTerminalHistory:(s,o={})=>Oe(t,`${r(`terminals/${encodeURIComponent(s)}/history`)}${Io(o)}`),getTerminalTranscriptHistory:(s,o={})=>Oe(t,`${r(`terminals/${encodeURIComponent(s)}/transcript-history`)}${Io(o)}`),getTerminalTranscriptSource:s=>Oe(t,r(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Oe(t,r("terminal-layout")),saveTerminalLayout:s=>Oe(t,r("terminal-layout"),ct("PUT",s)),createFileRoot:s=>Oe(t,r("files/root"),ct("POST",s)),listFiles:s=>Oe(t,r("files/list"),ct("POST",s)),readFile:s=>Oe(t,r("files/read"),ct("POST",s)),writeFile:s=>Oe(t,r("files/write"),ct("POST",s)),createFileEntry:s=>Oe(t,r("files/create"),ct("POST",s)),moveFileEntry:s=>Oe(t,r("files/move"),ct("POST",s)),previewDeleteFileEntry:s=>Oe(t,r("files/delete-preview"),ct("POST",s)),deleteFileEntry:s=>Oe(t,r("files/delete"),ct("POST",s)),openFileInTerminal:s=>Oe(t,r("files/open"),ct("POST",s)),previewFile:s=>v0(t,r("files/preview"),ct("POST",s)),createWebSocketUrl:(s,o=window.location.href)=>mE(r(`terminals/${encodeURIComponent(s)}/ws`),o)}}function mE(e,t){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=e,r.search="",r.hash="",r.toString()}function ct(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Io(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource);const r=t.toString();return r?`?${r}`:""}async function Oe(e,t,r){const s=await e(t,r??{credentials:"same-origin"});await Pm(s);try{return await s.json()}catch{throw new or(s.status,"invalid_json_response")}}async function hl(e,t,r){const s=await e(t,r);await Pm(s)}async function v0(e,t,r){const s=await e(t,r);return await Pm(s),s.blob()}async function Pm(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const r=await e.json(),s=typeof r.error=="string"?r.error:r.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new or(e.status,t)}const Um="nterminal.theme.id",y0="nterminal.theme.accent",fp="nterminal:theme",$u=[{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",..._b({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",..._b({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],vl="midnight";function ph(e){return $u.some(t=>t.id===e)?e:vl}function Im(e){return $u.find(t=>t.id===e)??$u[0]}function zs(){if(typeof window>"u")return vl;try{const e=window.localStorage.getItem(Um);return e?ph(e):bE(window.localStorage.getItem(y0))}catch{return vl}}function gE(e){const t=ph(e);if(typeof window<"u"){try{window.localStorage.setItem(Um,t)}catch{}Km(t),window.dispatchEvent(new CustomEvent(fp,{detail:t}))}return t}function Km(e=zs()){if(typeof document>"u")return;const t=Im(ph(e)),r=document.documentElement;r.dataset.ntTheme=t.id,r.style.setProperty("color-scheme",t.mode),et(r,"--nt-bg",t.tokens.bg),et(r,"--nt-bg-2",t.tokens.bg2),et(r,"--nt-bg-sidebar",t.tokens.bgSidebar),et(r,"--nt-line",t.tokens.line),et(r,"--nt-line-2",t.tokens.line2),et(r,"--nt-fg",t.tokens.fg),et(r,"--nt-fg-2",t.tokens.fg2),et(r,"--nt-fg-3",t.tokens.fg3),et(r,"--nt-fg-4",t.tokens.fg4),et(r,"--nt-accent",t.tokens.accent),et(r,"--nt-accent-soft",t.tokens.accentSoft),et(r,"--nt-accent-glow",t.tokens.accentGlow),et(r,"--nt-on-accent",t.tokens.onAccent),et(r,"--nt-ok",t.tokens.ok),et(r,"--nt-danger",t.tokens.danger),et(r,"--nt-on-danger",t.tokens.onDanger),et(r,"--nt-danger-soft",t.tokens.dangerSoft),et(r,"--nt-danger-line",t.tokens.dangerLine),et(r,"--nt-warning",t.tokens.warning),et(r,"--nt-warn",t.tokens.warning),et(r,"--nt-warning-soft",t.tokens.warningSoft),et(r,"--nt-warning-glow",t.tokens.warningGlow),et(r,"--nt-scrim",t.tokens.scrim),et(r,"--nt-scrim-soft",t.tokens.scrimSoft),et(r,"--nt-shadow",t.tokens.shadow),et(r,"--nt-shadow-strong",t.tokens.shadowStrong),et(r,"--nt-floating-bg",t.tokens.floatingBg),et(r,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),et(r,"--nt-floating-bg-hover",t.tokens.floatingBgHover),et(r,"--nt-subtle-fill",t.tokens.subtleFill),et(r,"--nt-hover-fill",t.tokens.hoverFill),et(r,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),et(r,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),et(r,"--nt-transcript-user",t.tokens.transcriptUser),et(r,"--nt-transcript-assistant",t.tokens.transcriptAssistant),et(r,"--nt-transcript-tool",t.tokens.transcriptTool),et(r,"--nt-transcript-command",t.tokens.transcriptCommand),et(r,"--nt-transcript-code",t.tokens.transcriptCode),et(r,"--nt-transcript-search",t.tokens.transcriptSearch),et(r,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),et(r,"--nt-qr-bg",t.tokens.qrBg)}function _E(e=zs()){return Im(ph(e)).xterm}function Wm(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Um||r.key===y0)&&(Km(zs()),e())};return window.addEventListener(fp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(fp,e),window.removeEventListener("storage",t)}}function et(e,t,r){e.style.setProperty(t,r)}function _b(e){const t=vE(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 vE(e){const t=[];for(let r=16;r<=e;r+=1)t.push(yE(r));return t}function yE(e){if(e>=16&&e<=231){const t=e-16,r=[0,95,135,175,215,255],s=r[Math.floor(t/36)%6],o=r[Math.floor(t/6)%6],c=r[t%6];return vb(s,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return vb(t,t,t)}return"#000000"}function vb(e,t,r){return`#${zf(e)}${zf(t)}${zf(r)}`}function zf(e){return e.toString(16).padStart(2,"0")}function bE(e){return e==="signal-red"?"signal-red":vl}function b0(){const e=v.useSyncExternalStore(Wm,zs,()=>vl);return Im(e).mode==="light"?"-light":""}function S0({size:e=22}){const t=b0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function w0({height:e=18}){const t=b0(),r=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:r,height:e,alt:"NTerminal"})}var No=_0();const mh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fm(e){return"nodeType"in e}function mn(e){var t,r;return e?xl(e)?e:Fm(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function qm(e){const{Document:t}=mn(e);return e instanceof t}function ac(e){return xl(e)?!1:e instanceof mn(e).HTMLElement}function C0(e){return e instanceof mn(e).SVGElement}function El(e){return e?xl(e)?e.document:Fm(e)?qm(e)?e:ac(e)||C0(e)?e.ownerDocument:document:document:document}const js=mh?v.useLayoutEffect:v.useEffect;function $m(e){const t=v.useRef(e);return js(()=>{t.current=e}),v.useCallback(function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}function SE(){const e=v.useRef(null),t=v.useCallback((s,o)=>{e.current=setInterval(s,o)},[]),r=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function Xo(e,t){t===void 0&&(t=[e]);const r=v.useRef(e);return js(()=>{r.current!==e&&(r.current=e)},t),r}function lc(e,t){const r=v.useRef();return v.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function Vu(e){const t=$m(e),r=v.useRef(null),s=v.useCallback(o=>{o!==r.current&&t?.(o,r.current),r.current=o},[]);return[r,s]}function pp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let jf={};function gh(e,t){return v.useMemo(()=>{if(t)return t;const r=jf[e]==null?0:jf[e]+1;return jf[e]=r,e+"-"+r},[e,t])}function x0(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const b=c[g];b!=null&&(c[g]=b+e*f)}return c},{...t})}}const gl=x0(1),Yu=x0(-1);function wE(e){return"clientX"in e&&"clientY"in e}function E0(e){if(!e)return!1;const{KeyboardEvent:t}=mn(e.target);return t&&e instanceof t}function CE(e){if(!e)return!1;const{TouchEvent:t}=mn(e.target);return t&&e instanceof t}function mp(e){if(CE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return wE(e)?{x:e.clientX,y:e.clientY}:null}const gp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[gp.Translate.toString(e),gp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),yb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xE(e){return e.matches(yb)?e:e.querySelector(yb)}const EE={display:"none"};function kE(e){let{id:t,value:r}=e;return Ti.createElement("div",{id:t,style:EE},r)}function TE(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ti.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},r)}function DE(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const k0=v.createContext(null);function RE(e){const t=v.useContext(k0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ME(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:o,event:c}=s;e.forEach(h=>{var p;return(p=h[o])==null?void 0:p.call(h,c)})},[e]),t]}const NE={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
- `},AE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function LE(e){let{announcements:t=AE,container:r,hiddenTextDescribedById:s,screenReaderInstructions:o=NE}=e;const{announce:c,announcement:h}=DE(),p=gh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),RE(v.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:w}=y;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(y){let{active:S,over:w}=y;c(t.onDragOver({active:S,over:w}))},onDragEnd(y){let{active:S,over:w}=y;c(t.onDragEnd({active:S,over:w}))},onDragCancel(y){let{active:S,over:w}=y;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const b=Ti.createElement(Ti.Fragment,null,Ti.createElement(kE,{id:s,value:o.draggable}),Ti.createElement(TE,{id:p,announcement:h}));return r?No.createPortal(b,r):b}var ki;(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"})(ki||(ki={}));function Xu(){}function bb(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function BE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const cr=Object.freeze({x:0,y:0});function OE(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function zE(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function jE(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=o-s,p=c-r;if(s<o&&r<c){const g=t.width*t.height,f=e.width*e.height,b=h*p,y=b/(g+f-b);return Number(y.toFixed(4))}return 0}const HE=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const o=[];for(const c of s){const{id:h}=c,p=r.get(h);if(p){const g=jE(p,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(OE)};function PE(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function T0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:cr}function UE(e){return function(r){for(var s=arguments.length,o=new Array(s>1?s-1:0),c=1;c<s;c++)o[c-1]=arguments[c];return o.reduce((h,p)=>({...h,top:h.top+e*p.y,bottom:h.bottom+e*p.y,left:h.left+e*p.x,right:h.right+e*p.x}),{...r})}}const IE=UE(1);function KE(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 WE(e,t,r){const s=KE(t);if(!s)return e;const{scaleX:o,scaleY:c,x:h,y:p}=s,g=e.left-h-(1-o)*parseFloat(r),f=e.top-p-(1-c)*parseFloat(r.slice(r.indexOf(" ")+1)),b=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:g+b,bottom:f+y,left:g}}const FE={ignoreTransform:!1};function oc(e,t){t===void 0&&(t=FE);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=mn(e).getComputedStyle(e);f&&(r=WE(r,f,b))}const{top:s,left:o,width:c,height:h,bottom:p,right:g}=r;return{top:s,left:o,width:c,height:h,bottom:p,right:g}}function Sb(e){return oc(e,{ignoreTransform:!0})}function qE(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function $E(e,t){return t===void 0&&(t=mn(e).getComputedStyle(e)),t.position==="fixed"}function VE(e,t){t===void 0&&(t=mn(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?r.test(c):!1})}function Vm(e,t){const r=[];function s(o){if(t!=null&&r.length>=t||!o)return r;if(qm(o)&&o.scrollingElement!=null&&!r.includes(o.scrollingElement))return r.push(o.scrollingElement),r;if(!ac(o)||C0(o)||r.includes(o))return r;const c=mn(e).getComputedStyle(o);return o!==e&&VE(o,c)&&r.push(o),$E(o,c)?r:s(o.parentNode)}return e?s(e):r}function D0(e){const[t]=Vm(e,1);return t??null}function Hf(e){return!mh||!e?null:xl(e)?e:Fm(e)?qm(e)||e===El(e).scrollingElement?window:ac(e)?e:null:null}function R0(e){return xl(e)?e.scrollX:e.scrollLeft}function M0(e){return xl(e)?e.scrollY:e.scrollTop}function _p(e){return{x:R0(e),y:M0(e)}}var Oi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Oi||(Oi={}));function N0(e){return!mh||!e?!1:e===document.scrollingElement}function A0(e){const t={x:0,y:0},r=N0(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=s.y,p=e.scrollLeft>=s.x;return{isTop:o,isLeft:c,isBottom:h,isRight:p,maxScroll:s,minScroll:t}}const YE={x:.2,y:.2};function XE(e,t,r,s,o){let{top:c,left:h,right:p,bottom:g}=r;s===void 0&&(s=10),o===void 0&&(o=YE);const{isTop:f,isBottom:b,isLeft:y,isRight:S}=A0(e),w={x:0,y:0},k={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+T.height?(w.y=Oi.Backward,k.y=s*Math.abs((t.top+T.height-c)/T.height)):!b&&g>=t.bottom-T.height&&(w.y=Oi.Forward,k.y=s*Math.abs((t.bottom-T.height-g)/T.height)),!S&&p>=t.right-T.width?(w.x=Oi.Forward,k.x=s*Math.abs((t.right-T.width-p)/T.width)):!y&&h<=t.left+T.width&&(w.x=Oi.Backward,k.x=s*Math.abs((t.left+T.width-h)/T.width)),{direction:w,speed:k}}function GE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:r,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function L0(e){return e.reduce((t,r)=>gl(t,_p(r)),cr)}function ZE(e){return e.reduce((t,r)=>t+R0(r),0)}function QE(e){return e.reduce((t,r)=>t+M0(r),0)}function JE(e,t){if(t===void 0&&(t=oc),!e)return;const{top:r,left:s,bottom:o,right:c}=t(e);D0(e)&&(o<=0||c<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ek=[["x",["left","right"],ZE],["y",["top","bottom"],QE]];class Ym{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Vm(r),o=L0(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of ek)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(s),b=o[c]-f;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ko{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var o;(o=this.target)==null||o.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function tk(e){const{EventTarget:t}=mn(e);return e instanceof t?e:El(e)}function Pf(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var Yn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Yn||(Yn={}));function wb(e){e.preventDefault()}function ik(e){e.stopPropagation()}var Lt;(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"})(Lt||(Lt={}));const B0={start:[Lt.Space,Lt.Enter],cancel:[Lt.Esc],end:[Lt.Space,Lt.Enter,Lt.Tab]},nk=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Lt.Right:return{...r,x:r.x+25};case Lt.Left:return{...r,x:r.x-25};case Lt.Down:return{...r,y:r.y+25};case Lt.Up:return{...r,y:r.y-25}}};class O0{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:r}}=t;this.props=t,this.listeners=new Ko(El(r)),this.windowListeners=new Ko(mn(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Yn.Resize,this.handleCancel),this.windowListeners.add(Yn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Yn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&JE(s),r(cr)}handleKeyDown(t){if(E0(t)){const{active:r,context:s,options:o}=this.props,{keyboardCodes:c=B0,coordinateGetter:h=nk,scrollBehavior:p="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,b=f?{x:f.left,y:f.top}:cr;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:r,context:s.current,currentCoordinates:b});if(y){const S=Yu(y,b),w={x:0,y:0},{scrollableAncestors:k}=s.current;for(const T of k){const B=t.code,{isTop:L,isRight:A,isLeft:W,isBottom:K,maxScroll:J,minScroll:ne}=A0(T),le=GE(T),oe={x:Math.min(B===Lt.Right?le.right-le.width/2:le.right,Math.max(B===Lt.Right?le.left:le.left+le.width/2,y.x)),y:Math.min(B===Lt.Down?le.bottom-le.height/2:le.bottom,Math.max(B===Lt.Down?le.top:le.top+le.height/2,y.y))},ve=B===Lt.Right&&!A||B===Lt.Left&&!W,P=B===Lt.Down&&!K||B===Lt.Up&&!L;if(ve&&oe.x!==y.x){const I=T.scrollLeft+S.x,F=B===Lt.Right&&I<=J.x||B===Lt.Left&&I>=ne.x;if(F&&!S.y){T.scrollTo({left:I,behavior:p});return}F?w.x=T.scrollLeft-I:w.x=B===Lt.Right?T.scrollLeft-J.x:T.scrollLeft-ne.x,w.x&&T.scrollBy({left:-w.x,behavior:p});break}else if(P&&oe.y!==y.y){const I=T.scrollTop+S.y,F=B===Lt.Down&&I<=J.y||B===Lt.Up&&I>=ne.y;if(F&&!S.x){T.scrollTo({top:I,behavior:p});return}F?w.y=T.scrollTop-I:w.y=B===Lt.Down?T.scrollTop-J.y:T.scrollTop-ne.y,w.y&&T.scrollBy({top:-w.y,behavior:p});break}}this.handleMove(t,gl(Yu(y,this.referenceCoordinates),w))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}O0.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=B0,onActivation:o}=t,{active:c}=r;const{code:h}=e.nativeEvent;if(s.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Cb(e){return!!(e&&"distance"in e)}function xb(e){return!!(e&&"delay"in e)}class Xm{constructor(t,r,s){var o;s===void 0&&(s=tk(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=r;const{event:c}=t,{target:h}=c;this.props=t,this.events=r,this.document=El(h),this.documentListeners=new Ko(this.document),this.listeners=new Ko(s),this.windowListeners=new Ko(mn(h)),this.initialCoordinates=(o=mp(c))!=null?o:cr,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:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Yn.Resize,this.handleCancel),this.windowListeners.add(Yn.DragStart,wb),this.windowListeners.add(Yn.VisibilityChange,this.handleCancel),this.windowListeners.add(Yn.ContextMenu,wb),this.documentListeners.add(Yn.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(xb(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Cb(r)){this.handlePending(r);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,r){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Yn.Click,ik,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Yn.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:o,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!o)return;const g=(r=mp(t))!=null?r:cr,f=Yu(o,g);if(!s&&p){if(Cb(p)){if(p.tolerance!=null&&Pf(f,p.tolerance))return this.handleCancel();if(Pf(f,p.distance))return this.handleStart()}if(xb(p)&&Pf(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Lt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const rk={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class z0 extends Xm{constructor(t){const{event:r}=t,s=El(r.target);super(t,rk,s)}}z0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s?.({event:r}),!0)}}];const sk={move:{name:"mousemove"},end:{name:"mouseup"}};var vp;(function(e){e[e.RightClick=2]="RightClick"})(vp||(vp={}));class j0 extends Xm{constructor(t){super(t,sk,El(t.event.target))}}j0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===vp.RightClick?!1:(s?.({event:r}),!0)}}];const Uf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class H0 extends Xm{constructor(t){super(t,Uf)}static setup(){return window.addEventListener(Uf.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Uf.move.name,t)};function t(){}}}H0.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:o}=r;return o.length>1?!1:(s?.({event:r}),!0)}}];var Wo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Wo||(Wo={}));var Gu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gu||(Gu={}));function ak(e){let{acceleration:t,activator:r=Wo.Pointer,canScroll:s,draggingRect:o,enabled:c,interval:h=5,order:p=Gu.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:S}=e;const w=ok({delta:y,disabled:!c}),[k,T]=SE(),B=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),A=v.useMemo(()=>{switch(r){case Wo.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Wo.DraggableRect:return o}},[r,o,g]),W=v.useRef(null),K=v.useCallback(()=>{const ne=W.current;if(!ne)return;const le=B.current.x*L.current.x,oe=B.current.y*L.current.y;ne.scrollBy(le,oe)},[]),J=v.useMemo(()=>p===Gu.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!A){T();return}for(const ne of J){if(s?.(ne)===!1)continue;const le=f.indexOf(ne),oe=b[le];if(!oe)continue;const{direction:ve,speed:P}=XE(ne,oe,A,t,S);for(const I of["x","y"])w[I][ve[I]]||(P[I]=0,ve[I]=0);if(P.x>0||P.y>0){T(),W.current=ne,k(K,h),B.current=P,L.current=ve;return}}B.current={x:0,y:0},L.current={x:0,y:0},T()},[t,K,s,T,c,h,JSON.stringify(A),JSON.stringify(w),k,f,J,b,JSON.stringify(S)])}const lk={x:{[Oi.Backward]:!1,[Oi.Forward]:!1},y:{[Oi.Backward]:!1,[Oi.Forward]:!1}};function ok(e){let{delta:t,disabled:r}=e;const s=pp(t);return lc(o=>{if(r||!s||!o)return lk;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Oi.Backward]:o.x[Oi.Backward]||c.x===-1,[Oi.Forward]:o.x[Oi.Forward]||c.x===1},y:{[Oi.Backward]:o.y[Oi.Backward]||c.y===-1,[Oi.Forward]:o.y[Oi.Forward]||c.y===1}}},[r,t,s])}function ck(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return lc(o=>{var c;return t==null?null:(c=s??o)!=null?c:null},[s,t])}function uk(e,t){return v.useMemo(()=>e.reduce((r,s)=>{const{sensor:o}=s,c=o.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,s)}));return[...r,...c]},[]),[e,t])}var Go;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Go||(Go={}));var yp;(function(e){e.Optimized="optimized"})(yp||(yp={}));const Eb=new Map;function hk(e,t){let{dragging:r,dependencies:s,config:o}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=o,b=v.useRef(e),y=B(),S=Xo(y),w=v.useCallback(function(L){L===void 0&&(L=[]),!S.current&&h(A=>A===null?L:A.concat(L.filter(W=>!A.includes(W))))},[S]),k=v.useRef(null),T=lc(L=>{if(y&&!r)return Eb;if(!L||L===Eb||b.current!==e||c!=null){const A=new Map;for(let W of e){if(!W)continue;if(c&&c.length>0&&!c.includes(W.id)&&W.rect.current){A.set(W.id,W.rect.current);continue}const K=W.node.current,J=K?new Ym(g(K),K):null;W.rect.current=J,J&&A.set(W.id,J)}return A}return L},[e,c,r,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||w()},[r,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof p!="number"||k.current!==null||(k.current=setTimeout(()=>{w(),k.current=null},p))},[p,y,w,...s]),{droppableRects:T,measureDroppableContainers:w,measuringScheduled:c!=null};function B(){switch(f){case Go.Always:return!1;case Go.BeforeDragging:return r;default:return!r}}}function P0(e,t){return lc(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function dk(e,t){return P0(e,t)}function fk(e){let{callback:t,disabled:r}=e;const s=$m(t),o=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,r]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function _h(e){let{callback:t,disabled:r}=e;const s=$m(t),o=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[r]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function pk(e){return new Ym(oc(e),e)}function kb(e,t,r){t===void 0&&(t=pk);const[s,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??r)!=null?f:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=fk({callback(g){if(e)for(const f of g){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=_h({callback:c});return js(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),s}function mk(e){const t=P0(e);return T0(e,t)}const Tb=[];function gk(e){const t=v.useRef(e),r=lc(s=>e?s&&s!==Tb&&e&&t.current&&e.parentNode===t.current.parentNode?s:Vm(e):Tb,[e]);return v.useEffect(()=>{t.current=e},[e]),r}function _k(e){const[t,r]=v.useState(null),s=v.useRef(e),o=v.useCallback(c=>{const h=Hf(c.target);h&&r(p=>p?(p.set(h,_p(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){h(c);const p=e.map(g=>{const f=Hf(g);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,_p(f)]):null}).filter(g=>g!=null);r(p.length?new Map(p):null),s.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=Hf(g);f?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>gl(c,h),cr):L0(e):cr,[e,t])}function Db(e,t){t===void 0&&(t=[]);const r=v.useRef(null);return v.useEffect(()=>{r.current=null},t),v.useEffect(()=>{const s=e!==cr;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?Yu(e,r.current):cr}function vk(e){v.useEffect(()=>{if(!mh)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function yk(e,t){return v.useMemo(()=>e.reduce((r,s)=>{let{eventName:o,handler:c}=s;return r[o]=h=>{c(h,t)},r},{}),[e,t])}function U0(e){return v.useMemo(()=>e?qE(e):null,[e])}const Rb=[];function bk(e,t){t===void 0&&(t=oc);const[r]=e,s=U0(r?mn(r):null),[o,c]=v.useState(Rb);function h(){c(()=>e.length?e.map(g=>N0(g)?s:new Ym(t(g),g)):Rb)}const p=_h({callback:h});return js(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),o}function Sk(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ac(t)?t:e}function wk(e){let{measure:t}=e;const[r,s]=v.useState(null),o=v.useCallback(f=>{for(const{target:b}of f)if(ac(b)){s(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=_h({callback:o}),h=v.useCallback(f=>{const b=Sk(f);c?.disconnect(),b&&c?.observe(b),s(b?t(b):null)},[t,c]),[p,g]=Vu(h);return v.useMemo(()=>({nodeRef:p,rect:r,setRef:g}),[r,p,g])}const Ck=[{sensor:z0,options:{}},{sensor:O0,options:{}}],xk={current:{}},Lu={draggable:{measure:Sb},droppable:{measure:Sb,strategy:Go.WhileDragging,frequency:yp.Optimized},dragOverlay:{measure:oc}};class Fo extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const Ek={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Fo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Xu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Lu,measureDroppableContainers:Xu,windowRect:null,measuringScheduled:!1},kk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Xu,draggableNodes:new Map,over:null,measureDroppableContainers:Xu},vh=v.createContext(kk),Tk=v.createContext(Ek);function Dk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Fo}}}function Rk(e,t){switch(t.type){case ki.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ki.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 ki.DragEnd:case ki.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ki.RegisterDroppable:{const{element:r}=t,{id:s}=r,o=new Fo(e.droppable.containers);return o.set(s,r),{...e,droppable:{...e.droppable,containers:o}}}case ki.SetDroppableDisabled:{const{id:r,key:s,disabled:o}=t,c=e.droppable.containers.get(r);if(!c||s!==c.key)return e;const h=new Fo(e.droppable.containers);return h.set(r,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case ki.UnregisterDroppable:{const{id:r,key:s}=t,o=e.droppable.containers.get(r);if(!o||s!==o.key)return e;const c=new Fo(e.droppable.containers);return c.delete(r),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function Mk(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:o}=v.useContext(vh),c=pp(s),h=pp(r?.id);return v.useEffect(()=>{if(!t&&!s&&c&&h!=null){if(!E0(c)||document.activeElement===c.target)return;const p=o.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[g.current,f.current]){if(!b)continue;const y=xE(b);if(y){y.focus();break}}})}},[s,t,o,h,c]),null}function Nk(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...s}),r):r}function Ak(e){return v.useMemo(()=>({draggable:{...Lu.draggable,...e?.draggable},droppable:{...Lu.droppable,...e?.droppable},dragOverlay:{...Lu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Lk(e){let{activeNode:t,measure:r,initialRect:s,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof o=="boolean"?{x:o,y:o}:o;js(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=r(f),y=T0(b,s);if(h||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=D0(f);S&&S.scrollBy({top:y.y,left:y.x})}},[t,h,p,s,r])}const I0=v.createContext({...cr,scaleX:1,scaleY:1});var Ns;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ns||(Ns={}));const Bk=v.memo(function(t){var r,s,o,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:b=Ck,collisionDetection:y=HE,measuring:S,modifiers:w,...k}=t;const T=v.useReducer(Rk,void 0,Dk),[B,L]=T,[A,W]=ME(),[K,J]=v.useState(Ns.Uninitialized),ne=K===Ns.Initialized,{draggable:{active:le,nodes:oe,translate:ve},droppable:{containers:P}}=B,I=le!=null?oe.get(le):null,F=v.useRef({initial:null,translated:null}),H=v.useMemo(()=>{var yt;return le!=null?{id:le,data:(yt=I?.data)!=null?yt:xk,rect:F}:null},[le,I]),j=v.useRef(null),[re,M]=v.useState(null),[V,Z]=v.useState(null),Ce=Xo(k,Object.values(k)),ke=gh("DndDescribedBy",h),R=v.useMemo(()=>P.getEnabled(),[P]),G=Ak(S),{droppableRects:se,measureDroppableContainers:_e,measuringScheduled:fe}=hk(R,{dragging:ne,dependencies:[ve.x,ve.y],config:G.droppable}),we=ck(oe,le),Ne=v.useMemo(()=>V?mp(V):null,[V]),je=Ii(),Ve=dk(we,G.draggable.measure);Lk({activeNode:le!=null?oe.get(le):null,config:je.layoutShiftCompensation,initialRect:Ve,measure:G.draggable.measure});const ee=kb(we,G.draggable.measure,Ve),me=kb(we?we.parentElement:null),De=v.useRef({activatorEvent:null,active:null,activeNode:we,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:oe,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=P.getNodeFor((r=De.current.over)==null?void 0:r.id),Re=wk({measure:G.dragOverlay.measure}),ze=(s=Re.nodeRef.current)!=null?s:we,Ke=ne?(o=Re.rect)!=null?o:ee:null,ce=!!(Re.nodeRef.current&&Re.rect),xe=mk(ce?null:ee),Le=U0(ze?mn(ze):null),Ae=gk(ne?be??we:null),Ie=bk(Ae),Y=Nk(w,{transform:{x:ve.x-xe.x,y:ve.y-xe.y,scaleX:1,scaleY:1},activatorEvent:V,active:H,activeNodeRect:ee,containerNodeRect:me,draggingNodeRect:Ke,over:De.current.over,overlayNodeRect:Re.rect,scrollableAncestors:Ae,scrollableAncestorRects:Ie,windowRect:Le}),Te=Ne?gl(Ne,ve):null,He=_k(Ae),vt=Db(He),yi=Db(He,[ee]),Ri=gl(Y,vt),ge=Ke?IE(Ke,Y):null,We=H&&ge?y({active:H,collisionRect:ge,droppableRects:se,droppableContainers:R,pointerCoordinates:Te}):null,dt=zE(We,"id"),[rt,Ft]=v.useState(null),zt=ce?Y:gl(Y,yi),ii=PE(zt,(c=rt?.rect)!=null?c:null,ee),qt=v.useRef(null),gt=v.useCallback((yt,bt)=>{let{sensor:Et,options:Mi}=bt;if(j.current==null)return;const ui=oe.get(j.current);if(!ui)return;const Xt=yt.nativeEvent,hi=new Et({active:j.current,activeNode:ui,event:Xt,options:Mi,context:De,onAbort(Ut){if(!oe.get(Ut))return;const{onDragAbort:ni}=Ce.current,Si={id:Ut};ni?.(Si),A({type:"onDragAbort",event:Si})},onPending(Ut,Ni,ni,Si){if(!oe.get(Ut))return;const{onDragPending:en}=Ce.current,tn={id:Ut,constraint:Ni,initialCoordinates:ni,offset:Si};en?.(tn),A({type:"onDragPending",event:tn})},onStart(Ut){const Ni=j.current;if(Ni==null)return;const ni=oe.get(Ni);if(!ni)return;const{onDragStart:Si}=Ce.current,_n={activatorEvent:Xt,active:{id:Ni,data:ni.data,rect:F}};No.unstable_batchedUpdates(()=>{Si?.(_n),J(Ns.Initializing),L({type:ki.DragStart,initialCoordinates:Ut,active:Ni}),A({type:"onDragStart",event:_n}),M(qt.current),Z(Xt)})},onMove(Ut){L({type:ki.DragMove,coordinates:Ut})},onEnd:bi(ki.DragEnd),onCancel:bi(ki.DragCancel)});qt.current=hi;function bi(Ut){return async function(){const{active:ni,collisions:Si,over:_n,scrollAdjustedTranslate:en}=De.current;let tn=null;if(ni&&en){const{cancelDrop:vn}=Ce.current;tn={activatorEvent:Xt,active:ni,collisions:Si,delta:en,over:_n},Ut===ki.DragEnd&&typeof vn=="function"&&await Promise.resolve(vn(tn))&&(Ut=ki.DragCancel)}j.current=null,No.unstable_batchedUpdates(()=>{L({type:Ut}),J(Ns.Uninitialized),Ft(null),M(null),Z(null),qt.current=null;const vn=Ut===ki.DragEnd?"onDragEnd":"onDragCancel";if(tn){const Xi=Ce.current[vn];Xi?.(tn),A({type:vn,event:tn})}})}}},[oe]),Yi=v.useCallback((yt,bt)=>(Et,Mi)=>{const ui=Et.nativeEvent,Xt=oe.get(Mi);if(j.current!==null||!Xt||ui.dndKit||ui.defaultPrevented)return;const hi={active:Xt};yt(Et,bt.options,hi)===!0&&(ui.dndKit={capturedBy:bt.sensor},j.current=Mi,gt(Et,bt))},[oe,gt]),gn=uk(b,Yi);vk(b),js(()=>{ee&&K===Ns.Initializing&&J(Ns.Initialized)},[ee,K]),v.useEffect(()=>{const{onDragMove:yt}=Ce.current,{active:bt,activatorEvent:Et,collisions:Mi,over:ui}=De.current;if(!bt||!Et)return;const Xt={active:bt,activatorEvent:Et,collisions:Mi,delta:{x:Ri.x,y:Ri.y},over:ui};No.unstable_batchedUpdates(()=>{yt?.(Xt),A({type:"onDragMove",event:Xt})})},[Ri.x,Ri.y]),v.useEffect(()=>{const{active:yt,activatorEvent:bt,collisions:Et,droppableContainers:Mi,scrollAdjustedTranslate:ui}=De.current;if(!yt||j.current==null||!bt||!ui)return;const{onDragOver:Xt}=Ce.current,hi=Mi.get(dt),bi=hi&&hi.rect.current?{id:hi.id,rect:hi.rect.current,data:hi.data,disabled:hi.disabled}:null,Ut={active:yt,activatorEvent:bt,collisions:Et,delta:{x:ui.x,y:ui.y},over:bi};No.unstable_batchedUpdates(()=>{Ft(bi),Xt?.(Ut),A({type:"onDragOver",event:Ut})})},[dt]),js(()=>{De.current={activatorEvent:V,active:H,activeNode:we,collisionRect:ge,collisions:We,droppableRects:se,draggableNodes:oe,draggingNode:ze,draggingNodeRect:Ke,droppableContainers:P,over:rt,scrollableAncestors:Ae,scrollAdjustedTranslate:Ri},F.current={initial:Ke,translated:ge}},[H,we,We,ge,oe,ze,Ke,se,P,rt,Ae,Ri]),ak({...je,delta:ve,draggingRect:ge,pointerCoordinates:Te,scrollableAncestors:Ae,scrollableAncestorRects:Ie});const Qn=v.useMemo(()=>({active:H,activeNode:we,activeNodeRect:ee,activatorEvent:V,collisions:We,containerNodeRect:me,dragOverlay:Re,draggableNodes:oe,droppableContainers:P,droppableRects:se,over:rt,measureDroppableContainers:_e,scrollableAncestors:Ae,scrollableAncestorRects:Ie,measuringConfiguration:G,measuringScheduled:fe,windowRect:Le}),[H,we,ee,V,We,me,Re,oe,P,se,rt,_e,Ae,Ie,G,fe,Le]),Mt=v.useMemo(()=>({activatorEvent:V,activators:gn,active:H,activeNodeRect:ee,ariaDescribedById:{draggable:ke},dispatch:L,draggableNodes:oe,over:rt,measureDroppableContainers:_e}),[V,gn,H,ee,L,ke,oe,rt,_e]);return Ti.createElement(k0.Provider,{value:W},Ti.createElement(vh.Provider,{value:Mt},Ti.createElement(Tk.Provider,{value:Qn},Ti.createElement(I0.Provider,{value:ii},f)),Ti.createElement(Mk,{disabled:p?.restoreFocus===!1})),Ti.createElement(LE,{...p,hiddenTextDescribedById:ke}));function Ii(){const yt=re?.autoScrollEnabled===!1,bt=typeof g=="object"?g.enabled===!1:g===!1,Et=ne&&!yt&&!bt;return typeof g=="object"?{...g,enabled:Et}:{enabled:Et}}}),Ok=v.createContext(null),Mb="button",zk="Draggable";function K0(e){let{id:t,data:r,disabled:s=!1,attributes:o}=e;const c=gh(zk),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:S}=v.useContext(vh),{role:w=Mb,roleDescription:k="draggable",tabIndex:T=0}=o??{},B=g?.id===t,L=v.useContext(B?I0:Ok),[A,W]=Vu(),[K,J]=Vu(),ne=yk(h,t),le=Xo(r);js(()=>(y.set(t,{id:t,key:c,node:A,activatorNode:K,data:le}),()=>{const ve=y.get(t);ve&&ve.key===c&&y.delete(t)}),[y,t]);const oe=v.useMemo(()=>({role:w,tabIndex:T,"aria-disabled":s,"aria-pressed":B&&w===Mb?!0:void 0,"aria-roledescription":k,"aria-describedby":b.draggable}),[s,w,T,B,k,b.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:oe,isDragging:B,listeners:s?void 0:ne,node:A,over:S,setNodeRef:W,setActivatorNodeRef:J,transform:L}}const jk="Droppable",Hk={timeout:25};function Gm(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:o}=e;const c=gh(jk),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(vh),b=v.useRef({disabled:r}),y=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:k,updateMeasurementsFor:T,timeout:B}={...Hk,...o},L=Xo(T??s),A=v.useCallback(()=>{if(!y.current){y.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(L.current)?L.current:[L.current]),w.current=null},B)},[B]),W=_h({callback:A,disabled:k||!h}),K=v.useCallback((oe,ve)=>{W&&(ve&&(W.unobserve(ve),y.current=!1),oe&&W.observe(oe))},[W]),[J,ne]=Vu(K),le=Xo(t);return v.useEffect(()=>{!W||!J.current||(W.disconnect(),y.current=!1,W.observe(J.current))},[J,W]),v.useEffect(()=>(p({type:ki.RegisterDroppable,element:{id:s,key:c,disabled:r,node:J,rect:S,data:le}}),()=>p({type:ki.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{r!==b.current.disabled&&(p({type:ki.SetDroppableDisabled,id:s,key:c,disabled:r}),b.current.disabled=r)},[s,c,r,p]),{active:h,rect:S,isOver:g?.id===s,node:J,over:g,setNodeRef:ne}}const Pk=128,Uk=512,kl=100,Ik="too_many_detached_terminals",Kk=64,Wk=4096;function W0(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>Pk)return null;const r=t.workspaces.map(Fk);return r.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function F0(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(r=>{if(!r||typeof r!="object")return!1;const s=r.detachedTerminalIds;return Array.isArray(s)&&s.length>kl}):!1}function Fk(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>Uk)return null;const r=t.tabs.map(qk);if(r.some(o=>o===null))return null;const s=Xk(t.detachedTerminalIds,kl);return s===null?null:{id:t.id,title:t.title,defaultCwd:Yk(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:r}}function qk(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 r=$k(t.root);return r?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:r}:null}function $k(e){if(!e||typeof e!="object")return null;let t=0;return bp(e,1,()=>(t+=1,t<=Wk))}function bp(e,t,r){if(!e||typeof e!="object"||t>Kk||!r())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const o=bp(s.first,t+1,r),c=bp(s.second,t+1,r);return!o||!c?null:{type:"split",direction:s.direction,ratio:Vk(s.ratio),first:o,second:c}}function Vk(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Yk(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Xk(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const r=new Set,s=[];for(const o of e)typeof o!="string"||!o||r.has(o)||(r.add(o),s.push(o));return s}const q0=[{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"}],pa="__main__";function Gk(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Zk(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Nb="Local",Qk=3e4,Jk=2,e2=6,$0="nterminal.serverList.viewMode.v1";function t2(){try{return window.localStorage.getItem($0)==="list"?"list":"stats"}catch{return"stats"}}function i2(e){try{window.localStorage.setItem($0,e)}catch{}}function ua(e,t){const r=[pa,...t.map(h=>h.id)],s=new Set(r),o=new Set,c=[];for(const h of e??[])!s.has(h)||o.has(h)||(o.add(h),c.push(h));for(const h of r)o.has(h)||c.push(h);return c}function n2(e,t){const r=new Map(e.map(s=>[s.id,s]));return ua(t,e).flatMap(s=>{if(s===pa)return[{kind:"main",id:pa}];const o=r.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function Ab(e,t){return e.length===t.length&&e.every((r,s)=>r===t[s])}function V0(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Gn(e.cpuPercent)} ${Zm(e)}`,`MEM ${Gn(e.memoryPercent)} ${Xr(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Gn(e.diskPercent)} ${Xr(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Gn(e.swapPercent)} ${Xr(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function r2(e){if(!(e===void 0||e==="error"))return[`CPU ${Gn(e.cpuPercent)} (${Zm(e)})`,`RAM ${Gn(e.memoryPercent)} (${Xr(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Gn(e.diskPercent)} (${Xr(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Gn(e.swapPercent)} (${Xr(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function s2(e,t){const r=V0(t);return`${e}${r?` — ${r}`:""}. Double-click to rename.`}function Gn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Zm(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`:`${Sp(e.cpuPercent/100*t)}/${t} cores`}function Xr(e,t){return!Lb(e)||!Lb(t)?"–/–":a2(e,t)}function a2(e,t){const r=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=r==="GB"?1024**3:r==="MB"?1024**2:1024;return`${Sp(e/s)}/${Sp(t/s)} ${r}`}function Sp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Lb(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function yu(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function l2(e){return[{label:"CPU",percent:Gn(e.cpuPercent),detail:Zm(e),tone:yu(e.cpuPercent)},{label:"MEM",percent:Gn(e.memoryPercent),detail:Xr(e.memoryUsedBytes,e.memoryTotalBytes),tone:yu(e.memoryPercent)},{label:"DISK",percent:Gn(e.diskPercent),detail:Xr(e.diskUsedBytes,e.diskTotalBytes),tone:yu(e.diskPercent)},{label:"SWAP",percent:Gn(e.swapPercent),detail:Xr(e.swapUsedBytes,e.swapTotalBytes),tone:yu(e.swapPercent)}]}function o2({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:r2(e),children:l2(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function Bb({api:e,activeAgentId:t,onSelectServer:r,onSessionInvalid:s,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,b]=v.useState([pa]),[y,S]=v.useState(null),[w,k]=v.useState(null),[T,B]=v.useState(""),L=v.useRef(null),[A,W]=v.useState(()=>t2()),[K,J]=v.useState(null),[ne,le]=v.useState(null),[oe,ve]=v.useState({}),P=v.useRef({}),I=v.useRef(0),F=v.useRef([]),H=v.useRef([pa]),j=v.useRef(null);v.useEffect(()=>{F.current=p},[p]),v.useEffect(()=>{const ee=ua(f,p);H.current=ee,Ab(ee,f)||b(ee)},[p,f]),v.useEffect(()=>{let ee=!1;return e.listAgents().then(me=>{ee||(g(me.agents),b(ua(me.serverOrder,me.agents)))}).catch(()=>{}),e.getMainInfo().then(me=>{ee||S(me.name)}).catch(()=>{}),()=>{ee=!0}},[e,o]),v.useEffect(()=>{w&&(L.current?.focus(),L.current?.select())},[w]),v.useEffect(()=>{let ee=!1;function me(){const be=[{key:"__main__",load:()=>e.getMainStats()},...p.map(ze=>({key:ze.id,load:()=>e.getAgentStats(ze.id)}))],Re=new Set(be.map(ze=>ze.key));for(const ze of Object.keys(P.current))Re.has(ze)||delete P.current[ze];ve(ze=>{const Ke={};for(const ce of Re)ce in ze&&(Ke[ce]=ze[ce]);return Ke});for(const ze of be)ze.load().then(Ke=>{ee||(P.current[ze.key]=0,ve(ce=>Re.has(ze.key)?{...ce,[ze.key]:Ke}:ce))}).catch(Ke=>{if(ee)return;if(Ke instanceof or&&Ke.status===401&&ze.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const ce=(P.current[ze.key]??0)+1;P.current[ze.key]=ce,ce>=Jk&&ve(xe=>Re.has(ze.key)?{...xe,[ze.key]:"error"}:xe)})}me();const De=window.setInterval(me,Qk);return()=>{ee=!0,window.clearInterval(De)}},[e,p,s]);function re(ee){ee==="main"?(B(y??""),k({kind:"main"})):(B(ee.name),k({kind:"agent",id:ee.id}))}async function M(){if(!w)return;const ee=T.trim(),me=w;if(k(null),me.kind==="main"){const De=ee||"";try{const be=await e.renameMain(De);S(be.name)}catch{}}else{if(!ee)return;const De=p.find(be=>be.id===me.id)?.name;g(be=>be.map(Re=>Re.id===me.id?{...Re,name:ee}:Re));try{await e.renameAgent(me.id,ee)}catch{De!==void 0&&g(be=>be.map(Re=>Re.id===me.id?{...Re,name:De}:Re))}}}function V(){k(null)}function Z(ee){W(ee),i2(ee)}function Ce(ee,me,De){if(ee===me)return;const be=ua(H.current,F.current),Re=be.findIndex(Ie=>Ie===ee),ze=be.findIndex(Ie=>Ie===me);if(Re<0||ze<0)return;const Ke=[...be],[ce]=Ke.splice(Re,1);if(!ce)return;const xe=Ke.findIndex(Ie=>Ie===me);if(xe<0)return;const Le=De==="before"?xe:xe+1;if(Ke.splice(Le,0,ce),Ab(Ke,be))return;const Ae=I.current+1;I.current=Ae,H.current=Ke,b(Ke),e.reorderAgents(Ke).then(Ie=>{if(I.current===Ae){F.current=Ie.agents;const Y=ua(Ie.serverOrder,Ie.agents);H.current=Y,g(Ie.agents),b(Y)}}).catch(async()=>{if(I.current===Ae)try{const Ie=await e.listAgents();if(I.current===Ae){F.current=Ie.agents;const Y=ua(Ie.serverOrder,Ie.agents);H.current=Y,g(Ie.agents),b(Y)}}catch{I.current===Ae&&(H.current=be,b(be))}})}function ke(ee,me){const De=ua(H.current,F.current),be=De.findIndex(ze=>ze===ee),Re=De[be+me];be<0||!Re||Ce(ee,Re,me<0?"before":"after")}function R(ee,me){me.pointerType==="mouse"&&me.button!==0||(me.stopPropagation(),j.current={sourceId:ee,pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,active:!1,targetId:null,placement:"after"},me.currentTarget.setPointerCapture?.(me.pointerId))}function G(ee){const me=j.current;if(!me||me.pointerId!==ee.pointerId)return;const De=Math.hypot(ee.clientX-me.startX,ee.clientY-me.startY);if(!me.active){if(De<e2)return;me.active=!0,J(me.sourceId)}const Re=document.elementFromPoint(ee.clientX,ee.clientY)?.closest("[data-server-id]"),ze=Re?.dataset.serverId??null;if(!Re||!ze||ze===me.sourceId){me.targetId=null,le(null);return}const Ke=Re.getBoundingClientRect(),ce=ee.clientY<Ke.top+Ke.height/2?"before":"after";me.targetId=ze,me.placement=ce,le({serverId:ze,placement:ce})}function se(ee){const me=j.current;!me||me.pointerId!==ee.pointerId||(ee.stopPropagation(),ee.currentTarget.releasePointerCapture?.(ee.pointerId),j.current=null,J(null),le(null),me.active&&me.targetId&&Ce(me.sourceId,me.targetId,me.placement))}function _e(ee){const me=j.current;me&&me.pointerId===ee.pointerId&&ee.currentTarget.releasePointerCapture?.(ee.pointerId),j.current=null,J(null),le(null)}const fe=y?.trim()||Nb,we=w?.kind==="main",Ne=A==="stats",je=n2(p,f),Ve=je.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:je.map(ee=>{const me=ee.kind==="main",De=me?fe:ee.agent.name,be=me?pa:ee.id,Re=oe[be],ze=V0(Re);return m.jsxs("button",{type:"button",className:`server-list-chip${(me?t===null:t===ee.id)?" server-list-chip--active":""}`,onClick:()=>r(me?null:ee.id),"aria-label":De,title:`${De}${ze?` — ${ze}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:Zk(De)}),m.jsx("span",{className:"server-list-chip-pip","data-status":Gk(Re)})]},ee.id)})}):m.jsxs("div",{className:`server-list server-list--${A}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":A==="list",onClick:()=>Z("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":A==="stats",onClick:()=>Z("stats"),title:"Show resource usage",children:"Stats"})]}),je.map(ee=>{const me=ee.kind==="main",De=me?fe:ee.agent.name,be=me?pa:ee.id,Re=me?t===null:t===ee.id,ze=me?we:w?.kind==="agent"&&w.id===ee.id,Ke=c?.({agentId:me?null:ee.id,serverId:ee.id,label:De,active:Re}),ce=ne?.serverId===ee.id&&K!==ee.id?` server-list-section--drop-target server-list-section--drop-${ne.placement}`:"";return m.jsxs("section",{className:`server-list-section${ce}`,"aria-label":`${De} server`,children:[m.jsx("div",{className:["server-list-row",K===ee.id?"server-list-row--dragging":"",ne?.serverId===ee.id&&K!==ee.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ee.id,children:ze?m.jsxs(m.Fragment,{children:[Ve?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:xe=>{xe.preventDefault(),M()},children:m.jsx("input",{ref:L,"aria-label":me?"Rename main server":`Rename ${De}`,value:T,onChange:xe=>B(xe.target.value),onBlur:()=>{M()},onKeyDown:xe=>{xe.key==="Escape"&&(xe.preventDefault(),V())},placeholder:me?Nb:void 0})})]}):m.jsxs(m.Fragment,{children:[Ve?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ee.id,title:"Drag to reorder","aria-label":`Reorder ${De}`,"aria-grabbed":K===ee.id,onPointerDown:xe=>R(ee.id,xe),onPointerMove:G,onPointerUp:se,onPointerCancel:_e,onKeyDown:xe=>{(xe.key==="ArrowUp"||xe.key==="ArrowDown")&&(xe.preventDefault(),xe.stopPropagation(),ke(ee.id,xe.key==="ArrowUp"?-1:1))},onClick:xe=>xe.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Re?" server-list-item--active":""}`,onClick:()=>r(me?null:ee.id),onDoubleClick:xe=>{xe.preventDefault(),re(me?"main":{id:ee.id,name:De})},title:s2(De,oe[be]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:me?void 0:ee.agent.url,children:De})]}),Ne?m.jsx(o2,{entry:oe[be]}):null]})]})}),Ke?m.jsx("div",{className:"server-list-children",children:Ke}):null]},ee.id)})]})}function c2({api:e}){const[t,r]=v.useState([]),[s,o]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,b]=v.useState(""),[y,S]=v.useState("");async function w(){try{const[L,A,W]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);r(L.devices),o(A.networks),h(W.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function k(L){await e.revokeDevice(L),await w()}async function T(L){await e.removeNetwork(L),await w()}async function B(L){L.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),S(""),await w()}catch(A){g(A instanceof Error?A.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[p?m.jsx("p",{className:"form-error",children:p}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[L.label,L.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(L.id)},children:"revoke"})]},L.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:s.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?m.jsx("span",{className:"security-item-meta",children:L.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(L.id)},children:"remove"})]},L.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:B,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:L=>b(L.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:L=>S(L.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.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."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const Y0="nterminal.notifications.completionEnabled",Qm="nterminal.notifications.completionToastEnabled",Jm="nterminal.notifications.completionToastDurationSeconds",eg="nterminal.notifications.completionToastPersistent",wp="nterminal:completion-toast-display",qo=6.5,Cp=2,xp=60;function yh(){return typeof window<"u"&&"Notification"in window}function X0(){try{return window.localStorage.getItem(Y0)==="true"}catch{return!1}}function Ob(e){try{window.localStorage.setItem(Y0,e?"true":"false")}catch{}}function ba(){return{enabled:f2(),durationSeconds:d2(),persistUntilDismissed:p2()}}function u2(e){if(typeof window<"u"){try{window.localStorage.setItem(Qm,e?"true":"false")}catch{}ig()}return ba()}function zb(e){const t=Z0(e);if(typeof window<"u"){try{window.localStorage.setItem(Jm,String(t))}catch{}ig()}return ba()}function h2(e){if(typeof window<"u"){try{window.localStorage.setItem(eg,e?"true":"false")}catch{}ig()}return ba()}function G0(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Qm||r.key===Jm||r.key===eg)&&e()};return window.addEventListener(wp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(wp,e),window.removeEventListener("storage",t)}}function tg(){return yh()?window.Notification.permission:"unsupported"}function d2(){if(typeof window>"u")return qo;try{const e=window.localStorage.getItem(Jm);return e===null?qo:Z0(Number(e))}catch{return qo}}function f2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Qm)!=="false"}catch{return!0}}function p2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eg)==="true"}catch{return!1}}function Z0(e){if(!Number.isFinite(e))return qo;const t=Math.round(e*2)/2;return Math.max(Cp,Math.min(xp,t))}function ig(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(wp))}async function m2(){if(!yh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return tg()}}function g2(e){if(!yh()||tg()!=="granted"||!X0()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const _2=1500,ng="nterminal.terminal.fontSize",rg="nterminal.terminal.fontFamily",Ep="nterminal:terminal-font-size",kp="nterminal:terminal-font-family",Tp=11,Dp=20,ga=14,Zu=[{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:[]}],yl="meslo";Rp(yl);async function If(e=ga,t=yl){if(typeof document>"u"||!document.fonts)return;const r=ew(t).webFontFamilies;if(r.length===0)return;const s=Promise.all(r.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(o=>{globalThis.setTimeout(o,_2)})])}function Q0(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return ga;const r=Math.round(t);return Math.max(Tp,Math.min(Dp,r))}function J0(e){return Zu.some(t=>t.id===e)?e:yl}function Rp(e){return ew(e).cssFamily}function ew(e){return Zu.find(t=>t.id===e)??Zu[0]}function Mp(){if(typeof window>"u")return ga;try{const e=window.localStorage.getItem(ng);return e?Q0(e):ga}catch{return ga}}function Np(){if(typeof window>"u")return yl;try{return J0(window.localStorage.getItem(rg))}catch{return yl}}function bu(e){const t=Q0(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ng,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Ep,{detail:t})),t}function v2(e){const t=J0(e);if(typeof window>"u")return t;try{window.localStorage.setItem(rg,t)}catch{}return window.dispatchEvent(new CustomEvent(kp,{detail:t})),t}function tw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===ng&&e()};return window.addEventListener(Ep,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ep,e),window.removeEventListener("storage",t)}}function iw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===rg&&e()};return window.addEventListener(kp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(kp,e),window.removeEventListener("storage",t)}}const sg="nterminal.terminal.showScrollProgress",Ap="nterminal:terminal-scroll-progress";function Lp(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(sg)!=="false"}catch{return!0}}function y2(e){if(typeof window<"u"){try{window.localStorage.setItem(sg,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Ap,{detail:e}))}return e}function nw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===sg&&e()};return window.addEventListener(Ap,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ap,e),window.removeEventListener("storage",t)}}const ag="nterminal.shortcuts.workspace.v1",Bp="nterminal:workspace-shortcuts",Zo=[{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}],bh={"server.previous":Bi("ArrowUp",{ctrlKey:!0}),"server.next":Bi("ArrowDown",{ctrlKey:!0}),"tab.previous":Bi("ArrowLeft",{ctrlKey:!0}),"tab.next":Bi("ArrowRight",{ctrlKey:!0}),"tab.index":Bi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Bi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Bi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Bi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Bi("KeyH",{altKey:!0})},b2={"server.previous":Bi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Bi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Bi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Bi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Bi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Bi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Bi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Bi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Bi("KeyH",{altKey:!0})};function Sa(){const e=aw(bh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(ag);if(!t)return e;const r=JSON.parse(t);for(const s of Zo){const o=r[s.id];if(D2(o)){const c=lw(o,s);T2(c,b2[s.id])||(e[s.id]=c)}}}catch{return e}return e}function jb(){return JSON.stringify(Sa())}function S2(e,t){const r=Sa(),s=Zo.find(o=>o.id===e);return s&&(r[e]=lw(t,s),cg(r)),r}function w2(e){const t=Sa();return t[e]={...bh[e]},cg(t),t}function C2(){const e=aw(bh);return cg(e),e}function lg(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===ag&&e()};return window.addEventListener(Bp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bp,e),window.removeEventListener("storage",t)}}function x2(e,t){const r=uw(e);return!r||M2(r)||t.indexed&&cw(e)===null||t.requiresPrimaryModifier&&!ow(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":r}}function rw(e){const t=Sa();for(const r of Zo){const s=t[r.id];if(!(!s||!R2(e,s))){if(r.indexed){if(s.code!=="Digit")continue;const o=cw(e);if(o!==null)return{id:r.id,index:o};continue}if(uw(e)===s.code)return{id:r.id,index:null}}}return null}function og(e){return sw(Sa()[e])}function sw(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(N2(e.code)),t.join("+")}const E2=()=>og("split.right"),k2=()=>og("split.down");function Bi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function aw(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r}]))}function T2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function cg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(ag,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Bp))}}function lw(e,t){return t.requiresPrimaryModifier&&!ow(e)?{...bh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function ow(e){return e.ctrlKey||e.altKey||e.metaKey}function D2(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 R2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function cw(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 uw(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 M2(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function N2(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const r=/^Key([A-Z])$/.exec(e);if(r?.[1])return r[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 A2="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 L2(e="nterminal",t=new Date){return{reason:"permission",message:A2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function B2(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 hw=3600*1e3,O2="local",Op=new Set,Bs=new Map;let Hs={checking:!1,hasUpdates:!1,lastCheckedAt:null},ug=null,$o=null,Qu=0,Ms=null;function z2(e){return Op.add(e),()=>{Op.delete(e)}}function Hb(){return Hs}function j2(e){const t=K2();ug=e,hg(),zp(e,t);const r=()=>{if(document.visibilityState!=="visible"||!Ps(e,t))return;const s=Hs.lastCheckedAt;(s===null||Date.now()-s>=hw)&&zp(e,t)};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r),Ps(e,t)&&I2()}}function H2(e,t){Bs.set(e,dw(t)),bl({...Hs,hasUpdates:dg(),lastCheckedAt:Date.now()})}function Kf(e){e===void 0?Bs.clear():Bs.set(e,!1),bl({...Hs,hasUpdates:dg()})}async function zp(e,t){if(!Ps(e,t))return;if(Ms&&Ms.api===e&&Ms.runId===t)return Ms.promise;bl({...Hs,checking:!0});const r=P2(e,t).finally(()=>{Ms?.promise===r&&(Ms=null),Ps(e,t)&&(bl({...Hs,checking:!1,lastCheckedAt:Date.now()}),U2(e,t))});return Ms={api:e,runId:t,promise:r},r}async function P2(e,t){try{const r=await e.listAgents();if(!Ps(e,t))return;const s=[{key:O2,check:()=>e.checkUpdate()},...r.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(s.map(async c=>{try{const h=await c.check();o.set(c.key,dw(h))}catch{o.set(c.key,Bs.get(c.key)??!1)}})),!Ps(e,t))return;Bs.clear();for(const[c,h]of o)Bs.set(c,h);bl({...Hs,hasUpdates:dg()})}catch{}}function U2(e,t){Ps(e,t)&&(hg(),$o=window.setTimeout(()=>{$o=null,Ps(e,t)&&zp(e,t)},hw))}function I2(){Qu+=1,hg(),ug=null,Ms=null,Bs.clear(),bl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function hg(){$o!==null&&(window.clearTimeout($o),$o=null)}function K2(){return Qu+=1,Qu}function Ps(e,t){return ug===e&&Qu===t}function dw(e){return e.updateAvailable===!0}function dg(){return Array.from(Bs.values()).some(Boolean)}function bl(e){Hs=e;for(const t of Array.from(Op))t()}const W2=e=>new Promise(t=>setTimeout(t,e));function F2({api:e,onAgentRemoved:t}){const[r,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[b,y]=v.useState(!1);function S(P,I){c(F=>({...F,[P]:{...F[P],...I}}))}const w=P=>P.id===null?e.getVersion():e.getAgentVersion(P.id),k=P=>P.id===null?e.checkUpdate():e.checkAgentUpdate(P.id),T=P=>P.id===null?e.runUpdate():e.runAgentUpdate(P.id);v.useEffect(()=>{let P=!1;return e.listAgents().then(I=>{if(P)return;const F=[{key:"local",id:null,name:"Local (main)"},...I.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];s(F);for(const H of F)w(H).then(j=>S(H.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(H.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{P=!0}},[]);async function B(P){S(P.key,{busy:!0,status:"checking…",error:void 0});try{const I=await k(P);H2(P.key,I),S(P.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:le(I),...I.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(I){S(P.key,{busy:!1,error:I instanceof Error?I.message:"check failed"})}}async function L(){p(!0),await Promise.all(r.map(P=>B(P))),p(!1)}async function A(P,I){const F=Date.now()+18e4;for(;Date.now()<F;){await W2(3e3);try{const H=await w(P);if(I&&H.runningVersion!==I.runningVersion)return H}catch{}}return null}async function W(P){let I=o[P.key]?.version;if(!I)try{I=await w(P),S(P.key,{version:I,manualUpdate:I.manualUpdate??null})}catch(j){return S(P.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(P.key,{busy:!0,status:"updating…",error:void 0});let F;try{F=await T(P)}catch(j){return S(P.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!F.ok){const j=F.manualUpdate??(B2(F.message)?L2():null);return j?(S(P.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(P.key,{busy:!1,status:void 0,error:F.message}),"failed")}if(!F.changed)return S(P.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Kf(P.key),"unchanged";S(P.key,{status:"restarting…"});const H=await A(P,I);return H?(S(P.key,{busy:!1,version:H,updateAvailable:!1,status:"updated",manualUpdate:H.manualUpdate??null}),Kf(P.key),P.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(P.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function K(P){if(!(P.id===null||!window.confirm([`Delete secondary server "${P.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(P.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const F=await e.uninstallAgent(P.id);s(H=>H.filter(j=>j.key!==P.key)),c(H=>{const j={...H};return delete j[P.key],j}),Kf(P.key),t?.(P.id),f(F.message)}catch(F){S(P.key,{busy:!1,status:void 0,error:F instanceof Error?F.message:"delete failed"})}}}async function J(){p(!0),f(null);const P=r.filter(M=>M.id!==null),I=r.find(M=>M.id===null),F=await Promise.all(P.map(M=>W(M))),H=F.filter(M=>M==="failed").length;let j=F.filter(M=>M==="manual").length,re=null;if(I&&(re=await W(I),re==="manual"&&(j+=1),re==="updated")){H>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}H>0&&j>0?f("Some servers failed and some need manual update. Check each marked row."):H>0?f("Some secondary servers failed to update. Check their rows and retry."):j>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function ne(P){return P?P.error?P.error:P.status?P.status:P.manualUpdate?"manual update required":P.version?`v${P.version.version}`:"…":"…"}function le(P){return P.error?P.error:typeof P.updateAvailable=="boolean"?P.updateAvailable?`latest v${P.latestVersion??"available"}`:"up to date":"unknown"}function oe(P){const I=P?.version;return I?`npm package v${I.runningVersion}`:""}async function ve(P,I){try{await q2(I),S(P,{copiedCommand:!0}),window.setTimeout(()=>S(P,{copiedCommand:!1}),1800)}catch(F){S(P,{error:F instanceof Error?F.message:"copy failed"})}}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{L()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{J()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsx("ul",{className:"security-list",children:r.map(P=>{const I=o[P.key],F=oe(I),H=I?.manualUpdate??null,j=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!h,re=P.id!==null&&!I?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:P.name}),m.jsxs("span",{className:"security-item-meta",children:[F?`${F} — `:"",ne(I)]})]}),H?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:H.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:H.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(P.key,H.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{W(P)},disabled:!j,children:I?.busy?"…":"Update"}),P.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{K(P)},disabled:!re,children:"Delete"}):null]})]},P.key)})})]})}async function q2(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 Su=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function $2({onClose:e,api:t,updateAvailable:r=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const c=v.useMemo(()=>t??fh(),[t]),[h,p]=v.useState(()=>Mp()),[g,f]=v.useState(()=>Np()),[b,y]=v.useState(()=>Lp()),[S,w]=v.useState(()=>zs()),[k,T]=v.useState(()=>Sa()),[B,L]=v.useState(null),[A,W]=v.useState(null),[K,J]=v.useState("appearance"),[ne,le]=v.useState(()=>X0()),[oe,ve]=v.useState(()=>ba()),[P,I]=v.useState(()=>tg()),[F,H]=v.useState([]),[j,re]=v.useState([]),[M,V]=v.useState([]),[Z,Ce]=v.useState(5*1024*1024),[ke,R]=v.useState(!1),[G,se]=v.useState(null),_e=v.useRef(null),fe=v.useRef(null),we=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),Ne=v.useMemo(()=>new Set(j),[j]),je=!Y2(j,M);v.useEffect(()=>tw(()=>p(Mp())),[]),v.useEffect(()=>iw(()=>f(Np())),[]),v.useEffect(()=>nw(()=>y(Lp())),[]),v.useEffect(()=>Wm(()=>w(zs())),[]),v.useEffect(()=>lg(()=>T(Sa())),[]),v.useEffect(()=>G0(()=>ve(ba())),[]),v.useEffect(()=>{if(!B)return;const Y=Zo.find(He=>He.id===B);if(!Y)return;const Te=He=>{if(He.preventDefault(),He.stopPropagation(),He.key==="Escape"){L(null),W(null);return}const vt=x2(He,Y);if(!vt){W(V2(Y));return}T(S2(B,vt)),L(null),W(null)};return window.addEventListener("keydown",Te,!0),()=>window.removeEventListener("keydown",Te,!0)},[B]),v.useEffect(()=>{let Y=!1;return c.listNotificationAssets().then(Te=>{Y||ze(Te)}).catch(Te=>{Y||se(wu(Te))}),()=>{Y=!0}},[c]);function Ve(Y){p(bu(Number(Y)))}function ee(Y){ve(zb(Number(Y)))}function me(Y){J(Y);const Te=fe.current,He=we.current[Y];if(!Te||!He)return;const vt=Math.max(0,Pb(He,Te)-12);typeof Te.scrollTo=="function"?Te.scrollTo({top:vt,behavior:"smooth"}):Te.scrollTop=vt}function De(){const Y=fe.current;if(!Y)return;if(Y.scrollTop+Y.clientHeight>=Y.scrollHeight-2){J(Su[Su.length-1].id);return}let Te="appearance";const He=Y.scrollTop+Math.min(180,Math.max(48,Y.clientHeight*.28));for(const vt of Su){const yi=we.current[vt.id];yi&&Pb(yi,Y)<=He&&(Te=vt.id)}J(Te)}function be(Y){T(w2(Y)),L(null),W(null)}function Re(){T(C2()),L(null),W(null)}function ze(Y){const Te=Y.assets.filter(He=>He.enabled).map(He=>He.id);H(Y.assets),re(Te),V(Te),Ce(Y.maxFileBytes),se(null)}async function Ke(){if(ne){Ob(!1),le(!1);return}let Y=P;Y==="default"&&(Y=await m2(),I(Y)),Y==="granted"&&(Ob(!0),le(!0))}async function ce(Y){const Te=Y?.[0];if(Te){if(Te.size>Z){se(`File must be ${Wf(Z)} or smaller.`),Le();return}if(Te.type!=="video/mp4"&&Te.type!=="video/webm"){se("Upload an MP4 or WebM video."),Le();return}R(!0),se(null);try{await c.uploadNotificationAsset(Te),ze(await c.listNotificationAssets()),s?.()}catch(He){se(wu(He))}finally{R(!1),Le()}}}async function xe(Y){R(!0),se(null);try{await c.deleteNotificationAsset(Y),ze(await c.listNotificationAssets()),s?.()}catch(Te){se(wu(Te))}finally{R(!1)}}function Le(){_e.current&&(_e.current.value="")}function Ae(Y,Te){const He=new Set(j);if(Te?He.add(Y):He.delete(Y),He.size===0){se("Keep at least one toast video selected.");return}se(null),re(Array.from(He))}async function Ie(){if(j.length===0){se("Keep at least one toast video selected.");return}R(!0),se(null);try{const Y=await c.updateNotificationAssetSelection({enabledAssetIds:j});ze(Y),s?.()}catch(Y){se(wu(Y))}finally{R(!1)}}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:Y=>Y.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Su.map(Y=>m.jsxs("button",{type:"button","data-active":K===Y.id?"true":"false","aria-current":K===Y.id?"true":void 0,onClick:()=>me(Y.id),children:[Y.label,Y.id==="servers"&&r?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},Y.id))}),m.jsxs("div",{ref:fe,className:"settings-content",onScroll:De,children:[m.jsxs("section",{id:"settings-appearance",ref:Y=>{we.current.appearance=Y},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:$u.map(Y=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":S===Y.id,"data-active":S===Y.id?"true":"false",onClick:()=>w(gE(Y.id)),style:{"--settings-theme-bg":Y.tokens.bg,"--settings-theme-bg-2":Y.tokens.bg2,"--settings-theme-sidebar":Y.tokens.bgSidebar,"--settings-theme-line":Y.tokens.line,"--settings-theme-fg":Y.tokens.fg,"--settings-theme-fg-2":Y.tokens.fg2,"--settings-theme-accent":Y.tokens.accent,"--settings-theme-xterm-bg":Y.xterm.background,"--settings-theme-xterm-fg":Y.xterm.foreground,"--settings-theme-xterm-selection":Y.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:Y.label}),m.jsx("small",{children:Y.description})]})]},Y.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Tp,max:Dp,step:1,value:h,"aria-label":"Terminal font size",onChange:Y=>Ve(Y.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(bu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Tp,max:Dp,step:1,value:h,"aria-label":"Terminal font size value",onChange:Y=>Ve(Y.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(bu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(bu(ga)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:Y=>f(v2(Y.currentTarget.value)),children:Zu.map(Y=>m.jsx("option",{value:Y.id,children:Y.label},Y.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:Y=>y(y2(Y.currentTarget.checked))}),"Show scroll progress"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:Y=>{we.current.shortcuts=Y},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:Re,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),A?m.jsx("p",{className:"settings-error",children:A}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Zo.map(Y=>{const Te=B===Y.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:Y.label}),m.jsx("span",{className:"settings-shortcut-group",children:Y.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Te?"true":"false",onClick:()=>{L(Y.id),W(null)},children:Te?"Press keys…":sw(k[Y.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>be(Y.id),children:"Reset"})]})]},Y.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:Y=>{we.current.notifications=Y},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),yh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ne&&P==="granted",onChange:()=>{Ke()},disabled:P==="denied"}),"System notification when page is hidden"]}),P==="denied"?m.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."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:oe.enabled,onChange:Y=>ve(u2(Y.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:oe.persistUntilDismissed?"Until closed":`${oe.durationSeconds}s`}),m.jsx("input",{type:"range",min:Cp,max:xp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:Y=>ee(Y.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Cp,max:xp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:Y=>ee(Y.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!oe.enabled||oe.persistUntilDismissed,onClick:()=>ve(zb(qo)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:oe.persistUntilDismissed,disabled:!oe.enabled,onChange:Y=>ve(h2(Y.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[Wf(Z)," max"]})]}),m.jsx("input",{ref:_e,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:Y=>{ce(Y.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ke,onClick:()=>_e.current?.click(),children:"Upload video"}),G?m.jsx("p",{className:"settings-error",children:G}):null,F.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:F.map(Y=>m.jsxs("li",{"data-enabled":Ne.has(Y.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:Ne.has(Y.id),disabled:ke,"aria-label":`Use ${Y.filename}`,onChange:Te=>Ae(Y.id,Te.currentTarget.checked)}),m.jsx("video",{src:Y.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:Y.filename}),m.jsx("small",{children:Y.source==="built-in"?"Built-in":Wf(Y.size)})]})]}),Y.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ke,"aria-label":`Delete ${Y.filename}`,onClick:()=>{xe(Y.id)},children:"x"}):null]},Y.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ke||F.length===0||!je,onClick:()=>{Ie()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:Y=>{we.current.security=Y},className:"settings-section-group",children:m.jsx(c2,{api:c})}),m.jsx("div",{id:"settings-servers",ref:Y=>{we.current.servers=Y},className:"settings-section-group",children:m.jsx(F2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Pb(e,t){const r=e.getBoundingClientRect(),s=t.getBoundingClientRect();return r.top-s.top+t.scrollTop}function Wf(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 wu(e){return e instanceof Error?e.message:"Request failed."}function V2(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 Y2(e,t){if(e.length!==t.length)return!1;const r=new Set(t);return e.every(s=>r.has(s))}class la extends Error{constructor(t,r){super(r),this.status=t,this.name="UploadClientError"}status}function X2(e){const t=e.createXhr?.()??new XMLHttpRequest,r=new FormData,s=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));r.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[o,c]of e.files.entries())r.append(`file${o}`,c.file);return new Promise((o,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,p(),o(y))},f=y=>{h||(h=!0,p(),c(y))},b=()=>{t.abort(),f(new la(0,"Upload aborted."))};if(e.signal?.aborted){f(new la(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new la(t.status,"Invalid upload response."))}return}f(new la(t.status,G2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new la(0,"Upload failed.")),t.onabort=()=>f(new la(0,"Upload aborted.")),t.ontimeout=()=>f(new la(0,"Upload timed out.")),t.send(r)})}function G2(e,t){try{const r=JSON.parse(e),s=typeof r.error=="string"?r.error:r.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const Z2="modulepreload",Q2=function(e){return"/"+e},Ub={},fg=function(t,r,s){let o=Promise.resolve();if(r&&r.length>0){let g=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");o=g(r.map(f=>{if(f=Q2(f),f in Ub)return;Ub[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":Z2,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((w,k)=>{S.addEventListener("load",w),S.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return o.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},J2=v.lazy(()=>fg(()=>import("./MarkdownPreview-BBxs32JK.js"),__vite__mapDeps([0,1])));function eT({api:e,activeTerminalId:t,activeTerminalCwd:r,workspaceRootPath:s=null,onOpenFile:o}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,b]=v.useState({}),[y,S]=v.useState(()=>new Set),[w,k]=v.useState(null),[T,B]=v.useState({type:"empty"}),[L,A]=v.useState("idle"),[W,K]=v.useState(null),J=v.useRef(null),ne=v.useRef(null),le=v.useRef(!1),oe=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const P=ve.current,I=s?iT(s):t?Ib(t,r):null,F=c?[c.rootPath,p].filter(Boolean).join("/"):"",H=w?.path??null;v.useEffect(()=>(le.current=!0,()=>{le.current=!1,oe.current+=1,me()}),[]),v.useEffect(()=>{ve.current=t,ne.current=null,j(I)},[e]),v.useEffect(()=>{s&&I!==ne.current&&re(s,I)},[s,I]),v.useEffect(()=>{if(s||!P||t!==P)return;const ce=Ib(P,r);ce!==ne.current&&M(P,ce)},[P,t,r,s]);async function j(ce=I){if(s){await re(s,ce);return}await M(t,ce)}async function re(ce,xe=I){const Le=De();if(ne.current=xe,me(),h(null),g(""),b({}),S(new Set),k(null),B({type:"empty"}),K(null),!ce){A("idle");return}A("loading");try{const Ae=await e.createFileRoot({path:ce});if(!be(Le))return;h({rootToken:Ae.rootToken,rootPath:Ae.rootPath});const Ie=await e.listFiles({rootToken:Ae.rootToken,path:""});if(!be(Le))return;Ce(Ie),A("idle")}catch(Ae){be(Le)&&(K(Fr(Ae)),A("idle"))}}async function M(ce,xe=I){const Le=De();if(ne.current=xe,me(),h(null),g(""),b({}),S(new Set),k(null),B({type:"empty"}),K(null),!ce){A("idle");return}A("loading");try{const Ae=await e.createFileRoot({terminalId:ce});if(!be(Le))return;h({rootToken:Ae.rootToken,rootPath:Ae.rootPath});const Ie=await e.listFiles({rootToken:Ae.rootToken,path:""});if(!be(Le))return;Ce(Ie),A("idle")}catch(Ae){if(await Re(Ae,Le))return;be(Le)&&(K(Fr(Ae)),A("idle"))}}async function V(ce=p,xe=c){if(!xe)return;const Le=De();A("loading"),K(null);try{const Ae=await e.listFiles({rootToken:xe.rootToken,path:ce});if(!be(Le))return;Ce(Ae),A("idle")}catch(Ae){if(await Re(Ae,Le))return;be(Le)&&(K(Fr(Ae)),A("idle"))}}async function Z(){if(s){await re(s,I);return}ve.current=t,await M(t,I)}function Ce(ce){b(xe=>({...xe,[ce.path]:nT(ce.entries)}))}async function ke(ce){if(!(!Ff(ce)||!c)){if(k(ce),K(null),ce.kind==="directory"){g(ce.path),ee(),await G(ce);return}if(g(oa(ce.path)),ce.editable){await _e(ce);return}ce.previewKind!=="none"&&await we(ce,ce.previewKind)}}async function R(ce){if(!(!Ff(ce)||!c)){if(k(ce),K(null),ce.kind==="directory"){g(ce.path),ee(),await G(ce);return}if(g(oa(ce.path)),ce.editable){await fe(ce);return}ce.previewKind!=="none"&&await we(ce,ce.previewKind)}}async function G(ce){if(y.has(ce.path)){S(xe=>{const Le=new Set(xe);return Le.delete(ce.path),Le});return}S(xe=>new Set(xe).add(ce.path)),await V(ce.path)}function se(ce,xe){ce.key==="Enter"&&(ce.preventDefault(),R(xe))}async function _e(ce){if(!c)return;const xe=De();A("loading"),me();try{const Le=await e.readFile({rootToken:c.rootToken,path:ce.path});if(!be(xe))return;B({type:"text-preview",file:ce,read:Le}),A("idle")}catch(Le){if(await Re(Le,xe))return;be(xe)&&(K(Fr(Le)),A("idle"))}}async function fe(ce){if(!c)return;const xe=De();A("loading");try{await o({rootToken:c.rootToken,path:ce.path,...t?{terminalId:t}:{}}),be(xe)&&A("idle")}catch(Le){if(await Re(Le,xe))return;be(xe)&&(K(Fr(Le)),A("idle"))}}async function we(ce,xe){if(!c)return;const Le=De();A("loading"),me();try{const Ae=await e.previewFile({rootToken:c.rootToken,path:ce.path});if(!be(Le))return;const Ie=URL.createObjectURL(Ae);if(!be(Le)){URL.revokeObjectURL(Ie);return}J.current=Ie,B({type:"preview",file:ce,previewKind:xe,url:Ie}),A("idle")}catch(Ae){if(await Re(Ae,Le))return;be(Le)&&(K(Fr(Ae)),A("idle"))}}async function Ne(ce){if(!c)return;const xe=ce==="file"?"New file":"New folder",Le=window.prompt(xe,""),Ae=w?w.kind==="directory"?w.path:oa(w.path):p,Ie=Kb(Le,Ae);if(Ie){K(null);try{const Y=await e.createFileEntry({rootToken:c.rootToken,path:Ie,kind:ce});k(Y.entry),await V(Ae)}catch(Y){if(await Re(Y))return;K(Fr(Y))}}}async function je(){if(!c||!w)return;const ce=window.prompt("Move selected entry",w.path),xe=Kb(ce,"");if(!xe||xe===w.path)return;const Le=oa(w.path),Ae=oa(xe);K(null);try{const Ie=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:xe});k(Ie.entry),g(Ie.entry.kind==="directory"?Ie.entry.path:oa(Ie.entry.path)),ee(),await V(Le),Ae!==Le&&await V(Ae)}catch(Ie){if(await Re(Ie))return;K(Fr(Ie))}}async function Ve(){if(!c||!w)return;const ce=w.path,xe=oa(ce);K(null);try{const Le=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Ae=Le.descendantCount>0?` and ${Le.descendantCount} nested item${Le.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Le.path}${Ae}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:Le.previewToken}),k(null),g(xe),S(Ie=>{const Y=new Set(Ie);for(const Te of Ie)(Te===ce||Te.startsWith(`${ce}/`))&&Y.delete(Te);return Y}),ee(),await V(xe)}catch(Le){if(await Re(Le))return;K(Fr(Le))}}function ee(){oe.current+=1,me(),B({type:"empty"})}function me(){J.current&&(URL.revokeObjectURL(J.current),J.current=null)}function De(){return oe.current+=1,oe.current}function be(ce){return le.current&&ce===oe.current}async function Re(ce,xe){return rT(ce)?(xe!==void 0&&!be(xe)||await j(I),!0):!1}function ze(ce,xe){const Le=Ff(ce),Ae=ce.kind==="directory"&&y.has(ce.path),Ie=f[ce.path]??[],Y={"--file-tree-depth":xe};return m.jsxs(Ti.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ce.kind,"data-expanded":Ae,"data-active":H===ce.path,disabled:!Le,style:Y,"aria-expanded":ce.kind==="directory"?Ae:void 0,"aria-label":`${ce.kind==="directory"?"Open folder":"Open file"} ${ce.name}`,title:ce.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ke(ce)},onDoubleClick:()=>{R(ce)},onKeyDown:Te=>se(Te,ce),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ce.kind==="directory"?Ae?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:ce.name}),m.jsx("small",{children:tT(ce)})]}),Ae?m.jsx("div",{className:"file-tree-children",role:"group",children:Ie.map(Te=>ze(Te,xe+1))}):null]},ce.path)}const Ke=f[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:F,children:F||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{Z()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ne("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ne("directory")},children:"▣"})]})]}),W?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:W}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":F?`Files in ${F}`:"Files",children:Ke.map(ce=>ze(ce,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{je()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ve()},children:"Delete"})]})]}),L==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&L!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?m.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?m.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(J2,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function Ff(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function tT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Ib(e,t){return`${e}\0${t??""}`}function iT(e){return`workspace\0${e}`}function nT(e){return[...e].sort((t,r)=>t.kind==="directory"&&r.kind!=="directory"?-1:t.kind!=="directory"&&r.kind==="directory"?1:t.name.localeCompare(r.name))}function oa(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Kb(e,t){if(e===null)return null;const r=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return r?!t||r.includes("/")?r:`${t}/${r}`:null}function Fr(e){return e instanceof Error?e.message:"Request failed"}function rT(e){return e instanceof or&&e.status===409&&e.message==="terminal_cwd_changed"}const sT=v.lazy(()=>fg(()=>import("./MarkdownPreview-BBxs32JK.js"),__vite__mapDeps([0,1])));function Wb({api:e,editor:t,canClose:r,onClose:s}){const[o,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[b,y]=v.useState(null),[S,w]=v.useState(!1),[k,T]=v.useState("edit"),B=v.useRef(t),L=v.useRef(t.read),A=v.useRef(t.read.content),W=v.useRef(!1),K=v.useRef(!1),J=v.useRef(0),ne=h!==o.content&&g!=="saving"&&!S;v.useEffect(()=>(K.current=!0,()=>{K.current=!1,J.current+=1}),[]),v.useEffect(()=>{J.current+=1,W.current=!1,B.current=t,L.current=t.read,A.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),w(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{L.current=o},[o]),v.useEffect(()=>{A.current=h},[h]),v.useEffect(()=>{if(h===o.content||S)return;const I=window.setInterval(()=>{!W.current&&A.current!==L.current.content&&le()},1e3);return()=>window.clearInterval(I)},[h===o.content,S,t.id]);async function le(){if(W.current)return;const I=A.current,F=L.current;if(I===F.content)return;const H=B.current,j=J.current;W.current=!0,f("saving"),y(null),w(!1);try{const re=await e.writeFile({rootToken:H.rootToken,path:H.path,content:I,expectedVersion:F.version});if(!K.current||j!==J.current)return;const M={...F,content:I,version:re.version};L.current=M,c(M),f(A.current===I?"saved":"idle")}catch(re){if(!K.current||j!==J.current)return;if(re instanceof or&&re.status===409){w(!0),f("idle");return}y(aT(re)),f("idle")}finally{j===J.current&&(W.current=!1)}}const oe=g==="saving"?"saving":g==="saved"?"saved":o.language,ve=o.language==="markdown",P=ve&&k==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:oe}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ne,onClick:()=>{le()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${P?"Edit":"Preview"} ${t.title}`,onClick:()=>T(I=>I==="preview"?"edit":"preview"),children:P?"Edit":"Preview"}):null,r?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,P?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(sT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:I=>{const F=I.target.value;A.current=F,p(F),f("idle"),y(null),w(!1)}})]})}function aT(e){return e instanceof Error?e.message:"Request failed"}var lT=2,oT=1,cT=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,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),o=Math.max(0,parseInt(r.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=h.top+h.bottom,g=h.right+h.left,f=s-p,b=o-g-t;return{cols:Math.max(lT,Math.floor(b/e.css.cell.width)),rows:Math.max(oT,Math.floor(f/e.css.cell.height))}}};var fw=Object.defineProperty,uT=Object.getOwnPropertyDescriptor,hT=(e,t)=>{for(var r in t)fw(e,r,{get:t[r],enumerable:!0})},ti=(e,t,r,s)=>{for(var o=s>1?void 0:s?uT(t,r):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(o=(s?h(t,r,o):h(o))||o);return s&&o&&fw(t,r,o),o},Me=(e,t)=>(r,s)=>t(r,s,e),Fb="Terminal input",jp={get:()=>Fb,set:e=>Fb=e},qb="Too much output to announce, navigate to rows manually to read",Hp={get:()=>qb,set:e=>qb=e};function dT(e){return e.replace(/\r?\n/g,"\r")}function fT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function pT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function mT(e,t,r,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");pw(o,t,r,s)}}function pw(e,t,r,s){e=dT(e),e=fT(e,r.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),t.value=""}function mw(e,t,r){let s=r.getBoundingClientRect(),o=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function $b(e,t,r,s,o){mw(e,t,r),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function As(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Sh(e,t=0,r=e.length){let s="";for(let o=t;o<r;++o){let c=e[o];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var gT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let r=e.length;if(!r)return 0;let s=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=o;c<r;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=r)return this._interim=h,s;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[s++]=(h-55296)*1024+p-56320+65536:(t[s++]=h,t[s++]=p);continue}h!==65279&&(t[s++]=h)}return s}},_T=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let r=e.length;if(!r)return 0;let s=0,o,c,h,p,g=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let k=0,T;for(;(T=this.interim[++k]&63)&&k<4;)w<<=6,w|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=B-k;for(;f<L;){if(f>=r)return 0;if(T=e[f++],(T&192)!==128){f--,S=!0;break}else this.interim[k++]=T,w<<=6,w|=T&63}S||(B===2?w<128?f--:t[s++]=w:B===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let b=r-4,y=f;for(;y<r;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((p=e[y+3])&128);)t[s++]=o,t[s++]=c,t[s++]=h,t[s++]=p,y+=4;if(o=e[y++],o<128)t[s++]=o;else if((o&224)===192){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(g=(o&31)<<6|c&63,g<128){y--;continue}t[s++]=g}else if((o&240)===224){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(g=(o&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((o&248)===240){if(y>=r)return this.interim[0]=o,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(y>=r)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=h,s;if(p=e[y++],(p&192)!==128){y--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},gw="",Ls=" ",cc=class _w{constructor(){this.fg=0,this.bg=0,this.extended=new Ju}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 _w;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}},Ju=class vw{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 vw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Zn=class yw extends cc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ju,this.combinedData=""}static fromCharData(t){let r=new yw;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?As(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vb="di$target",Pp="di$dependencies",qf=new Map;function vT(e){return e[Pp]||[]}function Ui(e){if(qf.has(e))return qf.get(e);let t=function(r,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");yT(t,r,o)};return t._id=e,qf.set(e,t),t}function yT(e,t,r){t[Vb]===t?t[Pp].push({id:e,index:r}):(t[Pp]=[{id:e,index:r}],t[Vb]=t)}var sn=Ui("BufferService"),bw=Ui("CoreMouseService"),Ea=Ui("CoreService"),bT=Ui("CharsetService"),pg=Ui("InstantiationService"),Sw=Ui("LogService"),an=Ui("OptionsService"),ww=Ui("OscLinkService"),ST=Ui("UnicodeService"),uc=Ui("DecorationService"),Up=class{constructor(e,t,r){this._bufferService=e,this._optionsService=t,this._oscLinkService=r}provideLinks(e,t){let r=this._bufferService.buffer.lines.get(e-1);if(!r){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,c=new Zn,h=r.getTrimmedLength(),p=-1,g=-1,f=!1;for(let b=0;b<h;b++)if(!(g===-1&&!r.hasContent(b))){if(r.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:g+1,y:e},end:{x:b+(!f&&b===h-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let k=new URL(y);["http:","https:"].includes(k.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:S,activate:(k,T)=>o?o.activate(k,T,S):wT(k,T),hover:(k,T)=>o?.hover?.(k,T,S),leave:(k,T)=>o?.leave?.(k,T,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,p=c.extended.urlId):(g=-1,p=-1)}}t(s)}};Up=ti([Me(0,sn),Me(1,an),Me(2,ww)],Up);function wT(e,t){if(confirm(`Do you want to navigate to ${t}?
16
-
17
- WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var wh=Ui("CharSizeService"),Gr=Ui("CoreBrowserService"),mg=Ui("MouseService"),Zr=Ui("RenderService"),CT=Ui("SelectionService"),Cw=Ui("CharacterJoinerService"),Tl=Ui("ThemeService"),xw=Ui("LinkProviderService"),xT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Yb.isErrorNoTelemetry(e)?new Yb(e.message+`
18
-
19
- `+e.stack):new Error(e.message+`
20
-
21
- `+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)}},ET=new xT;function Bu(e){kT(e)||ET.onUnexpectedError(e)}var Ip="Canceled";function kT(e){return e instanceof TT?!0:e instanceof Error&&e.name===Ip&&e.message===Ip}var TT=class extends Error{constructor(){super(Ip),this.name=this.message}};function DT(e){return new Error(`Illegal argument: ${e}`)}var Yb=class Kp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Kp)return t;let r=new Kp;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Wp=class Ew extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ew.prototype)}};function Rn(e,t=0){return e[e.length-(1+t)]}var RT;(e=>{function t(c){return c<0}e.isLessThan=t;function r(c){return c<=0}e.isLessThanOrEqual=r;function s(c){return c>0}e.isGreaterThan=s;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(RT||={});function MT(e,t){let r=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(r,arguments))),o}}var kw;(e=>{function t(K){return K&&typeof K=="object"&&typeof K[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function s(){return r}e.empty=s;function*o(K){yield K}e.single=o;function c(K){return t(K)?K:o(K)}e.wrap=c;function h(K){return K||r}e.from=h;function*p(K){for(let J=K.length-1;J>=0;J--)yield K[J]}e.reverse=p;function g(K){return!K||K[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(K){return K[Symbol.iterator]().next().value}e.first=f;function b(K,J){let ne=0;for(let le of K)if(J(le,ne++))return!0;return!1}e.some=b;function y(K,J){for(let ne of K)if(J(ne))return ne}e.find=y;function*S(K,J){for(let ne of K)J(ne)&&(yield ne)}e.filter=S;function*w(K,J){let ne=0;for(let le of K)yield J(le,ne++)}e.map=w;function*k(K,J){let ne=0;for(let le of K)yield*J(le,ne++)}e.flatMap=k;function*T(...K){for(let J of K)yield*J}e.concat=T;function B(K,J,ne){let le=ne;for(let oe of K)le=J(le,oe);return le}e.reduce=B;function*L(K,J,ne=K.length){for(J<0&&(J+=K.length),ne<0?ne+=K.length:ne>K.length&&(ne=K.length);J<ne;J++)yield K[J]}e.slice=L;function A(K,J=Number.POSITIVE_INFINITY){let ne=[];if(J===0)return[ne,K];let le=K[Symbol.iterator]();for(let oe=0;oe<J;oe++){let ve=le.next();if(ve.done)return[ne,e.empty()];ne.push(ve.value)}return[ne,{[Symbol.iterator](){return le}}]}e.consume=A;async function W(K){let J=[];for await(let ne of K)J.push(ne);return Promise.resolve(J)}e.asyncToArray=W})(kw||={});function wa(e){if(kw.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function NT(...e){return Wt(()=>wa(e))}function Wt(e){return{dispose:MT(()=>{e()})}}var Tw=class Dw{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{wa(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?Dw.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)}};Tw.DISABLE_DISPOSED_WARNING=!1;var Os=Tw,nt=class{constructor(){this._store=new Os,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)}};nt.None=Object.freeze({dispose(){}});var Sl=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}},Yr=typeof window=="object"?window:globalThis,Fp=class qp{constructor(t){this.element=t,this.next=qp.Undefined,this.prev=qp.Undefined}};Fp.Undefined=new Fp(void 0);var Vt=Fp,Xb=class{constructor(){this._first=Vt.Undefined,this._last=Vt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Vt.Undefined}clear(){let e=this._first;for(;e!==Vt.Undefined;){let t=e.next;e.prev=Vt.Undefined,e.next=Vt.Undefined,e=t}this._first=Vt.Undefined,this._last=Vt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new Vt(e);if(this._first===Vt.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==Vt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Vt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Vt.Undefined&&e.next!==Vt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Vt.Undefined&&e.next===Vt.Undefined?(this._first=Vt.Undefined,this._last=Vt.Undefined):e.next===Vt.Undefined?(this._last=this._last.prev,this._last.next=Vt.Undefined):e.prev===Vt.Undefined&&(this._first=this._first.next,this._first.prev=Vt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Vt.Undefined;)yield e.element,e=e.next}},AT=globalThis.performance&&typeof globalThis.performance.now=="function",LT=class Rw{static create(t){return new Rw(t)}constructor(t){this._now=AT&&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}},Vi;(e=>{e.None=()=>nt.None;function t(F,H){return y(F,()=>{},0,void 0,!0,void 0,H)}e.defer=t;function r(F){return(H,j=null,re)=>{let M=!1,V;return V=F(Z=>{if(!M)return V?V.dispose():M=!0,H.call(j,Z)},null,re),M&&V.dispose(),V}}e.once=r;function s(F,H,j){return f((re,M=null,V)=>F(Z=>re.call(M,H(Z)),null,V),j)}e.map=s;function o(F,H,j){return f((re,M=null,V)=>F(Z=>{H(Z),re.call(M,Z)},null,V),j)}e.forEach=o;function c(F,H,j){return f((re,M=null,V)=>F(Z=>H(Z)&&re.call(M,Z),null,V),j)}e.filter=c;function h(F){return F}e.signal=h;function p(...F){return(H,j=null,re)=>{let M=NT(...F.map(V=>V(Z=>H.call(j,Z))));return b(M,re)}}e.any=p;function g(F,H,j,re){let M=j;return s(F,V=>(M=H(M,V),M),re)}e.reduce=g;function f(F,H){let j,re={onWillAddFirstListener(){j=F(M.fire,M)},onDidRemoveLastListener(){j?.dispose()}},M=new Ee(re);return H?.add(M),M.event}function b(F,H){return H instanceof Array?H.push(F):H&&H.add(F),F}function y(F,H,j=100,re=!1,M=!1,V,Z){let Ce,ke,R,G=0,se,_e={leakWarningThreshold:V,onWillAddFirstListener(){Ce=F(we=>{G++,ke=H(ke,we),re&&!R&&(fe.fire(ke),ke=void 0),se=()=>{let Ne=ke;ke=void 0,R=void 0,(!re||G>1)&&fe.fire(Ne),G=0},typeof j=="number"?(clearTimeout(R),R=setTimeout(se,j)):R===void 0&&(R=0,queueMicrotask(se))})},onWillRemoveListener(){M&&G>0&&se?.()},onDidRemoveLastListener(){se=void 0,Ce.dispose()}},fe=new Ee(_e);return Z?.add(fe),fe.event}e.debounce=y;function S(F,H=0,j){return e.debounce(F,(re,M)=>re?(re.push(M),re):[M],H,void 0,!0,void 0,j)}e.accumulate=S;function w(F,H=(re,M)=>re===M,j){let re=!0,M;return c(F,V=>{let Z=re||!H(V,M);return re=!1,M=V,Z},j)}e.latch=w;function k(F,H,j){return[e.filter(F,H,j),e.filter(F,re=>!H(re),j)]}e.split=k;function T(F,H=!1,j=[],re){let M=j.slice(),V=F(ke=>{M?M.push(ke):Ce.fire(ke)});re&&re.add(V);let Z=()=>{M?.forEach(ke=>Ce.fire(ke)),M=null},Ce=new Ee({onWillAddFirstListener(){V||(V=F(ke=>Ce.fire(ke)),re&&re.add(V))},onDidAddFirstListener(){M&&(H?setTimeout(Z):Z())},onDidRemoveLastListener(){V&&V.dispose(),V=null}});return re&&re.add(Ce),Ce.event}e.buffer=T;function B(F,H){return(j,re,M)=>{let V=H(new A);return F(function(Z){let Ce=V.evaluate(Z);Ce!==L&&j.call(re,Ce)},void 0,M)}}e.chain=B;let L=Symbol("HaltChainable");class A{constructor(){this.steps=[]}map(H){return this.steps.push(H),this}forEach(H){return this.steps.push(j=>(H(j),j)),this}filter(H){return this.steps.push(j=>H(j)?j:L),this}reduce(H,j){let re=j;return this.steps.push(M=>(re=H(re,M),re)),this}latch(H=(j,re)=>j===re){let j=!0,re;return this.steps.push(M=>{let V=j||!H(M,re);return j=!1,re=M,V?M:L}),this}evaluate(H){for(let j of this.steps)if(H=j(H),H===L)break;return H}}function W(F,H,j=re=>re){let re=(...Ce)=>Z.fire(j(...Ce)),M=()=>F.on(H,re),V=()=>F.removeListener(H,re),Z=new Ee({onWillAddFirstListener:M,onDidRemoveLastListener:V});return Z.event}e.fromNodeEventEmitter=W;function K(F,H,j=re=>re){let re=(...Ce)=>Z.fire(j(...Ce)),M=()=>F.addEventListener(H,re),V=()=>F.removeEventListener(H,re),Z=new Ee({onWillAddFirstListener:M,onDidRemoveLastListener:V});return Z.event}e.fromDOMEventEmitter=K;function J(F){return new Promise(H=>r(F)(H))}e.toPromise=J;function ne(F){let H=new Ee;return F.then(j=>{H.fire(j)},()=>{H.fire(void 0)}).finally(()=>{H.dispose()}),H.event}e.fromPromise=ne;function le(F,H){return F(j=>H.fire(j))}e.forward=le;function oe(F,H,j){return H(j),F(re=>H(re))}e.runAndSubscribe=oe;class ve{constructor(H,j){this._observable=H,this._counter=0,this._hasChanged=!1;let re={onWillAddFirstListener:()=>{H.addObserver(this)},onDidRemoveLastListener:()=>{H.removeObserver(this)}};this.emitter=new Ee(re),j&&j.add(this.emitter)}beginUpdate(H){this._counter++}handlePossibleChange(H){}handleChange(H,j){this._hasChanged=!0}endUpdate(H){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(F,H){return new ve(F,H).emitter.event}e.fromObservable=P;function I(F){return(H,j,re)=>{let M=0,V=!1,Z={beginUpdate(){M++},endUpdate(){M--,M===0&&(F.reportChanges(),V&&(V=!1,H.call(j)))},handlePossibleChange(){},handleChange(){V=!0}};F.addObserver(Z),F.reportChanges();let Ce={dispose(){F.removeObserver(Z)}};return re instanceof Os?re.add(Ce):Array.isArray(re)&&re.push(Ce),Ce}}e.fromObservableLight=I})(Vi||={});var $p=class Vp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vp._idPool++}`,Vp.all.add(this)}start(t){this._stopWatch=new LT,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}}};$p.all=new Set,$p._idPool=0;var BT=$p,OT=-1,Mw=class Nw{constructor(t,r,s=(Nw._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new HT(p,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,r=0;for(let[s,o]of this._stacks)(!t||r<o)&&(t=[s,o],r=o);return t}};Mw._idPool=1;var zT=Mw,jT=class Aw{constructor(t){this.value=t}static create(){let t=new Error;return new Aw(t.stack??"")}print(){console.warn(this.value.split(`
22
- `).slice(2).join(`
23
- `))}},HT=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},PT=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},UT=0,$f=class{constructor(e){this.value=e,this.id=UT++}},IT=2,KT,Ee=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new zT(e?.onListenerError??Bu,this._options?.leakWarningThreshold??OT):void 0,this._perfMon=this._options?._profName?new BT(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,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new PT(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||Bu)(g),nt.None}if(this._disposed)return nt.None;t&&(e=e.bind(t));let s=new $f(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=jT.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof $f?(this._deliveryQueue??=new WT,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Wt(()=>{o?.(),this._removeListener(s)});return r instanceof Os?r.add(c):Array.isArray(r)&&r.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,r=t.indexOf(e);if(r===-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[r]=void 0;let s=this._deliveryQueue.current===this;if(this._size*IT<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:s&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let r=this._options?.onListenerError||Bu;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof $f)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}},WT=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Yp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ee,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ee,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Yp.INSTANCE=new Yp;var gg=Yp;function FT(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}gg.INSTANCE.onDidChangeZoomLevel;function qT(e){return gg.INSTANCE.getZoomFactor(e)}gg.INSTANCE.onDidChangeFullscreen;var Dl=typeof navigator=="object"?navigator.userAgent:"",Xp=Dl.indexOf("Firefox")>=0,$T=Dl.indexOf("AppleWebKit")>=0,_g=Dl.indexOf("Chrome")>=0,VT=!_g&&Dl.indexOf("Safari")>=0;Dl.indexOf("Electron/")>=0;Dl.indexOf("Android")>=0;var Vf=!1;if(typeof Yr.matchMedia=="function"){let e=Yr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Yr.matchMedia("(display-mode: fullscreen)");Vf=e.matches,FT(Yr,e,({matches:r})=>{Vf&&t.matches||(Vf=r)})}var dl="en",Gp=!1,Zp=!1,Ou=!1,Lw=!1,Cu,zu=dl,Gb=dl,YT,$r,_a=globalThis,An;typeof _a.vscode<"u"&&typeof _a.vscode.process<"u"?An=_a.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(An=process);var XT=typeof An?.versions?.electron=="string",GT=XT&&An?.type==="renderer";if(typeof An=="object"){Gp=An.platform==="win32",Zp=An.platform==="darwin",Ou=An.platform==="linux",Ou&&An.env.SNAP&&An.env.SNAP_REVISION,An.env.CI||An.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Cu=dl,zu=dl;let e=An.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Cu=t.userLocale,Gb=t.osLocale,zu=t.resolvedLanguage||dl,YT=t.languagePack?.translationsConfigFile}catch{}Lw=!0}else typeof navigator=="object"&&!GT?($r=navigator.userAgent,Gp=$r.indexOf("Windows")>=0,Zp=$r.indexOf("Macintosh")>=0,($r.indexOf("Macintosh")>=0||$r.indexOf("iPad")>=0||$r.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ou=$r.indexOf("Linux")>=0,$r?.indexOf("Mobi")>=0,zu=globalThis._VSCODE_NLS_LANGUAGE||dl,Cu=navigator.language.toLowerCase(),Gb=Cu):console.error("Unable to resolve platform.");var Bw=Gp,Cr=Zp,ZT=Ou,Zb=Lw,xr=$r,Es=zu,QT;(e=>{function t(){return Es}e.value=t;function r(){return Es.length===2?Es==="en":Es.length>=3?Es[0]==="e"&&Es[1]==="n"&&Es[2]==="-":!1}e.isDefaultVariant=r;function s(){return Es==="en"}e.isDefault=s})(QT||={});var JT=typeof _a.postMessage=="function"&&!_a.importScripts;(()=>{if(JT){let e=[];_a.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let c=e[s];if(c.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return r=>{let s=++t;e.push({id:s,callback:r}),_a.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var eD=!!(xr&&xr.indexOf("Chrome")>=0);xr&&xr.indexOf("Firefox")>=0;!eD&&xr&&xr.indexOf("Safari")>=0;xr&&xr.indexOf("Edg/")>=0;xr&&xr.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Zb||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Zb||cl&&cl.clipboard&&cl.clipboard.readText;var vg=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}},Yf=new vg,Qb=new vg,Jb=new vg,tD=new Array(230),Ow;(e=>{function t(p){return Yf.keyCodeToStr(p)}e.toString=t;function r(p){return Yf.strToKeyCode(p)}e.fromString=r;function s(p){return Qb.keyCodeToStr(p)}e.toUserSettingsUS=s;function o(p){return Jb.keyCodeToStr(p)}e.toUserSettingsGeneral=o;function c(p){return Qb.strToKeyCode(p)||Jb.strToKeyCode(p)}e.fromUserSettings=c;function h(p){if(p>=98&&p<=113)return null;switch(p){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Yf.keyCodeToStr(p)}e.toElectronAccelerator=h})(Ow||={});var iD=class zw{constructor(t,r,s,o,c){this.ctrlKey=t,this.shiftKey=r,this.altKey=s,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof zw&&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",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${r}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new nD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},nD=class{constructor(e){if(e.length===0)throw DT("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;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 rD(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return Ow.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(Xp)switch(t){case 59:return 85;case 60:if(ZT)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Cr)return 57;break}else if($T&&(Cr&&t===93||!Cr&&t===92))return 57;return tD[t]||0}var sD=Cr?256:2048,aD=512,lD=1024,oD=Cr?2048:256,eS=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=rD(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|=sD),this.altKey&&(t|=aD),this.shiftKey&&(t|=lD),this.metaKey&&(t|=oD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new iD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},tS=new WeakMap;function cD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var uD=class{static getSameOriginWindowChain(e){let t=tS.get(e);if(!t){t=[],tS.set(e,t);let r=e,s;do s=cD(r),s?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,s=0,o=this.getSameOriginWindowChain(e);for(let c of o){let h=c.window.deref();if(r+=h?.scrollY??0,s+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();r+=p.top,s+=p.left}return{top:r,left:s}}},xu=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 r=uD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},iS=class{constructor(e,t=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let s=!1;if(_g){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*h):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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Xp&&!Cr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")VT&&Bw?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*h):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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Xp&&!Cr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},jw=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),hD;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof dD?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Vi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:jw})})(hD||={});var dD=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?jw:(this._emitter||(this._emitter=new Ee),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},yg=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 Wp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Wp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},fD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,r=globalThis){if(this.isDisposed)throw new Wp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},t);this.disposable=Wt(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},pD;(e=>{async function t(s){let o,c=await Promise.all(s.map(h=>h.then(p=>p,p=>{o||(o=p)})));if(typeof o<"u")throw o;return c}e.settled=t;function r(s){return new Promise(async(o,c)=>{try{await s(o,c)}catch(h){c(h)}})}e.withAsyncBody=r})(pD||={});var nS=class Vn{static fromArray(t){return new Vn(r=>{r.emitMany(t)})}static fromPromise(t){return new Vn(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Vn(async r=>{await Promise.all(t.map(async s=>r.emitOne(await s)))})}static merge(t){return new Vn(async r=>{await Promise.all(t.map(async s=>{for await(let o of s)r.emitOne(o)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new Ee,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Vi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,r){return new Vn(async s=>{for await(let o of t)s.emitOne(r(o))})}map(t){return Vn.map(this,t)}static filter(t,r){return new Vn(async s=>{for await(let o of t)r(o)&&s.emitOne(o)})}filter(t){return Vn.filter(this,t)}static coalesce(t){return Vn.filter(t,r=>!!r)}coalesce(){return Vn.coalesce(this)}static async toPromise(t){let r=[];for await(let s of t)r.push(s);return r}toPromise(){return Vn.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())}};nS.EMPTY=nS.fromArray([]);var{getWindow:wr,getWindowId:mD,onDidRegisterWindow:gD}=(function(){let e=new Map,t={window:Yr,disposables:new Os};e.set(Yr.vscodeWindowId,t);let r=new Ee,s=new Ee,o=new Ee;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(h){if(e.has(h.vscodeWindowId))return nt.None;let p=new Os,g={window:h,disposables:p.add(new Os)};return e.set(h.vscodeWindowId,g),p.add(Wt(()=>{e.delete(h.vscodeWindowId),s.fire(h)})),p.add(Ge(h,Li.BEFORE_UNLOAD,()=>{o.fire(h)})),r.fire(g),p},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let p=h;if(p?.ownerDocument?.defaultView)return p.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:Yr},getDocument(h){return wr(h).document}}})(),_D=class{constructor(e,t,r,s){this._node=e,this._type=t,this._handler=r,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ge(e,t,r,s){return new _D(e,t,r,s)}var rS=function(e,t,r,s){return Ge(e,t,r,s)},bg,vD=class extends fD{constructor(e){super(),this.defaultTarget=e&&wr(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},sS=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){Bu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,s=new Map,o=c=>{r.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),s.set(c,!0);h.length>0;)h.sort(sS.sort),h.shift().execute();s.set(c,!1)};bg=(c,h,p=0)=>{let g=mD(c),f=new sS(h,p),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(f),r.get(g)||(r.set(g,!0),c.requestAnimationFrame(()=>o(g))),f}})();function yD(e){let t=e.getBoundingClientRect(),r=wr(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var Li={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"},bD=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=fn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=fn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=fn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=fn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=fn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=fn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=fn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=fn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=fn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=fn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=fn(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=fn(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=fn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=fn(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 fn(e){return typeof e=="number"?`${e}px`:e}function Vo(e){return new bD(e)}var Hw=class{constructor(){this._hooks=new Os,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(Wt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=wr(e)}this._hooks.add(Ge(c,Li.POINTER_MOVE,h=>{if(h.buttons!==r){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Ge(c,Li.POINTER_UP,h=>this.stopMonitoring(!0)))}};function SD(e,t,r){let s=null,o=null;if(typeof r.value=="function"?(s="value",o=r.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(s="get",o=r.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;r[s]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,h)}),this[c]}}var Sr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Sr||={});var Ao=class Ji extends nt{constructor(){super(),this.dispatched=!1,this.targets=new Xb,this.ignoreTargets=new Xb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Vi.runAndSubscribe(gD,({window:t,disposables:r})=>{r.add(Ge(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),r.add(Ge(t.document,"touchend",s=>this.onTouchEnd(t,s))),r.add(Ge(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Yr,disposables:this._store}))}static addTarget(t){if(!Ji.isTouchDevice())return nt.None;Ji.INSTANCE||(Ji.INSTANCE=new Ji);let r=Ji.INSTANCE.targets.push(t);return Wt(r)}static ignoreTarget(t){if(!Ji.isTouchDevice())return nt.None;Ji.INSTANCE||(Ji.INSTANCE=new Ji);let r=Ji.INSTANCE.ignoreTargets.push(t);return Wt(r)}static isTouchDevice(){return"ontouchstart"in Yr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:r,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[r],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(Sr.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,h=r.changedTouches.length;c<h;c++){let p=r.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(p.identifier))){console.warn("move of an UNKNOWN touch",p);continue}let g=this.activeTouches[p.identifier],f=Date.now()-g.initialTimeStamp;if(f<Ji.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let b=this.newGestureEvent(Sr.Tap,g.initialTarget);b.pageX=Rn(g.rollingPageX),b.pageY=Rn(g.rollingPageY),this.dispatchEvent(b)}else if(f>=Ji.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let b=this.newGestureEvent(Sr.Contextmenu,g.initialTarget);b.pageX=Rn(g.rollingPageX),b.pageY=Rn(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=Rn(g.rollingPageX),y=Rn(g.rollingPageY),S=Rn(g.rollingTimestamps)-g.rollingTimestamps[0],w=b-g.rollingPageX[0],k=y-g.rollingPageY[0],T=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,T,s,Math.abs(w)/S,w>0?1:-1,b,Math.abs(k)/S,k>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Sr.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(t){if(t.type===Sr.Tap){let r=new Date().getTime(),s=0;r-this._lastSetTapCountTime>Ji.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=r,t.tapCount=s}else(t.type===Sr.Change||t.type===Sr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let r=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==s;)o++,c=c.parentElement;r.push([o,s])}r.sort((s,o)=>s[0]-o[0]);for(let[s,o]of r)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,s,o,c,h,p,g,f){this.handle=bg(t,()=>{let b=Date.now(),y=b-s,S=0,w=0,k=!0;o+=Ji.SCROLL_FRICTION*y,p+=Ji.SCROLL_FRICTION*y,o>0&&(k=!1,S=c*o*y),p>0&&(k=!1,w=g*p*y);let T=this.newGestureEvent(Sr.Change);T.translationX=S,T.translationY=w,r.forEach(B=>B.dispatchEvent(T)),k||this.inertia(t,r,b,o,c,h+S,p,g,f+w)})}onTouchMove(t){let r=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(Sr.Change,h.initialTarget);p.translationX=c.pageX-Rn(h.rollingPageX),p.translationY=c.pageY-Rn(h.rollingPageY),p.pageX=c.pageX,p.pageY=c.pageY,this.dispatchEvent(p),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ao.SCROLL_FRICTION=-.005,Ao.HOLD_DELAY=700,Ao.CLEAR_TAP_COUNT_TIME=400,ti([SD],Ao,"isTouchDevice",1);var wD=Ao,Sg=class extends nt{onclick(e,t){this._register(Ge(e,Li.CLICK,r=>t(new xu(wr(e),r))))}onmousedown(e,t){this._register(Ge(e,Li.MOUSE_DOWN,r=>t(new xu(wr(e),r))))}onmouseover(e,t){this._register(Ge(e,Li.MOUSE_OVER,r=>t(new xu(wr(e),r))))}onmouseleave(e,t){this._register(Ge(e,Li.MOUSE_LEAVE,r=>t(new xu(wr(e),r))))}onkeydown(e,t){this._register(Ge(e,Li.KEY_DOWN,r=>t(new eS(r))))}onkeyup(e,t){this._register(Ge(e,Li.KEY_UP,r=>t(new eS(r))))}oninput(e,t){this._register(Ge(e,Li.INPUT,t))}onblur(e,t){this._register(Ge(e,Li.BLUR,t))}onfocus(e,t){this._register(Ge(e,Li.FOCUS,t))}onchange(e,t){this._register(Ge(e,Li.CHANGE,t))}ignoreGesture(e){return wD.ignoreTarget(e)}},aS=11,CD=class extends Sg{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=aS+"px",this.domNode.style.height=aS+"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 Hw),this._register(rS(this.bgDomNode,Li.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(rS(this.domNode,Li.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new vD),this._pointerdownScheduleRepeatTimer=this._register(new yg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,wr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},xD=class Qp{constructor(t,r,s,o,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,s=s|0,o=o|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=o,this.rawScrollTop=p,r<0&&(r=0),o+r>s&&(o=s-r),o<0&&(o=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=r,this.scrollWidth=s,this.scrollLeft=o,this.height=c,this.scrollHeight=h,this.scrollTop=p}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,r){return new Qp(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Qp(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,r){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,p=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},ED=class extends nt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ee),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new xD(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 r=this._state.withScrollDimensions(e,t);this._setState(r,!!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 r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let s;t?s=new oS(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=oS.start(this._state,r,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 r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},lS=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function Xf(e,t){let r=t-e;return function(s){return e+r*DD(s)}}function kD(e,t,r){return function(s){return s<r?e(s/r):t((s-r)/(1-r))}}var oS=class Jp{constructor(t,r,s,o){this.from=t,this.to=r,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,r,s){if(Math.abs(t-r)>2.5*s){let o,c;return t<r?(o=t+.75*s,c=r-.75*s):(o=t-.75*s,c=r+.75*s),kD(Xf(t,o),Xf(c,r),.33)}return Xf(t,r)}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 r=(t-this.startTime)/this.duration;if(r<1){let s=this.scrollLeft(r),o=this.scrollTop(r);return new lS(s,o,!1)}return new lS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,s){return Jp.start(t,r,s)}static start(t,r,s){s=s+10;let o=Date.now()-10;return new Jp(t,r,o,s)}};function TD(e){return Math.pow(e,3)}function DD(e){return 1-TD(1-e)}var RD=class extends nt{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new yg)}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":"")))}},MD=140,Pw=class extends Sg{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 RD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Hw),this._shouldRender=!0,this.domNode=Vo(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(Ge(this.domNode.domNode,Li.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new CD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,s){this.slider=Vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ge(this.slider.domNode,Li.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,r=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);r<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let o=yD(this.domNode.domNode);t=e.pageX-o.left,r=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),h=Math.abs(c-r);if(Bw&&h>MD){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let p=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(p))},()=>{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()}},Uw=class em{constructor(t,r,s,o,c,h){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new em(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,s,o,c){let h=Math.max(0,s-t),p=Math.max(0,h-2*r),g=o>0&&o>s;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*p/o))),b=(p-f)/(o-s),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=em._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 r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},ND=class extends Pw{constructor(e,t,r){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new Uw(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},AD=class extends Pw{constructor(e,t,r){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new Uw(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},LD=500,cS=50,BD=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},tm=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,r=0,s=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-s);if(t-=c,r+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(_g){let r=wr(t.browserEvent),s=qT(r);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,s){let o=null,c=new BD(t,r,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),r){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(r.deltaX),p=Math.abs(r.deltaY),g=Math.max(Math.min(o,h),1),f=Math.max(Math.min(c,p),1),b=Math.max(o,h),y=Math.max(c,p);b%g===0&&y%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};tm.INSTANCE=new tm;var OD=tm,zD=class extends Sg{constructor(e,t,r){super(),this._onScroll=this._register(new Ee),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ee),this.onWillScroll=this._onWillScroll.event,this._options=HD(t),this._scrollable=r,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new AD(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new ND(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Vo(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 yg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=wa(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,Cr&&(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 iS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=wa(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new iS(r))};this._mouseWheelToDispose.push(Ge(this._listenOnDomNode,Li.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=OD.INSTANCE;t.acceptStandardWheelEvent(e);let r=!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 h=!Cr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(o){let f=cS*o,b=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let f=cS*c,b=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),r=!0)}let s=r;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,r=e.scrollLeft>0,s=r?" left":"",o=t?" top":"",c=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),LD)}},jD=class extends zD{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function HD(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,Cr&&(t.className+=" mac"),t}var im=class extends nt{constructor(e,t,r,s,o,c,h,p){super(),this._bufferService=r,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new Ee),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new ED({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>bg(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new jD(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Vi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Wt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Wt(()=>this._styleElement.remove())),this._register(Vi.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(`
24
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};im=ti([Me(2,sn),Me(3,Gr),Me(4,bw),Me(5,Tl),Me(6,an),Me(7,Zr)],im);var nm=class extends nt{constructor(e,t,r,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(Wt(()=>{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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};nm=ti([Me(1,sn),Me(2,Gr),Me(3,uc),Me(4,Zr)],nm);var PD=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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},yr={full:0,left:0,center:0,right:0},ks={full:0,left:0,center:0,right:0},bo={full:0,left:0,center:0,right:0},eh=class extends nt{constructor(e,t,r,s,o,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=s,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,this._colorZoneStore=new PD,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(Wt(()=>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);ks.full=this._canvas.width,ks.left=e,ks.center=t,ks.right=e,this._refreshDrawHeightConstants(),bo.full=1,bo.left=1,bo.center=1+ks.left,bo.right=1+ks.left+ks.center}_refreshDrawHeightConstants(){yr.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);yr.left=t,yr.center=t,yr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.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(bo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-yr[e.position||"full"]/2),ks[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+yr[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}))}};eh=ti([Me(2,sn),Me(3,uc),Me(4,Zr),Me(5,an),Me(6,Tl),Me(7,Gr)],eh);var de;(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=`
25
- `,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=""))(de||={});var ju;(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="Ÿ"))(ju||={});var Iw;(e=>e.ST=`${de.ESC}\\`)(Iw||={});var rm=class{constructor(e,t,r,s,o,c){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=s,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${de.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),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};rm=ti([Me(2,sn),Me(3,an),Me(4,Ea),Me(5,Zr)],rm);var zi=0,ji=0,Hi=0,ei=0,uS={css:"#00000000",rgba:0},vi;(e=>{function t(o,c,h,p){return p!==void 0?`#${ca(o)}${ca(c)}${ca(h)}${ca(p)}`:`#${ca(o)}${ca(c)}${ca(h)}`}e.toCss=t;function r(o,c,h,p=255){return(o<<24|c<<16|h<<8|p)>>>0}e.toRgba=r;function s(o,c,h,p){return{css:e.toCss(o,c,h,p),rgba:e.toRgba(o,c,h,p)}}e.toColor=s})(vi||={});var Pt;(e=>{function t(g,f){if(ei=(f.rgba&255)/255,ei===1)return{css:f.css,rgba:f.rgba};let b=f.rgba>>24&255,y=f.rgba>>16&255,S=f.rgba>>8&255,w=g.rgba>>24&255,k=g.rgba>>16&255,T=g.rgba>>8&255;zi=w+Math.round((b-w)*ei),ji=k+Math.round((y-k)*ei),Hi=T+Math.round((S-T)*ei);let B=vi.toCss(zi,ji,Hi),L=vi.toRgba(zi,ji,Hi);return{css:B,rgba:L}}e.blend=t;function r(g){return(g.rgba&255)===255}e.isOpaque=r;function s(g,f,b){let y=Hu.ensureContrastRatio(g.rgba,f.rgba,b);if(y)return vi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function o(g){let f=(g.rgba|255)>>>0;return[zi,ji,Hi]=Hu.toChannels(f),{css:vi.toCss(zi,ji,Hi),rgba:f}}e.opaque=o;function c(g,f){return ei=Math.round(f*255),[zi,ji,Hi]=Hu.toChannels(g.rgba),{css:vi.toCss(zi,ji,Hi,ei),rgba:vi.toRgba(zi,ji,Hi,ei)}}e.opacity=c;function h(g,f){return ei=g.rgba&255,c(g,ei*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Pt||={});var Yt;(e=>{let t,r;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",r=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return zi=parseInt(o.slice(1,2).repeat(2),16),ji=parseInt(o.slice(2,3).repeat(2),16),Hi=parseInt(o.slice(3,4).repeat(2),16),vi.toColor(zi,ji,Hi);case 5:return zi=parseInt(o.slice(1,2).repeat(2),16),ji=parseInt(o.slice(2,3).repeat(2),16),Hi=parseInt(o.slice(3,4).repeat(2),16),ei=parseInt(o.slice(4,5).repeat(2),16),vi.toColor(zi,ji,Hi,ei);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 zi=parseInt(c[1]),ji=parseInt(c[2]),Hi=parseInt(c[3]),ei=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),vi.toColor(zi,ji,Hi,ei);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[zi,ji,Hi,ei]=t.getImageData(0,0,1,1).data,ei!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:vi.toRgba(zi,ji,Hi,ei),css:o}}e.toColor=s})(Yt||={});var rn;(e=>{function t(s){return r(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function r(s,o,c){let h=s/255,p=o/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+b*.7152+y*.0722}e.relativeLuminance2=r})(rn||={});var Hu;(e=>{function t(h,p){if(ei=(p&255)/255,ei===1)return p;let g=p>>24&255,f=p>>16&255,b=p>>8&255,y=h>>24&255,S=h>>16&255,w=h>>8&255;return zi=y+Math.round((g-y)*ei),ji=S+Math.round((f-S)*ei),Hi=w+Math.round((b-w)*ei),vi.toRgba(zi,ji,Hi)}e.blend=t;function r(h,p,g){let f=rn.relativeLuminance(h>>8),b=rn.relativeLuminance(p>>8);if(qr(f,b)<g){if(b<f){let w=s(h,p,g),k=qr(f,rn.relativeLuminance(w>>8));if(k<g){let T=o(h,p,g),B=qr(f,rn.relativeLuminance(T>>8));return k>B?w:T}return w}let y=o(h,p,g),S=qr(f,rn.relativeLuminance(y>>8));if(S<g){let w=s(h,p,g),k=qr(f,rn.relativeLuminance(w>>8));return S>k?y:w}return y}}e.ensureContrastRatio=r;function s(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,T=qr(rn.relativeLuminance2(S,w,k),rn.relativeLuminance2(f,b,y));for(;T<g&&(S>0||w>0||k>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),k-=Math.max(0,Math.ceil(k*.1)),T=qr(rn.relativeLuminance2(S,w,k),rn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.reduceLuminance=s;function o(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,T=qr(rn.relativeLuminance2(S,w,k),rn.relativeLuminance2(f,b,y));for(;T<g&&(S<255||w<255||k<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),T=qr(rn.relativeLuminance2(S,w,k),rn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(Hu||={});function ca(e){let t=e.toString(16);return t.length<2?"0"+t:t}function qr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var UD=class extends cc{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},th=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Zn}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 r=[],s=t.translateToString(!0),o=0,c=0,h=0,p=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==p||this._workCell.bg!==g){if(f-o>1){let b=this._getJoinedRanges(s,h,c,t,o);for(let y=0;y<b.length;y++)r.push(b[y])}o=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ls.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,h,c,t,o);for(let b=0;b<f.length;b++)r.push(f[b])}return r}_getJoinedRanges(e,t,r,s,o){let c=e.substring(t,r),h=[];try{h=this._characterJoiners[0].handler(c)}catch(p){console.error(p)}for(let p=1;p<this._characterJoiners.length;p++)try{let g=this._characterJoiners[p].handler(c);for(let f=0;f<g.length;f++)th._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,s,o),h}_stringRangesToCellRanges(e,t,r){let s=0,o=!1,c=0,h=e[s];if(h){for(let p=r;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||Ls.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=p,o=!0),h[1]<=c){if(h[1]=p,h=e[++s],!h)break;h[0]<=c?(h[0]=p,o=!0):o=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(r){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};th=ti([Me(0,sn)],th);function ID(e){return 57508<=e&&e<=57558}function KD(e){return 9472<=e&&e<=9631}function WD(e){return ID(e)||KD(e)}function FD(){return{css:{canvas:Eu(),cell:Eu()},device:{canvas:Eu(),cell:Eu(),char:{width:0,height:0,left:0,top:0}}}}function Eu(){return{width:0,height:0}}var sm=class{constructor(e,t,r,s,o,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=s,this._coreService=o,this._decorationService=c,this._themeService=h,this._workCell=new Zn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,s,o,c,h,p,g,f,b){let y=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,k=e.getNoBgTrimmedLength();r&&k<c+1&&(k=c+1);let T,B=0,L="",A=0,W=0,K=0,J=0,ne=!1,le=0,oe=!1,ve=0,P=0,I=[],F=f!==-1&&b!==-1;for(let H=0;H<k;H++){e.loadCell(H,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let re=!1,M=H>=P,V=H,Z=this._workCell;if(S.length>0&&H===S[0][0]&&M){let be=S.shift(),Re=this._isCellInSelection(be[0],t);for(A=be[0]+1;A<be[1];A++)M&&=Re===this._isCellInSelection(A,t);M&&=!r||c<be[0]||c>=be[1],M?(re=!0,Z=new UD(this._workCell,e.translateToString(!0,be[0],be[1]),be[1]-be[0]),V=be[1]-1,j=Z.getWidth()):P=be[1]}let Ce=this._isCellInSelection(H,t),ke=r&&H===c,R=F&&H>=f&&H<=b,G=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{G=!0});let se=Z.getChars()||Ls;if(se===" "&&(Z.isUnderline()||Z.isOverline())&&(se=" "),ve=j*p-g.get(se,Z.isBold(),Z.isItalic()),!T)T=this._document.createElement("span");else if(B&&(Ce&&oe||!Ce&&!oe&&Z.bg===W)&&(Ce&&oe&&w.selectionForeground||Z.fg===K)&&Z.extended.ext===J&&R===ne&&ve===le&&!ke&&!re&&!G&&M){Z.isInvisible()?L+=Ls:L+=se,B++;continue}else B&&(T.textContent=L),T=this._document.createElement("span"),B=0,L="";if(W=Z.bg,K=Z.fg,J=Z.extended.ext,ne=R,le=ve,oe=Ce,re&&c>=H&&c<=V&&(c=H),!this._coreService.isCursorHidden&&ke&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&I.push("xterm-cursor-blink"),I.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(Z.isBold()&&I.push("xterm-bold"),Z.isItalic()&&I.push("xterm-italic"),Z.isDim()&&I.push("xterm-dim"),Z.isInvisible()?L=Ls:L=Z.getChars()||Ls,Z.isUnderline()&&(I.push(`xterm-underline-${Z.extended.underlineStyle}`),L===" "&&(L=" "),!Z.isUnderlineColorDefault()))if(Z.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${cc.toColorRGB(Z.getUnderlineColor()).join(",")})`;else{let be=Z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Z.isBold()&&be<8&&(be+=8),T.style.textDecorationColor=w.ansi[be].css}Z.isOverline()&&(I.push("xterm-overline"),L===" "&&(L=" ")),Z.isStrikethrough()&&I.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let _e=Z.getFgColor(),fe=Z.getFgColorMode(),we=Z.getBgColor(),Ne=Z.getBgColorMode(),je=!!Z.isInverse();if(je){let be=_e;_e=we,we=be;let Re=fe;fe=Ne,Ne=Re}let Ve,ee,me=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{be.options.layer!=="top"&&me||(be.backgroundColorRGB&&(Ne=50331648,we=be.backgroundColorRGB.rgba>>8&16777215,Ve=be.backgroundColorRGB),be.foregroundColorRGB&&(fe=50331648,_e=be.foregroundColorRGB.rgba>>8&16777215,ee=be.foregroundColorRGB),me=be.options.layer==="top")}),!me&&Ce&&(Ve=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,we=Ve.rgba>>8&16777215,Ne=50331648,me=!0,w.selectionForeground&&(fe=50331648,_e=w.selectionForeground.rgba>>8&16777215,ee=w.selectionForeground)),me&&I.push("xterm-decoration-top");let De;switch(Ne){case 16777216:case 33554432:De=w.ansi[we],I.push(`xterm-bg-${we}`);break;case 50331648:De=vi.toColor(we>>16,we>>8&255,we&255),this._addStyle(T,`background-color:#${hS((we>>>0).toString(16),"0",6)}`);break;default:je?(De=w.foreground,I.push("xterm-bg-257")):De=w.background}switch(Ve||Z.isDim()&&(Ve=Pt.multiplyOpacity(De,.5)),fe){case 16777216:case 33554432:Z.isBold()&&_e<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(_e+=8),this._applyMinimumContrast(T,De,w.ansi[_e],Z,Ve,void 0)||I.push(`xterm-fg-${_e}`);break;case 50331648:let be=vi.toColor(_e>>16&255,_e>>8&255,_e&255);this._applyMinimumContrast(T,De,be,Z,Ve,ee)||this._addStyle(T,`color:#${hS(_e.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,De,w.foreground,Z,Ve,ee)||je&&I.push("xterm-fg-257")}I.length&&(T.className=I.join(" "),I.length=0),!ke&&!re&&!G&&M?B++:T.textContent=L,ve!==this.defaultSpacing&&(T.style.letterSpacing=`${ve}px`),y.push(T),H=V}return T&&B&&(T.textContent=L),y}_applyMinimumContrast(e,t,r,s,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||WD(s.getCode()))return!1;let h=this._getContrastCache(s),p;if(!o&&!c&&(p=h.getColor(t.rgba,r.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);p=Pt.ensureContrastRatio(o||t,c||r,g),h.setColor((o||t).rgba,(c||r).rgba,p??null)}return p?(this._addStyle(e,`color:${p.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 r=this._selectionStart,s=this._selectionEnd;return!r||!s?!1:this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&t>=r[1]&&e<s[0]&&t<=s[1]:e<r[0]&&t>=r[1]&&e>=s[0]&&t<=s[1]:t>r[1]&&t<s[1]||r[1]===s[1]&&t===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&t===s[1]&&e<s[0]||r[1]<s[1]&&t===r[1]&&e>=r[0]}};sm=ti([Me(1,Cw),Me(2,an),Me(3,Gr),Me(4,Ea),Me(5,uc),Me(6,Tl)],sm);function hS(e,t,r){for(;e.length<r;)e=t+e;return e}var qD=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[r,s,o,c],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,r,s){e===this._font&&t===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,r){let s=0;if(!t&&!r&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let h=this._measure(e,0);return h>0&&(this._flat[s]=h),h}let o=e;t&&(o+="B"),r&&(o+="I");let c=this._holey.get(o);if(c===void 0){let h=0;t&&(h|=1),r&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},$D=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,r,s=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,h=r[1]-o,p=Math.max(c,0),g=Math.min(h,e.rows-1);if(p>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function VD(){return new $D}var Gf="xterm-dom-renderer-owner-",$n="xterm-rows",ku="xterm-fg-",dS="xterm-bg-",So="xterm-focus",Tu="xterm-selection",YD=1,am=class extends nt{constructor(e,t,r,s,o,c,h,p,g,f,b,y,S,w){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=s,this._viewportElement=o,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=b,this._coreService=y,this._coreBrowserService=S,this._themeService=w,this._terminalClass=YD++,this._rowElements=[],this._selectionRenderModel=VD(),this.onRequestRedraw=this._register(new Ee).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add($n),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(Tu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=FD(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(sm,document),this._element.classList.add(Gf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(Wt(()=>{this._element.classList.remove(Gf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new qD(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${$n} 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} .${$n} { 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} .${$n} .xterm-dim { color: ${Pt.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${$n}.${So} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${$n}.${So} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${$n}.${So} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Tu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Tu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Tu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${ku}${c} { color: ${h.css}; }${this._terminalSelector} .${ku}${c}.xterm-dim { color: ${Pt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${dS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${ku}257 { color: ${Pt.opaque(e.background).css}; }${this._terminalSelector} .${ku}257.xterm-dim { color: ${Pt.multiplyOpacity(Pt.opaque(e.background),.5).css}; }${this._terminalSelector} .${dS}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 r=this._rowElements.length;r<=t;r++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(So),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(So),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(r){let g=e[0]>t[0];p.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=s===c?e[0]:0,f=c===o?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let b=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=o===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,r,s=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(r-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${h}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 r=this._bufferService.buffer,s=r.ybase+r.y,o=Math.min(r.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+r.ydisp,b=this._rowElements[g],y=r.lines.get(f);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,f,f===s,h,p,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Gf}${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,r,s,o,c){r<0&&(e=0),s<0&&(t=0);let h=this._bufferService.rows-1;r=Math.max(Math.min(r,h),0),s=Math.max(Math.min(s,h),0),o=Math.min(o,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,o-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=r;w<=s;++w){let k=w+p.ydisp,T=this._rowElements[w],B=p.lines.get(k);if(!T||!B)break;T.replaceChildren(...this._rowFactory.createRow(B,k,k===g,y,S,f,b,this.dimensions.css.cell.width,this._widthCache,c?w===r?e:0:-1,c?(w===s?t:o)-1:-1))}}};am=ti([Me(7,pg),Me(8,wh),Me(9,an),Me(10,sn),Me(11,Ea),Me(12,Gr),Me(13,Tl)],am);var lm=class extends nt{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ee),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new GD(this._optionsService))}catch{this._measureStrategy=this._register(new XD(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())}};lm=ti([Me(2,an)],lm);var Kw=class extends nt{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)}},XD=class extends Kw{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},GD=class extends Kw{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}},ZD=class extends nt{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new QD(this._window)),this._onDprChange=this._register(new Ee),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ee),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Vi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ge(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ge(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}},QD=class extends nt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sl),this._onDprChange=this._register(new Ee),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Wt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ge(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)}},JD=class extends nt{constructor(){super(),this.linkProviders=[],this._register(Wt(()=>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 wg(e,t,r){let s=r.getBoundingClientRect(),o=e.getComputedStyle(r),c=parseInt(o.getPropertyValue("padding-left")),h=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-h]}function eR(e,t,r,s,o,c,h,p,g){if(!c)return;let f=wg(e,t,r);if(f)return f[0]=Math.ceil((f[0]+(g?h/2:0))/h),f[1]=Math.ceil(f[1]/p),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var om=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,s,o){return eR(window,e,t,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let r=wg(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};om=ti([Me(0,Zr),Me(1,wh)],om);var tR=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,r){this._rowCount=r,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=[]}},Ww={};hT(Ww,{getSafariVersion:()=>nR,isChromeOS:()=>Vw,isFirefox:()=>Fw,isIpad:()=>rR,isIphone:()=>sR,isLegacyEdge:()=>iR,isLinux:()=>Cg,isMac:()=>ih,isNode:()=>Ch,isSafari:()=>qw,isWindows:()=>$w});var Ch=typeof process<"u"&&"title"in process,hc=Ch?"node":navigator.userAgent,dc=Ch?"node":navigator.platform,Fw=hc.includes("Firefox"),iR=hc.includes("Edge"),qw=/^((?!chrome|android).)*safari/i.test(hc);function nR(){if(!qw)return 0;let e=hc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ih=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(dc),rR=dc==="iPad",sR=dc==="iPhone",$w=["Windows","Win16","Win32","WinCE"].includes(dc),Cg=dc.indexOf("Linux")>=0,Vw=/\bCrOS\b/.test(hc),Yw=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,r=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),o=e.timeRemaining(),r*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},aR=class extends Yw{_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())}}},lR=class extends Yw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},nh=!Ch&&"requestIdleCallback"in window?lR:aR,oR=class{constructor(){this._queue=new nh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cm=class extends nt{constructor(e,t,r,s,o,c,h,p,g){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=o,this._coreBrowserService=p,this._renderer=this._register(new Sl),this._pausedResizeTask=new oR,this._observerDisposable=this._register(new Sl),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 Ee),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ee),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ee),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ee),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new tR((f,b)=>this._renderRows(f,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new cR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Wt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.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(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=Wt(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),r||(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,r){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,t,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};cm=ti([Me(2,an),Me(3,wh),Me(4,Ea),Me(5,uc),Me(6,sn),Me(7,Gr),Me(8,Tl)],cm);var cR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,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 uR(e,t,r,s){let o=r.buffer.x,c=r.buffer.y;if(!r.buffer.hasScrollback)return fR(o,c,e,t,r,s)+xh(c,t,r,s)+pR(o,c,e,t,r,s);let h;if(c===t)return h=o>e?"D":"C",Jo(Math.abs(o-e),Qo(h,s));h=c>t?"D":"C";let p=Math.abs(c-t),g=dR(c>t?e:o,r)+(p-1)*r.cols+1+hR(c>t?o:e);return Jo(g,Qo(h,s))}function hR(e,t){return e-1}function dR(e,t){return t.cols-e}function fR(e,t,r,s,o,c){return xh(t,s,o,c).length===0?"":Jo(Gw(e,t,e,t-Ca(t,o),!1,o).length,Qo("D",c))}function xh(e,t,r,s){let o=e-Ca(e,r),c=t-Ca(t,r),h=Math.abs(o-c)-mR(e,t,r);return Jo(h,Qo(Xw(e,t),s))}function pR(e,t,r,s,o,c){let h;xh(t,s,o,c).length>0?h=s-Ca(s,o):h=t;let p=s,g=gR(e,t,r,s,o,c);return Jo(Gw(e,h,r,p,g==="C",o).length,Qo(g,c))}function mR(e,t,r){let s=0,o=e-Ca(e,r),c=t-Ca(t,r);for(let h=0;h<Math.abs(o-c);h++){let p=Xw(e,t)==="A"?-1:1;r.buffer.lines.get(o+p*h)?.isWrapped&&s++}return s}function Ca(e,t){let r=0,s=t.buffer.lines.get(e),o=s?.isWrapped;for(;o&&e>=0&&e<t.rows;)r++,s=t.buffer.lines.get(--e),o=s?.isWrapped;return r}function gR(e,t,r,s,o,c){let h;return xh(r,s,o,c).length>0?h=s-Ca(s,o):h=t,e<r&&h<=s||e>=r&&h<s?"C":"D"}function Xw(e,t){return e>t?"A":"B"}function Gw(e,t,r,s,o,c){let h=e,p=t,g="";for(;(h!==r||p!==s)&&p>=0&&p<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!o&&h<0&&(g+=c.buffer.translateBufferLineToString(p,!1,0,e+1),h=c.cols-1,e=h,p--);return g+c.buffer.translateBufferLineToString(p,!1,e,h)}function Qo(e,t){let r=t?"O":"[";return de.ESC+r+e}function Jo(e,t){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=t;return r}var _R=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 fS(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 Zf=50,vR=15,yR=50,bR=500,SR=" ",wR=new RegExp(SR,"g"),um=class extends nt{constructor(e,t,r,s,o,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=s,this._coreService=o,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Zn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ee),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ee),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ee),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ee),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new _R(this._bufferService),this._activeSelectionMode=0,this._register(Wt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let r=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let p=r.translateBufferLineToString(h,!0,o,c);s.push(p)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let h=r.lines.get(c),p=r.translateBufferLineToString(c,!0);h?.isWrapped?s[s.length-1]+=p:s.push(p)}if(e[1]!==t[1]){let c=r.lines.get(t[1]),h=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=h:s.push(h)}}return s.map(o=>o.replace(wR," ")).join($w?`\r
26
- `:`
27
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Cg&&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),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s||!t?!1:this._areCoordsInSelection(t,r,s)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s?!1:this._areCoordsInSelection([e,t],r,s)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=fS(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=wg(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-Zf),Zf),t/=Zf,t/Math.abs(t)+Math.round(t*(vR-1)))}shouldForceSelection(e){return ih?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(),yR)}_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&&!(ih&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let s=r.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<bR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let s=uR(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:o>1&&t!==s&&(r+=o-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let h=o.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,b=0,y=0,S=0,w=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let B=e[0],L=e[0];c.getWidth(B)===0&&(b++,B--),c.getWidth(L)===2&&(y++,L++);let A=c.getString(L).length;for(A>1&&(w+=A-1,g+=A-1);B>0&&p>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,B--):W>1&&(S+=W-1,p-=W-1),p--,B--}for(;L<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,L++):W>1&&(w+=W-1,g+=W-1),g++,L++}}g++;let k=p+f-b+S,T=Math.min(this._bufferService.cols,g-p+b+y-S-w);if(!(!t&&h.slice(p,g).trim()==="")){if(r&&k===0&&c.getCodePoint(0)!==32){let B=o.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let A=this._bufferService.cols-L.start;k-=A,T+=A}}}if(s&&k+T===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=o.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(T+=L.length)}}return{start:k,length:T}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=fS(r,this._bufferService.cols)}};um=ti([Me(3,sn),Me(4,Ea),Me(5,mg),Me(6,an),Me(7,Zr),Me(8,Gr)],um);var pS=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},mS=class{constructor(){this._color=new pS,this._css=new pS}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},xi=Object.freeze((()=>{let e=[Yt.toColor("#2e3436"),Yt.toColor("#cc0000"),Yt.toColor("#4e9a06"),Yt.toColor("#c4a000"),Yt.toColor("#3465a4"),Yt.toColor("#75507b"),Yt.toColor("#06989a"),Yt.toColor("#d3d7cf"),Yt.toColor("#555753"),Yt.toColor("#ef2929"),Yt.toColor("#8ae234"),Yt.toColor("#fce94f"),Yt.toColor("#729fcf"),Yt.toColor("#ad7fa8"),Yt.toColor("#34e2e2"),Yt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=t[r/36%6|0],o=t[r/6%6|0],c=t[r%6];e.push({css:vi.toCss(s,o,c),rgba:vi.toRgba(s,o,c)})}for(let r=0;r<24;r++){let s=8+r*10;e.push({css:vi.toCss(s,s,s),rgba:vi.toRgba(s,s,s)})}return e})()),ha=Yt.toColor("#ffffff"),Lo=Yt.toColor("#000000"),gS=Yt.toColor("#ffffff"),_S=Lo,wo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},CR=ha,hm=class extends nt{constructor(e){super(),this._optionsService=e,this._contrastCache=new mS,this._halfContrastCache=new mS,this._onChangeColors=this._register(new Ee),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ha,background:Lo,cursor:gS,cursorAccent:_S,selectionForeground:void 0,selectionBackgroundTransparent:wo,selectionBackgroundOpaque:Pt.blend(Lo,wo),selectionInactiveBackgroundTransparent:wo,selectionInactiveBackgroundOpaque:Pt.blend(Lo,wo),scrollbarSliderBackground:Pt.opacity(ha,.2),scrollbarSliderHoverBackground:Pt.opacity(ha,.4),scrollbarSliderActiveBackground:Pt.opacity(ha,.5),overviewRulerBorder:ha,ansi:xi.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=Rt(e.foreground,ha),t.background=Rt(e.background,Lo),t.cursor=Pt.blend(t.background,Rt(e.cursor,gS)),t.cursorAccent=Pt.blend(t.background,Rt(e.cursorAccent,_S)),t.selectionBackgroundTransparent=Rt(e.selectionBackground,wo),t.selectionBackgroundOpaque=Pt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Rt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Pt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Rt(e.selectionForeground,uS):void 0,t.selectionForeground===uS&&(t.selectionForeground=void 0),Pt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Pt.opacity(t.selectionBackgroundTransparent,.3)),Pt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Pt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Rt(e.scrollbarSliderBackground,Pt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Rt(e.scrollbarSliderHoverBackground,Pt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Rt(e.scrollbarSliderActiveBackground,Pt.opacity(t.foreground,.5)),t.overviewRulerBorder=Rt(e.overviewRulerBorder,CR),t.ansi=xi.slice(),t.ansi[0]=Rt(e.black,xi[0]),t.ansi[1]=Rt(e.red,xi[1]),t.ansi[2]=Rt(e.green,xi[2]),t.ansi[3]=Rt(e.yellow,xi[3]),t.ansi[4]=Rt(e.blue,xi[4]),t.ansi[5]=Rt(e.magenta,xi[5]),t.ansi[6]=Rt(e.cyan,xi[6]),t.ansi[7]=Rt(e.white,xi[7]),t.ansi[8]=Rt(e.brightBlack,xi[8]),t.ansi[9]=Rt(e.brightRed,xi[9]),t.ansi[10]=Rt(e.brightGreen,xi[10]),t.ansi[11]=Rt(e.brightYellow,xi[11]),t.ansi[12]=Rt(e.brightBlue,xi[12]),t.ansi[13]=Rt(e.brightMagenta,xi[13]),t.ansi[14]=Rt(e.brightCyan,xi[14]),t.ansi[15]=Rt(e.brightWhite,xi[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)t.ansi[s+16]=Rt(e.extendedAnsi[s],xi[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};hm=ti([Me(0,an)],hm);function Rt(e,t){if(e!==void 0)try{return Yt.toColor(e)}catch{}return t}var xR=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ER=class{constructor(){this._services=new xR,this._services.set(pg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=vT(e).sort((c,h)=>c.index-h.index),s=[];for(let c of r){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(h)}let o=r.length>0?r[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},kR={trace:0,debug:1,info:2,warn:3,error:4,off:5},TR="xterm.js: ",dm=class extends nt{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=kR[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":TR)+t,...r)}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)}};dm=ti([Me(0,an)],dm);var vS=class extends nt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ee),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ee),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ee),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+r.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<r.length;s++)this._array[this._getCyclicIndex(e+s)]=r[s];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let s=this._length+r.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let o=t-1;o>=0;o--)this.set(e+o+r,this.get(e+o));let s=e+t+r-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},it=3,_i=Object.freeze(new cc),Du=0,Qf=2,Bo=class Zw{constructor(t,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*it);let o=r||Zn.fromCharData([0,gw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let r=this._data[t*it+0],s=r&2097151;return[this._data[t*it+1],r&2097152?this._combined[t]:s?As(s):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,r){this._data[t*it+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*it+0]=t|2097152|r[2]<<22):this._data[t*it+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*it+0]>>22}hasWidth(t){return this._data[t*it+0]&12582912}getFg(t){return this._data[t*it+1]}getBg(t){return this._data[t*it+2]}hasContent(t){return this._data[t*it+0]&4194303}getCodePoint(t){let r=this._data[t*it+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*it+0]&2097152}getString(t){let r=this._data[t*it+0];return r&2097152?this._combined[t]:r&2097151?As(r&2097151):""}isProtected(t){return this._data[t*it+2]&536870912}loadCell(t,r){return Du=t*it,r.content=this._data[Du+0],r.fg=this._data[Du+1],r.bg=this._data[Du+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*it+0]=r.content,this._data[t*it+1]=r.fg,this._data[t*it+2]=r.bg}setCellFromCodepoint(t,r,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*it+0]=r|s<<22,this._data[t*it+1]=o.fg,this._data[t*it+2]=o.bg}addCodepointToCell(t,r,s){let o=this._data[t*it+0];o&2097152?this._combined[t]+=As(r):o&2097151?(this._combined[t]=As(o&2097151)+As(r),o&=-2097152,o|=2097152):o=r|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*it+0]=o}insertCells(t,r,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length-t){let o=new Zn;for(let c=this.length-t-r-1;c>=0;--c)this.setCell(t+r+c,this.loadCell(t+c,o));for(let c=0;c<r;++c)this.setCell(t+c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,r,s){if(t%=this.length,r<this.length-t){let o=new Zn;for(let c=0;c<this.length-t-r;++c)this.setCell(t+c,this.loadCell(t+r+c,o));for(let c=this.length-r;c<this.length;++c)this.setCell(c,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,r,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.setCell(t++,s)}resize(t,r){if(t===this.length)return this._data.length*4*Qf<this._data.buffer.byteLength;let s=t*it;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,r)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let h=0;h<o.length;h++){let p=parseInt(o[h],10);p>=t&&delete this._combined[p]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let p=parseInt(c[h],10);p>=t&&delete this._extendedAttrs[p]}}return this.length=t,s*4*Qf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Qf<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new Zw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303)return t+(this._data[t*it+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303||this._data[t*it+2]&50331648)return t+(this._data[t*it+0]>>22);return 0}copyCellsFrom(t,r,s,o,c){let h=t._data;if(c)for(let g=o-1;g>=0;g--){for(let f=0;f<it;f++)this._data[(s+g)*it+f]=h[(r+g)*it+f];h[(r+g)*it+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}else for(let g=0;g<o;g++){for(let f=0;f<it;f++)this._data[(s+g)*it+f]=h[(r+g)*it+f];h[(r+g)*it+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=r&&(this._combined[f-r+s]=t._combined[f])}}translateToString(t,r,s,o){r=r??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;r<s;){let h=this._data[r*it+0],p=h&2097151,g=h&2097152?this._combined[r]:p?As(p):Ls;if(c+=g,o)for(let f=0;f<g.length;++f)o.push(r);r+=h>>22||1}return o&&o.push(r),c}};function DR(e,t,r,s,o,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let b=[e.get(p)];for(;g<e.length&&f.isWrapped;)b.push(f),f=e.get(++g);if(!c&&s>=p&&s<g){p+=b.length-1;continue}let y=0,S=ec(b,y,t),w=1,k=0;for(;w<b.length;){let B=ec(b,w,t),L=B-k,A=r-S,W=Math.min(L,A);b[y].copyCellsFrom(b[w],k,S,W,!1),S+=W,S===r&&(y++,S=0),k+=W,k===B&&(w++,k=0),S===0&&y!==0&&b[y-1].getWidth(r-1)===2&&(b[y].copyCellsFrom(b[y-1],r-1,S++,1,!1),b[y-1].setCell(r-1,o))}b[y].replaceCells(S,r,o);let T=0;for(let B=b.length-1;B>0&&(B>y||b[B].getTrimmedLength()===0);B--)T++;T>0&&(h.push(p+b.length-T),h.push(T)),p+=b.length-1}return h}function RR(e,t){let r=[],s=0,o=t[s],c=0;for(let h=0;h<e.length;h++)if(o===h){let p=t[++s];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,o=t[++s]}else r.push(h);return{layout:r,countRemoved:c}}function MR(e,t){let r=[];for(let s=0;s<t.length;s++)r.push(e.get(t[s]));for(let s=0;s<r.length;s++)e.set(s,r[s]);e.length=t.length}function NR(e,t,r){let s=[],o=e.map((g,f)=>ec(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<o;){if(o-p<r){s.push(o-p);break}c+=r;let g=ec(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let b=f?r-1:r;s.push(b),p+=b}return s}function ec(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?r-1:r}var Qw=class Jw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Jw._nextId++,this._onDispose=this.register(new Ee),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),wa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Qw._nextId=1;var AR=Qw,Di={},da=Di.B;Di[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Di.A={"#":"£"};Di.B=void 0;Di[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Di.C=Di[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Di.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Di.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Di.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Di.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Di.E=Di[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Di.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Di.H=Di[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Di["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var yS=4294967295,bS=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=_i.clone(),this.savedCharset=da,this.markers=[],this._nullCell=Zn.fromCharData([0,gw,1,0]),this._whitespaceCell=Zn.fromCharData([0,Ls,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new nh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new vS(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 Ju),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 Ju),this._whitespaceCell}getBlankLine(e,t){return new Bo(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>yS?yS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=_i);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 vS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(_i),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)s+=+this.lines.get(h).resize(e,r);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)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 Bo(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Bo(e,r)));else for(let h=this._rows;h>t;h--)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 h=this.lines.length-o;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=DR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(_i),r);if(s.length>0){let o=RR(this.lines,s);MR(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let s=this.getNullCell(_i),o=r;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Bo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(_i),o=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let p=this.lines.get(h);if(!p||!p.isWrapped&&p.getTrimmedLength()<=e)continue;let g=[p];for(;p.isWrapped&&h>0;)p=this.lines.get(--h),g.unshift(p);if(!r){let W=this.ybase+this.y;if(W>=h&&W<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),b=NR(g,this._cols,e),y=b.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+y):S=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let W=0;W<y;W++){let K=this.getBlankLine(_i,!0);w.push(K)}w.length>0&&(o.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let k=b.length-1,T=b[k];T===0&&(k--,T=b[k]);let B=g.length-y-1,L=f;for(;B>=0;){let W=Math.min(L,T);if(g[k]===void 0)break;if(g[k].copyCellsFrom(g[B],L-W,T-W,W,!0),T-=W,T===0&&(k--,T=b[k]),L-=W,L===0){B--;let K=Math.max(B,0);L=ec(g,K,this._cols)}}for(let W=0;W<g.length;W++)b[W]<e&&g[W].setCell(b[W],s);let A=y-S;for(;A-- >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+y,this.ybase+t-1)}if(o.length>0){let h=[],p=[];for(let T=0;T<this.lines.length;T++)p.push(this.lines.get(T));let g=this.lines.length,f=g-1,b=0,y=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(y&&y.start>f+S){for(let B=y.newLines.length-1;B>=0;B--)this.lines.set(T--,y.newLines[B]);T++,h.push({index:f+1,amount:y.newLines.length}),S+=y.newLines.length,y=o[++b]}else this.lines.set(T,p[f--]);let w=0;for(let T=h.length-1;T>=0;T--)h[T].index+=w,this.lines.onInsertEmitter.fire(h[T]),w+=h[T].amount;let k=Math.max(0,g+c-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,r=0,s){let o=this.lines.get(e);return o?o.translateToString(t,r,s):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}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 AR(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},LR=class extends nt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ee),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 bS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new bS(!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)}},e1=2,t1=1,fm=class extends nt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ee),this.onResize=this._onResize.event,this._onScroll=this._register(new Ee),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,e1),this.rows=Math.max(e.rawOptions.rows||0,t1),this.buffers=this._register(new LR(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=r.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=r.ybase+r.scrollTop,c=r.ybase+r.scrollBottom;if(r.scrollTop===0){let h=r.lines.isFull;c===r.lines.length-1?h?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(c+1,0,s.clone()),h?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let h=c-o+1;r.lines.shiftElements(o+1,h-1,-1),r.lines.set(c,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};fm=ti([Me(0,an)],fm);var ul={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:ih,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},BR=["normal","bold","100","200","300","400","500","600","700","800","900"],OR=class extends nt{constructor(e){super(),this._onOptionChange=this._register(new Ee),this.onOptionChange=this._onOptionChange.event;let t={...ul};for(let r in e)if(r in t)try{let s=e[r];t[r]=this._sanitizeAndValidateOption(r,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Wt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in ul))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,s)=>{if(!(r in ul))throw new Error(`No option with key "${r}"`);s=this._sanitizeAndValidateOption(r,s),this.rawOptions[r]!==s&&(this.rawOptions[r]=s,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=ul[e]),!zR(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=BR.includes(t)?t:ul[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 zR(e){return e==="block"||e==="underline"||e==="bar"}function Oo(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=t<=1?e[s]:e[s]&&Oo(e[s],t-1);return r}var SS=Object.freeze({insertMode:!1}),wS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),pm=class extends nt{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ee),this.onData=this._onData.event,this._onUserInput=this._register(new Ee),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ee),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ee),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Oo(SS),this.decPrivateModes=Oo(wS)}reset(){this.modes=Oo(SS),this.decPrivateModes=Oo(wS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};pm=ti([Me(0,sn),Me(1,Sw),Me(2,an)],pm);var CS={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 Jf(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var ep=String.fromCharCode,xS={DEFAULT:e=>{let t=[Jf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ep(t[0])}${ep(t[1])}${ep(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Jf(e,!0)};${e.x};${e.y}${t}`}},mm=class extends nt{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ee),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(CS))this.addProtocol(s,CS[s]);for(let s of Object.keys(xS))this.addEncoding(s,xS[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let s=t/r,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,r){if(r){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)}};mm=ti([Me(0,sn),Me(1,Ea),Me(2,an)],mm);var tp=[[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]],jR=[[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]],Ei;function HR(e,t){let r=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=r;)if(o=r+s>>1,e>t[o][1])r=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var PR=class{constructor(){if(this.version="6",!Ei){Ei=new Uint8Array(65536),Ei.fill(1),Ei[0]=0,Ei.fill(0,1,32),Ei.fill(0,127,160),Ei.fill(2,4352,4448),Ei[9001]=2,Ei[9002]=2,Ei.fill(2,11904,42192),Ei[12351]=1,Ei.fill(2,44032,55204),Ei.fill(2,63744,64256),Ei.fill(2,65040,65050),Ei.fill(2,65072,65136),Ei.fill(2,65280,65377),Ei.fill(2,65504,65511);for(let e=0;e<tp.length;++e)Ei.fill(0,tp[e][0],tp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ei[e]:HR(e,jR)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),s=r===0&&t!==0;if(s){let o=ma.extractWidth(t);o===0?s=!1:o>r&&(r=o)}return ma.createPropertyValue(0,r,s)}},ma=class Pu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ee,this.onChange=this._onChange.event;let t=new PR;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,r,s=!1){return(t&16777215)<<3|(r&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,s=0,o=t.length;for(let c=0;c<o;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=o)return r+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:r+=this.wcwidth(f)}let p=this.charProperties(h,s),g=Pu.extractWidth(p);Pu.extractShouldJoin(p)&&(g-=Pu.extractWidth(s)),r+=g,s=p}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},UR=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 ES(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Co=2147483647,IR=256,i1=class gm{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>IR)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new gm;if(!t.length)return r;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let c=0;c<o.length;++c)r.addSubParam(o[c]);else r.addParam(o)}return r}clone(){let t=new gm(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 r=0;r<this.length;++r){t.push(this.params[r]);let s=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Co?Co: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>Co?Co:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,o=this._subParamsIdx[r]&255;o-s>0&&(t[r]=this._subParams.slice(s,o))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[r-1];s[r-1]=~o?Math.min(o*10+t,Co):t}},xo=[],KR=class{constructor(){this._state=0,this._active=xo,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xo}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=xo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||xo,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Sh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;s>=0&&(r=this._active[s].end(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=xo,this._id=-1,this._state=0}}},Mn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Sh(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Eo=[],WR=class{constructor(){this._handlers=Object.create(null),this._active=Eo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Eo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Eo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Eo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Sh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&r===!1){for(;s>=0&&(r=this._active[s].unhook(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=Eo,this._ident=0}},zo=new i1;zo.addParam(0);var kS=class{constructor(e){this._handler=e,this._data="",this._params=zo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():zo,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Sh(e,t,r),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(r=>(this._params=zo,this._data="",this._hitLimit=!1,r));return this._params=zo,this._data="",this._hitLimit=!1,t}},FR=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,s){this.table[t<<8|e]=r<<4|s}addMany(e,t,r,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=r<<4|s}},Xn=160,qR=(function(){let e=new FR(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),r=(p,g)=>t.slice(p,g),s=r(32,127),o=r(0,24);o.push(25),o.push.apply(o,r(28,32));let c=r(0,14),h;e.setDefault(1,0),e.addMany(s,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(r(128,144),h,3,0),e.addMany(r(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(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(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Xn,0,2,0),e.add(Xn,8,5,8),e.add(Xn,6,0,6),e.add(Xn,11,0,11),e.add(Xn,13,13,13),e})(),$R=class extends nt{constructor(e=qR){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 i1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(Wt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new KR),this._dcsParser=this._register(new WR),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>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");r<<=8,r|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=s,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,r,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,r){let s=0,o=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let p=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(s!==24&&s!==26,r),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],h=this._oscParser.end(s!==24&&s!==26,r),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let p=c;p<t;++p){switch(s=e[p],o=this._transitions.table[this.currentState<<8|(s<160?s:Xn)],o>>4){case 2:for(let S=p+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Xn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Xn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Xn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Xn){this._printHandler(e,p,S),p=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(h=g[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._preserveStack(3,g,f,o,p),h;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++p<t&&(s=e[p])>47&&s<60);p--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let b=this._escHandlers[this._collect<<8|s],y=b?b.length-1:-1;for(;y>=0&&(h=b[y](),h!==!0);y--)if(h instanceof Promise)return this._preserveStack(4,b,y,o,p),h;y<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let S=p+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Xn){this._dcsParser.put(e,p,S),p=S-1;break}break;case 14:if(h=this._dcsParser.unhook(s!==24&&s!==26),h)return this._preserveStack(6,[],0,o,p),h;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let S=p+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Xn){this._oscParser.put(e,p,S),p=S-1;break}break;case 6:if(h=this._oscParser.end(s!==24&&s!==26),h)return this._preserveStack(5,[],0,o,p),h;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},VR=/^([\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})$/,YR=/^[\da-f]+$/;function TS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=VR.exec(t);if(r){let s=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/s*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/s*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),YR.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(r*o,r*o+r),16);s[o]=r===1?c<<4:r===2?c:r===3?c>>4:c>>8}return s}}function ip(e,t){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function XR(e,t=16){let[r,s,o]=e;return`rgb:${ip(r,t)}/${ip(s,t)}/${ip(o,t)}`}var GR={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ts=131072,DS=10;function RS(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 MS=5e3,NS=0,ZR=class extends nt{constructor(e,t,r,s,o,c,h,p,g=new $R){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=s,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new gT,this._utf8Decoder=new _T,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_i.clone(),this._eraseAttrDataInternal=_i.clone(),this._onRequestBell=this._register(new Ee),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ee),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ee),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ee),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ee),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ee),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ee),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ee),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ee),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ee),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ee),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ee),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ee),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 _m(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:b.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:b,data:y})}),this._parser.setDcsHandlerFallback((f,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:b,payload:y})}),this._parser.setPrintHandler((f,b,y)=>this.print(f,b,y)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(de.BEL,()=>this.bell()),this._parser.setExecuteHandler(de.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(de.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(de.BS,()=>this.backspace()),this._parser.setExecuteHandler(de.HT,()=>this.tab()),this._parser.setExecuteHandler(de.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(de.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ju.IND,()=>this.index()),this._parser.setExecuteHandler(ju.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ju.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Mn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Mn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Mn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Mn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Mn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Mn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Mn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Mn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Mn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Mn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Mn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Mn(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Di)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new kS((f,b)=>this.requestStatusString(f,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),MS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${MS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,s=this._activeBuffer.x,o=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ts&&(c=this._parseStack.position+Ts)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ts&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ts))),h||this._dirtyRowTracker.clearRange(),e.length>Ts)for(let f=c;f<e.length;f+=Ts){let b=f+Ts<e.length?f+Ts:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(f,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,b),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,o,y,f),this._logSlowResolvingAsync(r),r}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let p=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(p,this._bufferService.rows-1)})}print(e,t,r){let s,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,b=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let S=this._parser.precedingJoinState;for(let w=t;w<r;++w){if(s=e[w],s<127&&c){let L=c[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let k=this._unicodeService.charProperties(s,S);o=ma.extractWidth(k);let T=ma.extractShouldJoin(k),B=T?ma.extractWidth(S):0;if(S=k,h&&this._onA11yChar.fire(As(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>p){if(g){let L=y,A=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),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&y instanceof Bo&&y.copyCellsFrom(L,A,0,B,!1);A<p;)L.setCellFromCodepoint(A++,0,1,b)}else if(this._activeBuffer.x=p-1,o===2)continue}if(T&&this._activeBuffer.x){let L=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-L,s,o);for(let A=o-B;--A>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(f&&(y.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(b)),y.getWidth(p-1)===2&&y.setCellFromCodepoint(p-1,0,1,b)),y.setCellFromCodepoint(this._activeBuffer.x++,s,o,b),o>0)for(;--o;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=S,this._activeBuffer.x<p&&r-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>RS(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new kS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Mn(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,r,s=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(r,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 r=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(_i));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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,s=ma.extractWidth(t),o=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),h=new Uint32Array(c.length*r),p=0;for(let f=0;f<c.length;){let b=c.codePointAt(f)||0;h[p++]=b,f+=b>65535?2:1}let g=p;for(let f=1;f<r;++f)h.copyWithin(g,0,p),g+=p;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(de.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(de.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(de.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(de.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(de.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,da),this._charsetService.setgCharset(1,da),this._charsetService.setgCharset(2,da),this._charsetService.setgCharset(3,da);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 r;(T=>(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(r||={});let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:b}=p,y=this._optionsService.rawOptions,S=(T,B)=>(h.triggerDataEvent(`${de.ESC}[${t?"":"?"}${T};${B}$y`),!0),w=T=>T?1:2,k=e.params[0];return t?k===2?S(k,4):k===4?S(k,w(h.modes.insertMode)):k===12?S(k,3):k===20?S(k,w(y.convertEol)):S(k,0):k===1?S(k,w(s.applicationCursorKeys)):k===3?S(k,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):k===6?S(k,w(s.origin)):k===7?S(k,w(s.wraparound)):k===8?S(k,3):k===9?S(k,w(o==="X10")):k===12?S(k,w(y.cursorBlink)):k===25?S(k,w(!h.isCursorHidden)):k===45?S(k,w(s.reverseWraparound)):k===66?S(k,w(s.applicationKeypad)):k===67?S(k,4):k===1e3?S(k,w(o==="VT200")):k===1002?S(k,w(o==="DRAG")):k===1003?S(k,w(o==="ANY")):k===1004?S(k,w(s.sendFocus)):k===1005?S(k,4):k===1006?S(k,w(c==="SGR")):k===1015?S(k,4):k===1016?S(k,w(c==="SGR_PIXELS")):k===1048?S(k,1):k===47||k===1047||k===1049?S(k,w(f===b)):k===2004?S(k,w(s.bracketedPasteMode)):k===2026?S(k,w(s.synchronizedOutput)):S(k,0)}_updateAttrColor(e,t,r,s,o){return t===2?(e|=50331648,e&=-16777216,e|=cc.fromColorRGB([r,s,o])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let s=[0,0,-1,0,0,0],o=0,c=0;do{if(s[c+o]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do s[1]===5&&(o=1),s[c+p+1+o]=h[p];while(++p<h.length&&p+c+1+o<s.length);break}if(s[1]===5&&c+o>=2||s[1]===2&&c+o>=5)break;s[1]&&(o=1)}while(++c+t<e.length&&c+o<s.length);for(let h=2;h<s.length;++h)s[h]===-1&&(s[h]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,s[1],s[3],s[4],s[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=_i.fg,e.bg=_i.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,r,s=this._curAttrData;for(let o=0;o<t;o++)r=e.params[o],r>=30&&r<=37?(s.fg&=-50331904,s.fg|=16777216|r-30):r>=40&&r<=47?(s.bg&=-50331904,s.bg|=16777216|r-40):r>=90&&r<=97?(s.fg&=-50331904,s.fg|=16777216|r-90|8):r>=100&&r<=107?(s.bg&=-50331904,s.bg|=16777216|r-100|8):r===0?this._processSGR0(s):r===1?s.fg|=134217728:r===3?s.bg|=67108864:r===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):r===5?s.fg|=536870912:r===7?s.fg|=67108864:r===8?s.fg|=1073741824:r===9?s.fg|=2147483648:r===2?s.bg|=134217728:r===21?this._processUnderline(2,s):r===22?(s.fg&=-134217729,s.bg&=-134217729):r===23?s.bg&=-67108865:r===24?(s.fg&=-268435457,this._processUnderline(0,s)):r===25?s.fg&=-536870913:r===27?s.fg&=-67108865:r===28?s.fg&=-1073741825:r===29?s.fg&=2147483647:r===39?(s.fg&=-67108864,s.fg|=_i.fg&16777215):r===49?(s.bg&=-67108864,s.bg|=_i.bg&16777215):r===38||r===48||r===58?o+=this._extractColor(e,o,s):r===53?s.bg|=1073741824:r===55?s.bg&=-1073741825:r===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):r===100?(s.fg&=-67108864,s.fg|=_i.fg&16777215,s.bg&=-67108864,s.bg|=_i.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${de.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[?${t};${r}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=_i.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 r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!RS(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(`${de.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>DS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>DS&&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=[],r=e.split(";");for(;r.length>1;){let s=r.shift(),o=r.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(AS(c))if(o==="?")t.push({type:0,index:c});else{let h=TS(o);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(r,s):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,o=r.findIndex(c=>c.startsWith("id="));return o!==-1&&(s=r[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let s=0;s<r.length&&!(t>=this._specialColors.length);++s,++t)if(r[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=TS(r[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],r=e.split(";");for(let s=0;s<r.length;++s)if(/^\d+$/.exec(r[s])){let o=parseInt(r[s]);AS(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,da),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(GR[e[0]],Di[e[1]]||da),!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=_i.clone(),this._eraseAttrDataInternal=_i.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 Zn;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 r=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=h=>(this._coreService.triggerDataEvent(`${de.ESC}${h}${de.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},_m=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&&(NS=e,e=t,t=NS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};_m=ti([Me(0,sn)],_m);function AS(e){return 0<=e&&e<256}var QR=5e7,LS=12,JR=50,eM=class extends nt{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 Ee),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>QR)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let h=p=>performance.now()-r>=LS?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(r,p);o.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-r>=LS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>JR&&(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()}},vm=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 p=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(g,p)),this._dataByLinkId.set(g.id,g),g.id}let r=e,s=this._getEntryIdKey(r),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);r.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(r,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};vm=ti([Me(0,sn)],vm);var BS=!1,tM=class extends nt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sl),this._onBinary=this._register(new Ee),this.onBinary=this._onBinary.event,this._onData=this._register(new Ee),this.onData=this._onData.event,this._onLineFeed=this._register(new Ee),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ee),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ee),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ee),this._instantiationService=new ER,this.optionsService=this._register(new OR(e)),this._instantiationService.setService(an,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fm)),this._instantiationService.setService(sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(dm)),this._instantiationService.setService(Sw,this._logService),this.coreService=this._register(this._instantiationService.createInstance(pm)),this._instantiationService.setService(Ea,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mm)),this._instantiationService.setService(bw,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ma)),this._instantiationService.setService(ST,this.unicodeService),this._charsetService=this._instantiationService.createInstance(UR),this._instantiationService.setService(bT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(vm),this._instantiationService.setService(ww,this._oscLinkService),this._inputHandler=this._register(new ZR(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Vi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Vi.forward(this._bufferService.onResize,this._onResize)),this._register(Vi.forward(this.coreService.onData,this._onData)),this._register(Vi.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 eM((t,r)=>this._inputHandler.parse(t,r))),this._register(Vi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ee),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&&!BS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),BS=!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,e1),t=Math.max(t,t1),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(ES.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ES(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Wt(()=>{for(let t of e)t.dispose()})}}},iM={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 nM(e,t,r,s){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=de.ESC+"OA":o.key=de.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=de.ESC+"OD":o.key=de.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=de.ESC+"OC":o.key=de.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=de.ESC+"OB":o.key=de.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":de.DEL,e.altKey&&(o.key=de.ESC+o.key);break;case 9:if(e.shiftKey){o.key=de.ESC+"[Z";break}o.key=de.HT,o.cancel=!0;break;case 13:o.key=e.altKey?de.ESC+de.CR:de.CR,o.cancel=!0;break;case 27:o.key=de.ESC,e.altKey&&(o.key=de.ESC+de.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=de.ESC+"[1;"+(c+1)+"D":t?o.key=de.ESC+"OD":o.key=de.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=de.ESC+"[1;"+(c+1)+"C":t?o.key=de.ESC+"OC":o.key=de.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=de.ESC+"[1;"+(c+1)+"A":t?o.key=de.ESC+"OA":o.key=de.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=de.ESC+"[1;"+(c+1)+"B":t?o.key=de.ESC+"OB":o.key=de.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=de.ESC+"[2~");break;case 46:c?o.key=de.ESC+"[3;"+(c+1)+"~":o.key=de.ESC+"[3~";break;case 36:c?o.key=de.ESC+"[1;"+(c+1)+"H":t?o.key=de.ESC+"OH":o.key=de.ESC+"[H";break;case 35:c?o.key=de.ESC+"[1;"+(c+1)+"F":t?o.key=de.ESC+"OF":o.key=de.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=de.ESC+"[5;"+(c+1)+"~":o.key=de.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=de.ESC+"[6;"+(c+1)+"~":o.key=de.ESC+"[6~";break;case 112:c?o.key=de.ESC+"[1;"+(c+1)+"P":o.key=de.ESC+"OP";break;case 113:c?o.key=de.ESC+"[1;"+(c+1)+"Q":o.key=de.ESC+"OQ";break;case 114:c?o.key=de.ESC+"[1;"+(c+1)+"R":o.key=de.ESC+"OR";break;case 115:c?o.key=de.ESC+"[1;"+(c+1)+"S":o.key=de.ESC+"OS";break;case 116:c?o.key=de.ESC+"[15;"+(c+1)+"~":o.key=de.ESC+"[15~";break;case 117:c?o.key=de.ESC+"[17;"+(c+1)+"~":o.key=de.ESC+"[17~";break;case 118:c?o.key=de.ESC+"[18;"+(c+1)+"~":o.key=de.ESC+"[18~";break;case 119:c?o.key=de.ESC+"[19;"+(c+1)+"~":o.key=de.ESC+"[19~";break;case 120:c?o.key=de.ESC+"[20;"+(c+1)+"~":o.key=de.ESC+"[20~";break;case 121:c?o.key=de.ESC+"[21;"+(c+1)+"~":o.key=de.ESC+"[21~";break;case 122:c?o.key=de.ESC+"[23;"+(c+1)+"~":o.key=de.ESC+"[23~";break;case 123:c?o.key=de.ESC+"[24;"+(c+1)+"~":o.key=de.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=de.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=de.DEL:e.keyCode===219?o.key=de.ESC:e.keyCode===220?o.key=de.FS:e.keyCode===221&&(o.key=de.GS);else if((!r||s)&&e.altKey&&!e.metaKey){let h=iM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.key=de.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(p);e.shiftKey&&(g=g.toUpperCase()),o.key=de.ESC+g}else if(e.keyCode===32)o.key=de.ESC+(e.ctrlKey?de.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=de.ESC+p,o.cancel=!0}}else r&&!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=de.US),e.key==="@"&&(o.key=de.NUL));break}return o}var ci=0,rM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new nh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new nh,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,r=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(s[o]=e[t],t++):s[o]=this._array[r++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(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,r=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:r[s++]=this._array[o];this._array=r,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,r=this._array.length-1;for(;r>=t;){let s=t+r>>1,o=this._getKey(this._array[s]);if(o>e)r=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},np=0,OS=0,sM=class extends nt{constructor(){super(),this._decorations=new rM(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ee),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ee),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Wt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new aM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let s=0,o=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,o=s+(c.options.width??1),e>=s&&e<o&&(!r||(c.options.layer??"bottom")===r)&&(yield c)}forEachDecorationAtCell(e,t,r,s){this._decorations.forEachByKey(t,o=>{np=o.options.x??0,OS=np+(o.options.width??1),e>=np&&e<OS&&(!r||(o.options.layer??"bottom")===r)&&s(o)})}},aM=class extends Os{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ee),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ee),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=Yt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Yt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},lM=1e3,oM=class{constructor(e,t=lM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},zS=20,rh=class extends nt{constructor(e,t,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new oM(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(`
28
- `))),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(Ge(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Wt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<zS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
29
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===zS+1&&(this._liveRegion.textContent+=Hp.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 r=this._terminal.buffer,s=r.lines.length.toString();for(let o=e;o<=t;o++){let c=r.lines.get(r.ydisp+o),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(r.ydisp+o+1).toString(),f=this._rowElements[o];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,h)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=r.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==s)return;let h,p;if(t===0?(h=r,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=r,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),p.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},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let o=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let S=g<y.length?y[g]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=o(t),h=o(r);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.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,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};rh=ti([Me(1,pg),Me(2,Gr),Me(3,Zr)],rh);var ym=class extends nt{constructor(e,t,r,s,o){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ee),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ee),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Wt(()=>{wa(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(Ge(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ge(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ge(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ge(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 r=e.composedPath();for(let s=0;s<r.length;s++){let o=r[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(s,h),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let c=0;c<o.length;c++){let h=o[c],p=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let f=p;f<=g;f++){if(r.has(f)){o.splice(c--,1);break}r.add(f)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(r=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){r=!0,this._handleNewLink(h);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&cM(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,wa(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:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let s=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,r){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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,r){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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return r<=o&&o<=s}_positionFromMouseEvent(e,t,r){let s=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,s,o){return{x1:e,y1:t,x2:r,y2:s,cols:this._bufferService.cols,fg:o}}};ym=ti([Me(1,mg),Me(2,Zr),Me(3,sn),Me(4,xw)],ym);function cM(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 uM=class extends tM{constructor(e={}){super(e),this._linkifier=this._register(new Sl),this.browser=Ww,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sl),this._onCursorMove=this._register(new Ee),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ee),this.onKey=this._onKey.event,this._onRender=this._register(new Ee),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ee),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ee),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ee),this.onBell=this._onBell.event,this._onFocus=this._register(new Ee),this._onBlur=this._register(new Ee),this._onA11yCharEmitter=this._register(new Ee),this._onA11yTabEmitter=this._register(new Ee),this._onWillOpen=this._register(new Ee),this._setup(),this._decorationService=this._instantiationService.createInstance(sM),this._instantiationService.setService(uc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(JD),this._instantiationService.setService(xw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Up)),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(Vi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Vi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Vi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Vi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Wt(()=>{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 r,s="";switch(t.index){case 256:r="foreground",s="10";break;case 257:r="background",s="11";break;case 258:r="cursor",s="12";break;default:r="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Pt.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${de.ESC}]${s};${XR(o)}${Iw.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=vi.toColor(...t.color));else{let c=r;this._themeService.modifyColors(h=>h[c]=vi.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(rh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(de.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(de.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 r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(r),c=this._renderService.dimensions.css.cell.width*o,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ge(this.element,"copy",t=>{this.hasSelection()&&pT(t,this._selectionService)}));let e=t=>mT(t,this.textarea,this.coreService,this.optionsService);this._register(Ge(this.textarea,"paste",e)),this._register(Ge(this.element,"paste",e)),Fw?this._register(Ge(this.element,"mousedown",t=>{t.button===2&&$b(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ge(this.element,"contextmenu",t=>{$b(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Cg&&this._register(Ge(this.element,"auxclick",t=>{t.button===1&&mw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ge(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ge(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ge(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ge(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ge(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ge(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ge(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(Ge(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 r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",jp.get()),Vw||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(ZD,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Gr,this._coreBrowserService),this._register(Ge(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ge(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(lm,this._document,this._helperContainer),this._instantiationService.setService(wh,this._charSizeService),this._themeService=this._instantiationService.createInstance(hm),this._instantiationService.setService(Tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(th),this._instantiationService.setService(Cw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(cm,this.rows,this.screenElement)),this._instantiationService.setService(Zr,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(rm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(om),this._instantiationService.setService(mg,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(ym,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(im,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(um,this.element,this.screenElement,s)),this._instantiationService.setService(CT,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(Vi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(nm,this.screenElement)),this._register(Ge(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(rh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(eh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(eh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(am,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let p,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,p=c.button<3?c.button:3;break;case"mousedown":g=1,p=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,p=4;break;default:return!1}return g===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:p,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(r(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(r(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&r(c)},mousemove:c=>{c.buttons||r(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ge(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return r(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Ge(t,"wheel",c=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let h=de.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!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){pw(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,r){this._selectionService.setSelection(e,t,r)}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 r=nM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let s=this.rows-1;return this.scrollLines(r.type===2?-s:s),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===de.ETX||r.key===de.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(hM(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(_i));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(de.ESC+"[I"):this.coreService.triggerDataEvent(de.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[4;${r};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function hM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var dM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},fM=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 Zn)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},jS=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 fM(t)}getNullCell(){return new Zn}},pM=class extends nt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ee),this.onBufferChange=this._onBufferChange.event,this._normal=new jS(this._core.buffers.normal,"normal"),this._alternate=new jS(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)}},mM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,s)=>t(r,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},gM=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}},_M=["cols","rows"],br=0,vM=class extends nt{constructor(e){super(),this._core=this._register(new uM(e)),this._addonManager=this._register(new dM),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],r=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(_M.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 mM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new gM(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 pM(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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}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
30
- `,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 jp.get()},set promptLabel(e){jp.set(e)},get tooMuchOutput(){return Hp.get()},set tooMuchOutput(e){Hp.set(e)}}}_verifyIntegers(...e){for(br of e)if(br===1/0||isNaN(br)||br%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(br of e)if(br&&(br===1/0||isNaN(br)||br%1!==0||br<0))throw new Error("This API only accepts positive integers")}};class yM{pending=null;accept(t){let r="";for(const s of t)r+=this.acceptChar(s);return r}acceptChar(t){return t===""?this.acceptBackspace():a1.has(t)?this.acceptConsonant(t):l1.has(t)?this.acceptVowel(t):CM(t)&&this.canReplacePendingWith(t)?(this.pending=PS(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(o1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const r=wM.get(`${this.pending.final}${t}`);if(r)return this.pending.final=r,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=SM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const r=HS.get(this.pending.final);if(r){this.pending.final=r[0];const c=this.flushPending();return this.pending={initial:r[1],vowel:t},c}const s=this.pending.final,o=US({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=HS.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 r=PS(t);return r.initial===this.pending.initial&&(!this.pending.vowel||r.vowel===this.pending.vowel)&&(!this.pending.final||r.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=US(this.pending);return this.pending=null,t}}const sh=44032,ah=21,fl=28,bM=19*ah*fl,n1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],r1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],s1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],a1=xg(n1),l1=xg(r1),o1=xg(s1),SM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),c1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],wM=new Map(c1),HS=new Map(c1.map(([e,t])=>[t,[e[0],e[1]]]));function xg(e){return new Map(e.map((t,r)=>[t,r]))}function CM(e){const t=e.codePointAt(0);return t!==void 0&&t>=sh&&t<sh+bM}function PS(e){const t=e.codePointAt(0)-sh,r=Math.floor(t/(ah*fl)),s=Math.floor(t%(ah*fl)/fl),o=t%fl,c={initial:n1[r],vowel:r1[s]};return o===0?c:{...c,final:s1[o]}}function US(e){if(!e.vowel)return e.initial;const t=a1.get(e.initial),r=l1.get(e.vowel),s=e.final?o1.get(e.final):0;return t===void 0||r===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(sh+(t*ah+r)*fl+s)}const xM=[{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 EM({ctrlActive:e,onCtrl:t,onStandaloneKey:r,onPreserveFocus:s,onHide:o}){function c(h){h.preventDefault(),h.stopPropagation(),s()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.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"}),xM.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>r(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const kM={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function TM(e){return kM[e]}function DM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const u1="--nterminal-viewport-height",h1="--nterminal-keyboard-inset-bottom",d1="data-nterminal-keyboard-visible",Eh="data-nterminal-compose-open",lh="nterminal:viewport-refresh",RM=120;function MM(e=window){const t=e.document.documentElement,r=e.visualViewport,s=zM(e);function o(){Eg(e)}return o(),r?.addEventListener("resize",o),r?.addEventListener("scroll",o),s?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(lh,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{r?.removeEventListener("resize",o),r?.removeEventListener("scroll",o),s?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(lh,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(u1),t.style.removeProperty(h1),t.removeAttribute(d1)}}function Eg(e=window){const t=e.document.documentElement,{keyboardInsetBottom:r,keyboardVisible:s}=f1(e),o=NM(e,s);return o!==null&&IS(t,u1,`${o}px`),IS(t,h1,`${r}px`),AM(t,d1,String(s)),{viewportHeight:o,keyboardInsetBottom:r,keyboardVisible:s}}function f1(e=window){const t=LM(e);return{keyboardInsetBottom:t,keyboardVisible:t>RM}}function NM(e,t){if((e.document.documentElement.hasAttribute(Eh)||t)&&va(e.innerHeight))return e.innerHeight;const r=e.visualViewport?.height;return va(r)?r:va(e.innerHeight)?e.innerHeight:null}function va(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function IS(e,t,r){e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}function AM(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function LM(e){return Math.max(BM(e),OM(e))}function BM(e){const t=e.visualViewport?.height;if(!va(t)||!va(e.innerHeight))return 0;const r=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-r))}function OM(e){if(!va(e.innerHeight))return 0;const r=p1(e)?.boundingRect?.height;return!va(r)||r>=e.innerHeight*.8?0:Math.round(r)}function p1(e){return e.navigator.virtualKeyboard}function zM(e){const t=p1(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const fc=new Map,tc=new Map,jM=Object.freeze({open:!1,text:""});function HM(e){let t=tc.get(e);return t||(t=new Set,tc.set(e,t)),t}function m1(e){const t=tc.get(e);if(t)for(const r of Array.from(t))r()}function kg(e){return fc.get(e)??jM}function PM(e,t){const r=HM(e);return r.add(t),()=>{r.delete(t)}}function UM(e,t){const r=kg(e);r.open!==t&&(fc.set(e,{...r,open:t}),m1(e))}function IM(e,t){const r=kg(e);r.text!==t&&(fc.set(e,{...r,text:t}),m1(e))}function Ru(e){fc.delete(e),tc.delete(e)}function KS(){fc.clear(),tc.clear()}const g1=120,KM="\x1B[200~",WM="\x1B[201~";function WS(e,t){const r=t.stripTrailingLineBreaks===!1?e:Tg(e),s=qM(r);return s?t.bracketedPasteMode?`${KM}${s}${WM}`:s:""}function FM(e){return e==="queue"?" ":"\r"}function Tg(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function qM(e){return e.replace(/\r\n/g,`
31
- `).replace(/\r/g,`
32
- `).replace(/\n/g,"\r")}const $M=420,VM=3e3,FS=650,YM=80,XM=3,Uu=new Set;let _l=null;function GM({terminalId:e,onSubmit:t,queueAvailable:r=!1,disabled:s=!1}){const o=v.useMemo(()=>A=>PM(e,A),[e]),c=v.useMemo(()=>()=>kg(e),[e]),h=v.useSyncExternalStore(o,c,c),{open:p,text:g}=h,f=v.useRef(null),b=v.useRef(null),y=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!p||!Iu()))return QM(e),()=>JM(e)},[p,e]),v.useLayoutEffect(()=>{const A=f.current?.closest(".terminal-pane");if(!A)return;function W(){A?.removeAttribute("data-compose-open"),A?.style.removeProperty("--compose-drawer-panel-height")}if(!p){W();return}const K=b.current;A.setAttribute("data-compose-open","true");function J(){const ve=K?.getBoundingClientRect().height??0;ve>0&&A?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}J();const ne=[window.setTimeout(J,0),window.setTimeout(J,180),window.setTimeout(J,260)],le=window.requestAnimationFrame?.(J)??null,oe=typeof ResizeObserver=="function"&&K?new ResizeObserver(J):null;return oe&&K&&oe.observe(K),()=>{for(const ve of ne)window.clearTimeout(ve);le!==null&&window.cancelAnimationFrame?.(le),oe?.disconnect(),W()}},[p]),v.useEffect(()=>{if(!p){S.current?.(),S.current=null;return}qS(y.current),L()},[p]);function w(A){UM(e,A)}function k(A){IM(e,A)}function T(){ZM(f.current),w(!1),$S()}function B(A="send"){if(!(s||!g)){if(t(g,A),k(""),Iu()){y.current?.blur(),$S();return}window.setTimeout(()=>y.current?.focus(),g1+20)}}function L(){Iu()&&(S.current?.(),S.current=eN())}return m.jsxs("div",{ref:f,className:"compose-drawer","data-open":p?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":p?"true":void 0,tabIndex:p?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:b,className:"compose-drawer-panel","aria-hidden":p?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:p?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:T,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:r?"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"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:y,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:p?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:A=>k(A.target.value),onFocus:L,onKeyDown:A=>{if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)){if(A.preventDefault(),A.shiftKey){r&&B("queue");return}B("send");return}A.key==="Escape"&&(A.preventDefault(),T())},placeholder:r?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:p?0:-1,onClick:()=>{k(""),qS(y.current),L()},disabled:!g,children:"Clear"}),r?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:p?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>B("queue"),disabled:s||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:p?0:-1,onClick:()=>B("send"),disabled:s||!g,children:"Send"})]})]})]})}function ZM(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function qS(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Iu(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function $S(){if(!Iu())return;const e=pl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function QM(e){_l!==null&&(window.clearTimeout(_l),_l=null),Uu.add(e),document.documentElement.setAttribute(Eh,"true"),pl()}function JM(e){if(Uu.delete(e),Uu.size>0||_l!==null){pl();return}_l=window.setTimeout(()=>{if(_l=null,Uu.size>0){pl();return}document.documentElement.removeAttribute(Eh),pl()},$M),pl()}function eN(){let e=!1,t=null,r=null,s=null,o=0;const c=Date.now(),h=window.visualViewport,p=tN();function g(){t!==null&&(window.clearTimeout(t),t=null),r!==null&&(window.cancelAnimationFrame?.(r),r=null)}function f(){e||(e=!0,g(),h?.removeEventListener("resize",y),h?.removeEventListener("scroll",y),p?.removeEventListener("geometrychange",y))}function b(S){if(!e){if(S<FS&&typeof window.requestAnimationFrame=="function"){r=window.requestAnimationFrame(y);return}t=window.setTimeout(y,YM)}}function y(){if(e)return;g();const S=Eg(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?o+=1:(o=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=VM||w>=FS&&o>=XM){f();return}b(w)}return h?.addEventListener("resize",y),h?.addEventListener("scroll",y),p?.addEventListener("geometrychange",y),y(),f}function pl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Eg()}function tN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function iN(e,t){e.attachCustomKeyEventHandler(c=>{if(nN(c)){const h=VS(e);return h?(c.preventDefault(),c.stopPropagation(),YS(h),!1):!0}return rN(c)?(c.preventDefault(),c.stopPropagation(),sN(e,t),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const s=c=>{const h=VS(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),YS(h)}},o=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const p=Tg(h);c.preventDefault(),c.stopImmediatePropagation(),_1(e,p,t)};return r.addEventListener("copy",s,!0),r.addEventListener("paste",o,!0),{dispose(){r.removeEventListener("copy",s,!0),r.removeEventListener("paste",o,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function nN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function rN(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 sN(e,t){if(navigator.clipboard?.readText)try{const r=await navigator.clipboard.readText();if(!r)return;_1(e,Tg(r),t)}catch{}}function _1(e,t,r){if(t){if(r){r(t);return}e.paste(t)}}function VS(e){return e.hasSelection()?e.getSelection():""}async function YS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}aN(e)}function aN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",r.style.opacity="0",document.body.appendChild(r),r.focus({preventScroll:!0}),r.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{r.remove(),t?.focus({preventScroll:!0})}}const lN=[4,10,11,12];function oN(e,t){const r=[e.parser.registerCsiHandler({final:"c"},s=>XS(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>XS(s)),e.parser.registerCsiHandler({final:"n"},s=>cN(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>uN(s)),e.parser.registerCsiHandler({final:"t"},s=>hN(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...lN.map(s=>e.parser.registerOscHandler(s,o=>dN(o)))];return{dispose(){for(const s of r)s.dispose()}}}function XS(e){return kh(e)===0}function cN(e){const t=kh(e);return t===5||t===6}function uN(e){return kh(e)===6}function hN(e){const t=kh(e);return t===14||t===16||t===18}function dN(e){return e.split(";").some(t=>t==="?")}function kh(e){const t=e[0];return typeof t=="number"?t:0}const xa=new Map,fN=2*1024*1024,pN=1500,mN=25e3;function gN(e,t){let r=xa.get(e);r||(r=yN(e),xa.set(e,r),Th(r)),r.listeners.add(t);const s=c=>EN(r,c),o=()=>{r.listeners.delete(t)};return{status:r.status,snapshot:r.snapshot,output:r.output.slice(),history:r.history,send:s,detach:o}}function jo(e){const t=xa.get(e);t&&(kN(t),xa.delete(e))}function _N(e,t={}){const r=xa.get(e);if(!r)return!1;r.exited=!1,r.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(r.preserveCachedOutputOnNextSnapshot=!0),r.reconnectTimer!==null&&(window.clearTimeout(r.reconnectTimer),r.reconnectTimer=null),pc(r);const s=r.socket;return r.socket=null,fa(r,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),Th(r),!0}function vN(){for(const e of xa.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),pc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,fa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Th(e)}}function rp(){for(const e of Array.from(xa.keys()))jo(e)}function yN(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function Th(e){if(!e.reconnectEnabled)return;fa(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){fa(e,"connected");for(const r of e.pendingOut)t.send(JSON.stringify(r));e.pendingOut.length=0,e.isAlive=!0,bN(e)}}),t.addEventListener("message",r=>{if(e.socket!==t)return;const s=typeof r.data=="string"?r.data:"";if(!s)return;let o=null;try{o=JSON.parse(s)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;return}const c=wN(e,o);v1(e,{type:"message",message:c})}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,pc(e),r.code===1008){e.reconnectEnabled=!1,fa(e,SN(r.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){fa(e,"closed");return}fa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Th(e)},pN)}}),t.addEventListener("error",()=>{})}function bN(e){pc(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},mN)}function pc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function SN(e){return e.trim().toLowerCase()==="unauthorized"}function wN(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,CN(e,t.output),sp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((r,s)=>r+s.length,0),sp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,sp(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function CN(e,t){const r=xN(e.output,t);if(r===0)return;const s=t.slice(r);for(const o of s)e.output.push(o),e.outputBytes+=o.length}function xN(e,t){const r=Math.min(e.length,t.length);for(let s=r;s>0;s-=1){let o=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){o=!1;break}if(o)return s}return 0}function sp(e){for(;e.outputBytes>fN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function fa(e,t){e.status!==t&&(e.status=t,v1(e,{type:"status",status:t}))}function v1(e,t){for(const r of Array.from(e.listeners))r(t)}function EN(e,t){const r=e.socket;return r&&r.readyState===WebSocket.OPEN?(r.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function kN(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),pc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const TN=[0,50,150,350],DN=2,RN=[300,1200,2500],MN=1e3,NN=1e5,bm="\x1B[?1049l\x1B[?1047l\x1B[?47l",AN=new Set(["47","1047","1049"]),LN=400,BN=3,ON=3,zN=32,jN=1.42,HN=2,PN=24,UN=240,IN=60,KN=420,WN=6,FN=2,GS=[500,1500,3e3,5e3,8e3],ZS=15e3,qN=Ti.lazy(()=>fg(()=>import("./TranscriptMarkdownBody-Ct0CseQH.js"),__vite__mapDeps([2,1])));function QS({terminal:e,serverApi:t,active:r,visible:s=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:b,onAuthClose:y}){const S=v.useSyncExternalStore(tw,Mp,()=>ga),w=v.useSyncExternalStore(iw,Np,()=>yl),k=v.useSyncExternalStore(nw,Lp,()=>!0),T=v.useSyncExternalStore(Wm,zs,()=>vl),B=v.useSyncExternalStore(lg,()=>og("history.toggle"),()=>"Alt+H"),L=v.useRef(null),A=v.useRef(null),W=v.useRef(null),K=v.useRef(null),J=v.useRef({onExit:f,onSnapshot:b}),ne=v.useRef(t.createWebSocketUrl),le=v.useRef(y),oe=v.useRef(null),ve=v.useRef(null),P=v.useRef(null),I=v.useRef(!1),F=v.useRef(new Map),H=v.useRef([]),j=v.useRef([]),re=v.useRef([]),M=v.useRef(0),V=v.useRef(!1),Z=v.useRef(null),Ce=v.useRef(0),ke=v.useRef(null),R=v.useRef(null),G=v.useRef(!1),se=v.useRef(!1),_e=v.useRef(!1),fe=v.useRef(!1),we=v.useRef(null),Ne=v.useRef(null),je=v.useRef(!1),Ve=v.useRef(!1),ee=v.useRef(!1),me=v.useRef(!1),De=v.useRef(!1),be=v.useRef(!1),Re=v.useRef(!1),ze=v.useRef(r),Ke=v.useRef(s),ce=v.useRef(c),xe=v.useRef(S),Le=v.useRef(w),Ae=v.useRef(!1),Ie=v.useRef(null),Y=v.useRef(null),Te=v.useRef(!1),He=v.useRef(null),[,vt]=v.useState("connecting"),[yi,Ri]=v.useState(!1),[ge,We]=v.useState(null),[dt,rt]=v.useState(!1),[Ft,zt]=v.useState(null),[ii,qt]=v.useState(!1),[gt,Yi]=v.useState(!1),[gn,Qn]=v.useState(!1),[Mt,Ii]=v.useState(null),[yt,bt]=v.useState(!1),Et=!!Mt||Ku(e.currentCommand),[Mi,ui]=v.useState(!1);v.useLayoutEffect(()=>{ze.current=r},[r]),v.useLayoutEffect(()=>{Ke.current=s},[s]),v.useLayoutEffect(()=>{ce.current=c},[c]),v.useLayoutEffect(()=>{xe.current=S},[S]),v.useLayoutEffect(()=>{Le.current=w},[w]),v.useLayoutEffect(()=>{Ae.current=yt},[yt]),v.useLayoutEffect(()=>{Ie.current=Mt},[Mt]),v.useLayoutEffect(()=>{Te.current=Et},[Et]),v.useEffect(()=>{s&&r&&e.status==="running"&&(Bt(),Zi())},[r,s,e.status]),v.useEffect(()=>{J.current={onExit:f,onSnapshot:b}},[f,b]),v.useEffect(()=>{ne.current=t.createWebSocketUrl,le.current=y},[t,y]),v.useEffect(()=>{let D=!1,te=null,Ue=0;const $e=f3(e.currentCommand),Ye=Ku(e.currentCommand);function tt(){te!==null&&(window.clearTimeout(te),te=null)}function It(St){if(D)return;let wt;if(St){if(!Ye)return;wt=ZS}else if(Ue<GS.length){if(!$e)return;wt=GS[Ue++]}else{if(!Ye)return;wt=ZS}te=window.setTimeout(()=>{te=null,si()},wt)}async function si(){try{const St=await t.getTerminalTranscriptSource(e.id);if(D)return;Ii(wt=>wt&&St.source&&wt.provider===St.source.provider&&wt.sessionId===St.source.sessionId?wt:St.source),It(!!St.source)}catch(St){if(D)return;ap(St)&&Ii(null),It(!1)}}return Ii(null),e.status!=="running"?()=>{D=!0,tt()}:(si(),()=>{D=!0,tt()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const D=Mt?`${e.id}:${Mt.provider}:${Mt.sessionId}`:null,te=Y.current;te!==null&&D!==null&&te!==D&&Ae.current&&bt(!1),Y.current=D},[e.id,Mt?.provider,Mt?.sessionId]),v.useEffect(()=>{function D(te){!ze.current||!Ke.current||!Ie.current||te.isComposing||te.key==="Process"||YN(te.target)||rw(te)?.id!=="history.toggle"||(te.preventDefault(),te.stopPropagation(),bt($e=>!$e))}return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[]),v.useEffect(()=>{const D=A.current;D&&(D.options.disableStdin=e.status==="exited"),e.status==="exited"&&vt("closed")},[e.status]),v.useEffect(()=>{const D=A.current;D&&(D.options.fontSize=S,If(S,Le.current).then(()=>{xe.current===S&&Bt()}))},[S]),v.useEffect(()=>{const D=A.current;D&&(D.options.fontFamily=Rp(w),If(xe.current,w).then(()=>{Le.current===w&&Bt()}))},[w]),v.useEffect(()=>{const D=A.current;D&&(D.options.theme=JS(T))},[T]),v.useEffect(()=>{const D=L.current;if(!D)return;let te=!1,Ue=null,$e=null,Ye=null,tt=null,It=null,si=null,St=null;oe.current=null,De.current=!1,be.current=!1,fe.current=!1,Jn(),hi();const wt=xe.current,Ki=Le.current,Gt=new vM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Rp(Ki),fontSize:wt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:NN,theme:{...JS(zs())}}),Sn=new cT;return Gt.loadAddon(Sn),tt=oN(Gt),A.current=Gt,W.current=Sn,If(wt,Ki).then(()=>{if(te)return;Gt.open(D),De.current=!0,Ue=iN(Gt,pr),Ke.current&&ze.current&&e.status==="running"&&Zi(),Bt(),It=w3(D,Gt,()=>xe.current*1.2,Ot,E=>{Si(E)},st,ir),si=y3(D,Gt,Ot,E=>{Si(E)},st,ir);const x=new yM;$e=Gt.onData(E=>{if(Re.current){const ie=DM(E);if(ie){Tr(!1),nr(ie);return}}const z=x.accept(E);z&&nr(z)}),Ye=Gt.onScroll(E=>{if(Ve.current||me.current||ee.current){di();return}er(),lr(Gt)&&tr({scrollToBottom:!0}),Ot(),E<=3&&Si()}),St=new ResizeObserver(()=>{$t()}),St.observe(D),be.current&&(Ni(),be.current=!1,Bt()),zn()}),()=>{te=!0,De.current=!1,be.current=!1,Jn(),ve.current=null,P.current=null,I.current=!1,yn(),bn(),ee.current=!1,It?.(),si?.(),St?.disconnect(),Ue?.dispose(),$e?.dispose(),Ye?.dispose(),tt?.dispose(),Gt.dispose(),A.current=null,W.current=null}},[e.id]),v.useEffect(()=>{const D=ne.current(e.id),te=gN(D,Xt);return K.current=te.send,vt(te.status),te.status==="connected"&&Bt(),te.snapshot&&(J.current.onSnapshot(te.snapshot,{notifyCompletion:!1}),A.current&&(Bt(),bi(te.output,te.history),Bt())),()=>{te.detach(),K.current=null}},[e.id,e.status]);function Xt(D){if(D.type==="status"){vt(D.status),D.status==="unauthorized"&&le.current?.({source:"terminal-ws-1008",terminalId:e.id}),D.status==="connected"&&Bt();return}vn(D.message)}function hi(D=[],te=null){j.current=[],re.current=Mu(D),M.current=0,V.current=!1,Z.current=null,ee.current=!1,Ce.current+=1,ke.current=te,R.current=null,G.current=!1,se.current=!1,_e.current=!1,be.current=!1,He.current=null,we.current=null,je.current=!1,Ri(!1),We(null),rt(!1),zt(null),qt(!1),Yi(!1)}function bi(D=[],te=null){hi(D,te),Ut()}function Ut(){if(!A.current||!De.current){be.current=!0;return}be.current=!1,Ni()}async function Ni(){const D=A.current;if(!D)return;const te=Nu(D,je.current),Ue=te?re.current.length:M.current;await ni(D,{liveOutputLimit:Ue,scrollToBottom:te}),A.current===D&&di()}function ni(D,te={}){return new Promise(Ue=>{ee.current=!0,V.current=!1;const $e=Ce.current+1;Ce.current=$e;const Ye=Math.max(0,Math.min(te.liveOutputLimit??re.current.length,re.current.length)),tt=te.historyPages??j.current,It=()=>{if(A.current!==D||Ce.current!==$e){Ue(!1);return}try{M.current=Ye,te.scrollToBottom&&Er(D)}finally{ee.current=!1;const St=Ks();St?tr(St):te.applyDeferredSnapshot!==!1&&Jr(),Ue(!0)}},si=()=>{if(A.current!==D||Ce.current!==$e){Ue(!1);return}D.clear();const St=Mu([...tt,...re.current.slice(0,Ye)]);if(St.length===0){It();return}for(let wt=0;wt<St.length;wt+=1){const Ki=St[wt];wt===St.length-1?D.write(Ki,It):D.write(Ki)}};if(D.buffer.active.type==="alternate"){D.write(bm,si);return}si()})}async function Si(D=0){const te=A.current;if(_e.current||!te)return;if(hr(te)){di();return}const Ue=ke.current;_e.current=!0,Ri(!0);const $e=te.buffer.active.viewportY;try{let Ye=!!(Ue&&!Ue.hasMore);if(!Ye)try{const tt=await t.getTerminalHistory(e.id,{beforeLine:Ue?.startLine??0,limit:MN}),It={startLine:tt.startLine,endLine:tt.endLine,hasMore:tt.hasMore};if(tt.output.length>0){await en(te,tt.output,$e,D)&&(ke.current=It);return}ke.current=It,Ye=!tt.hasMore}catch(tt){Ye=ap(tt)}if(Ye){if(hr(te)){di();return}await _n(te,$e,D)}}catch{}finally{_e.current=!1,Ri(!1)}}async function _n(D,te,Ue){if(!(G.current||se.current))try{const $e=R.current,Ye=await t.getTerminalTranscriptHistory(e.id,{...$e?{cursor:$e}:{},limit:LN}),tt=Ye.output.map(S1);if(!Ye.source)return;if(tt.length===0){Ii(Ye.source),R.current=Ye.cursor,se.current=!Ye.hasMore||!Ye.cursor;return}await en(D,tt,te,Ue)&&(Ii(Ye.source),R.current=Ye.cursor,se.current=!Ye.hasMore||!Ye.cursor)}catch($e){ap($e)&&(G.current=!0)}}async function en(D,te,Ue,$e){if(hr(D))return di(),!1;const Ye=[...te,...j.current],tt=_3(te);return!await ni(D,{liveOutputLimit:M.current,scrollToBottom:!1,historyPages:Ye,applyDeferredSnapshot:!1})||A.current!==D?!1:(j.current=Ye,kr(D,Math.max(0,Ue+tt+Math.min(0,$e))),je.current=!lr(D),Ot(),!0)}v.useEffect(()=>{const D=window.visualViewport;function te(){document.visibilityState==="visible"&&Bt()}function Ue(){Bt()}function $e(){$t()}function Ye(){Ln()}return document.addEventListener("visibilitychange",te),window.addEventListener("pageshow",Ue),window.addEventListener("resize",$e),window.addEventListener(lh,Ye),D?.addEventListener("resize",$e),D?.addEventListener("scroll",$e),()=>{document.removeEventListener("visibilitychange",te),window.removeEventListener("pageshow",Ue),window.removeEventListener("resize",$e),window.removeEventListener(lh,Ye),D?.removeEventListener("resize",$e),D?.removeEventListener("scroll",$e)}},[e.id]);function tn(){const D=ne.current(e.id);fe.current=!0,He.current=null,vt("reconnecting"),Bt(),_N(D,{preserveCachedOutputOnNextSnapshot:!0})}function vn(D){if(D.type==="snapshot"&&D.terminal.id===e.id){J.current.onSnapshot(D.terminal,{notifyCompletion:!1});const Ue=A.current;if(!Ue)return;Bt();const $e=fe.current;if(fe.current=!1,$e){ke.current=D.history??ke.current,di(),Bt();return}if(dr(Ue,D.terminal)){ri(D.output,D.history??null),di(),Bt();return}bi(D.output,D.history??null),Bt();return}if(D.type==="terminal_updated"&&D.terminal.id===e.id){J.current.onSnapshot(D.terminal,{notifyCompletion:!0});return}if(D.type==="output"&&D.terminalId===e.id){const Ue=x1(D.data);if(!Ue)return;re.current.push(Ue),A.current&&De.current?tr({scrollToBottom:!0}):be.current=!0;return}const te=A.current;if(te){if(D.type==="exit"&&D.terminalId===e.id){J.current.onExit(D.exitCode),vt("closed");return}D.type==="error"&&te.writeln(`\r
33
- [nterminal] ${D.message}`)}}function Xi(D=25){if(document.visibilityState==="hidden"||!Ke.current||F.current.has(D))return;const te=window.setTimeout(()=>{F.current.delete(D),!wi()&&fr()},D);F.current.set(D,te)}function $t(){wi()||zn()}function wi(){const D=Qr();return D&&Is(D)?(I.current=!0,P.current=D,!0):D&&Nl(D)?(I.current=!1,P.current=null,!0):((!D||!D.composeOpen&&!D.keyboardVisible)&&(I.current=!1,P.current=null),!1)}function Ln(){if(!I.current)return;const D=Qr();D&&(D.composeOpen||D.keyboardVisible)||(I.current=!1,P.current=null)}function Is(D){if(!D.mobileLike||!D.composeOpen&&!D.keyboardVisible)return!1;const te=ve.current;return te?On(D.windowWidth,te.windowWidth)&&On(D.visualViewportWidth,te.visualViewportWidth)&&On(D.containerWidth,te.containerWidth):!1}function Nl(D){if(!D.mobileLike||D.composeOpen||D.keyboardVisible)return!1;const te=P.current;return!te||!te.composeOpen&&!te.keyboardVisible?!1:On(D.windowWidth,te.windowWidth)&&On(D.visualViewportWidth,te.visualViewportWidth)&&On(D.containerWidth,te.containerWidth)}function Qr(){const D=L.current;if(!D||D.isConnected===!1)return null;const te=D.getBoundingClientRect(),Ue=Bn(window.innerWidth)??0,$e=Bn(window.visualViewport?.width)??Ue,Ye=Bn(te.width)??Bn(D.clientWidth)??Ue;if(Ue<=0||$e<=0||Ye<=0)return null;const{keyboardVisible:tt}=f1(),It=document.documentElement.hasAttribute(Eh),si=Da()||tt;return{windowWidth:Ue,visualViewportWidth:$e,containerWidth:Ye,composeOpen:It,keyboardVisible:tt,mobileLike:si}}function Da(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Bn(D){return typeof D=="number"&&Number.isFinite(D)&&D>0?D:null}function On(D,te){return Math.abs(D-te)<=DN}function zn(){for(const D of TN)Xi(D)}function Bt(){oe.current=null,zn()}function Jn(){for(const D of F.current.values())window.clearTimeout(D);F.current.clear()}function yn(){for(const D of H.current)window.clearTimeout(D);H.current=[]}function Ot(){if(di(),!we.current){rt(!1);return}rt(!0),bn(),Ne.current=window.setTimeout(()=>{Ne.current=null,rt(!1)},1200)}function di(){const D=A.current,te=D?v3(D):null;if(we.current=te,We(te),Yi(!!(D&&te)),qt(!!(D&&te&&!lr(D))),te||!D||!Ra()){zt(null);return}zt({alternate:D.buffer.active.type==="alternate"})}function Ra(){const D=ke.current;return j.current.length>0||!!D?.hasMore}function bn(){Ne.current!==null&&(window.clearTimeout(Ne.current),Ne.current=null)}function er(){const D=A.current;D&&(je.current=!lr(D),di())}function Ma(D){Z.current=lp(Z.current,D)}function Na(D){const te=Z.current;return Z.current=null,lp(te,D)}function Ks(){const D=Z.current;return Z.current=null,D}function tr(D={}){const te=A.current;if(!te||!De.current){be.current=!0;return}if(ee.current){Ma(D);return}if(V.current){Ma(D);return}const Ue=Na(D);if(!Ue.force&&!Nu(te,je.current)){di();return}V.current=!0;const $e=Ce.current,Ye=()=>{if(A.current!==te||Ce.current!==$e){V.current=!1;return}if(!Ue.force&&!Nu(te,je.current)){V.current=!1,di();return}const tt=M.current,It=re.current[tt];if(It===void 0){V.current=!1,Ue.scrollToBottom&&Er(te),di();const si=Ks();si?tr(lp(Ue,si)):Jr();return}te.write(It,()=>{if(A.current!==te||Ce.current!==$e){V.current=!1;return}M.current=tt+1,Ye()})};Ye()}function hr(D){return!lr(D)&&(ln()||V.current||ee.current)}function dr(D,te){return(Te.current||Ku(te?.currentCommand))&&!lr(D)}function ln(){return M.current<re.current.length}function ri(D,te){He.current={output:D,history:te,appendFromLiveOutputIndex:M.current}}function Jr(){const D=A.current,te=He.current;if(!D||!te||!lr(D)||ln()||V.current||ee.current)return;const Ue=Mu(te.output),$e=Mu(re.current.slice(te.appendFromLiveOutputIndex));He.current=null,bi(g3(Ue,$e),te.history),Bt()}function st(){me.current=!0}function ir(){er(),me.current=!1;const D=A.current;D&&lr(D)&&tr({scrollToBottom:!0})}function Er(D){Ws(()=>r0(D))&&(je.current=!1)}function kr(D,te){Ws(()=>(D.scrollToLine(te),!0))}function Ws(D){Ve.current=!0;try{return D()}finally{Ve.current=!1}}function Gi(){const D=A.current;if(!D)return;const te=()=>{r0(D),je.current=!1,di(),tr({force:!0,scrollToBottom:!0}),Zi()};if(D.buffer.active.type==="alternate"){D.write(bm,te);return}te()}function es(D){const te=A.current,Ue=L.current;if(!te||!Ue)return;const $e=Ue.getBoundingClientRect();if($e.height<=0)return;const Ye=Math.max(0,Math.min(1,(D-$e.top)/$e.height)),tt=Math.round(te.buffer.active.baseY*Ye);st();try{te.scrollToLine(tt)}finally{ir()}je.current=!lr(te),di(),Ot(),tt<=3&&Si()}function Fs(D){D.preventDefault(),D.stopPropagation(),D.currentTarget.setPointerCapture?.(D.pointerId),es(D.clientY)}function qs(D){(D.buttons&1)!==0&&(D.preventDefault(),D.stopPropagation(),es(D.clientY))}function fr(){const D=A.current,te=W.current;if(!(!D||!te)&&!(document.visibilityState==="hidden"||!Ke.current||L.current?.isConnected===!1))try{const Ue=Nu(D,je.current),$e=Qr();te.fit(),$e&&(ve.current=$e),Ue&&Er(D),D.refresh(0,Math.max(0,D.rows-1)),di();const Ye={cols:D.cols,rows:D.rows},tt=oe.current;if(tt&&tt.cols===Ye.cols&&tt.rows===Ye.rows)return;ts({type:"resize",terminalId:e.id,cols:Ye.cols,rows:Ye.rows})&&(oe.current=Ye)}catch{}}function ts(D){const te=K.current;return te?te(D):!1}function nr(D){tr({force:!0,scrollToBottom:!0}),ts({type:"input",terminalId:e.id,data:D})&&h3(D)&&Aa()}function pr(D){const te=WS(D,{bracketedPasteMode:A.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});te&&nr(te)}function Al(D,te){const Ue=WS(D,{bracketedPasteMode:A.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ue&&nr(Ue),window.setTimeout(()=>nr(FM(te)),g1)}function Aa(){!ce.current||!ze.current||(yn(),H.current=RN.map(D=>{const te=window.setTimeout(()=>{H.current=H.current.filter(Ue=>Ue!==te),ce.current&&ze.current&&ts({type:"refresh_cwd",terminalId:e.id})},D);return te}))}function Zi(){Ae.current||A.current?.focus()}const is=v.useCallback(()=>{bt(!1)},[]);function jn(){Qn(D=>{const te=!D;return Re.current=te,te}),Zi()}function Tr(D){Re.current=D,Qn(D)}function Dr(D){Re.current&&Tr(!1),nr(TM(D)),Zi()}return m.jsxs("section",{className:"terminal-pane","data-active":r,onMouseDown:()=>{r||p()},children:[m.jsx(XN,{terminal:e,canClose:o,tabId:h,transcriptSource:Mt,transcriptShortcutLabel:B,onOpenTranscript:()=>bt(!0),onReload:tn,onClose:g}),m.jsx("div",{className:"xterm-container",ref:L}),yi?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,k&&ge?m.jsxs("div",{className:"terminal-scroll-progress","data-active":dt,"aria-hidden":"true",children:[ge.current,"/",ge.total]}):k&&Ft?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ft.alternate?"alternate":"normal","aria-hidden":"true",children:[Ft.alternate?"alt ":"","0/?"]}):null,ii?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),Gi()},children:"↓"}):null,gt?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Fs,onPointerMove:qs,children:m.jsx("span",{"aria-hidden":"true"})}):null,r&&e.status==="running"?Mi?m.jsx(EM,{ctrlActive:gn,onCtrl:jn,onStandaloneKey:Dr,onPreserveFocus:Zi,onHide:()=>ui(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:D=>{D.stopPropagation(),Zi()},onPointerDown:D=>{D.stopPropagation(),Zi()},onClick:()=>ui(!0),children:"⌨"}):null,m.jsx(GM,{terminalId:e.id,onSubmit:Al,queueAvailable:Mt?.provider==="codex"||b1(e.currentCommand),disabled:e.status!=="running"}),yt&&Mt?m.jsx(GN,{terminalId:e.id,serverApi:t,source:Mt,fontSize:S,onClose:is}):null]})}function JS(e){return _E(e)}function $N(e,t,r){const s=VN(e,t),o=e0(s*Math.max(1,r),IN,KN);return{limit:e0(Math.ceil(o/HN),PN,UN),maxLines:o}}function VN(e,t){const r=e?.clientHeight??0;if(r<=0)return zN;const s=Math.max(10,t*jN);return Math.max(1,Math.floor(r/s))}function e0(e,t,r){return Math.max(t,Math.min(r,Math.floor(e)))}function YN(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function XN({terminal:e,canClose:t,tabId:r,transcriptSource:s,transcriptShortcutLabel:o,onOpenTranscript:c,onReload:h,onClose:p}){const g=K0({id:`pane-${e.id}`,disabled:!r,...r?{data:{kind:"pane",sourceTabId:r,terminalId:e.id}}:{}}),f={cursor:r?"grab":"default",opacity:g.isDragging?.5:void 0};return m.jsxs("header",{ref:g.setNodeRef,className:"terminal-pane-header",style:f,"data-dragging":g.isDragging,...g.attributes,...g.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),s?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${oh(s.provider)} transcript history`,"aria-label":`View ${oh(s.provider)} transcript history`,onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),c()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:o})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),h()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),p()},children:"x"}):null]})}const GN=Ti.memo(function({terminalId:t,serverApi:r,source:s,fontSize:o,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),S=v.useRef(null),w=v.useRef(null),[k,T]=v.useState([]),[B,L]=v.useState(!1),[A,W]=v.useState(""),[K,J]=v.useState(-1),[ne,le]=v.useState(!1),[oe,ve]=v.useState(-1),[P,I]=v.useState(null),[F,H]=v.useState(null),[j,re]=v.useState(!1),[M,V]=v.useState(!0),[Z,Ce]=v.useState(!1),[ke,R]=v.useState(null);v.useEffect(()=>{function ge(We){We.key==="Escape"&&(We.preventDefault(),We.stopPropagation(),c())}return document.addEventListener("keydown",ge,!0),()=>document.removeEventListener("keydown",ge,!0)},[c]),v.useEffect(()=>{p.current+=1;const ge=p.current;return g.current=!1,f.current=!0,b.current=null,S.current=null,w.current=null,T([]),H(null),re(!1),R(null),J(-1),ve(-1),I(null),Ae(null,"initial",ge),()=>{p.current===ge&&(p.current+=1)}},[r,B,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const ge=h.current;if(!ge)return;if(f.current){if(M||k.length===0)return;f.current=!1;const dt=()=>{ge.scrollTop=ge.scrollHeight};dt(),window.requestAnimationFrame?.(dt);return}const We=b.current;We!==null&&(b.current=null,ge.scrollTop+=ge.scrollHeight-We)},[k,M,B]);const G=oh(s.provider),se=n0(k,B),_e=JN(se),fe=n3(_e),we=fe.map(ge=>ge.key).join(""),Ne=P?fe.find(ge=>ge.key===P)?.entryIndex??null:null,je=A.trim().length>0,Ve=i3(_e,A),ee=Ve.length,me=ee>0?K>=0&&K<ee?K:0:-1,De=me>=0?Ve[me]?.entryIndex??null:null,be=me>=0?Ve[me]??null:null,Re=je?De:Ne,ze=je?De===null?null:"search":Ne===null?null:"prompt",Ke=se?se.split(`
34
- `).length-1:0,ce=fe.length>0&&oe>=0&&oe<fe.length?oe:fe.length-1,xe=P??(ce>=0?fe[ce]?.key??null:null),Le=je?ee>0?`${me+1}/${ee} ${ee===1?"match":"matches"} · ${Ke} ${Ke===1?"line":"lines"}`:`0 matches · ${Ke} ${Ke===1?"line":"lines"}`:fe.length>0?`${ce+1}/${fe.length} prompts · ${Ke} ${Ke===1?"line":"lines"}`:`0 prompts · ${Ke} ${Ke===1?"line":"lines"}`;v.useEffect(()=>{const ge=A.trim().toLowerCase();J(We=>!ge||ee===0?-1:y.current!==ge?0:We>=0&&We<ee?We:0),y.current=ge},[A,ee]),v.useEffect(()=>{if(je){I(null);return}P&&!fe.some(ge=>ge.key===P)&&I(null),ve(ge=>{if(fe.length===0)return w.current=null,-1;const We=w.current?fe.findIndex(rt=>rt.key===w.current):-1,dt=We>=0?We:ge>=0&&ge<fe.length?ge:fe.length-1;return w.current=fe[dt]?.key??null,dt})},[P,je,we]),v.useEffect(()=>{const ge=S.current;if(!ge||fe.length===0)return;S.current=null;const We=ge.anchorKey?fe.findIndex(rt=>rt.key===ge.anchorKey):-1,dt=We>0?We-1:0;vt(dt)},[we]);async function Ae(ge,We,dt=p.current){if(!g.current){g.current=!0,We==="initial"?V(!0):(Ce(!0),b.current=h.current?.scrollHeight??null),R(null);try{await Ie(ge,We,dt)}catch(rt){if(p.current!==dt)return;R(rt instanceof Error?rt.message:"Failed to load transcript history.")}finally{p.current===dt&&(g.current=!1,V(!1),Ce(!1))}}}async function Ie(ge,We,dt){let rt=ge,Ft=0,zt=[];const ii=We==="initial"&&s.provider!=="claude"?FN:WN;for(;p.current===dt;){const qt=await r.getTerminalTranscriptHistory(t,{...rt?{cursor:rt}:{},...$N(h.current,o,We==="initial"?BN:ON),includeTools:B});if(p.current!==dt)return;const gt=i0(qt.output,s.provider,{includeTools:B}),Yi=Y(qt,We,zt,gt);if(gt&&(zt=[gt,...zt],Yi))return;if(!qt.hasMore||!qt.cursor||Ft>=ii){zt.length>0&&T(gn=>We==="older"?[...zt,...gn]:zt);return}rt=qt.cursor,Ft+=1}}function Y(ge,We,dt,rt=i0(ge.output,s.provider,{includeTools:B})){if(H(ge.cursor),re(!!(ge.hasMore&&ge.cursor)),!rt)return!1;const Ft=[rt,...dt];return n0(Ft,B)?(T(zt=>We==="older"?[...Ft,...zt]:Ft),!0):!1}function Te(){const ge=h.current;ge&&(Ri(),!(ge.scrollTop>72||!j||!F||g.current)&&Ae(F,"older"))}function He(ge){ee!==0&&J(We=>{const dt=me>=0?me:ge>0?-1:0;return((We>=0&&We<ee?We:dt)+ge+ee)%ee})}function vt(ge){const We=fe[ge];We&&(w.current=We.key,ve(ge),I(We.key))}async function yi(ge){if(fe.length===0){ge<0&&j&&F&&!g.current&&(S.current={anchorKey:null},await Ae(F,"older"));return}const dt=(oe>=0&&oe<fe.length?oe:ge<0?fe.length-1:-1)+ge;if(dt>=0&&dt<fe.length){vt(dt);return}ge<0&&dt<0&&j&&F&&!g.current&&(S.current={anchorKey:fe[0]?.key??null},await Ae(F,"older"))}function Ri(){if(je)return;const ge=h.current;if(!ge)return;const dt=ge.getBoundingClientRect().top+Math.min(140,Math.max(48,ge.clientHeight*.28));let rt=null;for(const Ft of o3(ge)){const zt=c3(Ft);if(zt!==null)if(Ft.getBoundingClientRect().top<=dt)rt=zt;else break}if(rt!==null){const Ft=fe[rt]?.key??null;w.current=Ft,ve(rt),P&&P!==Ft&&I(null)}}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>{ge.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[G," JSONL"]}),m.jsx("span",{title:s.sessionId,children:s.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:B,onChange:ge=>L(ge.currentTarget.checked)}),"Show tool output"]}),m.jsx("label",{className:"transcript-search",children:m.jsx("input",{type:"search",value:A,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ge=>W(ge.currentTarget.value),onKeyDown:ge=>{ge.key==="Enter"&&(ge.preventDefault(),je?He(ge.shiftKey?-1:1):yi(ge.shiftKey?-1:1))}})}),m.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":ne,"aria-label":"Toggle prompt list",onClick:()=>le(ge=>!ge),disabled:fe.length===0,children:"List"}),m.jsxs("div",{className:"transcript-search-actions","aria-label":je?"Search result navigation":"Prompt navigation",children:[m.jsx("button",{type:"button",onClick:()=>je?He(-1):void yi(-1),disabled:je?ee===0:fe.length===0&&!j,"aria-label":je?"Previous search match":"Previous user prompt",title:je?"Previous search match":"Previous user prompt",children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>je?He(1):void yi(1),disabled:je?ee===0:fe.length===0,"aria-label":je?"Next search match":"Next user prompt",title:je?"Next search match":"Next user prompt",children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:Le})]}),ne?m.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:fe.length>0?fe.map((ge,We)=>m.jsxs("button",{type:"button",className:xe===ge.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>vt(We),children:[m.jsx("span",{children:ge.timestampLabel}),m.jsx("strong",{children:ge.snippet})]},`${ge.key}:${We}`)):m.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Te,children:[Z?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!M&&j?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,se?m.jsx(ZN,{entries:_e,searchQuery:A,activeEntryIndex:Re,activeEntryMode:ze,activeSearchMatch:be,fontSize:o}):null,M?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!M&&!se&&!ke?j&&F?m.jsxs("div",{className:"transcript-dialog-status",children:[B?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{Ae(F,"older")},disabled:Z,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,ke?m.jsx("div",{className:"transcript-dialog-error",children:ke}):null]})]})})});function ZN({entries:e,searchQuery:t,activeEntryIndex:r,activeEntryMode:s,activeSearchMatch:o,fontSize:c}){const h=v.useRef(new Map);v.useEffect(()=>{if(r===null)return;const g=h.current.get(r);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===r?f[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[r,s,o,t]);let p=-1;return m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const b=g.kind==="user"?++p:null,y=r===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return m.jsxs("section",{ref:S=>{S?h.current.set(f,S):h.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${y}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...b!==null?{"data-transcript-prompt-position":b}:{},children:[g.header?m.jsx("div",{className:"transcript-entry-header",children:y1(g.header,t)}):null,g.body?m.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?m.jsx(t0,{text:g.body,searchQuery:t}):m.jsx(Ti.Suspense,{fallback:m.jsx(t0,{text:g.body,searchQuery:t}),children:m.jsx(qN,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function t0({text:e,searchQuery:t}){const r=e.endsWith(`
35
- `)?e.slice(0,-1).split(`
36
- `):e.split(`
37
- `);return m.jsx("pre",{className:"transcript-entry-pre",children:r.map((s,o)=>m.jsx("span",{className:`transcript-line transcript-line-${u3(s,o===0||r[o-1]?.trim()==="")}`,children:y1(s,t)},o))})}function y1(e,t){const r=t.trim();if(!r)return e||" ";const s=e.toLowerCase(),o=r.toLowerCase(),c=[];let h=0,p=s.indexOf(o);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+r.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=s.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function QN(e,t){const r=t.trim().toLowerCase();if(!r)return 0;const s=e.toLowerCase();let o=0,c=s.indexOf(r);for(;c!==-1;)o+=1,c=s.indexOf(r,c+r.length);return o}function JN(e){const t=e.endsWith(`
38
- `)?e.slice(0,-1):e;if(!t)return[];const r=[];let s=null,o="plain",c=[];function h(){const p=e3(c).join(`
39
- `);(s||p)&&r.push({header:s,body:p,kind:o}),s=null,o="plain",c=[]}for(const p of t.split(`
40
- `)){const g=t3(p);g?(h(),s=p,o=g):c.push(p)}return h(),r}function e3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function t3(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const r=t[1]??"";return r==="User"?"user":r==="Codex"||r==="Claude"?"assistant":r==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(r)?"tool":null}function i3(e,t){const r=[];for(let s=0;s<e.length;s+=1){const o=e[s];if(!o)continue;const c=o.header?`${o.header}
41
- ${o.body}`:o.body,h=QN(c,t);for(let p=0;p<h;p+=1)r.push({entryIndex:s,matchIndexInEntry:p})}return r}function n3(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:r3(c),entry:c,entryIndex:o})}const r=new Map,s=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const h=r.get(c.contentKey)??0;r.set(c.contentKey,h+1),s.set(o,JSON.stringify([c.contentKey,h]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:s.get(c)??JSON.stringify([o.contentKey,0]),snippet:a3(o.entry.body),timestampLabel:l3(o.entry.header)}))}function r3(e){return JSON.stringify([e.header??"",e.body.length,s3(e.body)])}function s3(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function a3(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function l3(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function o3(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function c3(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const r=Number(t);return Number.isInteger(r)&&r>=0?r:null}function u3(e,t){const r=e.trim();if(!r)return"blank";const s=r.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(r);return(o||t)&&/^User$/.test(s)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(o||t)&&/^System$/.test(s)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||C1(r))?"tool":/^(?:\$|>|❯|➜)\s+/.test(r)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(r)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(r)?"error":/^\[[^\]]+\]/.test(r)||/^(?:info|debug|warn)\b/i.test(r)?"dim":"plain"}function h3(e){return e.includes("\r")||e.includes(`
42
- `)}function ap(e){return e instanceof or&&e.status===404}function Ku(e){return b1(e)||d3(e)}function b1(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function d3(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function f3(e){if(Ku(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function oh(e){return e==="codex"?"Codex":"Claude"}function i0(e,t,r={}){const s=`[nterminal] ${oh(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
43
- `).replace(/\r/g,`
44
- `).replace(s,"").replace(/\n{3,}/g,`
45
-
46
- `).trimEnd(),c=S1(o),h=r.includeTools?c:w1(c);return h?`${h}
47
- `:""}function S1(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,r)=>{const s=p3(r);return s?`[${s}]`:t})}function p3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const r=t.getFullYear(),s=ko(t.getMonth()+1),o=ko(t.getDate()),c=ko(t.getHours()),h=ko(t.getMinutes()),p=ko(t.getSeconds());return`${r}-${s}-${o} ${c}:${h}:${p}`}function ko(e){return e.toString().padStart(2,"0")}function n0(e,t){return e.map(r=>t?r:w1(r)).filter(Boolean).map(r=>r.endsWith(`
48
- `)?r:`${r}
49
- `).join("")}function w1(e){if(!e)return"";const t=e.split(`
50
- `),r=[];let s=!1,o=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?m3(h):null;if(g&&(s=g==="tool",o=!1),C1(h)){o=!0,c=!1;continue}if(o){p?(o=!1,s||r.push(h),c=!0):c=!1;continue}s||r.push(h),c=p}return r.join(`
51
- `).replace(/\n{3,}/g,`
52
-
53
- `).trimEnd()}function m3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function C1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function g3(e,t){if(t.length===0)return e;let r=0;const s=Math.min(e.length,t.length);for(let o=s;o>0;o-=1){let c=!0;for(let h=0;h<o;h+=1)if(e[e.length-o+h]!==t[h]){c=!1;break}if(c){r=o;break}}return[...e,...t.slice(r)]}function _3(e){let t=0;for(const r of e){if(!r)continue;const s=r.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function Mu(e){const t=[];for(const r of e){const s=x1(r);s&&t.push(s)}return t}function x1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,r,s)=>{const o=r.split(";").filter(Boolean).filter(c=>!AN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${s}`:""})}function lp(e,t={}){const r={};return(e?.force||t.force)&&(r.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(r.scrollToBottom=!0),r}function v3(e){const t=e.buffer.active,r=t.baseY+e.rows;return r<=e.rows?null:{current:Math.max(1,Math.min(r,t.viewportY+1)),total:r}}function lr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Nu(e,t){return!t||lr(e)}function r0(e){return lr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function y3(e,t,r,s,o,c){const h=p=>{const g=S3(p);g!==0&&(p.cancelable&&p.preventDefault(),p.stopPropagation(),b3(t,g,r,s,o,c))};return e.addEventListener("wheel",h,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",h,{capture:!0})}}function b3(e,t,r,s,o,c){const h=()=>{o();try{e.scrollLines(t)}finally{c()}r(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(bm,h);return}h()}function S3(e){const r=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(r===0)return 0;const s=r<0?Math.floor(r):Math.ceil(r);return Math.max(-30,Math.min(30,s))}function w3(e,t,r,s,o,c,h){let p=null,g=0;const f={passive:!1};function b(w){p=op(w),g=0}function y(w){const k=op(w);if(k===null){p=null,g=0;return}if(p===null){p=k;return}const T=k.clientY-p.clientY;if(p=k,w.cancelable&&w.preventDefault(),T===0)return;if(C3(t)&&x3(t,k,-T)){g=0;return}g-=T/r();const B=g<0?Math.ceil(g):Math.floor(g);if(B!==0){g-=B,c();try{t.scrollLines(B)}finally{h()}s(),B<0&&t.buffer.active.viewportY<=3&&o(B)}}function S(w){if(w.touches.length>0){p=op(w);return}p=null,g=0}return e.addEventListener("touchstart",b,f),e.addEventListener("touchmove",y,f),e.addEventListener("touchend",S),e.addEventListener("touchcancel",S),()=>{e.removeEventListener("touchstart",b,f),e.removeEventListener("touchmove",y,f),e.removeEventListener("touchend",S),e.removeEventListener("touchcancel",S)}}function op(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function C3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function x3(e,t,r){const s=e.element;return s?(s.dispatchEvent(E3(t,r)),!0):!1}function E3(e,t){const r=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:r};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const o=new Event("wheel",s);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function Sm({node:e,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:S,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,onAuthClose:W}){const K=S??wm(e);if(y.length===0&&b){const oe=Cm(e),ve=oe.some(P=>P.key===b)?b:oe[0]?.key;if(oe.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:oe.map(P=>{const I=P.key===ve;if(P.type==="editor"){const H=r[P.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":I,"aria-hidden":!I,children:H?m.jsx(Wb,{api:s,editor:H,canClose:K>1,onClose:()=>A(P.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},P.key)}const F=t[P.terminalId];return F?m.jsx("div",{className:"mobile-focused-pane","data-active":I,"aria-hidden":!I,children:m.jsx(QS,{terminal:F,serverApi:s,active:I,visible:c&&I,canClose:K>1,refreshCwdOnEnter:h&&I,tabId:p,onSelect:()=>w(P.terminalId),onClose:()=>k(P.terminalId),onExit:H=>B(P.terminalId,H),onSnapshot:L,...W?{onAuthClose:W}:{}})},P.key):m.jsx("div",{className:"mobile-focused-pane","data-active":I,"aria-hidden":!I,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},P.key)})})}if(e.type==="pane"){const oe=t[e.terminalId];if(!oe)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(QS,{terminal:oe,serverApi:s,active:e.terminalId===o,visible:c,canClose:K>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:p,onSelect:()=>w(e.terminalId),onClose:()=>k(e.terminalId),onExit:I=>B(e.terminalId,I),onSnapshot:L,...W?{onAuthClose:W}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(Au,{terminalId:e.terminalId,side:"top"}),m.jsx(Au,{terminalId:e.terminalId,side:"right"}),m.jsx(Au,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Au,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const oe=r[e.editorId];return oe?m.jsx(Wb,{api:s,editor:oe,canClose:K>1,onClose:()=>A(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const J=Math.max(.1,Math.min(.9,e.ratio)),ne=1-J,le=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${J}fr) 1px minmax(0, ${ne}fr)`}:{gridTemplateRows:`minmax(0, ${J}fr) 1px minmax(0, ${ne}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:le,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Sm,{node:e.first,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,0],totalPanes:K,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,...W?{onAuthClose:W}:{}})}),m.jsx(k3,{direction:e.direction,path:y,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(Sm,{node:e.second,terminals:t,editors:r,api:s,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,1],totalPanes:K,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,...W?{onAuthClose:W}:{}})})]})}function Au({terminalId:e,side:t}){const{setNodeRef:r,isOver:s}=Gm({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:r,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function k3({direction:e,path:t,onResize:r}){function s(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-p.left)/p.width:(b.clientY-p.top)/p.height;r(t,Math.min(.9,Math.max(.1,y)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function wm(e){return e.type==="pane"||e.type==="editor"?1:wm(e.first)+wm(e.second)}function Cm(e){return e.type==="pane"?[{key:T3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:D3(e.editorId),type:"editor",editorId:e.editorId}]:[...Cm(e.first),...Cm(e.second)]}function T3(e){return`terminal:${e}`}function D3(e){return`editor:${e}`}const Dh="workspace-default",R3="NTerminal";function M3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function N3(e,t){switch(t.type){case"workspace.hydrated":return xm(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return A3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return z3(e,t.workspaceId);case"workspace.selected":return E1(e,t.workspaceId);case"workspace.renamed":return L3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return B3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return O3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return k1(e,t.terminal);case"terminal.split":return j3(e,t.terminal,t.direction);case"terminal.updated":return Y3(e,t.terminal);case"terminal.exited":return X3(e,t.terminalId,t.exitCode);case"terminal.closed":return R1(e,t.terminalId);case"terminal.detached":return G3(e,t.terminalId,t.workspaceId);case"editor.split":return H3(e,t.editorId,t.title,t.direction);case"editor.closed":return Z3(e,t.editorId);case"pane.selected":return $3(e,t.terminalId);case"pane.resized":return V3(e,t.path,t.ratio);case"tab.selected":return U3(e,t.tabId);case"tab.renamed":return q3(e,t.tabId,t.title);case"tab.reordered":return Dg(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return I3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return T1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return D1(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return K3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return P3(e);default:return e}}function A3(e,t){if(e.workspaces.some(s=>s.id===t.id))return E1(e,t.id);const r={id:t.id,title:t.title,defaultCwd:ur(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,r],activeWorkspaceId:r.id}}function E1(e,t){return e.workspaces.some(r=>r.id===t)?{...e,activeWorkspaceId:t}:e}function L3(e,t,r){const s=r.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===s?h:(o=!0,{...h,title:s}));return o?{...e,workspaces:c}:e}function B3(e,t,r){const s=ur(r);let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===s?h:(o=!0,{...h,defaultCwd:s}));return o?{...e,workspaces:c}:e}function O3(e,t,r,s){if(t===r)return e;const o=e.workspaces.findIndex(y=>y.id===t),c=e.workspaces.findIndex(y=>y.id===r);if(o<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(o,1);if(!p)return e;const g=h.findIndex(y=>y.id===r);if(g<0)return e;const f=s==="before"?g:g+1,b=h.slice();return b.splice(f,0,p),F3(e.workspaces,b)?e:{...e,workspaces:b}}function z3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const r=e.workspaces.find(p=>p.id===t),s=new Set(r?ch(r):[]),o={...e.terminals};for(const p of s)delete o[p];const c=e.workspaces.filter(p=>p.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:o}}function k1(e,t){const r=N1(e),s=ka(r)??Mh(),o=z1(t);return{...r,activeWorkspaceId:s.id,terminals:{...r.terminals,[t.id]:t},workspaces:r.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??ur(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:O1(c,t.id))}}function j3(e,t,r){const s=ka(e),o=s?Rh(s):void 0;if(!s||!o)return k1(e,t);const c=o.activeTerminalId,h=nc(o.root,c,{type:"split",direction:r,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(p=>p.id===s.id?{...p,defaultCwd:p.defaultCwd??ur(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:O1(p,t.id))}}function H3(e,t,r,s){const o=ka(e),c=o?Rh(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,p=nc(c.root,h,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:r}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function P3(e){const t=ka(e),r=t?Rh(t):void 0;return r?R1(e,r.activeTerminalId):e}function U3(e,t){const r=ka(e);return!r||!r.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===r.id?{...s,activeTabId:t}:s)}}function Dg(e,t,r){const s=e.workspaces.map(o=>{const c=o.tabs.findIndex(b=>b.id===t);if(c<0)return o;const h=o.tabs.slice(),[p]=h.splice(c,1);if(!p)return o;const g=Math.max(0,Math.min(h.length,r)),f=h.slice();return f.splice(g,0,p),W3(o.tabs,f)?o:{...o,tabs:f}});return s.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:s}}function I3(e,t,r,s,o){if(r===s||!e.terminals[r]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(k=>k.id===t);if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y=wl(b.root,r);if(!y){const k=g.tabs.filter((T,B)=>B!==f);return{...g,tabs:k}}const S={...b,root:y,activeTerminalId:Pi(y)[0]??b.activeTerminalId},w=g.tabs.slice();return w[f]=S,{...g,tabs:w}});const h=o==="left"||o==="right"?"vertical":"horizontal",p=o==="left"||o==="top";return c=c.map(g=>{const f=g.tabs.findIndex(T=>Pi(T.root).includes(s));if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y={type:"pane",terminalId:r},S={type:"split",direction:h,ratio:.5,first:p?y:{type:"pane",terminalId:s},second:p?{type:"pane",terminalId:s}:y},w=nc(b.root,s,S),k=g.tabs.slice();return k[f]={...b,root:w,activeTerminalId:r},{...g,tabs:k,activeTabId:b.id}}),N1({...e,workspaces:c})}function T1(e,t,r,s){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const L=e.workspaces[B].tabs.findIndex(A=>A.id===t);if(L>=0){o=B,c=L;break}}if(o<0)return e;const h=e.workspaces[o],p=h.tabs[c],g=Pi(p.root);if(!g.includes(r))return e;if(g.length===1)return Dg(e,t,s);const f=wl(p.root,r);if(!f)return e;const b={...p,root:f,activeTerminalId:Pi(f)[0]??p.activeTerminalId},y=e.terminals[r],S={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:y?.title??"",activeTerminalId:r,root:{type:"pane",terminalId:r}},w=h.tabs.slice();w[c]=b;const k=Math.max(0,Math.min(w.length,s));w.splice(k,0,S);const T=e.workspaces.slice();return T[o]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:T}}function D1(e,t,r,s=Number.MAX_SAFE_INTEGER){const o=A1(e.workspaces,t),c=e.workspaces.find(f=>f.id===r);if(!o||!c)return e;if(o.workspace.id===r)return s===Number.MAX_SAFE_INTEGER?e:Dg(e,t,s);const h=Pi(o.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===o.workspace.id)return Ta({...f,tabs:f.tabs.filter(b=>b.id!==t)});if(f.id===r){const b=f.tabs.slice(),y=Math.max(0,Math.min(b.length,s));return b.splice(y,0,o.tab),{...f,defaultCwd:f.defaultCwd??ur(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:b,activeTabId:o.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:r}}function K3(e,t,r,s,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),h=A1(e.workspaces,t);if(!c||!h||!e.terminals[r]||!Pi(h.tab.root).includes(r))return e;if(h.workspace.id===s)return T1(e,t,r,o);if(Pi(h.tab.root).length===1)return D1(e,t,s,o);const g=wl(h.tab.root,r);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Pi(g)[0]??h.tab.activeTerminalId},b=e.terminals[r],y={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:b.title??r,activeTerminalId:r,root:{type:"pane",terminalId:r}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return Ta({...w,tabs:w.tabs.map(k=>k.id===t?f:k)});if(w.id===s){const k=w.tabs.slice(),T=Math.max(0,Math.min(k.length,o));return k.splice(T,0,y),{...w,defaultCwd:w.defaultCwd??ur(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(B=>B!==r),tabs:k,activeTabId:y.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function W3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function F3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function q3(e,t,r){const s=r.trim();if(!s)return e;let o=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===s?f:(o=!0,p=!0,{...f,title:s}));return p?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function $3(e,t){const r=e.workspaces.find(o=>o.tabs.some(c=>Cl(c.root,t))),s=r?.tabs.find(o=>Cl(o.root,t));return!r||!s?e:{...e,activeWorkspaceId:r.id,workspaces:e.workspaces.map(o=>o.id===r.id?{...o,activeTabId:s.id,tabs:o.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:o)}}function V3(e,t,r){const s=ka(e),o=s?Rh(s):void 0;if(!s||!o)return e;const c=Mm(o.root,t,P1(r));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===s.id?{...h,tabs:h.tabs.map(p=>p.id===o.id?{...p,root:c}:p)}:h)}}function xm(e,t,r,s){const o=Object.fromEntries(e.map(y=>[y.id,y])),c=new Set(e.map(y=>y.id)),h=new Set,p=!!(r&&r.some(y=>j1(y))||t&&t.some(y=>H1(y)));let g=Q3(t,r,c,h);g.length===0&&(g=[Mh()]);const f=typeof s=="string"&&g.some(y=>y.id===s)?s:g[0]?.id??null,b=f??g[0]?.id??Dh;for(const y of e)if(!h.has(y.id)){if(p)g=tA(g,b,y.id,y);else{const S=z1(y);g=nA(g,b,S,y)}h.add(y.id)}return{workspaces:g.map(y=>Ta(iA(y,o))),activeWorkspaceId:f,terminals:o}}function ic(e){return Pi(e.root)}function Em(e){return Nm(e.root)}function ch(e){return Rg([...e.tabs.flatMap(t=>Pi(t.root)),...e.detachedTerminalIds])}function cp(e){const t=e.workspaces.map(r=>{const s=r.tabs.flatMap(o=>{const c=Dm(o.root);return c?[{...o,root:c}]:[]});return Ta({...r,tabs:s})});return{activeWorkspaceId:t.some(r=>r.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function Y3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(r=>({...r,tabs:r.tabs.map(s=>Cl(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function X3(e,t,r){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:r}}}:e}function R1(e,t){const r={...e.terminals};return delete r[t],M1(e,t,r)}function G3(e,t,r){if(!e.terminals[t])return e;const s=(r&&e.workspaces.some(c=>c.id===r)?r:null)??J3(e,t)?.id??eA(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Dh,o=e.workspaces.find(c=>c.id===s);return!o||!B1(o,t)?e:M1(e,t,{...e.terminals},{detachToWorkspaceId:s})}function M1(e,t,r,s={}){let o=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=wl(g.root,t);if(!f)continue;const b=Pi(f),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&p.push({...g,root:f,activeTerminalId:y})}return Ta({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});s.detachToWorkspaceId&&r[t]&&(o=o.map(h=>h.id===s.detachToWorkspaceId?L1(h,t,r[t]):h));const c=o.some(h=>h.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:r}}function Z3(e,t){const r=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const p=km(h.root,t);if(!p)continue;const g=Pi(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return Ta({...o,tabs:c})}),s=r.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:r,activeWorkspaceId:s?e.activeWorkspaceId:r[0]?.id??null}}function Q3(e,t,r,s){if(t&&t.length>0){const o=[];for(const c of t)j1(c)&&o.push(s0(c,r,s));if(o.length>0)return o}return[s0({...Mh(),tabs:e??[]},r,s)]}function s0(e,t,r){const s=[];for(const c of e.tabs){if(!H1(c))continue;const h=Tm(c.root,t);if(!h)continue;const p=Pi(h);for(const f of p)r.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&s.push({...c,root:h,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||r.has(c)||(r.add(c),o.push(c));return Ta({...e,defaultCwd:ur(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function N1(e){return ka(e)?e:{...e,workspaces:[Mh()],activeWorkspaceId:Dh}}function ka(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Rh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function A1(e,t){for(const r of e){const s=r.tabs.findIndex(o=>o.id===t);if(s>=0)return{workspace:r,tab:r.tabs[s],tabIndex:s}}return null}function J3(e,t){return e.workspaces.find(r=>r.tabs.some(s=>Cl(s.root,t)))}function eA(e,t){return e.workspaces.find(r=>r.detachedTerminalIds.includes(t))}function tA(e,t,r,s){return e.map(o=>o.id===t?L1(o,r,s):o)}function L1(e,t,r){return B1(e,t)?{...e,defaultCwd:e.defaultCwd??ur(r?.cwd),detachedTerminalIds:Rg([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function B1(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<kl}function O1(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(r=>r!==t)}:e}function iA(e,t){if(e.defaultCwd)return e;const r=ch(e).find(o=>!!t[o]),s=r?ur(t[r]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Mh(){return{id:Dh,title:R3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ta(e){const t=e.tabs.some(r=>r.id===e.activeTabId);return{...e,defaultCwd:ur(e.defaultCwd),detachedTerminalIds:Rg(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function nA(e,t,r,s){const o=Pi(r.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??ur(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,r],activeTabId:c.activeTabId??r.id}:c)}function z1(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function nc(e,t,r){return e.type==="pane"?e.terminalId===t?r:e:e.type==="editor"?e:{...e,first:nc(e.first,t,r),second:nc(e.second,t,r)}}function wl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const r=wl(e.first,t),s=wl(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function km(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const r=km(e.first,t),s=km(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function Tm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const r=Tm(e.first,t),s=Tm(e.second,t);return r&&s?{...e,ratio:P1(e.ratio),first:r,second:s}:r??s}function Dm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Dm(e.first),r=Dm(e.second);return t&&r?{...e,first:t,second:r}:t??r}function j1(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 H1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Rm(t.root)}function Rm(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")&&Rm(t.first)&&Rm(t.second):!1}function Mm(e,t,r){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===r?e:{...e,ratio:r};const[s,...o]=t;if(s===0){const c=Mm(e.first,o,r);return c===e.first?e:{...e,first:c}}if(s===1){const c=Mm(e.second,o,r);return c===e.second?e:{...e,second:c}}return e}function P1(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ur(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Rg(e){const t=new Set,r=[];for(const s of e)!s||t.has(s)||(t.add(s),r.push(s));return r}function Cl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Cl(e.first,t)||Cl(e.second,t)}function Pi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Pi(e.first),...Pi(e.second)]}function Nm(e){return e.type==="pane"||e.type==="editor"?1:Nm(e.first)+Nm(e.second)}const Us=new Map,rc=new Map,sc=new Map;function Rl(e){return e??"__local__"}function rA(e){return{agentId:e,state:M3(),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 At(e){const t=Rl(e);let r=Us.get(t);return r||(r=rA(e),Us.set(t,r)),r}function U1(e,t){const r=Rl(e);let s=rc.get(r);return s||(s=new Set,rc.set(r,s)),s.add(t),()=>{s.delete(t)}}function sA(e){const t=Rl(e),r=rc.get(t);if(r)for(const s of Array.from(r))s()}function Ml(e,t){Us.set(Rl(e),t),sA(e)}const Am=new Set;function aA(e){return Am.add(e),()=>{Am.delete(e)}}function To(e,t){const r=At(e),s=Rl(e);t.type==="workspace.hydrated"&&sc.delete(s);const o=N3(r.state,t);let c=r.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=r.state.terminals[t.terminal.id],b=f?.activity==="busy",y=t.terminal.activity==="busy",S=t.terminal.activity==="idle",w=pA(s);if(t.notifyCompletion===!0&&y&&w.add(t.terminal.id),t.notifyCompletion===!0&&b&&S&&w.has(t.terminal.id)){const k=lA(o,t.terminal.id);k&&(h={terminalId:t.terminal.id,tabId:k.tab.id,commandName:f?.currentCommand??null},(k.workspace.activeTabId!==k.tab.id||k.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id))))}(S||t.terminal.status==="exited")&&w.delete(t.terminal.id)}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=oA(o,t.tabId)?.tab??null;else{const y=o.workspaces.find(S=>S.id===t.workspaceId);f=y?.tabs.find(S=>S.id===y.activeTabId)??null}const b=f?Pi(f.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const S of b)y.delete(S);c=y}}const p=o!==r.state,g=c!==r.unreadCompletions;if((p||g)&&Ml(e,{...r,state:o,unreadCompletions:c}),g&&Mg(),h)for(const f of Array.from(Am))f({agentId:e,...h})}function lA(e,t){for(const r of e.workspaces)for(const s of r.tabs)if(Pi(s.root).includes(t))return{workspace:r,tab:s};return null}function oA(e,t){for(const r of e.workspaces){const s=r.tabs.find(o=>o.id===t);if(s)return{workspace:r,tab:s}}return null}const Lm=new Set;function cA(e){return Lm.add(e),()=>{Lm.delete(e)}}function uA(){let e=0;for(const t of Us.values())e+=t.unreadCompletions.size;return e}function Mg(){for(const e of Array.from(Lm))e()}function hA(e,t){const r=At(e);if(!r.unreadCompletions.has(t))return;const s=new Set(r.unreadCompletions);s.delete(t),Ml(e,{...r,unreadCompletions:s}),Mg()}function a0(e,t){const r=At(e);t!==r.state&&Ml(e,{...r,state:t})}function up(e,t){const r=At(e),s=t(r.editors);s!==r.editors&&Ml(e,{...r,editors:s})}function Ds(e,t,r){const s=At(e);s.loaded===t&&s.error===r||Ml(e,{...s,loaded:t,error:r})}function Do(e,t,r){const s=At(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===r||Ml(e,{...s,layoutRevision:t,lastPersistedLayoutJson:r})}function dA(e){const t=At(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function fA(e){const t=Rl(e),r=Us.get(t);r&&r.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(r.mutable.saveCoord.saveTimer);const s=r?r.unreadCompletions.size>0:!1;Us.delete(t),rc.delete(t),sc.delete(t),s&&Mg()}function hp(){for(const e of Us.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Us.clear(),rc.clear(),sc.clear()}function pA(e){let t=sc.get(e);return t||(t=new Set,sc.set(e,t)),t}function Bm(e,t){let r=!1,s=!1,o=null,c=!1;for(const h of ic(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,r=!0;continue}p.activity==="busy"?(s=!0,r=!0,!o&&p.currentCommand&&(o=p.currentCommand)):p.activity==="idle"&&(r=!0)}}return r?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Ng(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Om(e,t){const r=t[e.activeTerminalId];return e.title||r?.title||e.activeTerminalId}function mA(e,t,r,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${r} pane${r===1?"":"s"}`}function gA({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:k}){const[T,B]=v.useState(null),[L,A]=v.useState(!1),[W,K]=v.useState(null),J=v.useRef(null),ne=e.findIndex(j=>j.id===t),le=ne>=0?e[ne]:e[0]??null,oe=le?Bm(le,r):null,ve=le?Em(le):0,P=le?Om(le,r):"No tab";v.useEffect(()=>{J.current?.focus(),J.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!L)return;const j=re=>{re.key==="Escape"&&A(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[L]),v.useEffect(()=>{L&&e.length===0&&A(!1)},[L,e.length]);function I(j,re){B({tabId:j,title:re})}function F(){if(!T)return;const j=T.title.trim();j&&w(T.tabId,j),B(null)}function H(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${E2()}`,onClick:y,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${k2()}`,onClick:S,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:p,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:P,onClick:()=>A(!0),disabled:e.length===0,children:[oe?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":oe.state,"aria-hidden":"true",title:Ng(oe)}):null,m.jsx("span",{children:P}),m.jsxs("small",{children:[ne>=0?ne+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,re)=>{const M=ic(j),V=Em(j),Z=Om(j,r),Ce=j.id===t,ke=T?.tabId===j.id,R=Bm(j,r),G=s?.has(j.id)??!1;return m.jsxs(Ti.Fragment,{children:[m.jsx(l0,{index:re}),m.jsx(_A,{tab:j,active:Ce,editing:ke,title:Z,paneCount:V,terminalIds:M,canClose:e.length>1,editValue:ke?T.title:null,editInputRef:ke?J:null,activity:R,unread:G,onSelect:()=>c(j.id),onBeginRename:()=>I(j.id,Z),onCloseAll:()=>g(M),onCommitRename:F,onCancelRename:()=>B(null),onRenameChange:se=>B({tabId:j.id,title:se})})]},j.id)}),m.jsx(l0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(o?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(j=>m.jsx(yA,{terminal:j,onReattach:()=>f?.(j.id),onDelete:()=>K(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),k?H():null]}),L?m.jsx(vA,{tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:T,editInputRef:J,onClose:()=>A(!1),onSelectTab:j=>{c(j),A(!1)},onCreateTab:()=>{h(),A(!1)},onBeginRename:I,onCloseTerminals:j=>{g(j),A(!1)},onCommitRename:F,onCancelRename:()=>B(null),onRenameChange:(j,re)=>B({tabId:j,title:re}),onReattachTerminal:j=>{f?.(j),A(!1)},onDeleteTerminal:j=>{K(j),A(!1)}}):null,W?m.jsx(bA,{terminal:W,onCancel:()=>K(null),onConfirm:()=>{b?.(W.id),K(null)}}):null]})}function _A({tab:e,active:t,editing:r,title:s,paneCount:o,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:b,onBeginRename:y,onCloseAll:S,onCommitRename:w,onCancelRename:k,onRenameChange:T}){const{attributes:B,listeners:L,setNodeRef:A,transform:W,isDragging:K}=K0({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:r}),J={transform:gp.Translate.toString(W),opacity:K?.4:void 0,zIndex:K?2:void 0};return m.jsxs("div",{ref:A,className:"terminal-tab","data-active":t,"data-dragging":K,"data-unread":f?"true":void 0,style:J,...B,...L,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Ng(g)}):null,r&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:ne=>{ne.preventDefault(),w()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${s}`,value:h,onBlur:w,onChange:ne=>T(ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),w();return}ne.key==="Escape"&&(ne.preventDefault(),k())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:b,onDoubleClick:ne=>{ne.preventDefault(),y()},children:[m.jsx("span",{children:s}),m.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!r?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),S()},children:"x"}):null]})}function vA({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:b,onCloseTerminals:y,onCommitRename:S,onCancelRename:w,onRenameChange:k,onReattachTerminal:T,onDeleteTerminal:B}){const L=v.useRef(null);return v.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:p,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:A=>A.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:p,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((A,W)=>{const K=ic(A),J=Em(A),ne=Om(A,r),le=A.id===t,oe=c?.tabId===A.id,ve=Bm(A,r),P=s?.has(A.id)??!1;return m.jsxs("div",{ref:le?L:null,className:"mobile-tab-sheet-row","data-active":le,"data-unread":P?"true":void 0,children:[oe&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:I=>{I.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${ne}`,value:c.title,onBlur:S,onChange:I=>k(A.id,I.target.value),onKeyDown:I=>{if(I.key==="Enter"){I.preventDefault(),S();return}I.key==="Escape"&&(I.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${ne}`,onClick:()=>g(A.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:W+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:ne}),m.jsx("small",{children:mA(A,r,J,ve)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ve?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:Ng(ve)}):null,m.jsx("span",{children:J})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[oe?m.jsx("button",{type:"button","aria-label":`Done renaming ${ne}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${ne}`,onClick:()=>b(A.id,ne),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${ne}`,onClick:()=>y(K),children:"×"}):null]})]},A.id)}),(o?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(o??[]).map(A=>{const W=A.title||A.cwd||A.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${W}`,onClick:()=>T(A.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:W}),m.jsx("small",{children:A.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${W}`,onClick:()=>B(A),children:"×"})})]},A.id)})]}):null]})]})})}function l0({index:e}){const{setNodeRef:t,isOver:r}=Gm({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":r,"aria-hidden":"true"})}function yA({terminal:e,onReattach:t,onDelete:r}){const s=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
54
- ${e.cwd}
55
- (detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:o,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),r()},children:"×"})]})}function bA({terminal:e,onCancel:t,onConfirm:r}){const s=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:s}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:r,children:"Delete"})]})]})})}function SA({uploads:e,onDismiss:t,onDismissAll:r,onRetry:s,onCancel:o}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",p=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${kA(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?Wu(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:r,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(wA,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>o(g.id)},g.id))})]})}function wA({upload:e,compact:t,onDismiss:r,onRetry:s,onCancel:o}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Wu(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:Wu(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${Wu(e)}`,onClick:r,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(CA,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(xA,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function CA({toast:e}){const t=e.percent===null?TA(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function xA({response:e,compact:t}){const r=e.results.filter(h=>h.status==="failed"),s=e.results.filter(h=>h.status==="uploaded"),o=t?3:6,c=[...r,...s].slice(0,o);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,p)=>m.jsx(EA,{result:h},`${h.relativePath}-${p}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function EA({result:e}){const t=e.savedRelativePath??e.relativePath,r=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),r?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Wu(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,r=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${r} files`}return"Upload failed"}function kA(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 TA(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function DA({toast:e,onActivate:t,onDismiss:r}){if(!e)return null;const s=e,o=s.commandName?`${s.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),r()}function h(p){p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(s)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:s.tabTitle}),m.jsx("span",{children:o})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:p=>p.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const RA=Po(0,0,1,1),Vr=1e-6;function MA(e){return I1(e).map(t=>t.terminalId)}function I1(e){return Ho(e,RA).sort(BA).map((t,r)=>({...t,index:r+1}))}function NA(e,t,r){const s=I1(e),o=s.find(h=>h.terminalId===t);return o?s.filter(h=>h.terminalId!==t).map(h=>LA(o,h,r)).filter(h=>h!==null).sort(OA)[0]?.entry.terminalId??null:null}function AA(e,t){return!Number.isInteger(t)||t<1?null:MA(e)[t-1]??null}function Ho(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const r=zA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*r;return[...Ho(e.first,Po(t.left,t.top,o,t.bottom)),...Ho(e.second,Po(o,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*r;return[...Ho(e.first,Po(t.left,t.top,t.right,s)),...Ho(e.second,Po(t.left,s,t.right,t.bottom))]}function LA(e,t,r){const s=e.bounds,o=t.bounds,c=o0(s.left,s.right,o.left,o.right),h=o0(s.top,s.bottom,o.top,o.bottom);switch(r){case"left":return o.centerX>=s.centerX-Vr||h<=Vr?null:{entry:t,primaryDistance:Math.max(0,s.left-o.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:h};case"right":return o.centerX<=s.centerX+Vr||h<=Vr?null:{entry:t,primaryDistance:Math.max(0,o.left-s.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:h};case"up":return o.centerY>=s.centerY-Vr||c<=Vr?null:{entry:t,primaryDistance:Math.max(0,s.top-o.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};case"down":return o.centerY<=s.centerY+Vr||c<=Vr?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:c};default:return null}}function BA(e,t){return ml(e.bounds.top,t.bounds.top)||ml(e.bounds.left,t.bounds.left)}function OA(e,t){return ml(e.primaryDistance,t.primaryDistance)||ml(e.perpendicularDistance,t.perpendicularDistance)||ml(t.overlap,e.overlap)||ml(e.entry.index,t.entry.index)}function ml(e,t){const r=e-t;return Math.abs(r)<=Vr?0:r}function o0(e,t,r,s){return Math.max(0,Math.min(t,s)-Math.max(e,r))}function Po(e,t,r,s){return{left:e,top:t,right:r,bottom:s,centerX:e+(r-e)/2,centerY:t+(s-t)/2}}function zA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class jA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function c0(e){return e?Array.from(e.types??[]).includes("Files")||q1(e.items).some(r=>r.kind==="file")?!0:$1(e.files).length>0:!1}async function HA(e){const t=q1(e.items).filter(r=>r.kind==="file");return t.length>0?PA(t):UA(e.files)}async function PA(e){const t=[];for(const r of e){const s=FA(r);if(s){await K1(s,"",t);continue}const o=r.getAsFile();if(o){t.push({relativePath:W1(o),file:o});continue}throw new jA("Folder upload is not supported by this browser.")}return t}function UA(e){return $1(e).map(t=>({relativePath:W1(t),file:t}))}async function K1(e,t,r){const s=$A(t,e.name);if(e.isFile){const h=await IA(e);r.push({relativePath:s,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await KA(o);for(const h of c)await K1(h,s,r)}function IA(e){return new Promise((t,r)=>{e.file(t,s=>r(s))})}async function KA(e){const t=[];for(;;){const r=await WA(e);if(r.length===0)return t;t.push(...r)}}function WA(e){return new Promise((t,r)=>{e.readEntries(t,s=>r(s))})}function W1(e){const t=e.webkitRelativePath;return F1(typeof t=="string"&&t?t:e.name)}function FA(e){const t=e.webkitGetAsEntry?.();return qA(t)?t:null}function qA(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 $A(e,t){return F1(e?`${e}/${t}`:t)}function F1(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function q1(e){return e?Array.from(e):[]}function $1(e){return e?Array.from(e):[]}const u0="nterminal.terminalWorkspaces.v2",V1="nterminal.sidebarCollapsed.v1",VA=75,h0=q0.map(e=>e.url),YA=q0[0].url,XA=6;function GA({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:h}){const p=v.useMemo(()=>e??fh(),[e]),g=v.useMemo(()=>t??Yo(null),[t]),f=v.useMemo(()=>p5(r),[r]),b=v.useMemo(()=>x=>U1(r,x),[r]),y=v.useMemo(()=>()=>At(r),[r]),S=v.useSyncExternalStore(b,y,y),w=S.state,k=S.editors,T=!S.loaded,B=S.error,[L,A]=v.useState(!1),[W,K]=v.useState(()=>S5()),[J,ne]=v.useState("servers"),[le,oe]=v.useState(!1),ve=v.useSyncExternalStore(z2,Hb,Hb);v.useSyncExternalStore(lg,jb,jb);const[P,I]=v.useState(0),[F,H]=v.useState(null),[j,re]=v.useState(()=>[null]),[M,V]=v.useState(0),[Z,Ce]=v.useState(()=>[r]),[ke,R]=v.useState(()=>new Set),[G,se]=v.useState({}),[_e,fe]=v.useState(null),we=v.useRef(0),Ne=v.useRef(0),[je,Ve]=v.useState(null),[ee,me]=v.useState(null),De=v.useRef(null),be=v.useRef(0),Re=v.useRef(null),ze=v.useRef(null),Ke=v.useRef(null),[ce,xe]=v.useState(null),Le=BE(bb(j0,{activationConstraint:{distance:8}}),bb(H0,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>j2(p),[p]);function Ae(x){const E=x.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){xe({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&xe({tabId:E.sourceTabId,terminalId:E.terminalId})}}function Ie(x){xe(null);const E=x.active.data.current,z=x.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){st({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){st({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&st({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){st({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){st({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&st({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Y(){xe(null)}const Te=w.workspaces.find(x=>x.id===w.activeWorkspaceId)??w.workspaces[0],He=Te?.tabs.find(x=>x.id===Te.activeTabId)??Te?.tabs[0],vt=He?.activeTerminalId??null,yi=vt?w.terminals[vt]:void 0,Ri=h5("(max-width: 760px)"),ge=v.useMemo(()=>He?uh(He.root):[],[He]),We=Te&&He?Uo(r,Te.id,He.id):null,dt=He?Y1(ge,He.activeTerminalId,We?G[We]:void 0):null,rt=Ri&&ge.length>1,Ft=v.useMemo(()=>(Te?.detachedTerminalIds??[]).flatMap(x=>{const E=w.terminals[x];return E?[E]:[]}),[Te?.detachedTerminalIds,w.terminals]),zt=v.useMemo(()=>{const x=new Set;for(const E of Te?.tabs??[])ic(E).some(z=>S.unreadCompletions.has(z))&&x.add(E.id);return x},[Te?.tabs,S.unreadCompletions]),[ii,qt]=v.useState([]),gt=v.useRef([]),Yi=v.useRef(null),[gn,Qn]=v.useState(null),[Mt,Ii]=v.useState(null),[yt,bt]=v.useState([]),[Et,Mi]=v.useState(()=>ba()),ui=v.useRef(0),Xt=v.useRef(r),hi=v.useRef(h0),bi=v.useRef(Et),Ut=v.useRef(()=>{});Ut.current=es;const Ni=v.useCallback(async()=>{try{const x=await p.listNotificationAssets();bt(x.assets.filter(E=>E.enabled).map(E=>E.url))}catch{bt([])}},[p]);v.useEffect(()=>{Ce(x=>x.some(E=>pn(E,r))?x:[...x,r])},[r]);const ni=v.useCallback(x=>{const E=At(x),z=Yo(x);for(const ie of Object.keys(E.state.terminals))jo(z.createWebSocketUrl(ie)),Ru(ie);fA(x),Ce(ie=>ie.filter(ye=>!pn(ye,x))),R(ie=>{const ye=`${qu(x)}:`;let pe=!1;const Se=new Set;for(const Fe of ie){if(Fe.startsWith(ye)){pe=!0;continue}Se.add(Fe)}return pe?Se:ie}),se(ie=>{const ye=`${qu(x)}:`;let pe=!1;const Se={};for(const[Fe,at]of Object.entries(ie)){if(Fe.startsWith(ye)){pe=!0;continue}Se[Fe]=at}return pe?Se:ie})},[]);v.useEffect(()=>{let x=!1;return p.listAgents().then(E=>{if(!x){const z=E.agents.map(ye=>ye.id),ie=[null,...z];r!==null&&!z.includes(r)&&(ni(r),s?.(null)),re(ie)}}).catch(()=>{}),()=>{x=!0}},[r,p,ni,s,M]);const Si=v.useCallback(x=>{ni(x),V(E=>E+1),pn(x,Xt.current)&&s?.(null)},[ni,s]);v.useEffect(()=>{re(x=>x.some(E=>pn(E,r))?x:[...x,r])},[r]),v.useEffect(()=>{Xt.current=r},[r]),v.useEffect(()=>{H(null)},[r]),v.useEffect(()=>{const x=Re.current;if(!x)return;if(!pn(x.agentId,r)){Re.current=null;return}if(!S.loaded||w.workspaces.length===0)return;Re.current=null;const E=x.edge==="first"?w.workspaces[0]:w.workspaces[w.workspaces.length-1];E&&E.id!==w.activeWorkspaceId&&st({type:"workspace.selected",workspaceId:E.id})},[r,S.loaded,w.activeWorkspaceId,w.workspaces]),v.useEffect(()=>{const x=ze.current;if(x){if(!pn(x.agentId,r)){ze.current=null;return}S.loaded&&(ze.current=null,w.workspaces.some(E=>E.id===x.workspaceId)&&st({type:"workspace.selected",workspaceId:x.workspaceId}))}},[r,S.loaded,w.workspaces]),v.useEffect(()=>{const x=Ke.current;if(x){if(!pn(x.agentId,r)){Ke.current=null;return}S.loaded&&(Ke.current=null,S.error||vn())}},[r,S.error,S.loaded]),v.useEffect(()=>{Ni()},[Ni]),v.useEffect(()=>G0(()=>Mi(ba())),[]),v.useEffect(()=>{const x=E=>{Ut.current(E)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{hi.current=yt.length>0?yt:h0},[yt]),v.useEffect(()=>{bi.current=Et},[Et]),v.useEffect(()=>{if(!S.loaded||!Te||!He)return;const x=Uo(r,Te.id,He.id);R(E=>{if(E.has(x))return E;const z=new Set(E);return z.add(x),z})},[r,S.loaded,Te?.id,He?.id]),v.useEffect(()=>()=>{It()},[]),v.useEffect(()=>aA(x=>{const E=At(x.agentId).state,z=E.workspaces.flatMap(Se=>Se.tabs).find(Se=>Se.id===x.tabId),ie=E.terminals[x.terminalId],ye=z?.title?.trim()||ie?.title||x.commandName||"terminal",pe=document.visibilityState==="visible"&&pn(x.agentId,Xt.current)&&x.tabId===f5(E);if(pe||g2({tabTitle:ye,commandName:x.commandName,terminalId:x.terminalId}),!pe&&document.visibilityState==="visible"&&bi.current.enabled){const Se=ui.current+1;ui.current=Se;const Fe=hi.current;Qn({id:Se,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:ye,commandName:x.commandName,assetSrc:Fe[Math.floor(Math.random()*Fe.length)]??YA})}}),[]),v.useEffect(()=>{if(!gn||Et.persistUntilDismissed)return;const x=window.setTimeout(()=>{Qn(E=>E?.id===gn.id?null:E)},Et.durationSeconds*1e3);return()=>window.clearTimeout(x)},[gn,Et]),v.useEffect(()=>{w5(W),W&&en()},[W]),v.useEffect(()=>{let x=!1;async function E(){if(!At(r).loaded){Ds(r,!1,null);try{let ie=null,ye=null;try{ie=m5(f)}catch(at){if(!(at instanceof dh))throw at;ye=at}const[pe,Se]=await Promise.all([g.listTerminals(),g.getTerminalLayout()]),Fe=pe.terminals.length>0?pe.terminals:[(await g.createTerminal({cols:80,rows:24})).terminal];if(!x){const at=Se.layout?G1(Se.layout):null;if(!at&&ye)throw ye;const Zt=at??ie??{},ai=xm(Fe,void 0,Zt.savedWorkspaces,Zt.savedActiveWorkspaceId),La=cp(ai);a0(r,ai),Do(r,Se.revision,JSON.stringify(La)),Ds(r,!0,null),!at&&ie&&si(La,{baseRevision:Se.revision})}}catch(ie){!x&&!Jr(ie)&&Ds(r,!0,Rs(ie))}}}return E(),()=>{x=!0}},[r,g,P]);function _n(){Ds(r,!1,null),I(x=>x+1)}function en(){we.current+=1,Ne.current+=1,fe(null)}function tn(x){we.current+=1,Ne.current+=1,fe(E=>E&&{...E,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function vn(){we.current+=1,Ne.current+=1;const x=w.workspaces.length+1,E=wi();fe({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Ln(E)}function Xi(x){if(pn(x,r)){vn();return}Ke.current={agentId:x},s?.(x)}function $t(x){if(W&&!L)return;const E=w.workspaces.find(ie=>ie.id===x);if(!E)return;we.current+=1,Ne.current+=1;const z=E.defaultCwd??yi?.cwd??"";fe({mode:"edit",workspaceId:x,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Ln(z)}function wi(){return Te?.defaultCwd??yi?.cwd??""}async function Ln(x){const E=we.current+1;we.current=E;const z=x.trim();if(fe(ie=>ie&&{...ie,cwd:x,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const ie=await g.createFileRoot({path:z}),ye=await g.listFiles({rootToken:ie.rootToken,path:""});if(we.current!==E)return;fe(pe=>pe&&{...pe,cwd:ie.rootPath,browseRoot:{rootToken:ie.rootToken,rootPath:ie.rootPath},browseEntries:ye.entries.filter(Se=>Se.kind==="directory"),browseStatus:"idle",error:null})}catch(ie){if(we.current!==E)return;fe(ye=>ye&&{...ye,browseStatus:"idle",error:Rs(ie)})}}async function Is(){const x=_e;if(!x)return;const E=x.title.trim(),z=x.cwd.trim();if(!E||!z){fe({...x,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const ie=Ne.current+1;Ne.current=ie,fe({...x,submitStatus:"submitting",error:null});try{const ye=await g.createFileRoot({path:z});if(Ne.current!==ie)return;if(x.mode==="create"){const pe=w.workspaces.length+1;st({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${pe}`,title:E,defaultCwd:ye.rootPath})}else x.workspaceId&&(st({type:"workspace.renamed",workspaceId:x.workspaceId,title:E}),st({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:ye.rootPath}));fe(null)}catch(ye){if(Ne.current!==ie)return;fe(pe=>pe&&{...pe,submitStatus:"idle",error:Rs(ye)})}}function Nl(x){Ne.current+=1,fe(x)}function Qr(x,E,z){if(x===E)return;const ie=w.workspaces.some(pe=>pe.id===x),ye=w.workspaces.some(pe=>pe.id===E);!ie||!ye||st({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:E,placement:z})}function Da(x,E){const z=w.workspaces.findIndex(ye=>ye.id===x),ie=w.workspaces[z+E];z<0||!ie||Qr(x,ie.id,E<0?"before":"after")}function Bn(x,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),De.current={sourceId:x,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function On(x){const E=De.current;if(!E||E.pointerId!==x.pointerId)return;const z=Math.hypot(x.clientX-E.startX,x.clientY-E.startY);if(!E.active){if(z<XA)return;E.active=!0,Ve(E.sourceId)}const ye=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),pe=ye?.dataset.workspaceId??null;if(!ye||!pe||pe===E.sourceId||!w.workspaces.some(at=>at.id===pe)){E.targetId=null,me(null);return}const Se=ye.getBoundingClientRect(),Fe=x.clientY<Se.top+Se.height/2?"before":"after";E.targetId=pe,E.placement=Fe,me({workspaceId:pe,placement:Fe})}function zn(x){const E=De.current;!E||E.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),De.current=null,Ve(null),me(null),E.active&&E.targetId&&Qr(E.sourceId,E.targetId,E.placement))}function Bt(x){const E=De.current;E&&E.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),De.current=null,Ve(null),me(null)}async function Jn(){await ri(async()=>{const x=Te?.defaultCwd?{cols:80,rows:24,cwd:Te.defaultCwd}:{cols:80,rows:24},E=await g.createTerminal(x);st({type:"terminal.created",terminal:E.terminal})})}async function yn(x){await ri(async()=>{const E=vt?{parentTerminalId:vt,cols:80,rows:24}:Te?.defaultCwd?{cols:80,rows:24,cwd:Te.defaultCwd}:{cols:80,rows:24},z=await g.createTerminal(E);st({type:"terminal.split",terminal:z.terminal,direction:x})})}async function Ot(x){let E=vt,z=We;const ie=Te?.defaultCwd?.trim();if(!E&&!ie)throw new Error("No active pane is available.");const ye=await g.readFile(x);if(!E&&ie){const Fe=await g.createTerminal({cols:80,rows:24,cwd:ie});E=Fe.terminal.id,st({type:"terminal.created",terminal:Fe.terminal})}if(E){st({type:"pane.selected",terminalId:E});const Fe=At(r).state,at=Fe.workspaces.find(ai=>ai.id===Fe.activeWorkspaceId)??Fe.workspaces[0],Zt=at?.tabs.find(ai=>ai.id===at.activeTabId)??at?.tabs[0];z=at&&Zt?Uo(r,at.id,Zt.id):null}const pe=`editor-${Date.now().toString(36)}-${dA(r)}`,Se=b5(ye.path);up(r,Fe=>({...Fe,[pe]:{id:pe,title:Se,rootToken:x.rootToken,path:ye.path,read:ye}})),z&&se(Fe=>({...Fe,[z]:X1(pe)})),st({type:"editor.split",editorId:pe,title:Se,direction:"vertical"})}function di(x){up(r,E=>{const z={...E};return delete z[x],z}),st({type:"editor.closed",editorId:x})}function Ra(x){bn([x])}function bn(x){const E=[...new Set(x)].filter(ie=>w.terminals[ie]);if(E.length===0)return;const z=E.length===1?w.terminals[E[0]]?.title||w.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;H(null),Ii({terminalIds:E,label:z,workspaceId:Te?.id??w.activeWorkspaceId??null})}function er(x,E){const z=ts(x,E);if(!z)return!1;const ie=x.filter(ye=>!z.detachedTerminalIds.includes(ye));if(z.detachedTerminalIds.length+ie.length>kl)return H(_5(z.detachedTerminalIds.length)),!1;H(null);for(const ye of x)st(z.id?{type:"terminal.detached",terminalId:ye,workspaceId:z.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Ma(x){await ri(async()=>{for(const E of x)await dr(E),jo(g.createWebSocketUrl(E)),Ru(E),st({type:"terminal.closed",terminalId:E})})}async function Na(x){const E=w.workspaces.find(z=>z.id===x);!E||w.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await ri(async()=>{const z=ch(E),ie=[];let ye=null;for(const Se of z)try{await dr(Se)}catch(Fe){ie.push(Rs(Fe)),Fe instanceof or&&Fe.status===401&&!g.isAgent&&(ye=Fe)}finally{jo(g.createWebSocketUrl(Se)),Ru(Se)}const pe=E.tabs.flatMap(Se=>zm(Se.root));if(pe.length>0){const Se=new Set(pe);up(r,Fe=>{const at={...Fe};for(const Zt of Se)delete at[Zt];return at})}if(st({type:"workspace.closed",workspaceId:x}),ye)throw ye;if(ie.length>0)throw new Error(`Workspace was removed, but ${ie.length} terminal session${ie.length===1?"":"s"} may still be running. ${ie[0]}`)})}async function Ks(x){await ri(async()=>{await dr(x),jo(g.createWebSocketUrl(x)),Ru(x),st({type:"terminal.closed",terminalId:x})})}async function tr(x,E){const z=E.trim();if(!z)return;let ie=null;for(const ye of w.workspaces){const pe=ye.tabs.find(Se=>Se.id===x);if(pe){ie=pe.activeTerminalId;break}}if(st({type:"tab.renamed",tabId:x,title:z}),!!ie)try{const ye=await g.renameTerminal(ie,z);ir({type:"terminal.updated",terminal:ye.terminal})}catch(ye){Ds(r,!0,Rs(ye))}}function hr(x){const E=w.terminals[x];E&&st({type:"terminal.created",terminal:E})}async function dr(x){try{await g.closeTerminal(x)}catch(E){if(E instanceof or&&E.status===404)return;throw E}}async function ln(){await ri(async()=>{await c()})}async function ri(x){Ds(r,!0,null);try{await x()}catch(E){if(Jr(E))return;Ds(r,!0,Rs(E))}}function Jr(x){return x instanceof or&&x.status===401&&!g.isAgent&&h?(h({source:"workspace-api-401",status:401,activeAgentId:r}),!0):!1}function st(x){To(r,x);const E=At(r),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const ie=cp(z);JSON.stringify(ie)!==E.lastPersistedLayoutJson&&tt(ie)}function ir(x){To(r,x)}function Er(x,E,z,ie){const ye=Uo(x,E,z);se(pe=>({...pe,[ye]:ie}))}function kr(x){We&&se(E=>({...E,[We]:x}))}function Ws(x,E){const z=hh(x);E?Er(r,E.workspaceId,E.tabId,z):kr(z),st({type:"pane.selected",terminalId:x})}function Gi(x){kr(x.key),x.type==="terminal"&&st({type:"pane.selected",terminalId:x.terminalId})}function es(x){if(le||Mt||x.isComposing||x.key==="Process"||i5(x.target))return;const E=QA(x);if(!E)return;if(x.preventDefault(),x.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){qs(E.type==="server.next"?1:-1);return}const z=At(r).state,ie=z.workspaces.find(Se=>Se.id===z.activeWorkspaceId)??z.workspaces[0],ye=ie?.tabs.find(Se=>Se.id===ie.activeTabId)??ie?.tabs[0];if(E.type==="split"){if(!ye)return;yn(E.direction);return}if(!ie||!ye)return;if(E.type==="tab.previous"||E.type==="tab.next"){const Se=t5(ie.tabs,ye.id,E.type==="tab.next"?1:-1);Se&&st({type:"tab.selected",tabId:Se.id});return}if(E.type==="tab.index"){const Se=ie.tabs[E.index-1];Se&&st({type:"tab.selected",tabId:Se.id});return}const pe=JA(ye.root,ye.activeTerminalId,E);pe&&Ws(pe,{workspaceId:ie.id,tabId:ye.id})}function Fs(x,E){if(!s||j.length===0)return;const z=j.findIndex(Se=>pn(Se,r)),ye=((z===-1?0:z)+x+j.length)%j.length,pe=j[ye]??null;pn(pe,r)||(E&&(Re.current={agentId:pe,edge:E}),s(pe))}function qs(x){const E=At(r).state,z=E.workspaces;if(z.length===0){Fs(x,x===1?"first":"last");return}const ie=z.findIndex(Se=>Se.id===E.activeWorkspaceId),pe=(ie===-1?0:ie)+x;if(pe>=0&&pe<z.length){st({type:"workspace.selected",workspaceId:z[pe].id});return}Fs(x,x===1?"first":"last")}function fr(x,E){if(pn(x,r)){st({type:"workspace.selected",workspaceId:E});return}ze.current={agentId:x,workspaceId:E},s?.(x)}function ts(x,E){if(E)return w.workspaces.find(z=>z.id===E)??null;for(const z of x){const ie=w.workspaces.find(pe=>pe.tabs.some(Se=>ic(Se).includes(z)));if(ie)return ie;const ye=w.workspaces.find(pe=>pe.detachedTerminalIds.includes(z));if(ye)return ye}return w.workspaces.find(z=>z.id===w.activeWorkspaceId)??w.workspaces[0]??null}function nr(x){c0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function pr(x){if(!c0(x.dataTransfer))return;x.preventDefault();const E=v5(At(r).state),z=be.current+1;if(be.current=z,!E){is({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}is({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),Al(z,E.id,x.dataTransfer)}async function Al(x,E,z){try{const ie=await HA(z);if(ie.length===0)throw new Error("No files were found in the drop.");jn(x,{id:x,status:"queued",fileCount:ie.length,message:"Queued"},{terminalId:E,files:ie})}catch(ie){jn(x,{id:x,status:"failed",fileCount:0,message:Rs(ie)},{terminalId:E})}finally{Zi()}}async function Aa(x){const E=gt.current.find(pe=>pe.id===x);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,ie=E.files,ye=new AbortController;Yi.current=x,jn(x,{id:x,status:"uploading",fileCount:ie.length,loaded:0,total:null,percent:null},{terminalId:z,files:ie,abortController:ye});try{const pe=await X2({terminalId:z,files:ie,signal:ye.signal,onProgress:Zt=>{jn(x,{id:x,status:"uploading",fileCount:ie.length,loaded:Zt.loaded,total:Zt.total,percent:Zt.percent},{terminalId:z,files:ie,abortController:ye})}}),Se=pe.failed>0?pe.uploaded>0?"partial":"failed":"success",Fe=pe.failed>0?y5(pe):void 0,at={id:x,status:Se,fileCount:ie.length,response:pe};Fe&&(at.message=Fe),jn(x,at,{terminalId:z,files:ie})}catch(pe){jn(x,{id:x,status:"failed",fileCount:ie.length,message:ye.signal.aborted?"Upload canceled.":Rs(pe)},{terminalId:z,files:ie})}finally{Yi.current===x&&(Yi.current=null),Zi()}}function Zi(){if(Yi.current!==null)return;const x=gt.current.find(E=>E.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&Aa(x.id)}function is(x){Tr(E=>[...E,x])}function jn(x,E,z={}){Tr(ie=>ie.map(ye=>{if(ye.id!==x)return ye;const pe={...E},Se=z.terminalId??ye.terminalId,Fe=z.files??ye.files;return Se!==void 0&&(pe.terminalId=Se),Fe!==void 0&&(pe.files=Fe),z.abortController!==void 0&&(pe.abortController=z.abortController),pe}))}function Tr(x){const E=x(gt.current);gt.current=E,qt(E)}function Dr(x){gt.current.find(z=>z.id===x)?.abortController?.abort(),Yi.current===x&&(Yi.current=null),Tr(z=>z.filter(ie=>ie.id!==x)),Zi()}function D(){for(const x of gt.current)x.abortController?.abort();Yi.current=null,Tr(()=>[])}function te(x){const E=gt.current.find(z=>z.id===x);if(E){if(E.status==="queued"){Dr(x);return}E.abortController?.abort()}}function Ue(x){const E=gt.current.find(ie=>ie.id===x);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=$e(E);if(z.length===0){jn(x,{id:x,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}jn(x,{id:x,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),Zi()}function $e(x){const E=x.files??[],z="response"in x?x.response:void 0;if(!z)return E;const ie=z.results.filter(Se=>Se.status==="failed").map(Se=>Se.relativePath);if(ie.length===0)return[];const ye=new Map;for(const Se of E){const Fe=ye.get(Se.relativePath)??[];Fe.push(Se),ye.set(Se.relativePath,Fe)}const pe=[];for(const Se of ie){const at=ye.get(Se)?.shift();at&&pe.push(at)}return pe}function Ye(x){const z=At(x.agentId).state.workspaces.find(ie=>ie.tabs.some(ye=>ye.id===x.tabId));z&&Er(x.agentId,z.id,x.tabId,hh(x.terminalId)),To(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),hA(x.agentId,x.terminalId),pn(x.agentId,r)||s?.(x.agentId),Qn(null)}function tt(x){const E=At(r).mutable.saveCoord;E.pendingLayoutSave=x,Ro(x,f),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&si(z)},VA)}function It(){const x=At(r).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const E=x.pendingLayoutSave;x.pendingLayoutSave=null,E&&(Ro(E,f),si(E))}function si(x,E={}){const z=At(r).mutable.saveCoord;z.nextPersistLayout=x,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const ie=z.nextPersistLayout,ye=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,ie&&await St(ie,ye!==void 0?{baseRevision:ye}:{})}))}async function St(x,E={}){const z=At(r),ie=E.baseRevision??z.layoutRevision,ye={layout:x,...typeof ie=="number"?{baseRevision:ie}:{}};try{const pe=await g.saveTerminalLayout(ye),Se=pe.layout??x;Do(r,pe.revision,JSON.stringify(Se)),Ro(Se,f);return}catch(pe){if(pe instanceof or&&pe.status===400&&pe.message===Ik){g5(r,f),Ds(r,!0,Z1());return}if(pe instanceof or&&pe.status===409)try{const Se=await g.getTerminalLayout(),Fe=At(r).mutable.saveCoord;if(Fe.nextPersistLayout||Fe.pendingLayoutSave){const at=Se.layout?JSON.stringify(Se.layout):At(r).lastPersistedLayoutJson;Do(r,Se.revision,at);return}if(Se.layout){const at=At(r).state,Zt=xm(Object.values(at.terminals),void 0,Se.layout.workspaces,Se.layout.activeWorkspaceId),ai=cp(Zt);a0(r,Zt),Do(r,Se.revision,JSON.stringify(ai)),Ro(ai,f)}else Do(r,Se.revision,z.lastPersistedLayoutJson);return}catch{}Ro(x,f)}}const wt=C5(o),Ki=!W||L,Gt=Ki?J:"servers";function Sn(x){const E=x.active?S:At(x.agentId),z=x.active?w:E.state,ie=x.active?S.loaded:E.loaded,ye=x.active?B:E.error;return m.jsxs("div",{className:`workspace-list-panel${x.active?" workspace-list-panel--active-server":""}`,"aria-label":`${x.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${x.label}`,title:"New workspace",onClick:()=>Xi(x.agentId),children:"+"})]}),ie?ye?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(x.agentId),children:ye}):m.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(pe=>{const Se=x.active&&pe.id===Te?.id,Fe=ch(pe).length,at=x.active&&z.workspaces.length>1,Zt=ee?.workspaceId===pe.id&&je!==pe.id?ee.placement:null;return m.jsxs(l5,{workspaceId:pe.id,active:Se,disabled:!x.active,reorderable:at,dragging:je===pe.id,dropPlacement:Zt,children:[at?m.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":je===pe.id,onPointerDown:ai=>Bn(pe.id,ai),onPointerMove:On,onPointerUp:zn,onPointerCancel:Bt,onKeyDown:ai=>{(ai.key==="ArrowUp"||ai.key==="ArrowDown")&&(ai.preventDefault(),ai.stopPropagation(),Da(pe.id,ai.key==="ArrowUp"?-1:1))},onClick:ai=>ai.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Se?"page":void 0,title:pe.defaultCwd??void 0,onClick:()=>fr(x.agentId,pe.id),onDoubleClick:()=>{x.active&&$t(pe.id)},children:[m.jsx("span",{className:"workspace-list-name",children:pe.title}),m.jsxs("small",{children:[pe.defaultCwd??"No folder"," · ",Fe," ",Fe===1?"session":"sessions"]})]}),x.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${pe.title}`,title:"Edit workspace",onClick:()=>$t(pe.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${pe.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Na(pe.id)},children:"x"})]}):null]},pe.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(Bk,{sensors:Le,onDragStart:Ae,onDragEnd:Ie,onDragCancel:Y,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":W,"data-sidebar-open":L,onDragOver:nr,onDrop:pr,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>A(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[Ki?m.jsx(w0,{height:20}):m.jsx(S0,{size:24}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":W?"Expand sidebar":"Collapse sidebar",title:W?"Expand sidebar":"Collapse sidebar",onClick:()=>K(x=>!x),children:W?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>A(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Gt==="files"?"files":"servers"}`,children:[Ki?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":J==="servers",onClick:()=>{ne("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":J==="files",onClick:()=>{ne("files")},children:"Files"})]}):null,Gt==="servers"&&Ki?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(Bb,{api:p,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:h,refreshToken:M,renderServerChildren:Sn})}):null,Ki?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(Bb,{api:p,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:h,refreshToken:M,compact:!0})}),Gt==="files"?m.jsx(eT,{api:g,activeTerminalId:vt,activeTerminalCwd:yi?.cwd??null,workspaceRootPath:Te?.defaultCwd??yi?.cwd??null,onOpenFile:Ot}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[Ki?m.jsx("span",{children:wt}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>oe(!0),children:[m.jsx(f0,{name:"settings"}),ve.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Ki?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{ln()},children:m.jsx(f0,{name:"logout"})}):null]})]})]}),le?m.jsx($2,{api:p,onClose:()=>oe(!1),updateAvailable:ve.hasUpdates,onNotificationAssetsChanged:()=>{Ni()},onAgentRemoved:Si}):null,_e?m.jsx(n5,{dialog:_e,activePaneCwd:yi?.cwd??null,activeWorkspaceCwd:Te?.defaultCwd??null,onChange:Nl,onManualCwdChange:tn,onBrowse:Ln,onCancel:en,onSubmit:()=>{Is()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":rt?"true":void 0,children:[m.jsx(gA,{tabs:Te?.tabs??[],activeTabId:Te?.activeTabId??null,terminals:w.terminals,unreadCompletionTabIds:zt,detachedTerminals:Ft,onSelectTab:x=>st({type:"tab.selected",tabId:x}),onCreateTab:()=>{Jn()},onToggleWorkspaces:()=>A(x=>!x),onCloseTerminals:x=>bn(x),onReattachTerminal:x=>hr(x),onDeleteTerminal:x=>{Ks(x)},onSplitVertical:()=>{yn("vertical")},onSplitHorizontal:()=>{yn("horizontal")},onRenameTab:(x,E)=>{tr(x,E)},activePaneAvailable:!!vt}),rt?m.jsx(c5,{targets:ge,activeLeafKey:dt,terminals:w.terminals,editors:k,onSelect:Gi}):null,B?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:B}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:_n,children:"Retry"}),r!==null&&s?m.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":T,children:[T?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!T&&!He?m.jsx(a5,{onCreate:()=>{Jn()}}):null,Z.map(x=>{const E=pn(x,r);return m.jsx(ZA,{agentId:x,active:E,activeServerApi:E?g:void 0,visitedTabKeys:ke,refreshCwdOnEnter:E&&Gt==="files",draggingTab:E?ce:null,mobileSplitFocus:Ri,mobileFocusedLeafByTabKey:G,onSelect:z=>{E&&Ws(z)},onClose:z=>{E&&Ra(z)},onCloseEditor:z=>{E&&di(z)},onResize:(z,ie)=>{E&&st({type:"pane.resized",path:z,ratio:ie})},onExit:(z,ie)=>{E?ir({type:"terminal.exited",terminalId:z,exitCode:ie}):To(x,{type:"terminal.exited",terminalId:z,exitCode:ie})},onSnapshot:(z,ie)=>{const ye={type:"terminal.updated",terminal:z,notifyCompletion:ie?.notifyCompletion===!0};E?ir(ye):To(x,ye)},...x===null&&h?{onAuthClose:z=>h({...z,source:z?.source??"terminal-ws-1008",activeAgentId:x})}:{}},qu(x))})]}),Mt?m.jsx(o5,{label:Mt.label,count:Mt.terminalIds.length,warning:F,onCancel:()=>{H(null),Ii(null)},onHide:()=>{er(Mt.terminalIds,Mt.workspaceId)&&Ii(null)},onDelete:()=>{const x=Mt.terminalIds;H(null),Ii(null),Ma(x)}}):null,m.jsx(DA,{toast:gn,onActivate:Ye,onDismiss:()=>Qn(null)}),m.jsx(SA,{uploads:ii,onDismiss:Dr,onDismissAll:D,onRetry:Ue,onCancel:te})]})]})})}function ZA({agentId:e,active:t,activeServerApi:r,visitedTabKeys:s,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,onAuthClose:k}){const T=v.useMemo(()=>ve=>U1(e,ve),[e]),B=v.useMemo(()=>()=>At(e),[e]),L=v.useSyncExternalStore(T,B,B),A=v.useMemo(()=>Yo(e),[e]),W=r??A,K=L.state,J=K.workspaces.find(ve=>ve.id===K.activeWorkspaceId)??K.workspaces[0],ne=J?.id??null,oe=(J?.tabs.find(ve=>ve.id===J.activeTabId)??J?.tabs[0])?.id??null;return!L.loaded||K.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:K.workspaces.flatMap(ve=>ve.tabs.map(P=>{const I=t&&ve.id===ne&&P.id===oe,F=Uo(e,ve.id,P.id),H=uh(P.root),j=h&&H.length>1?Y1(H,P.activeTerminalId,p[F]):null;return!I&&!s.has(F)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":I,"aria-hidden":!I,children:m.jsx(Sm,{node:P.root,terminals:K.terminals,editors:L.editors,api:W,activeTerminalId:P.activeTerminalId,visible:I,refreshCwdOnEnter:I&&o,tabId:P.id,dropZoneActive:I&&c!==null,draggingTerminalId:I?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,...k?{onAuthClose:k}:{}})},`${ve.id}:${P.id}`)}))})}function QA(e){const t=rw(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 r=e5(e.key);return r?{type:"pane.direction",direction:r}:null}return null}function JA(e,t,r){switch(r.type){case"pane.direction":return NA(e,t,r.direction);case"pane.index":return AA(e,r.index);default:return null}}function e5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function t5(e,t,r){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+r+e.length)%e.length]??null}function uh(e){return e.type==="pane"?[{key:hh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:X1(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...uh(e.first),...uh(e.second)]}function zm(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...zm(e.first),...zm(e.second)]}function Y1(e,t,r){if(r&&e.some(o=>o.key===r))return r;const s=t?hh(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function hh(e){return`terminal:${e}`}function X1(e){return`editor:${e}`}function i5(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 n5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:r,onChange:s,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function y(w){s(k=>k&&{...k,...w})}function S(w){w&&(y({cwd:w,error:null}),c(w))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||p()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:w=>y({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:b,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(r),disabled:b||!r,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(s5(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{c(r5(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function r5(e,t){return t?t.startsWith("/")?Fu(t):Fu(`${e||"/"}/${t}`):Fu(e)}function s5(e){const t=Fu(e);if(!t||t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function Fu(e){const t=e.trim();if(!t)return"";const r=t.replace(/\/+/g,"/");return r==="/"?"/":r.endsWith("/")?r.slice(0,-1):r}function a5({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function l5({workspaceId:e,active:t,disabled:r=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=Gm({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:r}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function o5({label:e,count:t,warning:r,onCancel:s,onHide:o,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),r?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:r}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function c5({targets:e,activeLeafKey:t,terminals:r,editors:s,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(S=>S.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],b=d0(f,r,s);function y(S){const w=(g+S+e.length)%e.length,k=e[w];k&&o(k)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const k=d0(S,r,s),T=u5(S,r,s),B=S.key===f.key;return m.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:k}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function d0(e,t,r){if(e.type==="editor")return r[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function u5(e,t,r){if(e.type==="editor"){const c=r[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function h5(e){const[t,r]=v.useState(()=>d5(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){r(!1);return}const s=window.matchMedia(e),o=()=>r(s.matches);return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):(s.addListener(o),()=>s.removeListener(o))},[e]),t}function d5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function pn(e,t){return e===t}function f5(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function qu(e){return e??"__local__"}function Uo(e,t,r){return`${qu(e)}:${t}:${r}`}class dh extends Error{constructor(){super(Z1())}}function p5(e){return e?{workspaceKey:`${u0}:${e}`}:{workspaceKey:u0}}function m5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const r=JSON.parse(t);if(F0(r))throw new dh;const s=W0(r);return s?G1(s):null}catch(r){if(r instanceof dh)throw r;return null}}function G1(e){if(F0(e))throw new dh;const t=W0(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Ro(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function g5(e,t){const r=At(e).lastPersistedLayoutJson;if(r){localStorage.setItem(t.workspaceKey,r);return}localStorage.removeItem(t.workspaceKey)}function _5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${kl}. Re-open or delete hidden sessions before hiding more.`}function Z1(){return`A saved terminal layout has more than ${kl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function v5(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],r=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],s=r?e.terminals[r.activeTerminalId]:void 0;return s?.status==="running"?s:null}function y5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function b5(e){return e.split("/").filter(Boolean).pop()??e}function S5(){try{return localStorage.getItem(V1)==="true"}catch{return!1}}function w5(e){try{localStorage.setItem(V1,e?"true":"false")}catch{}}function C5(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const r=t-Date.now();if(r<=0)return"session · expired";const s=Math.max(1,Math.floor(r/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function f0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function Rs(e){return e instanceof Error?e.message:"Request failed"}function x5({api:e,onDone:t}){const[r,s]=v.useState(null),[o,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(B=>{T||(s(B.qrDataUrl),c(B.secret))}).catch(B=>{T||w(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function k(T){if(T.preventDefault(),!!o){f(!0),y(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(B){y(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!r||!o?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.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."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:r,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:o})]}),m.jsxs("form",{className:"auth-form",onSubmit:k,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>p(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?m.jsx("p",{className:"form-error",children:b}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}const Q1="nterminal.clientDiagnostics.v1",J1=150,E5=24,k5=160;let p0=!1,Mo=null;function T5(){p0||typeof window>"u"||(p0=!0,Nn("page.load",{navigation:j5(),visibility:document.visibilityState,online:navigator.onLine,viewport:iC(),standalone:z5()}),document.addEventListener("visibilitychange",()=>{Nn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Nn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Nn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Nn("network.online")),window.addEventListener("offline",()=>Nn("network.offline")),window.addEventListener("focus",()=>Nn("window.focus")),window.addEventListener("blur",()=>Nn("window.blur")),window.addEventListener("error",e=>{Nn("runtime.error",{message:e.message,source:H5(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Nn("runtime.unhandledrejection",{reason:P5(e.reason)})}))}function Nn(e,t={}){const r={at:new Date().toISOString(),event:Nh(e,80),data:tC({...t,visibility:t.visibility??B5(),online:t.online??O5(),viewport:t.viewport??iC()})},s=eC();return s.push(r),D5(s.slice(-J1)),r}function eC(){try{const e=window.localStorage.getItem(Q1);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(R5).filter(r=>r!==null).slice(-J1):[]}catch{return[]}}async function Ag(e,t=fetch){if(Mo)return Mo;const r=eC(),s={reason:Nh(e,80),events:r},o=JSON.stringify(s);Mo=(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 Mo}finally{Mo=null}}function D5(e){try{window.localStorage.setItem(Q1,JSON.stringify(e))}catch{}}function R5(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:Nh(t.event,80),...t.data&&typeof t.data=="object"?{data:tC(t.data)}:{}}}function tC(e){const t={};for(const[r,s]of Object.entries(e).slice(0,E5)){const o=Nh(r,64);if(!o||M5(o))continue;const c=N5(s);c!==void 0&&(t[o]=c)}return t}function M5(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function N5(e){if(typeof e=="string")return A5(e,k5);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Nh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function A5(e,t){return L5(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function L5(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 B5(){return typeof document>"u"?void 0:document.visibilityState}function O5(){return typeof navigator>"u"?void 0:navigator.onLine}function iC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function z5(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function j5(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function H5(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 P5(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function U5(e){return{source:dp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:dp(e.terminalId)}:{},...e?.detail?{detail:dp(e.detail)}:{}}}function I5(e){return{invalidationSource:e.source}}function K5(e){Nn("auth.session_invalid.request",nC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Ag("session-invalid-request").catch(()=>{}))}function W5(e,t){Nn("auth.session_invalid.result",{...nC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Ag("session-invalid-result").catch(()=>{}))}function nC(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 dp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function F5({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s}){const o=v.useMemo(()=>e??fh(),[e]),c=v.useMemo(()=>t??Yo(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let L=!1;return o.getSession().then(A=>{L||(p(A),f(null))}).catch(A=>{L||(f(ya(A)),p(null))}),()=>{L=!0}},[o]);const S=Y5(h);v.useEffect(()=>{const L=y.current;Nn("auth.view",{view:S,previousView:L,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),L==="workspace"&&S!=="workspace"&&Ag(`auth-left-workspace-${S}`).catch(()=>{}),y.current=S},[h,S]);async function w(){const L=await o.getSession();p(L),f(null)}async function k(){rp(),hp(),KS(),f(null),p(null);try{await w()}catch(L){f(ya(L))}}function T(L){const A=U5(L);if(K5(A),b.current)return b.current;const W=(async()=>{f(null);try{const K=await o.getSession(I5(A));if(W5(A,K.authenticated),p(K),K.authenticated){vN();return}rp(),hp(),KS()}catch(K){f(ya(K))}finally{b.current=null}})();return b.current=W,W}if(S==="workspace")return m.jsx(GA,{api:o,serverApi:c,activeAgentId:r,onSelectServer:s,sessionExpiresAt:h?.expiresAt??null,onSessionInvalid:L=>{T(L)},onLogout:async()=>{rp(),hp();const L=await o.logout();p(L)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(S0,{size:26}),m.jsxs("div",{children:[m.jsx(w0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:B[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},children:"Retry"}):null,S==="setup_password"?m.jsx(q5,{api:o,onSession:L=>{p(L)}}):null,S==="setup_totp"?m.jsx(x5,{api:o,onDone:()=>{w()}}):null,S==="login"?m.jsx($5,{api:o,session:h,onSession:p,onRefresh:w}):null,S==="reauth"?m.jsx(V5,{api:o,session:h,onSession:p,onFullLogin:()=>p(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function q5({api:e,onSession:t}){const[r,s]=v.useState(""),[o,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function b(y){y.preventDefault(),p(!0),f(null);try{if(r!==o){f("Passwords do not match");return}t(await e.setupPassword({password:r}))}catch(S){f(ya(S))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:b,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:r,onChange:y=>s(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:o,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||r.length<8||o.length<8,children:"Set password"})]})}function $5({api:e,session:t,onSession:r,onRefresh:s}){const[o,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(!1),[S,w]=v.useState(null),k=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function B(L){L.preventDefault(),y(!0),w(null);try{r(await e.login({password:o,...k?{otp:h}:{},rememberNetwork:g}))}catch(A){w(ya(A))}finally{y(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:B,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:L=>c(L.currentTarget.value),required:!0})]}),k?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:L=>p(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:L=>f(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||o.length===0||k&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function V5({api:e,session:t,onSession:r,onFullLogin:s}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,b]=v.useState(!1),[y,S]=v.useState(!1),[w,k]=v.useState(!1),[T,B]=v.useState(null),L=Ti.useCallback(async(W,K)=>{b(!0),B(null);try{r(await e.reauth({...W?{otp:W}:{},rememberNetwork:K}))}catch(J){B(ya(J))}finally{b(!1)}},[e,r]);v.useEffect(()=>{if(o){let W=!1;S(!0),k(!1),B(null);const K=window.setTimeout(()=>{W||k(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(J=>{W||r(J)}).catch(J=>{W||(B(ya(J)),k(!0))}).finally(()=>{window.clearTimeout(K),W||S(!1)}),()=>{W=!0,window.clearTimeout(K)}}},[e,o,r]);async function A(W){W.preventDefault(),await L(c,p)}return o&&y&&!w&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:A,children:[o&&w&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:W=>h(W.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:W=>g(W.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?m.jsx("p",{className:"form-error",children:T}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function Y5(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ya(e){return e instanceof Error?e.message:"Request failed"}const m0="NTerminal",jm="nterminal.activeAgentId";function X5(){const[e,t]=v.useState(()=>G5()),r=v.useMemo(()=>fh(),[]),s=v.useMemo(()=>Yo(e),[e]);v.useEffect(()=>{const c=()=>{const h=uA();document.title=h>0?`(${h}) ${m0}`:m0};return c(),cA(c)},[]);function o(c){Z5(c),t(c)}return m.jsx(F5,{api:r,activeAgentId:e,serverApi:s,onSelectServer:o})}function G5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(jm);return e&&e.trim()?e:null}catch{return null}}function Z5(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(jm,e);return}window.localStorage.removeItem(jm)}catch{}}const g0=["gesturestart","gesturechange","gestureend"],Q5=[".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 J5(e=window){if(!tL(e))return()=>{};const t={passive:!1},r=e.document;function s(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!eL(c.target))&&s(c)}for(const c of g0)r.addEventListener(c,s,t);return r.addEventListener("touchmove",o,t),r.addEventListener("dblclick",s,t),()=>{for(const c of g0)r.removeEventListener(c,s,t);r.removeEventListener("touchmove",o,t),r.removeEventListener("dblclick",s,t)}}function eL(e){return e instanceof Element&&e.closest(Q5)!==null}function tL(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}T5();MM();J5();Km();pE.createRoot(document.getElementById("root")).render(m.jsx(Ti.StrictMode,{children:m.jsx(X5,{})}));export{Ti as R,sE as g,m as j};