nterminal 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/assets/MarkdownPreview-D3Oa7_1H.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-CWvFo7OT.js → TranscriptMarkdownBody-Dd6cp7t2.js} +1 -1
- package/dist/client/assets/index-BOvp6zV9.js +58 -0
- package/dist/client/assets/index-CWRDvfyP.css +1 -0
- package/dist/client/assets/{index-Cc-QI7Ho.js → index-DJwOCZv_.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/accounts/accountService.d.ts +5 -2
- package/dist/server/accounts/accountService.js +172 -49
- package/dist/server/accounts/accountService.js.map +1 -1
- package/dist/server/agent/agentRoutes.js +2 -2
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/routes/agentManagementRoutes.d.ts +2 -0
- package/dist/server/routes/agentManagementRoutes.js +2 -2
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/server/system/stats.d.ts +4 -1
- package/dist/server/system/stats.js +6 -0
- package/dist/server/system/stats.js.map +1 -1
- package/dist/shared/accountRelogin.d.ts +3 -0
- package/dist/shared/accountRelogin.js +21 -0
- package/dist/shared/accountRelogin.js.map +1 -0
- package/dist/shared/protocol.d.ts +7 -0
- package/dist/shared/protocol.js.map +1 -1
- package/docs/features.md +3 -2
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-Bx3a_UAM.js +0 -1
- package/dist/client/assets/index-BdHPdvab.js +0 -58
- package/dist/client/assets/index-W-zGfY1a.css +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-D3Oa7_1H.js","assets/index-DJwOCZv_.js","assets/TranscriptMarkdownBody-Dd6cp7t2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function ZR(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rg={exports:{}},Du={};var Ww;function QR(){if(Ww)return Du;Ww=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var d=null;if(l!==void 0&&(d=""+l),o.key!==void 0&&(d=""+o.key),"key"in o){l={};for(var f in o)f!=="key"&&(l[f]=o[f])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:d,ref:o!==void 0?o:null,props:l}}return Du.Fragment=t,Du.jsx=n,Du.jsxs=n,Du}var Kw;function JR(){return Kw||(Kw=1,Rg.exports=QR()),Rg.exports}var u=JR(),Dg={exports:{}},bt={};var qw;function eD(){if(qw)return bt;qw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),w=Symbol.iterator;function C(N){return N===null||typeof N!="object"?null:(N=w&&N[w]||N["@@iterator"],typeof N=="function"?N:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,A={};function M(N,Y,oe){this.props=N,this.context=Y,this.refs=A,this.updater=oe||x}M.prototype.isReactComponent={},M.prototype.setState=function(N,Y){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,Y,"setState")},M.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function W(){}W.prototype=M.prototype;function U(N,Y,oe){this.props=N,this.context=Y,this.refs=A,this.updater=oe||x}var P=U.prototype=new W;P.constructor=U,T(P,M.prototype),P.isPureReactComponent=!0;var F=Array.isArray;function V(){}var O={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function fe(N,Y,oe){var Q=oe.ref;return{$$typeof:e,type:N,key:Y,ref:Q!==void 0?Q:null,props:oe}}function ee(N,Y){return fe(N.type,Y,N.props)}function te(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function $(N){var Y={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(oe){return Y[oe]})}var Z=/\/+/g;function ie(N,Y){return typeof N=="object"&&N!==null&&N.key!=null?$(""+N.key):Y.toString(36)}function J(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(V,V):(N.status="pending",N.then(function(Y){N.status==="pending"&&(N.status="fulfilled",N.value=Y)},function(Y){N.status==="pending"&&(N.status="rejected",N.reason=Y)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function j(N,Y,oe,Q,we){var Se=typeof N;(Se==="undefined"||Se==="boolean")&&(N=null);var ue=!1;if(N===null)ue=!0;else switch(Se){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(N.$$typeof){case e:case t:ue=!0;break;case b:return ue=N._init,j(ue(N._payload),Y,oe,Q,we)}}if(ue)return we=we(N),ue=Q===""?"."+ie(N,0):Q,F(we)?(oe="",ue!=null&&(oe=ue.replace(Z,"$&/")+"/"),j(we,Y,oe,"",function(ge){return ge})):we!=null&&(te(we)&&(we=ee(we,oe+(we.key==null||N&&N.key===we.key?"":(""+we.key).replace(Z,"$&/")+"/")+ue)),Y.push(we)),1;ue=0;var Re=Q===""?".":Q+":";if(F(N))for(var Oe=0;Oe<N.length;Oe++)Q=N[Oe],Se=Re+ie(Q,Oe),ue+=j(Q,Y,oe,Se,we);else if(Oe=C(N),typeof Oe=="function")for(N=Oe.call(N),Oe=0;!(Q=N.next()).done;)Q=Q.value,Se=Re+ie(Q,Oe++),ue+=j(Q,Y,oe,Se,we);else if(Se==="object"){if(typeof N.then=="function")return j(J(N),Y,oe,Q,we);throw Y=String(N),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ue}function R(N,Y,oe){if(N==null)return N;var Q=[],we=0;return j(N,Q,"","",function(Se){return Y.call(oe,Se,we++)}),Q}function I(N){if(N._status===-1){var Y=N._result;Y=Y(),Y.then(function(oe){(N._status===0||N._status===-1)&&(N._status=1,N._result=oe)},function(oe){(N._status===0||N._status===-1)&&(N._status=2,N._result=oe)}),N._status===-1&&(N._status=0,N._result=Y)}if(N._status===1)return N._result.default;throw N._result}var re=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},_e={map:R,forEach:function(N,Y,oe){R(N,function(){Y.apply(this,arguments)},oe)},count:function(N){var Y=0;return R(N,function(){Y++}),Y},toArray:function(N){return R(N,function(Y){return Y})||[]},only:function(N){if(!te(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return bt.Activity=_,bt.Children=_e,bt.Component=M,bt.Fragment=n,bt.Profiler=o,bt.PureComponent=U,bt.StrictMode=r,bt.Suspense=g,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,bt.__COMPILER_RUNTIME={__proto__:null,c:function(N){return O.H.useMemoCache(N)}},bt.cache=function(N){return function(){return N.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function(N,Y,oe){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Q=T({},N.props),we=N.key;if(Y!=null)for(Se in Y.key!==void 0&&(we=""+Y.key),Y)!G.call(Y,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Y.ref===void 0||(Q[Se]=Y[Se]);var Se=arguments.length-2;if(Se===1)Q.children=oe;else if(1<Se){for(var ue=Array(Se),Re=0;Re<Se;Re++)ue[Re]=arguments[Re+2];Q.children=ue}return fe(N.type,we,Q)},bt.createContext=function(N){return N={$$typeof:d,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:l,_context:N},N},bt.createElement=function(N,Y,oe){var Q,we={},Se=null;if(Y!=null)for(Q in Y.key!==void 0&&(Se=""+Y.key),Y)G.call(Y,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(we[Q]=Y[Q]);var ue=arguments.length-2;if(ue===1)we.children=oe;else if(1<ue){for(var Re=Array(ue),Oe=0;Oe<ue;Oe++)Re[Oe]=arguments[Oe+2];we.children=Re}if(N&&N.defaultProps)for(Q in ue=N.defaultProps,ue)we[Q]===void 0&&(we[Q]=ue[Q]);return fe(N,Se,we)},bt.createRef=function(){return{current:null}},bt.forwardRef=function(N){return{$$typeof:f,render:N}},bt.isValidElement=te,bt.lazy=function(N){return{$$typeof:b,_payload:{_status:-1,_result:N},_init:I}},bt.memo=function(N,Y){return{$$typeof:p,type:N,compare:Y===void 0?null:Y}},bt.startTransition=function(N){var Y=O.T,oe={};O.T=oe;try{var Q=N(),we=O.S;we!==null&&we(oe,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(V,re)}catch(Se){re(Se)}finally{Y!==null&&oe.types!==null&&(Y.types=oe.types),O.T=Y}},bt.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},bt.use=function(N){return O.H.use(N)},bt.useActionState=function(N,Y,oe){return O.H.useActionState(N,Y,oe)},bt.useCallback=function(N,Y){return O.H.useCallback(N,Y)},bt.useContext=function(N){return O.H.useContext(N)},bt.useDebugValue=function(){},bt.useDeferredValue=function(N,Y){return O.H.useDeferredValue(N,Y)},bt.useEffect=function(N,Y){return O.H.useEffect(N,Y)},bt.useEffectEvent=function(N){return O.H.useEffectEvent(N)},bt.useId=function(){return O.H.useId()},bt.useImperativeHandle=function(N,Y,oe){return O.H.useImperativeHandle(N,Y,oe)},bt.useInsertionEffect=function(N,Y){return O.H.useInsertionEffect(N,Y)},bt.useLayoutEffect=function(N,Y){return O.H.useLayoutEffect(N,Y)},bt.useMemo=function(N,Y){return O.H.useMemo(N,Y)},bt.useOptimistic=function(N,Y){return O.H.useOptimistic(N,Y)},bt.useReducer=function(N,Y,oe){return O.H.useReducer(N,Y,oe)},bt.useRef=function(N){return O.H.useRef(N)},bt.useState=function(N){return O.H.useState(N)},bt.useSyncExternalStore=function(N,Y,oe){return O.H.useSyncExternalStore(N,Y,oe)},bt.useTransition=function(){return O.H.useTransition()},bt.version="19.2.6",bt}var Vw;function Lb(){return Vw||(Vw=1,Dg.exports=eD()),Dg.exports}var v=Lb();const zt=ZR(v);var Ng={exports:{}},Nu={},Mg={exports:{}},Ag={};var Yw;function tD(){return Yw||(Yw=1,(function(e){function t(j,R){var I=j.length;j.push(R);e:for(;0<I;){var re=I-1>>>1,_e=j[re];if(0<o(_e,R))j[re]=R,j[I]=_e,I=re;else break e}}function n(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var R=j[0],I=j.pop();if(I!==R){j[0]=I;e:for(var re=0,_e=j.length,N=_e>>>1;re<N;){var Y=2*(re+1)-1,oe=j[Y],Q=Y+1,we=j[Q];if(0>o(oe,I))Q<_e&&0>o(we,oe)?(j[re]=we,j[Q]=I,re=Q):(j[re]=oe,j[Y]=I,re=Y);else if(Q<_e&&0>o(we,I))j[re]=we,j[Q]=I,re=Q;else break e}}return R}function o(j,R){var I=j.sortIndex-R.sortIndex;return I!==0?I:j.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var g=[],p=[],b=1,_=null,w=3,C=!1,x=!1,T=!1,A=!1,M=typeof setTimeout=="function"?setTimeout:null,W=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function P(j){for(var R=n(p);R!==null;){if(R.callback===null)r(p);else if(R.startTime<=j)r(p),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(p)}}function F(j){if(T=!1,P(j),!x)if(n(g)!==null)x=!0,V||(V=!0,$());else{var R=n(p);R!==null&&J(F,R.startTime-j)}}var V=!1,O=-1,G=5,fe=-1;function ee(){return A?!0:!(e.unstable_now()-fe<G)}function te(){if(A=!1,V){var j=e.unstable_now();fe=j;var R=!0;try{e:{x=!1,T&&(T=!1,W(O),O=-1),C=!0;var I=w;try{t:{for(P(j),_=n(g);_!==null&&!(_.expirationTime>j&&ee());){var re=_.callback;if(typeof re=="function"){_.callback=null,w=_.priorityLevel;var _e=re(_.expirationTime<=j);if(j=e.unstable_now(),typeof _e=="function"){_.callback=_e,P(j),R=!0;break t}_===n(g)&&r(g),P(j)}else r(g);_=n(g)}if(_!==null)R=!0;else{var N=n(p);N!==null&&J(F,N.startTime-j),R=!1}}break e}finally{_=null,w=I,C=!1}R=void 0}}finally{R?$():V=!1}}}var $;if(typeof U=="function")$=function(){U(te)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,ie=Z.port2;Z.port1.onmessage=te,$=function(){ie.postMessage(null)}}else $=function(){M(te,0)};function J(j,R){O=M(function(){j(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(j){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var I=w;w=R;try{return j()}finally{w=I}},e.unstable_requestPaint=function(){A=!0},e.unstable_runWithPriority=function(j,R){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var I=w;w=j;try{return R()}finally{w=I}},e.unstable_scheduleCallback=function(j,R,I){var re=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?re+I:re):I=re,j){case 1:var _e=-1;break;case 2:_e=250;break;case 5:_e=1073741823;break;case 4:_e=1e4;break;default:_e=5e3}return _e=I+_e,j={id:b++,callback:R,priorityLevel:j,startTime:I,expirationTime:_e,sortIndex:-1},I>re?(j.sortIndex=I,t(p,j),n(g)===null&&j===n(p)&&(T?(W(O),O=-1):T=!0,J(F,I-re))):(j.sortIndex=_e,t(g,j),x||C||(x=!0,V||(V=!0,$()))),j},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(j){var R=w;return function(){var I=w;w=R;try{return j.apply(this,arguments)}finally{w=I}}}})(Ag)),Ag}var Gw;function nD(){return Gw||(Gw=1,Mg.exports=tD()),Mg.exports}var Lg={exports:{}},Ri={};var Xw;function iD(){if(Xw)return Ri;Xw=1;var e=Lb();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)p+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(g,p,b){var _=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:_==null?null:""+_,children:g,containerInfo:p,implementation:b}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Ri.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ri.createPortal=function(g,p){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return l(g,p,null,b)},Ri.flushSync=function(g){var p=d.T,b=r.p;try{if(d.T=null,r.p=2,g)return g()}finally{d.T=p,r.p=b,r.d.f()}},Ri.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},Ri.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Ri.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var b=p.as,_=f(b,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,C=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;b==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:_,integrity:w,fetchPriority:C}):b==="script"&&r.d.X(g,{crossOrigin:_,integrity:w,fetchPriority:C,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Ri.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var b=f(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},Ri.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var b=p.as,_=f(b,p.crossOrigin);r.d.L(g,b,{crossOrigin:_,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Ri.preloadModule=function(g,p){if(typeof g=="string")if(p){var b=f(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},Ri.requestFormReset=function(g){r.d.r(g)},Ri.unstable_batchedUpdates=function(g,p){return g(p)},Ri.useFormState=function(g,p,b){return d.H.useFormState(g,p,b)},Ri.useFormStatus=function(){return d.H.useHostTransitionStatus()},Ri.version="19.2.6",Ri}var Zw;function MC(){if(Zw)return Lg.exports;Zw=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(),Lg.exports=iD(),Lg.exports}var Qw;function sD(){if(Qw)return Nu;Qw=1;var e=nD(),t=Lb(),n=MC();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function d(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(l(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=l(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,c=s;;){var h=a.return;if(h===null)break;var m=h.alternate;if(m===null){if(c=h.return,c!==null){a=c;continue}break}if(h.child===m.child){for(m=h.child;m;){if(m===a)return g(h),i;if(m===c)return g(h),s;m=m.sibling}throw Error(r(188))}if(a.return!==c.return)a=h,c=m;else{for(var y=!1,D=h.child;D;){if(D===a){y=!0,a=h,c=m;break}if(D===c){y=!0,c=h,a=m;break}D=D.sibling}if(!y){for(D=m.child;D;){if(D===a){y=!0,a=m,c=h;break}if(D===c){y=!0,c=m,a=h;break}D=D.sibling}if(!y)throw Error(r(189))}}if(a.alternate!==c)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function b(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=b(i),s!==null)return s;i=i.sibling}return null}var _=Object.assign,w=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),W=Symbol.for("react.consumer"),U=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),fe=Symbol.for("react.activity"),ee=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function $(i){return i===null||typeof i!="object"?null:(i=te&&i[te]||i["@@iterator"],typeof i=="function"?i:null)}var Z=Symbol.for("react.client.reference");function ie(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Z?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case M:return"Profiler";case A:return"StrictMode";case F:return"Suspense";case V:return"SuspenseList";case fe:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case U:return i.displayName||"Context";case W:return(i._context.displayName||"Context")+".Consumer";case P:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case O:return s=i.displayName||null,s!==null?s:ie(i.type)||"Memo";case G:s=i._payload,i=i._init;try{return ie(i(s))}catch{}}return null}var J=Array.isArray,j=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},re=[],_e=-1;function N(i){return{current:i}}function Y(i){0>_e||(i.current=re[_e],re[_e]=null,_e--)}function oe(i,s){_e++,re[_e]=i.current,i.current=s}var Q=N(null),we=N(null),Se=N(null),ue=N(null);function Re(i,s){switch(oe(Se,s),oe(we,i),oe(Q,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?fw(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=fw(s),i=pw(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Y(Q),oe(Q,i)}function Oe(){Y(Q),Y(we),Y(Se)}function ge(i){i.memoizedState!==null&&oe(ue,i);var s=Q.current,a=pw(s,i.type);s!==a&&(oe(we,i),oe(Q,a))}function He(i){we.current===i&&(Y(Q),Y(we)),ue.current===i&&(Y(ue),ku._currentValue=I)}var Be,L;function ve(i){if(Be===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);Be=s&&s[1]||"",L=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Be+i+L}var Le=!1;function Pe(i,s){if(!i||Le)return"";Le=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(s){var Ee=function(){throw Error()};if(Object.defineProperty(Ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ee,[])}catch(ye){var me=ye}Reflect.construct(i,[],Ee)}else{try{Ee.call()}catch(ye){me=ye}i.call(Ee.prototype)}}else{try{throw Error()}catch(ye){me=ye}(Ee=i())&&typeof Ee.catch=="function"&&Ee.catch(function(){})}}catch(ye){if(ye&&me&&typeof ye.stack=="string")return[ye.stack,me.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=c.DetermineComponentFrameRoot(),y=m[0],D=m[1];if(y&&D){var z=y.split(`
|
|
5
|
+
`),he=D.split(`
|
|
6
|
+
`);for(h=c=0;c<z.length&&!z[c].includes("DetermineComponentFrameRoot");)c++;for(;h<he.length&&!he[h].includes("DetermineComponentFrameRoot");)h++;if(c===z.length||h===he.length)for(c=z.length-1,h=he.length-1;1<=c&&0<=h&&z[c]!==he[h];)h--;for(;1<=c&&0<=h;c--,h--)if(z[c]!==he[h]){if(c!==1||h!==1)do if(c--,h--,0>h||z[c]!==he[h]){var xe=`
|
|
7
|
+
`+z[c].replace(" at new "," at ");return i.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",i.displayName)),xe}while(1<=c&&0<=h);break}}}finally{Le=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?ve(a):""}function H(i,s){switch(i.tag){case 26:case 27:case 5:return ve(i.type);case 16:return ve("Lazy");case 13:return i.child!==s&&s!==null?ve("Suspense Fallback"):ve("Suspense");case 19:return ve("SuspenseList");case 0:case 15:return Pe(i.type,!1);case 11:return Pe(i.type.render,!1);case 1:return Pe(i.type,!0);case 31:return ve("Activity");default:return""}}function de(i){try{var s="",a=null;do s+=H(i,a),a=i,i=i.return;while(i);return s}catch(c){return`
|
|
8
|
+
Error generating stack: `+c.message+`
|
|
9
|
+
`+c.stack}}var Te=Object.prototype.hasOwnProperty,Me=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,be=e.unstable_shouldYield,Fe=e.unstable_requestPaint,We=e.unstable_now,Ue=e.unstable_getCurrentPriorityLevel,ut=e.unstable_ImmediatePriority,_t=e.unstable_UserBlockingPriority,lt=e.unstable_NormalPriority,Nt=e.unstable_LowPriority,Yt=e.unstable_IdlePriority,st=e.log,On=e.unstable_setDisableYieldValue,Sn=null,dt=null;function Lt(i){if(typeof st=="function"&&On(i),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Sn,i)}catch{}}var Ct=Math.clz32?Math.clz32:pe,gi=Math.log,ki=Math.LN2;function pe(i){return i>>>=0,i===0?32:31-(gi(i)/ki|0)|0}var Ze=256,at=262144,mt=4194304;function St(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function It(i,s,a){var c=i.pendingLanes;if(c===0)return 0;var h=0,m=i.suspendedLanes,y=i.pingedLanes;i=i.warmLanes;var D=c&134217727;return D!==0?(c=D&~m,c!==0?h=St(c):(y&=D,y!==0?h=St(y):a||(a=D&~i,a!==0&&(h=St(a))))):(D=c&~m,D!==0?h=St(D):y!==0?h=St(y):a||(a=c&~i,a!==0&&(h=St(a)))),h===0?0:s!==0&&s!==h&&(s&m)===0&&(m=h&-h,a=s&-s,m>=a||m===32&&(a&4194048)!==0)?s:h}function $t(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function dn(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=mt;return mt<<=1,(mt&62914560)===0&&(mt=4194304),i}function rn(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function hn(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function an(i,s,a,c,h,m){var y=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 D=i.entanglements,z=i.expirationTimes,he=i.hiddenUpdates;for(a=y&~a;0<a;){var xe=31-Ct(a),Ee=1<<xe;D[xe]=0,z[xe]=-1;var me=he[xe];if(me!==null)for(he[xe]=null,xe=0;xe<me.length;xe++){var ye=me[xe];ye!==null&&(ye.lane&=-536870913)}a&=~Ee}c!==0&&ln(i,c,0),m!==0&&h===0&&i.tag!==0&&(i.suspendedLanes|=m&~(y&~s))}function ln(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var c=31-Ct(s);i.entangledLanes|=s,i.entanglements[c]=i.entanglements[c]|1073741824|a&261930}function En(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var c=31-Ct(a),h=1<<c;h&s|i[c]&s&&(i[c]|=s),a&=~h}}function wn(i,s){var a=s&-s;return a=(a&42)!==0?1:vi(a),(a&(i.suspendedLanes|s))!==0?0:a}function vi(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 si(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function ht(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:Iw(i.type))}function kt(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var ae=Math.random().toString(36).slice(2),Ce="__reactFiber$"+ae,Ye="__reactProps$"+ae,Xe="__reactContainer$"+ae,et="__reactEvents$"+ae,fn="__reactListeners$"+ae,xn="__reactHandles$"+ae,Mi="__reactResources$"+ae,Ft="__reactMarker$"+ae;function Ai(i){delete i[Ce],delete i[Ye],delete i[et],delete i[fn],delete i[xn]}function vs(i){var s=i[Ce];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Xe]||a[Ce]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=Sw(i);i!==null;){if(a=i[Ce])return a;i=Sw(i)}return s}i=a,a=i.parentNode}return null}function $n(i){if(i=i[Ce]||i[Xe]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function Li(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function Ki(i){var s=i[Mi];return s||(s=i[Mi]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function pn(i){i[Ft]=!0}var ri=new Set,Tr={};function ji(i,s){cn(i,s),cn(i+"Capture",s)}function cn(i,s){for(Tr[i]=s,i=0;i<s.length;i++)ri.add(s[i])}var _s=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]*$"),Co={},ga={};function Er(i){return Te.call(ga,i)?!0:Te.call(Co,i)?!1:_s.test(i)?ga[i]=!0:(Co[i]=!0,!1)}function Xn(i,s,a){if(Er(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var c=s.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function zs(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function qi(i,s,a,c){if(c===null)i.removeAttribute(a);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+c)}}function Rn(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Rr(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function va(i,s,a){var c=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var h=c.get,m=c.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,m.call(this,y)}}),Object.defineProperty(i,s,{enumerable:c.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function Dr(i){if(!i._valueTracker){var s=Rr(i)?"checked":"value";i._valueTracker=va(i,s,""+i[s])}}function _a(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),c="";return i&&(c=Rr(i)?i.checked?"true":"false":i.value),i=c,i!==a?(s.setValue(i),!0):!1}function bs(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var ko=/[\n"\\]/g;function Bn(i){return i.replace(ko,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function _i(i,s,a,c,h,m,y,D){i.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?i.type=y:i.removeAttribute("type"),s!=null?y==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Rn(s)):i.value!==""+Rn(s)&&(i.value=""+Rn(s)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),s!=null?To(i,y,Rn(s)):a!=null?To(i,y,Rn(a)):c!=null&&i.removeAttribute("value"),h==null&&m!=null&&(i.defaultChecked=!!m),h!=null&&(i.checked=h&&typeof h!="function"&&typeof h!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?i.name=""+Rn(D):i.removeAttribute("name")}function ir(i,s,a,c,h,m,y,D){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),s!=null||a!=null){if(!(m!=="submit"&&m!=="reset"||s!=null)){Dr(i);return}a=a!=null?""+Rn(a):"",s=s!=null?""+Rn(s):a,D||s===i.value||(i.value=s),i.defaultValue=s}c=c??h,c=typeof c!="function"&&typeof c!="symbol"&&!!c,i.checked=D?i.checked:!!c,i.defaultChecked=!!c,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.name=y),Dr(i)}function To(i,s,a){s==="number"&&bs(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Vi(i,s,a,c){if(i=i.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<i.length;a++)h=s.hasOwnProperty("$"+i[a].value),i[a].selected!==h&&(i[a].selected=h),h&&c&&(i[a].defaultSelected=!0)}else{for(a=""+Rn(a),s=null,h=0;h<i.length;h++){if(i[h].value===a){i[h].selected=!0,c&&(i[h].defaultSelected=!0);return}s!==null||i[h].disabled||(s=i[h])}s!==null&&(s.selected=!0)}}function Eo(i,s,a){if(s!=null&&(s=""+Rn(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Rn(a):""}function Nr(i,s,a,c){if(s==null){if(c!=null){if(a!=null)throw Error(r(92));if(J(c)){if(1<c.length)throw Error(r(93));c=c[0]}a=c}a==null&&(a=""),s=a}a=Rn(s),i.defaultValue=a,c=i.textContent,c===a&&c!==""&&c!==null&&(i.value=c),Dr(i)}function Hs(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var sr=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 Ro(i,s,a){var c=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?c?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":c?i.setProperty(s,a):typeof a!="number"||a===0||sr.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function Do(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var c in a)!a.hasOwnProperty(c)||s!=null&&s.hasOwnProperty(c)||(c.indexOf("--")===0?i.setProperty(c,""):c==="float"?i.cssFloat="":i[c]="");for(var h in s)c=s[h],s.hasOwnProperty(h)&&a[h]!==c&&Ro(i,h,c)}else for(var m in s)s.hasOwnProperty(m)&&Ro(i,m,s[m])}function ss(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 $c=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"]]),ba=/^[\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 Oi(i){return ba.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Bi(){}var Us=null;function ys(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ti=null,Mr=null;function ai(i){var s=$n(i);if(s&&(i=s.stateNode)){var a=i[Ye]||null;e:switch(i=s.stateNode,s.type){case"input":if(_i(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Bn(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var c=a[s];if(c!==i&&c.form===i.form){var h=c[Ye]||null;if(!h)throw Error(r(90));_i(c,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(s=0;s<a.length;s++)c=a[s],c.form===i.form&&_a(c)}break e;case"textarea":Eo(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&Vi(i,!!a.multiple,s,!1)}}}var ya=!1;function Ar(i,s,a){if(ya)return i(s,a);ya=!0;try{var c=i(s);return c}finally{if(ya=!1,(Ti!==null||Mr!==null)&&(kh(),Ti&&(s=Ti,i=Mr,Mr=Ti=null,ai(s),i)))for(s=0;s<i.length;s++)ai(i[s])}}function Ii(i,s){var a=i.stateNode;if(a===null)return null;var c=a[Ye]||null;if(c===null)return null;a=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(i=i.type,c=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!c;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Yi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Lr=!1;if(Yi)try{var $s={};Object.defineProperty($s,"passive",{get:function(){Lr=!0}}),window.addEventListener("test",$s,$s),window.removeEventListener("test",$s,$s)}catch{Lr=!1}var Ei=null,Pi=null,jr=null;function xl(){if(jr)return jr;var i,s=Pi,a=s.length,c,h="value"in Ei?Ei.value:Ei.textContent,m=h.length;for(i=0;i<a&&s[i]===h[i];i++);var y=a-i;for(c=1;c<=y&&s[a-c]===h[m-c];c++);return jr=h.slice(i,1<c?1-c:void 0)}function rr(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function Fs(){return!0}function ar(){return!1}function Zn(i){function s(a,c,h,m,y){this._reactName=a,this._targetInst=h,this.type=c,this.nativeEvent=m,this.target=y,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(a=i[D],this[D]=a?a(m):m[D]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Fs:ar,this.isPropagationStopped=ar,this}return _(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Fs)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Fs)},persist:function(){},isPersistent:Fs}),s}var oi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ss=Zn(oi),ot=_({},oi,{view:0,detail:0}),No=Zn(ot),or,Ws,Ks,Sa=_({},ot,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ur,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!==Ks&&(Ks&&i.type==="mousemove"?(or=i.screenX-Ks.screenX,Ws=i.screenY-Ks.screenY):Ws=or=0,Ks=i),or)},movementY:function(i){return"movementY"in i?i.movementY:Ws}}),Cl=Zn(Sa),kl=_({},Sa,{dataTransfer:0}),Tl=Zn(kl),El=_({},ot,{relatedTarget:0}),Mo=Zn(El),Fc=_({},oi,{animationName:0,elapsedTime:0,pseudoElement:0}),Wc=Zn(Fc),Ao=_({},oi,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Kc=Zn(Ao),wa=_({},oi,{data:0}),lr=Zn(wa),bi={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cr={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"},Fn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Lo(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Fn[i])?!!s[i]:!1}function ur(){return Lo}var Rl=_({},ot,{key:function(i){if(i.key){var s=bi[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=rr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?cr[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ur,charCode:function(i){return i.type==="keypress"?rr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?rr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Dl=Zn(Rl),Nl=_({},Sa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gi=Zn(Nl),Qn=_({},ot,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ur}),qc=Zn(Qn),jo=_({},oi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ml=Zn(jo),xa=_({},Sa,{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}),Vc=Zn(xa),Al=_({},oi,{newState:0,oldState:0}),li=Zn(Al),Or=[9,13,27,32],Oo=Yi&&"CompositionEvent"in window,Br=null;Yi&&"documentMode"in document&&(Br=document.documentMode);var Yc=Yi&&"TextEvent"in window&&!Br,Ca=Yi&&(!Oo||Br&&8<Br&&11>=Br),ka=" ",S=!1;function k(i,s){switch(i){case"keyup":return Or.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function B(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var X=!1;function se(i,s){switch(i){case"compositionend":return B(s);case"keypress":return s.which!==32?null:(S=!0,ka);case"textInput":return i=s.data,i===ka&&S?null:i;default:return null}}function le(i,s){if(X)return i==="compositionend"||!Oo&&k(i,s)?(i=xl(),jr=Pi=Ei=null,X=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Ca&&s.locale!=="ko"?null:s.data;default:return null}}var De={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 Ie(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!De[i.type]:s==="textarea"}function qe(i,s,a,c){Ti?Mr?Mr.push(c):Mr=[c]:Ti=c,s=Ah(s,"onChange"),0<s.length&&(a=new Ss("onChange","change",null,a,c),i.push({event:a,listeners:s}))}var Ke=null,ft=null;function Wt(i){ow(i,0)}function jt(i){var s=Li(i);if(_a(s))return i}function Dn(i,s){if(i==="change")return s}var Ir=!1;if(Yi){var Pr;if(Yi){var Ta="oninput"in document;if(!Ta){var qs=document.createElement("div");qs.setAttribute("oninput","return;"),Ta=typeof qs.oninput=="function"}Pr=Ta}else Pr=!1;Ir=Pr&&(!document.documentMode||9<document.documentMode)}function Ud(){Ke&&(Ke.detachEvent("onpropertychange",Gc),ft=Ke=null)}function Gc(i){if(i.propertyName==="value"&&jt(ft)){var s=[];qe(s,ft,i,ys(i)),Ar(Wt,s)}}function dr(i,s,a){i==="focusin"?(Ud(),Ke=s,ft=a,Ke.attachEvent("onpropertychange",Gc)):i==="focusout"&&Ud()}function Pp(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return jt(ft)}function zp(i,s){if(i==="click")return jt(s)}function $d(i,s){if(i==="input"||i==="change")return jt(s)}function Hp(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var zi=typeof Object.is=="function"?Object.is:Hp;function rs(i,s){if(zi(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),c=Object.keys(s);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var h=a[c];if(!Te.call(s,h)||!zi(i[h],s[h]))return!1}return!0}function Fd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Wd(i,s){var a=Fd(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=s&&c>=s)return{node:a,offset:s-i};i=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Fd(a)}}function Kd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?Kd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function Xc(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=bs(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=bs(i.document)}return s}function ws(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var Up=Yi&&"documentMode"in document&&11>=document.documentMode,Ea=null,Bo=null,Io=null,Ll=!1;function E(i,s,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ll||Ea==null||Ea!==bs(c)||(c=Ea,"selectionStart"in c&&ws(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Io&&rs(Io,c)||(Io=c,c=Ah(Bo,"onSelect"),0<c.length&&(s=new Ss("onSelect","select",null,s,a),i.push({event:s,listeners:c}),s.target=Ea)))}function K(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var ze={animationend:K("Animation","AnimationEnd"),animationiteration:K("Animation","AnimationIteration"),animationstart:K("Animation","AnimationStart"),transitionrun:K("Transition","TransitionRun"),transitionstart:K("Transition","TransitionStart"),transitioncancel:K("Transition","TransitionCancel"),transitionend:K("Transition","TransitionEnd")},Je={},tt={};Yi&&(tt=document.createElement("div").style,"AnimationEvent"in window||(delete ze.animationend.animation,delete ze.animationiteration.animation,delete ze.animationstart.animation),"TransitionEvent"in window||delete ze.transitionend.transition);function pt(i){if(Je[i])return Je[i];if(!ze[i])return i;var s=ze[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in tt)return Je[i]=s[a];return i}var Tt=pt("animationend"),Et=pt("animationiteration"),rt=pt("animationstart"),un=pt("transitionrun"),Jt=pt("transitionstart"),Xt=pt("transitioncancel"),Vs=pt("transitionend"),Po=new Map,xs="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(" ");xs.push("scrollEnd");function Xi(i,s){Po.set(i,s),ji(s,[i])}var zo=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Cs=[],jl=0,$p=0;function qd(){for(var i=jl,s=$p=jl=0;s<i;){var a=Cs[s];Cs[s++]=null;var c=Cs[s];Cs[s++]=null;var h=Cs[s];Cs[s++]=null;var m=Cs[s];if(Cs[s++]=null,c!==null&&h!==null){var y=c.pending;y===null?h.next=h:(h.next=y.next,y.next=h),c.pending=h}m!==0&&$y(a,h,m)}}function Vd(i,s,a,c){Cs[jl++]=i,Cs[jl++]=s,Cs[jl++]=a,Cs[jl++]=c,$p|=c,i.lanes|=c,i=i.alternate,i!==null&&(i.lanes|=c)}function Fp(i,s,a,c){return Vd(i,s,a,c),Yd(i)}function Ho(i,s){return Vd(i,null,null,s),Yd(i)}function $y(i,s,a){i.lanes|=a;var c=i.alternate;c!==null&&(c.lanes|=a);for(var h=!1,m=i.return;m!==null;)m.childLanes|=a,c=m.alternate,c!==null&&(c.childLanes|=a),m.tag===22&&(i=m.stateNode,i===null||i._visibility&1||(h=!0)),i=m,m=m.return;return i.tag===3?(m=i.stateNode,h&&s!==null&&(h=31-Ct(a),i=m.hiddenUpdates,c=i[h],c===null?i[h]=[s]:c.push(s),s.lane=a|536870912),m):null}function Yd(i){if(50<_u)throw _u=0,Qm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var Ol={};function j2(i,s,a,c){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function as(i,s,a,c){return new j2(i,s,a,c)}function Wp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function zr(i,s){var a=i.alternate;return a===null?(a=as(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function Fy(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function Gd(i,s,a,c,h,m){var y=0;if(c=i,typeof i=="function")Wp(i)&&(y=1);else if(typeof i=="string")y=zR(i,a,Q.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case fe:return i=as(31,a,s,h),i.elementType=fe,i.lanes=m,i;case T:return Uo(a.children,h,m,s);case A:y=8,h|=24;break;case M:return i=as(12,a,s,h|2),i.elementType=M,i.lanes=m,i;case F:return i=as(13,a,s,h),i.elementType=F,i.lanes=m,i;case V:return i=as(19,a,s,h),i.elementType=V,i.lanes=m,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case U:y=10;break e;case W:y=9;break e;case P:y=11;break e;case O:y=14;break e;case G:y=16,c=null;break e}y=29,a=Error(r(130,i===null?"null":typeof i,"")),c=null}return s=as(y,a,s,h),s.elementType=i,s.type=c,s.lanes=m,s}function Uo(i,s,a,c){return i=as(7,i,c,s),i.lanes=a,i}function Kp(i,s,a){return i=as(6,i,null,s),i.lanes=a,i}function Wy(i){var s=as(18,null,null,0);return s.stateNode=i,s}function qp(i,s,a){return s=as(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var Ky=new WeakMap;function ks(i,s){if(typeof i=="object"&&i!==null){var a=Ky.get(i);return a!==void 0?a:(s={value:i,source:s,stack:de(s)},Ky.set(i,s),s)}return{value:i,source:s,stack:de(s)}}var Bl=[],Il=0,Xd=null,Zc=0,Ts=[],Es=0,Ra=null,hr=1,fr="";function Hr(i,s){Bl[Il++]=Zc,Bl[Il++]=Xd,Xd=i,Zc=s}function qy(i,s,a){Ts[Es++]=hr,Ts[Es++]=fr,Ts[Es++]=Ra,Ra=i;var c=hr;i=fr;var h=32-Ct(c)-1;c&=~(1<<h),a+=1;var m=32-Ct(s)+h;if(30<m){var y=h-h%5;m=(c&(1<<y)-1).toString(32),c>>=y,h-=y,hr=1<<32-Ct(s)+h|a<<h|c,fr=m+i}else hr=1<<m|a<<h|c,fr=i}function Vp(i){i.return!==null&&(Hr(i,1),qy(i,1,0))}function Yp(i){for(;i===Xd;)Xd=Bl[--Il],Bl[Il]=null,Zc=Bl[--Il],Bl[Il]=null;for(;i===Ra;)Ra=Ts[--Es],Ts[Es]=null,fr=Ts[--Es],Ts[Es]=null,hr=Ts[--Es],Ts[Es]=null}function Vy(i,s){Ts[Es++]=hr,Ts[Es++]=fr,Ts[Es++]=Ra,hr=s.id,fr=s.overflow,Ra=i}var yi=null,mn=null,Pt=!1,Da=null,Rs=!1,Gp=Error(r(519));function Na(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qc(ks(s,i)),Gp}function Yy(i){var s=i.stateNode,a=i.type,c=i.memoizedProps;switch(s[Ce]=i,s[Ye]=c,a){case"dialog":At("cancel",s),At("close",s);break;case"iframe":case"object":case"embed":At("load",s);break;case"video":case"audio":for(a=0;a<yu.length;a++)At(yu[a],s);break;case"source":At("error",s);break;case"img":case"image":case"link":At("error",s),At("load",s);break;case"details":At("toggle",s);break;case"input":At("invalid",s),ir(s,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":At("invalid",s);break;case"textarea":At("invalid",s),Nr(s,c.value,c.defaultValue,c.children)}a=c.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||c.suppressHydrationWarning===!0||dw(s.textContent,a)?(c.popover!=null&&(At("beforetoggle",s),At("toggle",s)),c.onScroll!=null&&At("scroll",s),c.onScrollEnd!=null&&At("scrollend",s),c.onClick!=null&&(s.onclick=Bi),s=!0):s=!1,s||Na(i,!0)}function Gy(i){for(yi=i.return;yi;)switch(yi.tag){case 5:case 31:case 13:Rs=!1;return;case 27:case 3:Rs=!0;return;default:yi=yi.return}}function Pl(i){if(i!==yi)return!1;if(!Pt)return Gy(i),Pt=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||fg(i.type,i.memoizedProps)),a=!a),a&&mn&&Na(i),Gy(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));mn=yw(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));mn=yw(i)}else s===27?(s=mn,Wa(i.type)?(i=_g,_g=null,mn=i):mn=s):mn=yi?Ns(i.stateNode.nextSibling):null;return!0}function $o(){mn=yi=null,Pt=!1}function Xp(){var i=Da;return i!==null&&(es===null?es=i:es.push.apply(es,i),Da=null),i}function Qc(i){Da===null?Da=[i]:Da.push(i)}var Zp=N(null),Fo=null,Ur=null;function Ma(i,s,a){oe(Zp,s._currentValue),s._currentValue=a}function $r(i){i._currentValue=Zp.current,Y(Zp)}function Qp(i,s,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),i===a)break;i=i.return}}function Jp(i,s,a,c){var h=i.child;for(h!==null&&(h.return=i);h!==null;){var m=h.dependencies;if(m!==null){var y=h.child;m=m.firstContext;e:for(;m!==null;){var D=m;m=h;for(var z=0;z<s.length;z++)if(D.context===s[z]){m.lanes|=a,D=m.alternate,D!==null&&(D.lanes|=a),Qp(m.return,a,i),c||(y=null);break e}m=D.next}}else if(h.tag===18){if(y=h.return,y===null)throw Error(r(341));y.lanes|=a,m=y.alternate,m!==null&&(m.lanes|=a),Qp(y,a,i),y=null}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===i){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}}function zl(i,s,a,c){i=null;for(var h=s,m=!1;h!==null;){if(!m){if((h.flags&524288)!==0)m=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var y=h.alternate;if(y===null)throw Error(r(387));if(y=y.memoizedProps,y!==null){var D=h.type;zi(h.pendingProps.value,y.value)||(i!==null?i.push(D):i=[D])}}else if(h===ue.current){if(y=h.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(i!==null?i.push(ku):i=[ku])}h=h.return}i!==null&&Jp(s,i,a,c),s.flags|=262144}function Zd(i){for(i=i.firstContext;i!==null;){if(!zi(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Wo(i){Fo=i,Ur=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Si(i){return Xy(Fo,i)}function Qd(i,s){return Fo===null&&Wo(i),Xy(i,s)}function Xy(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},Ur===null){if(i===null)throw Error(r(308));Ur=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else Ur=Ur.next=s;return a}var O2=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,c){i.push(c)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},B2=e.unstable_scheduleCallback,I2=e.unstable_NormalPriority,Wn={$$typeof:U,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function em(){return{controller:new O2,data:new Map,refCount:0}}function Jc(i){i.refCount--,i.refCount===0&&B2(I2,function(){i.controller.abort()})}var eu=null,tm=0,Hl=0,Ul=null;function P2(i,s){if(eu===null){var a=eu=[];tm=0,Hl=sg(),Ul={status:"pending",value:void 0,then:function(c){a.push(c)}}}return tm++,s.then(Zy,Zy),s}function Zy(){if(--tm===0&&eu!==null){Ul!==null&&(Ul.status="fulfilled");var i=eu;eu=null,Hl=0,Ul=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function z2(i,s){var a=[],c={status:"pending",value:null,reason:null,then:function(h){a.push(h)}};return i.then(function(){c.status="fulfilled",c.value=s;for(var h=0;h<a.length;h++)(0,a[h])(s)},function(h){for(c.status="rejected",c.reason=h,h=0;h<a.length;h++)(0,a[h])(void 0)}),c}var Qy=j.S;j.S=function(i,s){O0=We(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&P2(i,s),Qy!==null&&Qy(i,s)};var Ko=N(null);function nm(){var i=Ko.current;return i!==null?i:on.pooledCache}function Jd(i,s){s===null?oe(Ko,Ko.current):oe(Ko,s.pool)}function Jy(){var i=nm();return i===null?null:{parent:Wn._currentValue,pool:i}}var $l=Error(r(460)),im=Error(r(474)),eh=Error(r(542)),th={then:function(){}};function eS(i){return i=i.status,i==="fulfilled"||i==="rejected"}function tS(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Bi,Bi),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,iS(i),i;default:if(typeof s.status=="string")s.then(Bi,Bi);else{if(i=on,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(c){if(s.status==="pending"){var h=s;h.status="fulfilled",h.value=c}},function(c){if(s.status==="pending"){var h=s;h.status="rejected",h.reason=c}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,iS(i),i}throw Vo=s,$l}}function qo(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Vo=a,$l):a}}var Vo=null;function nS(){if(Vo===null)throw Error(r(459));var i=Vo;return Vo=null,i}function iS(i){if(i===$l||i===eh)throw Error(r(483))}var Fl=null,tu=0;function nh(i){var s=tu;return tu+=1,Fl===null&&(Fl=[]),tS(Fl,i,s)}function nu(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function ih(i,s){throw s.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function sS(i){function s(ne,q){if(i){var ce=ne.deletions;ce===null?(ne.deletions=[q],ne.flags|=16):ce.push(q)}}function a(ne,q){if(!i)return null;for(;q!==null;)s(ne,q),q=q.sibling;return null}function c(ne){for(var q=new Map;ne!==null;)ne.key!==null?q.set(ne.key,ne):q.set(ne.index,ne),ne=ne.sibling;return q}function h(ne,q){return ne=zr(ne,q),ne.index=0,ne.sibling=null,ne}function m(ne,q,ce){return ne.index=ce,i?(ce=ne.alternate,ce!==null?(ce=ce.index,ce<q?(ne.flags|=67108866,q):ce):(ne.flags|=67108866,q)):(ne.flags|=1048576,q)}function y(ne){return i&&ne.alternate===null&&(ne.flags|=67108866),ne}function D(ne,q,ce,ke){return q===null||q.tag!==6?(q=Kp(ce,ne.mode,ke),q.return=ne,q):(q=h(q,ce),q.return=ne,q)}function z(ne,q,ce,ke){var nt=ce.type;return nt===T?xe(ne,q,ce.props.children,ke,ce.key):q!==null&&(q.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===G&&qo(nt)===q.type)?(q=h(q,ce.props),nu(q,ce),q.return=ne,q):(q=Gd(ce.type,ce.key,ce.props,null,ne.mode,ke),nu(q,ce),q.return=ne,q)}function he(ne,q,ce,ke){return q===null||q.tag!==4||q.stateNode.containerInfo!==ce.containerInfo||q.stateNode.implementation!==ce.implementation?(q=qp(ce,ne.mode,ke),q.return=ne,q):(q=h(q,ce.children||[]),q.return=ne,q)}function xe(ne,q,ce,ke,nt){return q===null||q.tag!==7?(q=Uo(ce,ne.mode,ke,nt),q.return=ne,q):(q=h(q,ce),q.return=ne,q)}function Ee(ne,q,ce){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=Kp(""+q,ne.mode,ce),q.return=ne,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case C:return ce=Gd(q.type,q.key,q.props,null,ne.mode,ce),nu(ce,q),ce.return=ne,ce;case x:return q=qp(q,ne.mode,ce),q.return=ne,q;case G:return q=qo(q),Ee(ne,q,ce)}if(J(q)||$(q))return q=Uo(q,ne.mode,ce,null),q.return=ne,q;if(typeof q.then=="function")return Ee(ne,nh(q),ce);if(q.$$typeof===U)return Ee(ne,Qd(ne,q),ce);ih(ne,q)}return null}function me(ne,q,ce,ke){var nt=q!==null?q.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return nt!==null?null:D(ne,q,""+ce,ke);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case C:return ce.key===nt?z(ne,q,ce,ke):null;case x:return ce.key===nt?he(ne,q,ce,ke):null;case G:return ce=qo(ce),me(ne,q,ce,ke)}if(J(ce)||$(ce))return nt!==null?null:xe(ne,q,ce,ke,null);if(typeof ce.then=="function")return me(ne,q,nh(ce),ke);if(ce.$$typeof===U)return me(ne,q,Qd(ne,ce),ke);ih(ne,ce)}return null}function ye(ne,q,ce,ke,nt){if(typeof ke=="string"&&ke!==""||typeof ke=="number"||typeof ke=="bigint")return ne=ne.get(ce)||null,D(q,ne,""+ke,nt);if(typeof ke=="object"&&ke!==null){switch(ke.$$typeof){case C:return ne=ne.get(ke.key===null?ce:ke.key)||null,z(q,ne,ke,nt);case x:return ne=ne.get(ke.key===null?ce:ke.key)||null,he(q,ne,ke,nt);case G:return ke=qo(ke),ye(ne,q,ce,ke,nt)}if(J(ke)||$(ke))return ne=ne.get(ce)||null,xe(q,ne,ke,nt,null);if(typeof ke.then=="function")return ye(ne,q,ce,nh(ke),nt);if(ke.$$typeof===U)return ye(ne,q,ce,Qd(q,ke),nt);ih(q,ke)}return null}function Ge(ne,q,ce,ke){for(var nt=null,Ht=null,Qe=q,xt=q=0,Bt=null;Qe!==null&&xt<ce.length;xt++){Qe.index>xt?(Bt=Qe,Qe=null):Bt=Qe.sibling;var Ut=me(ne,Qe,ce[xt],ke);if(Ut===null){Qe===null&&(Qe=Bt);break}i&&Qe&&Ut.alternate===null&&s(ne,Qe),q=m(Ut,q,xt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut,Qe=Bt}if(xt===ce.length)return a(ne,Qe),Pt&&Hr(ne,xt),nt;if(Qe===null){for(;xt<ce.length;xt++)Qe=Ee(ne,ce[xt],ke),Qe!==null&&(q=m(Qe,q,xt),Ht===null?nt=Qe:Ht.sibling=Qe,Ht=Qe);return Pt&&Hr(ne,xt),nt}for(Qe=c(Qe);xt<ce.length;xt++)Bt=ye(Qe,ne,xt,ce[xt],ke),Bt!==null&&(i&&Bt.alternate!==null&&Qe.delete(Bt.key===null?xt:Bt.key),q=m(Bt,q,xt),Ht===null?nt=Bt:Ht.sibling=Bt,Ht=Bt);return i&&Qe.forEach(function(Ga){return s(ne,Ga)}),Pt&&Hr(ne,xt),nt}function ct(ne,q,ce,ke){if(ce==null)throw Error(r(151));for(var nt=null,Ht=null,Qe=q,xt=q=0,Bt=null,Ut=ce.next();Qe!==null&&!Ut.done;xt++,Ut=ce.next()){Qe.index>xt?(Bt=Qe,Qe=null):Bt=Qe.sibling;var Ga=me(ne,Qe,Ut.value,ke);if(Ga===null){Qe===null&&(Qe=Bt);break}i&&Qe&&Ga.alternate===null&&s(ne,Qe),q=m(Ga,q,xt),Ht===null?nt=Ga:Ht.sibling=Ga,Ht=Ga,Qe=Bt}if(Ut.done)return a(ne,Qe),Pt&&Hr(ne,xt),nt;if(Qe===null){for(;!Ut.done;xt++,Ut=ce.next())Ut=Ee(ne,Ut.value,ke),Ut!==null&&(q=m(Ut,q,xt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut);return Pt&&Hr(ne,xt),nt}for(Qe=c(Qe);!Ut.done;xt++,Ut=ce.next())Ut=ye(Qe,ne,xt,Ut.value,ke),Ut!==null&&(i&&Ut.alternate!==null&&Qe.delete(Ut.key===null?xt:Ut.key),q=m(Ut,q,xt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut);return i&&Qe.forEach(function(XR){return s(ne,XR)}),Pt&&Hr(ne,xt),nt}function nn(ne,q,ce,ke){if(typeof ce=="object"&&ce!==null&&ce.type===T&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case C:e:{for(var nt=ce.key;q!==null;){if(q.key===nt){if(nt=ce.type,nt===T){if(q.tag===7){a(ne,q.sibling),ke=h(q,ce.props.children),ke.return=ne,ne=ke;break e}}else if(q.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===G&&qo(nt)===q.type){a(ne,q.sibling),ke=h(q,ce.props),nu(ke,ce),ke.return=ne,ne=ke;break e}a(ne,q);break}else s(ne,q);q=q.sibling}ce.type===T?(ke=Uo(ce.props.children,ne.mode,ke,ce.key),ke.return=ne,ne=ke):(ke=Gd(ce.type,ce.key,ce.props,null,ne.mode,ke),nu(ke,ce),ke.return=ne,ne=ke)}return y(ne);case x:e:{for(nt=ce.key;q!==null;){if(q.key===nt)if(q.tag===4&&q.stateNode.containerInfo===ce.containerInfo&&q.stateNode.implementation===ce.implementation){a(ne,q.sibling),ke=h(q,ce.children||[]),ke.return=ne,ne=ke;break e}else{a(ne,q);break}else s(ne,q);q=q.sibling}ke=qp(ce,ne.mode,ke),ke.return=ne,ne=ke}return y(ne);case G:return ce=qo(ce),nn(ne,q,ce,ke)}if(J(ce))return Ge(ne,q,ce,ke);if($(ce)){if(nt=$(ce),typeof nt!="function")throw Error(r(150));return ce=nt.call(ce),ct(ne,q,ce,ke)}if(typeof ce.then=="function")return nn(ne,q,nh(ce),ke);if(ce.$$typeof===U)return nn(ne,q,Qd(ne,ce),ke);ih(ne,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,q!==null&&q.tag===6?(a(ne,q.sibling),ke=h(q,ce),ke.return=ne,ne=ke):(a(ne,q),ke=Kp(ce,ne.mode,ke),ke.return=ne,ne=ke),y(ne)):a(ne,q)}return function(ne,q,ce,ke){try{tu=0;var nt=nn(ne,q,ce,ke);return Fl=null,nt}catch(Qe){if(Qe===$l||Qe===eh)throw Qe;var Ht=as(29,Qe,null,ne.mode);return Ht.lanes=ke,Ht.return=ne,Ht}}}var Yo=sS(!0),rS=sS(!1),Aa=!1;function sm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rm(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function La(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ja(i,s,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Kt&2)!==0){var h=c.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),c.pending=s,s=Yd(i),$y(i,null,a),s}return Vd(i,c,s,a),Yd(i)}function iu(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,En(i,a)}}function am(i,s){var a=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var h=null,m=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};m===null?h=m=y:m=m.next=y,a=a.next}while(a!==null);m===null?h=m=s:m=m.next=s}else h=m=s;a={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:m,shared:c.shared,callbacks:c.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var om=!1;function su(){if(om){var i=Ul;if(i!==null)throw i}}function ru(i,s,a,c){om=!1;var h=i.updateQueue;Aa=!1;var m=h.firstBaseUpdate,y=h.lastBaseUpdate,D=h.shared.pending;if(D!==null){h.shared.pending=null;var z=D,he=z.next;z.next=null,y===null?m=he:y.next=he,y=z;var xe=i.alternate;xe!==null&&(xe=xe.updateQueue,D=xe.lastBaseUpdate,D!==y&&(D===null?xe.firstBaseUpdate=he:D.next=he,xe.lastBaseUpdate=z))}if(m!==null){var Ee=h.baseState;y=0,xe=he=z=null,D=m;do{var me=D.lane&-536870913,ye=me!==D.lane;if(ye?(Ot&me)===me:(c&me)===me){me!==0&&me===Hl&&(om=!0),xe!==null&&(xe=xe.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Ge=i,ct=D;me=s;var nn=a;switch(ct.tag){case 1:if(Ge=ct.payload,typeof Ge=="function"){Ee=Ge.call(nn,Ee,me);break e}Ee=Ge;break e;case 3:Ge.flags=Ge.flags&-65537|128;case 0:if(Ge=ct.payload,me=typeof Ge=="function"?Ge.call(nn,Ee,me):Ge,me==null)break e;Ee=_({},Ee,me);break e;case 2:Aa=!0}}me=D.callback,me!==null&&(i.flags|=64,ye&&(i.flags|=8192),ye=h.callbacks,ye===null?h.callbacks=[me]:ye.push(me))}else ye={lane:me,tag:D.tag,payload:D.payload,callback:D.callback,next:null},xe===null?(he=xe=ye,z=Ee):xe=xe.next=ye,y|=me;if(D=D.next,D===null){if(D=h.shared.pending,D===null)break;ye=D,D=ye.next,ye.next=null,h.lastBaseUpdate=ye,h.shared.pending=null}}while(!0);xe===null&&(z=Ee),h.baseState=z,h.firstBaseUpdate=he,h.lastBaseUpdate=xe,m===null&&(h.shared.lanes=0),za|=y,i.lanes=y,i.memoizedState=Ee}}function aS(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function oS(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)aS(a[i],s)}var Wl=N(null),sh=N(0);function lS(i,s){i=Zr,oe(sh,i),oe(Wl,s),Zr=i|s.baseLanes}function lm(){oe(sh,Zr),oe(Wl,Wl.current)}function cm(){Zr=sh.current,Y(Wl),Y(sh)}var os=N(null),Ds=null;function Oa(i){var s=i.alternate;oe(In,In.current&1),oe(os,i),Ds===null&&(s===null||Wl.current!==null||s.memoizedState!==null)&&(Ds=i)}function um(i){oe(In,In.current),oe(os,i),Ds===null&&(Ds=i)}function cS(i){i.tag===22?(oe(In,In.current),oe(os,i),Ds===null&&(Ds=i)):Ba()}function Ba(){oe(In,In.current),oe(os,os.current)}function ls(i){Y(os),Ds===i&&(Ds=null),Y(In)}var In=N(0);function rh(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||gg(a)||vg(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Fr=0,wt=null,en=null,Kn=null,ah=!1,Kl=!1,Go=!1,oh=0,au=0,ql=null,H2=0;function Nn(){throw Error(r(321))}function dm(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!zi(i[a],s[a]))return!1;return!0}function hm(i,s,a,c,h,m){return Fr=m,wt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,j.H=i===null||i.memoizedState===null?qS:Em,Go=!1,m=a(c,h),Go=!1,Kl&&(m=dS(s,a,c,h)),uS(i),m}function uS(i){j.H=cu;var s=en!==null&&en.next!==null;if(Fr=0,Kn=en=wt=null,ah=!1,au=0,ql=null,s)throw Error(r(300));i===null||qn||(i=i.dependencies,i!==null&&Zd(i)&&(qn=!0))}function dS(i,s,a,c){wt=i;var h=0;do{if(Kl&&(ql=null),au=0,Kl=!1,25<=h)throw Error(r(301));if(h+=1,Kn=en=null,i.updateQueue!=null){var m=i.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}j.H=VS,m=s(a,c)}while(Kl);return m}function U2(){var i=j.H,s=i.useState()[0];return s=typeof s.then=="function"?ou(s):s,i=i.useState()[0],(en!==null?en.memoizedState:null)!==i&&(wt.flags|=1024),s}function fm(){var i=oh!==0;return oh=0,i}function pm(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function mm(i){if(ah){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}ah=!1}Fr=0,Kn=en=wt=null,Kl=!1,au=oh=0,ql=null}function Hi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Kn===null?wt.memoizedState=Kn=i:Kn=Kn.next=i,Kn}function Pn(){if(en===null){var i=wt.alternate;i=i!==null?i.memoizedState:null}else i=en.next;var s=Kn===null?wt.memoizedState:Kn.next;if(s!==null)Kn=s,en=i;else{if(i===null)throw wt.alternate===null?Error(r(467)):Error(r(310));en=i,i={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},Kn===null?wt.memoizedState=Kn=i:Kn=Kn.next=i}return Kn}function lh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ou(i){var s=au;return au+=1,ql===null&&(ql=[]),i=tS(ql,i,s),s=wt,(Kn===null?s.memoizedState:Kn.next)===null&&(s=s.alternate,j.H=s===null||s.memoizedState===null?qS:Em),i}function ch(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return ou(i);if(i.$$typeof===U)return Si(i)}throw Error(r(438,String(i)))}function gm(i){var s=null,a=wt.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var c=wt.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(s={data:c.data.map(function(h){return h.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=lh(),wt.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),c=0;c<i;c++)a[c]=ee;return s.index++,a}function Wr(i,s){return typeof s=="function"?s(i):s}function uh(i){var s=Pn();return vm(s,en,i)}function vm(i,s,a){var c=i.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=a;var h=i.baseQueue,m=c.pending;if(m!==null){if(h!==null){var y=h.next;h.next=m.next,m.next=y}s.baseQueue=h=m,c.pending=null}if(m=i.baseState,h===null)i.memoizedState=m;else{s=h.next;var D=y=null,z=null,he=s,xe=!1;do{var Ee=he.lane&-536870913;if(Ee!==he.lane?(Ot&Ee)===Ee:(Fr&Ee)===Ee){var me=he.revertLane;if(me===0)z!==null&&(z=z.next={lane:0,revertLane:0,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),Ee===Hl&&(xe=!0);else if((Fr&me)===me){he=he.next,me===Hl&&(xe=!0);continue}else Ee={lane:0,revertLane:he.revertLane,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null},z===null?(D=z=Ee,y=m):z=z.next=Ee,wt.lanes|=me,za|=me;Ee=he.action,Go&&a(m,Ee),m=he.hasEagerState?he.eagerState:a(m,Ee)}else me={lane:Ee,revertLane:he.revertLane,gesture:he.gesture,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null},z===null?(D=z=me,y=m):z=z.next=me,wt.lanes|=Ee,za|=Ee;he=he.next}while(he!==null&&he!==s);if(z===null?y=m:z.next=D,!zi(m,i.memoizedState)&&(qn=!0,xe&&(a=Ul,a!==null)))throw a;i.memoizedState=m,i.baseState=y,i.baseQueue=z,c.lastRenderedState=m}return h===null&&(c.lanes=0),[i.memoizedState,c.dispatch]}function _m(i){var s=Pn(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var c=a.dispatch,h=a.pending,m=s.memoizedState;if(h!==null){a.pending=null;var y=h=h.next;do m=i(m,y.action),y=y.next;while(y!==h);zi(m,s.memoizedState)||(qn=!0),s.memoizedState=m,s.baseQueue===null&&(s.baseState=m),a.lastRenderedState=m}return[m,c]}function hS(i,s,a){var c=wt,h=Pn(),m=Pt;if(m){if(a===void 0)throw Error(r(407));a=a()}else a=s();var y=!zi((en||h).memoizedState,a);if(y&&(h.memoizedState=a,qn=!0),h=h.queue,Sm(mS.bind(null,c,h,i),[i]),h.getSnapshot!==s||y||Kn!==null&&Kn.memoizedState.tag&1){if(c.flags|=2048,Vl(9,{destroy:void 0},pS.bind(null,c,h,a,s),null),on===null)throw Error(r(349));m||(Fr&127)!==0||fS(c,s,a)}return a}function fS(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=wt.updateQueue,s===null?(s=lh(),wt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function pS(i,s,a,c){s.value=a,s.getSnapshot=c,gS(s)&&vS(i)}function mS(i,s,a){return a(function(){gS(s)&&vS(i)})}function gS(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!zi(i,a)}catch{return!0}}function vS(i){var s=Ho(i,2);s!==null&&ts(s,i,2)}function bm(i){var s=Hi();if(typeof i=="function"){var a=i;if(i=a(),Go){Lt(!0);try{a()}finally{Lt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:i},s}function _S(i,s,a,c){return i.baseState=a,vm(i,en,typeof c=="function"?c:Wr)}function $2(i,s,a,c,h){if(fh(i))throw Error(r(485));if(i=s.action,i!==null){var m={payload:h,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){m.listeners.push(y)}};j.T!==null?a(!0):m.isTransition=!1,c(m),a=s.pending,a===null?(m.next=s.pending=m,bS(s,m)):(m.next=a.next,s.pending=a.next=m)}}function bS(i,s){var a=s.action,c=s.payload,h=i.state;if(s.isTransition){var m=j.T,y={};j.T=y;try{var D=a(h,c),z=j.S;z!==null&&z(y,D),yS(i,s,D)}catch(he){ym(i,s,he)}finally{m!==null&&y.types!==null&&(m.types=y.types),j.T=m}}else try{m=a(h,c),yS(i,s,m)}catch(he){ym(i,s,he)}}function yS(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(c){SS(i,s,c)},function(c){return ym(i,s,c)}):SS(i,s,a)}function SS(i,s,a){s.status="fulfilled",s.value=a,wS(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,bS(i,a)))}function ym(i,s,a){var c=i.pending;if(i.pending=null,c!==null){c=c.next;do s.status="rejected",s.reason=a,wS(s),s=s.next;while(s!==c)}i.action=null}function wS(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function xS(i,s){return s}function CS(i,s){if(Pt){var a=on.formState;if(a!==null){e:{var c=wt;if(Pt){if(mn){t:{for(var h=mn,m=Rs;h.nodeType!==8;){if(!m){h=null;break t}if(h=Ns(h.nextSibling),h===null){h=null;break t}}m=h.data,h=m==="F!"||m==="F"?h:null}if(h){mn=Ns(h.nextSibling),c=h.data==="F!";break e}}Na(c)}c=!1}c&&(s=a[0])}}return a=Hi(),a.memoizedState=a.baseState=s,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xS,lastRenderedState:s},a.queue=c,a=FS.bind(null,wt,c),c.dispatch=a,c=bm(!1),m=Tm.bind(null,wt,!1,c.queue),c=Hi(),h={state:s,dispatch:null,action:i,pending:null},c.queue=h,a=$2.bind(null,wt,h,m,a),h.dispatch=a,c.memoizedState=i,[s,a,!1]}function kS(i){var s=Pn();return TS(s,en,i)}function TS(i,s,a){if(s=vm(i,s,xS)[0],i=uh(Wr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var c=ou(s)}catch(y){throw y===$l?eh:y}else c=s;s=Pn();var h=s.queue,m=h.dispatch;return a!==s.memoizedState&&(wt.flags|=2048,Vl(9,{destroy:void 0},F2.bind(null,h,a),null)),[c,m,i]}function F2(i,s){i.action=s}function ES(i){var s=Pn(),a=en;if(a!==null)return TS(s,a,i);Pn(),s=s.memoizedState,a=Pn();var c=a.queue.dispatch;return a.memoizedState=i,[s,c,!1]}function Vl(i,s,a,c){return i={tag:i,create:a,deps:c,inst:s,next:null},s=wt.updateQueue,s===null&&(s=lh(),wt.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,s.lastEffect=i),i}function RS(){return Pn().memoizedState}function dh(i,s,a,c){var h=Hi();wt.flags|=i,h.memoizedState=Vl(1|s,{destroy:void 0},a,c===void 0?null:c)}function hh(i,s,a,c){var h=Pn();c=c===void 0?null:c;var m=h.memoizedState.inst;en!==null&&c!==null&&dm(c,en.memoizedState.deps)?h.memoizedState=Vl(s,m,a,c):(wt.flags|=i,h.memoizedState=Vl(1|s,m,a,c))}function DS(i,s){dh(8390656,8,i,s)}function Sm(i,s){hh(2048,8,i,s)}function W2(i){wt.flags|=4;var s=wt.updateQueue;if(s===null)s=lh(),wt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function NS(i){var s=Pn().memoizedState;return W2({ref:s,nextImpl:i}),function(){if((Kt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function MS(i,s){return hh(4,2,i,s)}function AS(i,s){return hh(4,4,i,s)}function LS(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function jS(i,s,a){a=a!=null?a.concat([i]):null,hh(4,4,LS.bind(null,s,i),a)}function wm(){}function OS(i,s){var a=Pn();s=s===void 0?null:s;var c=a.memoizedState;return s!==null&&dm(s,c[1])?c[0]:(a.memoizedState=[i,s],i)}function BS(i,s){var a=Pn();s=s===void 0?null:s;var c=a.memoizedState;if(s!==null&&dm(s,c[1]))return c[0];if(c=i(),Go){Lt(!0);try{i()}finally{Lt(!1)}}return a.memoizedState=[c,s],c}function xm(i,s,a){return a===void 0||(Fr&1073741824)!==0&&(Ot&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=I0(),wt.lanes|=i,za|=i,a)}function IS(i,s,a,c){return zi(a,s)?a:Wl.current!==null?(i=xm(i,a,c),zi(i,s)||(qn=!0),i):(Fr&42)===0||(Fr&1073741824)!==0&&(Ot&261930)===0?(qn=!0,i.memoizedState=a):(i=I0(),wt.lanes|=i,za|=i,s)}function PS(i,s,a,c,h){var m=R.p;R.p=m!==0&&8>m?m:8;var y=j.T,D={};j.T=D,Tm(i,!1,s,a);try{var z=h(),he=j.S;if(he!==null&&he(D,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var xe=z2(z,c);lu(i,s,xe,ds(i))}else lu(i,s,c,ds(i))}catch(Ee){lu(i,s,{then:function(){},status:"rejected",reason:Ee},ds())}finally{R.p=m,y!==null&&D.types!==null&&(y.types=D.types),j.T=y}}function K2(){}function Cm(i,s,a,c){if(i.tag!==5)throw Error(r(476));var h=zS(i).queue;PS(i,h,s,I,a===null?K2:function(){return HS(i),a(c)})}function zS(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:I},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function HS(i){var s=zS(i);s.next===null&&(s=i.alternate.memoizedState),lu(i,s.next.queue,{},ds())}function km(){return Si(ku)}function US(){return Pn().memoizedState}function $S(){return Pn().memoizedState}function q2(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=ds();i=La(a);var c=ja(s,i,a);c!==null&&(ts(c,s,a),iu(c,s,a)),s={cache:em()},i.payload=s;return}s=s.return}}function V2(i,s,a){var c=ds();a={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fh(i)?WS(s,a):(a=Fp(i,s,a,c),a!==null&&(ts(a,i,c),KS(a,s,c)))}function FS(i,s,a){var c=ds();lu(i,s,a,c)}function lu(i,s,a,c){var h={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(fh(i))WS(s,h);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=s.lastRenderedReducer,m!==null))try{var y=s.lastRenderedState,D=m(y,a);if(h.hasEagerState=!0,h.eagerState=D,zi(D,y))return Vd(i,s,h,0),on===null&&qd(),!1}catch{}if(a=Fp(i,s,h,c),a!==null)return ts(a,i,c),KS(a,s,c),!0}return!1}function Tm(i,s,a,c){if(c={lane:2,revertLane:sg(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},fh(i)){if(s)throw Error(r(479))}else s=Fp(i,a,c,2),s!==null&&ts(s,i,2)}function fh(i){var s=i.alternate;return i===wt||s!==null&&s===wt}function WS(i,s){Kl=ah=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function KS(i,s,a){if((a&4194048)!==0){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,En(i,a)}}var cu={readContext:Si,use:ch,useCallback:Nn,useContext:Nn,useEffect:Nn,useImperativeHandle:Nn,useLayoutEffect:Nn,useInsertionEffect:Nn,useMemo:Nn,useReducer:Nn,useRef:Nn,useState:Nn,useDebugValue:Nn,useDeferredValue:Nn,useTransition:Nn,useSyncExternalStore:Nn,useId:Nn,useHostTransitionStatus:Nn,useFormState:Nn,useActionState:Nn,useOptimistic:Nn,useMemoCache:Nn,useCacheRefresh:Nn};cu.useEffectEvent=Nn;var qS={readContext:Si,use:ch,useCallback:function(i,s){return Hi().memoizedState=[i,s===void 0?null:s],i},useContext:Si,useEffect:DS,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,dh(4194308,4,LS.bind(null,s,i),a)},useLayoutEffect:function(i,s){return dh(4194308,4,i,s)},useInsertionEffect:function(i,s){dh(4,2,i,s)},useMemo:function(i,s){var a=Hi();s=s===void 0?null:s;var c=i();if(Go){Lt(!0);try{i()}finally{Lt(!1)}}return a.memoizedState=[c,s],c},useReducer:function(i,s,a){var c=Hi();if(a!==void 0){var h=a(s);if(Go){Lt(!0);try{a(s)}finally{Lt(!1)}}}else h=s;return c.memoizedState=c.baseState=h,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:h},c.queue=i,i=i.dispatch=V2.bind(null,wt,i),[c.memoizedState,i]},useRef:function(i){var s=Hi();return i={current:i},s.memoizedState=i},useState:function(i){i=bm(i);var s=i.queue,a=FS.bind(null,wt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:wm,useDeferredValue:function(i,s){var a=Hi();return xm(a,i,s)},useTransition:function(){var i=bm(!1);return i=PS.bind(null,wt,i.queue,!0,!1),Hi().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var c=wt,h=Hi();if(Pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),on===null)throw Error(r(349));(Ot&127)!==0||fS(c,s,a)}h.memoizedState=a;var m={value:a,getSnapshot:s};return h.queue=m,DS(mS.bind(null,c,m,i),[i]),c.flags|=2048,Vl(9,{destroy:void 0},pS.bind(null,c,m,a,s),null),a},useId:function(){var i=Hi(),s=on.identifierPrefix;if(Pt){var a=fr,c=hr;a=(c&~(1<<32-Ct(c)-1)).toString(32)+a,s="_"+s+"R_"+a,a=oh++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=H2++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:km,useFormState:CS,useActionState:CS,useOptimistic:function(i){var s=Hi();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=Tm.bind(null,wt,!0,a),a.dispatch=s,[i,s]},useMemoCache:gm,useCacheRefresh:function(){return Hi().memoizedState=q2.bind(null,wt)},useEffectEvent:function(i){var s=Hi(),a={impl:i};return s.memoizedState=a,function(){if((Kt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Em={readContext:Si,use:ch,useCallback:OS,useContext:Si,useEffect:Sm,useImperativeHandle:jS,useInsertionEffect:MS,useLayoutEffect:AS,useMemo:BS,useReducer:uh,useRef:RS,useState:function(){return uh(Wr)},useDebugValue:wm,useDeferredValue:function(i,s){var a=Pn();return IS(a,en.memoizedState,i,s)},useTransition:function(){var i=uh(Wr)[0],s=Pn().memoizedState;return[typeof i=="boolean"?i:ou(i),s]},useSyncExternalStore:hS,useId:US,useHostTransitionStatus:km,useFormState:kS,useActionState:kS,useOptimistic:function(i,s){var a=Pn();return _S(a,en,i,s)},useMemoCache:gm,useCacheRefresh:$S};Em.useEffectEvent=NS;var VS={readContext:Si,use:ch,useCallback:OS,useContext:Si,useEffect:Sm,useImperativeHandle:jS,useInsertionEffect:MS,useLayoutEffect:AS,useMemo:BS,useReducer:_m,useRef:RS,useState:function(){return _m(Wr)},useDebugValue:wm,useDeferredValue:function(i,s){var a=Pn();return en===null?xm(a,i,s):IS(a,en.memoizedState,i,s)},useTransition:function(){var i=_m(Wr)[0],s=Pn().memoizedState;return[typeof i=="boolean"?i:ou(i),s]},useSyncExternalStore:hS,useId:US,useHostTransitionStatus:km,useFormState:ES,useActionState:ES,useOptimistic:function(i,s){var a=Pn();return en!==null?_S(a,en,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:gm,useCacheRefresh:$S};VS.useEffectEvent=NS;function Rm(i,s,a,c){s=i.memoizedState,a=a(c,s),a=a==null?s:_({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Dm={enqueueSetState:function(i,s,a){i=i._reactInternals;var c=ds(),h=La(c);h.payload=s,a!=null&&(h.callback=a),s=ja(i,h,c),s!==null&&(ts(s,i,c),iu(s,i,c))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var c=ds(),h=La(c);h.tag=1,h.payload=s,a!=null&&(h.callback=a),s=ja(i,h,c),s!==null&&(ts(s,i,c),iu(s,i,c))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=ds(),c=La(a);c.tag=2,s!=null&&(c.callback=s),s=ja(i,c,a),s!==null&&(ts(s,i,a),iu(s,i,a))}};function YS(i,s,a,c,h,m,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,m,y):s.prototype&&s.prototype.isPureReactComponent?!rs(a,c)||!rs(h,m):!0}function GS(i,s,a,c){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,c),s.state!==i&&Dm.enqueueReplaceState(s,s.state,null)}function Xo(i,s){var a=s;if("ref"in s){a={};for(var c in s)c!=="ref"&&(a[c]=s[c])}if(i=i.defaultProps){a===s&&(a=_({},a));for(var h in i)a[h]===void 0&&(a[h]=i[h])}return a}function XS(i){zo(i)}function ZS(i){console.error(i)}function QS(i){zo(i)}function ph(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(c){setTimeout(function(){throw c})}}function JS(i,s,a){try{var c=i.onCaughtError;c(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function Nm(i,s,a){return a=La(a),a.tag=3,a.payload={element:null},a.callback=function(){ph(i,s)},a}function e0(i){return i=La(i),i.tag=3,i}function t0(i,s,a,c){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var m=c.value;i.payload=function(){return h(m)},i.callback=function(){JS(s,a,c)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){JS(s,a,c),typeof h!="function"&&(Ha===null?Ha=new Set([this]):Ha.add(this));var D=c.stack;this.componentDidCatch(c.value,{componentStack:D!==null?D:""})})}function Y2(i,s,a,c,h){if(a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(s=a.alternate,s!==null&&zl(s,a,h,!0),a=os.current,a!==null){switch(a.tag){case 31:case 13:return Ds===null?Th():a.alternate===null&&Mn===0&&(Mn=3),a.flags&=-257,a.flags|=65536,a.lanes=h,c===th?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([c]):s.add(c),tg(i,c,h)),!1;case 22:return a.flags|=65536,c===th?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([c])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([c]):a.add(c)),tg(i,c,h)),!1}throw Error(r(435,a.tag))}return tg(i,c,h),Th(),!1}if(Pt)return s=os.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=h,c!==Gp&&(i=Error(r(422),{cause:c}),Qc(ks(i,a)))):(c!==Gp&&(s=Error(r(423),{cause:c}),Qc(ks(s,a))),i=i.current.alternate,i.flags|=65536,h&=-h,i.lanes|=h,c=ks(c,a),h=Nm(i.stateNode,c,h),am(i,h),Mn!==4&&(Mn=2)),!1;var m=Error(r(520),{cause:c});if(m=ks(m,a),vu===null?vu=[m]:vu.push(m),Mn!==4&&(Mn=2),s===null)return!0;c=ks(c,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=h&-h,a.lanes|=i,i=Nm(a.stateNode,c,i),am(a,i),!1;case 1:if(s=a.type,m=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Ha===null||!Ha.has(m))))return a.flags|=65536,h&=-h,a.lanes|=h,h=e0(h),t0(h,i,a,c),am(a,h),!1}a=a.return}while(a!==null);return!1}var Mm=Error(r(461)),qn=!1;function wi(i,s,a,c){s.child=i===null?rS(s,null,a,c):Yo(s,i.child,a,c)}function n0(i,s,a,c,h){a=a.render;var m=s.ref;if("ref"in c){var y={};for(var D in c)D!=="ref"&&(y[D]=c[D])}else y=c;return Wo(s),c=hm(i,s,a,y,m,h),D=fm(),i!==null&&!qn?(pm(i,s,h),Kr(i,s,h)):(Pt&&D&&Vp(s),s.flags|=1,wi(i,s,c,h),s.child)}function i0(i,s,a,c,h){if(i===null){var m=a.type;return typeof m=="function"&&!Wp(m)&&m.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=m,s0(i,s,m,c,h)):(i=Gd(a.type,null,c,s,s.mode,h),i.ref=s.ref,i.return=s,s.child=i)}if(m=i.child,!zm(i,h)){var y=m.memoizedProps;if(a=a.compare,a=a!==null?a:rs,a(y,c)&&i.ref===s.ref)return Kr(i,s,h)}return s.flags|=1,i=zr(m,c),i.ref=s.ref,i.return=s,s.child=i}function s0(i,s,a,c,h){if(i!==null){var m=i.memoizedProps;if(rs(m,c)&&i.ref===s.ref)if(qn=!1,s.pendingProps=c=m,zm(i,h))(i.flags&131072)!==0&&(qn=!0);else return s.lanes=i.lanes,Kr(i,s,h)}return Am(i,s,a,c,h)}function r0(i,s,a,c){var h=c.children,m=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((s.flags&128)!==0){if(m=m!==null?m.baseLanes|a:a,i!==null){for(c=s.child=i.child,h=0;c!==null;)h=h|c.lanes|c.childLanes,c=c.sibling;c=h&~m}else c=0,s.child=null;return a0(i,s,m,a,c)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Jd(s,m!==null?m.cachePool:null),m!==null?lS(s,m):lm(),cS(s);else return c=s.lanes=536870912,a0(i,s,m!==null?m.baseLanes|a:a,a,c)}else m!==null?(Jd(s,m.cachePool),lS(s,m),Ba(),s.memoizedState=null):(i!==null&&Jd(s,null),lm(),Ba());return wi(i,s,h,a),s.child}function uu(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function a0(i,s,a,c,h){var m=nm();return m=m===null?null:{parent:Wn._currentValue,pool:m},s.memoizedState={baseLanes:a,cachePool:m},i!==null&&Jd(s,null),lm(),cS(s),i!==null&&zl(i,s,c,!0),s.childLanes=h,null}function mh(i,s){return s=vh({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function o0(i,s,a){return Yo(s,i.child,null,a),i=mh(s,s.pendingProps),i.flags|=2,ls(s),s.memoizedState=null,i}function G2(i,s,a){var c=s.pendingProps,h=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Pt){if(c.mode==="hidden")return i=mh(s,c),s.lanes=536870912,uu(null,i);if(um(s),(i=mn)?(i=bw(i,Rs),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Ra!==null?{id:hr,overflow:fr}:null,retryLane:536870912,hydrationErrors:null},a=Wy(i),a.return=s,s.child=a,yi=s,mn=null)):i=null,i===null)throw Na(s);return s.lanes=536870912,null}return mh(s,c)}var m=i.memoizedState;if(m!==null){var y=m.dehydrated;if(um(s),h)if(s.flags&256)s.flags&=-257,s=o0(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(qn||zl(i,s,a,!1),h=(a&i.childLanes)!==0,qn||h){if(c=on,c!==null&&(y=wn(c,a),y!==0&&y!==m.retryLane))throw m.retryLane=y,Ho(i,y),ts(c,i,y),Mm;Th(),s=o0(i,s,a)}else i=m.treeContext,mn=Ns(y.nextSibling),yi=s,Pt=!0,Da=null,Rs=!1,i!==null&&Vy(s,i),s=mh(s,c),s.flags|=4096;return s}return i=zr(i.child,{mode:c.mode,children:c.children}),i.ref=s.ref,s.child=i,i.return=s,i}function gh(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function Am(i,s,a,c,h){return Wo(s),a=hm(i,s,a,c,void 0,h),c=fm(),i!==null&&!qn?(pm(i,s,h),Kr(i,s,h)):(Pt&&c&&Vp(s),s.flags|=1,wi(i,s,a,h),s.child)}function l0(i,s,a,c,h,m){return Wo(s),s.updateQueue=null,a=dS(s,c,a,h),uS(i),c=fm(),i!==null&&!qn?(pm(i,s,m),Kr(i,s,m)):(Pt&&c&&Vp(s),s.flags|=1,wi(i,s,a,m),s.child)}function c0(i,s,a,c,h){if(Wo(s),s.stateNode===null){var m=Ol,y=a.contextType;typeof y=="object"&&y!==null&&(m=Si(y)),m=new a(c,m),s.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=Dm,s.stateNode=m,m._reactInternals=s,m=s.stateNode,m.props=c,m.state=s.memoizedState,m.refs={},sm(s),y=a.contextType,m.context=typeof y=="object"&&y!==null?Si(y):Ol,m.state=s.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Rm(s,a,y,c),m.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(y=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),y!==m.state&&Dm.enqueueReplaceState(m,m.state,null),ru(s,c,m,h),su(),m.state=s.memoizedState),typeof m.componentDidMount=="function"&&(s.flags|=4194308),c=!0}else if(i===null){m=s.stateNode;var D=s.memoizedProps,z=Xo(a,D);m.props=z;var he=m.context,xe=a.contextType;y=Ol,typeof xe=="object"&&xe!==null&&(y=Si(xe));var Ee=a.getDerivedStateFromProps;xe=typeof Ee=="function"||typeof m.getSnapshotBeforeUpdate=="function",D=s.pendingProps!==D,xe||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(D||he!==y)&&GS(s,m,c,y),Aa=!1;var me=s.memoizedState;m.state=me,ru(s,c,m,h),su(),he=s.memoizedState,D||me!==he||Aa?(typeof Ee=="function"&&(Rm(s,a,Ee,c),he=s.memoizedState),(z=Aa||YS(s,a,z,c,me,he,y))?(xe||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(s.flags|=4194308)):(typeof m.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=he),m.props=c,m.state=he,m.context=y,c=z):(typeof m.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{m=s.stateNode,rm(i,s),y=s.memoizedProps,xe=Xo(a,y),m.props=xe,Ee=s.pendingProps,me=m.context,he=a.contextType,z=Ol,typeof he=="object"&&he!==null&&(z=Si(he)),D=a.getDerivedStateFromProps,(he=typeof D=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(y!==Ee||me!==z)&&GS(s,m,c,z),Aa=!1,me=s.memoizedState,m.state=me,ru(s,c,m,h),su();var ye=s.memoizedState;y!==Ee||me!==ye||Aa||i!==null&&i.dependencies!==null&&Zd(i.dependencies)?(typeof D=="function"&&(Rm(s,a,D,c),ye=s.memoizedState),(xe=Aa||YS(s,a,xe,c,me,ye,z)||i!==null&&i.dependencies!==null&&Zd(i.dependencies))?(he||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(c,ye,z),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(c,ye,z)),typeof m.componentDidUpdate=="function"&&(s.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=ye),m.props=c,m.state=ye,m.context=z,c=xe):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(s.flags|=1024),c=!1)}return m=c,gh(i,s),c=(s.flags&128)!==0,m||c?(m=s.stateNode,a=c&&typeof a.getDerivedStateFromError!="function"?null:m.render(),s.flags|=1,i!==null&&c?(s.child=Yo(s,i.child,null,h),s.child=Yo(s,null,a,h)):wi(i,s,a,h),s.memoizedState=m.state,i=s.child):i=Kr(i,s,h),i}function u0(i,s,a,c){return $o(),s.flags|=256,wi(i,s,a,c),s.child}var Lm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function jm(i){return{baseLanes:i,cachePool:Jy()}}function Om(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=us),i}function d0(i,s,a){var c=s.pendingProps,h=!1,m=(s.flags&128)!==0,y;if((y=m)||(y=i!==null&&i.memoizedState===null?!1:(In.current&2)!==0),y&&(h=!0,s.flags&=-129),y=(s.flags&32)!==0,s.flags&=-33,i===null){if(Pt){if(h?Oa(s):Ba(),(i=mn)?(i=bw(i,Rs),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Ra!==null?{id:hr,overflow:fr}:null,retryLane:536870912,hydrationErrors:null},a=Wy(i),a.return=s,s.child=a,yi=s,mn=null)):i=null,i===null)throw Na(s);return vg(i)?s.lanes=32:s.lanes=536870912,null}var D=c.children;return c=c.fallback,h?(Ba(),h=s.mode,D=vh({mode:"hidden",children:D},h),c=Uo(c,h,a,null),D.return=s,c.return=s,D.sibling=c,s.child=D,c=s.child,c.memoizedState=jm(a),c.childLanes=Om(i,y,a),s.memoizedState=Lm,uu(null,c)):(Oa(s),Bm(s,D))}var z=i.memoizedState;if(z!==null&&(D=z.dehydrated,D!==null)){if(m)s.flags&256?(Oa(s),s.flags&=-257,s=Im(i,s,a)):s.memoizedState!==null?(Ba(),s.child=i.child,s.flags|=128,s=null):(Ba(),D=c.fallback,h=s.mode,c=vh({mode:"visible",children:c.children},h),D=Uo(D,h,a,null),D.flags|=2,c.return=s,D.return=s,c.sibling=D,s.child=c,Yo(s,i.child,null,a),c=s.child,c.memoizedState=jm(a),c.childLanes=Om(i,y,a),s.memoizedState=Lm,s=uu(null,c));else if(Oa(s),vg(D)){if(y=D.nextSibling&&D.nextSibling.dataset,y)var he=y.dgst;y=he,c=Error(r(419)),c.stack="",c.digest=y,Qc({value:c,source:null,stack:null}),s=Im(i,s,a)}else if(qn||zl(i,s,a,!1),y=(a&i.childLanes)!==0,qn||y){if(y=on,y!==null&&(c=wn(y,a),c!==0&&c!==z.retryLane))throw z.retryLane=c,Ho(i,c),ts(y,i,c),Mm;gg(D)||Th(),s=Im(i,s,a)}else gg(D)?(s.flags|=192,s.child=i.child,s=null):(i=z.treeContext,mn=Ns(D.nextSibling),yi=s,Pt=!0,Da=null,Rs=!1,i!==null&&Vy(s,i),s=Bm(s,c.children),s.flags|=4096);return s}return h?(Ba(),D=c.fallback,h=s.mode,z=i.child,he=z.sibling,c=zr(z,{mode:"hidden",children:c.children}),c.subtreeFlags=z.subtreeFlags&65011712,he!==null?D=zr(he,D):(D=Uo(D,h,a,null),D.flags|=2),D.return=s,c.return=s,c.sibling=D,s.child=c,uu(null,c),c=s.child,D=i.child.memoizedState,D===null?D=jm(a):(h=D.cachePool,h!==null?(z=Wn._currentValue,h=h.parent!==z?{parent:z,pool:z}:h):h=Jy(),D={baseLanes:D.baseLanes|a,cachePool:h}),c.memoizedState=D,c.childLanes=Om(i,y,a),s.memoizedState=Lm,uu(i.child,c)):(Oa(s),a=i.child,i=a.sibling,a=zr(a,{mode:"visible",children:c.children}),a.return=s,a.sibling=null,i!==null&&(y=s.deletions,y===null?(s.deletions=[i],s.flags|=16):y.push(i)),s.child=a,s.memoizedState=null,a)}function Bm(i,s){return s=vh({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function vh(i,s){return i=as(22,i,null,s),i.lanes=0,i}function Im(i,s,a){return Yo(s,i.child,null,a),i=Bm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function h0(i,s,a){i.lanes|=s;var c=i.alternate;c!==null&&(c.lanes|=s),Qp(i.return,s,a)}function Pm(i,s,a,c,h,m){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:h,treeForkCount:m}:(y.isBackwards=s,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=a,y.tailMode=h,y.treeForkCount=m)}function f0(i,s,a){var c=s.pendingProps,h=c.revealOrder,m=c.tail;c=c.children;var y=In.current,D=(y&2)!==0;if(D?(y=y&1|2,s.flags|=128):y&=1,oe(In,y),wi(i,s,c,a),c=Pt?Zc:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&h0(i,a,s);else if(i.tag===19)h0(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(h){case"forwards":for(a=s.child,h=null;a!==null;)i=a.alternate,i!==null&&rh(i)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),Pm(s,!1,h,a,m,c);break;case"backwards":case"unstable_legacy-backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(i=h.alternate,i!==null&&rh(i)===null){s.child=h;break}i=h.sibling,h.sibling=a,a=h,h=i}Pm(s,!0,a,null,m,c);break;case"together":Pm(s,!1,null,null,void 0,c);break;default:s.memoizedState=null}return s.child}function Kr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),za|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(zl(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=zr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=zr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function zm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Zd(i)))}function X2(i,s,a){switch(s.tag){case 3:Re(s,s.stateNode.containerInfo),Ma(s,Wn,i.memoizedState.cache),$o();break;case 27:case 5:ge(s);break;case 4:Re(s,s.stateNode.containerInfo);break;case 10:Ma(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,um(s),null;break;case 13:var c=s.memoizedState;if(c!==null)return c.dehydrated!==null?(Oa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?d0(i,s,a):(Oa(s),i=Kr(i,s,a),i!==null?i.sibling:null);Oa(s);break;case 19:var h=(i.flags&128)!==0;if(c=(a&s.childLanes)!==0,c||(zl(i,s,a,!1),c=(a&s.childLanes)!==0),h){if(c)return f0(i,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),oe(In,In.current),c)break;return null;case 22:return s.lanes=0,r0(i,s,a,s.pendingProps);case 24:Ma(s,Wn,i.memoizedState.cache)}return Kr(i,s,a)}function p0(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)qn=!0;else{if(!zm(i,a)&&(s.flags&128)===0)return qn=!1,X2(i,s,a);qn=(i.flags&131072)!==0}else qn=!1,Pt&&(s.flags&1048576)!==0&&qy(s,Zc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var c=s.pendingProps;if(i=qo(s.elementType),s.type=i,typeof i=="function")Wp(i)?(c=Xo(i,c),s.tag=1,s=c0(null,s,i,c,a)):(s.tag=0,s=Am(null,s,i,c,a));else{if(i!=null){var h=i.$$typeof;if(h===P){s.tag=11,s=n0(null,s,i,c,a);break e}else if(h===O){s.tag=14,s=i0(null,s,i,c,a);break e}}throw s=ie(i)||i,Error(r(306,s,""))}}return s;case 0:return Am(i,s,s.type,s.pendingProps,a);case 1:return c=s.type,h=Xo(c,s.pendingProps),c0(i,s,c,h,a);case 3:e:{if(Re(s,s.stateNode.containerInfo),i===null)throw Error(r(387));c=s.pendingProps;var m=s.memoizedState;h=m.element,rm(i,s),ru(s,c,null,a);var y=s.memoizedState;if(c=y.cache,Ma(s,Wn,c),c!==m.cache&&Jp(s,[Wn],a,!0),su(),c=y.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:y.cache},s.updateQueue.baseState=m,s.memoizedState=m,s.flags&256){s=u0(i,s,c,a);break e}else if(c!==h){h=ks(Error(r(424)),s),Qc(h),s=u0(i,s,c,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,mn=Ns(i.firstChild),yi=s,Pt=!0,Da=null,Rs=!0,a=rS(s,null,c,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if($o(),c===h){s=Kr(i,s,a);break e}wi(i,s,c,a)}s=s.child}return s;case 26:return gh(i,s),i===null?(a=kw(s.type,null,s.pendingProps,null))?s.memoizedState=a:Pt||(a=s.type,i=s.pendingProps,c=Lh(Se.current).createElement(a),c[Ce]=s,c[Ye]=i,xi(c,a,i),pn(c),s.stateNode=c):s.memoizedState=kw(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return ge(s),i===null&&Pt&&(c=s.stateNode=ww(s.type,s.pendingProps,Se.current),yi=s,Rs=!0,h=mn,Wa(s.type)?(_g=h,mn=Ns(c.firstChild)):mn=h),wi(i,s,s.pendingProps.children,a),gh(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Pt&&((h=c=mn)&&(c=TR(c,s.type,s.pendingProps,Rs),c!==null?(s.stateNode=c,yi=s,mn=Ns(c.firstChild),Rs=!1,h=!0):h=!1),h||Na(s)),ge(s),h=s.type,m=s.pendingProps,y=i!==null?i.memoizedProps:null,c=m.children,fg(h,m)?c=null:y!==null&&fg(h,y)&&(s.flags|=32),s.memoizedState!==null&&(h=hm(i,s,U2,null,null,a),ku._currentValue=h),gh(i,s),wi(i,s,c,a),s.child;case 6:return i===null&&Pt&&((i=a=mn)&&(a=ER(a,s.pendingProps,Rs),a!==null?(s.stateNode=a,yi=s,mn=null,i=!0):i=!1),i||Na(s)),null;case 13:return d0(i,s,a);case 4:return Re(s,s.stateNode.containerInfo),c=s.pendingProps,i===null?s.child=Yo(s,null,c,a):wi(i,s,c,a),s.child;case 11:return n0(i,s,s.type,s.pendingProps,a);case 7:return wi(i,s,s.pendingProps,a),s.child;case 8:return wi(i,s,s.pendingProps.children,a),s.child;case 12:return wi(i,s,s.pendingProps.children,a),s.child;case 10:return c=s.pendingProps,Ma(s,s.type,c.value),wi(i,s,c.children,a),s.child;case 9:return h=s.type._context,c=s.pendingProps.children,Wo(s),h=Si(h),c=c(h),s.flags|=1,wi(i,s,c,a),s.child;case 14:return i0(i,s,s.type,s.pendingProps,a);case 15:return s0(i,s,s.type,s.pendingProps,a);case 19:return f0(i,s,a);case 31:return G2(i,s,a);case 22:return r0(i,s,a,s.pendingProps);case 24:return Wo(s),c=Si(Wn),i===null?(h=nm(),h===null&&(h=on,m=em(),h.pooledCache=m,m.refCount++,m!==null&&(h.pooledCacheLanes|=a),h=m),s.memoizedState={parent:c,cache:h},sm(s),Ma(s,Wn,h)):((i.lanes&a)!==0&&(rm(i,s),ru(s,null,null,a),su()),h=i.memoizedState,m=s.memoizedState,h.parent!==c?(h={parent:c,cache:c},s.memoizedState=h,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=h),Ma(s,Wn,c)):(c=m.cache,Ma(s,Wn,c),c!==h.cache&&Jp(s,[Wn],a,!0))),wi(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function qr(i){i.flags|=4}function Hm(i,s,a,c,h){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(h&335544128)===h)if(i.stateNode.complete)i.flags|=8192;else if(U0())i.flags|=8192;else throw Vo=th,im}else i.flags&=-16777217}function m0(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Nw(s))if(U0())i.flags|=8192;else throw Vo=th,im}function _h(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Gt():536870912,i.lanes|=s,Zl|=s)}function du(i,s){if(!Pt)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function gn(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(s)for(var h=i.child;h!==null;)a|=h.lanes|h.childLanes,c|=h.subtreeFlags&65011712,c|=h.flags&65011712,h.return=i,h=h.sibling;else for(h=i.child;h!==null;)a|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=i,h=h.sibling;return i.subtreeFlags|=c,i.childLanes=a,s}function Z2(i,s,a){var c=s.pendingProps;switch(Yp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(s),null;case 1:return gn(s),null;case 3:return a=s.stateNode,c=null,i!==null&&(c=i.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),$r(Wn),Oe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Pl(s)?qr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Xp())),gn(s),null;case 26:var h=s.type,m=s.memoizedState;return i===null?(qr(s),m!==null?(gn(s),m0(s,m)):(gn(s),Hm(s,h,null,c,a))):m?m!==i.memoizedState?(qr(s),gn(s),m0(s,m)):(gn(s),s.flags&=-16777217):(i=i.memoizedProps,i!==c&&qr(s),gn(s),Hm(s,h,i,c,a)),null;case 27:if(He(s),a=Se.current,h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==c&&qr(s);else{if(!c){if(s.stateNode===null)throw Error(r(166));return gn(s),null}i=Q.current,Pl(s)?Yy(s):(i=ww(h,c,a),s.stateNode=i,qr(s))}return gn(s),null;case 5:if(He(s),h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==c&&qr(s);else{if(!c){if(s.stateNode===null)throw Error(r(166));return gn(s),null}if(m=Q.current,Pl(s))Yy(s);else{var y=Lh(Se.current);switch(m){case 1:m=y.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:m=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":m=y.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":m=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":m=y.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof c.is=="string"?y.createElement("select",{is:c.is}):y.createElement("select"),c.multiple?m.multiple=!0:c.size&&(m.size=c.size);break;default:m=typeof c.is=="string"?y.createElement(h,{is:c.is}):y.createElement(h)}}m[Ce]=s,m[Ye]=c;e:for(y=s.child;y!==null;){if(y.tag===5||y.tag===6)m.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===s)break e;for(;y.sibling===null;){if(y.return===null||y.return===s)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}s.stateNode=m;e:switch(xi(m,h,c),h){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&qr(s)}}return gn(s),Hm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==c&&qr(s);else{if(typeof c!="string"&&s.stateNode===null)throw Error(r(166));if(i=Se.current,Pl(s)){if(i=s.stateNode,a=s.memoizedProps,c=null,h=yi,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}i[Ce]=s,i=!!(i.nodeValue===a||c!==null&&c.suppressHydrationWarning===!0||dw(i.nodeValue,a)),i||Na(s,!0)}else i=Lh(i).createTextNode(c),i[Ce]=s,s.stateNode=i}return gn(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(c=Pl(s),a!==null){if(i===null){if(!c)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Ce]=s}else $o(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;gn(s),i=!1}else a=Xp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(ls(s),s):(ls(s),null);if((s.flags&128)!==0)throw Error(r(558))}return gn(s),null;case 13:if(c=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(h=Pl(s),c!==null&&c.dehydrated!==null){if(i===null){if(!h)throw Error(r(318));if(h=s.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[Ce]=s}else $o(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;gn(s),h=!1}else h=Xp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=h),h=!0;if(!h)return s.flags&256?(ls(s),s):(ls(s),null)}return ls(s),(s.flags&128)!==0?(s.lanes=a,s):(a=c!==null,i=i!==null&&i.memoizedState!==null,a&&(c=s.child,h=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(h=c.alternate.memoizedState.cachePool.pool),m=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),m!==h&&(c.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),_h(s,s.updateQueue),gn(s),null);case 4:return Oe(),i===null&&lg(s.stateNode.containerInfo),gn(s),null;case 10:return $r(s.type),gn(s),null;case 19:if(Y(In),c=s.memoizedState,c===null)return gn(s),null;if(h=(s.flags&128)!==0,m=c.rendering,m===null)if(h)du(c,!1);else{if(Mn!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(m=rh(i),m!==null){for(s.flags|=128,du(c,!1),i=m.updateQueue,s.updateQueue=i,_h(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)Fy(a,i),a=a.sibling;return oe(In,In.current&1|2),Pt&&Hr(s,c.treeForkCount),s.child}i=i.sibling}c.tail!==null&&We()>xh&&(s.flags|=128,h=!0,du(c,!1),s.lanes=4194304)}else{if(!h)if(i=rh(m),i!==null){if(s.flags|=128,h=!0,i=i.updateQueue,s.updateQueue=i,_h(s,i),du(c,!0),c.tail===null&&c.tailMode==="hidden"&&!m.alternate&&!Pt)return gn(s),null}else 2*We()-c.renderingStartTime>xh&&a!==536870912&&(s.flags|=128,h=!0,du(c,!1),s.lanes=4194304);c.isBackwards?(m.sibling=s.child,s.child=m):(i=c.last,i!==null?i.sibling=m:s.child=m,c.last=m)}return c.tail!==null?(i=c.tail,c.rendering=i,c.tail=i.sibling,c.renderingStartTime=We(),i.sibling=null,a=In.current,oe(In,h?a&1|2:a&1),Pt&&Hr(s,c.treeForkCount),i):(gn(s),null);case 22:case 23:return ls(s),cm(),c=s.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(s.flags|=8192):c&&(s.flags|=8192),c?(a&536870912)!==0&&(s.flags&128)===0&&(gn(s),s.subtreeFlags&6&&(s.flags|=8192)):gn(s),a=s.updateQueue,a!==null&&_h(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),c=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),c!==a&&(s.flags|=2048),i!==null&&Y(Ko),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),$r(Wn),gn(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function Q2(i,s){switch(Yp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return $r(Wn),Oe(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return He(s),null;case 31:if(s.memoizedState!==null){if(ls(s),s.alternate===null)throw Error(r(340));$o()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(ls(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));$o()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return Y(In),null;case 4:return Oe(),null;case 10:return $r(s.type),null;case 22:case 23:return ls(s),cm(),i!==null&&Y(Ko),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return $r(Wn),null;case 25:return null;default:return null}}function g0(i,s){switch(Yp(s),s.tag){case 3:$r(Wn),Oe();break;case 26:case 27:case 5:He(s);break;case 4:Oe();break;case 31:s.memoizedState!==null&&ls(s);break;case 13:ls(s);break;case 19:Y(In);break;case 10:$r(s.type);break;case 22:case 23:ls(s),cm(),i!==null&&Y(Ko);break;case 24:$r(Wn)}}function hu(i,s){try{var a=s.updateQueue,c=a!==null?a.lastEffect:null;if(c!==null){var h=c.next;a=h;do{if((a.tag&i)===i){c=void 0;var m=a.create,y=a.inst;c=m(),y.destroy=c}a=a.next}while(a!==h)}}catch(D){Qt(s,s.return,D)}}function Ia(i,s,a){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var m=h.next;c=m;do{if((c.tag&i)===i){var y=c.inst,D=y.destroy;if(D!==void 0){y.destroy=void 0,h=s;var z=a,he=D;try{he()}catch(xe){Qt(h,z,xe)}}}c=c.next}while(c!==m)}}catch(xe){Qt(s,s.return,xe)}}function v0(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{oS(s,a)}catch(c){Qt(i,i.return,c)}}}function _0(i,s,a){a.props=Xo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(c){Qt(i,s,c)}}function fu(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var c=i.stateNode;break;case 30:c=i.stateNode;break;default:c=i.stateNode}typeof a=="function"?i.refCleanup=a(c):a.current=c}}catch(h){Qt(i,s,h)}}function pr(i,s){var a=i.ref,c=i.refCleanup;if(a!==null)if(typeof c=="function")try{c()}catch(h){Qt(i,s,h)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(h){Qt(i,s,h)}else a.current=null}function b0(i){var s=i.type,a=i.memoizedProps,c=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&c.focus();break e;case"img":a.src?c.src=a.src:a.srcSet&&(c.srcset=a.srcSet)}}catch(h){Qt(i,i.return,h)}}function Um(i,s,a){try{var c=i.stateNode;yR(c,i.type,a,s),c[Ye]=s}catch(h){Qt(i,i.return,h)}}function y0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Wa(i.type)||i.tag===4}function $m(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||y0(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&&Wa(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 Fm(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Bi));else if(c!==4&&(c===27&&Wa(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Fm(i,s,a),i=i.sibling;i!==null;)Fm(i,s,a),i=i.sibling}function bh(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(c!==4&&(c===27&&Wa(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(bh(i,s,a),i=i.sibling;i!==null;)bh(i,s,a),i=i.sibling}function S0(i){var s=i.stateNode,a=i.memoizedProps;try{for(var c=i.type,h=s.attributes;h.length;)s.removeAttributeNode(h[0]);xi(s,c,a),s[Ce]=i,s[Ye]=a}catch(m){Qt(i,i.return,m)}}var Vr=!1,Vn=!1,Wm=!1,w0=typeof WeakSet=="function"?WeakSet:Set,ci=null;function J2(i,s){if(i=i.containerInfo,dg=Hh,i=Xc(i),ws(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var h=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var y=0,D=-1,z=-1,he=0,xe=0,Ee=i,me=null;t:for(;;){for(var ye;Ee!==a||h!==0&&Ee.nodeType!==3||(D=y+h),Ee!==m||c!==0&&Ee.nodeType!==3||(z=y+c),Ee.nodeType===3&&(y+=Ee.nodeValue.length),(ye=Ee.firstChild)!==null;)me=Ee,Ee=ye;for(;;){if(Ee===i)break t;if(me===a&&++he===h&&(D=y),me===m&&++xe===c&&(z=y),(ye=Ee.nextSibling)!==null)break;Ee=me,me=Ee.parentNode}Ee=ye}a=D===-1||z===-1?null:{start:D,end:z}}else a=null}a=a||{start:0,end:0}}else a=null;for(hg={focusedElem:i,selectionRange:a},Hh=!1,ci=s;ci!==null;)if(s=ci,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,ci=i;else for(;ci!==null;){switch(s=ci,m=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)h=i[a],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&m!==null){i=void 0,a=s,h=m.memoizedProps,m=m.memoizedState,c=a.stateNode;try{var Ge=Xo(a.type,h);i=c.getSnapshotBeforeUpdate(Ge,m),c.__reactInternalSnapshotBeforeUpdate=i}catch(ct){Qt(a,a.return,ct)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)mg(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":mg(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,ci=i;break}ci=s.return}}function x0(i,s,a){var c=a.flags;switch(a.tag){case 0:case 11:case 15:Gr(i,a),c&4&&hu(5,a);break;case 1:if(Gr(i,a),c&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(y){Qt(a,a.return,y)}else{var h=Xo(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(h,s,i.__reactInternalSnapshotBeforeUpdate)}catch(y){Qt(a,a.return,y)}}c&64&&v0(a),c&512&&fu(a,a.return);break;case 3:if(Gr(i,a),c&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{oS(i,s)}catch(y){Qt(a,a.return,y)}}break;case 27:s===null&&c&4&&S0(a);case 26:case 5:Gr(i,a),s===null&&c&4&&b0(a),c&512&&fu(a,a.return);break;case 12:Gr(i,a);break;case 31:Gr(i,a),c&4&&T0(i,a);break;case 13:Gr(i,a),c&4&&E0(i,a),c&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=lR.bind(null,a),RR(i,a))));break;case 22:if(c=a.memoizedState!==null||Vr,!c){s=s!==null&&s.memoizedState!==null||Vn,h=Vr;var m=Vn;Vr=c,(Vn=s)&&!m?Xr(i,a,(a.subtreeFlags&8772)!==0):Gr(i,a),Vr=h,Vn=m}break;case 30:break;default:Gr(i,a)}}function C0(i){var s=i.alternate;s!==null&&(i.alternate=null,C0(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Ai(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var _n=null,Zi=!1;function Yr(i,s,a){for(a=a.child;a!==null;)k0(i,s,a),a=a.sibling}function k0(i,s,a){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(Sn,a)}catch{}switch(a.tag){case 26:Vn||pr(a,s),Yr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Vn||pr(a,s);var c=_n,h=Zi;Wa(a.type)&&(_n=a.stateNode,Zi=!1),Yr(i,s,a),wu(a.stateNode),_n=c,Zi=h;break;case 5:Vn||pr(a,s);case 6:if(c=_n,h=Zi,_n=null,Yr(i,s,a),_n=c,Zi=h,_n!==null)if(Zi)try{(_n.nodeType===9?_n.body:_n.nodeName==="HTML"?_n.ownerDocument.body:_n).removeChild(a.stateNode)}catch(m){Qt(a,s,m)}else try{_n.removeChild(a.stateNode)}catch(m){Qt(a,s,m)}break;case 18:_n!==null&&(Zi?(i=_n,vw(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),rc(i)):vw(_n,a.stateNode));break;case 4:c=_n,h=Zi,_n=a.stateNode.containerInfo,Zi=!0,Yr(i,s,a),_n=c,Zi=h;break;case 0:case 11:case 14:case 15:Ia(2,a,s),Vn||Ia(4,a,s),Yr(i,s,a);break;case 1:Vn||(pr(a,s),c=a.stateNode,typeof c.componentWillUnmount=="function"&&_0(a,s,c)),Yr(i,s,a);break;case 21:Yr(i,s,a);break;case 22:Vn=(c=Vn)||a.memoizedState!==null,Yr(i,s,a),Vn=c;break;default:Yr(i,s,a)}}function T0(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{rc(i)}catch(a){Qt(s,s.return,a)}}}function E0(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{rc(i)}catch(a){Qt(s,s.return,a)}}function eR(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new w0),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new w0),s;default:throw Error(r(435,i.tag))}}function yh(i,s){var a=eR(i);s.forEach(function(c){if(!a.has(c)){a.add(c);var h=cR.bind(null,i,c);c.then(h,h)}})}function Qi(i,s){var a=s.deletions;if(a!==null)for(var c=0;c<a.length;c++){var h=a[c],m=i,y=s,D=y;e:for(;D!==null;){switch(D.tag){case 27:if(Wa(D.type)){_n=D.stateNode,Zi=!1;break e}break;case 5:_n=D.stateNode,Zi=!1;break e;case 3:case 4:_n=D.stateNode.containerInfo,Zi=!0;break e}D=D.return}if(_n===null)throw Error(r(160));k0(m,y,h),_n=null,Zi=!1,m=h.alternate,m!==null&&(m.return=null),h.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)R0(s,i),s=s.sibling}var Ys=null;function R0(i,s){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Qi(s,i),Ji(i),c&4&&(Ia(3,i,i.return),hu(3,i),Ia(5,i,i.return));break;case 1:Qi(s,i),Ji(i),c&512&&(Vn||a===null||pr(a,a.return)),c&64&&Vr&&(i=i.updateQueue,i!==null&&(c=i.callbacks,c!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?c:a.concat(c))));break;case 26:var h=Ys;if(Qi(s,i),Ji(i),c&512&&(Vn||a===null||pr(a,a.return)),c&4){var m=a!==null?a.memoizedState:null;if(c=i.memoizedState,a===null)if(c===null)if(i.stateNode===null){e:{c=i.type,a=i.memoizedProps,h=h.ownerDocument||h;t:switch(c){case"title":m=h.getElementsByTagName("title")[0],(!m||m[Ft]||m[Ce]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=h.createElement(c),h.head.insertBefore(m,h.querySelector("head > title"))),xi(m,c,a),m[Ce]=i,pn(m),c=m;break e;case"link":var y=Rw("link","href",h).get(c+(a.href||""));if(y){for(var D=0;D<y.length;D++)if(m=y[D],m.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&m.getAttribute("rel")===(a.rel==null?null:a.rel)&&m.getAttribute("title")===(a.title==null?null:a.title)&&m.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(D,1);break t}}m=h.createElement(c),xi(m,c,a),h.head.appendChild(m);break;case"meta":if(y=Rw("meta","content",h).get(c+(a.content||""))){for(D=0;D<y.length;D++)if(m=y[D],m.getAttribute("content")===(a.content==null?null:""+a.content)&&m.getAttribute("name")===(a.name==null?null:a.name)&&m.getAttribute("property")===(a.property==null?null:a.property)&&m.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&m.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(D,1);break t}}m=h.createElement(c),xi(m,c,a),h.head.appendChild(m);break;default:throw Error(r(468,c))}m[Ce]=i,pn(m),c=m}i.stateNode=c}else Dw(h,i.type,i.stateNode);else i.stateNode=Ew(h,c,i.memoizedProps);else m!==c?(m===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):m.count--,c===null?Dw(h,i.type,i.stateNode):Ew(h,c,i.memoizedProps)):c===null&&i.stateNode!==null&&Um(i,i.memoizedProps,a.memoizedProps)}break;case 27:Qi(s,i),Ji(i),c&512&&(Vn||a===null||pr(a,a.return)),a!==null&&c&4&&Um(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Qi(s,i),Ji(i),c&512&&(Vn||a===null||pr(a,a.return)),i.flags&32){h=i.stateNode;try{Hs(h,"")}catch(Ge){Qt(i,i.return,Ge)}}c&4&&i.stateNode!=null&&(h=i.memoizedProps,Um(i,h,a!==null?a.memoizedProps:h)),c&1024&&(Wm=!0);break;case 6:if(Qi(s,i),Ji(i),c&4){if(i.stateNode===null)throw Error(r(162));c=i.memoizedProps,a=i.stateNode;try{a.nodeValue=c}catch(Ge){Qt(i,i.return,Ge)}}break;case 3:if(Bh=null,h=Ys,Ys=jh(s.containerInfo),Qi(s,i),Ys=h,Ji(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{rc(s.containerInfo)}catch(Ge){Qt(i,i.return,Ge)}Wm&&(Wm=!1,D0(i));break;case 4:c=Ys,Ys=jh(i.stateNode.containerInfo),Qi(s,i),Ji(i),Ys=c;break;case 12:Qi(s,i),Ji(i);break;case 31:Qi(s,i),Ji(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,yh(i,c)));break;case 13:Qi(s,i),Ji(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(wh=We()),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,yh(i,c)));break;case 22:h=i.memoizedState!==null;var z=a!==null&&a.memoizedState!==null,he=Vr,xe=Vn;if(Vr=he||h,Vn=xe||z,Qi(s,i),Vn=xe,Vr=he,Ji(i),c&8192)e:for(s=i.stateNode,s._visibility=h?s._visibility&-2:s._visibility|1,h&&(a===null||z||Vr||Vn||Zo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){z=a=s;try{if(m=z.stateNode,h)y=m.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{D=z.stateNode;var Ee=z.memoizedProps.style,me=Ee!=null&&Ee.hasOwnProperty("display")?Ee.display:null;D.style.display=me==null||typeof me=="boolean"?"":(""+me).trim()}}catch(Ge){Qt(z,z.return,Ge)}}}else if(s.tag===6){if(a===null){z=s;try{z.stateNode.nodeValue=h?"":z.memoizedProps}catch(Ge){Qt(z,z.return,Ge)}}}else if(s.tag===18){if(a===null){z=s;try{var ye=z.stateNode;h?_w(ye,!0):_w(z.stateNode,!1)}catch(Ge){Qt(z,z.return,Ge)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}c&4&&(c=i.updateQueue,c!==null&&(a=c.retryQueue,a!==null&&(c.retryQueue=null,yh(i,a))));break;case 19:Qi(s,i),Ji(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,yh(i,c)));break;case 30:break;case 21:break;default:Qi(s,i),Ji(i)}}function Ji(i){var s=i.flags;if(s&2){try{for(var a,c=i.return;c!==null;){if(y0(c)){a=c;break}c=c.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var h=a.stateNode,m=$m(i);bh(i,m,h);break;case 5:var y=a.stateNode;a.flags&32&&(Hs(y,""),a.flags&=-33);var D=$m(i);bh(i,D,y);break;case 3:case 4:var z=a.stateNode.containerInfo,he=$m(i);Fm(i,he,z);break;default:throw Error(r(161))}}catch(xe){Qt(i,i.return,xe)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function D0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;D0(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function Gr(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)x0(i,s.alternate,s),s=s.sibling}function Zo(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:Ia(4,s,s.return),Zo(s);break;case 1:pr(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&_0(s,s.return,a),Zo(s);break;case 27:wu(s.stateNode);case 26:case 5:pr(s,s.return),Zo(s);break;case 22:s.memoizedState===null&&Zo(s);break;case 30:Zo(s);break;default:Zo(s)}i=i.sibling}}function Xr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var c=s.alternate,h=i,m=s,y=m.flags;switch(m.tag){case 0:case 11:case 15:Xr(h,m,a),hu(4,m);break;case 1:if(Xr(h,m,a),c=m,h=c.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(he){Qt(c,c.return,he)}if(c=m,h=c.updateQueue,h!==null){var D=c.stateNode;try{var z=h.shared.hiddenCallbacks;if(z!==null)for(h.shared.hiddenCallbacks=null,h=0;h<z.length;h++)aS(z[h],D)}catch(he){Qt(c,c.return,he)}}a&&y&64&&v0(m),fu(m,m.return);break;case 27:S0(m);case 26:case 5:Xr(h,m,a),a&&c===null&&y&4&&b0(m),fu(m,m.return);break;case 12:Xr(h,m,a);break;case 31:Xr(h,m,a),a&&y&4&&T0(h,m);break;case 13:Xr(h,m,a),a&&y&4&&E0(h,m);break;case 22:m.memoizedState===null&&Xr(h,m,a),fu(m,m.return);break;case 30:break;default:Xr(h,m,a)}s=s.sibling}}function Km(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Jc(a))}function qm(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Jc(i))}function Gs(i,s,a,c){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)N0(i,s,a,c),s=s.sibling}function N0(i,s,a,c){var h=s.flags;switch(s.tag){case 0:case 11:case 15:Gs(i,s,a,c),h&2048&&hu(9,s);break;case 1:Gs(i,s,a,c);break;case 3:Gs(i,s,a,c),h&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Jc(i)));break;case 12:if(h&2048){Gs(i,s,a,c),i=s.stateNode;try{var m=s.memoizedProps,y=m.id,D=m.onPostCommit;typeof D=="function"&&D(y,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(z){Qt(s,s.return,z)}}else Gs(i,s,a,c);break;case 31:Gs(i,s,a,c);break;case 13:Gs(i,s,a,c);break;case 23:break;case 22:m=s.stateNode,y=s.alternate,s.memoizedState!==null?m._visibility&2?Gs(i,s,a,c):pu(i,s):m._visibility&2?Gs(i,s,a,c):(m._visibility|=2,Yl(i,s,a,c,(s.subtreeFlags&10256)!==0||!1)),h&2048&&Km(y,s);break;case 24:Gs(i,s,a,c),h&2048&&qm(s.alternate,s);break;default:Gs(i,s,a,c)}}function Yl(i,s,a,c,h){for(h=h&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var m=i,y=s,D=a,z=c,he=y.flags;switch(y.tag){case 0:case 11:case 15:Yl(m,y,D,z,h),hu(8,y);break;case 23:break;case 22:var xe=y.stateNode;y.memoizedState!==null?xe._visibility&2?Yl(m,y,D,z,h):pu(m,y):(xe._visibility|=2,Yl(m,y,D,z,h)),h&&he&2048&&Km(y.alternate,y);break;case 24:Yl(m,y,D,z,h),h&&he&2048&&qm(y.alternate,y);break;default:Yl(m,y,D,z,h)}s=s.sibling}}function pu(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,c=s,h=c.flags;switch(c.tag){case 22:pu(a,c),h&2048&&Km(c.alternate,c);break;case 24:pu(a,c),h&2048&&qm(c.alternate,c);break;default:pu(a,c)}s=s.sibling}}var mu=8192;function Gl(i,s,a){if(i.subtreeFlags&mu)for(i=i.child;i!==null;)M0(i,s,a),i=i.sibling}function M0(i,s,a){switch(i.tag){case 26:Gl(i,s,a),i.flags&mu&&i.memoizedState!==null&&HR(a,Ys,i.memoizedState,i.memoizedProps);break;case 5:Gl(i,s,a);break;case 3:case 4:var c=Ys;Ys=jh(i.stateNode.containerInfo),Gl(i,s,a),Ys=c;break;case 22:i.memoizedState===null&&(c=i.alternate,c!==null&&c.memoizedState!==null?(c=mu,mu=16777216,Gl(i,s,a),mu=c):Gl(i,s,a));break;default:Gl(i,s,a)}}function A0(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function gu(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var c=s[a];ci=c,j0(c,i)}A0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)L0(i),i=i.sibling}function L0(i){switch(i.tag){case 0:case 11:case 15:gu(i),i.flags&2048&&Ia(9,i,i.return);break;case 3:gu(i);break;case 12:gu(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,Sh(i)):gu(i);break;default:gu(i)}}function Sh(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var c=s[a];ci=c,j0(c,i)}A0(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:Ia(8,s,s.return),Sh(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,Sh(s));break;default:Sh(s)}i=i.sibling}}function j0(i,s){for(;ci!==null;){var a=ci;switch(a.tag){case 0:case 11:case 15:Ia(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var c=a.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Jc(a.memoizedState.cache)}if(c=a.child,c!==null)c.return=a,ci=c;else e:for(a=i;ci!==null;){c=ci;var h=c.sibling,m=c.return;if(C0(c),c===a){ci=null;break e}if(h!==null){h.return=m,ci=h;break e}ci=m}}}var tR={getCacheForType:function(i){var s=Si(Wn),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return Si(Wn).controller.signal}},nR=typeof WeakMap=="function"?WeakMap:Map,Kt=0,on=null,Mt=null,Ot=0,Zt=0,cs=null,Pa=!1,Xl=!1,Vm=!1,Zr=0,Mn=0,za=0,Qo=0,Ym=0,us=0,Zl=0,vu=null,es=null,Gm=!1,wh=0,O0=0,xh=1/0,Ch=null,Ha=null,Jn=0,Ua=null,Ql=null,Qr=0,Xm=0,Zm=null,B0=null,_u=0,Qm=null;function ds(){return(Kt&2)!==0&&Ot!==0?Ot&-Ot:j.T!==null?sg():ht()}function I0(){if(us===0)if((Ot&536870912)===0||Pt){var i=at;at<<=1,(at&3932160)===0&&(at=262144),us=i}else us=536870912;return i=os.current,i!==null&&(i.flags|=32),us}function ts(i,s,a){(i===on&&(Zt===2||Zt===9)||i.cancelPendingCommit!==null)&&(Jl(i,0),$a(i,Ot,us,!1)),hn(i,a),((Kt&2)===0||i!==on)&&(i===on&&((Kt&2)===0&&(Qo|=a),Mn===4&&$a(i,Ot,us,!1)),mr(i))}function P0(i,s,a){if((Kt&6)!==0)throw Error(r(327));var c=!a&&(s&127)===0&&(s&i.expiredLanes)===0||$t(i,s),h=c?rR(i,s):eg(i,s,!0),m=c;do{if(h===0){Xl&&!c&&$a(i,s,0,!1);break}else{if(a=i.current.alternate,m&&!iR(a)){h=eg(i,s,!1),m=!1;continue}if(h===2){if(m=s,i.errorRecoveryDisabledLanes&m)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){s=y;e:{var D=i;h=vu;var z=D.current.memoizedState.isDehydrated;if(z&&(Jl(D,y).flags|=256),y=eg(D,y,!1),y!==2){if(Vm&&!z){D.errorRecoveryDisabledLanes|=m,Qo|=m,h=4;break e}m=es,es=h,m!==null&&(es===null?es=m:es.push.apply(es,m))}h=y}if(m=!1,h!==2)continue}}if(h===1){Jl(i,0),$a(i,s,0,!0);break}e:{switch(c=i,m=h,m){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:$a(c,s,us,!Pa);break e;case 2:es=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(h=wh+300-We(),10<h)){if($a(c,s,us,!Pa),It(c,0,!0)!==0)break e;Qr=s,c.timeoutHandle=mw(z0.bind(null,c,a,es,Ch,Gm,s,us,Qo,Zl,Pa,m,"Throttled",-0,0),h);break e}z0(c,a,es,Ch,Gm,s,us,Qo,Zl,Pa,m,null,-0,0)}}break}while(!0);mr(i)}function z0(i,s,a,c,h,m,y,D,z,he,xe,Ee,me,ye){if(i.timeoutHandle=-1,Ee=s.subtreeFlags,Ee&8192||(Ee&16785408)===16785408){Ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Bi},M0(s,m,Ee);var Ge=(m&62914560)===m?wh-We():(m&4194048)===m?O0-We():0;if(Ge=UR(Ee,Ge),Ge!==null){Qr=m,i.cancelPendingCommit=Ge(V0.bind(null,i,s,m,a,c,h,y,D,z,xe,Ee,null,me,ye)),$a(i,m,y,!he);return}}V0(i,s,m,a,c,h,y,D,z)}function iR(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var c=0;c<a.length;c++){var h=a[c],m=h.getSnapshot;h=h.value;try{if(!zi(m(),h))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function $a(i,s,a,c){s&=~Ym,s&=~Qo,i.suspendedLanes|=s,i.pingedLanes&=~s,c&&(i.warmLanes|=s),c=i.expirationTimes;for(var h=s;0<h;){var m=31-Ct(h),y=1<<m;c[m]=-1,h&=~y}a!==0&&ln(i,a,s)}function kh(){return(Kt&6)===0?(bu(0),!1):!0}function Jm(){if(Mt!==null){if(Zt===0)var i=Mt.return;else i=Mt,Ur=Fo=null,mm(i),Fl=null,tu=0,i=Mt;for(;i!==null;)g0(i.alternate,i),i=i.return;Mt=null}}function Jl(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,xR(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Qr=0,Jm(),on=i,Mt=a=zr(i.current,null),Ot=s,Zt=0,cs=null,Pa=!1,Xl=$t(i,s),Vm=!1,Zl=us=Ym=Qo=za=Mn=0,es=vu=null,Gm=!1,(s&8)!==0&&(s|=s&32);var c=i.entangledLanes;if(c!==0)for(i=i.entanglements,c&=s;0<c;){var h=31-Ct(c),m=1<<h;s|=i[h],c&=~m}return Zr=s,qd(),a}function H0(i,s){wt=null,j.H=cu,s===$l||s===eh?(s=nS(),Zt=3):s===im?(s=nS(),Zt=4):Zt=s===Mm?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,cs=s,Mt===null&&(Mn=1,ph(i,ks(s,i.current)))}function U0(){var i=os.current;return i===null?!0:(Ot&4194048)===Ot?Ds===null:(Ot&62914560)===Ot||(Ot&536870912)!==0?i===Ds:!1}function $0(){var i=j.H;return j.H=cu,i===null?cu:i}function F0(){var i=j.A;return j.A=tR,i}function Th(){Mn=4,Pa||(Ot&4194048)!==Ot&&os.current!==null||(Xl=!0),(za&134217727)===0&&(Qo&134217727)===0||on===null||$a(on,Ot,us,!1)}function eg(i,s,a){var c=Kt;Kt|=2;var h=$0(),m=F0();(on!==i||Ot!==s)&&(Ch=null,Jl(i,s)),s=!1;var y=Mn;e:do try{if(Zt!==0&&Mt!==null){var D=Mt,z=cs;switch(Zt){case 8:Jm(),y=6;break e;case 3:case 2:case 9:case 6:os.current===null&&(s=!0);var he=Zt;if(Zt=0,cs=null,ec(i,D,z,he),a&&Xl){y=0;break e}break;default:he=Zt,Zt=0,cs=null,ec(i,D,z,he)}}sR(),y=Mn;break}catch(xe){H0(i,xe)}while(!0);return s&&i.shellSuspendCounter++,Ur=Fo=null,Kt=c,j.H=h,j.A=m,Mt===null&&(on=null,Ot=0,qd()),y}function sR(){for(;Mt!==null;)W0(Mt)}function rR(i,s){var a=Kt;Kt|=2;var c=$0(),h=F0();on!==i||Ot!==s?(Ch=null,xh=We()+500,Jl(i,s)):Xl=$t(i,s);e:do try{if(Zt!==0&&Mt!==null){s=Mt;var m=cs;t:switch(Zt){case 1:Zt=0,cs=null,ec(i,s,m,1);break;case 2:case 9:if(eS(m)){Zt=0,cs=null,K0(s);break}s=function(){Zt!==2&&Zt!==9||on!==i||(Zt=7),mr(i)},m.then(s,s);break e;case 3:Zt=7;break e;case 4:Zt=5;break e;case 7:eS(m)?(Zt=0,cs=null,K0(s)):(Zt=0,cs=null,ec(i,s,m,7));break;case 5:var y=null;switch(Mt.tag){case 26:y=Mt.memoizedState;case 5:case 27:var D=Mt;if(y?Nw(y):D.stateNode.complete){Zt=0,cs=null;var z=D.sibling;if(z!==null)Mt=z;else{var he=D.return;he!==null?(Mt=he,Eh(he)):Mt=null}break t}}Zt=0,cs=null,ec(i,s,m,5);break;case 6:Zt=0,cs=null,ec(i,s,m,6);break;case 8:Jm(),Mn=6;break e;default:throw Error(r(462))}}aR();break}catch(xe){H0(i,xe)}while(!0);return Ur=Fo=null,j.H=c,j.A=h,Kt=a,Mt!==null?0:(on=null,Ot=0,qd(),Mn)}function aR(){for(;Mt!==null&&!be();)W0(Mt)}function W0(i){var s=p0(i.alternate,i,Zr);i.memoizedProps=i.pendingProps,s===null?Eh(i):Mt=s}function K0(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=l0(a,s,s.pendingProps,s.type,void 0,Ot);break;case 11:s=l0(a,s,s.pendingProps,s.type.render,s.ref,Ot);break;case 5:mm(s);default:g0(a,s),s=Mt=Fy(s,Zr),s=p0(a,s,Zr)}i.memoizedProps=i.pendingProps,s===null?Eh(i):Mt=s}function ec(i,s,a,c){Ur=Fo=null,mm(s),Fl=null,tu=0;var h=s.return;try{if(Y2(i,h,s,a,Ot)){Mn=1,ph(i,ks(a,i.current)),Mt=null;return}}catch(m){if(h!==null)throw Mt=h,m;Mn=1,ph(i,ks(a,i.current)),Mt=null;return}s.flags&32768?(Pt||c===1?i=!0:Xl||(Ot&536870912)!==0?i=!1:(Pa=i=!0,(c===2||c===9||c===3||c===6)&&(c=os.current,c!==null&&c.tag===13&&(c.flags|=16384))),q0(s,i)):Eh(s)}function Eh(i){var s=i;do{if((s.flags&32768)!==0){q0(s,Pa);return}i=s.return;var a=Z2(s.alternate,s,Zr);if(a!==null){Mt=a;return}if(s=s.sibling,s!==null){Mt=s;return}Mt=s=i}while(s!==null);Mn===0&&(Mn=5)}function q0(i,s){do{var a=Q2(i.alternate,i);if(a!==null){a.flags&=32767,Mt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){Mt=i;return}Mt=i=a}while(i!==null);Mn=6,Mt=null}function V0(i,s,a,c,h,m,y,D,z){i.cancelPendingCommit=null;do Rh();while(Jn!==0);if((Kt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(m=s.lanes|s.childLanes,m|=$p,an(i,a,m,y,D,z),i===on&&(Mt=on=null,Ot=0),Ql=s,Ua=i,Qr=a,Xm=m,Zm=h,B0=c,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,uR(lt,function(){return Q0(),null})):(i.callbackNode=null,i.callbackPriority=0),c=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||c){c=j.T,j.T=null,h=R.p,R.p=2,y=Kt,Kt|=4;try{J2(i,s,a)}finally{Kt=y,R.p=h,j.T=c}}Jn=1,Y0(),G0(),X0()}}function Y0(){if(Jn===1){Jn=0;var i=Ua,s=Ql,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=j.T,j.T=null;var c=R.p;R.p=2;var h=Kt;Kt|=4;try{R0(s,i);var m=hg,y=Xc(i.containerInfo),D=m.focusedElem,z=m.selectionRange;if(y!==D&&D&&D.ownerDocument&&Kd(D.ownerDocument.documentElement,D)){if(z!==null&&ws(D)){var he=z.start,xe=z.end;if(xe===void 0&&(xe=he),"selectionStart"in D)D.selectionStart=he,D.selectionEnd=Math.min(xe,D.value.length);else{var Ee=D.ownerDocument||document,me=Ee&&Ee.defaultView||window;if(me.getSelection){var ye=me.getSelection(),Ge=D.textContent.length,ct=Math.min(z.start,Ge),nn=z.end===void 0?ct:Math.min(z.end,Ge);!ye.extend&&ct>nn&&(y=nn,nn=ct,ct=y);var ne=Wd(D,ct),q=Wd(D,nn);if(ne&&q&&(ye.rangeCount!==1||ye.anchorNode!==ne.node||ye.anchorOffset!==ne.offset||ye.focusNode!==q.node||ye.focusOffset!==q.offset)){var ce=Ee.createRange();ce.setStart(ne.node,ne.offset),ye.removeAllRanges(),ct>nn?(ye.addRange(ce),ye.extend(q.node,q.offset)):(ce.setEnd(q.node,q.offset),ye.addRange(ce))}}}}for(Ee=[],ye=D;ye=ye.parentNode;)ye.nodeType===1&&Ee.push({element:ye,left:ye.scrollLeft,top:ye.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<Ee.length;D++){var ke=Ee[D];ke.element.scrollLeft=ke.left,ke.element.scrollTop=ke.top}}Hh=!!dg,hg=dg=null}finally{Kt=h,R.p=c,j.T=a}}i.current=s,Jn=2}}function G0(){if(Jn===2){Jn=0;var i=Ua,s=Ql,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=j.T,j.T=null;var c=R.p;R.p=2;var h=Kt;Kt|=4;try{x0(i,s.alternate,s)}finally{Kt=h,R.p=c,j.T=a}}Jn=3}}function X0(){if(Jn===4||Jn===3){Jn=0,Fe();var i=Ua,s=Ql,a=Qr,c=B0;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Jn=5:(Jn=0,Ql=Ua=null,Z0(i,i.pendingLanes));var h=i.pendingLanes;if(h===0&&(Ha=null),si(a),s=s.stateNode,dt&&typeof dt.onCommitFiberRoot=="function")try{dt.onCommitFiberRoot(Sn,s,void 0,(s.current.flags&128)===128)}catch{}if(c!==null){s=j.T,h=R.p,R.p=2,j.T=null;try{for(var m=i.onRecoverableError,y=0;y<c.length;y++){var D=c[y];m(D.value,{componentStack:D.stack})}}finally{j.T=s,R.p=h}}(Qr&3)!==0&&Rh(),mr(i),h=i.pendingLanes,(a&261930)!==0&&(h&42)!==0?i===Qm?_u++:(_u=0,Qm=i):_u=0,bu(0)}}function Z0(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,Jc(s)))}function Rh(){return Y0(),G0(),X0(),Q0()}function Q0(){if(Jn!==5)return!1;var i=Ua,s=Xm;Xm=0;var a=si(Qr),c=j.T,h=R.p;try{R.p=32>a?32:a,j.T=null,a=Zm,Zm=null;var m=Ua,y=Qr;if(Jn=0,Ql=Ua=null,Qr=0,(Kt&6)!==0)throw Error(r(331));var D=Kt;if(Kt|=4,L0(m.current),N0(m,m.current,y,a),Kt=D,bu(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(Sn,m)}catch{}return!0}finally{R.p=h,j.T=c,Z0(i,s)}}function J0(i,s,a){s=ks(a,s),s=Nm(i.stateNode,s,2),i=ja(i,s,2),i!==null&&(hn(i,2),mr(i))}function Qt(i,s,a){if(i.tag===3)J0(i,i,a);else for(;s!==null;){if(s.tag===3){J0(s,i,a);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ha===null||!Ha.has(c))){i=ks(a,i),a=e0(2),c=ja(s,a,2),c!==null&&(t0(a,c,s,i),hn(c,2),mr(c));break}}s=s.return}}function tg(i,s,a){var c=i.pingCache;if(c===null){c=i.pingCache=new nR;var h=new Set;c.set(s,h)}else h=c.get(s),h===void 0&&(h=new Set,c.set(s,h));h.has(a)||(Vm=!0,h.add(a),i=oR.bind(null,i,s,a),s.then(i,i))}function oR(i,s,a){var c=i.pingCache;c!==null&&c.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,on===i&&(Ot&a)===a&&(Mn===4||Mn===3&&(Ot&62914560)===Ot&&300>We()-wh?(Kt&2)===0&&Jl(i,0):Ym|=a,Zl===Ot&&(Zl=0)),mr(i)}function ew(i,s){s===0&&(s=Gt()),i=Ho(i,s),i!==null&&(hn(i,s),mr(i))}function lR(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),ew(i,a)}function cR(i,s){var a=0;switch(i.tag){case 31:case 13:var c=i.stateNode,h=i.memoizedState;h!==null&&(a=h.retryLane);break;case 19:c=i.stateNode;break;case 22:c=i.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(s),ew(i,a)}function uR(i,s){return Me(i,s)}var Dh=null,tc=null,ng=!1,Nh=!1,ig=!1,Fa=0;function mr(i){i!==tc&&i.next===null&&(tc===null?Dh=tc=i:tc=tc.next=i),Nh=!0,ng||(ng=!0,hR())}function bu(i,s){if(!ig&&Nh){ig=!0;do for(var a=!1,c=Dh;c!==null;){if(i!==0){var h=c.pendingLanes;if(h===0)var m=0;else{var y=c.suspendedLanes,D=c.pingedLanes;m=(1<<31-Ct(42|i)+1)-1,m&=h&~(y&~D),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(a=!0,sw(c,m))}else m=Ot,m=It(c,c===on?m:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(m&3)===0||$t(c,m)||(a=!0,sw(c,m));c=c.next}while(a);ig=!1}}function dR(){tw()}function tw(){Nh=ng=!1;var i=0;Fa!==0&&wR()&&(i=Fa);for(var s=We(),a=null,c=Dh;c!==null;){var h=c.next,m=nw(c,s);m===0?(c.next=null,a===null?Dh=h:a.next=h,h===null&&(tc=a)):(a=c,(i!==0||(m&3)!==0)&&(Nh=!0)),c=h}Jn!==0&&Jn!==5||bu(i),Fa!==0&&(Fa=0)}function nw(i,s){for(var a=i.suspendedLanes,c=i.pingedLanes,h=i.expirationTimes,m=i.pendingLanes&-62914561;0<m;){var y=31-Ct(m),D=1<<y,z=h[y];z===-1?((D&a)===0||(D&c)!==0)&&(h[y]=dn(D,s)):z<=s&&(i.expiredLanes|=D),m&=~D}if(s=on,a=Ot,a=It(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c=i.callbackNode,a===0||i===s&&(Zt===2||Zt===9)||i.cancelPendingCommit!==null)return c!==null&&c!==null&&je(c),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||$t(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(c!==null&&je(c),si(a)){case 2:case 8:a=_t;break;case 32:a=lt;break;case 268435456:a=Yt;break;default:a=lt}return c=iw.bind(null,i),a=Me(a,c),i.callbackPriority=s,i.callbackNode=a,s}return c!==null&&c!==null&&je(c),i.callbackPriority=2,i.callbackNode=null,2}function iw(i,s){if(Jn!==0&&Jn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Rh()&&i.callbackNode!==a)return null;var c=Ot;return c=It(i,i===on?c:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c===0?null:(P0(i,c,s),nw(i,We()),i.callbackNode!=null&&i.callbackNode===a?iw.bind(null,i):null)}function sw(i,s){if(Rh())return null;P0(i,s,!0)}function hR(){CR(function(){(Kt&6)!==0?Me(ut,dR):tw()})}function sg(){if(Fa===0){var i=Hl;i===0&&(i=Ze,Ze<<=1,(Ze&261888)===0&&(Ze=256)),Fa=i}return Fa}function rw(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Oi(""+i)}function aw(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function fR(i,s,a,c,h){if(s==="submit"&&a&&a.stateNode===h){var m=rw((h[Ye]||null).action),y=c.submitter;y&&(s=(s=y[Ye]||null)?rw(s.formAction):y.getAttribute("formAction"),s!==null&&(m=s,y=null));var D=new Ss("action","action",null,c,h);i.push({event:D,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Fa!==0){var z=y?aw(h,y):new FormData(h);Cm(a,{pending:!0,data:z,method:h.method,action:m},null,z)}}else typeof m=="function"&&(D.preventDefault(),z=y?aw(h,y):new FormData(h),Cm(a,{pending:!0,data:z,method:h.method,action:m},m,z))},currentTarget:h}]})}}for(var rg=0;rg<xs.length;rg++){var ag=xs[rg],pR=ag.toLowerCase(),mR=ag[0].toUpperCase()+ag.slice(1);Xi(pR,"on"+mR)}Xi(Tt,"onAnimationEnd"),Xi(Et,"onAnimationIteration"),Xi(rt,"onAnimationStart"),Xi("dblclick","onDoubleClick"),Xi("focusin","onFocus"),Xi("focusout","onBlur"),Xi(un,"onTransitionRun"),Xi(Jt,"onTransitionStart"),Xi(Xt,"onTransitionCancel"),Xi(Vs,"onTransitionEnd"),cn("onMouseEnter",["mouseout","mouseover"]),cn("onMouseLeave",["mouseout","mouseover"]),cn("onPointerEnter",["pointerout","pointerover"]),cn("onPointerLeave",["pointerout","pointerover"]),ji("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ji("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ji("onBeforeInput",["compositionend","keypress","textInput","paste"]),ji("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ji("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ji("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var yu="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(" "),gR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yu));function ow(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var c=i[a],h=c.event;c=c.listeners;e:{var m=void 0;if(s)for(var y=c.length-1;0<=y;y--){var D=c[y],z=D.instance,he=D.currentTarget;if(D=D.listener,z!==m&&h.isPropagationStopped())break e;m=D,h.currentTarget=he;try{m(h)}catch(xe){zo(xe)}h.currentTarget=null,m=z}else for(y=0;y<c.length;y++){if(D=c[y],z=D.instance,he=D.currentTarget,D=D.listener,z!==m&&h.isPropagationStopped())break e;m=D,h.currentTarget=he;try{m(h)}catch(xe){zo(xe)}h.currentTarget=null,m=z}}}}function At(i,s){var a=s[et];a===void 0&&(a=s[et]=new Set);var c=i+"__bubble";a.has(c)||(lw(s,i,2,!1),a.add(c))}function og(i,s,a){var c=0;s&&(c|=4),lw(a,i,c,s)}var Mh="_reactListening"+Math.random().toString(36).slice(2);function lg(i){if(!i[Mh]){i[Mh]=!0,ri.forEach(function(a){a!=="selectionchange"&&(gR.has(a)||og(a,!1,i),og(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[Mh]||(s[Mh]=!0,og("selectionchange",!1,s))}}function lw(i,s,a,c){switch(Iw(s)){case 2:var h=WR;break;case 8:h=KR;break;default:h=xg}a=h.bind(null,s,a,i),h=void 0,!Lr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),c?h!==void 0?i.addEventListener(s,a,{capture:!0,passive:h}):i.addEventListener(s,a,!0):h!==void 0?i.addEventListener(s,a,{passive:h}):i.addEventListener(s,a,!1)}function cg(i,s,a,c,h){var m=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var y=c.tag;if(y===3||y===4){var D=c.stateNode.containerInfo;if(D===h)break;if(y===4)for(y=c.return;y!==null;){var z=y.tag;if((z===3||z===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;D!==null;){if(y=vs(D),y===null)return;if(z=y.tag,z===5||z===6||z===26||z===27){c=m=y;continue e}D=D.parentNode}}c=c.return}Ar(function(){var he=m,xe=ys(a),Ee=[];e:{var me=Po.get(i);if(me!==void 0){var ye=Ss,Ge=i;switch(i){case"keypress":if(rr(a)===0)break e;case"keydown":case"keyup":ye=Dl;break;case"focusin":Ge="focus",ye=Mo;break;case"focusout":Ge="blur",ye=Mo;break;case"beforeblur":case"afterblur":ye=Mo;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":ye=Cl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Tl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=qc;break;case Tt:case Et:case rt:ye=Wc;break;case Vs:ye=Ml;break;case"scroll":case"scrollend":ye=No;break;case"wheel":ye=Vc;break;case"copy":case"cut":case"paste":ye=Kc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=Gi;break;case"toggle":case"beforetoggle":ye=li}var ct=(s&4)!==0,nn=!ct&&(i==="scroll"||i==="scrollend"),ne=ct?me!==null?me+"Capture":null:me;ct=[];for(var q=he,ce;q!==null;){var ke=q;if(ce=ke.stateNode,ke=ke.tag,ke!==5&&ke!==26&&ke!==27||ce===null||ne===null||(ke=Ii(q,ne),ke!=null&&ct.push(Su(q,ke,ce))),nn)break;q=q.return}0<ct.length&&(me=new ye(me,Ge,null,a,xe),Ee.push({event:me,listeners:ct}))}}if((s&7)===0){e:{if(me=i==="mouseover"||i==="pointerover",ye=i==="mouseout"||i==="pointerout",me&&a!==Us&&(Ge=a.relatedTarget||a.fromElement)&&(vs(Ge)||Ge[Xe]))break e;if((ye||me)&&(me=xe.window===xe?xe:(me=xe.ownerDocument)?me.defaultView||me.parentWindow:window,ye?(Ge=a.relatedTarget||a.toElement,ye=he,Ge=Ge?vs(Ge):null,Ge!==null&&(nn=l(Ge),ct=Ge.tag,Ge!==nn||ct!==5&&ct!==27&&ct!==6)&&(Ge=null)):(ye=null,Ge=he),ye!==Ge)){if(ct=Cl,ke="onMouseLeave",ne="onMouseEnter",q="mouse",(i==="pointerout"||i==="pointerover")&&(ct=Gi,ke="onPointerLeave",ne="onPointerEnter",q="pointer"),nn=ye==null?me:Li(ye),ce=Ge==null?me:Li(Ge),me=new ct(ke,q+"leave",ye,a,xe),me.target=nn,me.relatedTarget=ce,ke=null,vs(xe)===he&&(ct=new ct(ne,q+"enter",Ge,a,xe),ct.target=ce,ct.relatedTarget=nn,ke=ct),nn=ke,ye&&Ge)t:{for(ct=vR,ne=ye,q=Ge,ce=0,ke=ne;ke;ke=ct(ke))ce++;ke=0;for(var nt=q;nt;nt=ct(nt))ke++;for(;0<ce-ke;)ne=ct(ne),ce--;for(;0<ke-ce;)q=ct(q),ke--;for(;ce--;){if(ne===q||q!==null&&ne===q.alternate){ct=ne;break t}ne=ct(ne),q=ct(q)}ct=null}else ct=null;ye!==null&&cw(Ee,me,ye,ct,!1),Ge!==null&&nn!==null&&cw(Ee,nn,Ge,ct,!0)}}e:{if(me=he?Li(he):window,ye=me.nodeName&&me.nodeName.toLowerCase(),ye==="select"||ye==="input"&&me.type==="file")var Ht=Dn;else if(Ie(me))if(Ir)Ht=$d;else{Ht=Pp;var Qe=dr}else ye=me.nodeName,!ye||ye.toLowerCase()!=="input"||me.type!=="checkbox"&&me.type!=="radio"?he&&ss(he.elementType)&&(Ht=Dn):Ht=zp;if(Ht&&(Ht=Ht(i,he))){qe(Ee,Ht,a,xe);break e}Qe&&Qe(i,me,he),i==="focusout"&&he&&me.type==="number"&&he.memoizedProps.value!=null&&To(me,"number",me.value)}switch(Qe=he?Li(he):window,i){case"focusin":(Ie(Qe)||Qe.contentEditable==="true")&&(Ea=Qe,Bo=he,Io=null);break;case"focusout":Io=Bo=Ea=null;break;case"mousedown":Ll=!0;break;case"contextmenu":case"mouseup":case"dragend":Ll=!1,E(Ee,a,xe);break;case"selectionchange":if(Up)break;case"keydown":case"keyup":E(Ee,a,xe)}var xt;if(Oo)e:{switch(i){case"compositionstart":var Bt="onCompositionStart";break e;case"compositionend":Bt="onCompositionEnd";break e;case"compositionupdate":Bt="onCompositionUpdate";break e}Bt=void 0}else X?k(i,a)&&(Bt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Bt="onCompositionStart");Bt&&(Ca&&a.locale!=="ko"&&(X||Bt!=="onCompositionStart"?Bt==="onCompositionEnd"&&X&&(xt=xl()):(Ei=xe,Pi="value"in Ei?Ei.value:Ei.textContent,X=!0)),Qe=Ah(he,Bt),0<Qe.length&&(Bt=new lr(Bt,i,null,a,xe),Ee.push({event:Bt,listeners:Qe}),xt?Bt.data=xt:(xt=B(a),xt!==null&&(Bt.data=xt)))),(xt=Yc?se(i,a):le(i,a))&&(Bt=Ah(he,"onBeforeInput"),0<Bt.length&&(Qe=new lr("onBeforeInput","beforeinput",null,a,xe),Ee.push({event:Qe,listeners:Bt}),Qe.data=xt)),fR(Ee,i,he,a,xe)}ow(Ee,s)})}function Su(i,s,a){return{instance:i,listener:s,currentTarget:a}}function Ah(i,s){for(var a=s+"Capture",c=[];i!==null;){var h=i,m=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||m===null||(h=Ii(i,a),h!=null&&c.unshift(Su(i,h,m)),h=Ii(i,s),h!=null&&c.push(Su(i,h,m))),i.tag===3)return c;i=i.return}return[]}function vR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function cw(i,s,a,c,h){for(var m=s._reactName,y=[];a!==null&&a!==c;){var D=a,z=D.alternate,he=D.stateNode;if(D=D.tag,z!==null&&z===c)break;D!==5&&D!==26&&D!==27||he===null||(z=he,h?(he=Ii(a,m),he!=null&&y.unshift(Su(a,he,z))):h||(he=Ii(a,m),he!=null&&y.push(Su(a,he,z)))),a=a.return}y.length!==0&&i.push({event:s,listeners:y})}var _R=/\r\n?/g,bR=/\u0000|\uFFFD/g;function uw(i){return(typeof i=="string"?i:""+i).replace(_R,`
|
|
10
|
+
`).replace(bR,"")}function dw(i,s){return s=uw(s),uw(i)===s}function tn(i,s,a,c,h,m){switch(a){case"children":typeof c=="string"?s==="body"||s==="textarea"&&c===""||Hs(i,c):(typeof c=="number"||typeof c=="bigint")&&s!=="body"&&Hs(i,""+c);break;case"className":zs(i,"class",c);break;case"tabIndex":zs(i,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":zs(i,a,c);break;case"style":Do(i,c,m);break;case"data":if(s!=="object"){zs(i,"data",c);break}case"src":case"href":if(c===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){i.removeAttribute(a);break}c=Oi(""+c),i.setAttribute(a,c);break;case"action":case"formAction":if(typeof c=="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 m=="function"&&(a==="formAction"?(s!=="input"&&tn(i,s,"name",h.name,h,null),tn(i,s,"formEncType",h.formEncType,h,null),tn(i,s,"formMethod",h.formMethod,h,null),tn(i,s,"formTarget",h.formTarget,h,null)):(tn(i,s,"encType",h.encType,h,null),tn(i,s,"method",h.method,h,null),tn(i,s,"target",h.target,h,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){i.removeAttribute(a);break}c=Oi(""+c),i.setAttribute(a,c);break;case"onClick":c!=null&&(i.onclick=Bi);break;case"onScroll":c!=null&&At("scroll",i);break;case"onScrollEnd":c!=null&&At("scrollend",i);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":i.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){i.removeAttribute("xlink:href");break}a=Oi(""+c),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":c!=null&&typeof c!="function"&&typeof c!="symbol"?i.setAttribute(a,""+c):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":c&&typeof c!="function"&&typeof c!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":c===!0?i.setAttribute(a,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?i.setAttribute(a,c):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?i.setAttribute(a,c):i.removeAttribute(a);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?i.removeAttribute(a):i.setAttribute(a,c);break;case"popover":At("beforetoggle",i),At("toggle",i),Xn(i,"popover",c);break;case"xlinkActuate":qi(i,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":qi(i,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":qi(i,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":qi(i,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":qi(i,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":qi(i,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":qi(i,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":qi(i,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":qi(i,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Xn(i,"is",c);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=$c.get(a)||a,Xn(i,a,c))}}function ug(i,s,a,c,h,m){switch(a){case"style":Do(i,c,m);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof c=="string"?Hs(i,c):(typeof c=="number"||typeof c=="bigint")&&Hs(i,""+c);break;case"onScroll":c!=null&&At("scroll",i);break;case"onScrollEnd":c!=null&&At("scrollend",i);break;case"onClick":c!=null&&(i.onclick=Bi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Tr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),s=a.slice(2,h?a.length-7:void 0),m=i[Ye]||null,m=m!=null?m[a]:null,typeof m=="function"&&i.removeEventListener(s,m,h),typeof c=="function")){typeof m!="function"&&m!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,c,h);break e}a in i?i[a]=c:c===!0?i.setAttribute(a,""):Xn(i,a,c)}}}function xi(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":At("error",i),At("load",i);var c=!1,h=!1,m;for(m in a)if(a.hasOwnProperty(m)){var y=a[m];if(y!=null)switch(m){case"src":c=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:tn(i,s,m,y,a,null)}}h&&tn(i,s,"srcSet",a.srcSet,a,null),c&&tn(i,s,"src",a.src,a,null);return;case"input":At("invalid",i);var D=m=y=h=null,z=null,he=null;for(c in a)if(a.hasOwnProperty(c)){var xe=a[c];if(xe!=null)switch(c){case"name":h=xe;break;case"type":y=xe;break;case"checked":z=xe;break;case"defaultChecked":he=xe;break;case"value":m=xe;break;case"defaultValue":D=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(r(137,s));break;default:tn(i,s,c,xe,a,null)}}ir(i,m,D,z,he,y,h,!1);return;case"select":At("invalid",i),c=y=m=null;for(h in a)if(a.hasOwnProperty(h)&&(D=a[h],D!=null))switch(h){case"value":m=D;break;case"defaultValue":y=D;break;case"multiple":c=D;default:tn(i,s,h,D,a,null)}s=m,a=y,i.multiple=!!c,s!=null?Vi(i,!!c,s,!1):a!=null&&Vi(i,!!c,a,!0);return;case"textarea":At("invalid",i),m=h=c=null;for(y in a)if(a.hasOwnProperty(y)&&(D=a[y],D!=null))switch(y){case"value":c=D;break;case"defaultValue":h=D;break;case"children":m=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(r(91));break;default:tn(i,s,y,D,a,null)}Nr(i,c,h,m);return;case"option":for(z in a)a.hasOwnProperty(z)&&(c=a[z],c!=null)&&(z==="selected"?i.selected=c&&typeof c!="function"&&typeof c!="symbol":tn(i,s,z,c,a,null));return;case"dialog":At("beforetoggle",i),At("toggle",i),At("cancel",i),At("close",i);break;case"iframe":case"object":At("load",i);break;case"video":case"audio":for(c=0;c<yu.length;c++)At(yu[c],i);break;case"image":At("error",i),At("load",i);break;case"details":At("toggle",i);break;case"embed":case"source":case"link":At("error",i),At("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(he in a)if(a.hasOwnProperty(he)&&(c=a[he],c!=null))switch(he){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:tn(i,s,he,c,a,null)}return;default:if(ss(s)){for(xe in a)a.hasOwnProperty(xe)&&(c=a[xe],c!==void 0&&ug(i,s,xe,c,a,void 0));return}}for(D in a)a.hasOwnProperty(D)&&(c=a[D],c!=null&&tn(i,s,D,c,a,null))}function yR(i,s,a,c){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,m=null,y=null,D=null,z=null,he=null,xe=null;for(ye in a){var Ee=a[ye];if(a.hasOwnProperty(ye)&&Ee!=null)switch(ye){case"checked":break;case"value":break;case"defaultValue":z=Ee;default:c.hasOwnProperty(ye)||tn(i,s,ye,null,c,Ee)}}for(var me in c){var ye=c[me];if(Ee=a[me],c.hasOwnProperty(me)&&(ye!=null||Ee!=null))switch(me){case"type":m=ye;break;case"name":h=ye;break;case"checked":he=ye;break;case"defaultChecked":xe=ye;break;case"value":y=ye;break;case"defaultValue":D=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(r(137,s));break;default:ye!==Ee&&tn(i,s,me,ye,c,Ee)}}_i(i,y,D,z,he,xe,m,h);return;case"select":ye=y=D=me=null;for(m in a)if(z=a[m],a.hasOwnProperty(m)&&z!=null)switch(m){case"value":break;case"multiple":ye=z;default:c.hasOwnProperty(m)||tn(i,s,m,null,c,z)}for(h in c)if(m=c[h],z=a[h],c.hasOwnProperty(h)&&(m!=null||z!=null))switch(h){case"value":me=m;break;case"defaultValue":D=m;break;case"multiple":y=m;default:m!==z&&tn(i,s,h,m,c,z)}s=D,a=y,c=ye,me!=null?Vi(i,!!a,me,!1):!!c!=!!a&&(s!=null?Vi(i,!!a,s,!0):Vi(i,!!a,a?[]:"",!1));return;case"textarea":ye=me=null;for(D in a)if(h=a[D],a.hasOwnProperty(D)&&h!=null&&!c.hasOwnProperty(D))switch(D){case"value":break;case"children":break;default:tn(i,s,D,null,c,h)}for(y in c)if(h=c[y],m=a[y],c.hasOwnProperty(y)&&(h!=null||m!=null))switch(y){case"value":me=h;break;case"defaultValue":ye=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(91));break;default:h!==m&&tn(i,s,y,h,c,m)}Eo(i,me,ye);return;case"option":for(var Ge in a)me=a[Ge],a.hasOwnProperty(Ge)&&me!=null&&!c.hasOwnProperty(Ge)&&(Ge==="selected"?i.selected=!1:tn(i,s,Ge,null,c,me));for(z in c)me=c[z],ye=a[z],c.hasOwnProperty(z)&&me!==ye&&(me!=null||ye!=null)&&(z==="selected"?i.selected=me&&typeof me!="function"&&typeof me!="symbol":tn(i,s,z,me,c,ye));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 ct in a)me=a[ct],a.hasOwnProperty(ct)&&me!=null&&!c.hasOwnProperty(ct)&&tn(i,s,ct,null,c,me);for(he in c)if(me=c[he],ye=a[he],c.hasOwnProperty(he)&&me!==ye&&(me!=null||ye!=null))switch(he){case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(r(137,s));break;default:tn(i,s,he,me,c,ye)}return;default:if(ss(s)){for(var nn in a)me=a[nn],a.hasOwnProperty(nn)&&me!==void 0&&!c.hasOwnProperty(nn)&&ug(i,s,nn,void 0,c,me);for(xe in c)me=c[xe],ye=a[xe],!c.hasOwnProperty(xe)||me===ye||me===void 0&&ye===void 0||ug(i,s,xe,me,c,ye);return}}for(var ne in a)me=a[ne],a.hasOwnProperty(ne)&&me!=null&&!c.hasOwnProperty(ne)&&tn(i,s,ne,null,c,me);for(Ee in c)me=c[Ee],ye=a[Ee],!c.hasOwnProperty(Ee)||me===ye||me==null&&ye==null||tn(i,s,Ee,me,c,ye)}function hw(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function SR(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),c=0;c<a.length;c++){var h=a[c],m=h.transferSize,y=h.initiatorType,D=h.duration;if(m&&D&&hw(y)){for(y=0,D=h.responseEnd,c+=1;c<a.length;c++){var z=a[c],he=z.startTime;if(he>D)break;var xe=z.transferSize,Ee=z.initiatorType;xe&&hw(Ee)&&(z=z.responseEnd,y+=xe*(z<D?1:(D-he)/(z-he)))}if(--c,s+=8*(m+y)/(h.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var dg=null,hg=null;function Lh(i){return i.nodeType===9?i:i.ownerDocument}function fw(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 pw(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function fg(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var pg=null;function wR(){var i=window.event;return i&&i.type==="popstate"?i===pg?!1:(pg=i,!0):(pg=null,!1)}var mw=typeof setTimeout=="function"?setTimeout:void 0,xR=typeof clearTimeout=="function"?clearTimeout:void 0,gw=typeof Promise=="function"?Promise:void 0,CR=typeof queueMicrotask=="function"?queueMicrotask:typeof gw<"u"?function(i){return gw.resolve(null).then(i).catch(kR)}:mw;function kR(i){setTimeout(function(){throw i})}function Wa(i){return i==="head"}function vw(i,s){var a=s,c=0;do{var h=a.nextSibling;if(i.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"||a==="/&"){if(c===0){i.removeChild(h),rc(s);return}c--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")c++;else if(a==="html")wu(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,wu(a);for(var m=a.firstChild;m;){var y=m.nextSibling,D=m.nodeName;m[Ft]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&m.rel.toLowerCase()==="stylesheet"||a.removeChild(m),m=y}}else a==="body"&&wu(i.ownerDocument.body);a=h}while(a);rc(s)}function _w(i,s){var a=i;i=0;do{var c=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),c&&c.nodeType===8)if(a=c.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=c}while(a)}function mg(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":mg(a),Ai(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function TR(i,s,a,c){for(;i.nodeType===1;){var h=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!c&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(c){if(!i[Ft])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(m=i.getAttribute("rel"),m==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(m!==h.rel||i.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||i.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||i.getAttribute("title")!==(h.title==null?null:h.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(m=i.getAttribute("src"),(m!==(h.src==null?null:h.src)||i.getAttribute("type")!==(h.type==null?null:h.type)||i.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&m&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var m=h.name==null?null:""+h.name;if(h.type==="hidden"&&i.getAttribute("name")===m)return i}else return i;if(i=Ns(i.nextSibling),i===null)break}return null}function ER(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Ns(i.nextSibling),i===null))return null;return i}function bw(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=Ns(i.nextSibling),i===null))return null;return i}function gg(i){return i.data==="$?"||i.data==="$~"}function vg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function RR(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var c=function(){s(),a.removeEventListener("DOMContentLoaded",c)};a.addEventListener("DOMContentLoaded",c),i._reactRetry=c}}function Ns(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var _g=null;function yw(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return Ns(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function Sw(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function ww(i,s,a){switch(s=Lh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function wu(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Ai(i)}var Ms=new Map,xw=new Set;function jh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Jr=R.d;R.d={f:DR,r:NR,D:MR,C:AR,L:LR,m:jR,X:BR,S:OR,M:IR};function DR(){var i=Jr.f(),s=kh();return i||s}function NR(i){var s=$n(i);s!==null&&s.tag===5&&s.type==="form"?HS(s):Jr.r(i)}var nc=typeof document>"u"?null:document;function Cw(i,s,a){var c=nc;if(c&&typeof s=="string"&&s){var h=Bn(s);h='link[rel="'+i+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),xw.has(h)||(xw.add(h),i={rel:i,crossOrigin:a,href:s},c.querySelector(h)===null&&(s=c.createElement("link"),xi(s,"link",i),pn(s),c.head.appendChild(s)))}}function MR(i){Jr.D(i),Cw("dns-prefetch",i,null)}function AR(i,s){Jr.C(i,s),Cw("preconnect",i,s)}function LR(i,s,a){Jr.L(i,s,a);var c=nc;if(c&&i&&s){var h='link[rel="preload"][as="'+Bn(s)+'"]';s==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+Bn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+Bn(a.imageSizes)+'"]')):h+='[href="'+Bn(i)+'"]';var m=h;switch(s){case"style":m=ic(i);break;case"script":m=sc(i)}Ms.has(m)||(i=_({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),Ms.set(m,i),c.querySelector(h)!==null||s==="style"&&c.querySelector(xu(m))||s==="script"&&c.querySelector(Cu(m))||(s=c.createElement("link"),xi(s,"link",i),pn(s),c.head.appendChild(s)))}}function jR(i,s){Jr.m(i,s);var a=nc;if(a&&i){var c=s&&typeof s.as=="string"?s.as:"script",h='link[rel="modulepreload"][as="'+Bn(c)+'"][href="'+Bn(i)+'"]',m=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=sc(i)}if(!Ms.has(m)&&(i=_({rel:"modulepreload",href:i},s),Ms.set(m,i),a.querySelector(h)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Cu(m)))return}c=a.createElement("link"),xi(c,"link",i),pn(c),a.head.appendChild(c)}}}function OR(i,s,a){Jr.S(i,s,a);var c=nc;if(c&&i){var h=Ki(c).hoistableStyles,m=ic(i);s=s||"default";var y=h.get(m);if(!y){var D={loading:0,preload:null};if(y=c.querySelector(xu(m)))D.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":s},a),(a=Ms.get(m))&&bg(i,a);var z=y=c.createElement("link");pn(z),xi(z,"link",i),z._p=new Promise(function(he,xe){z.onload=he,z.onerror=xe}),z.addEventListener("load",function(){D.loading|=1}),z.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Oh(y,s,c)}y={type:"stylesheet",instance:y,count:1,state:D},h.set(m,y)}}}function BR(i,s){Jr.X(i,s);var a=nc;if(a&&i){var c=Ki(a).hoistableScripts,h=sc(i),m=c.get(h);m||(m=a.querySelector(Cu(h)),m||(i=_({src:i,async:!0},s),(s=Ms.get(h))&&yg(i,s),m=a.createElement("script"),pn(m),xi(m,"link",i),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(h,m))}}function IR(i,s){Jr.M(i,s);var a=nc;if(a&&i){var c=Ki(a).hoistableScripts,h=sc(i),m=c.get(h);m||(m=a.querySelector(Cu(h)),m||(i=_({src:i,async:!0,type:"module"},s),(s=Ms.get(h))&&yg(i,s),m=a.createElement("script"),pn(m),xi(m,"link",i),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},c.set(h,m))}}function kw(i,s,a,c){var h=(h=Se.current)?jh(h):null;if(!h)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=ic(a.href),a=Ki(h).hoistableStyles,c=a.get(s),c||(c={type:"style",instance:null,count:0,state:null},a.set(s,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=ic(a.href);var m=Ki(h).hoistableStyles,y=m.get(i);if(y||(h=h.ownerDocument||h,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,y),(m=h.querySelector(xu(i)))&&!m._p&&(y.instance=m,y.state.loading=5),Ms.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},Ms.set(i,a),m||PR(h,i,a,y.state))),s&&c===null)throw Error(r(528,""));return y}if(s&&c!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=sc(a),a=Ki(h).hoistableScripts,c=a.get(s),c||(c={type:"script",instance:null,count:0,state:null},a.set(s,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ic(i){return'href="'+Bn(i)+'"'}function xu(i){return'link[rel="stylesheet"]['+i+"]"}function Tw(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function PR(i,s,a,c){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?c.loading=1:(s=i.createElement("link"),c.preload=s,s.addEventListener("load",function(){return c.loading|=1}),s.addEventListener("error",function(){return c.loading|=2}),xi(s,"link",a),pn(s),i.head.appendChild(s))}function sc(i){return'[src="'+Bn(i)+'"]'}function Cu(i){return"script[async]"+i}function Ew(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var c=i.querySelector('style[data-href~="'+Bn(a.href)+'"]');if(c)return s.instance=c,pn(c),c;var h=_({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),pn(c),xi(c,"style",h),Oh(c,a.precedence,i),s.instance=c;case"stylesheet":h=ic(a.href);var m=i.querySelector(xu(h));if(m)return s.state.loading|=4,s.instance=m,pn(m),m;c=Tw(a),(h=Ms.get(h))&&bg(c,h),m=(i.ownerDocument||i).createElement("link"),pn(m);var y=m;return y._p=new Promise(function(D,z){y.onload=D,y.onerror=z}),xi(m,"link",c),s.state.loading|=4,Oh(m,a.precedence,i),s.instance=m;case"script":return m=sc(a.src),(h=i.querySelector(Cu(m)))?(s.instance=h,pn(h),h):(c=a,(h=Ms.get(m))&&(c=_({},a),yg(c,h)),i=i.ownerDocument||i,h=i.createElement("script"),pn(h),xi(h,"link",c),i.head.appendChild(h),s.instance=h);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(c=s.instance,s.state.loading|=4,Oh(c,a.precedence,i));return s.instance}function Oh(i,s,a){for(var c=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=c.length?c[c.length-1]:null,m=h,y=0;y<c.length;y++){var D=c[y];if(D.dataset.precedence===s)m=D;else if(m!==h)break}m?m.parentNode.insertBefore(i,m.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function bg(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function yg(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var Bh=null;function Rw(i,s,a){if(Bh===null){var c=new Map,h=Bh=new Map;h.set(a,c)}else h=Bh,c=h.get(a),c||(c=new Map,h.set(a,c));if(c.has(i))return c;for(c.set(i,null),a=a.getElementsByTagName(i),h=0;h<a.length;h++){var m=a[h];if(!(m[Ft]||m[Ce]||i==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var y=m.getAttribute(s)||"";y=i+y;var D=c.get(y);D?D.push(m):c.set(y,[m])}}return c}function Dw(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function zR(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function Nw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function HR(i,s,a,c){if(a.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var h=ic(c.href),m=s.querySelector(xu(h));if(m){s=m._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=Ih.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=m,pn(m);return}m=s.ownerDocument||s,c=Tw(c),(h=Ms.get(h))&&bg(c,h),m=m.createElement("link"),pn(m);var y=m;y._p=new Promise(function(D,z){y.onload=D,y.onerror=z}),xi(m,"link",c),a.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Ih.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var Sg=0;function UR(i,s){return i.stylesheets&&i.count===0&&zh(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var c=setTimeout(function(){if(i.stylesheets&&zh(i,i.stylesheets),i.unsuspend){var m=i.unsuspend;i.unsuspend=null,m()}},6e4+s);0<i.imgBytes&&Sg===0&&(Sg=62500*SR());var h=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&zh(i,i.stylesheets),i.unsuspend)){var m=i.unsuspend;i.unsuspend=null,m()}},(i.imgBytes>Sg?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(h)}}:null}function Ih(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zh(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ph=null;function zh(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ph=new Map,s.forEach($R,i),Ph=null,Ih.call(i))}function $R(i,s){if(!(s.state.loading&4)){var a=Ph.get(i);if(a)var c=a.get(null);else{a=new Map,Ph.set(i,a);for(var h=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<h.length;m++){var y=h[m];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(a.set(y.dataset.precedence,y),c=y)}c&&a.set(null,c)}h=s.instance,y=h.getAttribute("data-precedence"),m=a.get(y)||c,m===c&&a.set(null,h),a.set(y,h),this.count++,c=Ih.bind(this),h.addEventListener("load",c),h.addEventListener("error",c),m?m.parentNode.insertBefore(h,m.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(h,i.firstChild)),s.state.loading|=4}}var ku={$$typeof:U,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function FR(i,s,a,c,h,m,y,D,z){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=rn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rn(0),this.hiddenUpdates=rn(null),this.identifierPrefix=c,this.onUncaughtError=h,this.onCaughtError=m,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=z,this.incompleteTransitions=new Map}function Mw(i,s,a,c,h,m,y,D,z,he,xe,Ee){return i=new FR(i,s,a,y,z,he,xe,Ee,D),s=1,m===!0&&(s|=24),m=as(3,null,null,s),i.current=m,m.stateNode=i,s=em(),s.refCount++,i.pooledCache=s,s.refCount++,m.memoizedState={element:c,isDehydrated:a,cache:s},sm(m),i}function Aw(i){return i?(i=Ol,i):Ol}function Lw(i,s,a,c,h,m){h=Aw(h),c.context===null?c.context=h:c.pendingContext=h,c=La(s),c.payload={element:a},m=m===void 0?null:m,m!==null&&(c.callback=m),a=ja(i,c,s),a!==null&&(ts(a,i,s),iu(a,i,s))}function jw(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function wg(i,s){jw(i,s),(i=i.alternate)&&jw(i,s)}function Ow(i){if(i.tag===13||i.tag===31){var s=Ho(i,67108864);s!==null&&ts(s,i,67108864),wg(i,67108864)}}function Bw(i){if(i.tag===13||i.tag===31){var s=ds();s=vi(s);var a=Ho(i,s);a!==null&&ts(a,i,s),wg(i,s)}}var Hh=!0;function WR(i,s,a,c){var h=j.T;j.T=null;var m=R.p;try{R.p=2,xg(i,s,a,c)}finally{R.p=m,j.T=h}}function KR(i,s,a,c){var h=j.T;j.T=null;var m=R.p;try{R.p=8,xg(i,s,a,c)}finally{R.p=m,j.T=h}}function xg(i,s,a,c){if(Hh){var h=Cg(c);if(h===null)cg(i,s,c,Uh,a),Pw(i,c);else if(VR(h,i,s,a,c))c.stopPropagation();else if(Pw(i,c),s&4&&-1<qR.indexOf(i)){for(;h!==null;){var m=$n(h);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var y=St(m.pendingLanes);if(y!==0){var D=m;for(D.pendingLanes|=2,D.entangledLanes|=2;y;){var z=1<<31-Ct(y);D.entanglements[1]|=z,y&=~z}mr(m),(Kt&6)===0&&(xh=We()+500,bu(0))}}break;case 31:case 13:D=Ho(m,2),D!==null&&ts(D,m,2),kh(),wg(m,2)}if(m=Cg(c),m===null&&cg(i,s,c,Uh,a),m===h)break;h=m}h!==null&&c.stopPropagation()}else cg(i,s,c,null,a)}}function Cg(i){return i=ys(i),kg(i)}var Uh=null;function kg(i){if(Uh=null,i=vs(i),i!==null){var s=l(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=d(s),i!==null)return i;i=null}else if(a===31){if(i=f(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return Uh=i,null}function Iw(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(Ue()){case ut:return 2;case _t:return 8;case lt:case Nt:return 32;case Yt:return 268435456;default:return 32}default:return 32}}var Tg=!1,Ka=null,qa=null,Va=null,Tu=new Map,Eu=new Map,Ya=[],qR="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 Pw(i,s){switch(i){case"focusin":case"focusout":Ka=null;break;case"dragenter":case"dragleave":qa=null;break;case"mouseover":case"mouseout":Va=null;break;case"pointerover":case"pointerout":Tu.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Eu.delete(s.pointerId)}}function Ru(i,s,a,c,h,m){return i===null||i.nativeEvent!==m?(i={blockedOn:s,domEventName:a,eventSystemFlags:c,nativeEvent:m,targetContainers:[h]},s!==null&&(s=$n(s),s!==null&&Ow(s)),i):(i.eventSystemFlags|=c,s=i.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),i)}function VR(i,s,a,c,h){switch(s){case"focusin":return Ka=Ru(Ka,i,s,a,c,h),!0;case"dragenter":return qa=Ru(qa,i,s,a,c,h),!0;case"mouseover":return Va=Ru(Va,i,s,a,c,h),!0;case"pointerover":var m=h.pointerId;return Tu.set(m,Ru(Tu.get(m)||null,i,s,a,c,h)),!0;case"gotpointercapture":return m=h.pointerId,Eu.set(m,Ru(Eu.get(m)||null,i,s,a,c,h)),!0}return!1}function zw(i){var s=vs(i.target);if(s!==null){var a=l(s);if(a!==null){if(s=a.tag,s===13){if(s=d(a),s!==null){i.blockedOn=s,kt(i.priority,function(){Bw(a)});return}}else if(s===31){if(s=f(a),s!==null){i.blockedOn=s,kt(i.priority,function(){Bw(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function $h(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Cg(i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);Us=c,a.target.dispatchEvent(c),Us=null}else return s=$n(a),s!==null&&Ow(s),i.blockedOn=a,!1;s.shift()}return!0}function Hw(i,s,a){$h(i)&&a.delete(s)}function YR(){Tg=!1,Ka!==null&&$h(Ka)&&(Ka=null),qa!==null&&$h(qa)&&(qa=null),Va!==null&&$h(Va)&&(Va=null),Tu.forEach(Hw),Eu.forEach(Hw)}function Fh(i,s){i.blockedOn===s&&(i.blockedOn=null,Tg||(Tg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,YR)))}var Wh=null;function Uw(i){Wh!==i&&(Wh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Wh===i&&(Wh=null);for(var s=0;s<i.length;s+=3){var a=i[s],c=i[s+1],h=i[s+2];if(typeof c!="function"){if(kg(c||a)===null)continue;break}var m=$n(a);m!==null&&(i.splice(s,3),s-=3,Cm(m,{pending:!0,data:h,method:a.method,action:c},c,h))}}))}function rc(i){function s(z){return Fh(z,i)}Ka!==null&&Fh(Ka,i),qa!==null&&Fh(qa,i),Va!==null&&Fh(Va,i),Tu.forEach(s),Eu.forEach(s);for(var a=0;a<Ya.length;a++){var c=Ya[a];c.blockedOn===i&&(c.blockedOn=null)}for(;0<Ya.length&&(a=Ya[0],a.blockedOn===null);)zw(a),a.blockedOn===null&&Ya.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(c=0;c<a.length;c+=3){var h=a[c],m=a[c+1],y=h[Ye]||null;if(typeof m=="function")y||Uw(a);else if(y){var D=null;if(m&&m.hasAttribute("formAction")){if(h=m,y=m[Ye]||null)D=y.formAction;else if(kg(h)!==null)continue}else D=y.action;typeof D=="function"?a[c+1]=D:(a.splice(c,3),c-=3),Uw(a)}}}function $w(){function i(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(y){return h=y})},focusReset:"manual",scroll:"manual"})}function s(){h!==null&&(h(),h=null),c||setTimeout(a,20)}function a(){if(!c&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,h=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){c=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),h!==null&&(h(),h=null)}}}function Eg(i){this._internalRoot=i}Kh.prototype.render=Eg.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,c=ds();Lw(a,c,i,s,null,null)},Kh.prototype.unmount=Eg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;Lw(i.current,2,null,i,null,null),kh(),s[Xe]=null}};function Kh(i){this._internalRoot=i}Kh.prototype.unstable_scheduleHydration=function(i){if(i){var s=ht();i={blockedOn:null,target:i,priority:s};for(var a=0;a<Ya.length&&s!==0&&s<Ya[a].priority;a++);Ya.splice(a,0,i),a===0&&zw(i)}};var Fw=t.version;if(Fw!=="19.2.6")throw Error(r(527,Fw,"19.2.6"));R.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var GR={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:j,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var qh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qh.isDisabled&&qh.supportsFiber)try{Sn=qh.inject(GR),dt=qh}catch{}}return Nu.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,c="",h=XS,m=ZS,y=QS;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onUncaughtError!==void 0&&(h=s.onUncaughtError),s.onCaughtError!==void 0&&(m=s.onCaughtError),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=Mw(i,1,!1,null,null,a,c,null,h,m,y,$w),i[Xe]=s.current,lg(i),new Eg(s)},Nu.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var c=!1,h="",m=XS,y=ZS,D=QS,z=null;return a!=null&&(a.unstable_strictMode===!0&&(c=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onUncaughtError!==void 0&&(m=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(D=a.onRecoverableError),a.formState!==void 0&&(z=a.formState)),s=Mw(i,1,!0,s,a??null,c,h,z,m,y,D,$w),s.context=Aw(null),a=s.current,c=ds(),c=vi(c),h=La(c),h.callback=null,ja(a,h,c),a=c,s.current.lanes=a,hn(s,a),mr(s),i[Xe]=s.current,lg(i),new Kh(s)},Nu.version="19.2.6",Nu}var Jw;function rD(){if(Jw)return Ng.exports;Jw=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(),Ng.exports=sD(),Ng.exports}var aD=rD();class Jo extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function AC(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,l)=>({fieldName:`file${l}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,l]of e.files.entries())n.append(`file${o}`,l.file);return new Promise((o,l)=>{let d=!1;const f=()=>{e.signal?.removeEventListener("abort",b)},g=_=>{d||(d=!0,f(),o(_))},p=_=>{d||(d=!0,f(),l(_))},b=()=>{t.abort(),p(new Jo(0,"Upload aborted."))};if(e.signal?.aborted){p(new Jo(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST",e.endpoint??"/api/uploads"),t.withCredentials=!0,t.upload.onprogress=_=>{if(e.onProgress){if(_.lengthComputable&&_.total>0){e.onProgress({loaded:_.loaded,total:_.total,percent:Math.round(_.loaded/_.total*100)});return}e.onProgress({loaded:_.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{p(new Jo(t.status,"Invalid upload response."))}return}p(new Jo(t.status,oD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new Jo(0,"Upload failed.")),t.onabort=()=>p(new Jo(0,"Upload aborted.")),t.ontimeout=()=>p(new Jo(0,"Upload timed out.")),t.send(n)})}function oD(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class Un extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function up(e=fetch){return{getSession:(t={})=>Ae(e,`/api/auth/session${br(t)}`),setupPassword:t=>Ae(e,"/api/auth/password",it("POST",t)),login:t=>Ae(e,"/api/auth/login",it("POST",t)),reauth:t=>Ae(e,"/api/auth/reauth",it("POST",t)),logout:()=>Ae(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ae(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Ae(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ae(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Ae(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ae(e,"/api/auth/devices"),revokeDevice:async t=>{await cc(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ae(e,"/api/auth/networks"),addNetwork:t=>Ae(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await cc(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ae(e,"/api/agents"),addAgent:t=>Ae(e,"/api/agents",it("POST",t)),reorderAgents:t=>Ae(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>Ae(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>Ae(e,"/api/main"),renameMain:t=>Ae(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await cc(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ae(e,"/api/stats"),getAgentStats:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ae(e,"/api/version"),checkUpdate:()=>Ae(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ae(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Ae(e,`/api/code-server/status${br(t)}`),installCodeServer:()=>Ae(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Ae(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>Ae(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>Ae(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),getFavorites:()=>Ae(e,"/api/favorites"),saveFavorites:t=>Ae(e,"/api/favorites",it("PUT",t)),listTerminals:()=>Ae(e,"/api/terminals"),getTerminalLayout:()=>Ae(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ae(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>Ae(e,"/api/files/root",it("POST",t)),listFiles:t=>Ae(e,"/api/files/list",it("POST",t)),readFile:t=>Ae(e,"/api/files/read",it("POST",t)),writeFile:t=>Ae(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Ae(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Ae(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Ae(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Ae(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Ae(e,"/api/files/open",it("POST",t)),previewFile:t=>LC(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Ae(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await cc(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Ae(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/history${br(n)}`),getTerminalTranscriptHistory:(t,n={},r)=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${br(n)}`,r?{signal:r}:void 0),searchTerminalTranscript:(t,n,r)=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-search`,{...it("POST",n),...r?{signal:r}:{}}),getTerminalTranscriptSource:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${br(r)}`),listNotificationAssets:()=>Ae(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Ae(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Ae(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await cc(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Ae(e,`/api/push-notifications/status${t||n?br({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Ae(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>Ae(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>Ae(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>Ae(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>Ae(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>Ae(e,"/api/push-notifications/test",it("POST",t))}}function Zs(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{transcriptCacheScope:e?`agent:${e}`:"local",isAgent:e!==null,listTerminals:()=>Ae(t,n("terminals")),createTerminal:(r={})=>Ae(t,n("terminals"),it("POST",r)),closeTerminal:async r=>{await cc(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ae(t,n(`terminals/${encodeURIComponent(r)}`),it("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${br(o)}`),getTerminalTranscriptHistory:(r,o={},l)=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${br(o)}`,l?{signal:l}:void 0),searchTerminalTranscript:(r,o,l)=>Ae(t,n(`terminals/${encodeURIComponent(r)}/transcript-search`),{...it("POST",o),...l?{signal:l}:{}}),getTerminalTranscriptSource:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,l={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${br(l)}`),getTerminalLayout:()=>Ae(t,n("terminal-layout")),saveTerminalLayout:r=>Ae(t,n("terminal-layout"),it("PUT",r)),createFileRoot:r=>Ae(t,n("files/root"),it("POST",r)),listFiles:r=>Ae(t,n("files/list"),it("POST",r)),readFile:r=>Ae(t,n("files/read"),it("POST",r)),writeFile:r=>Ae(t,n("files/write"),it("POST",r)),createFileEntry:r=>Ae(t,n("files/create"),it("POST",r)),moveFileEntry:r=>Ae(t,n("files/move"),it("POST",r)),previewDeleteFileEntry:r=>Ae(t,n("files/delete-preview"),it("POST",r)),deleteFileEntry:r=>Ae(t,n("files/delete"),it("POST",r)),openFileInTerminal:r=>Ae(t,n("files/open"),it("POST",r)),previewFile:r=>LC(t,n("files/preview"),it("POST",r)),uploadComposeAttachments:r=>AC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>Ae(t,n("attachments/limits")),deleteComposeAttachments:r=>Ae(t,n("attachments/delete"),it("POST",r)),getCodeServerStatus:(r={})=>Ae(t,`${n("code-server/status")}${br(r)}`),installCodeServer:()=>Ae(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>Ae(t,n("code-server/open"),it("POST",r)),stopCodeServer:(r={})=>Ae(t,n("code-server/stop"),it("POST",r)),uninstallCodeServer:()=>Ae(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getProviderHooks:r=>Ae(t,n(`hooks/${r}`)),installProviderHooks:r=>Ae(t,n(`hooks/${r}/install`),{method:"POST",credentials:"same-origin"}),removeProviderHooks:r=>Ae(t,n(`hooks/${r}/remove`),{method:"POST",credentials:"same-origin"}),checkProviderHookTrust:r=>Ae(t,n(`hooks/${r}/trust`)),trustProviderHooks:r=>Ae(t,n(`hooks/${r}/trust`),{method:"POST",credentials:"same-origin"}),getAccounts:()=>Ae(t,n("accounts")),getAccountUsage:r=>Ae(t,n(`accounts/${r}/usage`),{method:"POST",credentials:"same-origin"}),getServerProcesses:()=>Ae(t,n("server-info/processes")),renameServerProject:(r,o)=>Ae(t,n("server-info/project-name"),it("POST",{path:r,name:o})),getServerExternalIp:(r=!1)=>Ae(t,n("server-info/external-ip")+(r?"?refresh=1":"")),selectAccount:(r,o)=>Ae(t,n(`accounts/${r}/select`),it("POST",{profileId:o})),removeAccount:(r,o)=>Ae(t,n(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>Ae(t,n(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(r,o)=>Ae(t,n(`accounts/${r}/login/complete`),it("POST",{label:o})),cancelAccountLogin:r=>Ae(t,n(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>Ae(t,n(`accounts/${r}/refresh`),it("POST",o?{profileId:o}:{})),terminateProviderSessions:r=>Ae(t,n(`accounts/${r}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>lD(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function lD(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function it(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function br(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.ifSnapshot!==void 0&&t.set("ifSnapshot",e.ifSnapshot),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.candidateId!==void 0&&t.set("candidateId",e.candidateId),e.expectedSessionId!==void 0&&t.set("expectedSessionId",e.expectedSessionId),e.around!==void 0&&t.set("around",e.around),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function Ae(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await jb(r);try{return await r.json()}catch{throw new Un(r.status,"invalid_json_response")}}async function cc(e,t,n){const r=await e(t,n);await jb(r)}async function LC(e,t,n){const r=await e(t,n);return await jb(r),r.blob()}async function jb(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Un(e.status,t)}const Ob="nterminal.theme.id",jC="nterminal.theme.accent",Bv="nterminal:theme",Af=[{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",working:"#4ade80",unread:"#60a5fa",onUnread:"#06152f",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",working:"#137333",unread:"#1d4ed8",onUnread:"#ffffff",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",...e1({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",working:"#4ade80",unread:"#60a5fa",onUnread:"#06152f",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",working:"#4ade80",unread:"#60a5fa",onUnread:"#06152f",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",working:"#137333",unread:"#1d4ed8",onUnread:"#ffffff",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",...e1({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Rc="midnight";function dp(e){return Af.some(t=>t.id===e)?e:Rc}function Bb(e){return Af.find(t=>t.id===e)??Af[0]}function po(){if(typeof window>"u")return Rc;try{const e=window.localStorage.getItem(Ob);return e?dp(e):fD(window.localStorage.getItem(jC))}catch{return Rc}}function cD(e){const t=dp(e);if(typeof window<"u"){try{window.localStorage.setItem(Ob,t)}catch{}Ib(t),window.dispatchEvent(new CustomEvent(Bv,{detail:t}))}return t}function Ib(e=po()){if(typeof document>"u")return;const t=Bb(dp(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),yt(n,"--nt-bg",t.tokens.bg),yt(n,"--nt-bg-2",t.tokens.bg2),yt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),yt(n,"--nt-line",t.tokens.line),yt(n,"--nt-line-2",t.tokens.line2),yt(n,"--nt-fg",t.tokens.fg),yt(n,"--nt-fg-2",t.tokens.fg2),yt(n,"--nt-fg-3",t.tokens.fg3),yt(n,"--nt-fg-4",t.tokens.fg4),yt(n,"--nt-accent",t.tokens.accent),yt(n,"--nt-accent-soft",t.tokens.accentSoft),yt(n,"--nt-accent-glow",t.tokens.accentGlow),yt(n,"--nt-on-accent",t.tokens.onAccent),yt(n,"--nt-ok",t.tokens.ok),yt(n,"--nt-working",t.tokens.working),yt(n,"--nt-unread",t.tokens.unread),yt(n,"--nt-on-unread",t.tokens.onUnread),yt(n,"--nt-danger",t.tokens.danger),yt(n,"--nt-on-danger",t.tokens.onDanger),yt(n,"--nt-danger-soft",t.tokens.dangerSoft),yt(n,"--nt-danger-line",t.tokens.dangerLine),yt(n,"--nt-warning",t.tokens.warning),yt(n,"--nt-warn",t.tokens.warning),yt(n,"--nt-warning-soft",t.tokens.warningSoft),yt(n,"--nt-warning-glow",t.tokens.warningGlow),yt(n,"--nt-scrim",t.tokens.scrim),yt(n,"--nt-scrim-soft",t.tokens.scrimSoft),yt(n,"--nt-shadow",t.tokens.shadow),yt(n,"--nt-shadow-strong",t.tokens.shadowStrong),yt(n,"--nt-floating-bg",t.tokens.floatingBg),yt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),yt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),yt(n,"--nt-subtle-fill",t.tokens.subtleFill),yt(n,"--nt-hover-fill",t.tokens.hoverFill),yt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),yt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),yt(n,"--nt-transcript-user",t.tokens.transcriptUser),yt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),yt(n,"--nt-transcript-tool",t.tokens.transcriptTool),yt(n,"--nt-transcript-command",t.tokens.transcriptCommand),yt(n,"--nt-transcript-code",t.tokens.transcriptCode),yt(n,"--nt-transcript-search",t.tokens.transcriptSearch),yt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),yt(n,"--nt-qr-bg",t.tokens.qrBg)}function uD(e=po()){return Bb(dp(e)).xterm}function Pb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Ob||n.key===jC)&&(Ib(po()),e())};return window.addEventListener(Bv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bv,e),window.removeEventListener("storage",t)}}function yt(e,t,n){e.style.setProperty(t,n)}function e1(e){const t=dD(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 dD(e){const t=[];for(let n=16;n<=e;n+=1)t.push(hD(n));return t}function hD(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],l=n[t%6];return t1(r,o,l)}if(e>=232&&e<=255){const t=8+(e-232)*10;return t1(t,t,t)}return"#000000"}function t1(e,t,n){return`#${jg(e)}${jg(t)}${jg(n)}`}function jg(e){return e.toString(16).padStart(2,"0")}function fD(e){return e==="signal-red"?"signal-red":Rc}function OC(){const e=v.useSyncExternalStore(Pb,po,()=>Rc);return Bb(e).mode==="light"?"-light":""}function BC({size:e=22}){const t=OC();return u.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function IC({height:e=18}){const t=OC(),n=Math.round(243/34*e);return u.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var $u=MC();function pD(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const hp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Oc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function zb(e){return"nodeType"in e}function $i(e){var t,n;return e?Oc(e)?e:zb(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Hb(e){const{Document:t}=$i(e);return e instanceof t}function Ad(e){return Oc(e)?!1:e instanceof $i(e).HTMLElement}function PC(e){return e instanceof $i(e).SVGElement}function Bc(e){return e?Oc(e)?e.document:zb(e)?Hb(e)?e:Ad(e)||PC(e)?e.ownerDocument:document:document:document}const Js=hp?v.useLayoutEffect:v.useEffect;function fp(e){const t=v.useRef(e);return Js(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function mD(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function cd(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Js(()=>{n.current!==e&&(n.current=e)},t),n}function Ld(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Lf(e){const t=fp(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function jf(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Og={};function jd(e,t){return v.useMemo(()=>{if(t)return t;const n=Og[e]==null?0:Og[e]+1;return Og[e]=n,e+"-"+n},[e,t])}function zC(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((l,d)=>{const f=Object.entries(d);for(const[g,p]of f){const b=l[g];b!=null&&(l[g]=b+e*p)}return l},{...t})}}const Cc=zC(1),Of=zC(-1);function gD(e){return"clientX"in e&&"clientY"in e}function pp(e){if(!e)return!1;const{KeyboardEvent:t}=$i(e.target);return t&&e instanceof t}function vD(e){if(!e)return!1;const{TouchEvent:t}=$i(e.target);return t&&e instanceof t}function Bf(e){if(vD(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return gD(e)?{x:e.clientX,y:e.clientY}:null}const ha=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ha.Translate.toString(e),ha.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),n1="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function _D(e){return e.matches(n1)?e:e.querySelector(n1)}const bD={display:"none"};function yD(e){let{id:t,value:n}=e;return zt.createElement("div",{id:t,style:bD},n)}function SD(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return zt.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function wD(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const HC=v.createContext(null);function xD(e){const t=v.useContext(HC);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function CD(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:l}=r;e.forEach(d=>{var f;return(f=d[o])==null?void 0:f.call(d,l)})},[e]),t]}const kD={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
|
+
`},TD={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function ED(e){let{announcements:t=TD,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=kD}=e;const{announce:l,announcement:d}=wD(),f=jd("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),xD(v.useMemo(()=>({onDragStart(_){let{active:w}=_;l(t.onDragStart({active:w}))},onDragMove(_){let{active:w,over:C}=_;t.onDragMove&&l(t.onDragMove({active:w,over:C}))},onDragOver(_){let{active:w,over:C}=_;l(t.onDragOver({active:w,over:C}))},onDragEnd(_){let{active:w,over:C}=_;l(t.onDragEnd({active:w,over:C}))},onDragCancel(_){let{active:w,over:C}=_;l(t.onDragCancel({active:w,over:C}))}}),[l,t])),!g)return null;const b=zt.createElement(zt.Fragment,null,zt.createElement(yD,{id:r,value:o.draggable}),zt.createElement(SD,{id:f,announcement:d}));return n?$u.createPortal(b,n):b}var ni;(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"})(ni||(ni={}));function If(){}function Pf(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function UC(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const er=Object.freeze({x:0,y:0});function RD(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function DD(e,t){const n=Bf(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function ND(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function MD(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function AD(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function i1(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const LD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=i1(t,t.left,t.top),l=[];for(const d of r){const{id:f}=d,g=n.get(f);if(g){const p=RD(i1(g),o);l.push({id:f,data:{droppableContainer:d,value:p}})}}return l.sort(ND)};function jD(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),d=o-r,f=l-n;if(r<o&&n<l){const g=t.width*t.height,p=e.width*e.height,b=d*f,_=b/(g+p-b);return Number(_.toFixed(4))}return 0}const OD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const l of r){const{id:d}=l,f=n.get(d);if(f){const g=jD(f,t);g>0&&o.push({id:d,data:{droppableContainer:l,value:g}})}}return o.sort(MD)};function BD(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function $C(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:er}function ID(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),l=1;l<r;l++)o[l-1]=arguments[l];return o.reduce((d,f)=>({...d,top:d.top+e*f.y,bottom:d.bottom+e*f.y,left:d.left+e*f.x,right:d.right+e*f.x}),{...n})}}const PD=ID(1);function FC(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 zD(e,t,n){const r=FC(t);if(!r)return e;const{scaleX:o,scaleY:l,x:d,y:f}=r,g=e.left-d-(1-o)*parseFloat(n),p=e.top-f-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),b=o?e.width/o:e.width,_=l?e.height/l:e.height;return{width:b,height:_,top:p,right:g+b,bottom:p+_,left:g}}const HD={ignoreTransform:!1};function Ic(e,t){t===void 0&&(t=HD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:b}=$i(e).getComputedStyle(e);p&&(n=zD(n,p,b))}const{top:r,left:o,width:l,height:d,bottom:f,right:g}=n;return{top:r,left:o,width:l,height:d,bottom:f,right:g}}function s1(e){return Ic(e,{ignoreTransform:!0})}function UD(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function $D(e,t){return t===void 0&&(t=$i(e).getComputedStyle(e)),t.position==="fixed"}function FD(e,t){t===void 0&&(t=$i(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const l=t[o];return typeof l=="string"?n.test(l):!1})}function Ub(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Hb(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ad(o)||PC(o)||n.includes(o))return n;const l=$i(e).getComputedStyle(o);return o!==e&&FD(o,l)&&n.push(o),$D(o,l)?n:r(o.parentNode)}return e?r(e):n}function WC(e){const[t]=Ub(e,1);return t??null}function Bg(e){return!hp||!e?null:Oc(e)?e:zb(e)?Hb(e)||e===Bc(e).scrollingElement?window:Ad(e)?e:null:null}function KC(e){return Oc(e)?e.scrollX:e.scrollLeft}function qC(e){return Oc(e)?e.scrollY:e.scrollTop}function Iv(e){return{x:KC(e),y:qC(e)}}var di;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(di||(di={}));function VC(e){return!hp||!e?!1:e===document.scrollingElement}function YC(e){const t={x:0,y:0},n=VC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,d=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:l,isBottom:d,isRight:f,maxScroll:r,minScroll:t}}const WD={x:.2,y:.2};function KD(e,t,n,r,o){let{top:l,left:d,right:f,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=WD);const{isTop:p,isBottom:b,isLeft:_,isRight:w}=YC(e),C={x:0,y:0},x={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!p&&l<=t.top+T.height?(C.y=di.Backward,x.y=r*Math.abs((t.top+T.height-l)/T.height)):!b&&g>=t.bottom-T.height&&(C.y=di.Forward,x.y=r*Math.abs((t.bottom-T.height-g)/T.height)),!w&&f>=t.right-T.width?(C.x=di.Forward,x.x=r*Math.abs((t.right-T.width-f)/T.width)):!_&&d<=t.left+T.width&&(C.x=di.Backward,x.x=r*Math.abs((t.left+T.width-d)/T.width)),{direction:C,speed:x}}function qD(e){if(e===document.scrollingElement){const{innerWidth:l,innerHeight:d}=window;return{top:0,left:0,right:l,bottom:d,width:l,height:d}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function GC(e){return e.reduce((t,n)=>Cc(t,Iv(n)),er)}function VD(e){return e.reduce((t,n)=>t+KC(n),0)}function YD(e){return e.reduce((t,n)=>t+qC(n),0)}function XC(e,t){if(t===void 0&&(t=Ic),!e)return;const{top:n,left:r,bottom:o,right:l}=t(e);WC(e)&&(o<=0||l<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const GD=[["x",["left","right"],VD],["y",["top","bottom"],YD]];class $b{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Ub(n),o=GC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,d,f]of GD)for(const g of d)Object.defineProperty(this,g,{get:()=>{const p=f(r),b=o[l]-p;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Qu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function XD(e){const{EventTarget:t}=$i(e);return e instanceof t?e:Bc(e)}function Ig(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Os;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Os||(Os={}));function r1(e){e.preventDefault()}function ZD(e){e.stopPropagation()}var qt;(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"})(qt||(qt={}));const ZC={start:[qt.Space,qt.Enter],cancel:[qt.Esc],end:[qt.Space,qt.Enter,qt.Tab]},QD=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case qt.Right:return{...n,x:n.x+25};case qt.Left:return{...n,x:n.x-25};case qt.Down:return{...n,y:n.y+25};case qt.Up:return{...n,y:n.y-25}}};class QC{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Qu(Bc(n)),this.windowListeners=new Qu($i(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Os.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&XC(r),n(er)}handleKeyDown(t){if(pp(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:l=ZC,coordinateGetter:d=QD,scrollBehavior:f="smooth"}=o,{code:g}=t;if(l.end.includes(g)){this.handleEnd(t);return}if(l.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,b=p?{x:p.left,y:p.top}:er;this.referenceCoordinates||(this.referenceCoordinates=b);const _=d(t,{active:n,context:r.current,currentCoordinates:b});if(_){const w=Of(_,b),C={x:0,y:0},{scrollableAncestors:x}=r.current;for(const T of x){const A=t.code,{isTop:M,isRight:W,isLeft:U,isBottom:P,maxScroll:F,minScroll:V}=YC(T),O=qD(T),G={x:Math.min(A===qt.Right?O.right-O.width/2:O.right,Math.max(A===qt.Right?O.left:O.left+O.width/2,_.x)),y:Math.min(A===qt.Down?O.bottom-O.height/2:O.bottom,Math.max(A===qt.Down?O.top:O.top+O.height/2,_.y))},fe=A===qt.Right&&!W||A===qt.Left&&!U,ee=A===qt.Down&&!P||A===qt.Up&&!M;if(fe&&G.x!==_.x){const te=T.scrollLeft+w.x,$=A===qt.Right&&te<=F.x||A===qt.Left&&te>=V.x;if($&&!w.y){T.scrollTo({left:te,behavior:f});return}$?C.x=T.scrollLeft-te:C.x=A===qt.Right?T.scrollLeft-F.x:T.scrollLeft-V.x,C.x&&T.scrollBy({left:-C.x,behavior:f});break}else if(ee&&G.y!==_.y){const te=T.scrollTop+w.y,$=A===qt.Down&&te<=F.y||A===qt.Up&&te>=V.y;if($&&!w.x){T.scrollTo({top:te,behavior:f});return}$?C.y=T.scrollTop-te:C.y=A===qt.Down?T.scrollTop-F.y:T.scrollTop-V.y,C.y&&T.scrollBy({top:-C.y,behavior:f});break}}this.handleMove(t,Cc(Of(_,this.referenceCoordinates),C))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}QC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=ZC,onActivation:o}=t,{active:l}=n;const{code:d}=e.nativeEvent;if(r.start.includes(d)){const f=l.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function a1(e){return!!(e&&"distance"in e)}function o1(e){return!!(e&&"delay"in e)}class Fb{constructor(t,n,r){var o;r===void 0&&(r=XD(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:l}=t,{target:d}=l;this.props=t,this.events=n,this.document=Bc(d),this.documentListeners=new Qu(this.document),this.listeners=new Qu(r),this.windowListeners=new Qu($i(d)),this.initialCoordinates=(o=Bf(l))!=null?o:er,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Os.Resize,this.handleCancel),this.windowListeners.add(Os.DragStart,r1),this.windowListeners.add(Os.VisibilityChange,this.handleCancel),this.windowListeners.add(Os.ContextMenu,r1),this.documentListeners.add(Os.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(o1(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(a1(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Os.Click,ZD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Os.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:l}=this,{onMove:d,options:{activationConstraint:f}}=l;if(!o)return;const g=(n=Bf(t))!=null?n:er,p=Of(o,g);if(!r&&f){if(a1(f)){if(f.tolerance!=null&&Ig(p,f.tolerance))return this.handleCancel();if(Ig(p,f.distance))return this.handleStart()}if(o1(f)&&Ig(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),d(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===qt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const JD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class JC extends Fb{constructor(t){const{event:n}=t,r=Bc(n.target);super(t,JD,r)}}JC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const eN={move:{name:"mousemove"},end:{name:"mouseup"}};var Pv;(function(e){e[e.RightClick=2]="RightClick"})(Pv||(Pv={}));class Wb extends Fb{constructor(t){super(t,eN,Bc(t.event.target))}}Wb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Pv.RightClick?!1:(r?.({event:n}),!0)}}];const Pg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Kb extends Fb{constructor(t){super(t,Pg)}static setup(){return window.addEventListener(Pg.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Pg.move.name,t)};function t(){}}}Kb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ju;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ju||(Ju={}));var zf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(zf||(zf={}));function tN(e){let{acceleration:t,activator:n=Ju.Pointer,canScroll:r,draggingRect:o,enabled:l,interval:d=5,order:f=zf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:b,delta:_,threshold:w}=e;const C=iN({delta:_,disabled:!l}),[x,T]=mD(),A=v.useRef({x:0,y:0}),M=v.useRef({x:0,y:0}),W=v.useMemo(()=>{switch(n){case Ju.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Ju.DraggableRect:return o}},[n,o,g]),U=v.useRef(null),P=v.useCallback(()=>{const V=U.current;if(!V)return;const O=A.current.x*M.current.x,G=A.current.y*M.current.y;V.scrollBy(O,G)},[]),F=v.useMemo(()=>f===zf.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!l||!p.length||!W){T();return}for(const V of F){if(r?.(V)===!1)continue;const O=p.indexOf(V),G=b[O];if(!G)continue;const{direction:fe,speed:ee}=KD(V,G,W,t,w);for(const te of["x","y"])C[te][fe[te]]||(ee[te]=0,fe[te]=0);if(ee.x>0||ee.y>0){T(),U.current=V,x(P,d),A.current=ee,M.current=fe;return}}A.current={x:0,y:0},M.current={x:0,y:0},T()},[t,P,r,T,l,d,JSON.stringify(W),JSON.stringify(C),x,p,F,b,JSON.stringify(w)])}const nN={x:{[di.Backward]:!1,[di.Forward]:!1},y:{[di.Backward]:!1,[di.Forward]:!1}};function iN(e){let{delta:t,disabled:n}=e;const r=jf(t);return Ld(o=>{if(n||!r||!o)return nN;const l={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[di.Backward]:o.x[di.Backward]||l.x===-1,[di.Forward]:o.x[di.Forward]||l.x===1},y:{[di.Backward]:o.y[di.Backward]||l.y===-1,[di.Forward]:o.y[di.Forward]||l.y===1}}},[n,t,r])}function sN(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Ld(o=>{var l;return t==null?null:(l=r??o)!=null?l:null},[r,t])}function rN(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,l=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,r)}));return[...n,...l]},[]),[e,t])}var ud;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ud||(ud={}));var zv;(function(e){e.Optimized="optimized"})(zv||(zv={}));const l1=new Map;function aN(e,t){let{dragging:n,dependencies:r,config:o}=t;const[l,d]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,b=v.useRef(e),_=A(),w=cd(_),C=v.useCallback(function(M){M===void 0&&(M=[]),!w.current&&d(W=>W===null?M:W.concat(M.filter(U=>!W.includes(U))))},[w]),x=v.useRef(null),T=Ld(M=>{if(_&&!n)return l1;if(!M||M===l1||b.current!==e||l!=null){const W=new Map;for(let U of e){if(!U)continue;if(l&&l.length>0&&!l.includes(U.id)&&U.rect.current){W.set(U.id,U.rect.current);continue}const P=U.node.current,F=P?new $b(g(P),P):null;U.rect.current=F,F&&W.set(U.id,F)}return W}return M},[e,l,n,_,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{_||C()},[n,_]),v.useEffect(()=>{l&&l.length>0&&d(null)},[JSON.stringify(l)]),v.useEffect(()=>{_||typeof f!="number"||x.current!==null||(x.current=setTimeout(()=>{C(),x.current=null},f))},[f,_,C,...r]),{droppableRects:T,measureDroppableContainers:C,measuringScheduled:l!=null};function A(){switch(p){case ud.Always:return!1;case ud.BeforeDragging:return n;default:return!n}}}function qb(e,t){return Ld(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function oN(e,t){return qb(e,t)}function lN(e){let{callback:t,disabled:n}=e;const r=fp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function mp(e){let{callback:t,disabled:n}=e;const r=fp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function cN(e){return new $b(Ic(e),e)}function c1(e,t,n){t===void 0&&(t=cN);const[r,o]=v.useState(null);function l(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const d=lN({callback(g){if(e)for(const p of g){const{type:b,target:_}=p;if(b==="childList"&&_ instanceof HTMLElement&&_.contains(e)){l();break}}}}),f=mp({callback:l});return Js(()=>{l(),e?(f?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),d?.disconnect())},[e]),r}function uN(e){const t=qb(e);return $C(e,t)}const u1=[];function dN(e){const t=v.useRef(e),n=Ld(r=>e?r&&r!==u1&&e&&t.current&&e.parentNode===t.current.parentNode?r:Ub(e):u1,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function hN(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(l=>{const d=Bg(l.target);d&&n(f=>f?(f.set(d,Iv(d)),new Map(f)):null)},[]);return v.useEffect(()=>{const l=r.current;if(e!==l){d(l);const f=e.map(g=>{const p=Bg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Iv(p)]):null}).filter(g=>g!=null);n(f.length?new Map(f):null),r.current=e}return()=>{d(e),d(l)};function d(f){f.forEach(g=>{const p=Bg(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,d)=>Cc(l,d),er):GC(e):er,[e,t])}function d1(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==er;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Of(e,n.current):er}function fN(e){v.useEffect(()=>{if(!hp)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function pN(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:l}=r;return n[o]=d=>{l(d,t)},n},{}),[e,t])}function ek(e){return v.useMemo(()=>e?UD(e):null,[e])}const h1=[];function mN(e,t){t===void 0&&(t=Ic);const[n]=e,r=ek(n?$i(n):null),[o,l]=v.useState(h1);function d(){l(()=>e.length?e.map(g=>VC(g)?r:new $b(t(g),g)):h1)}const f=mp({callback:d});return Js(()=>{f?.disconnect(),d(),e.forEach(g=>f?.observe(g))},[e]),o}function tk(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ad(t)?t:e}function gN(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:b}of p)if(Ad(b)){r(_=>{const w=t(b);return _?{..._,width:w.width,height:w.height}:w});break}},[t]),l=mp({callback:o}),d=v.useCallback(p=>{const b=tk(p);l?.disconnect(),b&&l?.observe(b),r(b?t(b):null)},[t,l]),[f,g]=Lf(d);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:g}),[n,f,g])}const vN=[{sensor:JC,options:{}},{sensor:QC,options:{}}],_N={current:{}},pf={draggable:{measure:s1},droppable:{measure:s1,strategy:ud.WhileDragging,frequency:zv.Optimized},dragOverlay:{measure:Ic}};class ed extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const bN={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ed,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:If},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:pf,measureDroppableContainers:If,windowRect:null,measuringScheduled:!1},nk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:If,draggableNodes:new Map,over:null,measureDroppableContainers:If},Od=v.createContext(nk),ik=v.createContext(bN);function yN(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ed}}}function SN(e,t){switch(t.type){case ni.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ni.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 ni.DragEnd:case ni.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ni.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ed(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case ni.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,l=e.droppable.containers.get(n);if(!l||r!==l.key)return e;const d=new ed(e.droppable.containers);return d.set(n,{...l,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case ni.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const l=new ed(e.droppable.containers);return l.delete(n),{...e,droppable:{...e.droppable,containers:l}}}default:return e}}function wN(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Od),l=jf(r),d=jf(n?.id);return v.useEffect(()=>{if(!t&&!r&&l&&d!=null){if(!pp(l)||document.activeElement===l.target)return;const f=o.get(d);if(!f)return;const{activatorNode:g,node:p}=f;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const b of[g.current,p.current]){if(!b)continue;const _=_D(b);if(_){_.focus();break}}})}},[r,t,o,d,l]),null}function sk(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,l)=>l({transform:o,...r}),n):n}function xN(e){return v.useMemo(()=>({draggable:{...pf.draggable,...e?.draggable},droppable:{...pf.droppable,...e?.droppable},dragOverlay:{...pf.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function CN(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const l=v.useRef(!1),{x:d,y:f}=typeof o=="boolean"?{x:o,y:o}:o;Js(()=>{if(!d&&!f||!t){l.current=!1;return}if(l.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const b=n(p),_=$C(b,r);if(d||(_.x=0),f||(_.y=0),l.current=!0,Math.abs(_.x)>0||Math.abs(_.y)>0){const w=WC(p);w&&w.scrollBy({top:_.y,left:_.x})}},[t,d,f,r,n])}const gp=v.createContext({...er,scaleX:1,scaleY:1});var no;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(no||(no={}));const rk=v.memo(function(t){var n,r,o,l;let{id:d,accessibility:f,autoScroll:g=!0,children:p,sensors:b=vN,collisionDetection:_=OD,measuring:w,modifiers:C,...x}=t;const T=v.useReducer(SN,void 0,yN),[A,M]=T,[W,U]=CD(),[P,F]=v.useState(no.Uninitialized),V=P===no.Initialized,{draggable:{active:O,nodes:G,translate:fe},droppable:{containers:ee}}=A,te=O!=null?G.get(O):null,$=v.useRef({initial:null,translated:null}),Z=v.useMemo(()=>{var mt;return O!=null?{id:O,data:(mt=te?.data)!=null?mt:_N,rect:$}:null},[O,te]),ie=v.useRef(null),[J,j]=v.useState(null),[R,I]=v.useState(null),re=cd(x,Object.values(x)),_e=jd("DndDescribedBy",d),N=v.useMemo(()=>ee.getEnabled(),[ee]),Y=xN(w),{droppableRects:oe,measureDroppableContainers:Q,measuringScheduled:we}=aN(N,{dragging:V,dependencies:[fe.x,fe.y],config:Y.droppable}),Se=sN(G,O),ue=v.useMemo(()=>R?Bf(R):null,[R]),Re=at(),Oe=oN(Se,Y.draggable.measure);CN({activeNode:O!=null?G.get(O):null,config:Re.layoutShiftCompensation,initialRect:Oe,measure:Y.draggable.measure});const ge=c1(Se,Y.draggable.measure,Oe),He=c1(Se?Se.parentElement:null),Be=v.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:oe,draggableNodes:G,draggingNode:null,draggingNodeRect:null,droppableContainers:ee,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),L=ee.getNodeFor((n=Be.current.over)==null?void 0:n.id),ve=gN({measure:Y.dragOverlay.measure}),Le=(r=ve.nodeRef.current)!=null?r:Se,Pe=V?(o=ve.rect)!=null?o:ge:null,H=!!(ve.nodeRef.current&&ve.rect),de=uN(H?null:ge),Te=ek(Le?$i(Le):null),Me=dN(V?L??Se:null),je=mN(Me),be=sk(C,{transform:{x:fe.x-de.x,y:fe.y-de.y,scaleX:1,scaleY:1},activatorEvent:R,active:Z,activeNodeRect:ge,containerNodeRect:He,draggingNodeRect:Pe,over:Be.current.over,overlayNodeRect:ve.rect,scrollableAncestors:Me,scrollableAncestorRects:je,windowRect:Te}),Fe=ue?Cc(ue,fe):null,We=hN(Me),Ue=d1(We),ut=d1(We,[ge]),_t=Cc(be,Ue),lt=Pe?PD(Pe,be):null,Nt=Z&<?_({active:Z,collisionRect:lt,droppableRects:oe,droppableContainers:N,pointerCoordinates:Fe}):null,Yt=AD(Nt,"id"),[st,On]=v.useState(null),Sn=H?be:Cc(be,ut),dt=BD(Sn,(l=st?.rect)!=null?l:null,ge),Lt=v.useRef(null),Ct=v.useCallback((mt,St)=>{let{sensor:It,options:$t}=St;if(ie.current==null)return;const dn=G.get(ie.current);if(!dn)return;const Gt=mt.nativeEvent,rn=new It({active:ie.current,activeNode:dn,event:Gt,options:$t,context:Be,onAbort(an){if(!G.get(an))return;const{onDragAbort:En}=re.current,wn={id:an};En?.(wn),W({type:"onDragAbort",event:wn})},onPending(an,ln,En,wn){if(!G.get(an))return;const{onDragPending:si}=re.current,ht={id:an,constraint:ln,initialCoordinates:En,offset:wn};si?.(ht),W({type:"onDragPending",event:ht})},onStart(an){const ln=ie.current;if(ln==null)return;const En=G.get(ln);if(!En)return;const{onDragStart:wn}=re.current,vi={activatorEvent:Gt,active:{id:ln,data:En.data,rect:$}};$u.unstable_batchedUpdates(()=>{wn?.(vi),F(no.Initializing),M({type:ni.DragStart,initialCoordinates:an,active:ln}),W({type:"onDragStart",event:vi}),j(Lt.current),I(Gt)})},onMove(an){M({type:ni.DragMove,coordinates:an})},onEnd:hn(ni.DragEnd),onCancel:hn(ni.DragCancel)});Lt.current=rn;function hn(an){return async function(){const{active:En,collisions:wn,over:vi,scrollAdjustedTranslate:si}=Be.current;let ht=null;if(En&&si){const{cancelDrop:kt}=re.current;ht={activatorEvent:Gt,active:En,collisions:wn,delta:si,over:vi},an===ni.DragEnd&&typeof kt=="function"&&await Promise.resolve(kt(ht))&&(an=ni.DragCancel)}ie.current=null,$u.unstable_batchedUpdates(()=>{M({type:an}),F(no.Uninitialized),On(null),j(null),I(null),Lt.current=null;const kt=an===ni.DragEnd?"onDragEnd":"onDragCancel";if(ht){const ae=re.current[kt];ae?.(ht),W({type:kt,event:ht})}})}}},[G]),gi=v.useCallback((mt,St)=>(It,$t)=>{const dn=It.nativeEvent,Gt=G.get($t);if(ie.current!==null||!Gt||dn.dndKit||dn.defaultPrevented)return;const rn={active:Gt};mt(It,St.options,rn)===!0&&(dn.dndKit={capturedBy:St.sensor},ie.current=$t,Ct(It,St))},[G,Ct]),ki=rN(b,gi);fN(b),Js(()=>{ge&&P===no.Initializing&&F(no.Initialized)},[ge,P]),v.useEffect(()=>{const{onDragMove:mt}=re.current,{active:St,activatorEvent:It,collisions:$t,over:dn}=Be.current;if(!St||!It)return;const Gt={active:St,activatorEvent:It,collisions:$t,delta:{x:_t.x,y:_t.y},over:dn};$u.unstable_batchedUpdates(()=>{mt?.(Gt),W({type:"onDragMove",event:Gt})})},[_t.x,_t.y]),v.useEffect(()=>{const{active:mt,activatorEvent:St,collisions:It,droppableContainers:$t,scrollAdjustedTranslate:dn}=Be.current;if(!mt||ie.current==null||!St||!dn)return;const{onDragOver:Gt}=re.current,rn=$t.get(Yt),hn=rn&&rn.rect.current?{id:rn.id,rect:rn.rect.current,data:rn.data,disabled:rn.disabled}:null,an={active:mt,activatorEvent:St,collisions:It,delta:{x:dn.x,y:dn.y},over:hn};$u.unstable_batchedUpdates(()=>{On(hn),Gt?.(an),W({type:"onDragOver",event:an})})},[Yt]),Js(()=>{Be.current={activatorEvent:R,active:Z,activeNode:Se,collisionRect:lt,collisions:Nt,droppableRects:oe,draggableNodes:G,draggingNode:Le,draggingNodeRect:Pe,droppableContainers:ee,over:st,scrollableAncestors:Me,scrollAdjustedTranslate:_t},$.current={initial:Pe,translated:lt}},[Z,Se,Nt,lt,G,Le,Pe,oe,ee,st,Me,_t]),tN({...Re,delta:fe,draggingRect:lt,pointerCoordinates:Fe,scrollableAncestors:Me,scrollableAncestorRects:je});const pe=v.useMemo(()=>({active:Z,activeNode:Se,activeNodeRect:ge,activatorEvent:R,collisions:Nt,containerNodeRect:He,dragOverlay:ve,draggableNodes:G,droppableContainers:ee,droppableRects:oe,over:st,measureDroppableContainers:Q,scrollableAncestors:Me,scrollableAncestorRects:je,measuringConfiguration:Y,measuringScheduled:we,windowRect:Te}),[Z,Se,ge,R,Nt,He,ve,G,ee,oe,st,Q,Me,je,Y,we,Te]),Ze=v.useMemo(()=>({activatorEvent:R,activators:ki,active:Z,activeNodeRect:ge,ariaDescribedById:{draggable:_e},dispatch:M,draggableNodes:G,over:st,measureDroppableContainers:Q}),[R,ki,Z,ge,M,_e,G,st,Q]);return zt.createElement(HC.Provider,{value:U},zt.createElement(Od.Provider,{value:Ze},zt.createElement(ik.Provider,{value:pe},zt.createElement(gp.Provider,{value:dt},p)),zt.createElement(wN,{disabled:f?.restoreFocus===!1})),zt.createElement(ED,{...f,hiddenTextDescribedById:_e}));function at(){const mt=J?.autoScrollEnabled===!1,St=typeof g=="object"?g.enabled===!1:g===!1,It=V&&!mt&&!St;return typeof g=="object"?{...g,enabled:It}:{enabled:It}}}),kN=v.createContext(null),f1="button",TN="Draggable";function Vb(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const l=jd(TN),{activators:d,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:b,draggableNodes:_,over:w}=v.useContext(Od),{role:C=f1,roleDescription:x="draggable",tabIndex:T=0}=o??{},A=g?.id===t,M=v.useContext(A?gp:kN),[W,U]=Lf(),[P,F]=Lf(),V=pN(d,t),O=cd(n);Js(()=>(_.set(t,{id:t,key:l,node:W,activatorNode:P,data:O}),()=>{const fe=_.get(t);fe&&fe.key===l&&_.delete(t)}),[_,t]);const G=v.useMemo(()=>({role:C,tabIndex:T,"aria-disabled":r,"aria-pressed":A&&C===f1?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[r,C,T,A,x,b.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:G,isDragging:A,listeners:r?void 0:V,node:W,over:w,setNodeRef:U,setActivatorNodeRef:F,transform:M}}function ak(){return v.useContext(ik)}const EN="Droppable",RN={timeout:25};function vp(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const l=jd(EN),{active:d,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(Od),b=v.useRef({disabled:n}),_=v.useRef(!1),w=v.useRef(null),C=v.useRef(null),{disabled:x,updateMeasurementsFor:T,timeout:A}={...RN,...o},M=cd(T??r),W=v.useCallback(()=>{if(!_.current){_.current=!0;return}C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{p(Array.isArray(M.current)?M.current:[M.current]),C.current=null},A)},[A]),U=mp({callback:W,disabled:x||!d}),P=v.useCallback((G,fe)=>{U&&(fe&&(U.unobserve(fe),_.current=!1),G&&U.observe(G))},[U]),[F,V]=Lf(P),O=cd(t);return v.useEffect(()=>{!U||!F.current||(U.disconnect(),_.current=!1,U.observe(F.current))},[F,U]),v.useEffect(()=>(f({type:ni.RegisterDroppable,element:{id:r,key:l,disabled:n,node:F,rect:w,data:O}}),()=>f({type:ni.UnregisterDroppable,key:l,id:r})),[r]),v.useEffect(()=>{n!==b.current.disabled&&(f({type:ni.SetDroppableDisabled,id:r,key:l,disabled:n}),b.current.disabled=n)},[r,l,n,f]),{active:d,rect:w,isOver:g?.id===r,node:F,over:g,setNodeRef:V}}function DN(e){let{animation:t,children:n}=e;const[r,o]=v.useState(null),[l,d]=v.useState(null),f=jf(n);return!n&&!r&&f&&o(f),Js(()=>{if(!l)return;const g=r?.key,p=r?.props.id;if(g==null||p==null){o(null);return}Promise.resolve(t(p,l)).then(()=>{o(null)})},[t,r,l]),zt.createElement(zt.Fragment,null,n,r?v.cloneElement(r,{ref:d}):null)}const NN={x:0,y:0,scaleX:1,scaleY:1};function MN(e){let{children:t}=e;return zt.createElement(Od.Provider,{value:nk},zt.createElement(gp.Provider,{value:NN},t))}const AN={position:"fixed",touchAction:"none"},LN=e=>pp(e)?"transform 250ms ease":void 0,jN=v.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:l,className:d,rect:f,style:g,transform:p,transition:b=LN}=e;if(!f)return null;const _=o?p:{...p,scaleX:1,scaleY:1},w={...AN,width:f.width,height:f.height,top:f.top,left:f.left,transform:ha.Transform.toString(_),transformOrigin:o&&r?DD(r,f):void 0,transition:typeof b=="function"?b(r):b,...g};return zt.createElement(n,{className:d,style:w,ref:t},l)}),ON=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:l,className:d}=e;if(l!=null&&l.active)for(const[f,g]of Object.entries(l.active))g!==void 0&&(o[f]=n.node.style.getPropertyValue(f),n.node.style.setProperty(f,g));if(l!=null&&l.dragOverlay)for(const[f,g]of Object.entries(l.dragOverlay))g!==void 0&&r.node.style.setProperty(f,g);return d!=null&&d.active&&n.node.classList.add(d.active),d!=null&&d.dragOverlay&&r.node.classList.add(d.dragOverlay),function(){for(const[g,p]of Object.entries(o))n.node.style.setProperty(g,p);d!=null&&d.active&&n.node.classList.remove(d.active)}},BN=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ha.Transform.toString(t)},{transform:ha.Transform.toString(n)}]},IN={duration:250,easing:"ease",keyframes:BN,sideEffects:ON({styles:{active:{opacity:"0"}}})};function PN(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return fp((l,d)=>{if(t===null)return;const f=n.get(l);if(!f)return;const g=f.node.current;if(!g)return;const p=tk(d);if(!p)return;const{transform:b}=$i(d).getComputedStyle(d),_=FC(b);if(!_)return;const w=typeof t=="function"?t:zN(t);return XC(g,o.draggable.measure),w({active:{id:l,data:f.data,node:g,rect:o.draggable.measure(g)},draggableNodes:n,dragOverlay:{node:d,rect:o.dragOverlay.measure(p)},droppableContainers:r,measuringConfiguration:o,transform:_})})}function zN(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...IN,...e};return l=>{let{active:d,dragOverlay:f,transform:g,...p}=l;if(!t)return;const b={x:f.rect.left-d.rect.left,y:f.rect.top-d.rect.top},_={scaleX:g.scaleX!==1?d.rect.width*g.scaleX/f.rect.width:1,scaleY:g.scaleY!==1?d.rect.height*g.scaleY/f.rect.height:1},w={x:g.x-b.x,y:g.y-b.y,..._},C=o({...p,active:d,dragOverlay:f,transform:{initial:g,final:w}}),[x]=C,T=C[C.length-1];if(JSON.stringify(x)===JSON.stringify(T))return;const A=r?.({active:d,dragOverlay:f,...p}),M=f.node.animate(C,{duration:t,easing:n,fill:"forwards"});return new Promise(W=>{M.onfinish=()=>{A?.(),W()}})}}let p1=0;function HN(e){return v.useMemo(()=>{if(e!=null)return p1++,p1},[e])}const UN=zt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:l,modifiers:d,wrapperElement:f="div",className:g,zIndex:p=999}=e;const{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:C,draggableNodes:x,droppableContainers:T,dragOverlay:A,over:M,measuringConfiguration:W,scrollableAncestors:U,scrollableAncestorRects:P,windowRect:F}=ak(),V=v.useContext(gp),O=HN(_?.id),G=sk(d,{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:C,draggingNodeRect:A.rect,over:M,overlayNodeRect:A.rect,scrollableAncestors:U,scrollableAncestorRects:P,transform:V,windowRect:F}),fe=qb(w),ee=PN({config:r,draggableNodes:x,droppableContainers:T,measuringConfiguration:W}),te=fe?A.setRef:void 0;return zt.createElement(MN,null,zt.createElement(DN,{animation:ee},_&&O?zt.createElement(jN,{key:O,id:_.id,ref:te,as:f,activatorEvent:b,adjustScale:t,className:g,transition:l,rect:fe,style:{zIndex:p,...o},transform:G},n):null))}),$N=128,FN=512,mo=100,WN="too_many_detached_terminals",KN=64,qN=4096;function _p(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>$N)return null;const n=t.workspaces.map(VN);if(n.some(d=>d===null))return null;const r=n,o=new Set,l=new Set;for(const d of r){if(o.has(d.id))return null;o.add(d.id);for(const f of d.tabs){if(l.has(f.id))return null;l.add(f.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function ok(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>mo}):!1}function VN(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>FN)return null;const n=t.tabs.map(YN);if(n.some(o=>o===null))return null;const r=QN(t.detachedTerminalIds,mo);return r===null?null:{id:t.id,title:t.title,defaultCwd:ZN(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function YN(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=GN(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function GN(e){if(!e||typeof e!="object")return null;let t=0;return Hv(e,1,()=>(t+=1,t<=qN))}function Hv(e,t,n){if(!e||typeof e!="object"||t>KN||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=Hv(r.first,t+1,n),l=Hv(r.second,t+1,n);return!o||!l?null:{type:"split",direction:r.direction,ratio:XN(r.ratio),first:o,second:l}}function XN(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ZN(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function QN(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const lk=[{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"}],JN="nterminal-focus",eM=/^[A-Za-z0-9_.:-]{1,128}$/;function tM(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(JN)!=="terminal"?null:bp({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function bp(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!m1(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!m1(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function m1(e){return typeof e=="string"&&eM.test(e)}const Vt="__main__",ck=128,nM=600*1e3,uk="nterminal.clientDiagnostics.v1",dk="nterminal.terminalDiagnosticsCursor.v1",yp=150,iM=24,sM=160,rM=48*1024,aM="terminal-connection-recovery";let g1=!1,Mu=null,Au=null,zg=0;function oM(){g1||typeof window>"u"||(g1=!0,Ni("page.load",{navigation:CM(),visibility:document.visibilityState,online:navigator.onLine,viewport:gk(),standalone:xM()}),document.addEventListener("visibilitychange",()=>{Ni("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Ni("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Ni("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Ni("network.online")),window.addEventListener("offline",()=>Ni("network.offline")),window.addEventListener("focus",()=>Ni("window.focus")),window.addEventListener("blur",()=>Ni("window.blur")),window.addEventListener("error",e=>{Ni("runtime.error",{message:e.message,source:kM(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Ni("runtime.unhandledrejection",{reason:TM(e.reason)})}))}function Ni(e,t={}){const n={id:gM(),at:new Date().toISOString(),event:dd(e,80),data:mk({...t,visibility:t.visibility??SM(),online:t.online??wM(),viewport:t.viewport??gk()})},r=Yb();return r.push(n),pM(r.slice(-yp)),n}function Yb(){try{const e=window.localStorage.getItem(uk);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(mM).filter(n=>n!==null).slice(-yp):[]}catch{return[]}}async function Gb(e,t=fetch){if(Mu)return Mu;const n=Yb(),r={reason:dd(e,80),events:n},o=JSON.stringify(r);Mu=(async()=>{const l=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!l.ok)throw new Error(`diagnostics_send_failed_${l.status}`);return l.json()})();try{return await Mu}finally{Mu=null}}function Sp(){return hk().events.length>0}async function lM(e=fetch){if(Au)return Au;Au=cM(e);try{return await Au}finally{Au=null}}async function cM(e){const t=hk();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(fM(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function hk(){const e=fk(),t=Yb().filter(o=>uM(o)&&hM(o,e)),n=[];let r=v1([]);for(const o of t){const l=[...n,o],d=v1(l);if(dM(d)>rM)break;n.push(o),r=d}return{events:n,body:r,hasMore:n.length<t.length}}function v1(e){return JSON.stringify({reason:aM,events:e})}function uM(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function dM(e){return new TextEncoder().encode(e).byteLength}function hM(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(pk(e))}function fk(){try{const e=window.localStorage.getItem(dk);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-yp):[]}}catch{return null}}function fM(e){const t=e.at(-1);if(!t)return;const n=fk(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const l of e)l.at===t.at&&r.add(pk(l));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-yp)};try{window.localStorage.setItem(dk,JSON.stringify(o))}catch{}}function pM(e){try{window.localStorage.setItem(uk,JSON.stringify(e))}catch{}}function mM(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:dd(t.id,128)}:{},at:t.at.slice(0,40),event:dd(t.event,80),...t.data&&typeof t.data=="object"?{data:mk(t.data)}:{}}}function gM(){return zg=(zg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${zg.toString(36)}`.slice(0,128)}function pk(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function mk(e){const t={};for(const[n,r]of Object.entries(e).slice(0,iM)){const o=dd(n,64);if(!o||vM(o))continue;const l=_M(r);l!==void 0&&(t[o]=l)}return t}function vM(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function _M(e){if(typeof e=="string")return bM(e,sM);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function dd(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function bM(e,t){return yM(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function yM(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 SM(){return typeof document>"u"?void 0:document.visibilityState}function wM(){return typeof navigator>"u"?void 0:navigator.onLine}function gk(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function xM(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function CM(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function kM(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 TM(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const vk="nterminal.notifications.completionEnabled",Xb="nterminal.notifications.completionToastEnabled",Zb="nterminal.notifications.completionToastDurationSeconds",Qb="nterminal.notifications.completionToastPersistent",Uv="nterminal:completion-toast-display",$v="nterminal:notification-focus",td=6.5,Fv=2,Wv=60;function wp(){return typeof window<"u"&&"Notification"in window}function Jb(){try{return window.localStorage.getItem(vk)==="true"}catch{return!1}}function _1(e){try{window.localStorage.setItem(vk,e?"true":"false")}catch{}}function fl(){return{enabled:NM(),durationSeconds:DM(),persistUntilDismissed:MM()}}function EM(e){if(typeof window<"u"){try{window.localStorage.setItem(Xb,e?"true":"false")}catch{}ey()}return fl()}function b1(e){const t=bk(e);if(typeof window<"u"){try{window.localStorage.setItem(Zb,String(t))}catch{}ey()}return fl()}function RM(e){if(typeof window<"u"){try{window.localStorage.setItem(Qb,e?"true":"false")}catch{}ey()}return fl()}function _k(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Xb||n.key===Zb||n.key===Qb)&&e()};return window.addEventListener(Uv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Uv,e),window.removeEventListener("storage",t)}}function Pc(){return wp()?window.Notification.permission:"unsupported"}function DM(){if(typeof window>"u")return td;try{const e=window.localStorage.getItem(Zb);return e===null?td:bk(Number(e))}catch{return td}}function NM(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Xb)!=="false"}catch{return!0}}function MM(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Qb)==="true"}catch{return!1}}function bk(e){if(!Number.isFinite(e))return td;const t=Math.round(e*2)/2;return Math.max(Fv,Math.min(Wv,t))}function ey(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Uv))}async function yk(){if(!wp())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Pc()}}function AM(e){if(!wp()||Pc()!=="granted"||!Jb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=bp({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),LM(r)})}catch{}}function LM(e){typeof window>"u"||window.dispatchEvent(new CustomEvent($v,{detail:e}))}const y1="nterminal.push.clientId",jM=2e4,S1=[5e3,3e4,12e4];function oa(){try{const e=window.localStorage.getItem(y1);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${qv()}`;return window.localStorage.setItem(y1,t),t}catch{return`client-${qv()}`}}function OM(){return`page-${qv()}`}function xp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=$M(),n=FM(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function BM(e,t){const n=xp();if(!n.supported)throw new Error(n.reason);if((Pc()==="granted"?"granted":await yk())!=="granted")throw new Error("permission_denied");const o=oa(),l=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(o),g=await KM(l,d.publicKey)??await l.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:xk(d.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:wk(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:Sk(n.deviceKind),alwaysNotify:t})}async function IM(e){const t=xp();if(!t.supported||Pc()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=oa(),l=await qM(r.endpoint),d=await e.getPushNotificationStatus(o,l);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&Kv(r,d.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),g=d.endpointRegistered===!0&&Kv(r,f.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:xk(f.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:wk(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:Sk(t.deviceKind),alwaysNotify:!1}),!0}function PM(e){let t=!1,n=!1,r=0,o=null;const l=()=>{o!==null&&(window.clearTimeout(o),o=null)},d=b=>{t||n||(n=!0,IM(e).then(_=>{r=0,_&&Ni("push.subscription.reconciled",{trigger:b})}).catch(_=>{if(Ni("push.subscription.reconcile_failed",{trigger:b,reason:_ instanceof Error?_.message:String(_)}),!t&&r<S1.length){const w=S1[r++];o=window.setTimeout(()=>{o=null,d("retry")},w)}}).finally(()=>{n=!1}))},f=b=>{l(),r=0,d(b)},g=()=>f("online"),p=()=>f("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),d("startup"),()=>{t=!0,l(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function zM(e){const t=oa();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function HM(e,t){await e.updatePushNotificationDevice({clientId:oa(),alwaysNotify:t})}function UM(e){if(typeof window>"u")return()=>{};const t=oa(),n=OM();let r=null,o=!1;const l=(p=!0)=>{const b=xp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:WM(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:Jb()&&Pc()==="granted",active:p}).catch(()=>{})},d=()=>{o||r!==null||(r=window.setInterval(()=>l(!0),jM))},f=()=>l(!0),g=()=>l(!1);return window.addEventListener("focus",f),window.addEventListener("blur",f),document.addEventListener("visibilitychange",f),window.addEventListener("pagehide",g),l(!0),d(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",f),window.removeEventListener("blur",f),document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",g),l(!1)}}function $M(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function FM(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function Sk(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function WM(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function wk(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function KM(e,t){const n=await e.pushManager.getSubscription();return n?Kv(n,t)?n:(await n.unsubscribe(),null):null}function Kv(e,t){const n=e.options.applicationServerKey;return n?Ck(n)===t:!0}async function qM(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Ck(t)}function xk(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),l=new Uint8Array(o);for(let d=0;d<r.length;d+=1)l[d]=r.charCodeAt(d);return o}function Ck(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function qv(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const VM=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function YM(e,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:VM(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}const GM=e=>{let t="",n=!1;for(const r of e){if(r==="-"||r==="_"||r<=" "){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t};const XM=e=>{const t=GM(e);return t.charAt(0).toUpperCase()+t.slice(1)};const Vv=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const el={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Hg(e){return e!=null}function ZM(e,t={}){const n=t.attributeNames??{},r=w=>n[w]??w,o=e.size??e.width??el.width,l=e.size??e.height??el.height,d=e.aliases?.filter(w=>typeof w=="string"&&w.trim()!=="").map(w=>`lucide-${w}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...d],g=t.className?.split(" ").filter(Boolean)??[],p=t.includeDefaultClasses===!1?Vv(...g):Vv("lucide",...f,...g),b=t.absoluteStrokeWidth?Number(t.strokeWidth??el["stroke-width"])*Number(e.size??e.width??el.width)/Number(t.size??t.width??el.width):t.strokeWidth??el["stroke-width"];return["svg",{...Object.entries(el).reduce((w,[C,x])=>(w[r(C)]=x,w),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&Hg(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&Hg(t.width)&&{[r("width")]:t.width},..."height"in t&&Hg(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:b,...p&&{[r("class")]:p},[r("viewBox")]:`0 0 ${o} ${l}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(w=>{const[C,x,T]=w,A=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return T?[C,A,T]:[C,A]})]}function QM(e,t={}){return ZM(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const JM=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},eA=v.createContext({}),tA=()=>v.useContext(eA),nA=v.forwardRef(({color:e,size:t,width:n,height:r,strokeWidth:o,absoluteStrokeWidth:l,nonScalingStroke:d,className:f="",children:g,iconNode:p=[],icon:b={node:p,aliases:[],size:24},..._},w)=>{const{size:C=24,strokeWidth:x=2,absoluteStrokeWidth:T=!1,nonScalingStroke:A=!1,color:M="currentColor",className:W=""}=tA()??{},U=!!g||JM(_),[P,F,V=[]]=QM(b,{color:e??M,width:n??t??C,height:r??t??C,strokeWidth:o??x,absoluteStrokeWidth:l??T,nonScalingStroke:d??A,className:Vv(W,f),hasA11yProp:U,attributes:_});return v.createElement(P,{ref:w,...F},[...V.map(([O,G])=>v.createElement(O,G)),...Array.isArray(g)?g:[g]])});function Ln(e,t=[],n=[]){const r=typeof e=="string"?YM(e,t,n):e,o=v.forwardRef(({className:l,...d},f)=>v.createElement(nA,{ref:f,icon:r,className:l,...d}));return r.name&&(o.displayName=XM(r.name)),o}const kk={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};kk.node;const iA=Ln(kk);const Tk={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Tk.node;const sA=Ln(Tk);const Ek={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Ek.node;const rA=Ln(Ek);const Rk={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Rk.node;const aA=Ln(Rk);const Dk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Dk.node;const Nk=Ln(Dk);const Mk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Mk.node;const oA=Ln(Mk);const Ak={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ak.node;const Lk=Ln(Ak);const jk={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};jk.node;const w1=Ln(jk);const Ok={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Ok.node;const lA=Ln(Ok);const Bk={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};Bk.node;const cA=Ln(Bk);const Ik={name:"key-round",size:24,node:[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]};Ik.node;const uA=Ln(Ik);const Pk={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]};Pk.node;const dA=Ln(Pk);const zk={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};zk.node;const hA=Ln(zk);const Hk={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]};Hk.node;const fA=Ln(Hk);const Uk={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Uk.node;const pA=Ln(Uk);const $k={name:"plug",size:24,node:[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]};$k.node;const Ug=Ln($k);const Fk={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};Fk.node;const mA=Ln(Fk);const Wk={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};Wk.node;const Dc=Ln(Wk);const Kk={name:"shield-check",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};Kk.node;const x1=Ln(Kk);const qk={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};qk.node;const gA=Ln(qk);const Vk={name:"unplug",size:24,node:[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]};Vk.node;const C1=Ln(Vk);const Yk={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Yk.node;const Yv=Ln(Yk);function ra(e,t){const n=[Vt,...t.map(d=>d.id)],r=new Set(n),o=new Set,l=[];for(const d of e??[])!r.has(d)||o.has(d)||(o.add(d),l.push(d));for(const d of n)o.has(d)||l.push(d);return l}function vA(e,t){return ra(e,t).map(n=>n===Vt?null:n)}function _A(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function bA(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const k1="Local",yA=3e4,SA=2,wA=6,Gk="nterminal.serverList.viewMode.v1";function xA(){try{return window.localStorage.getItem(Gk)==="list"?"list":"stats"}catch{return"stats"}}function CA(e){try{window.localStorage.setItem(Gk,e)}catch{}}function kA(e,t){const n=new Map(e.map(r=>[r.id,r]));return ra(t,e).flatMap(r=>{if(r===Vt)return[{kind:"main",id:Vt}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function T1(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Xk(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Is(e.value.cpuPercent)} ${ty(e.value)}`,`MEM ${Is(e.value.memoryPercent)} ${da(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Is(e.value.diskPercent)} ${da(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Is(e.value.swapPercent)} ${da(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function E1(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Is(e.value.cpuPercent)} (${ty(e.value)})`,`RAM ${Is(e.value.memoryPercent)} (${da(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Is(e.value.diskPercent)} (${da(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Is(e.value.swapPercent)} (${da(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function TA(e,t){const n=Xk(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function Is(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function ty(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`:`${Gv(e.cpuPercent/100*t)}/${t} cores`}function da(e,t){return!R1(e)||!R1(t)?"–/–":EA(e,t)}function EA(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Gv(e/r)}/${Gv(t/r)} ${n}`}function Gv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function R1(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Vh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function RA(e){return[{label:"CPU",percent:Is(e.cpuPercent),detail:ty(e),tone:Vh(e.cpuPercent)},{label:"MEM",percent:Is(e.memoryPercent),detail:da(e.memoryUsedBytes,e.memoryTotalBytes),tone:Vh(e.memoryPercent)},{label:"DISK",percent:Is(e.diskPercent),detail:da(e.diskUsedBytes,e.diskTotalBytes),tone:Vh(e.diskPercent)},{label:"SWAP",percent:Is(e.swapPercent),detail:da(e.swapUsedBytes,e.swapTotalBytes),tone:Vh(e.swapPercent)}]}function DA({entry:e}){return e?.status==="offline"?u.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?u.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>u.jsxs("span",{className:"server-list-stat-cell",children:[u.jsxs("span",{className:"server-list-stat-head",children:[u.jsx("span",{className:"server-list-stat-label",children:t}),u.jsx("span",{className:"server-list-stat-value",children:"–"})]}),u.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):u.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:E1(e),"aria-label":E1(e),children:RA(e.value).map(t=>u.jsxs("span",{className:"server-list-stat-cell",children:[u.jsxs("span",{className:"server-list-stat-head",children:[u.jsx("span",{className:"server-list-stat-label",children:t.label}),u.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),u.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function D1({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:l,onManageAccounts:d,onServerInfo:f,renderServerChildren:g,compact:p=!1}){const[b,_]=v.useState([]),[w,C]=v.useState([Vt]),[x,T]=v.useState(null),[A,M]=v.useState(!1),[W,U]=v.useState(!1),[P,F]=v.useState(null),[V,O]=v.useState(""),G=v.useRef(null),[fe,ee]=v.useState(()=>xA()),[te,$]=v.useState(null),[Z,ie]=v.useState(null),[J,j]=v.useState({}),R=v.useRef({}),I=v.useRef(0),re=v.useRef([]),_e=v.useRef([Vt]),N=v.useRef(null);v.useEffect(()=>{re.current=b},[b]),v.useEffect(()=>{const H=ra(w,b);_e.current=H,T1(H,w)||C(H)},[b,w]),v.useEffect(()=>{let H=!1;return e.listAgents().then(de=>{H||(_(de.agents),U(!0),C(ra(de.serverOrder,de.agents)))}).catch(()=>{}),e.getMainInfo().then(de=>{H||(T(de.name),M(!0))}).catch(()=>{}),()=>{H=!0}},[e,o]),v.useEffect(()=>{P&&(G.current?.focus(),G.current?.select())},[P]),v.useEffect(()=>{let H=!1;function de(){const Me=[{key:Vt,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...b.map(be=>({key:be.id,load:()=>e.getAgentStats(be.id),probe:async()=>(await e.pingAgent(be.id)).ok}))],je=new Set(Me.map(be=>be.key));for(const be of Object.keys(R.current))je.has(be)||delete R.current[be];j(be=>{const Fe={};for(const We of je)We in be&&(Fe[We]=be[We]);return Fe});for(const be of Me)be.load().then(Fe=>{H||(R.current[be.key]=0,j(We=>je.has(be.key)?{...We,[be.key]:{status:"online",value:Fe,stale:!1}}:We))}).catch(async Fe=>{if(H)return;if(Fe instanceof Un&&Fe.status===401&&be.key===Vt){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(be.key===Vt&&Fe instanceof Un){R.current[be.key]=0,j(Ue=>{if(!je.has(be.key))return Ue;const ut=Ue[be.key];return{...Ue,[be.key]:{status:"online",value:ut?.value??null,stale:!0}}});return}if(be.probe)try{if(await be.probe()){if(H)return;R.current[be.key]=0,j(Ue=>{if(!je.has(be.key))return Ue;const ut=Ue[be.key];return{...Ue,[be.key]:{status:"online",value:ut?.value??null,stale:!0}}});return}}catch(Ue){if(H)return;if(Ue instanceof Un&&Ue.status===401){r?.({source:be.key===Vt?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const We=(R.current[be.key]??0)+1;R.current[be.key]=We,We>=SA&&j(Ue=>je.has(be.key)?{...Ue,[be.key]:{status:"offline",value:Ue[be.key]?.value??null,stale:!0}}:Ue)})}de();const Te=window.setInterval(de,yA);return()=>{H=!0,window.clearInterval(Te)}},[e,b,r]);function Y(H){H==="main"?(O(x??""),F({kind:"main"})):(O(H.name),F({kind:"agent",id:H.id}))}async function oe(){if(!P)return;const H=V.trim(),de=P;if(F(null),de.kind==="main"){const Te=H||"";try{const Me=await e.renameMain(Te);T(Me.name)}catch{}}else{if(!H)return;const Te=b.find(Me=>Me.id===de.id)?.name;_(Me=>Me.map(je=>je.id===de.id?{...je,name:H}:je));try{await e.renameAgent(de.id,H)}catch{Te!==void 0&&_(Me=>Me.map(je=>je.id===de.id?{...je,name:Te}:je))}}}function Q(){F(null)}function we(H){ee(H),CA(H)}function Se(H,de,Te){if(H===de)return;const Me=ra(_e.current,re.current),je=Me.findIndex(lt=>lt===H),be=Me.findIndex(lt=>lt===de);if(je<0||be<0)return;const Fe=[...Me],[We]=Fe.splice(je,1);if(!We)return;const Ue=Fe.findIndex(lt=>lt===de);if(Ue<0)return;const ut=Te==="before"?Ue:Ue+1;if(Fe.splice(ut,0,We),T1(Fe,Me))return;const _t=I.current+1;I.current=_t,_e.current=Fe,C(Fe),e.reorderAgents(Fe).then(lt=>{if(I.current===_t){re.current=lt.agents;const Nt=ra(lt.serverOrder,lt.agents);_e.current=Nt,_(lt.agents),C(Nt)}}).catch(async()=>{if(I.current===_t)try{const lt=await e.listAgents();if(I.current===_t){re.current=lt.agents;const Nt=ra(lt.serverOrder,lt.agents);_e.current=Nt,_(lt.agents),C(Nt)}}catch{I.current===_t&&(_e.current=Me,C(Me))}})}function ue(H,de){const Te=ra(_e.current,re.current),Me=Te.findIndex(be=>be===H),je=Te[Me+de];Me<0||!je||Se(H,je,de<0?"before":"after")}function Re(H,de){de.pointerType==="mouse"&&de.button!==0||(de.stopPropagation(),N.current={sourceId:H,pointerId:de.pointerId,startX:de.clientX,startY:de.clientY,active:!1,targetId:null,placement:"after"},de.currentTarget.setPointerCapture?.(de.pointerId))}function Oe(H){const de=N.current;if(!de||de.pointerId!==H.pointerId)return;const Te=Math.hypot(H.clientX-de.startX,H.clientY-de.startY);if(!de.active){if(Te<wA)return;de.active=!0,$(de.sourceId)}const je=document.elementFromPoint(H.clientX,H.clientY)?.closest("[data-server-id]"),be=je?.dataset.serverId??null;if(!je||!be||be===de.sourceId){de.targetId=null,ie(null);return}const Fe=je.getBoundingClientRect(),We=H.clientY<Fe.top+Fe.height/2?"before":"after";de.targetId=be,de.placement=We,ie({serverId:be,placement:We})}function ge(H){const de=N.current;!de||de.pointerId!==H.pointerId||(H.stopPropagation(),H.currentTarget.releasePointerCapture?.(H.pointerId),N.current=null,$(null),ie(null),de.active&&de.targetId&&Se(de.sourceId,de.targetId,de.placement))}function He(H){const de=N.current;de&&de.pointerId===H.pointerId&&H.currentTarget.releasePointerCapture?.(H.pointerId),N.current=null,$(null),ie(null)}const Be=x?.trim()||k1,L=P?.kind==="main",ve=fe==="stats",Le=kA(b,w),Pe=Le.length>1;return v.useEffect(()=>{l?.([...A?[{agentId:null,label:Be}]:[],...W?b.map(H=>({agentId:H.id,label:H.name})):[]])},[b,W,Be,A,l]),p?u.jsx("div",{className:"server-list server-list--compact",children:Le.map(H=>{const de=H.kind==="main",Te=de?Be:H.agent.name,Me=de?Vt:H.id,je=J[Me],be=Xk(je);return u.jsxs("button",{type:"button",className:`server-list-chip${(de?t===null:t===H.id)?" server-list-chip--active":""}`,onClick:()=>n(de?null:H.id),"aria-label":`${Te}${be?` — ${be}`:""}`,title:`${Te}${be?` — ${be}`:""}`,children:[u.jsx("span",{className:"server-list-chip-initial",children:bA(Te)}),u.jsx("span",{className:"server-list-chip-pip","data-status":_A(je)})]},H.id)})}):u.jsxs("div",{className:`server-list server-list--${fe}`,children:[u.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[u.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":fe==="list",onClick:()=>we("list"),title:"Show server names only",children:"List"}),u.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":fe==="stats",onClick:()=>we("stats"),title:"Show resource usage",children:"Stats"})]}),Le.map(H=>{const de=H.kind==="main",Te=de?Be:H.agent.name,Me=de?Vt:H.id,je=de?t===null:t===H.id,be=de?L:P?.kind==="agent"&&P.id===H.id,Fe=g?.({agentId:de?null:H.id,serverId:H.id,label:Te,active:je}),We=Z?.serverId===H.id&&te!==H.id?` server-list-section--drop-target server-list-section--drop-${Z.placement}`:"";return u.jsxs("section",{className:`server-list-section${We}`,"aria-label":`${Te} server`,children:[u.jsx("div",{className:["server-list-row",te===H.id?"server-list-row--dragging":"",Z?.serverId===H.id&&te!==H.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":H.id,children:be?u.jsxs(u.Fragment,{children:[Pe?u.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,u.jsx("form",{className:"server-list-editor",onSubmit:Ue=>{Ue.preventDefault(),oe()},children:u.jsx("input",{ref:G,"aria-label":de?"Rename main server":`Rename ${Te}`,value:V,onChange:Ue=>O(Ue.target.value),onBlur:()=>{oe()},onKeyDown:Ue=>{Ue.key==="Escape"&&(Ue.preventDefault(),Q())},placeholder:de?k1:void 0})})]}):u.jsxs(u.Fragment,{children:[Pe?u.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":H.id,title:"Drag to reorder","aria-label":`Reorder ${Te}`,"aria-grabbed":te===H.id,onPointerDown:Ue=>Re(H.id,Ue),onPointerMove:Oe,onPointerUp:ge,onPointerCancel:He,onKeyDown:Ue=>{(Ue.key==="ArrowUp"||Ue.key==="ArrowDown")&&(Ue.preventDefault(),Ue.stopPropagation(),ue(H.id,Ue.key==="ArrowUp"?-1:1))},onClick:Ue=>Ue.stopPropagation(),children:"::"}):null,u.jsxs("div",{className:`server-list-item${je?" server-list-item--active":""}`,title:TA(Te,J[Me]),children:[u.jsxs("div",{className:"server-list-item-header",children:[u.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(de?null:H.id),onDoubleClick:Ue=>{Ue.preventDefault(),Y(de?"main":{id:H.id,name:Te})},children:[u.jsx("span",{className:"server-list-dot"}),u.jsx("span",{className:"server-list-name",title:de?void 0:H.agent.url??"Outbound connection to main",children:Te})]}),d?u.jsx("span",{className:"server-list-provider-actions","aria-label":`${Te} account management`,children:["codex","claude"].map(Ue=>{const ut=Ue==="codex"?"Codex":"Claude",_t=J[Me]?.value?.accountsReloginRequired?.includes(Ue)===!0;return u.jsxs("button",{type:"button",className:`server-list-provider-button${_t?" server-list-provider-button--attention":""}`,title:_t?`Manage ${ut} accounts: a saved account needs re-login`:`Manage ${ut} accounts`,"aria-label":`Manage ${ut} accounts on ${Te}${_t?" (re-login required)":""}`,onClick:()=>d({agentId:de?null:H.id,label:Te},Ue),children:[u.jsx("img",{src:`/brand/${Ue}.webp`,alt:""}),_t?u.jsx("span",{className:"server-list-provider-attention","aria-hidden":"true"}):null]},Ue)})}):null,f&&u.jsx("button",{type:"button",className:"server-list-provider-button",title:"Server information","aria-label":`Server information: ${Te}`,onClick:()=>f({agentId:de?null:H.id,label:Te}),children:u.jsx(cA,{size:17})})]}),ve?u.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(de?null:H.id),children:u.jsx(DA,{entry:J[Me]})}):null]})]})}),Fe?u.jsx("div",{className:"server-list-children",children:Fe}):null]},H.id)})]})}function NA(e,t){if(e.refresh?.state==="reauth_required")return e.refresh.code??"reauth_required";const n=e.refreshTokenExpiresAt?Date.parse(e.refreshTokenExpiresAt):NaN;return Number.isFinite(n)&&n<=t?"refresh_token_expired":null}function MA(e){return["refresh_token_invalidated","refresh_token_revoked","refresh_token_reused","invalid_grant"].includes(e)?"The provider revoked this login.":["refresh_token_expired","token_expired"].includes(e)?"Login expired.":e==="refresh_token_unavailable"?"No renewable login is stored for this account.":"The provider no longer accepts this login."}function AA({provider:e,serverLabel:t,api:n,disabled:r=!1,onBusyChange:o}){const[l,d]=v.useState(null),[f,g]=v.useState(!0),[p,b]=v.useState(!1),[_,w]=v.useState(null),[C,x]=v.useState(null),[T,A]=v.useState(null),M=v.useRef(null),W=v.useRef(null),U=v.useRef(null),P=v.useRef(null),F=v.useRef(null),V=v.useRef(!1),O=v.useId(),G=v.useId(),fe=e==="codex"?"Codex":"Claude",ee=r||l?.reason==="preview_mode",te=OA(l),$=e==="codex"&&!!l?.installed&&!te&&l?.reason!=="hooks_disabled",Z=v.useCallback(async()=>{const J=M.current;if(!J?.active||J.busy)return;const j=++J.generation;g(!0),x(null),A(null);let R=null;try{R=await n.getProviderHooks(e),J.active&&j===J.generation&&d(R)}catch(I){J.active&&j===J.generation&&x(M1(I))}finally{J.active&&j===J.generation&&g(!1)}if(!(e!=="codex"||!R?.installed||R.trust||R.reason==="preview_mode"||R.reason==="hooks_disabled"))try{const I=await n.checkProviderHookTrust(e);J.active&&j===J.generation&&!J.busy&&I.trust&&!I.trust.reason&&d(I)}catch{}},[n,e]);v.useEffect(()=>{const J={active:!0,busy:!1,generation:0};return M.current=J,d(null),w(null),b(!1),A(null),F.current=null,Z(),()=>{J.active=!1}},[Z]),v.useEffect(()=>{_&&!p?W.current?.focus():!p&&V.current&&(F.current==="trust"&&P.current?P:U).current?.focus(),V.current=!!_||p;const J=j=>{j.key!=="Escape"||!_&&!p||(j.preventDefault(),j.stopImmediatePropagation(),p||w(null))};return window.addEventListener("keydown",J,!0),()=>window.removeEventListener("keydown",J,!0)},[_,p]);async function ie(){const J=M.current;if(!(!J?.active||J.busy||ee||!_)){J.busy=!0,J.generation++,b(!0),g(!1),x(null),A(null),o(!0),F.current=_;try{const j=await(_==="install"?n.installProviderHooks(e):_==="remove"?n.removeProviderHooks(e):n.trustProviderHooks(e));J.active&&(d(j),w(null),_==="trust"?j.trust?j.trust.reason?x(PA(j.trust.reason)):A(IA(j.trust)):x("Codex did not report a trust result. Use /hooks in Codex instead."):j.installed!==(_==="install")&&x(j.reason?Xv(j.reason):"The requested hook change was not applied."))}catch(j){J.active&&x(M1(j))}finally{J.busy=!1,J.active&&(b(!1),o(!1))}}}return u.jsxs("section",{className:"provider-hooks","aria-labelledby":O,"aria-busy":f||p,children:[u.jsxs("div",{className:"provider-hooks-heading",children:[u.jsxs("div",{children:[u.jsxs("h3",{id:O,children:[u.jsx(Ug,{size:14,"aria-hidden":"true"}),"Provider hooks"]}),u.jsx("span",{className:"provider-hooks-status",role:"status",children:f?"Checking...":l?jA(l):"Status unavailable"})]}),u.jsxs("div",{className:"provider-hooks-actions",children:[u.jsx("button",{type:"button",className:"account-icon-button",title:"Refresh hook status","aria-label":"Refresh hook status",disabled:r||f||p||!!_,onClick:()=>{Z()},children:u.jsx(Dc,{size:14,"aria-hidden":"true"})}),u.jsxs("button",{ref:U,type:"button",disabled:ee||f||p||!l||!!_,onClick:()=>w(l?.installed?"remove":"install"),children:[l?.installed?u.jsx(C1,{size:14,"aria-hidden":"true"}):u.jsx(Ug,{size:14,"aria-hidden":"true"}),l?.installed?"Remove hooks":"Install hooks"]})]})]}),l?.configPath?u.jsx("code",{className:"provider-hooks-path",children:l.configPath}):null,l?.notifyConfigPath?u.jsx("code",{className:"provider-hooks-path",children:l.notifyConfigPath}):null,l?.reason&&l.reason!=="approval_unknown"&&l.reason!=="approval_required"?u.jsxs("p",{className:"provider-hooks-reason",children:[Xv(l.reason),l.reason==="unsafe_path"&&l.unsafePath?u.jsxs(u.Fragment,{children:[" ",u.jsx("code",{children:l.unsafePath})]}):null]}):null,l?.warnings?.length?u.jsx("ul",{className:"provider-hooks-warnings",children:l.warnings.map(J=>u.jsx("li",{children:zA(J)},J))}):null,e==="codex"&&te?u.jsxs("p",{className:"provider-hooks-trusted",children:["Codex reports ",BA(l?.trust?.total??l?.hookCount)," as trusted."]}):e==="codex"&&(l?.installed||l?.approvalRequired||l?.activity?.observed||_==="install")?u.jsxs("p",{className:"provider-hooks-trust",children:["In Codex, open ",u.jsx("code",{children:"/hooks"})," and trust the NTerminal hooks.",l?.activity?.observed?" Events received from at least one hook; other hooks may still need approval.":null,l?.trust&&!l.trust.reason&&l.trust.pending>0?` Codex reports ${l.trust.pending} of ${l.trust.total} still need approval.`:null]}):null,$?u.jsx("div",{className:"provider-hooks-actions",children:u.jsxs("button",{ref:P,type:"button",disabled:ee||f||p||!!_,onClick:()=>w("trust"),children:[u.jsx(x1,{size:14,"aria-hidden":"true"}),"Trust NTerminal hooks in Codex"]})}):null,e==="codex"&&l?.installed&&l.activity?.unboundPanes?.length?u.jsx(LA,{panes:l.activity.unboundPanes}):null,_?u.jsxs("div",{className:"provider-hooks-confirm",role:"group","aria-labelledby":G,children:[_==="trust"?u.jsxs(u.Fragment,{children:[u.jsxs("p",{id:G,children:["Trust ",N1(l?.hookCount)," Codex hooks on ",t,"?"]}),u.jsxs("p",{children:["This marks only ",N1(l?.hookCount)," Codex hooks as trusted in Codex's ",u.jsx("code",{children:"config.toml"}),", the same as pressing Trust in ",u.jsx("code",{children:"/hooks"}),". Codex performs the change; other hooks stay as they are."]}),u.jsxs("p",{children:["Trusted hooks run outside the Codex sandbox. The command it trusts is the NTerminal hook helper",l?.hookCommand?":":"."]}),l?.hookCommand?u.jsx("code",{className:"provider-hooks-path",children:l.hookCommand}):null]}):u.jsxs(u.Fragment,{children:[u.jsxs("p",{id:G,children:[_==="install"?"Install":"Remove"," ",fe," hooks on ",t,"?"]}),u.jsx("p",{children:_==="install"?"Add NTerminal hooks to this provider's configuration?":"Remove NTerminal hooks from this provider's configuration?"})]}),u.jsxs("div",{className:"provider-hooks-actions",children:[u.jsx("button",{ref:W,type:"button",disabled:p,onClick:()=>w(null),children:"Cancel"}),u.jsxs("button",{type:"button",className:_==="remove"?"danger-button":"primary-button",disabled:ee||p,onClick:()=>{ie()},children:[p?u.jsx(hA,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"}):_==="install"?u.jsx(Ug,{size:14,"aria-hidden":"true"}):_==="trust"?u.jsx(x1,{size:14,"aria-hidden":"true"}):u.jsx(C1,{size:14,"aria-hidden":"true"}),p?"Applying...":_==="install"?"Confirm installation":_==="trust"?"Confirm trust":"Confirm removal"]})]})]}):null,T?u.jsx("p",{className:"provider-hooks-notice",role:"status",children:T}):null,C?u.jsx("p",{className:"provider-hooks-error",role:"alert",children:C}):null]})}function LA({panes:e}){const t=e.some(o=>o.reason==="shared_daemon_same_cwd"),n=e.map(o=>o.title).filter(Boolean),r=e.length===1?"1 Codex pane is":`${e.length} Codex panes are`;return u.jsxs("p",{className:"provider-hooks-note",role:"note",children:[r," not linked to hook events",n.length?` (${n.join(", ")})`:"","."," ",t?"Codex runs sessions in a shared background server, and another session is open in the same directory, so events cannot be matched to a pane.":"Codex runs sessions in a shared background server, and NTerminal could not confirm which session belongs to the pane."," ","These panes use transcript detection instead. Run one Codex per directory, or start Codex with ",u.jsx("code",{children:"--no-daemon"}),"."]})}function jA(e){return e.installed?e.activity?.observed?"Receiving events":e.trust&&!e.trust.reason?e.trust.pending>0?"Installed; awaiting approval":"Installed and trusted; awaiting events":e.approvalRequired===!1?"Installed; awaiting events":"Installed; awaiting approval or events":e.activity?.observed?"Not installed; receiving events":"Not installed"}function OA(e){return!!(e?.installed&&e.trust&&!e.trust.reason&&e.trust.pending===0&&e.trust.total>0)}function BA(e){return e===void 0?"all NTerminal hooks":e===1?"the NTerminal hook":`all ${e} NTerminal hooks`}function N1(e){return e===void 0?"NTerminal's":`NTerminal's ${e}`}function IA(e){const t=[e.trusted===0?"All NTerminal hooks were already trusted in Codex.":`Codex trusted ${e.trusted} NTerminal hook${e.trusted===1?"":"s"}.`];return e.trusted>0&&e.alreadyTrusted>0&&t.push(`${e.alreadyTrusted} ${e.alreadyTrusted===1?"was":"were"} already trusted.`),e.skipped>0&&t.push(`${e.skipped} other hook${e.skipped===1?" was":"s were"} left unchanged.`),t.push("New Codex sessions use the trusted hooks."),t.join(" ")}function PA(e){return{codex_unavailable:"The Codex CLI was not found on this server. Trust the hooks with /hooks in Codex instead.",codex_timeout:"Codex did not respond in time. Try again, or trust the hooks with /hooks in Codex.",codex_rpc_failed:"Codex could not complete the request. Trust the hooks with /hooks in Codex instead.",hooks_not_installed:"NTerminal hooks are not installed.",hooks_not_listed:"Codex did not list every NTerminal hook exactly as installed. Nothing was trusted; reinstall the hooks or use /hooks.",verification_failed:"Codex did not confirm trust for every NTerminal hook. Check /hooks in Codex."}[e]??Xv(e)}function M1(e){if(e instanceof Un){if(e.message==="preview_mode")return"Hook changes are disabled in preview mode.";if(e.status===401)return"Your session expired. Sign in again.";if(e.status===404)return"Hook integration is unavailable on this server.";if(e.status===502)return"The remote server could not be reached."}return"The hook operation could not be completed. Refresh the status before trying again."}function Xv(e){return{preview_mode:"Hook changes are disabled in preview mode.",notify_conflict:"An existing Codex notify command conflicts with this integration.",ownership_conflict:"The configuration has changed. NTerminal cannot safely update these hooks.",installation_incomplete:"The previous hook installation did not finish.",helper_missing:"The installed hook helper is missing.",helper_unavailable:"The hook helper is unavailable on this server.",node_unavailable:"The Node executable for these hooks is unavailable.",hooks_disabled:"Hooks are disabled by provider configuration or policy.",approval_unknown:"Hook trust must be checked in Codex.",approval_required:"Codex reports NTerminal hooks that still need approval.",config_malformed:"The provider configuration could not be parsed.",manifest_malformed:"The hook installation metadata could not be parsed.",config_too_large:"The provider configuration exceeds the supported size.",config_changed:"The provider configuration changed during this operation.",installation_busy:"Another hook installation operation is in progress.",lock_identity_unavailable:"The installation lock owner could not be verified. No hook settings were changed.",lock_host_mismatch:"An installation lock belongs to another host or boot identity. It was left unchanged.",lock_host_unknown:"An existing installation lock has unknown host ownership. It was left unchanged.",unsafe_path:"The hook configuration path could not be safely accessed.",installation_unavailable:"Hook installation is unavailable on this server."}[e]??"Hook status could not be verified."}function zA(e){return{notify_foreign:"Your own Codex notify command was left unchanged; hooks work alongside it.",notify_profile_override:"A Codex profile sets its own notify command, which overrides the older NTerminal notify.",profile_hooks_disabled:"A Codex profile disables hooks; sessions using it will not send events.",managed_policy_unreadable:"A managed provider policy could not be read, so hooks may be restricted.",legacy_definitions:"Older NTerminal hook definitions are installed. Reinstall to update them."}[e]??e}function HA(e){const[t,n]=v.useState({api:e.api,provider:e.provider,revision:0});return t.api!==e.api||t.provider!==e.provider?(n({api:e.api,provider:e.provider,revision:t.revision+1}),null):u.jsx(UA,{...e},t.revision)}function UA({provider:e,serverLabel:t,api:n,onClose:r,onLoginStarted:o,onLoginFinished:l}){const[d,f]=v.useState(null),[g,p]=v.useState(!0),[b,_]=v.useState(null),[w,C]=v.useState(!1),[x,T]=v.useState(null),[A,M]=v.useState(""),[W,U]=v.useState(null),[P,F]=v.useState(!1),[V,O]=v.useState(null),[G,fe]=v.useState(!1),[ee,te]=v.useState(()=>Date.now()),[$,Z]=v.useState({}),[ie,J]=v.useState(!0),[j,R]=v.useState(!1),[I,re]=v.useState(!1),_e=v.useRef(null),N=v.useCallback(async(ue=!1)=>{const Re=_e.current;if(!Re?.active||Re.actionPending||ue&&Re.statusPending)return;const Oe=++Re.statusGeneration;Re.statusPending=!0,ue||(p(!0),T(null));try{const ge=await n.getAccounts();Re.active&&Oe===Re.statusGeneration&&f(ge)}catch(ge){Re.active&&Oe===Re.statusGeneration&&!ue&&T($g(ge))}finally{Re.active&&Oe===Re.statusGeneration&&(Re.statusPending=!1,ue||p(!1))}},[n]),Y=v.useCallback(async()=>{const ue=_e.current;if(!(!ue?.active||ue.actionPending)&&(ue.usageGeneration+=1,ue.usageQueued=!0,!ue.usagePending)){ue.usagePending=!0,J(!0);do{ue.usageQueued=!1;const Re=ue.usageGeneration;try{const Oe=await n.getAccountUsage(e);if(Oe.provider!==e)throw new Error("Unexpected account usage provider");ue.active&&Re===ue.usageGeneration&&(Z(Object.fromEntries(Oe.profiles.map(ge=>[ge.profileId,ge.usage]))),R(!1),re(!1),te(Date.now()))}catch{ue.active&&Re===ue.usageGeneration&&(R(!0),re(!0))}}while(ue.active&&ue.usageQueued&&!ue.actionPending);ue.usagePending=!1,ue.active&&J(!1)}},[n,e]),oe=v.useMemo(()=>d?.providers.find(ue=>ue.provider===e)??null,[e,d]);v.useEffect(()=>{const ue={active:!0,actionPending:!1,statusGeneration:0,statusPending:!1,usageGeneration:0,usagePending:!1,usageQueued:!1};return _e.current=ue,N(),Y(),()=>{ue.active=!1}},[N,Y]),v.useEffect(()=>{const ue=Re=>{Re.key==="Escape"&&!Re.defaultPrevented&&!b&&!w&&(P?F(!1):r())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[r,b,w,P]),v.useEffect(()=>{const ue=window.setInterval(()=>te(Date.now()),6e4);return()=>window.clearInterval(ue)},[]),v.useEffect(()=>{if(!oe?.pendingLogin||b)return;const Re=window.setInterval(()=>{N(!0)},1500);return()=>window.clearInterval(Re)},[b,oe?.pendingLogin,N]),v.useEffect(()=>{const ue=oe?.pendingLogin,Re=_e.current;Re?.active&&(!ue?.ready||!ue.terminalId||ue.terminalId===V||G||(fe(!0),l(ue.terminalId).then(()=>{Re.active&&O(ue.terminalId)}).catch(Oe=>{Re.active&&T($g(Oe))}).finally(()=>{Re.active&&fe(!1)})))},[V,G,l,oe?.pendingLogin]);async function Q(ue,Re){const Oe=_e.current;if(!(!Oe?.active||Oe.actionPending||w)){Oe.actionPending=!0,Oe.statusGeneration+=1,Oe.statusPending=!1,Oe.usageGeneration+=1,R(!0),p(!1),_(ue),T(null);try{const ge=await Re();Oe.active&&f(ge)}catch(ge){Oe.active&&T($g(ge))}finally{Oe.actionPending=!1,Oe.active&&(_(null),N(!0),Y())}}}async function we(ue=null){U(ue?.label??null),M(""),await Q("login",async()=>{const Re=_e.current,Oe=await n.beginAccountLogin(e);return Re?.active&&o(Oe.terminal),Re?.active?n.getAccounts():{providers:[]}})}const Se=e==="codex"?"Codex":"Claude";return u.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:ue=>{ue.target===ue.currentTarget&&!b&&!w&&r()},children:[u.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${Se} accounts on ${t}`,children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"account-dialog-title",children:[u.jsx(qA,{provider:e}),u.jsxs("div",{children:[u.jsxs("h2",{children:[Se," accounts"]}),u.jsx("p",{children:t})]})]}),u.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",title:"Close accounts",onClick:r,disabled:!!b||w,children:u.jsx(Yv,{size:16,"aria-hidden":"true"})})]}),u.jsxs("div",{className:"account-dialog-scroll",children:[g&&!oe?u.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,oe?u.jsx($A,{provider:e,status:oe,pendingAction:b??(w?"hooks":null),clock:ee,usage:$,usageLoading:ie,usageStale:j,label:A,onLabelChange:M,onSelect:ue=>{Q(`select:${ue}`,()=>n.selectAccount(e,ue))},onDelete:ue=>{Q(`delete:${ue}`,()=>n.removeAccount(e,ue))},onRefresh:ue=>{Q(`refresh:${ue}`,()=>n.refreshAccount(e,ue))},onBeginLogin:()=>{we()},onRelogin:ue=>{we(ue)},reloginFor:W,onCompleteLogin:()=>{Q("complete",()=>n.completeAccountLogin(e,A))},onCancelLogin:()=>{Q("cancel",()=>n.cancelAccountLogin(e))},onRequestTerminate:()=>F(!0),loginPaneClosed:!oe.pendingLogin?.terminalId||V===oe.pendingLogin.terminalId,loginPaneClosing:G}):null,I?u.jsx("p",{className:"account-dialog-muted account-usage-error",role:"status",children:"Usage could not be updated. Previous readings, if any, are stale."}):null,x?u.jsx("p",{className:"account-dialog-error",role:"alert",children:x}):null,u.jsx(AA,{provider:e,serverLabel:t,api:n,disabled:!!b||P,onBusyChange:C})]}),u.jsxs("footer",{className:"account-dialog-footer",children:[u.jsxs("button",{type:"button",title:"Reload account metadata and usage; does not refresh OAuth credentials",onClick:()=>{N(),Y()},disabled:g||!!b||w,children:[u.jsx(Dc,{size:14,"aria-hidden":"true"}),"Refresh"]}),u.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!b||w,children:"Close"})]})]}),P?u.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:ue=>{ue.target===ue.currentTarget&&!b&&F(!1)},children:u.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${Se} sessions`,children:[u.jsxs("h3",{children:["Exit all ",Se," sessions?"]}),u.jsxs("p",{children:["This stops detected ",Se," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),e==="codex"?u.jsx("p",{children:"The shared Codex daemon will also stop. All Codex work using that daemon is affected."}):null,u.jsxs("div",{children:[u.jsx("button",{type:"button",onClick:()=>F(!1),disabled:!!b,children:"Cancel"}),u.jsx("button",{type:"button",className:"danger-button",disabled:!!b,onClick:()=>{F(!1),Q("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function $A({provider:e,status:t,pendingAction:n,clock:r,usage:o,usageLoading:l,usageStale:d,label:f,onLabelChange:g,onSelect:p,onDelete:b,onRefresh:_,onBeginLogin:w,onRelogin:C,reloginFor:x,onCompleteLogin:T,onCancelLogin:A,onRequestTerminate:M,loginPaneClosed:W,loginPaneClosing:U}){const P=t.runningProcesses??[],F=t.runningPanes.length>0||P.length>0||t.processCheckUnavailable===!0,V=e==="codex"?"Codex":"Claude",O=F?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsxs("strong",{children:[V," is running. Changing accounts here does not stop these sessions; they keep their current account until restarted."]}),e==="codex"?u.jsx("small",{children:"New Codex sessions started through the shared background server may also use the previous account until that server restarts."}):null,t.runningPanes.map($=>u.jsxs("span",{children:[u.jsx("b",{children:$.title}),u.jsx("small",{children:$.cwd})]},$.terminalId)),P.map($=>u.jsxs("span",{children:[u.jsxs("b",{children:[$.command," ",u.jsxs("em",{children:["PID ",$.pid]})]}),u.jsx("small",{children:$.role==="daemon"?"Shared Codex daemon / manager":"Provider process on this server"})]},$.pid)),t.processCheckUnavailable?u.jsxs("span",{children:[u.jsx("b",{children:"Process check unavailable"}),u.jsx("small",{children:"Running sessions could not be listed. Refreshing the active account's credentials is paused until they can."})]}):null,t.processCheckUnavailable?null:u.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:M,children:["Exit all ",V," sessions"]})]}):null;if(t.pendingLogin)return u.jsxs(u.Fragment,{children:[O,u.jsxs("div",{className:"account-dialog-section",children:[x?u.jsxs("p",{className:"account-dialog-muted",children:["Signing in again to ",u.jsx("b",{children:x}),". Use the same account: its saved name is kept, and it becomes the active account when saved."]}):null,u.jsx("p",{children:t.pendingLogin.ready?U?"Sign-in completed. Closing the login terminal...":"Sign-in completed. Name this account to save it in the server vault.":"Complete sign-in in the login terminal. This dialog will continue automatically."}),t.pendingLogin.ready&&W?u.jsxs("label",{className:"account-dialog-label",children:["Account name",u.jsx("input",{value:f,onChange:$=>g($.target.value),placeholder:x?"Leave blank to keep the saved name":`${e==="codex"?"Codex":"Claude"} account`,maxLength:80,autoFocus:!0})]}):null,u.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready&&W?u.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:T,children:"Save account"}):null,u.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:A,children:"Cancel and restore previous"})]})]})]});const G=t.lastExternalSwitch??null,fe=G?t.profiles.find($=>$.id===G.fromProfileId&&$.id!==t.activeProfileId):void 0,ee=G?.toProfileId?t.profiles.find($=>$.id===G.toProfileId):void 0,te=fe?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsx("strong",{children:ee?`${V} on this server was switched to ${ee.label} outside NTerminal, for example by a running session that still used it.`:`The ${V} login on this server was removed outside NTerminal.`}),u.jsxs("span",{children:[fe.label," is still saved. Restart old ",V," sessions, then press Use on ",fe.label,"."]})]}):null;return u.jsxs(u.Fragment,{children:[O,te,u.jsxs("div",{className:"account-dialog-section",children:[u.jsxs("div",{className:"account-dialog-section-heading",children:[u.jsx("span",{children:"Saved accounts"}),u.jsxs("button",{type:"button",className:"primary-button",disabled:!!n,onClick:w,children:[u.jsx(mA,{size:14,"aria-hidden":"true"}),"Add account"]})]}),t.profiles.length===0?u.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map($=>{const Z=$.id===t.activeProfileId,ie=NA($,r);return u.jsxs("article",{className:`account-profile${Z?" account-profile--active":""}${ie?" account-profile--relogin":""}`,children:[u.jsxs("div",{children:[u.jsx("strong",{children:$.label}),u.jsxs("small",{title:YA($.expiresAt),children:[Z?"Active":"Saved"," · ",VA($.expiresAt,r)," · ",GA($.updatedAt,r)]}),u.jsx(KA,{refresh:$.refresh,clock:r}),ie?u.jsxs("div",{className:"account-relogin",role:"status","aria-label":`${$.label}: re-login required`,children:[u.jsx("span",{className:"account-relogin-badge",children:"Re-login required"}),u.jsx("span",{className:"account-relogin-reason",children:MA(ie)}),u.jsxs("button",{type:"button",className:"primary-button",title:`Sign in to ${$.label} again; its saved name is kept`,disabled:!!n,onClick:()=>C($),children:[u.jsx(fA,{size:14,"aria-hidden":"true"}),"Sign in again"]})]}):null]}),u.jsxs("div",{className:"account-profile-actions",children:[u.jsxs("button",{type:"button",title:`Use ${$.label}`,disabled:!!n||Z,onClick:()=>p($.id),children:[u.jsx(sA,{size:14,"aria-hidden":"true"}),"Use"]}),u.jsxs("button",{type:"button",title:Z&&F?t.processCheckUnavailable?"Credential refresh deferred: process check unavailable":"Managed by running CLI":"Refresh OAuth credentials (rotates tokens); does not reset usage limits",disabled:Z&&F||!!n,onClick:()=>_($.id),children:[u.jsx(uA,{size:14,"aria-hidden":"true"}),"Refresh credentials"]}),u.jsx("button",{type:"button",className:"danger-button account-icon-button","aria-label":`Remove ${$.label}`,title:`Remove ${$.label}`,disabled:!!n||Z,onClick:()=>b($.id),children:u.jsx(gA,{size:14,"aria-hidden":"true"})})]}),u.jsx(WA,{usage:o[$.id],loading:l,stale:d,clock:r})]},$.id)})]})]})}const FA=2*6e4;function WA({usage:e,loading:t,stale:n,clock:r}){const o=e?.status==="available"?e.windows.filter(g=>Number.isFinite(g.usedPercent)&&g.usedPercent>=0&&g.usedPercent<=100):[],l=e?Date.parse(e.checkedAt):NaN,d=!!e&&(n||!Number.isFinite(l)||r-l>=FA||o.some(g=>g.resetsAt&&Date.parse(g.resetsAt)<=r)),f=!e&&t?"Checking weekly usage...":e?.status==="reauth_required"?"Weekly usage unavailable: sign-in required":e?.status==="unsupported"?"Weekly usage not provided":e?.code==="usage_authentication_required"?"Weekly usage unavailable: access token not accepted":"Weekly usage unavailable";return u.jsxs("div",{className:"account-quota","aria-label":"Account usage","aria-busy":t,title:"Read-only usage check; does not rotate credentials",children:[o.some(g=>g.kind==="weekly")?null:u.jsx("span",{className:"account-quota-unavailable",children:f}),["weekly","session"].map(g=>{const p=o.find(_=>_.kind===g);if(!p)return null;const b=Math.round((100-p.usedPercent)*10)/10;return u.jsxs("div",{className:"account-quota-window",children:[u.jsxs("span",{children:[g==="weekly"?"Weekly":"Session"," ",u.jsxs("b",{className:b<=10?"account-quota-critical":b<=25?"account-quota-warning":void 0,children:[b,"% remaining"]})]}),u.jsx("small",{title:Hf(p.resetsAt),children:p.resetsAt&&Number.isFinite(Date.parse(p.resetsAt))?`Resets ${Zk(p.resetsAt,r)}`:"Reset time unavailable"})]},g)}),u.jsxs("small",{className:"account-quota-check",children:[e?u.jsxs(u.Fragment,{children:["Last checked ",u.jsx("time",{dateTime:e.checkedAt,children:Hf(e.checkedAt)})]}):"Not yet checked",d?u.jsx("span",{className:"account-quota-warning",children:"Stale"}):null,t&&e?u.jsx("span",{children:"Updating..."}):null]}),e?.code?u.jsx("small",{className:"account-diagnostic-code",children:e.code}):null]})}function KA({refresh:e,clock:t}){if(!e)return null;const n={success:"Credentials refreshed",retrying:"Credential refresh retrying",reauth_required:"Sign-in required",deferred:"Credential refresh deferred"},r=e.state==="deferred"&&e.code==="active_cli_refresh_deferred"?"Managed by running CLI":e.state==="deferred"&&e.code==="account_process_check_unavailable"?"Refresh deferred: process check unavailable":n[e.state];return u.jsxs("div",{className:`account-refresh-status account-refresh-status--${e.state}`,children:[u.jsxs("span",{children:[r,e.nextRetryAt?` · Next retry ${Zk(e.nextRetryAt,t)}`:""]}),e.lastAttemptAt?u.jsxs("small",{children:["Last attempt ",Hf(e.lastAttemptAt)]}):null,e.lastSuccessAt?u.jsxs("small",{children:["Last success ",Hf(e.lastSuccessAt)]}):null,e.code||e.httpStatus!==null?u.jsx("small",{className:"account-diagnostic-code",children:[e.code,e.httpStatus!==null?`HTTP ${e.httpStatus}`:null].filter(Boolean).join(" · ")}):null]})}function Hf(e){return e&&Number.isFinite(Date.parse(e))?new Date(e).toLocaleString():"Timestamp unavailable"}function Zk(e,t){const n=Date.parse(e)-t;if(!Number.isFinite(n))return"time unavailable";if(n<=0)return"due now";const r=Math.ceil(n/6e4),o=Math.floor(r/1440),l=Math.floor(r%1440/60);return`in ${o?`${o}d `:""}${l?`${l}h `:""}${o?"":`${r%60}m`}`.trim()}function qA({provider:e}){return u.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function VA(e,t=Date.now()){if(!e||!Number.isFinite(Date.parse(e)))return"Access token expiry unavailable";const n=Math.ceil((Date.parse(e)-t)/6e4);if(n<=0)return"Access token expired";const r=Math.floor(n/1440),o=Math.floor(n%1440/60),l=n%60;return`Access token ${[r?`${r}d`:null,o?`${o}h`:null,`${l}m`].filter(Boolean).join(" ")} remaining`}function YA(e){return!e||!Number.isFinite(Date.parse(e))?"Access token expiry timestamp unavailable":`Access token expires ${new Date(e).toLocaleString()}`}function GA(e,t=Date.now()){const n=Math.max(0,Math.floor((t-Date.parse(e))/6e4));return!Number.isFinite(n)||n>1440?"Updated earlier":n===0?"Updated now":n<60?`Updated ${n}m ago`:`Updated ${Math.floor(n/60)}h ago`}function $g(e){return e instanceof Un?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",codex_daemon_stop_failed:"Could not stop the shared Codex daemon. No account was switched. Stop the daemon and try again.",account_operation_busy:"Another account operation is in progress. Try again shortly.",account_process_check_unavailable:"Could not verify running CLI processes. Refreshing the active account is paused.",active_cli_refresh_deferred:"Credentials are managed by the running CLI. Refresh is deferred.",account_credential_changed:"Credentials changed during refresh. Refresh the account list before trying again.",account_login_already_pending:"Finish or cancel the current sign-in first.",account_login_not_complete:"The provider login has not finished yet.",account_refresh_failed:"The credential refresh failed. Check the account refresh status for details.",account_refresh_unavailable:"The provider refresh endpoint is temporarily unavailable.",account_reauth_required:"The account needs a new sign-in. Add the account again to update its credentials.",preview_mode:"Account changes are disabled in preview mode."}[e.message]??"The account operation could not be completed.":"The account operation could not be completed."}function XA(e){const t=new Map(e.map(l=>[l.pid,{process:l,children:[],count:1,cpuPercent:l.cpuPercent,memoryBytes:l.memoryBytes}])),n=[];for(const l of t.values()){const d=t.get(l.process.ppid);d&&d!==l?d.children.push(l):n.push(l)}const r=[...n],o=new Set;for(let l=0;l<r.length;l++){const d=r[l];o.add(d.process.pid);for(const f of d.children)r.push(f)}for(const l of t.values())o.has(l.process.pid)||(l.children=[],n.push(l));for(let l=r.length-1;l>=0;l--){const d=r[l];for(const f of d.children)d.count+=f.count,d.cpuPercent+=f.cpuPercent,d.memoryBytes+=f.memoryBytes}return n}const Zv=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function ZA({api:e,label:t,main:n,favorites:r,targets:o,onClose:l,onFavorite:d,onTarget:f,getRuntimeStatus:g,targetStatus:p}){const[b,_]=v.useState(null),[w,C]=v.useState(null),[x,T]=v.useState(!0),[A,M]=v.useState(!0),[W,U]=v.useState(null),[P,F]=v.useState(!1),[V,O]=v.useState(null),[G,fe]=v.useState(""),[ee,te]=v.useState(!1),[$,Z]=v.useState(null),ie=v.useRef(null),J=v.useRef(l);J.current=l;const j=v.useRef(!0);async function R(Q=!1){T(!0);try{const we=await e.getServerExternalIp(Q);j.current&&_(we)}catch{j.current&&_(we=>({address:we?.address??null,checkedAt:we?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{j.current&&T(!1)}}async function I(){M(!0),U(null);try{const Q=await e.getServerProcesses();j.current&&C(Q)}catch{j.current&&U("Could not retrieve processes. The server may be offline or need an update.")}finally{j.current&&M(!1)}}v.useEffect(()=>(j.current=!0,R(),I(),()=>{j.current=!1}),[e]),v.useEffect(()=>{const Q=document.activeElement;ie.current?.focus();const we=Se=>{if(Se.key==="Escape"){Se.preventDefault(),Se.stopImmediatePropagation(),J.current();return}if(Se.key==="Tab"){const ue=[...ie.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(Oe=>Oe.getClientRects().length>0),Re=ue.indexOf(document.activeElement);ue.length&&(Re<0||(Se.shiftKey?Re===0:Re===ue.length-1))&&(Se.preventDefault(),ue[Se.shiftKey?ue.length-1:0]?.focus()),Se.stopPropagation();return}ie.current?.contains(Se.target)||(Se.preventDefault(),Se.stopImmediatePropagation())};return window.addEventListener("keydown",we,!0),()=>{window.removeEventListener("keydown",we,!0),Q instanceof HTMLButtonElement&&Q.isConnected&&Q.focus({preventScroll:!0})}},[]);async function re(Q){try{await navigator.clipboard.writeText(Q),F(!1)}catch{F(!0)}}async function _e(Q){if(!(ee||!G.trim())){te(!0),Z(null);try{const we=await e.renameServerProject(Q,G.trim());if(!j.current)return;C(Se=>Se&&{...Se,projects:Se.projects.map(ue=>ue.path===Q?{...ue,name:we.name}:ue)}),O(null)}catch{j.current&&Z("Could not save project name.")}finally{j.current&&te(!1)}}}const N=v.useMemo(()=>w?.projects.filter(Q=>Q.category!=="services")??[],[w]),Y=v.useMemo(()=>{const Q=w?.projects.filter(we=>we.category==="services")??[];return N.length?[...Q,{name:"Development tools",path:"",category:"tools",cpuPercent:N.reduce((we,Se)=>we+Se.cpuPercent,0),memoryBytes:N.reduce((we,Se)=>we+Se.memoryBytes,0),processes:N.flatMap(we=>we.processes)}]:Q},[w,N]);function oe(Q){const we=Q.path?o.filter(Se=>Se.cwd===Q.path||Se.cwd.startsWith(Q.path.replace(/\/$/,"")+"/")):[];return u.jsxs(u.Fragment,{children:[Q.category!=="services"&&u.jsxs("div",{className:"server-info-tool-name",children:[u.jsx(lA,{size:15,"aria-hidden":"true"}),u.jsx("strong",{children:Q.path?Q.name:"Shared tools"})]}),u.jsxs("div",{className:"server-info-path",children:[u.jsx("code",{children:Q.path||"Shared across projects"}),Q.path&&u.jsxs(u.Fragment,{children:[u.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{re(Q.path)},children:u.jsx(w1,{size:14})}),u.jsx("button",{disabled:A||ee,title:"Rename project","aria-label":`Rename ${Q.name}`,onClick:()=>{O(`${Q.category}:${Q.path}`),fe(Q.name),Z(null)},children:u.jsx(pA,{size:14})})]})]}),V===`${Q.category}:${Q.path}`&&u.jsxs("form",{className:"server-info-rename",onSubmit:Se=>{Se.preventDefault(),_e(Q.path)},children:[u.jsx("input",{"aria-label":"Project display name",maxLength:80,value:G,disabled:ee,onChange:Se=>fe(Se.target.value)}),u.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:ee||!G.trim(),children:u.jsx(Nk,{size:16})}),u.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:ee,onClick:()=>O(null),children:u.jsx(Yv,{size:16})}),$&&u.jsx("small",{role:"alert",className:"server-info-error",children:$})]}),Q.path&&u.jsx("div",{className:"server-info-targets",children:we.length?we.map(Se=>u.jsxs("button",{onClick:()=>f(Se),title:`Open ${Se.label}`,children:[u.jsx(rA,{size:14}),Se.label]},Se.terminalId)):u.jsx("button",{disabled:!0,children:p??"No open tab"})}),u.jsx(QA,{processes:Q.processes})]})}return u.jsx("div",{className:"server-info-backdrop",onMouseDown:Q=>{Q.target===Q.currentTarget&&l()},children:u.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:ie,onKeyDown:Q=>Q.stopPropagation(),children:[u.jsxs("header",{children:[u.jsxs("div",{children:[u.jsx("h2",{children:t}),u.jsx("small",{children:n?"Main":"Secondary"})]}),u.jsx("button",{title:"Close","aria-label":"Close server information",onClick:l,children:u.jsx(Yv,{size:18})})]}),u.jsxs("div",{className:"server-info-body",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"server-info-ip",children:[u.jsx("h3",{title:"External IPv4",children:"IPv4"}),u.jsx("code",{title:b?.checkedAt?`Checked ${new Date(b.checkedAt).toLocaleString()}`:void 0,children:b?.address??(x?"Loading...":"Unavailable")}),u.jsxs("span",{className:"server-info-ip-actions",children:[b?.address&&u.jsx("button",{title:"Copy IPv4","aria-label":"Copy IPv4",onClick:()=>{re(b.address)},children:u.jsx(w1,{size:16})}),u.jsx("button",{disabled:x,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{R(!0)},children:u.jsx(Dc,{size:16})})]})]}),b?.error&&u.jsx("p",{role:"status",className:"server-info-error",children:b.error})]}),u.jsxs("section",{children:[u.jsx("h3",{children:"Favorites"}),u.jsx("div",{className:"server-info-favorites",children:r.map(Q=>u.jsxs("button",{onClick:()=>d(Q),children:[u.jsx("strong",{children:Q.tabName}),u.jsxs("small",{children:[Q.workspaceName," · ",g?.(Q)?.state??"Not loaded"]}),u.jsx("span",{children:Q.providers.map(we=>u.jsx("img",{alt:we,src:`/brand/${we}.webp`},we))})]},`${Q.workspaceId}:${Q.tabId}`))}),!r.length&&u.jsx("small",{children:"No favorite tabs on this server."})]}),u.jsxs("section",{children:[u.jsxs("div",{className:"server-info-heading",children:[u.jsx("h3",{children:"Projects"}),u.jsx("button",{disabled:A||ee,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{I()},children:u.jsx(Dc,{size:16})})]}),A&&u.jsx("p",{role:"status",children:"Sampling processes..."}),W&&u.jsx("p",{role:"alert",className:"server-info-error",children:W}),w&&u.jsxs("small",{children:["Sampled ",new Date(w.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),Y.map(Q=>u.jsxs(Jk,{className:"server-info-project",children:[u.jsxs("summary",{children:[u.jsxs("span",{className:"server-info-project-label",children:[u.jsx(Lk,{className:"server-info-chevron",size:16,"aria-hidden":"true"}),u.jsx("strong",{title:Q.name,children:Q.name}),u.jsx("small",{className:"server-info-project-location",title:Q.path,children:Q.path}),u.jsx("small",{className:"server-info-project-count",title:`${Q.processes.length} processes`,children:Q.processes.length})]}),u.jsxs("span",{className:"server-info-metrics",children:[u.jsxs("span",{children:[Q.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:Zv(Q.memoryBytes)})]})]}),u.jsx("div",{className:"server-info-project-body",children:Q.category==="services"?oe(Q):N.map(we=>u.jsx("div",{className:"server-info-tool-project",children:oe(we)},`${we.category}:${we.path}`))})]},`${Q.category}:${Q.path}`)),w&&!w.projects.length&&u.jsx("p",{children:"No processes found for the runtime user."})]}),P&&u.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function QA({processes:e}){const t=v.useMemo(()=>XA(e),[e]);return u.jsx("div",{className:"server-info-process-list",children:t.map(n=>u.jsx("div",{className:"server-info-process-root",children:u.jsx(Qk,{node:n})},n.process.pid))})}function Qk({node:e}){const t=e.process,n=u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"server-info-process-label",children:[e.children.length?u.jsx(Lk,{className:"server-info-chevron",size:14,"aria-hidden":"true"}):u.jsx("span",{className:"server-info-process-dot","aria-hidden":"true"}),u.jsxs("span",{children:[u.jsx("strong",{children:t.name}),u.jsxs("small",{children:["PID ",t.pid," · ",t.manager??"Unmanaged",e.count>1?` · ${e.count} processes · Total`:""]})]})]}),u.jsxs("span",{className:"server-info-metrics",title:e.count>1?"Total for this process and its descendants":"Process usage",children:[u.jsxs("span",{children:[e.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:Zv(e.memoryBytes)})]})]});return e.children.length?u.jsxs(Jk,{className:"server-info-process-group",children:[u.jsx("summary",{className:"server-info-process",children:n}),u.jsxs("div",{className:"server-info-process-children",children:[u.jsxs("div",{className:"server-info-process",children:[u.jsxs("span",{children:[u.jsx("strong",{children:t.name}),u.jsxs("small",{children:["PID ",t.pid," · Parent"]})]}),u.jsxs("span",{className:"server-info-metrics",children:[u.jsxs("span",{children:[t.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:Zv(t.memoryBytes)})]})]}),e.children.map(r=>u.jsx(Qk,{node:r},r.process.pid))]})]}):u.jsx("div",{className:"server-info-process",children:n})}function Jk({children:e,className:t}){const[n,r]=v.useState(!1),[o,...l]=zt.Children.toArray(e);return u.jsxs("details",{className:t,onToggle:d=>{d.target===d.currentTarget&&r(d.currentTarget.open)},children:[o,n?l:null]})}function JA({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[l,d]=v.useState(!1),[f,g]=v.useState(null),[p,b]=v.useState(""),[_,w]=v.useState("");async function C(){try{const[M,W,U]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(M.devices),o(W.networks),d(U.totpEnabled),g(null)}catch(M){g(M instanceof Error?M.message:"Failed to load")}}v.useEffect(()=>{C()},[]);async function x(M){await e.revokeDevice(M),await C()}async function T(M){await e.removeNetwork(M),await C()}async function A(M){M.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:_.trim()}),b(""),w(""),await C()}catch(W){g(W instanceof Error?W.message:"Failed to add network")}}return u.jsxs(u.Fragment,{children:[f?u.jsx("p",{className:"form-error",children:f}):null,u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Trusted devices"}),u.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?u.jsx("p",{className:"muted",children:"No trusted devices."}):u.jsx("ul",{className:"security-list",children:t.map(M=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsxs("span",{className:"security-item-label",children:[M.label,M.current?u.jsx("span",{className:"security-badge",children:"this device"}):null]}),u.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(M.lastSeenAt).toLocaleString()]})]}),u.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(M.id)},children:"revoke"})]},M.id))})]}),u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Trusted networks"}),u.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?u.jsx("p",{className:"muted",children:"No trusted networks."}):u.jsx("ul",{className:"security-list",children:r.map(M=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("span",{className:"security-item-label",children:M.value}),M.label!==M.value?u.jsx("span",{className:"security-item-meta",children:M.label}):null]}),u.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(M.id)},children:"remove"})]},M.id))}),u.jsxs("form",{className:"security-add-form",onSubmit:A,children:[u.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:M=>b(M.currentTarget.value),required:!0}),u.jsx("input",{type:"text",placeholder:"Label (optional)",value:_,onChange:M=>w(M.currentTarget.value)}),u.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),l?u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Two-factor authentication"}),u.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."}),u.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await C()},children:"Disable 2FA"})]}):null]})}const eL=1500,ny="nterminal.terminal.fontSize",iy="nterminal.terminal.fontFamily",Qv="nterminal:terminal-font-size",Jv="nterminal:terminal-font-family",e_=11,t_=20,cl=14,Uf=[{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:[]}],Nc="meslo";n_(Nc);async function Fg(e=cl,t=Nc){if(typeof document>"u"||!document.fonts)return;const n=nT(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,eL)})])}function eT(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return cl;const n=Math.round(t);return Math.max(e_,Math.min(t_,n))}function tT(e){return Uf.some(t=>t.id===e)?e:Nc}function n_(e){return nT(e).cssFamily}function nT(e){return Uf.find(t=>t.id===e)??Uf[0]}function i_(){if(typeof window>"u")return cl;try{const e=window.localStorage.getItem(ny);return e?eT(e):cl}catch{return cl}}function s_(){if(typeof window>"u")return Nc;try{return tT(window.localStorage.getItem(iy))}catch{return Nc}}function Yh(e){const t=eT(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ny,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Qv,{detail:t})),t}function tL(e){const t=tT(e);if(typeof window>"u")return t;try{window.localStorage.setItem(iy,t)}catch{}return window.dispatchEvent(new CustomEvent(Jv,{detail:t})),t}function iT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ny&&e()};return window.addEventListener(Qv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qv,e),window.removeEventListener("storage",t)}}function sT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===iy&&e()};return window.addEventListener(Jv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Jv,e),window.removeEventListener("storage",t)}}const sy="nterminal.terminal.showScrollProgress",r_="nterminal:terminal-scroll-progress",ry="nterminal.terminal.tmuxScrollback.shell",ay="nterminal.terminal.tmuxScrollback.agent",oy="nterminal.terminal.tmuxScrollback.overrides",hd="nterminal:terminal-tmux-scrollback",nL=200;function a_(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(sy)!=="false"}catch{return!0}}function iL(e){if(typeof window<"u"){try{window.localStorage.setItem(sy,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(r_,{detail:e}))}return e}function rT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===sy&&e()};return window.addEventListener(r_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(r_,e),window.removeEventListener("storage",t)}}function o_(){return aT(ry,!0)}function sL(e){return oT(ry,e,hd)}function l_(){return aT(ay,!0)}function rL(e){return oT(ay,e,hd)}function mf(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===ry||n.key===ay||n.key===oy)&&e()};return window.addEventListener(hd,e),window.addEventListener("storage",t),()=>{window.removeEventListener(hd,e),window.removeEventListener("storage",t)}}function Wg(e){const n=lT()[e];return typeof n=="boolean"?n:null}function aL(e,t){if(typeof window<"u"){try{const n=lT(),r=Object.entries(n).filter(([l])=>l!==e);r.push([e,t]);const o=r.slice(-nL);window.localStorage.setItem(oy,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(hd,{detail:{terminalId:e,enabled:t}}))}return t}function aT(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function oT(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function lT(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(oy);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const ly="nterminal.shortcuts.workspace.v1",c_="nterminal:workspace-shortcuts",fd=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"subagents.toggle",label:"Toggle view agents",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0},{id:"favorites.toggle",label:"Open favorite tabs",group:"Tabs",requiresPrimaryModifier:!0}],Cp={"server.previous":bn("ArrowUp",{ctrlKey:!0}),"server.next":bn("ArrowDown",{ctrlKey:!0}),"tab.previous":bn("ArrowLeft",{ctrlKey:!0}),"tab.next":bn("ArrowRight",{ctrlKey:!0}),"tab.index":bn("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":bn("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":bn("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":bn("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":bn("KeyH",{altKey:!0}),"subagents.toggle":bn("KeyA",{altKey:!0}),"scrollback.toggle":bn("KeyS",{altKey:!0}),"favorites.toggle":bn("KeyF",{ctrlKey:!0,altKey:!0})},oL={"server.previous":bn("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":bn("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":bn("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":bn("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":bn("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":bn("Digit",{ctrlKey:!0,altKey:!0}),"split.right":bn("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":bn("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":bn("KeyH",{altKey:!0}),"subagents.toggle":bn("KeyA",{altKey:!0}),"scrollback.toggle":bn("KeyS",{altKey:!0}),"favorites.toggle":bn("KeyF",{ctrlKey:!0,altKey:!0})};function pl(){const e=dT(Cp);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(ly);if(!t)return e;const n=JSON.parse(t);for(const r of fd){const o=n[r.id];if(mL(o)){const l=hT(o,r);pL(l,oL[r.id])||(e[r.id]=l)}}}catch{return e}return e}function A1(){return JSON.stringify(pl())}function lL(e,t){const n=pl(),r=fd.find(o=>o.id===e);return r&&(n[e]=hT(t,r),cy(n)),n}function cL(e){const t=pl();return t[e]={...Cp[e]},cy(t),t}function uL(){const e=dT(Cp);return cy(e),e}function nd(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ly&&e()};return window.addEventListener(c_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(c_,e),window.removeEventListener("storage",t)}}function dL(e,t){const n=mT(e);return!n||vL(n)||t.indexed&&pT(e)===null||t.requiresPrimaryModifier&&!fT(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function cT(e){const t=pl();for(const n of fd){const r=t[n.id];if(!(!r||!gL(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=pT(e);if(o!==null)return{id:n.id,index:o};continue}if(mT(e)===r.code)return{id:n.id,index:null}}}return null}function id(e){return uT(pl()[e])}function uT(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(_L(e.code)),t.join("+")}const hL=()=>id("split.right"),fL=()=>id("split.down");function bn(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function dT(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function pL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function cy(e){if(!(typeof window>"u")){try{window.localStorage.setItem(ly,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(c_))}}function hT(e,t){return t.requiresPrimaryModifier&&!fT(e)?{...Cp[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function fT(e){return e.ctrlKey||e.altKey||e.metaKey}function mL(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 gL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function pT(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 mT(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 vL(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function _L(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const bL="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 yL(e="nterminal",t=new Date){return{reason:"permission",message:bL,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function SL(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 gT=3600*1e3,wL="local",u_=new Set,oo=new Map;let go={checking:!1,hasUpdates:!1,lastCheckedAt:null},uy=null,sd=null,$f=0,to=null;function xL(e){return u_.add(e),()=>{u_.delete(e)}}function L1(){return go}function CL(e){const t=DL();uy=e,dy(),d_(e,t);const n=()=>{if(document.visibilityState!=="visible"||!vo(e,t))return;const r=go.lastCheckedAt;(r===null||Date.now()-r>=gT)&&d_(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),vo(e,t)&&RL()}}function kL(e,t){oo.set(e,vT(t)),Mc({...go,hasUpdates:hy(),lastCheckedAt:Date.now()})}function Kg(e){e===void 0?oo.clear():oo.set(e,!1),Mc({...go,hasUpdates:hy()})}async function d_(e,t){if(!vo(e,t))return;if(to&&to.api===e&&to.runId===t)return to.promise;Mc({...go,checking:!0});const n=TL(e,t).finally(()=>{to?.promise===n&&(to=null),vo(e,t)&&(Mc({...go,checking:!1,lastCheckedAt:Date.now()}),EL(e,t))});return to={api:e,runId:t,promise:n},n}async function TL(e,t){try{const n=await e.listAgents();if(!vo(e,t))return;const r=[{key:wL,check:()=>e.checkUpdate()},...n.agents.map(l=>({key:l.id,check:()=>e.checkAgentUpdate(l.id)}))],o=new Map;if(await Promise.all(r.map(async l=>{try{const d=await l.check();o.set(l.key,vT(d))}catch{o.set(l.key,oo.get(l.key)??!1)}})),!vo(e,t))return;oo.clear();for(const[l,d]of o)oo.set(l,d);Mc({...go,hasUpdates:hy()})}catch{}}function EL(e,t){vo(e,t)&&(dy(),sd=window.setTimeout(()=>{sd=null,vo(e,t)&&d_(e,t)},gT))}function RL(){$f+=1,dy(),uy=null,to=null,oo.clear(),Mc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function dy(){sd!==null&&(window.clearTimeout(sd),sd=null)}function DL(){return $f+=1,$f}function vo(e,t){return uy===e&&$f===t}function vT(e){return e.updateAvailable===!0}function hy(){return Array.from(oo.values()).some(Boolean)}function Mc(e){go=e;for(const t of Array.from(u_))t()}const NL=e=>new Promise(t=>setTimeout(t,e));function ML({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,l]=v.useState({}),[d,f]=v.useState(!1),[g,p]=v.useState(null),[b,_]=v.useState(!1),[w,C]=v.useState({});function x(R,I){l(re=>({...re,[R]:{...re[R],...I}}))}function T(R,I){C(re=>({...re,[R]:{status:re[R]?.status??null,busy:re[R]?.busy??!1,error:re[R]?.error??null,...I}}))}const A=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),M=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),W=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),U=R=>R.id===null?e:Zs(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async I=>{if(R)return;let re="Local";try{re=(await e.getMainInfo()).name?.trim()||re}catch{}if(R)return;const _e=new Map(I.agents.map(Y=>[Y.id,Y])),N=ra(I.serverOrder,I.agents).flatMap(Y=>{if(Y===Vt)return[{key:"local",id:null,name:re}];const oe=_e.get(Y);return oe?[{key:oe.id,id:oe.id,name:oe.name}]:[]});r(N);for(const Y of N)A(Y).then(oe=>x(Y.key,{version:oe,manualUpdate:oe.manualUpdate??null})).catch(oe=>x(Y.key,{error:oe instanceof Error?oe.message:"unreachable"})),ie(Y)}).catch(()=>{}),()=>{R=!0}},[]);async function P(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const I=await M(R);kL(R.key,I),x(R.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:te(I),...I.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(I){x(R.key,{busy:!1,error:I instanceof Error?I.message:"check failed"})}}async function F(){f(!0),await Promise.all(n.map(R=>P(R))),f(!1)}async function V(R,I){const re=Date.now()+18e4;for(;Date.now()<re;){await NL(3e3);try{const _e=await A(R);if(I&&_e.runningVersion!==I.runningVersion)return _e}catch{}}return null}async function O(R){let I=o[R.key]?.version;if(!I)try{I=await A(R),x(R.key,{version:I,manualUpdate:I.manualUpdate??null})}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let re;try{re=await W(R)}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!re.ok){const N=re.manualUpdate??(SL(re.message)?yL():null);return N?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(x(R.key,{busy:!1,status:void 0,error:re.message}),"failed")}if(!re.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Kg(R.key),"unchanged";x(R.key,{status:"restarting…"});const _e=await V(R,I);return _e?(x(R.key,{busy:!1,version:_e,updateAvailable:!1,status:"updated",manualUpdate:_e.manualUpdate??null}),Kg(R.key),R.id===null&&(_(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(x(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function G(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const re=await e.uninstallAgent(R.id);r(_e=>_e.filter(N=>N.key!==R.key)),l(_e=>{const N={..._e};return delete N[R.key],N}),Kg(R.key),t?.(R.id),p(re.message)}catch(re){x(R.key,{busy:!1,status:void 0,error:re instanceof Error?re.message:"delete failed"})}}}async function fe(){f(!0),p(null);const R=n.filter(oe=>oe.id!==null),I=n.find(oe=>oe.id===null),re=await Promise.all(R.map(oe=>O(oe))),_e=re.filter(oe=>oe==="failed").length;let N=re.filter(oe=>oe==="manual").length,Y=null;if(I&&(Y=await O(I),Y==="manual"&&(N+=1),Y==="updated")){_e>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),f(!1);return}_e>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):_e>0?p("Some secondary servers failed to update. Check their rows and retry."):N>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function ee(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function te(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function $(R){const I=R?.version;return I?`npm package v${I.runningVersion}`:""}async function Z(R,I){try{await LL(I),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(re){x(R,{error:re instanceof Error?re.message:"copy failed"})}}async function ie(R,I=!1){try{const re=await U(R).getCodeServerStatus(I?{checkLatest:!0}:void 0);T(R.key,{status:re,error:null})}catch(re){T(R.key,{error:re instanceof Error?re.message:"code-server status failed"})}}async function J(R,I){if(I==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const re=U(R);T(R.key,{busy:!0,error:null});try{if(I==="install"){const _e=await re.installCodeServer();T(R.key,{status:_e.status})}else if(I==="update"){const _e=await re.updateCodeServer();T(R.key,{status:_e.status})}else{const _e=await re.uninstallCodeServer();T(R.key,{status:_e.status})}}catch(_e){T(R.key,{error:_e instanceof Error?_e.message:"code-server action failed"})}finally{T(R.key,{busy:!1})}}const j=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(re=>w[re.key]?.status?.job?.status==="running");if(R.length===0)return;const I=window.setInterval(()=>{for(const re of R)ie(re)},1e3);return()=>window.clearInterval(I)},[j]),u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Servers"}),u.jsxs("div",{className:"update-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{F()},disabled:d,children:"Check for updates"}),u.jsx("button",{type:"button",onClick:()=>{fe()},disabled:d,children:"Update all"})]}),g?u.jsx("p",{className:"settings-status",children:g}):null,b?u.jsxs("div",{className:"server-reload-required",role:"status",children:[u.jsx("span",{children:"Main server update is ready."}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,u.jsx("ul",{className:"security-list",children:n.map(R=>{const I=o[R.key],re=$(I),_e=I?.manualUpdate??null,N=w[R.key]??{status:null,busy:!1,error:null},Y=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!d,oe=R.id!==null&&!I?.busy&&!d;return u.jsxs("li",{children:[u.jsxs("div",{className:"server-row-main",children:[u.jsxs("div",{children:[u.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?u.jsx("span",{className:"security-badge",children:"Main"}):null]}),u.jsxs("span",{className:"security-item-meta",children:[re?`${re} — `:"",ee(I)]})]}),_e?u.jsxs("div",{className:"server-manual-update",children:[u.jsx("span",{children:_e.message}),u.jsxs("div",{className:"server-manual-command",children:[u.jsx("code",{children:_e.command}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Z(R.key,_e.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null,u.jsx(AL,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{ie(R,!0)},onInstall:()=>{J(R,"install")},onUpdate:()=>{J(R,"update")},onUninstall:()=>{J(R,"uninstall")}})]}),u.jsxs("div",{className:"server-row-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{O(R)},disabled:!Y,children:I?.busy?"…":"Update"}),R.id!==null?u.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{G(R)},disabled:!oe,children:"Delete"}):null]})]},R.key)})})]})}function AL({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:l,onUninstall:d}){const f=e?.job??null,g=f?.status==="running",p=e!==null,b=e?.installed===!0,_=e?.supported!==!1,w=e===null&&!n;return u.jsxs("div",{className:"server-code-addon-inline",children:[u.jsxs("div",{className:"server-code-addon-summary",children:[u.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),u.jsxs("span",{className:"security-item-meta",children:[_?w?"checking...":b?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?u.jsx("p",{className:"settings-error",children:n}):null,f?u.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,u.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[u.jsx("a",{className:"server-code-addon-icon-button",href:"https://github.com/coder/code-server",target:"_blank",rel:"noreferrer",title:"Open code-server on GitHub","aria-label":"Open code-server on GitHub",children:"↗"}),b?u.jsxs(u.Fragment,{children:[e?.updateAvailable?u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:l,disabled:t||g||!_,title:"Update code-server","aria-label":"Update code-server",children:"↑"}):u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:r,disabled:t||g||!_,title:"Check code-server updates","aria-label":"Check code-server updates",children:"↻"}),u.jsx("button",{type:"button",className:"server-code-addon-icon-button server-code-addon-icon-button--delete",onClick:d,disabled:t||g,title:"Uninstall code-server","aria-label":"Uninstall code-server",children:"×"})]}):u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:o,disabled:!p||w||t||g||!_,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function LL(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 Gh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function jL({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const l=v.useMemo(()=>t??up(),[t]),[d,f]=v.useState(()=>i_()),[g,p]=v.useState(()=>s_()),[b,_]=v.useState(()=>a_()),[w,C]=v.useState(()=>o_()),[x,T]=v.useState(()=>l_()),[A,M]=v.useState(()=>po()),[W,U]=v.useState(()=>pl()),[P,F]=v.useState(null),[V,O]=v.useState(null),[G,fe]=v.useState("appearance"),[ee,te]=v.useState(()=>Jb()),[$,Z]=v.useState(()=>fl()),[ie,J]=v.useState(()=>Pc()),[j,R]=v.useState([]),[I,re]=v.useState([]),[_e,N]=v.useState([]),[Y,oe]=v.useState(5*1024*1024),[Q,we]=v.useState(!1),[Se,ue]=v.useState(null),[Re,Oe]=v.useState(null),[ge,He]=v.useState(!1),[Be,L]=v.useState(null),[ve,Le]=v.useState(null),Pe=v.useRef(null),H=v.useRef(null),de=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),Te=v.useMemo(()=>new Set(I),[I]),Me=!BL(I,_e),je=v.useMemo(()=>xp(),[]),be=Re?.displayMode==="standalone"&&(Re.deviceKind==="mobile"||Re.deviceKind==="tablet");v.useEffect(()=>iT(()=>f(i_())),[]),v.useEffect(()=>sT(()=>p(s_())),[]),v.useEffect(()=>rT(()=>_(a_())),[]),v.useEffect(()=>mf(()=>{C(o_()),T(l_())}),[]),v.useEffect(()=>Pb(()=>M(po())),[]),v.useEffect(()=>nd(()=>U(pl())),[]),v.useEffect(()=>_k(()=>Z(fl())),[]),v.useEffect(()=>{if(!P)return;const pe=fd.find(at=>at.id===P);if(!pe)return;const Ze=at=>{if(at.preventDefault(),at.stopPropagation(),at.key==="Escape"){F(null),O(null);return}const mt=dL(at,pe);if(!mt){O(OL(pe));return}U(lL(P,mt)),F(null),O(null)};return window.addEventListener("keydown",Ze,!0),()=>window.removeEventListener("keydown",Ze,!0)},[P]),v.useEffect(()=>{let pe=!1;return l.listNotificationAssets().then(Ze=>{pe||Nt(Ze)}).catch(Ze=>{pe||ue(uc(Ze))}),()=>{pe=!0}},[l]),v.useEffect(()=>{let pe=!1;return l.getPushNotificationStatus(oa()).then(Ze=>{pe||(Oe(Ze.currentDevice),L(null))}).catch(Ze=>{pe||L(uc(Ze))}),()=>{pe=!0}},[l]);function Fe(pe){f(Yh(Number(pe)))}function We(pe){Z(b1(Number(pe)))}function Ue(pe){fe(pe);const Ze=H.current,at=de.current[pe];if(!Ze||!at)return;const mt=Math.max(0,j1(at,Ze)-12);typeof Ze.scrollTo=="function"?Ze.scrollTo({top:mt,behavior:"smooth"}):Ze.scrollTop=mt}function ut(){const pe=H.current;if(!pe)return;if(pe.scrollTop+pe.clientHeight>=pe.scrollHeight-2){fe(Gh[Gh.length-1].id);return}let Ze="appearance";const at=pe.scrollTop+Math.min(180,Math.max(48,pe.clientHeight*.28));for(const mt of Gh){const St=de.current[mt.id];St&&j1(St,pe)<=at&&(Ze=mt.id)}fe(Ze)}function _t(pe){U(cL(pe)),F(null),O(null)}function lt(){U(uL()),F(null),O(null)}function Nt(pe){const Ze=pe.assets.filter(at=>at.enabled).map(at=>at.id);R(pe.assets),re(Ze),N(Ze),oe(pe.maxFileBytes),ue(null)}async function Yt(){if(ee){_1(!1),te(!1);return}let pe=ie;pe==="default"&&(pe=await yk(),J(pe)),pe==="granted"&&(_1(!0),te(!0))}async function st(){He(!0),L(null),Le(null);try{if(Re)await zM(l),Oe(null);else{await BM(l,!1);const pe=await l.getPushNotificationStatus(oa());Oe(pe.currentDevice)}}catch(pe){L(Vg(pe))}finally{He(!1)}}async function On(pe){He(!0),L(null),Le(null);try{await HM(l,pe);const Ze=await l.getPushNotificationStatus(oa());Oe(Ze.currentDevice)}catch(Ze){L(Vg(Ze))}finally{He(!1)}}async function Sn(){He(!0),L(null),Le(null);try{await l.testPushNotification({clientId:oa()}),Le("Test notification accepted by the push service.")}catch(pe){L(Vg(pe))}finally{He(!1)}}async function dt(pe){const Ze=pe?.[0];if(Ze){if(Ze.size>Y){ue(`File must be ${qg(Y)} or smaller.`),Ct();return}if(Ze.type!=="video/mp4"&&Ze.type!=="video/webm"){ue("Upload an MP4 or WebM video."),Ct();return}we(!0),ue(null);try{await l.uploadNotificationAsset(Ze),Nt(await l.listNotificationAssets()),r?.()}catch(at){ue(uc(at))}finally{we(!1),Ct()}}}async function Lt(pe){we(!0),ue(null);try{await l.deleteNotificationAsset(pe),Nt(await l.listNotificationAssets()),r?.()}catch(Ze){ue(uc(Ze))}finally{we(!1)}}function Ct(){Pe.current&&(Pe.current.value="")}function gi(pe,Ze){const at=new Set(I);if(Ze?at.add(pe):at.delete(pe),at.size===0){ue("Keep at least one toast video selected.");return}ue(null),re(Array.from(at))}async function ki(){if(I.length===0){ue("Keep at least one toast video selected.");return}we(!0),ue(null);try{const pe=await l.updateNotificationAssetSelection({enabledAssetIds:I});Nt(pe),r?.()}catch(pe){ue(uc(pe))}finally{we(!1)}}return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:u.jsxs("div",{className:"security-panel settings-panel",onClick:pe=>pe.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{children:"Settings"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),u.jsxs("div",{className:"settings-layout",children:[u.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Gh.map(pe=>u.jsxs("button",{type:"button","data-active":G===pe.id?"true":"false","aria-current":G===pe.id?"true":void 0,onClick:()=>Ue(pe.id),children:[pe.label,pe.id==="servers"&&n?u.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},pe.id))}),u.jsxs("div",{ref:H,className:"settings-content",onScroll:ut,children:[u.jsxs("section",{id:"settings-appearance",ref:pe=>{de.current.appearance=pe},className:"security-section settings-section",children:[u.jsx("h3",{children:"Appearance"}),u.jsx("div",{className:"settings-section-heading",children:u.jsxs("div",{children:[u.jsx("span",{className:"settings-control-title",children:"Theme"}),u.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),u.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Af.map(pe=>u.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":A===pe.id,"data-active":A===pe.id?"true":"false",onClick:()=>M(cD(pe.id)),style:{"--settings-theme-bg":pe.tokens.bg,"--settings-theme-bg-2":pe.tokens.bg2,"--settings-theme-sidebar":pe.tokens.bgSidebar,"--settings-theme-line":pe.tokens.line,"--settings-theme-fg":pe.tokens.fg,"--settings-theme-fg-2":pe.tokens.fg2,"--settings-theme-accent":pe.tokens.accent,"--settings-theme-xterm-bg":pe.xterm.background,"--settings-theme-xterm-fg":pe.xterm.foreground,"--settings-theme-xterm-selection":pe.xterm.selectionBackground},children:[u.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[u.jsxs("span",{className:"settings-theme-preview-sidebar",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]}),u.jsxs("span",{className:"settings-theme-preview-main",children:[u.jsxs("span",{className:"settings-theme-preview-tabs",children:[u.jsx("span",{}),u.jsx("span",{})]}),u.jsxs("span",{className:"settings-theme-preview-terminal",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]})]})]}),u.jsxs("span",{className:"settings-theme-card-copy",children:[u.jsx("strong",{children:pe.label}),u.jsx("small",{children:pe.description})]})]},pe.id))}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Font size"}),u.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),u.jsx("input",{type:"range",min:e_,max:t_,step:1,value:d,"aria-label":"Terminal font size",onChange:pe=>Fe(pe.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row",children:[u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Yh(d-1)),children:"-"}),u.jsx("input",{type:"number",min:e_,max:t_,step:1,value:d,"aria-label":"Terminal font size value",onChange:pe=>Fe(pe.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Yh(d+1)),children:"+"}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Yh(cl)),children:"Reset"})]}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Font family"}),u.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:pe=>p(tL(pe.currentTarget.value)),children:Uf.map(pe=>u.jsx("option",{value:pe.id,children:pe.label},pe.id))})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:b,onChange:pe=>_(iL(pe.currentTarget.checked))}),"Show scroll progress"]}),u.jsx("div",{className:"settings-section-heading",children:u.jsxs("div",{children:[u.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),u.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:w,onChange:pe=>C(sL(pe.currentTarget.checked))}),"Shell panes"]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:x,onChange:pe=>T(rL(pe.currentTarget.checked))}),"Codex/Claude panes"]})]}),u.jsxs("section",{id:"settings-shortcuts",ref:pe=>{de.current.shortcuts=pe},className:"security-section settings-section",children:[u.jsxs("div",{className:"settings-section-heading",children:[u.jsx("h3",{children:"Shortcuts"}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:lt,children:"Reset all"})]}),u.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),V?u.jsx("p",{className:"settings-error",children:V}):null,u.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:fd.map(pe=>{const Ze=P===pe.id;return u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("span",{className:"settings-shortcut-label",children:pe.label}),u.jsx("span",{className:"settings-shortcut-group",children:pe.group})]}),u.jsxs("div",{className:"settings-shortcut-actions",children:[u.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ze?"true":"false",onClick:()=>{F(pe.id),O(null)},children:Ze?"Press keys…":uT(W[pe.id])}),u.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>_t(pe.id),children:"Reset"})]})]},pe.id)})})]}),u.jsxs("section",{id:"settings-notifications",ref:pe=>{de.current.notifications=pe},className:"security-section settings-section",children:[u.jsx("h3",{children:"Notifications"}),wp()?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:ee&&ie==="granted",onChange:()=>{Yt()},disabled:ie==="denied"}),"System notification when page is hidden"]}),ie==="denied"?u.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."}):u.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):u.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),u.jsxs("div",{className:"settings-subsection",children:[u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:!!Re,onChange:()=>{st()},disabled:ge||!je.supported}),"Installed app push notifications"]}),u.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),je.supported?null:u.jsx("p",{className:"muted",children:gf(je.reason)}),Re?u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"muted",children:["Registered as ",Re.label,". Last active ",new Date(Re.lastActiveAt).toLocaleString(),"."]}),u.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{Sn()},disabled:ge,children:"Send test notification"})]}):null,be?u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:Re?.alwaysNotify===!0,onChange:pe=>{On(pe.currentTarget.checked)},disabled:ge||!Re}),"Always notify this mobile device"]}):null,Be?u.jsx("p",{className:"form-error",children:Be}):null,ve?u.jsx("p",{className:"muted",role:"status",children:ve}):null]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:$.enabled,onChange:pe=>Z(EM(pe.currentTarget.checked))}),"Show animated completion toast"]}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Toast duration"}),u.jsx("span",{className:"settings-control-value",children:$.persistUntilDismissed?"Until closed":`${$.durationSeconds}s`}),u.jsx("input",{type:"range",min:Fv,max:Wv,step:.5,value:$.durationSeconds,disabled:!$.enabled||$.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:pe=>We(pe.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[u.jsx("input",{type:"number",min:Fv,max:Wv,step:.5,value:$.durationSeconds,disabled:!$.enabled||$.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:pe=>We(pe.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!$.enabled||$.persistUntilDismissed,onClick:()=>Z(b1(td)),children:"Reset"})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:$.persistUntilDismissed,disabled:!$.enabled,onChange:pe=>Z(RM(pe.currentTarget.checked))}),"Keep toast until dismissed"]}),u.jsxs("div",{className:"settings-assets-header",children:[u.jsx("span",{children:"Toast videos"}),u.jsxs("span",{children:[qg(Y)," max"]})]}),u.jsx("input",{ref:Pe,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:pe=>{dt(pe.currentTarget.files)}}),u.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Q,onClick:()=>Pe.current?.click(),children:"Upload video"}),Se?u.jsx("p",{className:"settings-error",children:Se}):null,j.length>0?u.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:j.map(pe=>u.jsxs("li",{"data-enabled":Te.has(pe.id)?"true":"false",children:[u.jsxs("label",{className:"settings-asset-choice",children:[u.jsx("input",{type:"checkbox",checked:Te.has(pe.id),disabled:Q,"aria-label":`Use ${pe.filename}`,onChange:Ze=>gi(pe.id,Ze.currentTarget.checked)}),u.jsx("video",{src:pe.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),u.jsxs("span",{className:"settings-asset-copy",children:[u.jsx("span",{children:pe.filename}),u.jsx("small",{children:pe.source==="built-in"?"Built-in":qg(pe.size)})]})]}),pe.source==="uploaded"?u.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Q,"aria-label":`Delete ${pe.filename}`,onClick:()=>{Lt(pe.id)},children:"x"}):null]},pe.id))}):u.jsx("p",{className:"muted",children:"Built-in videos will be used."}),u.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Q||j.length===0||!Me,onClick:()=>{ki()},children:"Save selected videos"})]}),u.jsx("div",{id:"settings-security",ref:pe=>{de.current.security=pe},className:"settings-section-group",children:u.jsx(JA,{api:l})}),u.jsx("div",{id:"settings-servers",ref:pe=>{de.current.servers=pe},className:"settings-section-group",children:u.jsx(ML,{api:l,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function j1(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function qg(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 uc(e){return e instanceof Error?e.message:"Request failed."}function gf(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function Vg(e){const t=uc(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?gf("not_standalone"):t==="insecure"?gf("insecure"):t==="not_mobile"?gf("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function OL(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 BL(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const IL="modulepreload",PL=function(e){return"/"+e},O1={},fy=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.map(b=>Promise.resolve(b).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=d?.nonce||d?.getAttribute("nonce");o=g(n.map(p=>{if(p=PL(p),p in O1)return;O1[p]=!0;const b=p.endsWith(".css"),_=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${_}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":IL,b||(w.as="script"),w.crossOrigin="",w.href=p,f&&w.setAttribute("nonce",f),document.head.appendChild(w),b)return new Promise((C,x)=>{w.addEventListener("load",C),w.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&l(f.reason);return t().catch(l)})},zL=v.lazy(()=>fy(()=>import("./MarkdownPreview-D3Oa7_1H.js"),__vite__mapDeps([0,1])));function HL({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[l,d]=v.useState(null),[f,g]=v.useState(""),[p,b]=v.useState({}),[_,w]=v.useState(()=>new Set),[C,x]=v.useState(null),[T,A]=v.useState({type:"empty"}),[M,W]=v.useState("idle"),[U,P]=v.useState(null),F=v.useRef(null),V=v.useRef(null),O=v.useRef(!1),G=v.useRef(0),fe=v.useRef(null);fe.current===null&&t&&(fe.current=t);const ee=fe.current,te=r?$L(r):t?B1(t,n):null,$=l?[l.rootPath,f].filter(Boolean).join("/"):"",Z=C?.path??null;v.useEffect(()=>(O.current=!0,()=>{O.current=!1,G.current+=1,He()}),[]),v.useEffect(()=>{fe.current=t,V.current=null,ie(te)},[e]),v.useEffect(()=>{r&&te!==V.current&&J(r,te)},[r,te]),v.useEffect(()=>{if(r||!ee||t!==ee)return;const H=B1(ee,n);H!==V.current&&j(ee,H)},[ee,t,n,r]);async function ie(H=te){if(r){await J(r,H);return}await j(t,H)}async function J(H,de=te){const Te=Be();if(V.current=de,He(),d(null),g(""),b({}),w(new Set),x(null),A({type:"empty"}),P(null),!H){W("idle");return}W("loading");try{const Me=await e.createFileRoot({path:H});if(!L(Te))return;d({rootToken:Me.rootToken,rootPath:Me.rootPath});const je=await e.listFiles({rootToken:Me.rootToken,path:""});if(!L(Te))return;re(je),W("idle")}catch(Me){L(Te)&&(P(ea(Me)),W("idle"))}}async function j(H,de=te){const Te=Be();if(V.current=de,He(),d(null),g(""),b({}),w(new Set),x(null),A({type:"empty"}),P(null),!H){W("idle");return}W("loading");try{const Me=await e.createFileRoot({terminalId:H});if(!L(Te))return;d({rootToken:Me.rootToken,rootPath:Me.rootPath});const je=await e.listFiles({rootToken:Me.rootToken,path:""});if(!L(Te))return;re(je),W("idle")}catch(Me){if(await ve(Me,Te))return;L(Te)&&(P(ea(Me)),W("idle"))}}async function R(H=f,de=l){if(!de)return;const Te=Be();W("loading"),P(null);try{const Me=await e.listFiles({rootToken:de.rootToken,path:H});if(!L(Te))return;re(Me),W("idle")}catch(Me){if(await ve(Me,Te))return;L(Te)&&(P(ea(Me)),W("idle"))}}async function I(){if(r){await J(r,te);return}fe.current=t,await j(t,te)}function re(H){b(de=>({...de,[H.path]:FL(H.entries)}))}async function _e(H){if(!(!Yg(H)||!l)){if(x(H),P(null),H.kind==="directory"){g(H.path),ge(),await Y(H);return}if(g(tl(H.path)),H.editable){await Q(H);return}H.previewKind!=="none"&&await Se(H,H.previewKind)}}async function N(H){if(!(!Yg(H)||!l)){if(x(H),P(null),H.kind==="directory"){g(H.path),ge(),await Y(H);return}if(g(tl(H.path)),H.editable){await we(H);return}H.previewKind!=="none"&&await Se(H,H.previewKind)}}async function Y(H){if(_.has(H.path)){w(de=>{const Te=new Set(de);return Te.delete(H.path),Te});return}w(de=>new Set(de).add(H.path)),await R(H.path)}function oe(H,de){H.key==="Enter"&&(H.preventDefault(),N(de))}async function Q(H){if(!l)return;const de=Be();W("loading"),He();try{const Te=await e.readFile({rootToken:l.rootToken,path:H.path});if(!L(de))return;A({type:"text-preview",file:H,read:Te}),W("idle")}catch(Te){if(await ve(Te,de))return;L(de)&&(P(ea(Te)),W("idle"))}}async function we(H){if(!l)return;const de=Be();W("loading");try{await o({rootToken:l.rootToken,path:H.path,...t?{terminalId:t}:{}}),L(de)&&W("idle")}catch(Te){if(await ve(Te,de))return;L(de)&&(P(ea(Te)),W("idle"))}}async function Se(H,de){if(!l)return;const Te=Be();W("loading"),He();try{const Me=await e.previewFile({rootToken:l.rootToken,path:H.path});if(!L(Te))return;const je=URL.createObjectURL(Me);if(!L(Te)){URL.revokeObjectURL(je);return}F.current=je,A({type:"preview",file:H,previewKind:de,url:je}),W("idle")}catch(Me){if(await ve(Me,Te))return;L(Te)&&(P(ea(Me)),W("idle"))}}async function ue(H){if(!l)return;const de=H==="file"?"New file":"New folder",Te=window.prompt(de,""),Me=C?C.kind==="directory"?C.path:tl(C.path):f,je=I1(Te,Me);if(je){P(null);try{const be=await e.createFileEntry({rootToken:l.rootToken,path:je,kind:H});x(be.entry),await R(Me)}catch(be){if(await ve(be))return;P(ea(be))}}}async function Re(){if(!l||!C)return;const H=window.prompt("Move selected entry",C.path),de=I1(H,"");if(!de||de===C.path)return;const Te=tl(C.path),Me=tl(de);P(null);try{const je=await e.moveFileEntry({rootToken:l.rootToken,sourcePath:C.path,destinationPath:de});x(je.entry),g(je.entry.kind==="directory"?je.entry.path:tl(je.entry.path)),ge(),await R(Te),Me!==Te&&await R(Me)}catch(je){if(await ve(je))return;P(ea(je))}}async function Oe(){if(!l||!C)return;const H=C.path,de=tl(H);P(null);try{const Te=await e.previewDeleteFileEntry({rootToken:l.rootToken,path:C.path}),Me=Te.descendantCount>0?` and ${Te.descendantCount} nested item${Te.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Te.path}${Me}?`))return;await e.deleteFileEntry({rootToken:l.rootToken,path:C.path,previewToken:Te.previewToken}),x(null),g(de),w(je=>{const be=new Set(je);for(const Fe of je)(Fe===H||Fe.startsWith(`${H}/`))&&be.delete(Fe);return be}),ge(),await R(de)}catch(Te){if(await ve(Te))return;P(ea(Te))}}function ge(){G.current+=1,He(),A({type:"empty"})}function He(){F.current&&(URL.revokeObjectURL(F.current),F.current=null)}function Be(){return G.current+=1,G.current}function L(H){return O.current&&H===G.current}async function ve(H,de){return WL(H)?(de!==void 0&&!L(de)||await ie(te),!0):!1}function Le(H,de){const Te=Yg(H),Me=H.kind==="directory"&&_.has(H.path),je=p[H.path]??[],be={"--file-tree-depth":de};return u.jsxs(zt.Fragment,{children:[u.jsxs("button",{type:"button",className:"file-entry-button","data-kind":H.kind,"data-expanded":Me,"data-active":Z===H.path,disabled:!Te,style:be,"aria-expanded":H.kind==="directory"?Me:void 0,"aria-label":`${H.kind==="directory"?"Open folder":"Open file"} ${H.name}`,title:H.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{_e(H)},onDoubleClick:()=>{N(H)},onKeyDown:Fe=>oe(Fe,H),children:[u.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:H.kind==="directory"?Me?"▾":"▸":""}),u.jsx("span",{className:"file-entry-name",children:H.name}),u.jsx("small",{children:UL(H)})]}),Me?u.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Fe=>Le(Fe,de+1))}):null]},H.path)}const Pe=p[""]??[];return u.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":M==="loading",children:[u.jsxs("header",{className:"file-explorer-header",children:[u.jsx("div",{className:"file-explorer-path",title:$,children:$||"No active pane"}),u.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[u.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{I()},children:"↻"}),u.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!l,onClick:()=>{ue("file")},children:"+"}),u.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!l,onClick:()=>{ue("directory")},children:"▣"})]})]}),U?u.jsx("div",{className:"file-explorer-alert",role:"alert",children:U}):null,u.jsxs("div",{className:"file-explorer-layout",children:[u.jsx("div",{className:"file-tree","aria-label":$?`Files in ${$}`:"Files",children:Pe.map(H=>Le(H,0))}),u.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[u.jsxs("div",{className:"file-detail-header",children:[u.jsx("strong",{children:C?.name??"detail"}),u.jsxs("div",{className:"file-detail-actions",children:[u.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!C,onClick:()=>{Re()},children:"Move"}),u.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!C,onClick:()=>{Oe()},children:"Delete"})]})]}),M==="loading"?u.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&M!=="loading"?u.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?u.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?u.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?u.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?u.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:u.jsx(v.Suspense,{fallback:u.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:u.jsx(zL,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?u.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function Yg(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function UL(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function B1(e,t){return`${e}\0${t??""}`}function $L(e){return`workspace\0${e}`}function FL(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function tl(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function I1(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function ea(e){return e instanceof Error?e.message:"Request failed"}function WL(e){return e instanceof Un&&e.status===409&&e.message==="terminal_cwd_changed"}const KL=v.lazy(()=>fy(()=>import("./MarkdownPreview-D3Oa7_1H.js"),__vite__mapDeps([0,1])));function P1({api:e,editor:t,canClose:n,onClose:r}){const[o,l]=v.useState(t.read),[d,f]=v.useState(t.read.content),[g,p]=v.useState("idle"),[b,_]=v.useState(null),[w,C]=v.useState(!1),[x,T]=v.useState("edit"),A=v.useRef(t),M=v.useRef(t.read),W=v.useRef(t.read.content),U=v.useRef(!1),P=v.useRef(!1),F=v.useRef(0),V=d!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,F.current+=1}),[]),v.useEffect(()=>{F.current+=1,U.current=!1,A.current=t,M.current=t.read,W.current=t.read.content,l(t.read),f(t.read.content),p("idle"),_(null),C(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{A.current=t},[t]),v.useEffect(()=>{M.current=o},[o]),v.useEffect(()=>{W.current=d},[d]),v.useEffect(()=>{if(d===o.content||w)return;const te=window.setInterval(()=>{!U.current&&W.current!==M.current.content&&O()},1e3);return()=>window.clearInterval(te)},[d===o.content,w,t.id]);async function O(){if(U.current)return;const te=W.current,$=M.current;if(te===$.content)return;const Z=A.current,ie=F.current;U.current=!0,p("saving"),_(null),C(!1);try{const J=await e.writeFile({rootToken:Z.rootToken,path:Z.path,content:te,expectedVersion:$.version});if(!P.current||ie!==F.current)return;const j={...$,content:te,version:J.version};M.current=j,l(j),p(W.current===te?"saved":"idle")}catch(J){if(!P.current||ie!==F.current)return;if(J instanceof Un&&J.status===409){C(!0),p("idle");return}_(qL(J)),p("idle")}finally{ie===F.current&&(U.current=!1)}}const G=g==="saving"?"saving":g==="saved"?"saved":o.language,fe=o.language==="markdown",ee=fe&&x==="preview";return u.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[u.jsxs("header",{className:"editor-pane-header",children:[u.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),u.jsx("strong",{children:t.title}),u.jsx("span",{className:"terminal-pane-spacer"}),u.jsx("span",{className:"terminal-pane-state",children:G}),u.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!V,onClick:()=>{O()},children:"Save"}),fe?u.jsx("button",{type:"button","aria-label":`${ee?"Edit":"Preview"} ${t.title}`,onClick:()=>T(te=>te==="preview"?"edit":"preview"),children:ee?"Edit":"Preview"}):null,n?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),b?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,w?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ee?u.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:u.jsx(v.Suspense,{fallback:u.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:u.jsx(KL,{content:d})})}):u.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:te=>{const $=te.target.value;W.current=$,f($),p("idle"),_(null),C(!1)}})]})}function qL(e){return e instanceof Error?e.message:"Request failed"}var VL=2,YL=1,GL=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),d={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=d.top+d.bottom,g=d.right+d.left,p=r-f,b=o-g-t;return{cols:Math.max(VL,Math.floor(b/e.css.cell.width)),rows:Math.max(YL,Math.floor(p/e.css.cell.height))}}};var _T=Object.defineProperty,XL=Object.getOwnPropertyDescriptor,ZL=(e,t)=>{for(var n in t)_T(e,n,{get:t[n],enumerable:!0})},jn=(e,t,n,r)=>{for(var o=r>1?void 0:r?XL(t,n):t,l=e.length-1,d;l>=0;l--)(d=e[l])&&(o=(r?d(t,n,o):d(o))||o);return r&&o&&_T(t,n,o),o},Ve=(e,t)=>(n,r)=>t(n,r,e),z1="Terminal input",h_={get:()=>z1,set:e=>z1=e},H1="Too much output to announce, navigate to rows manually to read",f_={get:()=>H1,set:e=>H1=e};function QL(e){return e.replace(/\r?\n/g,"\r")}function JL(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function ej(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function tj(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");bT(o,t,n,r)}}function bT(e,t,n,r){e=QL(e),e=JL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function yT(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,l=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function U1(e,t,n,r,o){yT(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function io(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function kp(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,r+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):r+=String.fromCharCode(l)}return r}var nj=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[r++]=(this._interim-55296)*1024+l-56320+65536:(t[r++]=this._interim,t[r++]=l),this._interim=0}for(let l=o;l<n;++l){let d=e.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=n)return this._interim=d,r;let f=e.charCodeAt(l);56320<=f&&f<=57343?t[r++]=(d-55296)*1024+f-56320+65536:(t[r++]=d,t[r++]=f);continue}d!==65279&&(t[r++]=d)}return r}},ij=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,l,d,f,g=0,p=0;if(this.interim[0]){let w=!1,C=this.interim[0];C&=(C&224)===192?31:(C&240)===224?15:7;let x=0,T;for(;(T=this.interim[++x]&63)&&x<4;)C<<=6,C|=T;let A=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=A-x;for(;p<M;){if(p>=n)return 0;if(T=e[p++],(T&192)!==128){p--,w=!0;break}else this.interim[x++]=T,C<<=6,C|=T&63}w||(A===2?C<128?p--:t[r++]=C:A===3?C<2048||C>=55296&&C<=57343||C===65279||(t[r++]=C):C<65536||C>1114111||(t[r++]=C)),this.interim.fill(0)}let b=n-4,_=p;for(;_<n;){for(;_<b&&!((o=e[_])&128)&&!((l=e[_+1])&128)&&!((d=e[_+2])&128)&&!((f=e[_+3])&128);)t[r++]=o,t[r++]=l,t[r++]=d,t[r++]=f,_+=4;if(o=e[_++],o<128)t[r++]=o;else if((o&224)===192){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(g=(o&31)<<6|l&63,g<128){_--;continue}t[r++]=g}else if((o&240)===224){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,r;if(d=e[_++],(d&192)!==128){_--;continue}if(g=(o&15)<<12|(l&63)<<6|d&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,r;if(d=e[_++],(d&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=d,r;if(f=e[_++],(f&192)!==128){_--;continue}if(g=(o&7)<<18|(l&63)<<12|(d&63)<<6|f&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},ST="",ao=" ",Bd=class wT{constructor(){this.fg=0,this.bg=0,this.extended=new Ff}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 wT;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}},Ff=class xT{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new xT(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ps=class CT extends Bd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ff,this.combinedData=""}static fromCharData(t){let n=new CT;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?io(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},$1="di$target",p_="di$dependencies",Gg=new Map;function sj(e){return e[p_]||[]}function mi(e){if(Gg.has(e))return Gg.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");rj(t,n,o)};return t._id=e,Gg.set(e,t),t}function rj(e,t,n){t[$1]===t?t[p_].push({id:e,index:n}):(t[p_]=[{id:e,index:n}],t[$1]=t)}var Fi=mi("BufferService"),kT=mi("CoreMouseService"),_l=mi("CoreService"),aj=mi("CharsetService"),py=mi("InstantiationService"),TT=mi("LogService"),Wi=mi("OptionsService"),ET=mi("OscLinkService"),oj=mi("UnicodeService"),Id=mi("DecorationService"),m_=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,l=new Ps,d=n.getTrimmedLength(),f=-1,g=-1,p=!1;for(let b=0;b<d;b++)if(!(g===-1&&!n.hasContent(b))){if(n.loadCell(b,l),l.hasExtendedAttrs()&&l.extended.urlId)if(g===-1){g=b,f=l.extended.urlId;continue}else p=l.extended.urlId!==f;else g!==-1&&(p=!0);if(p||g!==-1&&b===d-1){let _=this._oscLinkService.getLinkData(f)?.uri;if(_){let w={start:{x:g+1,y:e},end:{x:b+(!p&&b===d-1?1:0),y:e}},C=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(C=!0)}catch{C=!0}C||r.push({text:_,range:w,activate:(x,T)=>o?o.activate(x,T,w):lj(x,T),hover:(x,T)=>o?.hover?.(x,T,w),leave:(x,T)=>o?.leave?.(x,T,w)})}p=!1,l.hasExtendedAttrs()&&l.extended.urlId?(g=b,f=l.extended.urlId):(g=-1,f=-1)}}t(r)}};m_=jn([Ve(0,Fi),Ve(1,Wi),Ve(2,ET)],m_);function lj(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Tp=mi("CharSizeService"),pa=mi("CoreBrowserService"),my=mi("MouseService"),ma=mi("RenderService"),cj=mi("SelectionService"),RT=mi("CharacterJoinerService"),zc=mi("ThemeService"),DT=mi("LinkProviderService"),uj=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?F1.isErrorNoTelemetry(e)?new F1(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)}},dj=new uj;function vf(e){hj(e)||dj.onUnexpectedError(e)}var g_="Canceled";function hj(e){return e instanceof fj?!0:e instanceof Error&&e.name===g_&&e.message===g_}var fj=class extends Error{constructor(){super(g_),this.name=this.message}};function pj(e){return new Error(`Illegal argument: ${e}`)}var F1=class v_ extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof v_)return t;let n=new v_;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},__=class NT extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,NT.prototype)}};function hs(e,t=0){return e[e.length-(1+t)]}var mj;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function r(l){return l>0}e.isGreaterThan=r;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(mj||={});function gj(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var MT;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(P){yield P}e.single=o;function l(P){return t(P)?P:o(P)}e.wrap=l;function d(P){return P||n}e.from=d;function*f(P){for(let F=P.length-1;F>=0;F--)yield P[F]}e.reverse=f;function g(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(P){return P[Symbol.iterator]().next().value}e.first=p;function b(P,F){let V=0;for(let O of P)if(F(O,V++))return!0;return!1}e.some=b;function _(P,F){for(let V of P)if(F(V))return V}e.find=_;function*w(P,F){for(let V of P)F(V)&&(yield V)}e.filter=w;function*C(P,F){let V=0;for(let O of P)yield F(O,V++)}e.map=C;function*x(P,F){let V=0;for(let O of P)yield*F(O,V++)}e.flatMap=x;function*T(...P){for(let F of P)yield*F}e.concat=T;function A(P,F,V){let O=V;for(let G of P)O=F(O,G);return O}e.reduce=A;function*M(P,F,V=P.length){for(F<0&&(F+=P.length),V<0?V+=P.length:V>P.length&&(V=P.length);F<V;F++)yield P[F]}e.slice=M;function W(P,F=Number.POSITIVE_INFINITY){let V=[];if(F===0)return[V,P];let O=P[Symbol.iterator]();for(let G=0;G<F;G++){let fe=O.next();if(fe.done)return[V,e.empty()];V.push(fe.value)}return[V,{[Symbol.iterator](){return O}}]}e.consume=W;async function U(P){let F=[];for await(let V of P)F.push(V);return Promise.resolve(F)}e.asyncToArray=U})(MT||={});function ml(e){if(MT.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function vj(...e){return yn(()=>ml(e))}function yn(e){return{dispose:gj(()=>{e()})}}var AT=class LT{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{ml(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?LT.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)}};AT.DISABLE_DISPOSED_WARNING=!1;var lo=AT,Dt=class{constructor(){this._store=new lo,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)}};Dt.None=Object.freeze({dispose(){}});var Ac=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}},la=typeof window=="object"?window:globalThis,b_=class y_{constructor(t){this.element=t,this.next=y_.Undefined,this.prev=y_.Undefined}};b_.Undefined=new b_(void 0);var Cn=b_,W1=class{constructor(){this._first=Cn.Undefined,this._last=Cn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Cn.Undefined}clear(){let e=this._first;for(;e!==Cn.Undefined;){let t=e.next;e.prev=Cn.Undefined,e.next=Cn.Undefined,e=t}this._first=Cn.Undefined,this._last=Cn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Cn(e);if(this._first===Cn.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==Cn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Cn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Cn.Undefined&&e.next!==Cn.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Cn.Undefined&&e.next===Cn.Undefined?(this._first=Cn.Undefined,this._last=Cn.Undefined):e.next===Cn.Undefined?(this._last=this._last.prev,this._last.next=Cn.Undefined):e.prev===Cn.Undefined&&(this._first=this._first.next,this._first.prev=Cn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Cn.Undefined;)yield e.element,e=e.next}},_j=globalThis.performance&&typeof globalThis.performance.now=="function",bj=class jT{static create(t){return new jT(t)}constructor(t){this._now=_j&&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}},Ci;(e=>{e.None=()=>Dt.None;function t($,Z){return _($,()=>{},0,void 0,!0,void 0,Z)}e.defer=t;function n($){return(Z,ie=null,J)=>{let j=!1,R;return R=$(I=>{if(!j)return R?R.dispose():j=!0,Z.call(ie,I)},null,J),j&&R.dispose(),R}}e.once=n;function r($,Z,ie){return p((J,j=null,R)=>$(I=>J.call(j,Z(I)),null,R),ie)}e.map=r;function o($,Z,ie){return p((J,j=null,R)=>$(I=>{Z(I),J.call(j,I)},null,R),ie)}e.forEach=o;function l($,Z,ie){return p((J,j=null,R)=>$(I=>Z(I)&&J.call(j,I),null,R),ie)}e.filter=l;function d($){return $}e.signal=d;function f(...$){return(Z,ie=null,J)=>{let j=vj(...$.map(R=>R(I=>Z.call(ie,I))));return b(j,J)}}e.any=f;function g($,Z,ie,J){let j=ie;return r($,R=>(j=Z(j,R),j),J)}e.reduce=g;function p($,Z){let ie,J={onWillAddFirstListener(){ie=$(j.fire,j)},onDidRemoveLastListener(){ie?.dispose()}},j=new $e(J);return Z?.add(j),j.event}function b($,Z){return Z instanceof Array?Z.push($):Z&&Z.add($),$}function _($,Z,ie=100,J=!1,j=!1,R,I){let re,_e,N,Y=0,oe,Q={leakWarningThreshold:R,onWillAddFirstListener(){re=$(Se=>{Y++,_e=Z(_e,Se),J&&!N&&(we.fire(_e),_e=void 0),oe=()=>{let ue=_e;_e=void 0,N=void 0,(!J||Y>1)&&we.fire(ue),Y=0},typeof ie=="number"?(clearTimeout(N),N=setTimeout(oe,ie)):N===void 0&&(N=0,queueMicrotask(oe))})},onWillRemoveListener(){j&&Y>0&&oe?.()},onDidRemoveLastListener(){oe=void 0,re.dispose()}},we=new $e(Q);return I?.add(we),we.event}e.debounce=_;function w($,Z=0,ie){return e.debounce($,(J,j)=>J?(J.push(j),J):[j],Z,void 0,!0,void 0,ie)}e.accumulate=w;function C($,Z=(J,j)=>J===j,ie){let J=!0,j;return l($,R=>{let I=J||!Z(R,j);return J=!1,j=R,I},ie)}e.latch=C;function x($,Z,ie){return[e.filter($,Z,ie),e.filter($,J=>!Z(J),ie)]}e.split=x;function T($,Z=!1,ie=[],J){let j=ie.slice(),R=$(_e=>{j?j.push(_e):re.fire(_e)});J&&J.add(R);let I=()=>{j?.forEach(_e=>re.fire(_e)),j=null},re=new $e({onWillAddFirstListener(){R||(R=$(_e=>re.fire(_e)),J&&J.add(R))},onDidAddFirstListener(){j&&(Z?setTimeout(I):I())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return J&&J.add(re),re.event}e.buffer=T;function A($,Z){return(ie,J,j)=>{let R=Z(new W);return $(function(I){let re=R.evaluate(I);re!==M&&ie.call(J,re)},void 0,j)}}e.chain=A;let M=Symbol("HaltChainable");class W{constructor(){this.steps=[]}map(Z){return this.steps.push(Z),this}forEach(Z){return this.steps.push(ie=>(Z(ie),ie)),this}filter(Z){return this.steps.push(ie=>Z(ie)?ie:M),this}reduce(Z,ie){let J=ie;return this.steps.push(j=>(J=Z(J,j),J)),this}latch(Z=(ie,J)=>ie===J){let ie=!0,J;return this.steps.push(j=>{let R=ie||!Z(j,J);return ie=!1,J=j,R?j:M}),this}evaluate(Z){for(let ie of this.steps)if(Z=ie(Z),Z===M)break;return Z}}function U($,Z,ie=J=>J){let J=(...re)=>I.fire(ie(...re)),j=()=>$.on(Z,J),R=()=>$.removeListener(Z,J),I=new $e({onWillAddFirstListener:j,onDidRemoveLastListener:R});return I.event}e.fromNodeEventEmitter=U;function P($,Z,ie=J=>J){let J=(...re)=>I.fire(ie(...re)),j=()=>$.addEventListener(Z,J),R=()=>$.removeEventListener(Z,J),I=new $e({onWillAddFirstListener:j,onDidRemoveLastListener:R});return I.event}e.fromDOMEventEmitter=P;function F($){return new Promise(Z=>n($)(Z))}e.toPromise=F;function V($){let Z=new $e;return $.then(ie=>{Z.fire(ie)},()=>{Z.fire(void 0)}).finally(()=>{Z.dispose()}),Z.event}e.fromPromise=V;function O($,Z){return $(ie=>Z.fire(ie))}e.forward=O;function G($,Z,ie){return Z(ie),$(J=>Z(J))}e.runAndSubscribe=G;class fe{constructor(Z,ie){this._observable=Z,this._counter=0,this._hasChanged=!1;let J={onWillAddFirstListener:()=>{Z.addObserver(this)},onDidRemoveLastListener:()=>{Z.removeObserver(this)}};this.emitter=new $e(J),ie&&ie.add(this.emitter)}beginUpdate(Z){this._counter++}handlePossibleChange(Z){}handleChange(Z,ie){this._hasChanged=!0}endUpdate(Z){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ee($,Z){return new fe($,Z).emitter.event}e.fromObservable=ee;function te($){return(Z,ie,J)=>{let j=0,R=!1,I={beginUpdate(){j++},endUpdate(){j--,j===0&&($.reportChanges(),R&&(R=!1,Z.call(ie)))},handlePossibleChange(){},handleChange(){R=!0}};$.addObserver(I),$.reportChanges();let re={dispose(){$.removeObserver(I)}};return J instanceof lo?J.add(re):Array.isArray(J)&&J.push(re),re}}e.fromObservableLight=te})(Ci||={});var S_=class w_{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${w_._idPool++}`,w_.all.add(this)}start(t){this._stopWatch=new bj,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}}};S_.all=new Set,S_._idPool=0;var yj=S_,Sj=-1,OT=class BT{constructor(t,n,r=(BT._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[l,d]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(f),console.warn(l);let g=new Cj(f,l);this._errorHandler(g)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};OT._idPool=1;var wj=OT,xj=class IT{constructor(t){this.value=t}static create(){let t=new Error;return new IT(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},Cj=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},kj=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Tj=0,Xg=class{constructor(e){this.value=e,this.id=Tj++}},Ej=2,Rj,$e=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new wj(e?.onListenerError??vf,this._options?.leakWarningThreshold??Sj):void 0,this._perfMon=this._options?._profName?new yj(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new kj(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||vf)(g),Dt.None}if(this._disposed)return Dt.None;t&&(e=e.bind(t));let r=new Xg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=xj.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Xg?(this._deliveryQueue??=new Dj,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let l=yn(()=>{o?.(),this._removeListener(r)});return n instanceof lo?n.add(l):Array.isArray(n)&&n.push(l),l},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Ej<=t.length){let o=0;for(let l=0;l<t.length;l++)t[l]?t[o++]=t[l]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||vf;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Xg)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}},Dj=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},x_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new $e,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new $e,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};x_.INSTANCE=new x_;var gy=x_;function Nj(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}gy.INSTANCE.onDidChangeZoomLevel;function Mj(e){return gy.INSTANCE.getZoomFactor(e)}gy.INSTANCE.onDidChangeFullscreen;var Hc=typeof navigator=="object"?navigator.userAgent:"",C_=Hc.indexOf("Firefox")>=0,Aj=Hc.indexOf("AppleWebKit")>=0,vy=Hc.indexOf("Chrome")>=0,Lj=!vy&&Hc.indexOf("Safari")>=0;Hc.indexOf("Electron/")>=0;Hc.indexOf("Android")>=0;var Zg=!1;if(typeof la.matchMedia=="function"){let e=la.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=la.matchMedia("(display-mode: fullscreen)");Zg=e.matches,Nj(la,e,({matches:n})=>{Zg&&t.matches||(Zg=n)})}var _c="en",k_=!1,T_=!1,_f=!1,PT=!1,Xh,bf=_c,K1=_c,jj,ia,ul=globalThis,ms;typeof ul.vscode<"u"&&typeof ul.vscode.process<"u"?ms=ul.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ms=process);var Oj=typeof ms?.versions?.electron=="string",Bj=Oj&&ms?.type==="renderer";if(typeof ms=="object"){k_=ms.platform==="win32",T_=ms.platform==="darwin",_f=ms.platform==="linux",_f&&ms.env.SNAP&&ms.env.SNAP_REVISION,ms.env.CI||ms.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Xh=_c,bf=_c;let e=ms.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Xh=t.userLocale,K1=t.osLocale,bf=t.resolvedLanguage||_c,jj=t.languagePack?.translationsConfigFile}catch{}PT=!0}else typeof navigator=="object"&&!Bj?(ia=navigator.userAgent,k_=ia.indexOf("Windows")>=0,T_=ia.indexOf("Macintosh")>=0,(ia.indexOf("Macintosh")>=0||ia.indexOf("iPad")>=0||ia.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,_f=ia.indexOf("Linux")>=0,ia?.indexOf("Mobi")>=0,bf=globalThis._VSCODE_NLS_LANGUAGE||_c,Xh=navigator.language.toLowerCase(),K1=Xh):console.error("Unable to resolve platform.");var zT=k_,Sr=T_,Ij=_f,q1=PT,Cr=ia,Xa=bf,Pj;(e=>{function t(){return Xa}e.value=t;function n(){return Xa.length===2?Xa==="en":Xa.length>=3?Xa[0]==="e"&&Xa[1]==="n"&&Xa[2]==="-":!1}e.isDefaultVariant=n;function r(){return Xa==="en"}e.isDefault=r})(Pj||={});var zj=typeof ul.postMessage=="function"&&!ul.importScripts;(()=>{if(zj){let e=[];ul.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let l=e[r];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),l.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),ul.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var Hj=!!(Cr&&Cr.indexOf("Chrome")>=0);Cr&&Cr.indexOf("Firefox")>=0;!Hj&&Cr&&Cr.indexOf("Safari")>=0;Cr&&Cr.indexOf("Edg/")>=0;Cr&&Cr.indexOf("Android")>=0;var ac=typeof navigator=="object"?navigator:{};q1||document.queryCommandSupported&&document.queryCommandSupported("copy")||ac&&ac.clipboard&&ac.clipboard.writeText,q1||ac&&ac.clipboard&&ac.clipboard.readText;var _y=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}},Qg=new _y,V1=new _y,Y1=new _y,Uj=new Array(230),HT;(e=>{function t(f){return Qg.keyCodeToStr(f)}e.toString=t;function n(f){return Qg.strToKeyCode(f)}e.fromString=n;function r(f){return V1.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return Y1.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function l(f){return V1.strToKeyCode(f)||Y1.strToKeyCode(f)}e.fromUserSettings=l;function d(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Qg.keyCodeToStr(f)}e.toElectronAccelerator=d})(HT||={});var $j=class UT{constructor(t,n,r,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof UT&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Fj([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Fj=class{constructor(e){if(e.length===0)throw pj("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Wj(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return HT.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(C_)switch(t){case 59:return 85;case 60:if(Ij)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Sr)return 57;break}else if(Aj&&(Sr&&t===93||!Sr&&t===92))return 57;return Uj[t]||0}var Kj=Sr?256:2048,qj=512,Vj=1024,Yj=Sr?2048:256,G1=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=Wj(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|=Kj),this.altKey&&(t|=qj),this.shiftKey&&(t|=Vj),this.metaKey&&(t|=Yj),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new $j(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},X1=new WeakMap;function Gj(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Xj=class{static getSameOriginWindowChain(e){let t=X1.get(e);if(!t){t=[],X1.set(e,t);let n=e,r;do r=Gj(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let l of o){let d=l.window.deref();if(n+=d?.scrollY??0,r+=d?.scrollX??0,d===t||!l.iframeElement)break;let f=l.iframeElement.getBoundingClientRect();n+=f.top,r+=f.left}return{top:n,left:r}}},Zh=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Xj.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Z1=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(vy){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,d=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*d):this.deltaY=o.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?C_&&!Sr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")Lj&&zT?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*d):this.deltaX=o.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?C_&&!Sr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},$T=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Zj;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Qj?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ci.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:$T})})(Zj||={});var Qj=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?$T:(this._emitter||(this._emitter=new $e),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},by=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 __("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new __("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Jj=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new __("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=yn(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},e3;(e=>{async function t(r){let o,l=await Promise.all(r.map(d=>d.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(r){return new Promise(async(o,l)=>{try{await r(o,l)}catch(d){l(d)}})}e.withAsyncBody=n})(e3||={});var Q1=class Ls{static fromArray(t){return new Ls(n=>{n.emitMany(t)})}static fromPromise(t){return new Ls(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ls(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new Ls(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new $e,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ci.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new Ls(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return Ls.map(this,t)}static filter(t,n){return new Ls(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return Ls.filter(this,t)}static coalesce(t){return Ls.filter(t,n=>!!n)}coalesce(){return Ls.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return Ls.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())}};Q1.EMPTY=Q1.fromArray([]);var{getWindow:yr,getWindowId:t3,onDidRegisterWindow:n3}=(function(){let e=new Map,t={window:la,disposables:new lo};e.set(la.vscodeWindowId,t);let n=new $e,r=new $e,o=new $e;function l(d,f){return(typeof d=="number"?e.get(d):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(d){if(e.has(d.vscodeWindowId))return Dt.None;let f=new lo,g={window:d,disposables:f.add(new lo)};return e.set(d.vscodeWindowId,g),f.add(yn(()=>{e.delete(d.vscodeWindowId),r.fire(d)})),f.add(vt(d,ui.BEFORE_UNLOAD,()=>{o.fire(d)})),n.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:l,getWindow(d){let f=d;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=d;return g?.view?g.view.window:la},getDocument(d){return yr(d).document}}})(),i3=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function vt(e,t,n,r){return new i3(e,t,n,r)}var J1=function(e,t,n,r){return vt(e,t,n,r)},yy,s3=class extends Jj{constructor(e){super(),this.defaultTarget=e&&yr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},ex=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){vf(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=l=>{n.set(l,!1);let d=e.get(l)??[];for(t.set(l,d),e.set(l,[]),r.set(l,!0);d.length>0;)d.sort(ex.sort),d.shift().execute();r.set(l,!1)};yy=(l,d,f=0)=>{let g=t3(l),p=new ex(d,f),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(p),n.get(g)||(n.set(g,!0),l.requestAnimationFrame(()=>o(g))),p}})();function r3(e){let t=e.getBoundingClientRect(),n=yr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var ui={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"},a3=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=ns(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ns(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ns(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ns(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ns(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ns(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ns(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ns(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ns(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ns(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ns(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=ns(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=ns(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ns(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 ns(e){return typeof e=="number"?`${e}px`:e}function rd(e){return new a3(e)}var FT=class{constructor(){this._hooks=new lo,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(yn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=yr(e)}this._hooks.add(vt(l,ui.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(vt(l,ui.POINTER_UP,d=>this.stopMonitoring(!0)))}};function o3(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;n[r]=function(...d){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,d)}),this[l]}}var _r;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(_r||={});var Fu=class Di extends Dt{constructor(){super(),this.dispatched=!1,this.targets=new W1,this.ignoreTargets=new W1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ci.runAndSubscribe(n3,({window:t,disposables:n})=>{n.add(vt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(vt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(vt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:la,disposables:this._store}))}static addTarget(t){if(!Di.isTouchDevice())return Dt.None;Di.INSTANCE||(Di.INSTANCE=new Di);let n=Di.INSTANCE.targets.push(t);return yn(n)}static ignoreTarget(t){if(!Di.isTouchDevice())return Dt.None;Di.INSTANCE||(Di.INSTANCE=new Di);let n=Di.INSTANCE.ignoreTargets.push(t);return yn(n)}static isTouchDevice(){return"ontouchstart"in la||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let l=t.targetTouches.item(r);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let d=this.newGestureEvent(_r.Start,l.target);d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,d=n.changedTouches.length;l<d;l++){let f=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let g=this.activeTouches[f.identifier],p=Date.now()-g.initialTimeStamp;if(p<Di.HOLD_DELAY&&Math.abs(g.initialPageX-hs(g.rollingPageX))<30&&Math.abs(g.initialPageY-hs(g.rollingPageY))<30){let b=this.newGestureEvent(_r.Tap,g.initialTarget);b.pageX=hs(g.rollingPageX),b.pageY=hs(g.rollingPageY),this.dispatchEvent(b)}else if(p>=Di.HOLD_DELAY&&Math.abs(g.initialPageX-hs(g.rollingPageX))<30&&Math.abs(g.initialPageY-hs(g.rollingPageY))<30){let b=this.newGestureEvent(_r.Contextmenu,g.initialTarget);b.pageX=hs(g.rollingPageX),b.pageY=hs(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=hs(g.rollingPageX),_=hs(g.rollingPageY),w=hs(g.rollingTimestamps)-g.rollingTimestamps[0],C=b-g.rollingPageX[0],x=_-g.rollingPageY[0],T=[...this.targets].filter(A=>g.initialTarget instanceof Node&&A.contains(g.initialTarget));this.inertia(t,T,r,Math.abs(C)/w,C>0?1:-1,b,Math.abs(x)/w,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(_r.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===_r.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>Di.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===_r.Change||t.type===_r.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==r;)o++,l=l.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,l,d,f,g,p){this.handle=yy(t,()=>{let b=Date.now(),_=b-r,w=0,C=0,x=!0;o+=Di.SCROLL_FRICTION*_,f+=Di.SCROLL_FRICTION*_,o>0&&(x=!1,w=l*o*_),f>0&&(x=!1,C=g*f*_);let T=this.newGestureEvent(_r.Change);T.translationX=w,T.translationY=C,n.forEach(A=>A.dispatchEvent(T)),x||this.inertia(t,n,b,o,l,d+w,f,g,p+C)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let l=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let d=this.activeTouches[l.identifier],f=this.newGestureEvent(_r.Change,d.initialTarget);f.translationX=l.pageX-hs(d.rollingPageX),f.translationY=l.pageY-hs(d.rollingPageY),f.pageX=l.pageX,f.pageY=l.pageY,this.dispatchEvent(f),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(l.pageX),d.rollingPageY.push(l.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Fu.SCROLL_FRICTION=-.005,Fu.HOLD_DELAY=700,Fu.CLEAR_TAP_COUNT_TIME=400,jn([o3],Fu,"isTouchDevice",1);var l3=Fu,Sy=class extends Dt{onclick(e,t){this._register(vt(e,ui.CLICK,n=>t(new Zh(yr(e),n))))}onmousedown(e,t){this._register(vt(e,ui.MOUSE_DOWN,n=>t(new Zh(yr(e),n))))}onmouseover(e,t){this._register(vt(e,ui.MOUSE_OVER,n=>t(new Zh(yr(e),n))))}onmouseleave(e,t){this._register(vt(e,ui.MOUSE_LEAVE,n=>t(new Zh(yr(e),n))))}onkeydown(e,t){this._register(vt(e,ui.KEY_DOWN,n=>t(new G1(n))))}onkeyup(e,t){this._register(vt(e,ui.KEY_UP,n=>t(new G1(n))))}oninput(e,t){this._register(vt(e,ui.INPUT,t))}onblur(e,t){this._register(vt(e,ui.BLUR,t))}onfocus(e,t){this._register(vt(e,ui.FOCUS,t))}onchange(e,t){this._register(vt(e,ui.CHANGE,t))}ignoreGesture(e){return l3.ignoreTarget(e)}},tx=11,c3=class extends Sy{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=tx+"px",this.domNode.style.height=tx+"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 FT),this._register(J1(this.bgDomNode,ui.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(J1(this.domNode,ui.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new s3),this._pointerdownScheduleRepeatTimer=this._register(new by)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,yr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},u3=class E_{constructor(t,n,r,o,l,d,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,l=l|0,d=d|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),l<0&&(l=0),f+l>d&&(f=d-l),f<0&&(f=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=l,this.scrollHeight=d,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new E_(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new E_(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:d,scrollHeightChanged:f,scrollTopChanged:g}}},d3=class extends Dt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new $e),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new u3(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new ix(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=ix.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},nx=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Jg(e,t){let n=t-e;return function(r){return e+n*p3(r)}}function h3(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var ix=class R_{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let o,l;return t<n?(o=t+.75*r,l=n-.75*r):(o=t-.75*r,l=n+.75*r),h3(Jg(t,o),Jg(l,n),.33)}return Jg(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new nx(r,o,!1)}return new nx(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return R_.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new R_(t,n,o,r)}};function f3(e){return Math.pow(e,3)}function p3(e){return 1-f3(1-e)}var m3=class extends Dt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new by)}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":"")))}},g3=140,WT=class extends Sy{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 m3(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new FT),this._shouldRender=!0,this.domNode=rd(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(vt(this.domNode.domNode,ui.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new c3(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=rd(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(vt(this.slider.domNode,ui.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=r3(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),d=Math.abs(l-n);if(zT&&d>g3){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(f))},()=>{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()}},KT=class D_{constructor(t,n,r,o,l,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new D_(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,l){let d=Math.max(0,r-t),f=Math.max(0,d-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*f/o))),b=(f-p)/(o-r),_=l*b;return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:b,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=D_._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},v3=class extends WT{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new KT(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},_3=class extends WT{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new KT(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},b3=500,sx=50,y3=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},N_=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-r);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(vy){let n=yr(t.browserEvent),r=Mj(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,l=new y3(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=l,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]=l),l.score=this._computeScore(l,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),d=Math.abs(n.deltaX),f=Math.abs(n.deltaY),g=Math.max(Math.min(o,d),1),p=Math.max(Math.min(l,f),1),b=Math.max(o,d),_=Math.max(l,f);b%g===0&&_%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};N_.INSTANCE=new N_;var S3=N_,w3=class extends Sy{constructor(e,t,n){super(),this._onScroll=this._register(new $e),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new $e),this.onWillScroll=this._onWillScroll.event,this._options=C3(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new _3(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new v3(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=rd(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=rd(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=rd(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 by),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ml(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,Sr&&(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 Z1(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ml(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Z1(n))};this._mouseWheelToDispose.push(vt(this._listenOnDomNode,ui.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=S3.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,l=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&l+o===0?l=o=0:Math.abs(o)>=Math.abs(l)?l=0:o=0),this._options.flipAxes&&([o,l]=[l,o]);let d=!Sr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!l&&(l=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(l=l*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=sx*o,b=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,b)}if(l){let p=sx*l,b=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(f.scrollLeft!==g.scrollLeft||f.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),b3)}},x3=class extends w3{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function C3(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,Sr&&(t.className+=" mac"),t}var M_=class extends Dt{constructor(e,t,n,r,o,l,d,f){super(),this._bufferService=n,this._optionsService=d,this._renderService=f,this._onRequestScrollLines=this._register(new $e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new d3({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>yy(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new x3(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ci.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(yn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(yn(()=>this._styleElement.remove())),this._register(Ci.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.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(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};M_=jn([Ve(2,Fi),Ve(3,pa),Ve(4,kT),Ve(5,zc),Ve(6,Wi),Ve(7,ma)],M_);var A_=class extends Dt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(yn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};A_=jn([Ve(1,Fi),Ve(2,pa),Ve(3,Id),Ve(4,ma)],A_);var k3=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},gr={full:0,left:0,center:0,right:0},Za={full:0,left:0,center:0,right:0},Lu={full:0,left:0,center:0,right:0},Wf=class extends Dt{constructor(e,t,n,r,o,l,d,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=l,this._themeService=d,this._coreBrowserService=f,this._colorZoneStore=new k3,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(yn(()=>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);Za.full=this._canvas.width,Za.left=e,Za.center=t,Za.right=e,this._refreshDrawHeightConstants(),Lu.full=1,Lu.left=1,Lu.center=1+Za.left,Lu.right=1+Za.left+Za.center}_refreshDrawHeightConstants(){gr.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);gr.left=t,gr.center=t,gr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gr.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(Lu[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-gr[e.position||"full"]/2),Za[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+gr[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}))}};Wf=jn([Ve(2,Fi),Ve(3,Id),Ve(4,ma),Ve(5,Wi),Ve(6,zc),Ve(7,pa)],Wf);var Ne;(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=""))(Ne||={});var yf;(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=""))(yf||={});var qT;(e=>e.ST=`${Ne.ESC}\\`)(qT||={});var L_=class{constructor(e,t,n,r,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Ne.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};L_=jn([Ve(2,Fi),Ve(3,Wi),Ve(4,_l),Ve(5,ma)],L_);var hi=0,fi=0,pi=0,An=0,rx={css:"#00000000",rgba:0},Gn;(e=>{function t(o,l,d,f){return f!==void 0?`#${nl(o)}${nl(l)}${nl(d)}${nl(f)}`:`#${nl(o)}${nl(l)}${nl(d)}`}e.toCss=t;function n(o,l,d,f=255){return(o<<24|l<<16|d<<8|f)>>>0}e.toRgba=n;function r(o,l,d,f){return{css:e.toCss(o,l,d,f),rgba:e.toRgba(o,l,d,f)}}e.toColor=r})(Gn||={});var vn;(e=>{function t(g,p){if(An=(p.rgba&255)/255,An===1)return{css:p.css,rgba:p.rgba};let b=p.rgba>>24&255,_=p.rgba>>16&255,w=p.rgba>>8&255,C=g.rgba>>24&255,x=g.rgba>>16&255,T=g.rgba>>8&255;hi=C+Math.round((b-C)*An),fi=x+Math.round((_-x)*An),pi=T+Math.round((w-T)*An);let A=Gn.toCss(hi,fi,pi),M=Gn.toRgba(hi,fi,pi);return{css:A,rgba:M}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,b){let _=Sf.ensureContrastRatio(g.rgba,p.rgba,b);if(_)return Gn.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[hi,fi,pi]=Sf.toChannels(p),{css:Gn.toCss(hi,fi,pi),rgba:p}}e.opaque=o;function l(g,p){return An=Math.round(p*255),[hi,fi,pi]=Sf.toChannels(g.rgba),{css:Gn.toCss(hi,fi,pi,An),rgba:Gn.toRgba(hi,fi,pi,An)}}e.opacity=l;function d(g,p){return An=g.rgba&255,l(g,An*p/255)}e.multiplyOpacity=d;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(vn||={});var kn;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return hi=parseInt(o.slice(1,2).repeat(2),16),fi=parseInt(o.slice(2,3).repeat(2),16),pi=parseInt(o.slice(3,4).repeat(2),16),Gn.toColor(hi,fi,pi);case 5:return hi=parseInt(o.slice(1,2).repeat(2),16),fi=parseInt(o.slice(2,3).repeat(2),16),pi=parseInt(o.slice(3,4).repeat(2),16),An=parseInt(o.slice(4,5).repeat(2),16),Gn.toColor(hi,fi,pi,An);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 l=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(l)return hi=parseInt(l[1]),fi=parseInt(l[2]),pi=parseInt(l[3]),An=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),Gn.toColor(hi,fi,pi,An);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[hi,fi,pi,An]=t.getImageData(0,0,1,1).data,An!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Gn.toRgba(hi,fi,pi,An),css:o}}e.toColor=r})(kn||={});var Ui;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,l){let d=r/255,f=o/255,g=l/255,p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),b=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+b*.7152+_*.0722}e.relativeLuminance2=n})(Ui||={});var Sf;(e=>{function t(d,f){if(An=(f&255)/255,An===1)return f;let g=f>>24&255,p=f>>16&255,b=f>>8&255,_=d>>24&255,w=d>>16&255,C=d>>8&255;return hi=_+Math.round((g-_)*An),fi=w+Math.round((p-w)*An),pi=C+Math.round((b-C)*An),Gn.toRgba(hi,fi,pi)}e.blend=t;function n(d,f,g){let p=Ui.relativeLuminance(d>>8),b=Ui.relativeLuminance(f>>8);if(ta(p,b)<g){if(b<p){let C=r(d,f,g),x=ta(p,Ui.relativeLuminance(C>>8));if(x<g){let T=o(d,f,g),A=ta(p,Ui.relativeLuminance(T>>8));return x>A?C:T}return C}let _=o(d,f,g),w=ta(p,Ui.relativeLuminance(_>>8));if(w<g){let C=r(d,f,g),x=ta(p,Ui.relativeLuminance(C>>8));return w>x?_:C}return _}}e.ensureContrastRatio=n;function r(d,f,g){let p=d>>24&255,b=d>>16&255,_=d>>8&255,w=f>>24&255,C=f>>16&255,x=f>>8&255,T=ta(Ui.relativeLuminance2(w,C,x),Ui.relativeLuminance2(p,b,_));for(;T<g&&(w>0||C>0||x>0);)w-=Math.max(0,Math.ceil(w*.1)),C-=Math.max(0,Math.ceil(C*.1)),x-=Math.max(0,Math.ceil(x*.1)),T=ta(Ui.relativeLuminance2(w,C,x),Ui.relativeLuminance2(p,b,_));return(w<<24|C<<16|x<<8|255)>>>0}e.reduceLuminance=r;function o(d,f,g){let p=d>>24&255,b=d>>16&255,_=d>>8&255,w=f>>24&255,C=f>>16&255,x=f>>8&255,T=ta(Ui.relativeLuminance2(w,C,x),Ui.relativeLuminance2(p,b,_));for(;T<g&&(w<255||C<255||x<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),T=ta(Ui.relativeLuminance2(w,C,x),Ui.relativeLuminance2(p,b,_));return(w<<24|C<<16|x<<8|255)>>>0}e.increaseLuminance=o;function l(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=l})(Sf||={});function nl(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ta(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var T3=class extends Bd{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ps}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,l=0,d=0,f=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(p-o>1){let b=this._getJoinedRanges(r,d,l,t,o);for(let _=0;_<b.length;_++)n.push(b[_])}o=p,d=l,f=this._workCell.fg,g=this._workCell.bg}l+=this._workCell.getChars().length||ao.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,d,l,t,o);for(let b=0;b<p.length;b++)n.push(p[b])}return n}_getJoinedRanges(e,t,n,r,o){let l=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(l)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let g=this._characterJoiners[f].handler(l);for(let p=0;p<g.length;p++)Kf._mergeRanges(d,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(d,r,o),d}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,l=0,d=e[r];if(d){for(let f=n;f<this._bufferService.cols;f++){let g=t.getWidth(f),p=t.getString(f).length||ao.length;if(g!==0){if(!o&&d[0]<=l&&(d[0]=f,o=!0),d[1]<=l){if(d[1]=f,d=e[++r],!d)break;d[0]<=l?(d[0]=f,o=!0):o=!1}l+=p}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Kf=jn([Ve(0,Fi)],Kf);function E3(e){return 57508<=e&&e<=57558}function R3(e){return 9472<=e&&e<=9631}function D3(e){return E3(e)||R3(e)}function N3(){return{css:{canvas:Qh(),cell:Qh()},device:{canvas:Qh(),cell:Qh(),char:{width:0,height:0,left:0,top:0}}}}function Qh(){return{width:0,height:0}}var j_=class{constructor(e,t,n,r,o,l,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=l,this._themeService=d,this._workCell=new Ps,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,l,d,f,g,p,b){let _=[],w=this._characterJoinerService.getJoinedCharacters(t),C=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<l+1&&(x=l+1);let T,A=0,M="",W=0,U=0,P=0,F=0,V=!1,O=0,G=!1,fe=0,ee=0,te=[],$=p!==-1&&b!==-1;for(let Z=0;Z<x;Z++){e.loadCell(Z,this._workCell);let ie=this._workCell.getWidth();if(ie===0)continue;let J=!1,j=Z>=ee,R=Z,I=this._workCell;if(w.length>0&&Z===w[0][0]&&j){let L=w.shift(),ve=this._isCellInSelection(L[0],t);for(W=L[0]+1;W<L[1];W++)j&&=ve===this._isCellInSelection(W,t);j&&=!n||l<L[0]||l>=L[1],j?(J=!0,I=new T3(this._workCell,e.translateToString(!0,L[0],L[1]),L[1]-L[0]),R=L[1]-1,ie=I.getWidth()):ee=L[1]}let re=this._isCellInSelection(Z,t),_e=n&&Z===l,N=$&&Z>=p&&Z<=b,Y=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,L=>{Y=!0});let oe=I.getChars()||ao;if(oe===" "&&(I.isUnderline()||I.isOverline())&&(oe=" "),fe=ie*f-g.get(oe,I.isBold(),I.isItalic()),!T)T=this._document.createElement("span");else if(A&&(re&&G||!re&&!G&&I.bg===U)&&(re&&G&&C.selectionForeground||I.fg===P)&&I.extended.ext===F&&N===V&&fe===O&&!_e&&!J&&!Y&&j){I.isInvisible()?M+=ao:M+=oe,A++;continue}else A&&(T.textContent=M),T=this._document.createElement("span"),A=0,M="";if(U=I.bg,P=I.fg,F=I.extended.ext,V=N,O=fe,G=re,J&&l>=Z&&l<=R&&(l=Z),!this._coreService.isCursorHidden&&_e&&this._coreService.isCursorInitialized){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&te.push("xterm-cursor-blink"),te.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline");break}}if(I.isBold()&&te.push("xterm-bold"),I.isItalic()&&te.push("xterm-italic"),I.isDim()&&te.push("xterm-dim"),I.isInvisible()?M=ao:M=I.getChars()||ao,I.isUnderline()&&(te.push(`xterm-underline-${I.extended.underlineStyle}`),M===" "&&(M=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Bd.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let L=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&L<8&&(L+=8),T.style.textDecorationColor=C.ansi[L].css}I.isOverline()&&(te.push("xterm-overline"),M===" "&&(M=" ")),I.isStrikethrough()&&te.push("xterm-strikethrough"),N&&(T.style.textDecoration="underline");let Q=I.getFgColor(),we=I.getFgColorMode(),Se=I.getBgColor(),ue=I.getBgColorMode(),Re=!!I.isInverse();if(Re){let L=Q;Q=Se,Se=L;let ve=we;we=ue,ue=ve}let Oe,ge,He=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,L=>{L.options.layer!=="top"&&He||(L.backgroundColorRGB&&(ue=50331648,Se=L.backgroundColorRGB.rgba>>8&16777215,Oe=L.backgroundColorRGB),L.foregroundColorRGB&&(we=50331648,Q=L.foregroundColorRGB.rgba>>8&16777215,ge=L.foregroundColorRGB),He=L.options.layer==="top")}),!He&&re&&(Oe=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,Se=Oe.rgba>>8&16777215,ue=50331648,He=!0,C.selectionForeground&&(we=50331648,Q=C.selectionForeground.rgba>>8&16777215,ge=C.selectionForeground)),He&&te.push("xterm-decoration-top");let Be;switch(ue){case 16777216:case 33554432:Be=C.ansi[Se],te.push(`xterm-bg-${Se}`);break;case 50331648:Be=Gn.toColor(Se>>16,Se>>8&255,Se&255),this._addStyle(T,`background-color:#${ax((Se>>>0).toString(16),"0",6)}`);break;default:Re?(Be=C.foreground,te.push("xterm-bg-257")):Be=C.background}switch(Oe||I.isDim()&&(Oe=vn.multiplyOpacity(Be,.5)),we){case 16777216:case 33554432:I.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(T,Be,C.ansi[Q],I,Oe,void 0)||te.push(`xterm-fg-${Q}`);break;case 50331648:let L=Gn.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(T,Be,L,I,Oe,ge)||this._addStyle(T,`color:#${ax(Q.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Be,C.foreground,I,Oe,ge)||Re&&te.push("xterm-fg-257")}te.length&&(T.className=te.join(" "),te.length=0),!_e&&!J&&!Y&&j?A++:T.textContent=M,fe!==this.defaultSpacing&&(T.style.letterSpacing=`${fe}px`),_.push(T),Z=R}return T&&A&&(T.textContent=M),_}_applyMinimumContrast(e,t,n,r,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||D3(r.getCode()))return!1;let d=this._getContrastCache(r),f;if(!o&&!l&&(f=d.getColor(t.rgba,n.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=vn.ensureContrastRatio(o||t,l||n,g),d.setColor((o||t).rgba,(l||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};j_=jn([Ve(1,RT),Ve(2,Wi),Ve(3,pa),Ve(4,_l),Ve(5,Id),Ve(6,zc)],j_);function ax(e,t,n){for(;e.length<n;)e=t+e;return e}var M3=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,r,o,l],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let d=this._measure(e,0);return d>0&&(this._flat[r]=d),d}let o=e;t&&(o+="B"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let d=0;t&&(d|=1),n&&(d|=2),l=this._measure(e,d),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},A3=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,d=n[1]-o,f=Math.max(l,0),g=Math.min(d,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=f,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function L3(){return new A3}var ev="xterm-dom-renderer-owner-",As="xterm-rows",Jh="xterm-fg-",ox="xterm-bg-",ju="xterm-focus",ef="xterm-selection",j3=1,O_=class extends Dt{constructor(e,t,n,r,o,l,d,f,g,p,b,_,w,C){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=l,this._linkifier2=d,this._charSizeService=g,this._optionsService=p,this._bufferService=b,this._coreService=_,this._coreBrowserService=w,this._themeService=C,this._terminalClass=j3++,this._rowElements=[],this._selectionRenderModel=L3(),this.onRequestRedraw=this._register(new $e).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(As),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(ef),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=N3(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(j_,document),this._element.classList.add(ev+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(yn(()=>{this._element.classList.remove(ev+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new M3(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${As} 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} .${As} { 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} .${As} .xterm-dim { color: ${vn.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${As}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${As}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${As}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${As} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${As} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${As} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${As} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${As} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ef} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ef} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ef} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,d]of e.ansi.entries())t+=`${this._terminalSelector} .${Jh}${l} { color: ${d.css}; }${this._terminalSelector} .${Jh}${l}.xterm-dim { color: ${vn.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${ox}${l} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${Jh}257 { color: ${vn.opaque(e.background).css}; }${this._terminalSelector} .${Jh}257.xterm-dim { color: ${vn.multiplyOpacity(vn.opaque(e.background),.5).css}; }${this._terminalSelector} .${ox}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ju),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ju),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];f.appendChild(this._createSelectionElement(l,g?t[0]:e[0],g?e[0]:t[0],d-l+1))}else{let g=r===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(l,g,p));let b=d-l-1;if(f.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,b)),l!==d){let _=o===d?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(d,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return l+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-l),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}px`,o.style.width=`${d}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+n.ydisp,b=this._rowElements[g],_=n.lines.get(p);if(!b||!_)break;b.replaceChildren(...this._rowFactory.createRow(_,p,p===r,d,f,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ev}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,l){n<0&&(e=0),r<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),r=Math.max(Math.min(r,d),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,g=f.ybase+f.y,p=Math.min(f.x,o-1),b=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let C=n;C<=r;++C){let x=C+f.ydisp,T=this._rowElements[C],A=f.lines.get(x);if(!T||!A)break;T.replaceChildren(...this._rowFactory.createRow(A,x,x===g,_,w,p,b,this.dimensions.css.cell.width,this._widthCache,l?C===n?e:0:-1,l?(C===r?t:o)-1:-1))}}};O_=jn([Ve(7,py),Ve(8,Tp),Ve(9,Wi),Ve(10,Fi),Ve(11,_l),Ve(12,pa),Ve(13,zc)],O_);var B_=class extends Dt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new $e),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new B3(this._optionsService))}catch{this._measureStrategy=this._register(new O3(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())}};B_=jn([Ve(2,Wi)],B_);var VT=class extends Dt{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)}},O3=class extends VT{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},B3=class extends VT{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}},I3=class extends Dt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new P3(this._window)),this._onDprChange=this._register(new $e),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new $e),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ci.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(vt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(vt(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}},P3=class extends Dt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ac),this._onDprChange=this._register(new $e),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(yn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=vt(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)}},z3=class extends Dt{constructor(){super(),this.linkProviders=[],this._register(yn(()=>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 wy(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),d=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-l,t.clientY-r.top-d]}function H3(e,t,n,r,o,l,d,f,g){if(!l)return;let p=wy(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?d/2:0))/d),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var I_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return H3(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=wy(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};I_=jn([Ve(0,ma),Ve(1,Tp)],I_);var U3=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},YT={};ZL(YT,{getSafariVersion:()=>F3,isChromeOS:()=>QT,isFirefox:()=>GT,isIpad:()=>W3,isIphone:()=>K3,isLegacyEdge:()=>$3,isLinux:()=>xy,isMac:()=>qf,isNode:()=>Ep,isSafari:()=>XT,isWindows:()=>ZT});var Ep=typeof process<"u"&&"title"in process,Pd=Ep?"node":navigator.userAgent,zd=Ep?"node":navigator.platform,GT=Pd.includes("Firefox"),$3=Pd.includes("Edge"),XT=/^((?!chrome|android).)*safari/i.test(Pd);function F3(){if(!XT)return 0;let e=Pd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var qf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(zd),W3=zd==="iPad",K3=zd==="iPhone",ZT=["Windows","Win16","Win32","WinCE"].includes(zd),xy=zd.indexOf("Linux")>=0,QT=/\bCrOS\b/.test(Pd),JT=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},q3=class extends JT{_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())}}},V3=class extends JT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Vf=!Ep&&"requestIdleCallback"in window?V3:q3,Y3=class{constructor(){this._queue=new Vf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},P_=class extends Dt{constructor(e,t,n,r,o,l,d,f,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Ac),this._pausedResizeTask=new Y3,this._observerDisposable=this._register(new Ac),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 $e),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new $e),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new $e),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new $e),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new U3((p,b)=>this._renderRows(p,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new G3(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(yn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=yn(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};P_=jn([Ve(2,Wi),Ve(3,Tp),Ve(4,_l),Ve(5,Id),Ve(6,Fi),Ve(7,pa),Ve(8,zc)],P_);var G3=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function X3(e,t,n,r){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return J3(o,l,e,t,n,r)+Rp(l,t,n,r)+eO(o,l,e,t,n,r);let d;if(l===t)return d=o>e?"D":"C",md(Math.abs(o-e),pd(d,r));d=l>t?"D":"C";let f=Math.abs(l-t),g=Q3(l>t?e:o,n)+(f-1)*n.cols+1+Z3(l>t?o:e);return md(g,pd(d,r))}function Z3(e,t){return e-1}function Q3(e,t){return t.cols-e}function J3(e,t,n,r,o,l){return Rp(t,r,o,l).length===0?"":md(tE(e,t,e,t-gl(t,o),!1,o).length,pd("D",l))}function Rp(e,t,n,r){let o=e-gl(e,n),l=t-gl(t,n),d=Math.abs(o-l)-tO(e,t,n);return md(d,pd(eE(e,t),r))}function eO(e,t,n,r,o,l){let d;Rp(t,r,o,l).length>0?d=r-gl(r,o):d=t;let f=r,g=nO(e,t,n,r,o,l);return md(tE(e,d,n,f,g==="C",o).length,pd(g,l))}function tO(e,t,n){let r=0,o=e-gl(e,n),l=t-gl(t,n);for(let d=0;d<Math.abs(o-l);d++){let f=eE(e,t)==="A"?-1:1;n.buffer.lines.get(o+f*d)?.isWrapped&&r++}return r}function gl(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function nO(e,t,n,r,o,l){let d;return Rp(n,r,o,l).length>0?d=r-gl(r,o):d=t,e<n&&d<=r||e>=n&&d<r?"C":"D"}function eE(e,t){return e>t?"A":"B"}function tE(e,t,n,r,o,l){let d=e,f=t,g="";for(;(d!==n||f!==r)&&f>=0&&f<l.buffer.lines.length;)d+=o?1:-1,o&&d>l.cols-1?(g+=l.buffer.translateBufferLineToString(f,!1,e,d),d=0,e=0,f++):!o&&d<0&&(g+=l.buffer.translateBufferLineToString(f,!1,0,e+1),d=l.cols-1,e=d,f--);return g+l.buffer.translateBufferLineToString(f,!1,e,d)}function pd(e,t){let n=t?"O":"[";return Ne.ESC+n+e}function md(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var iO=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 lx(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 tv=50,sO=15,rO=50,aO=500,oO=" ",lO=new RegExp(oO,"g"),z_=class extends Dt{constructor(e,t,n,r,o,l,d,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=l,this._optionsService=d,this._renderService=f,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ps,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new $e),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new $e),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new $e),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new $e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new iO(this._bufferService),this._activeSelectionMode=0,this._register(yn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let f=n.translateBufferLineToString(d,!0,o,l);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let d=n.lines.get(l),f=n.translateBufferLineToString(l,!0);d?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?r[r.length-1]+=d:r.push(d)}}return r.map(o=>o.replace(lO," ")).join(ZT?`\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())),xy&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=lx(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=wy(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-tv),tv),t/=tv,t/Math.abs(t)+Math.round(t*(sO-1)))}shouldForceSelection(e){return qf?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(),rO)}_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&&!(qf&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<aO&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=X3(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let d=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(l,e[0]),g=f,p=e[0]-f,b=0,_=0,w=0,C=0;if(d.charAt(f)===" "){for(;f>0&&d.charAt(f-1)===" ";)f--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let A=e[0],M=e[0];l.getWidth(A)===0&&(b++,A--),l.getWidth(M)===2&&(_++,M++);let W=l.getString(M).length;for(W>1&&(C+=W-1,g+=W-1);A>0&&f>0&&!this._isCharWordSeparator(l.loadCell(A-1,this._workCell));){l.loadCell(A-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,A--):U>1&&(w+=U-1,f-=U-1),f--,A--}for(;M<l.length&&g+1<d.length&&!this._isCharWordSeparator(l.loadCell(M+1,this._workCell));){l.loadCell(M+1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,M++):U>1&&(C+=U-1,g+=U-1),g++,M++}}g++;let x=f+p-b+w,T=Math.min(this._bufferService.cols,g-f+b+_-w-C);if(!(!t&&d.slice(f,g).trim()==="")){if(n&&x===0&&l.getCodePoint(0)!==32){let A=o.lines.get(e[1]-1);if(A&&l.isWrapped&&A.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let W=this._bufferService.cols-M.start;x-=W,T+=W}}}if(r&&x+T===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let A=o.lines.get(e[1]+1);if(A?.isWrapped&&A.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(T+=M.length)}}return{start:x,length:T}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=lx(n,this._bufferService.cols)}};z_=jn([Ve(3,Fi),Ve(4,_l),Ve(5,my),Ve(6,Wi),Ve(7,ma),Ve(8,pa)],z_);var cx=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},ux=class{constructor(){this._color=new cx,this._css=new cx}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ei=Object.freeze((()=>{let e=[kn.toColor("#2e3436"),kn.toColor("#cc0000"),kn.toColor("#4e9a06"),kn.toColor("#c4a000"),kn.toColor("#3465a4"),kn.toColor("#75507b"),kn.toColor("#06989a"),kn.toColor("#d3d7cf"),kn.toColor("#555753"),kn.toColor("#ef2929"),kn.toColor("#8ae234"),kn.toColor("#fce94f"),kn.toColor("#729fcf"),kn.toColor("#ad7fa8"),kn.toColor("#34e2e2"),kn.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],l=t[n%6];e.push({css:Gn.toCss(r,o,l),rgba:Gn.toRgba(r,o,l)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Gn.toCss(r,r,r),rgba:Gn.toRgba(r,r,r)})}return e})()),il=kn.toColor("#ffffff"),Wu=kn.toColor("#000000"),dx=kn.toColor("#ffffff"),hx=Wu,Ou={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},cO=il,H_=class extends Dt{constructor(e){super(),this._optionsService=e,this._contrastCache=new ux,this._halfContrastCache=new ux,this._onChangeColors=this._register(new $e),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:il,background:Wu,cursor:dx,cursorAccent:hx,selectionForeground:void 0,selectionBackgroundTransparent:Ou,selectionBackgroundOpaque:vn.blend(Wu,Ou),selectionInactiveBackgroundTransparent:Ou,selectionInactiveBackgroundOpaque:vn.blend(Wu,Ou),scrollbarSliderBackground:vn.opacity(il,.2),scrollbarSliderHoverBackground:vn.opacity(il,.4),scrollbarSliderActiveBackground:vn.opacity(il,.5),overviewRulerBorder:il,ansi:ei.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=sn(e.foreground,il),t.background=sn(e.background,Wu),t.cursor=vn.blend(t.background,sn(e.cursor,dx)),t.cursorAccent=vn.blend(t.background,sn(e.cursorAccent,hx)),t.selectionBackgroundTransparent=sn(e.selectionBackground,Ou),t.selectionBackgroundOpaque=vn.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=sn(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vn.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?sn(e.selectionForeground,rx):void 0,t.selectionForeground===rx&&(t.selectionForeground=void 0),vn.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=vn.opacity(t.selectionBackgroundTransparent,.3)),vn.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=vn.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=sn(e.scrollbarSliderBackground,vn.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=sn(e.scrollbarSliderHoverBackground,vn.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=sn(e.scrollbarSliderActiveBackground,vn.opacity(t.foreground,.5)),t.overviewRulerBorder=sn(e.overviewRulerBorder,cO),t.ansi=ei.slice(),t.ansi[0]=sn(e.black,ei[0]),t.ansi[1]=sn(e.red,ei[1]),t.ansi[2]=sn(e.green,ei[2]),t.ansi[3]=sn(e.yellow,ei[3]),t.ansi[4]=sn(e.blue,ei[4]),t.ansi[5]=sn(e.magenta,ei[5]),t.ansi[6]=sn(e.cyan,ei[6]),t.ansi[7]=sn(e.white,ei[7]),t.ansi[8]=sn(e.brightBlack,ei[8]),t.ansi[9]=sn(e.brightRed,ei[9]),t.ansi[10]=sn(e.brightGreen,ei[10]),t.ansi[11]=sn(e.brightYellow,ei[11]),t.ansi[12]=sn(e.brightBlue,ei[12]),t.ansi[13]=sn(e.brightMagenta,ei[13]),t.ansi[14]=sn(e.brightCyan,ei[14]),t.ansi[15]=sn(e.brightWhite,ei[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=sn(e.extendedAnsi[r],ei[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};H_=jn([Ve(0,Wi)],H_);function sn(e,t){if(e!==void 0)try{return kn.toColor(e)}catch{}return t}var uO=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},dO=class{constructor(){this._services=new uO,this._services.set(py,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=sj(e).sort((l,d)=>l.index-d.index),r=[];for(let l of n){let d=this._services.get(l.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);r.push(d)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},hO={trace:0,debug:1,info:2,warn:3,error:4,off:5},fO="xterm.js: ",U_=class extends Dt{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=hO[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":fO)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};U_=jn([Ve(0,Wi)],U_);var fx=class extends Dt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new $e),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new $e),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new $e),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Rt=3,Yn=Object.freeze(new Bd),tf=0,nv=2,Ku=class nE{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Rt);let o=n||Ps.fromCharData([0,ST,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*Rt+0],r=n&2097151;return[this._data[t*Rt+1],n&2097152?this._combined[t]:r?io(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Rt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Rt+0]=t|2097152|n[2]<<22):this._data[t*Rt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Rt+0]>>22}hasWidth(t){return this._data[t*Rt+0]&12582912}getFg(t){return this._data[t*Rt+1]}getBg(t){return this._data[t*Rt+2]}hasContent(t){return this._data[t*Rt+0]&4194303}getCodePoint(t){let n=this._data[t*Rt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Rt+0]&2097152}getString(t){let n=this._data[t*Rt+0];return n&2097152?this._combined[t]:n&2097151?io(n&2097151):""}isProtected(t){return this._data[t*Rt+2]&536870912}loadCell(t,n){return tf=t*Rt,n.content=this._data[tf+0],n.fg=this._data[tf+1],n.bg=this._data[tf+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Rt+0]=n.content,this._data[t*Rt+1]=n.fg,this._data[t*Rt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Rt+0]=n|r<<22,this._data[t*Rt+1]=o.fg,this._data[t*Rt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*Rt+0];o&2097152?this._combined[t]+=io(n):o&2097151?(this._combined[t]=io(o&2097151)+io(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*Rt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new Ps;for(let l=this.length-t-n-1;l>=0;--l)this.setCell(t+n+l,this.loadCell(t+l,o));for(let l=0;l<n;++l)this.setCell(t+l,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new Ps;for(let l=0;l<this.length-t-n;++l)this.setCell(t+l,this.loadCell(t+n+l,o));for(let l=this.length-n;l<this.length;++l)this.setCell(l,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*nv<this._data.buffer.byteLength;let r=t*Rt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let d=0;d<o.length;d++){let f=parseInt(o[d],10);f>=t&&delete this._combined[f]}let l=Object.keys(this._extendedAttrs);for(let d=0;d<l.length;d++){let f=parseInt(l[d],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*nv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*nv<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new nE(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Rt+0]&4194303)return t+(this._data[t*Rt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Rt+0]&4194303||this._data[t*Rt+2]&50331648)return t+(this._data[t*Rt+0]>>22);return 0}copyCellsFrom(t,n,r,o,l){let d=t._data;if(l)for(let g=o-1;g>=0;g--){for(let p=0;p<Rt;p++)this._data[(r+g)*Rt+p]=d[(n+g)*Rt+p];d[(n+g)*Rt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<Rt;p++)this._data[(r+g)*Rt+p]=d[(n+g)*Rt+p];d[(n+g)*Rt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let p=parseInt(f[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;n<r;){let d=this._data[n*Rt+0],f=d&2097151,g=d&2097152?this._combined[n]:f?io(f):ao;if(l+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=d>>22||1}return o&&o.push(n),l}};function pO(e,t,n,r,o,l){let d=[];for(let f=0;f<e.length-1;f++){let g=f,p=e.get(++g);if(!p.isWrapped)continue;let b=[e.get(f)];for(;g<e.length&&p.isWrapped;)b.push(p),p=e.get(++g);if(!l&&r>=f&&r<g){f+=b.length-1;continue}let _=0,w=gd(b,_,t),C=1,x=0;for(;C<b.length;){let A=gd(b,C,t),M=A-x,W=n-w,U=Math.min(M,W);b[_].copyCellsFrom(b[C],x,w,U,!1),w+=U,w===n&&(_++,w=0),x+=U,x===A&&(C++,x=0),w===0&&_!==0&&b[_-1].getWidth(n-1)===2&&(b[_].copyCellsFrom(b[_-1],n-1,w++,1,!1),b[_-1].setCell(n-1,o))}b[_].replaceCells(w,n,o);let T=0;for(let A=b.length-1;A>0&&(A>_||b[A].getTrimmedLength()===0);A--)T++;T>0&&(d.push(f+b.length-T),d.push(T)),f+=b.length-1}return d}function mO(e,t){let n=[],r=0,o=t[r],l=0;for(let d=0;d<e.length;d++)if(o===d){let f=t[++r];e.onDeleteEmitter.fire({index:d-l,amount:f}),d+=f-1,l+=f,o=t[++r]}else n.push(d);return{layout:n,countRemoved:l}}function gO(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function vO(e,t,n){let r=[],o=e.map((g,p)=>gd(e,p,t)).reduce((g,p)=>g+p),l=0,d=0,f=0;for(;f<o;){if(o-f<n){r.push(o-f);break}l+=n;let g=gd(e,d,t);l>g&&(l-=g,d++);let p=e[d].getWidth(l-1)===2;p&&l--;let b=p?n-1:n;r.push(b),f+=b}return r}function gd(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var iE=class sE{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=sE._nextId++,this._onDispose=this.register(new $e),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ml(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};iE._nextId=1;var _O=iE,ii={},sl=ii.B;ii[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:"≥","{":"π","|":"≠","}":"£","~":"·"};ii.A={"#":"£"};ii.B=void 0;ii[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ii.C=ii[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ii.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ii.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ii.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ii.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ii.E=ii[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ii.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ii.H=ii[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ii["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var px=4294967295,mx=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Yn.clone(),this.savedCharset=sl,this.markers=[],this._nullCell=Ps.fromCharData([0,ST,1,0]),this._whitespaceCell=Ps.fromCharData([0,ao,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Vf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new fx(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 Ff),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 Ff),this._whitespaceCell}getBlankLine(e,t){return new Ku(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>px?px:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Yn);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 fx(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Yn),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)r+=+this.lines.get(d).resize(e,n);let l=0;if(this._rows<t)for(let d=this._rows;d<t;d++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ku(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ku(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let d=this.lines.length-o;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),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 l=0;l<this.lines.length;l++)r+=+this.lines.get(l).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=pO(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Yn),n);if(r.length>0){let o=mO(this.lines,r);gO(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Yn),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ku(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Yn),o=[],l=0;for(let d=this.lines.length-1;d>=0;d--){let f=this.lines.get(d);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&d>0;)f=this.lines.get(--d),g.unshift(f);if(!n){let U=this.ybase+this.y;if(U>=d&&U<d+g.length)continue}let p=g[g.length-1].getTrimmedLength(),b=vO(g,this._cols,e),_=b.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+_):w=Math.max(0,this.lines.length-this.lines.maxLength+_);let C=[];for(let U=0;U<_;U++){let P=this.getBlankLine(Yn,!0);C.push(P)}C.length>0&&(o.push({start:d+g.length+l,newLines:C}),l+=C.length),g.push(...C);let x=b.length-1,T=b[x];T===0&&(x--,T=b[x]);let A=g.length-_-1,M=p;for(;A>=0;){let U=Math.min(M,T);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[A],M-U,T-U,U,!0),T-=U,T===0&&(x--,T=b[x]),M-=U,M===0){A--;let P=Math.max(A,0);M=gd(g,P,this._cols)}}for(let U=0;U<g.length;U++)b[U]<e&&g[U].setCell(b[U],r);let W=_-w;for(;W-- >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+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}if(o.length>0){let d=[],f=[];for(let T=0;T<this.lines.length;T++)f.push(this.lines.get(T));let g=this.lines.length,p=g-1,b=0,_=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let w=0;for(let T=Math.min(this.lines.maxLength-1,g+l-1);T>=0;T--)if(_&&_.start>p+w){for(let A=_.newLines.length-1;A>=0;A--)this.lines.set(T--,_.newLines[A]);T++,d.push({index:p+1,amount:_.newLines.length}),w+=_.newLines.length,_=o[++b]}else this.lines.set(T,f[p--]);let C=0;for(let T=d.length-1;T>=0;T--)d[T].index+=C,this.lines.onInsertEmitter.fire(d[T]),C+=d[T].amount;let x=Math.max(0,g+l-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new _O(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},bO=class extends Dt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new $e),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 mx(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new mx(!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)}},rE=2,aE=1,$_=class extends Dt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new $e),this.onResize=this._onResize.event,this._onScroll=this._register(new $e),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,rE),this.rows=Math.max(e.rawOptions.rows||0,aE),this.buffers=this._register(new bO(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;l===n.lines.length-1?d?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(l+1,0,r.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=l-o+1;n.lines.shiftElements(o+1,d-1,-1),n.lines.set(l,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};$_=jn([Ve(0,Wi)],$_);var oc={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:qf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},yO=["normal","bold","100","200","300","400","500","600","700","800","900"],SO=class extends Dt{constructor(e){super(),this._onOptionChange=this._register(new $e),this.onOptionChange=this._onOptionChange.event;let t={...oc};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(yn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in oc))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in oc))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=oc[e]),!wO(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=oc[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=yO.includes(t)?t:oc[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 wO(e){return e==="block"||e==="underline"||e==="bar"}function qu(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&qu(e[r],t-1);return n}var gx=Object.freeze({insertMode:!1}),vx=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),F_=class extends Dt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new $e),this.onData=this._onData.event,this._onUserInput=this._register(new $e),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new $e),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new $e),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=qu(gx),this.decPrivateModes=qu(vx)}reset(){this.modes=qu(gx),this.decPrivateModes=qu(vx)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};F_=jn([Ve(0,Fi),Ve(1,TT),Ve(2,Wi)],F_);var _x={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 iv(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var sv=String.fromCharCode,bx={DEFAULT:e=>{let t=[iv(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${sv(t[0])}${sv(t[1])}${sv(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${iv(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${iv(e,!0)};${e.x};${e.y}${t}`}},W_=class extends Dt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new $e),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(_x))this.addProtocol(r,_x[r]);for(let r of Object.keys(bx))this.addEncoding(r,bx[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};W_=jn([Ve(0,Fi),Ve(1,_l),Ve(2,Wi)],W_);var rv=[[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]],xO=[[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]],ti;function CO(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var kO=class{constructor(){if(this.version="6",!ti){ti=new Uint8Array(65536),ti.fill(1),ti[0]=0,ti.fill(0,1,32),ti.fill(0,127,160),ti.fill(2,4352,4448),ti[9001]=2,ti[9002]=2,ti.fill(2,11904,42192),ti[12351]=1,ti.fill(2,44032,55204),ti.fill(2,63744,64256),ti.fill(2,65040,65050),ti.fill(2,65072,65136),ti.fill(2,65280,65377),ti.fill(2,65504,65511);for(let e=0;e<rv.length;++e)ti.fill(0,rv[e][0],rv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ti[e]:CO(e,xO)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=ol.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return ol.createPropertyValue(0,n,r)}},ol=class wf{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new $e,this.onChange=this._onChange.event;let t=new kO;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let l=0;l<o;++l){let d=t.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=o)return n+this.wcwidth(d);let p=t.charCodeAt(l);56320<=p&&p<=57343?d=(d-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let f=this.charProperties(d,r),g=wf.extractWidth(f);wf.extractShouldJoin(f)&&(g-=wf.extractWidth(r)),n+=g,r=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},TO=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 yx(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Bu=2147483647,EO=256,oE=class K_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>EO)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new K_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new K_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Bu?Bu: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>Bu?Bu:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Bu):t}},Iu=[],RO=class{constructor(){this._state=0,this._active=Iu,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Iu}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=Iu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Iu,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",kp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Iu,this._id=-1,this._state=0}}},fs=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=kp(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Pu=[],DO=class{constructor(){this._handlers=Object.create(null),this._active=Pu,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Pu}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Pu,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Pu,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",kp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Pu,this._ident=0}},Vu=new oE;Vu.addParam(0);var Sx=class{constructor(e){this._handler=e,this._data="",this._params=Vu,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Vu,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=kp(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Vu,this._data="",this._hitLimit=!1,n));return this._params=Vu,this._data="",this._hitLimit=!1,t}},NO=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},Bs=160,MO=(function(){let e=new NO(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),n=(f,g)=>t.slice(f,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),d;e.setDefault(1,0),e.addMany(r,0,2,0);for(d in l)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Bs,0,2,0),e.add(Bs,8,5,8),e.add(Bs,6,0,6),e.add(Bs,11,0,11),e.add(Bs,13,13,13),e})(),AO=class extends Dt{constructor(e=MO){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 oE,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(yn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new RO),this._dcsParser=this._register(new DO),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,l=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(d=f[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(d=f[g](),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(r!==24&&r!==26,n),d)return d;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],d=this._oscParser.end(r!==24&&r!==26,n),d)return d;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=l;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:Bs)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<Bs){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Bs){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Bs){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Bs){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(d=g[p](this._params),d!==!0);p--)if(d instanceof Promise)return this._preserveStack(3,g,p,o,f),d;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++f<t&&(r=e[f])>47&&r<60);f--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let b=this._escHandlers[this._collect<<8|r],_=b?b.length-1:-1;for(;_>=0&&(d=b[_](),d!==!0);_--)if(d instanceof Promise)return this._preserveStack(4,b,_,o,f),d;_<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let w=f+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<Bs){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(d=this._dcsParser.unhook(r!==24&&r!==26),d)return this._preserveStack(6,[],0,o,f),d;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=f+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<Bs){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(d=this._oscParser.end(r!==24&&r!==26),d)return this._preserveStack(5,[],0,o,f),d;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},LO=/^([\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})$/,jO=/^[\da-f]+$/;function wx(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=LO.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),jO.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return r}}function av(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function OO(e,t=16){let[n,r,o]=e;return`rgb:${av(n,t)}/${av(r,t)}/${av(o,t)}`}var BO={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Qa=131072,xx=10;function Cx(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 kx=5e3,Tx=0,IO=class extends Dt{constructor(e,t,n,r,o,l,d,f,g=new AO){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=d,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nj,this._utf8Decoder=new ij,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Yn.clone(),this._eraseAttrDataInternal=Yn.clone(),this._onRequestBell=this._register(new $e),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new $e),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new $e),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new $e),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new $e),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new $e),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new $e),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new $e),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new $e),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new $e),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new $e),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new $e),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new $e),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 q_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:b.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,b,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:b,data:_})}),this._parser.setDcsHandlerFallback((p,b,_)=>{b==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:b,payload:_})}),this._parser.setPrintHandler((p,b,_)=>this.print(p,b,_)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(Ne.BEL,()=>this.bell()),this._parser.setExecuteHandler(Ne.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Ne.BS,()=>this.backspace()),this._parser.setExecuteHandler(Ne.HT,()=>this.tab()),this._parser.setExecuteHandler(Ne.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Ne.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(yf.IND,()=>this.index()),this._parser.setExecuteHandler(yf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(yf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new fs(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new fs(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new fs(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new fs(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new fs(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new fs(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new fs(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new fs(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new fs(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new fs(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new fs(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new fs(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in ii)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Sx((p,b)=>this.requestStatusString(p,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),kx))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kx} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,l=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Qa&&(l=this._parseStack.position+Qa)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Qa&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Qa))),d||this._dirtyRowTracker.clearRange(),e.length>Qa)for(let p=l;p<e.length;p+=Qa){let b=p+Qa<e.length?p+Qa:e.length,_=typeof e=="string"?this._stringDecoder.decode(e.substring(p,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,b),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,_))return this._preserveStack(r,o,_,p),this._logSlowResolvingAsync(n),n}else if(!d){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=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(f,this._bufferService.rows-1)})}print(e,t,n){let r,o,l=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,b=this._curAttrData,_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&_.getWidth(this._activeBuffer.x-1)===2&&_.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let w=this._parser.precedingJoinState;for(let C=t;C<n;++C){if(r=e[C],r<127&&l){let M=l[String.fromCharCode(r)];M&&(r=M.charCodeAt(0))}let x=this._unicodeService.charProperties(r,w);o=ol.extractWidth(x);let T=ol.extractShouldJoin(x),A=T?ol.extractWidth(w):0;if(w=x,d&&this._onA11yChar.fire(io(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-A>f){if(g){let M=_,W=this._activeBuffer.x-A;for(this._activeBuffer.x=A,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),_=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),A>0&&_ instanceof Ku&&_.copyCellsFrom(M,W,0,A,!1);W<f;)M.setCellFromCodepoint(W++,0,1,b)}else if(this._activeBuffer.x=f-1,o===2)continue}if(T&&this._activeBuffer.x){let M=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-M,r,o);for(let W=o-A;--W>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(p&&(_.insertCells(this._activeBuffer.x,o-A,this._activeBuffer.getNullCell(b)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,b)),_.setCellFromCodepoint(this._activeBuffer.x++,r,o,b),o>0)for(;--o;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&n-t>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.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,n=>Cx(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Sx(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new fs(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Yn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=ol.extractWidth(t),o=this._activeBuffer.x-r,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),d=new Uint32Array(l.length*n),f=0;for(let p=0;p<l.length;){let b=l.codePointAt(p)||0;d[f++]=b,p+=b>65535?2:1}let g=f;for(let p=1;p<n;++p)d.copyWithin(g,0,f),g+=f;return this.print(d,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Ne.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Ne.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Ne.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Ne.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Ne.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,sl),this._charsetService.setgCharset(1,sl),this._charsetService.setgCharset(2,sl),this._charsetService.setgCharset(3,sl);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(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"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,d=this._coreService,{buffers:f,cols:g}=this._bufferService,{active:p,alt:b}=f,_=this._optionsService.rawOptions,w=(T,A)=>(d.triggerDataEvent(`${Ne.ESC}[${t?"":"?"}${T};${A}$y`),!0),C=T=>T?1:2,x=e.params[0];return t?x===2?w(x,4):x===4?w(x,C(d.modes.insertMode)):x===12?w(x,3):x===20?w(x,C(_.convertEol)):w(x,0):x===1?w(x,C(r.applicationCursorKeys)):x===3?w(x,_.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?w(x,C(r.origin)):x===7?w(x,C(r.wraparound)):x===8?w(x,3):x===9?w(x,C(o==="X10")):x===12?w(x,C(_.cursorBlink)):x===25?w(x,C(!d.isCursorHidden)):x===45?w(x,C(r.reverseWraparound)):x===66?w(x,C(r.applicationKeypad)):x===67?w(x,4):x===1e3?w(x,C(o==="VT200")):x===1002?w(x,C(o==="DRAG")):x===1003?w(x,C(o==="ANY")):x===1004?w(x,C(r.sendFocus)):x===1005?w(x,4):x===1006?w(x,C(l==="SGR")):x===1015?w(x,4):x===1016?w(x,C(l==="SGR_PIXELS")):x===1048?w(x,1):x===47||x===1047||x===1049?w(x,C(p===b)):x===2004?w(x,C(r.bracketedPasteMode)):x===2026?w(x,C(r.synchronizedOutput)):w(x,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=Bd.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,l=0;do{if(r[l+o]=e.params[t+l],e.hasSubParams(t+l)){let d=e.getSubParams(t+l),f=0;do r[1]===5&&(o=1),r[l+f+1+o]=d[f];while(++f<d.length&&f+l+1+o<r.length);break}if(r[1]===5&&l+o>=2||r[1]===2&&l+o>=5)break;r[1]&&(o=1)}while(++l+t<e.length&&l+o<r.length);for(let d=2;d<r.length;++d)r[d]===-1&&(r[d]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return l}_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=Yn.fg,e.bg=Yn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Yn.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Yn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Yn.fg&16777215,r.bg&=-67108864,r.bg|=Yn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Ne.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ne.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ne.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Yn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Cx(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(`${Ne.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>xx&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>xx&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let l=parseInt(r);if(Ex(l))if(o==="?")t.push({type:0,index:l});else{let d=wx(o);d&&t.push({type:1,index:l,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(l=>l.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=wx(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);Ex(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,sl),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(BO[e[0]],ii[e[1]]||sl),!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=Yn.clone(),this._eraseAttrDataInternal=Yn.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 Ps;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${Ne.ESC}${d}${Ne.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},q_=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&&(Tx=e,e=t,t=Tx),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};q_=jn([Ve(0,Fi)],q_);function Ex(e){return 0<=e&&e<256}var PO=5e7,Rx=12,zO=50,HO=class extends Dt{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 $e),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>PO)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let d=f=>performance.now()-n>=Rx?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(d);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=Rx)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>zO&&(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()}},V_=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 f=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(g,f)),this._dataByLinkId.set(g.id,g),g.id}let n=e,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(d,l)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};V_=jn([Ve(0,Fi)],V_);var Dx=!1,UO=class extends Dt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ac),this._onBinary=this._register(new $e),this.onBinary=this._onBinary.event,this._onData=this._register(new $e),this.onData=this._onData.event,this._onLineFeed=this._register(new $e),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new $e),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new $e),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new $e),this._instantiationService=new dO,this.optionsService=this._register(new SO(e)),this._instantiationService.setService(Wi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance($_)),this._instantiationService.setService(Fi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(U_)),this._instantiationService.setService(TT,this._logService),this.coreService=this._register(this._instantiationService.createInstance(F_)),this._instantiationService.setService(_l,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(W_)),this._instantiationService.setService(kT,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ol)),this._instantiationService.setService(oj,this.unicodeService),this._charsetService=this._instantiationService.createInstance(TO),this._instantiationService.setService(aj,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(V_),this._instantiationService.setService(ET,this._oscLinkService),this._inputHandler=this._register(new IO(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ci.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ci.forward(this._bufferService.onResize,this._onResize)),this._register(Ci.forward(this.coreService.onData,this._onData)),this._register(Ci.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 HO((t,n)=>this._inputHandler.parse(t,n))),this._register(Ci.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new $e),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&&!Dx&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Dx=!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,rE),t=Math.max(t,aE),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(yx.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(yx(this._bufferService),!1))),this._windowsWrappingHeuristics.value=yn(()=>{for(let t of e)t.dispose()})}}},$O={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 FO(e,t,n,r){let o={type:0,cancel:!1,key:void 0},l=(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=Ne.ESC+"OA":o.key=Ne.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=Ne.ESC+"OD":o.key=Ne.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=Ne.ESC+"OC":o.key=Ne.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=Ne.ESC+"OB":o.key=Ne.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":Ne.DEL,e.altKey&&(o.key=Ne.ESC+o.key);break;case 9:if(e.shiftKey){o.key=Ne.ESC+"[Z";break}o.key=Ne.HT,o.cancel=!0;break;case 13:o.key=e.altKey?Ne.ESC+Ne.CR:Ne.CR,o.cancel=!0;break;case 27:o.key=Ne.ESC,e.altKey&&(o.key=Ne.ESC+Ne.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"D":t?o.key=Ne.ESC+"OD":o.key=Ne.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"C":t?o.key=Ne.ESC+"OC":o.key=Ne.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"A":t?o.key=Ne.ESC+"OA":o.key=Ne.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"B":t?o.key=Ne.ESC+"OB":o.key=Ne.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=Ne.ESC+"[2~");break;case 46:l?o.key=Ne.ESC+"[3;"+(l+1)+"~":o.key=Ne.ESC+"[3~";break;case 36:l?o.key=Ne.ESC+"[1;"+(l+1)+"H":t?o.key=Ne.ESC+"OH":o.key=Ne.ESC+"[H";break;case 35:l?o.key=Ne.ESC+"[1;"+(l+1)+"F":t?o.key=Ne.ESC+"OF":o.key=Ne.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=Ne.ESC+"[5;"+(l+1)+"~":o.key=Ne.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=Ne.ESC+"[6;"+(l+1)+"~":o.key=Ne.ESC+"[6~";break;case 112:l?o.key=Ne.ESC+"[1;"+(l+1)+"P":o.key=Ne.ESC+"OP";break;case 113:l?o.key=Ne.ESC+"[1;"+(l+1)+"Q":o.key=Ne.ESC+"OQ";break;case 114:l?o.key=Ne.ESC+"[1;"+(l+1)+"R":o.key=Ne.ESC+"OR";break;case 115:l?o.key=Ne.ESC+"[1;"+(l+1)+"S":o.key=Ne.ESC+"OS";break;case 116:l?o.key=Ne.ESC+"[15;"+(l+1)+"~":o.key=Ne.ESC+"[15~";break;case 117:l?o.key=Ne.ESC+"[17;"+(l+1)+"~":o.key=Ne.ESC+"[17~";break;case 118:l?o.key=Ne.ESC+"[18;"+(l+1)+"~":o.key=Ne.ESC+"[18~";break;case 119:l?o.key=Ne.ESC+"[19;"+(l+1)+"~":o.key=Ne.ESC+"[19~";break;case 120:l?o.key=Ne.ESC+"[20;"+(l+1)+"~":o.key=Ne.ESC+"[20~";break;case 121:l?o.key=Ne.ESC+"[21;"+(l+1)+"~":o.key=Ne.ESC+"[21~";break;case 122:l?o.key=Ne.ESC+"[23;"+(l+1)+"~":o.key=Ne.ESC+"[23~";break;case 123:l?o.key=Ne.ESC+"[24;"+(l+1)+"~":o.key=Ne.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=Ne.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=Ne.DEL:e.keyCode===219?o.key=Ne.ESC:e.keyCode===220?o.key=Ne.FS:e.keyCode===221&&(o.key=Ne.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=$O[e.keyCode]?.[e.shiftKey?1:0];if(d)o.key=Ne.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(f);e.shiftKey&&(g=g.toUpperCase()),o.key=Ne.ESC+g}else if(e.keyCode===32)o.key=Ne.ESC+(e.ctrlKey?Ne.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=Ne.ESC+f,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=Ne.US),e.key==="@"&&(o.key=Ne.NUL));break}return o}var zn=0,WO=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Vf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Vf,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,l)=>this._getKey(o)-this._getKey(l)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(zn=this._search(t),zn===-1)||this._getKey(this._array[zn])!==t)return!1;do if(this._array[zn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(zn),!0;while(++zn<this._array.length&&this._getKey(this._array[zn])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(zn=this._search(e),!(zn<0||zn>=this._array.length)&&this._getKey(this._array[zn])===e))do yield this._array[zn];while(++zn<this._array.length&&this._getKey(this._array[zn])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(zn=this._search(e),!(zn<0||zn>=this._array.length)&&this._getKey(this._array[zn])===e))do t(this._array[zn]);while(++zn<this._array.length&&this._getKey(this._array[zn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ov=0,Nx=0,KO=class extends Dt{constructor(){super(),this._decorations=new WO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new $e),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new $e),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(yn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new qO(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let l of this._decorations.getKeyIterator(t))r=l.options.x??0,o=r+(l.options.width??1),e>=r&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{ov=o.options.x??0,Nx=ov+(o.options.width??1),e>=ov&&e<Nx&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},qO=class extends lo{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new $e),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new $e),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=kn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=kn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},VO=1e3,YO=class{constructor(e,t=VO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_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)}},Mx=20,Yf=class extends Dt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,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 YO(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(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
28
|
+
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(vt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(yn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Mx+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Mx+1&&(this._liveRegion.textContent+=f_.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let l=n.lines.get(n.ydisp+o),d=[],f=l?.translateToString(!0,void 0,void 0,d)||"",g=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,d)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==r)return;let d,f;if(t===0?(d=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(d=this._rowElements.shift(),f=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:f,offset:g})=>{let p=f instanceof Text?f.parentNode:f,b=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(p);if(!_)return console.warn("columns is null. Race condition?"),null;let w=g<_.length?_[g]:_.slice(-1)[0]+1;return w>=this._terminal.cols&&(++b,w=0),{row:b,column:w}},l=o(t),d=o(n);if(!(!l||!d)){if(l.row>d.row||l.row===d.row&&l.column>=d.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(d.row-l.row)*this._terminal.cols-l.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Yf=jn([Ve(1,py),Ve(2,pa),Ve(3,ma)],Yf);var Y_=class extends Dt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new $e),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new $e),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(yn(()=>{ml(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(vt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(vt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(vt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(vt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,l=>{if(this._isMouseOut)return;let d=l?.map(f=>({link:f}));this._activeProviderReplies?.set(r,d),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let l=0;l<o.length;l++){let d=o[l],f=d.link.range.start.y<e?0:d.link.range.start.x,g=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let p=f;p<=g;p++){if(n.has(p)){o.splice(l--,1);break}n.add(p)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),o=!1;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(o=!0);if(!o&&r){let l=r.find(d=>this._linkAtPosition(d.link,t));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=this._activeProviderReplies.get(l)?.find(f=>this._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&GO(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,ml(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};Y_=jn([Ve(1,my),Ve(2,ma),Ve(3,Fi),Ve(4,DT)],Y_);function GO(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 XO=class extends UO{constructor(e={}){super(e),this._linkifier=this._register(new Ac),this.browser=YT,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ac),this._onCursorMove=this._register(new $e),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new $e),this.onKey=this._onKey.event,this._onRender=this._register(new $e),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new $e),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new $e),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new $e),this.onBell=this._onBell.event,this._onFocus=this._register(new $e),this._onBlur=this._register(new $e),this._onA11yCharEmitter=this._register(new $e),this._onA11yTabEmitter=this._register(new $e),this._onWillOpen=this._register(new $e),this._setup(),this._decorationService=this._instantiationService.createInstance(KO),this._instantiationService.setService(Id,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(z3),this._instantiationService.setService(DT,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(m_)),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(Ci.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ci.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ci.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ci.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(yn(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=vn.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${Ne.ESC}]${r};${OO(o)}${qT.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=Gn.toColor(...t.color));else{let l=n;this._themeService.modifyColors(d=>d[l]=Gn.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(Yf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ne.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(Ne.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=d+"px",this.textarea.style.width=l+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(vt(this.element,"copy",t=>{this.hasSelection()&&ej(t,this._selectionService)}));let e=t=>tj(t,this.textarea,this.coreService,this.optionsService);this._register(vt(this.textarea,"paste",e)),this._register(vt(this.element,"paste",e)),GT?this._register(vt(this.element,"mousedown",t=>{t.button===2&&U1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(vt(this.element,"contextmenu",t=>{U1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),xy&&this._register(vt(this.element,"auxclick",t=>{t.button===1&&yT(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(vt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(vt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(vt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(vt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(vt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(vt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(vt(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(vt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",h_.get()),QT||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(I3,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(pa,this._coreBrowserService),this._register(vt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(vt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(B_,this._document,this._helperContainer),this._instantiationService.setService(Tp,this._charSizeService),this._themeService=this._instantiationService.createInstance(H_),this._instantiationService.setService(zc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Kf),this._instantiationService.setService(RT,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(P_,this.rows,this.screenElement)),this._instantiationService.setService(ma,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(L_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(I_),this._instantiationService.setService(my,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Y_,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(M_,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(z_,this.element,this.screenElement,r)),this._instantiationService.setService(cj,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(Ci.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(A_,this.screenElement)),this._register(vt(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(Yf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wf,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wf,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(O_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){let d=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!d)return!1;let f,g;switch(l.overrideType||l.type){case"mousemove":g=32,l.buttons===void 0?(f=3,l.button!==void 0&&(f=l.button<3?l.button:3)):f=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":g=0,f=l.button<3?l.button:3;break;case"mousedown":g=1,f=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let p=l.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,f=4;break;default:return!1}return g===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:f,action:g,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(l)),wheel:l=>(n(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&n(l)},mousemove:l=>{l.buttons||n(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),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()),l&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),l&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),l&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),l&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(vt(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(l)})),this._register(vt(t,"wheel",l=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(l,!0);let d=Ne.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(l,!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){bT(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=FO(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Ne.ETX||n.key===Ne.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(ZO(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(Yn));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(Ne.ESC+"[I"):this.coreService.triggerDataEvent(Ne.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function ZO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var QO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},JO=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 Ps)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Ax=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 JO(t)}getNullCell(){return new Ps}},e5=class extends Dt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new $e),this.onBufferChange=this._onBufferChange.event,this._normal=new Ax(this._core.buffers.normal,"normal"),this._alternate=new Ax(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)}},t5=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},n5=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}},i5=["cols","rows"],vr=0,s5=class extends Dt{constructor(e){super(),this._core=this._register(new XO(e)),this._addonManager=this._register(new QO),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(i5.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 t5(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new n5(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 e5(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
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 h_.get()},set promptLabel(e){h_.set(e)},get tooMuchOutput(){return f_.get()},set tooMuchOutput(e){f_.set(e)}}}_verifyIntegers(...e){for(vr of e)if(vr===1/0||isNaN(vr)||vr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(vr of e)if(vr&&(vr===1/0||isNaN(vr)||vr%1!==0||vr<0))throw new Error("This API only accepts positive integers")}};function Dp(e){return e.normalize("NFC").trim().toLowerCase()}function r5(e){const t=Dp(e);if(t.length>256)return"Use at most 256 characters.";const n=[...t.replace(/\s/gu,"")].length,r=/[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/u.test(t)?2:3;return n<r?`Enter at least ${r} non-space characters.`:null}const a5=zt.lazy(()=>fy(()=>import("./TranscriptMarkdownBody-Dd6cp7t2.js"),__vite__mapDeps([2,1])));function lE({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:l}){const d=v.useRef(new Map),f=v.useMemo(()=>{const p=new Map,b=new Array(e.length);for(let _=e.length-1;_>=0;_--){const w=e[_],C=`${w.kind}\0${w.header??""}\0${w.body}`;let x=2166136261,T=5381;for(let W=0;W<C.length;W++)x=Math.imul(x^C.charCodeAt(W),16777619),T=Math.imul(T,33)^C.charCodeAt(W);const A=`${C.length}:${x>>>0}:${T>>>0}`,M=p.get(A)??0;p.set(A,M+1),b[_]=`${A}:${M}`}return b},[e]);v.useEffect(()=>{if(n===null)return;const p=d.current.get(n);if(!p||typeof p.scrollIntoView!="function")return;if(r==="prompt"){p.scrollIntoView({block:"start",inline:"nearest"});return}const b=p.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?b[o.matchIndexInEntry]:null)??p).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let g=-1;return u.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:l},children:e.map((p,b)=>{const _=p.kind==="user"?++g:null,w=n===b?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return u.jsxs("section",{ref:C=>{C?d.current.set(b,C):d.current.delete(b)},className:`transcript-entry transcript-entry-${p.kind}${w}`,"data-transcript-kind":p.kind,"data-transcript-entry-key":f[b],"data-transcript-entry-index":b,..._!==null?{"data-transcript-prompt-position":_}:{},children:[p.header?u.jsx("div",{className:"transcript-entry-header",children:cE(p.header,t)}):null,p.body?u.jsx("div",{className:"transcript-entry-body",children:p.kind==="tool"?u.jsx(Lx,{text:p.body,searchQuery:t}):u.jsx(zt.Suspense,{fallback:u.jsx(Lx,{text:p.body,searchQuery:t}),children:u.jsx(a5,{text:p.body,searchQuery:t})})}):null]},f[b])})})}function Lx({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
31
|
+
`)?e.slice(0,-1).split(`
|
|
32
|
+
`):e.split(`
|
|
33
|
+
`);return u.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>u.jsx("span",{className:`transcript-line transcript-line-${d5(r,o===0||n[o-1]?.trim()==="")}`,children:cE(r,t)},o))})}function cE(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),l=[];let d=0,f=r.indexOf(o);for(;f!==-1;){f>d&&l.push(e.slice(d,f));const g=f+n.length;l.push(u.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),d=g,f=r.indexOf(o,d)}return d<e.length&&l.push(e.slice(d)),l.length>0?l:e||" "}function o5(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,l=r.indexOf(n);for(;l!==-1;)o+=1,l=r.indexOf(n,l+n.length);return o}function G_(e){const t=e.endsWith(`
|
|
34
|
+
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",l=[];function d(){const f=l5(l).join(`
|
|
35
|
+
`);(r||f)&&n.push({header:r,body:f,kind:o}),r=null,o="plain",l=[]}for(const f of t.split(`
|
|
36
|
+
`)){const g=c5(f);g?(d(),r=f,o=g):l.push(f)}return d(),n}function l5(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function c5(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function u5(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const l=o.header?`${o.header}
|
|
37
|
+
${o.body}`:o.body,d=o5(l,t);for(let f=0;f<d;f+=1)n.push({entryIndex:r,matchIndexInEntry:f})}return n}function d5(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||dE(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function co(e){return e==="codex"?"Codex":"Claude"}function dc(e,t,n={}){const r=`[nterminal] ${co(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
38
|
+
`).replace(/\r/g,`
|
|
39
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
40
|
+
|
|
41
|
+
`).trimEnd(),l=Cy(o),d=n.includeTools?l:uE(l);return d?`${d}
|
|
42
|
+
`:""}function Cy(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=h5(n);return r?`[${r}]`:t})}function h5(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=zu(t.getMonth()+1),o=zu(t.getDate()),l=zu(t.getHours()),d=zu(t.getMinutes()),f=zu(t.getSeconds());return`${n}-${r}-${o} ${l}:${d}:${f}`}function zu(e){return e.toString().padStart(2,"0")}function Gf(e,t){return e.map(n=>t?n:uE(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
43
|
+
`)?n:`${n}
|
|
44
|
+
`).join("")}function uE(e){if(!e)return"";const t=e.split(`
|
|
45
|
+
`),n=[];let r=!1,o=!1,l=!0;for(const d of t){const f=d.trim()==="",g=l?f5(d):null;if(g&&(r=g==="tool",o=!1),dE(d)){o=!0,l=!1;continue}if(o){f?(o=!1,r||n.push(d),l=!0):l=!1;continue}r||n.push(d),l=f}return n.join(`
|
|
46
|
+
`).replace(/\n{3,}/g,`
|
|
47
|
+
|
|
48
|
+
`).trimEnd()}function f5(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function dE(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function ca(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function jx(e,t){return e===null?t===null:t!==null&&ca(e,t)}const p5=5e3,m5=200,g5=1200,v5=4,_5=zt.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:l}){const d=v.useRef(null),f=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),b=v.useRef(null),_=v.useRef(!1),[w,C]=v.useState(null),[x,T]=v.useState(null),[A,M]=v.useState(null),[W,U]=v.useState(()=>new Set),[P,F]=v.useState(!1),[V,O]=v.useState(!1),[G,fe]=v.useState([]),[ee,te]=v.useState(null),[$,Z]=v.useState(!1),[ie,J]=v.useState(!1),[j,R]=v.useState(!1),[I,re]=v.useState(null),_e=w?.find(L=>L.id===A)??null;v.useEffect(()=>{function L(ve){ve.key==="Escape"&&(ve.preventDefault(),ve.stopPropagation(),l())}return document.addEventListener("keydown",L,!0),()=>document.removeEventListener("keydown",L,!0)},[l]);const N=v.useCallback(async()=>{try{const L=await n.getTerminalSubagents(t);if(T(null),C(ve=>ve&&x5(ve,L.subagents)?ve:L.subagents),!_.current){const ve=L.subagents.find(Le=>Le.hasTranscript);ve&&(_.current=!0,M(Le=>Le??ve.id))}}catch(L){T(L instanceof Error?L.message:"Failed to load subagents."),C(ve=>ve??[])}},[n,t]);v.useEffect(()=>{N();const L=window.setInterval(()=>{document.hidden||N()},p5);function ve(){document.hidden||N()}return document.addEventListener("visibilitychange",ve),()=>{window.clearInterval(L),document.removeEventListener("visibilitychange",ve)}},[N]),v.useEffect(()=>{f.current+=1;const L=f.current;return g.current=!1,p.current=!0,b.current=null,fe([]),te(null),Z(!1),re(null),A&&Y(null,"initial",L),()=>{f.current===L&&(f.current+=1)}},[n,t,A,V]),v.useLayoutEffect(()=>{const L=d.current;if(!L)return;if(p.current){if(ie||G.length===0)return;p.current=!1;const Le=()=>{L.scrollTop=L.scrollHeight};Le(),window.requestAnimationFrame?.(Le);return}const ve=b.current;ve!==null&&(b.current=null,L.scrollTop+=L.scrollHeight-ve)},[G,ie,V]);async function Y(L,ve,Le=f.current){const Pe=A;if(!(!Pe||g.current)){g.current=!0,ve==="initial"?J(!0):(R(!0),b.current=d.current?.scrollHeight??null),re(null);try{let H=L,de=0,Te=0,Me=[];for(;f.current===Le;){const je=await n.getTerminalSubagentTranscriptHistory(t,Pe,{...H?{cursor:H}:{},limit:m5,maxLines:g5,includeTools:V});if(f.current!==Le)return;if(!je.source){if(Te<1){Te+=1,await new Promise(Fe=>setTimeout(Fe,600));continue}re("Subagent transcript is unavailable.");return}const be=dc(je.output,je.source.provider,{includeTools:V});if(te(je.cursor),Z(!!(je.hasMore&&je.cursor)),be&&(Me=[be,...Me],Gf(Me,V))){fe(Fe=>ve==="older"?[...Me,...Fe]:Me);return}if(!je.hasMore||!je.cursor||de>=v5){Me.length>0&&fe(Fe=>ve==="older"?[...Me,...Fe]:Me);return}H=je.cursor,de+=1}}catch(H){if(f.current!==Le)return;re(H instanceof Error?H.message:"Failed to load subagent transcript.")}finally{f.current===Le&&(g.current=!1,J(!1),R(!1))}}}function oe(){const L=d.current;L&&(L.scrollTop>72||!$||!ee||g.current||Y(ee,"older"))}function Q(L){U(ve=>{const Le=new Set(ve);return Le.delete(L)||Le.add(L),Le})}function we(L){_.current=!0,F(!0),L.id!==A&&M(L.id),Se(L.id)}function Se(L){const ve=S5(w??[],L);ve.length!==0&&U(Le=>{if(ve.every(H=>Le.has(H)))return Le;const Pe=new Set(Le);for(const H of ve)Pe.add(H);return Pe})}function ue(){f.current+=1;const L=f.current;g.current=!1,p.current=!0,b.current=null,fe([]),te(null),Z(!1),re(null),Y(null,"initial",L)}const Re=v.useMemo(()=>Gf(G,V),[G,V]),Oe=v.useMemo(()=>G_(Re),[Re]),ge=w===null;v.useEffect(()=>{if(ie||j||!$||!ee||g.current)return;const L=d.current;!L||G.length===0||L.scrollHeight<=L.clientHeight+4&&Y(ee,"older")},[G,$,ee,ie,j]);const He=w?.filter(L=>L.state==="working").length??0,Be=v.useMemo(()=>pE(b5(w??[]),W),[w,W]);return u.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:L=>L.stopPropagation(),onMouseDown:L=>L.stopPropagation(),onClick:L=>{L.stopPropagation(),l()},children:u.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":P?"transcript":"list",onPointerDown:L=>L.stopPropagation(),onMouseDown:L=>L.stopPropagation(),onClick:L=>L.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"transcript-dialog-title",children:[u.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?u.jsx("span",{className:"subagents-count",children:He>0?`${He} working · ${w.length} total`:`${w.length} total`}):null]}),u.jsxs("span",{title:r.sessionId,children:[co(r.provider)," session ",r.sessionId]})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:l,children:"×"})]}),u.jsxs("div",{className:"subagents-body",children:[u.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[ge?u.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!ge&&x?u.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!ge&&!x&&w!==null&&w.length===0?u.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Be.map(L=>{const ve=L.subagent,Le=W.has(ve.id);return u.jsxs("div",{className:"subagent-row-wrap",style:L.level>0?{paddingLeft:`${Math.min(L.level,4)*14}px`}:void 0,children:[L.nestedCount>0?u.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":Le,"aria-label":`${Le?"Collapse":"Expand"} ${L.nestedCount} nested subagents of ${ve.name}`,title:L.nestedWorkingCount>0?`${L.nestedCount} nested · ${L.nestedWorkingCount} working`:`${L.nestedCount} nested`,onClick:()=>Q(ve.id),children:[u.jsx("span",{"aria-hidden":"true",children:Le?"▾":"▸"}),u.jsx("span",{className:"subagent-expander-count","data-working":L.nestedWorkingCount>0?"true":"false",children:L.nestedCount})]}):u.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),u.jsxs("button",{type:"button",className:"subagent-row","data-selected":ve.id===A?"true":"false","data-state":ve.state,disabled:!ve.hasTranscript,title:ve.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>we(ve),children:[u.jsx("span",{className:"subagent-row-dot","data-state":ve.state,"aria-hidden":"true"}),u.jsxs("span",{className:"subagent-row-main",children:[u.jsxs("span",{className:"subagent-row-title",children:[u.jsx("strong",{children:ve.name}),u.jsx("span",{className:"subagent-row-badge","data-kind":ve.kind,children:ve.kind==="cross"?co(ve.provider):ve.provider})]}),ve.description?u.jsx("span",{className:"subagent-row-description",children:ve.description}):null,u.jsxs("span",{className:"subagent-row-meta",children:[C5(ve.state),ve.model?` · ${ve.model}`:"",ve.updatedAt?` · ${k5(ve.updatedAt)}`:"",L.nestedCount>0&&!Le?` · ${L.nestedCount} nested${L.nestedWorkingCount>0?` (${L.nestedWorkingCount} working)`:""}`:""]})]})]})]},ve.id)})]}),u.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[u.jsxs("div",{className:"subagents-transcript-controls",children:[u.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>F(!1),children:"‹ List"}),u.jsx("span",{className:"subagents-transcript-name",children:_e?_e.name:"Select a subagent"}),u.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[u.jsx("input",{type:"checkbox",checked:V,onChange:L=>O(L.currentTarget.checked)}),"Show tool output"]}),u.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!_e,onClick:ue,children:"↻"})]}),_e?u.jsx("div",{className:"subagents-transcript-hint",children:w5(_e)}):null,u.jsxs("div",{ref:d,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:oe,children:[j?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ie&&$?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Re?u.jsx(lE,{entries:Oe,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,ie?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!ie&&_e&&!Re&&!I?$&&ee?u.jsxs("div",{className:"transcript-dialog-status",children:[V?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",u.jsx("button",{type:"button",onClick:()=>{Y(ee,"older")},disabled:j,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!_e&&!ge&&!Re?u.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,I?u.jsx("div",{className:"transcript-dialog-error",children:I}):null]})]})]})]})})});function b5(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=y5(r,t);o?o.children.push(r):n.push(r)}for(const r of n)hE(r);return fE(n),n}function y5(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let l=r;l;){if(o.has(l.subagent.id))return null;o.add(l.subagent.id);const d=l.subagent.parentId;l=d?t.get(d):void 0}return r}function hE(e){let t=0,n=0;for(const r of e.children)hE(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,fE(e.children)}function fE(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function pE(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...pE(o.children,t,n+1));return r}function S5(e,t){const n=new Map(e.map(d=>[d.id,d])),r=[],o=new Set([t]);let l=n.get(t)?.parentId??null;for(;l&&!o.has(l);)o.add(l),r.push(l),l=n.get(l)?.parentId??null;return r}function w5(e){return e.kind==="cross"?'"User" entries are the prompt the parent session passed to codex exec, not operator input.':e.provider==="codex"?"Codex forks the parent thread to start a teammate; the inherited history is hidden here. Coordinator instructions are stored encrypted by Codex, so they show as placeholders.":`"User" entries are the parent session's instructions and tool results, not operator input.`}function x5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function C5(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function k5(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function T5({options:e,value:t,onSelect:n}){const[r,o]=v.useState(!1),l=v.useRef(null),d=v.useRef(null),f=e.find(g=>g.id===t);return v.useEffect(()=>{if(!r)return;const g=()=>Array.from(l.current?.querySelectorAll('[role="menuitemradio"]')??[]),p=g();(p.find(w=>w.getAttribute("aria-checked")==="true")??p[0])?.focus();function b(w){l.current?.contains(w.target)||o(!1)}function _(w){if(w.key==="Escape")w.preventDefault(),w.stopPropagation(),o(!1),d.current?.focus();else if(["ArrowDown","ArrowUp","Home","End"].includes(w.key)){w.preventDefault(),w.stopPropagation();const C=g(),x=C.findIndex(A=>A===document.activeElement),T=w.key==="Home"?0:w.key==="End"?C.length-1:(x+(w.key==="ArrowDown"?1:-1)+C.length)%C.length;C[T]?.focus()}else w.key==="Tab"&&o(!1)}return document.addEventListener("pointerdown",b,!0),window.addEventListener("keydown",_,!0),()=>{document.removeEventListener("pointerdown",b,!0),window.removeEventListener("keydown",_,!0)}},[r]),u.jsxs("div",{className:"transcript-session-menu",ref:l,children:[u.jsxs("button",{ref:d,type:"button",className:"transcript-session-trigger","aria-label":"Transcript session","aria-haspopup":"menu","aria-expanded":r,onClick:()=>o(!r),children:[u.jsx("span",{children:f?.title??"Choose a session"}),u.jsx(oA,{size:16,"aria-hidden":"true"})]}),r?u.jsx("div",{className:"transcript-session-options",role:"menu","aria-label":"Transcript sessions",children:e.map(g=>u.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t===g.id,tabIndex:-1,onClick:()=>{o(!1),d.current?.focus(),n(g.id)},children:[u.jsx("span",{className:"transcript-session-check",children:t===g.id?u.jsx(Nk,{size:16}):null}),u.jsxs("span",{className:"transcript-session-copy",children:[u.jsx("strong",{children:g.title}),u.jsx("small",{children:g.detail})]})]},g.id))}):null]})}function ky(e){const t=new Set;return e.filter(n=>t.has(n.id)?!1:(t.add(n.id),!0))}function X_(e){return!e.page||e.page.unchanged?null:{page:{...e.page,records:ky(e.page.records)},cursor:e.cursor,hasMore:e.hasMore,scrollTop:0,atBottom:!0}}function Ox(e,t){const n=X_(t);if(!n||n.page.identity!==e.page.identity||n.page.endOffset!==e.page.startOffset)return null;const r=n.page.snapshot===e.page.snapshot&&n.page.snapshotSize===e.page.snapshotSize&&n.page.snapshotMtime===e.page.snapshotMtime,o=n.page.snapshotSize<e.page.snapshotSize&&n.page.endOffset<=e.page.stableBefore&&n.page.endOffset<=n.page.stableBefore;return!r&&!o?null:{...e,page:{...e.page,startOffset:n.page.startOffset,records:ky([...n.page.records,...e.page.records])},cursor:n.cursor,hasMore:n.hasMore}}function mE(e,t){return e.identity===t.identity&&(t.snapshotSize>e.snapshotSize||t.snapshotSize===e.snapshotSize&&t.snapshotMtime===e.snapshotMtime)}function gE(e,t){return!mE(e.page,t.page)||t.page.startOffset<=e.page.stableBefore||t.page.startOffset<=e.page.startOffset}function E5(e,t){if(!mE(e.page,t.page)||!gE(e,t))return t;const n=new Set(t.page.records.map(l=>l.id)),r=e.page.records.filter(l=>l.startOffset<t.page.startOffset&&l.endOffset<=t.page.startOffset&&!n.has(l.id)),o=e.page.startOffset<t.page.startOffset;return{...t,page:{...t.page,startOffset:Math.min(e.page.startOffset,t.page.startOffset),records:ky([...r,...t.page.records])},cursor:o?e.cursor:t.cursor,hasMore:o?e.hasMore:t.hasMore,scrollTop:e.scrollTop,atBottom:e.atBottom,...e.scrollAnchor?{scrollAnchor:e.scrollAnchor}:{}}}const R5=64*1024*1024,D5=1800*1e3;let Z_=0,Q_=new WeakMap;const vd=new Map,_d=new Set;function N5(e){const t=e.page;return 2*(t.identity.length+t.snapshot.length+(e.cursor?.length??0)+t.records.reduce((n,r)=>n+r.id.length+r.block.length,0))}function J_(e){e.owner.delete(e.key),_d.delete(e),e.snapshot=null,e.bytes=0}function lv(e){for(const r of _d)!r.leases&&e-r.closedAt>=D5&&J_(r);let t=0;const n=[];for(const r of _d)t+=r.bytes,r.leases||n.push(r);n.sort((r,o)=>r.closedAt-o.closedAt);for(const r of n){if(t<=R5)break;t-=r.bytes,J_(r)}for(const[r,o]of vd)o.size||vd.delete(r)}function cv(){Z_+=1;for(const e of _d)J_(e);vd.clear(),Q_=new WeakMap}function M5(e,t,n,r){lv(Date.now());const o=e.transcriptCacheScope;let l=o===void 0?Q_.get(e):vd.get(o);l||(l=new Map,o===void 0?Q_.set(e,l):vd.set(o,l));const d=JSON.stringify([t,n.provider,n.sessionId,r]);let f=l.get(d);f||(f={snapshot:null,bytes:0,leases:0,closedAt:0,owner:l,key:d},l.set(d,f),_d.add(f));const g=Z_,p=f;p.leases+=1;let b=!1;const _=()=>!b&&g===Z_;return{get snapshot(){return _()?p.snapshot:null},current:_,write(w){_()&&(p.snapshot=w,p.bytes=N5(w),lv(Date.now()))},invalidate(){_()&&(p.snapshot=null,p.bytes=0)},release(){b||(b=!0,p.leases-=1,p.leases||(p.closedAt=Date.now()),lv(Date.now()))}}}function A5(e,t,n){if(!e.length)return null;const r=t.timestamp?Cy(`[${t.timestamp}] ${t.role}`):null;let o=e.length-1;if(r){for(let d=e.length-1;d>=0;d-=1)if(e[d]?.header===r){o=d;break}}const l=u5(e,Dp(n)).filter(d=>d.entryIndex===o);return(r&&e[o]?.header===r?l[0]:l.at(-1))??{entryIndex:o,matchIndexInEntry:0}}function L5(e,t,n,r,o,l){const[d,f]=v.useState(null),[g,p]=v.useState(!1),[b,_]=v.useState(null),w=v.useRef(null),C=v.useRef(0);function x(){C.current+=1,w.current?.abort(),w.current=null}function T(){x(),p(!1)}v.useEffect(()=>(x(),f(null),p(!1),_(null),x),[e,t,n.provider,n.sessionId,r,o,l]);async function A(M=!1){const W=r5(l);if(W){_(W);return}x();const U=C.current,P=new AbortController;w.current=P,p(!0),_(null);let F=M?d:null;M||f(null);try{for(let V=0;V<4;V+=1){const O=await e.searchTerminalTranscript(t,{query:Dp(l),...F?.cursor?{cursor:F.cursor}:{},...r?{candidateId:r}:{},expectedSessionId:n.sessionId,includeTools:o},P.signal);if(P.signal.aborted||U!==C.current)return;if(!O.source||O.source.provider!==n.provider||O.source.sessionId!==n.sessionId)throw new Error("Transcript source changed or is unavailable. Choose a session again.");const G=new Set(F?.hits.map(te=>te.id)),fe=[...F?.hits??[],...O.hits.filter(te=>!G.has(te.id))],ee=F?.cursor;if(F={...O,hits:fe.slice(-200)},f(F),O.complete||!O.cursor||O.cursor===ee||O.hits.length)break}}catch(V){!P.signal.aborted&&U===C.current&&_(V instanceof Error?V.message:"Search failed.")}finally{U===C.current&&p(!1)}}return{result:d,busy:g,error:b,search:A,cancel:T}}class j5{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():yE.has(t)?this.acceptConsonant(t):SE.has(t)?this.acceptVowel(t):P5(t)&&this.canReplacePendingWith(t)?(this.pending=Ix(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(wE.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=I5.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const l=B5.get(`${this.pending.vowel}${t}`);return l?(this.pending.vowel=l,""):this.flushPending()+t}const n=Bx.get(this.pending.final);if(n){this.pending.final=n[0];const l=this.flushPending();return this.pending={initial:n[1],vowel:t},l}const r=this.pending.final,o=Px({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=Bx.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=Ix(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=Px(this.pending);return this.pending=null,t}}const Xf=44032,Zf=21,bc=28,O5=19*Zf*bc,vE=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],_E=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],bE=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],yE=Ty(vE),SE=Ty(_E),wE=Ty(bE),B5=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),xE=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],I5=new Map(xE),Bx=new Map(xE.map(([e,t])=>[t,[e[0],e[1]]]));function Ty(e){return new Map(e.map((t,n)=>[t,n]))}function P5(e){const t=e.codePointAt(0);return t!==void 0&&t>=Xf&&t<Xf+O5}function Ix(e){const t=e.codePointAt(0)-Xf,n=Math.floor(t/(Zf*bc)),r=Math.floor(t%(Zf*bc)/bc),o=t%bc,l={initial:vE[n],vowel:_E[r]};return o===0?l:{...l,final:bE[o]}}function Px(e){if(!e.vowel)return e.initial;const t=yE.get(e.initial),n=SE.get(e.vowel),r=e.final?wE.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Xf+(t*Zf+n)*bc+r)}const z5=[{key:"interrupt",label:"^C",ariaLabel:"Send Interrupt"},{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function H5({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function l(d){d.preventDefault(),d.stopPropagation(),r()}return u.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:l,onPointerDown:l,children:[u.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"}),z5.map(d=>u.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":d.ariaLabel,onClick:()=>n(d.key),children:d.label},d.key)),u.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const U5={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function $5(e){return U5[e]}function F5(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const CE="--nterminal-viewport-height",kE="--nterminal-keyboard-inset-bottom",TE="data-nterminal-keyboard-visible",Np="data-nterminal-compose-open",Qf="nterminal:viewport-refresh",W5=120;function K5(e=window){const t=e.document.documentElement,n=e.visualViewport,r=Z5(e);function o(){Ey(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(Qf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(Qf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(CE),t.style.removeProperty(kE),t.removeAttribute(TE)}}function Ey(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=eb(e),o=q5(e,r);return o!==null&&zx(t,CE,`${o}px`),zx(t,kE,`${n}px`),V5(t,TE,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function eb(e=window){const t=Y5(e);return{keyboardInsetBottom:t,keyboardVisible:t>W5}}function q5(e,t){if((e.document.documentElement.hasAttribute(Np)||t)&&dl(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return dl(n)?n:dl(e.innerHeight)?e.innerHeight:null}function dl(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function zx(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function V5(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Y5(e){return Math.max(G5(e),X5(e))}function G5(e){const t=e.visualViewport?.height;if(!dl(t)||!dl(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function X5(e){if(!dl(e.innerHeight))return 0;const n=EE(e)?.boundingRect?.height;return!dl(n)||n>=e.innerHeight*.8?0:Math.round(n)}function EE(e){return e.navigator.virtualKeyboard}function Z5(e){const t=EE(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Hd=new Map,bd=new Map,Q5=Object.freeze({open:!1,text:""});function J5(e){let t=bd.get(e);return t||(t=new Set,bd.set(e,t)),t}function RE(e){const t=bd.get(e);if(t)for(const n of Array.from(t))n()}function kc(e){return Hd.get(e)??Q5}function eB(e,t){const n=J5(e);return n.add(t),()=>{n.delete(t)}}function tB(e,t){const n=kc(e);n.open!==t&&(Hd.set(e,{...n,open:t}),RE(e))}function nB(e,t){const n=kc(e);n.text!==t&&(Hd.set(e,{...n,text:t}),RE(e))}function Hu(e){Hd.delete(e),bd.delete(e)}function Hx(){Hd.clear(),bd.clear()}const _o=new Map,yd=new Map,Jf=new Map,iB=Object.freeze([]);function Sd(e){return _o.get(e)??iB}function sB(e,t){let n=yd.get(e);return n||(n=new Set,yd.set(e,n)),n.add(t),()=>n?.delete(t)}function uv(e,t){t.length!==0&&(_o.set(e,[...Sd(e),...t]),Mp(e))}function dv(e){const t=Jf.get(e)??1;return Jf.set(e,t+1),`attach${t}`}function tb(e){Jf.delete(e)}function Uu(e,t,n){const r=Sd(e);r.length!==0&&(_o.set(e,r.map(o=>t.has(o.id)?n(o):o)),Mp(e))}function nf(e,t){const n=Sd(e);n.find(l=>l.id===t)?.cancel?.();const o=n.filter(l=>l.id!==t);o.length!==n.length&&(o.length===0?_o.delete(e):_o.set(e,o),Mp(e))}function DE(e){const t=_o.get(e);if(t){for(const n of t)n.cancel?.();_o.delete(e),Mp(e)}}function hc(e){DE(e),tb(e),yd.delete(e)}function Ux(){for(const e of Array.from(_o.keys()))hc(e);yd.clear(),Jf.clear()}function Mp(e){for(const t of Array.from(yd.get(e)??[]))t()}class rB extends Error{constructor(t){super(t),this.name="UploadDropError"}}function yc(e){return e?Array.from(e.types??[]).includes("Files")||Dy(e.items).some(n=>n.kind==="file")?!0:jE(e.files).length>0:!1}async function NE(e){const t=Dy(e.items).filter(n=>n.kind==="file");return t.length>0?oB(t):ME(e.files)}function aB(e){const t=Dy(e.items).filter(o=>o.kind==="file").flatMap(o=>{const l=o.getAsFile();return l?[{relativePath:Ry(l),file:l}]:[]}),n=ME(e.files);if(t.length===0)return n;if(n.length===0)return t;const r=[...t];for(const o of n)r.some(l=>dB(l.file,o.file))||r.push(o);return r}async function oB(e){const t=[];for(const n of e){const r=hB(n);if(r){await AE(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Ry(o),file:o});continue}throw new rB("Folder upload is not supported by this browser.")}return t}function ME(e){return jE(e).map(t=>({relativePath:Ry(t),file:t}))}async function AE(e,t,n){const r=pB(t,e.name);if(e.isFile){const d=await lB(e);n.push({relativePath:r,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),l=await cB(o);for(const d of l)await AE(d,r,n)}function lB(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function cB(e){const t=[];for(;;){const n=await uB(e);if(n.length===0)return t;t.push(...n)}}function uB(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Ry(e){const t=e.webkitRelativePath;return LE(typeof t=="string"&&t?t:e.name)}function dB(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified}function hB(e){const t=e.webkitGetAsEntry?.();return fB(t)?t:null}function fB(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 pB(e,t){return LE(e?`${e}/${t}`:t)}function LE(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Dy(e){return e?Array.from(e):[]}function jE(e){return e?Array.from(e):[]}const mB=120,gB="\x1B[200~",vB="\x1B[201~";function hv(e,t){const n=t.stripTrailingLineBreaks===!1?e:Ny(e),r=bB(n);return r?t.bracketedPasteMode?`${gB}${r}${vB}`:r:""}function _B(e){return e==="queue"?" ":"\r"}function Ny(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function bB(e){return e.replace(/\r\n/g,`
|
|
49
|
+
`).replace(/\r/g,`
|
|
50
|
+
`).replace(/\n/g,"\r")}const yB=420,SB=3e3,$x=650,wB=80,xB=3,CB=10,kB=50*1024*1024,TB=100*1024*1024,EB=2,RB={maxFiles:CB,maxFileBytes:kB,maxBatchBytes:TB},xf=new Set;let Tc=null;function DB({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:l,onDeleteAttachments:d}){const f=v.useMemo(()=>L=>eB(e,L),[e]),g=v.useMemo(()=>()=>kc(e),[e]),p=v.useSyncExternalStore(f,g,g),{open:b,text:_}=p,w=v.useMemo(()=>L=>sB(e,L),[e]),C=v.useMemo(()=>()=>Sd(e),[e]),x=v.useSyncExternalStore(w,C,C),[T,A]=v.useState(RB),[M,W]=v.useState(!1),U=v.useRef(null),P=v.useRef(null),F=v.useRef(null),V=v.useRef(null),O=v.useRef(new Map),G=v.useRef(l),fe=v.useRef(d),ee=v.useRef(null),te=v.useRef({start:0,end:0});G.current=l,fe.current=d,v.useEffect(()=>()=>{ee.current?.(),ee.current=null},[]),v.useEffect(()=>{if(!b||!G.current)return;let L=!0;return G.current().then(ve=>{L&&A(ve)}).catch(()=>{}),()=>{L=!1}},[b,e]),v.useLayoutEffect(()=>{if(!(!b||!Cf()))return IB(e),()=>PB(e)},[b,e]),v.useLayoutEffect(()=>{const L=U.current?.closest(".terminal-pane");if(!L)return;function ve(){L?.removeAttribute("data-compose-open"),L?.style.removeProperty("--compose-drawer-panel-height")}if(!b){ve();return}const Le=P.current;L.setAttribute("data-compose-open","true");function Pe(){const Me=Le?.getBoundingClientRect().height??0;Me>0&&L?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Me)}px`)}Pe();const H=[window.setTimeout(Pe,0),window.setTimeout(Pe,180),window.setTimeout(Pe,260)],de=window.requestAnimationFrame?.(Pe)??null,Te=typeof ResizeObserver=="function"&&Le?new ResizeObserver(Pe):null;return Te&&Le&&Te.observe(Le),()=>{for(const Me of H)window.clearTimeout(Me);de!==null&&window.cancelAnimationFrame?.(de),Te?.disconnect(),ve()}},[b]),v.useEffect(()=>{if(!b){ee.current?.(),ee.current=null;return}gv(F.current),ge()},[b]);function $(L){tB(e,L)}function Z(L){nB(e,L)}function ie(){BB(U.current),$(!1),Kx()}function J(L="send"){const ve=x.filter(Pe=>Pe.status==="uploaded"&&Pe.path);if(r||x.some(Pe=>Pe.status==="uploading"||Pe.status==="failed")||!_&&ve.length===0)return;const Le=AB(_,x);if(Le.parts.some(Pe=>Pe.kind==="image"||Pe.value.trim())&&t(Le,L)){if(Z(""),DE(e),tb(e),Cf()){F.current?.blur(),Kx();return}window.setTimeout(()=>F.current?.focus(),mB+20)}}async function j(L){if(r||L.length===0)return;const ve=Sd(e).filter(be=>be.status!=="failed"),Le=ve.reduce((be,Fe)=>be+Fe.file.size,0);let Pe=0,H=ve.length;const de=[],Te=L.filter((be,Fe)=>{const We=Le+Pe+be.file.size,Ue=be.file.size>T.maxFileBytes?`File exceeds the ${Wx(T.maxFileBytes)} attachment limit.`:H>=T.maxFiles?`A compose message can include up to ${T.maxFiles} attachments.`:We>T.maxBatchBytes?`Compose attachments cannot exceed ${Wx(T.maxBatchBytes)} in total.`:null;return Ue?(de.push({id:pv(Fe),reference:dv(e),file:be.file,relativePath:Fx(be.relativePath,be.file.name),status:"failed",error:Ue}),!1):(H+=1,Pe+=be.file.size,!0)});if(de.length>0&&uv(e,de),Te.length===0)return;const Me=new Map,je=Te.map((be,Fe)=>{const We=pv(Fe),Ue=new AbortController;return Me.set(We,Ue),{id:We,reference:dv(e),file:be.file,relativePath:Fx(be.relativePath,be.file.name),status:"uploading",loaded:0,total:be.file.size,cancel:()=>Ue.abort()}});uv(e,je),He(je.map(be=>be.reference));for(const be of je)O.current.set(be.id,Me.get(be.id));await OB(je,EB,async be=>{const Fe=Me.get(be.id),We=new Set([be.id]);try{const ut=(await o([{relativePath:be.relativePath,file:be.file}],{signal:Fe.signal,onProgress:_t=>{Uu(e,We,lt=>({...lt,loaded:_t.loaded,total:_t.total}))}})).results[0];if(Fe.signal.aborted){const _t=fe.current;ut?.status==="uploaded"&&ut.attachmentId&&_t&&_t([ut.attachmentId]).catch(()=>{});return}Uu(e,We,_t=>{const{error:lt,cancel:Nt,...Yt}=_t;return ut?.status==="uploaded"&&ut.path?{...Yt,status:"uploaded",...ut.attachmentId?{attachmentId:ut.attachmentId}:{},path:ut.path,loaded:ut.size??_t.file.size,total:ut.size??_t.file.size}:{...Yt,status:"failed",error:ut?.error??"upload_failed"}})}catch(Ue){const ut=Fe.signal.aborted?"Upload canceled.":mv(Ue);Uu(e,We,_t=>{const{cancel:lt,...Nt}=_t;return{...Nt,status:"failed",error:ut}})}finally{O.current.get(be.id)===Fe&&O.current.delete(be.id)}})}function R(L){if(L.status!=="removing"){if(Be(L.reference),L.status!=="uploaded"&&L.status!=="failed"||!L.attachmentId||!fe.current){O.current.delete(L.id),nf(e,L.id);return}re([L])}}function I(){Z(""),tb(e);const L=x.filter(ve=>!!(ve.path&&ve.attachmentId));for(const ve of x)L.includes(ve)||(O.current.delete(ve.id),nf(e,ve.id));L.length>0&&re(L)}function re(L){const ve=L.flatMap(Pe=>Pe.attachmentId?[Pe.attachmentId]:[]);if(ve.length===0||!fe.current){for(const Pe of L)nf(e,Pe.id);return}const Le=new Set(L.map(Pe=>Pe.id));Uu(e,Le,Pe=>{const{error:H,...de}=Pe;return{...de,status:"removing"}}),fe.current(ve).then(()=>{for(const Pe of L)nf(e,Pe.id)}).catch(Pe=>{Uu(e,Le,H=>({...H,status:"failed",error:`Could not remove attachment: ${mv(Pe)}`}))})}function _e(L){const ve=Array.from(L.currentTarget.files??[]).map(Le=>({relativePath:Le.name,file:Le}));L.currentTarget.value="",j(ve)}function N(L){const ve=aB(L.clipboardData);ve.length!==0&&(L.preventDefault(),j(ve))}function Y(L){r||!yc(L.dataTransfer)||(L.preventDefault(),L.stopPropagation(),L.dataTransfer.dropEffect="copy",W(!0))}function oe(L){r||!yc(L.dataTransfer)||(L.preventDefault(),L.stopPropagation(),W(!0))}function Q(L){if(!yc(L.dataTransfer))return;const ve=L.relatedTarget;ve instanceof Node&&L.currentTarget.contains(ve)||W(!1)}function we(L){yc(L.dataTransfer)&&(L.preventDefault(),L.stopPropagation(),W(!1),NE(L.dataTransfer).then(j).catch(ve=>{const Le={id:pv(0),reference:dv(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:mv(ve)};uv(e,[Le])}))}const Se=x.some(L=>L.status==="uploading"),ue=x.some(L=>L.status==="failed"),Re=x.filter(L=>L.status==="uploaded"&&L.path).length,Oe=!r&&!Se&&!ue&&(!!_||Re>0);function ge(){Cf()&&(ee.current?.(),ee.current=zB())}function He(L){if(L.length===0)return;const ve=L.map(Ue=>`@${Ue}`).join(" "),Le=kc(e).text,Pe=Math.min(te.current.start,Le.length),H=Math.min(Math.max(Pe,te.current.end),Le.length),de=Le.slice(0,Pe),Te=Le.slice(H),Me=de&&!/\s$/.test(de)?" ":"",je=Te&&!/^\s/.test(Te)?" ":"",be=`${Me}${ve}${je}`,Fe=`${de}${be}${Te}`,We=de.length+be.length;te.current={start:We,end:We},Z(Fe),window.requestAnimationFrame(()=>{const Ue=F.current;Ue&&(gv(Ue),Ue.setSelectionRange(We,We))})}function Be(L){const ve=kc(e).text,Le=ve.replace(new RegExp(`@${jB(L)}(?![A-Za-z0-9_])`,"g"),"");Le!==ve&&Z(Le.replace(/[ \t]{2,}/g," "))}return u.jsxs("div",{ref:U,className:"compose-drawer","data-open":b?"true":"false",children:[u.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":b?"true":void 0,tabIndex:b?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>$(!0),children:[u.jsx("span",{"aria-hidden":"true",children:"▴"}),u.jsx("span",{children:"compose"}),_||x.length>0?u.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),u.jsxs("div",{ref:P,className:"compose-drawer-panel","aria-hidden":b?void 0:"true","data-file-drag-active":M?"true":void 0,onDragEnter:oe,onDragOver:Y,onDragLeave:Q,onDrop:we,children:[M?u.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,u.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:b?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:ie,children:[u.jsx("span",{"aria-hidden":"true",children:"▾"}),u.jsx("span",{className:"compose-drawer-title",children:"compose"}),u.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),u.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),u.jsx("textarea",{ref:F,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:b?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:_,onChange:L=>{te.current={start:L.target.selectionStart,end:L.target.selectionEnd},Z(L.target.value)},onSelect:L=>{te.current={start:L.currentTarget.selectionStart,end:L.currentTarget.selectionEnd}},onPaste:N,onFocus:ge,onKeyDown:L=>{if(L.key==="Enter"&&(L.metaKey||L.ctrlKey)){if(L.preventDefault(),L.shiftKey){n&&J("queue");return}J("send");return}L.key==="Escape"&&(L.preventDefault(),ie())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),u.jsx("input",{ref:V,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:_e}),x.length>0?u.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:x.map(L=>u.jsx(NB,{attachment:L,onRemove:()=>R(L)},L.id))}):null,u.jsxs("div",{className:"compose-drawer-actions",children:[u.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:b?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>V.current?.click(),disabled:r,children:"+"}),u.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:b?0:-1,onClick:()=>{I(),gv(F.current),ge()},disabled:!_&&x.length===0,children:"Clear"}),n?u.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:b?0:-1,title:ue?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>J("queue"),disabled:!Oe,children:"Queue"}):null,u.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:b?0:-1,title:ue?"Remove failed attachments before sending.":void 0,onClick:()=>J("send"),disabled:!Oe,children:"Send"})]})]})]})}function NB({attachment:e,onRemove:t}){const n=MB(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return u.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?u.jsx("img",{src:n,alt:""}):u.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),u.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),u.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),u.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),u.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function MB(e,t){const n=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n}function AB(e,t){const n=new Map(t.map(f=>[f.reference,f])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let l=0,d;for(;(d=o.exec(e))!==null;){const f=n.get(d[1]);f&&(fv(r,e.slice(l,d.index)),f.status==="uploaded"&&f.path&&(LB(f)?r.push({kind:"image",path:f.path}):fv(r,f.path)),l=o.lastIndex)}return fv(r,e.slice(l)),{parts:r}}function fv(e,t){if(!t)return;const n=e.at(-1);if(n?.kind==="text"){n.value+=t;return}e.push({kind:"text",value:t})}function LB(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function jB(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fx(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function pv(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function mv(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function Wx(e){return e%(1024*1024)===0?`${e/(1024*1024)} MB`:e>=1024*1024?`${Math.round(e/(1024*1024)*10)/10} MB`:`${Math.ceil(e/1024)} KB`}async function OB(e,t,n){let r=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){const l=r;if(r+=1,l>=e.length)return;await n(e[l])}});await Promise.all(o)}function BB(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function gv(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Cf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Kx(){if(!Cf())return;const e=Sc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function IB(e){Tc!==null&&(window.clearTimeout(Tc),Tc=null),xf.add(e),document.documentElement.setAttribute(Np,"true"),Sc()}function PB(e){if(xf.delete(e),xf.size>0||Tc!==null){Sc();return}Tc=window.setTimeout(()=>{if(Tc=null,xf.size>0){Sc();return}document.documentElement.removeAttribute(Np),Sc()},yB),Sc()}function zB(){let e=!1,t=null,n=null,r=null,o=0;const l=Date.now(),d=window.visualViewport,f=HB();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),d?.removeEventListener("resize",_),d?.removeEventListener("scroll",_),f?.removeEventListener("geometrychange",_))}function b(w){if(!e){if(w<$x&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(_);return}t=window.setTimeout(_,wB)}}function _(){if(e)return;g();const w=Ey(),C=Date.now()-l;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),C>=SB||C>=$x&&o>=xB){p();return}b(C)}return d?.addEventListener("resize",_),d?.addEventListener("scroll",_),f?.addEventListener("geometrychange",_),_(),p}function Sc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Ey()}function HB(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function UB(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(WB(d))return d.preventDefault(),d.stopPropagation(),$B(e),!1;if(FB(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(KB(d)){const f=nb(e);return f?(d.preventDefault(),d.stopPropagation(),ib(f),!1):!0}return qB(d)?(d.preventDefault(),d.stopPropagation(),VB(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const f=nb(e);if(f){if(d.clipboardData){d.clipboardData.setData("text/plain",f),d.preventDefault();return}d.preventDefault(),ib(f)}},l=d=>{const f=d.clipboardData?.getData("text/plain");if(!f)return;const g=Ny(f);d.preventDefault(),d.stopImmediatePropagation(),OE(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",l,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",l,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function $B(e){const t=nb(e);t&&await ib(t)}function FB(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function WB(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function KB(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function qB(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 VB(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;OE(e,Ny(n),t)}catch{}}function OE(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function nb(e){return e.hasSelection()?e.getSelection():YB(e.element??null)}function YB(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function ib(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}GB(e)}function GB(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const XB=[4,10,11,12];function ZB(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>qx(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>qx(r)),e.parser.registerCsiHandler({final:"n"},r=>QB(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>JB(r)),e.parser.registerCsiHandler({final:"t"},r=>e4(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...XB.map(r=>e.parser.registerOscHandler(r,o=>t4(o)))];return{dispose(){for(const r of n)r.dispose()}}}function qx(e){return Ap(e)===0}function QB(e){const t=Ap(e);return t===5||t===6}function JB(e){return Ap(e)===6}function e4(e){const t=Ap(e);return t===14||t===16||t===18}function t4(e){return e.split(";").some(t=>t==="?")}function Ap(e){const t=e[0];return typeof t=="number"?t:0}const tr=new Map,vv=2*1024*1024,n4=1500,Vx=25e3,i4=2500,s4=2500,r4=1e3,a4=2e3,o4=3e4,l4=16*1024*1024,sb=256,BE=nM-3e4,c4=3e3,IE=1e4,u4=3e3,rb=16*1024*1024,Lp=4*1024*1024,ep=25,d4=1e3,h4=3e3,_v=8,f4=100,PE=1e3,Yx=[2e3,5e3,15e3,6e4];let p4=0,m4=0,bv=0,yv=null,kf=!1,ab=0,Tf=0,uo=!1,Gx=!1,ad=null,Xx=!1,ob=0,wd=document.visibilityState!=="hidden";const tp=new Set;let Ec=null,od=0;const g4=new TextEncoder,v4=z4();function _4(e,t){y4(),E4(),Sp()&&ua(0);let n=tr.get(e);n||(n=x4(e),tr.set(e,n),Uc(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Ay(n));const o=(f,g)=>D4(n,f,g),l=f=>{f?(n.foregroundAttachments.add(r),np(),UE(n)):(n.foregroundAttachments.delete(r),lb())},d=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),lb()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:l,detach:d}}function fc(e){const t=tr.get(e);t&&(P4(t),tr.delete(e),lb())}function b4(e){const t=tr.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),So(t),Qs(t),kr(t),wo(t),wr(t,"reconnecting"),xo(t);const n=t.socket;return t.socket=null,so(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Uc(t),!0}function y4(){if(Xx)return;Xx=!0;const e=()=>{if(document.visibilityState==="hidden"){wd=!1,ob+=1,$E(),HE(),S4();return}My(),od=Date.now(),np()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),np()}function np(){Ec!==null||document.visibilityState==="hidden"||!zE()||typeof window.requestAnimationFrame!="function"||(Ec=window.requestAnimationFrame(()=>{if(Ec=null,document.visibilityState==="hidden")return;const e=Date.now(),t=od>0?e-od:0;if(od=e,t>=a4){for(const n of tr.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&bo("terminal.connection.foreground_gap",n,{gapMs:t});My(void 0,{foregroundOnly:!0})}np()}))}function zE(){for(const e of tr.values())if(e.foregroundAttachments.size>0)return!0;return!1}function lb(){zE()||(HE(),od=0)}function HE(){Ec!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Ec),Ec=null}function UE(e){if(document.visibilityState!=="hidden"){if(!wd||e?.heartbeatSuspended){My(e);return}e&&cb(e)}}function My(e,t={}){if(document.visibilityState==="hidden")return;wd=!0;const n=++ob;$E();const r=Array.from(tr.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=r.filter(f=>f===e||f.foregroundAttachments.size>0||M4(f)),l=new Set(o),d=r.filter(f=>!l.has(f));for(const f of o)cb(f);if(!t.foregroundOnly)for(let f=0;f<d.length;f+=_v){const g=d.slice(f,f+_v),p=Math.floor(f/_v)*f4,b=window.setTimeout(()=>{if(tp.delete(b),!(n!==ob||!wd||document.visibilityState==="hidden"))for(const _ of g)cb(_)},p);tp.add(b)}}function $E(){for(const e of tp)window.clearTimeout(e);tp.clear()}function cb(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,Uc(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<r4)return Promise.resolve("alive");wr(e,"reconnecting"),xo(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++p4).toString(36)}`;let o;const l=new Promise(f=>{o=f}),d={socket:t,nonce:r,timeout:0,promise:l,resolve:o};e.resumeProbe=d,d.timeout=window.setTimeout(()=>{e.resumeProbe!==d||e.socket!==t||(bo("terminal.connection.resume_timeout",e,{pendingInputs:ho(e)}),wr(e,"reconnecting"),fo(e))},i4);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{wr(e,"reconnecting"),fo(e)}return l}function S4(){wd=!1;for(const e of tr.values())e.heartbeatSuspended=!0,So(e),Qs(e),kr(e),wo(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,wr(e,"skipped"),xo(e)}function w4(){uo=!1,Sp()&&ua(0);for(const e of tr.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),So(e),Qs(e),kr(e),wo(e),wr(e,"reconnecting"),xo(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,so(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Uc(e)}}function Sv(){for(const e of Array.from(tr.keys()))fc(e)}function x4(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:ep,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function Uc(e){if(!e.reconnectEnabled)return;so(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Qs(e),kr(e),wo(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,So(e),Qs(e),so(e,"connected"),yo(e,t),FE(e,t),e.isAlive=!0,Zx(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let l=null;try{l=JSON.parse(o)}catch{return}if(!l||typeof l.type!="string")return;if(V4(l)){Y4(e,t,l.instanceId,l.inputAck,l.inputReceipt===!0),uo&&(uo=!1,Sp()&&ua(0));return}if(e.inputProtocolMode==="unknown"&&qE(e,t),l.type==="pong"){e.isAlive=!0;const f=e.resumeProbe;f?.socket===t&&f.nonce===l.nonce&&(e.lastResumeProbeAt=Date.now(),ho(e)>0&&bo("terminal.connection.resume_alive",e,{pendingInputs:ho(e)}),wr(e,"alive"),yo(e,t),Zx(e),vl(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===l.nonce&&(Cd(e),bo("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:ho(e)}),fo(e));return}if(l.type==="input_ack"){F4(e,t,l);return}if(l.type==="input_received"){W4(e,t,l);return}if(l.type==="error"&&K4(e,l),l.type==="input_ack_confirmed"){X4(e,l);return}const d=k4(e,l);if(xd(e,{type:"message",message:d}),l.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;Ay(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",So(e),Qs(e),kr(e),wo(e),wr(e,"reconnecting"),xo(e),r.code===1008){e.reconnectEnabled=!1,so(e,C4(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=o4)&&(e.lastUpgradeAuthProbeAt=o,xd(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){so(e,"closed");return}so(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Uc(e)},n4)}}),t.addEventListener("error",()=>{})}function Zx(e){if(xo(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>Vx*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},Vx)}function xo(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function C4(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function k4(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+fa(r),0),Qx(e),e.exited&&Ef(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=fa(t.data),Qx(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Ef(e)),t):(t.type==="exit"&&(e.exited=!0,Ef(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function Qx(e){for(;e.outputBytes>vv&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=fa(t)}e.outputBytes>vv&&e.output.length===1&&(e.output[0]=Q4(e.output[0],vv),e.outputBytes=fa(e.output[0]))}function so(e,t){e.status!==t&&(e.status=t,xd(e,{type:"status",status:t}))}function xd(e,t){for(const n of Array.from(e.listeners))n(t)}function ho(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function T4(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function bo(e,t,n={}){Ni(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:ho(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??T4(t)}),ab+=1,Tf=0,ua(PE)}function E4(){if(Gx)return;Gx=!0;const e=()=>{document.visibilityState==="hidden"||uo||Sp()&&ua(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function ua(e){if(kf){ad=ad===null?e:Math.min(ad,e);return}yv!==null||uo||document.visibilityState==="hidden"||navigator.onLine===!1||(yv=window.setTimeout(()=>{yv=null,R4()},e))}async function R4(){if(kf||uo||document.visibilityState==="hidden"||navigator.onLine===!1)return;kf=!0;const e=ab;try{const t=await lM();if(t.outcome==="auth_blocked"){uo=!0;return}if(t.outcome==="retryable"){const n=Yx[Math.min(Tf,Yx.length-1)];Tf+=1,ua(n);return}if(Tf=0,t.outcome==="sent"&&t.hasMore){ua(0);return}}finally{kf=!1;const t=ad;ad=null,t!==null&&ua(t),ab!==e&&!uo&&ua(PE)}}function D4(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=U4(e,t);if(!r)return"rejected";const o=JSON.stringify(r),l=fa(o);if(l>l4)return"rejected";const d=n.durability!=="live-only",f={message:r,encoded:o,bytes:l,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:d};if(!$4(e,f))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&d&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(bo("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:ho(e)}),UE(e));const _=r.type!=="ping"&&r.type!=="resize";if(_&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Lp))return!d&&r.type==="input"?"rejected":N4(e,r)?(p&&g&&yo(e,g),"queued"):e.pendingOut.length>=sb||e.pendingOutBytes+l>rb?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=l,eC(e,f),p&&g&&yo(e,g),"queued");if(p){eC(e,f);try{return g.send(o),KE(e,f),"sent"}catch{if(_&&d&&e.pendingOut.length<sb&&e.pendingOutBytes+l<=rb)return e.pendingOut.push(f),e.pendingOutBytes+=l,g.close(),"queued";bl(e,f),g.close()}}return"rejected"}function yo(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Qs(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Lp){Z4(e,t),L4(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){FE(e,t);return}try{t.send(r.encoded),KE(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=ep,n=!0}e.outboundFlushDelayMs=ep,Qs(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&xd(e,{type:"outbound_flushed"})})}function N4(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const d=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(d===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:d}}}if(!r)return!1;const o=JSON.stringify(r),l=fa(o);return e.pendingOutBytes+=l-n.bytes,n.message=r,n.encoded=o,n.bytes=l,!0}function So(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=ep}function Qs(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function ip(e){return e.pendingOut.some(t=>t.message.type==="input")}function M4(e){return ip(e)||e.unackedInputs.size>0}function A4(e){if(!ip(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function L4(e,t){e.outboundStallWatchdog!==null||!ip(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!ip(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Lp;if(!n&&!r){yo(e,t);return}A4(e),fo(e)},h4))}function kr(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function FE(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&fo(e)},u4))}function WE(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function Cd(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function wo(e){WE(e),Cd(e)}function vl(e){WE(e),ub(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=Jx(e),r=j4(e),o=B4(e);if(n===null&&r===null&&o===null){Cd(e);return}if(e.inputAckProbe)return;const l=n===null?Number.POSITIVE_INFINITY:n+c4,d=Math.max(0,Math.min(l,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(ub(e,{notifyImmediately:!0})){vl(e);return}if(O4(e),Jx(e)===null){vl(e);return}I4(e,t)},d)}function j4(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+IE;t=t===null?r:Math.min(t,r)}return t}function O4(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<IE||(n.writeSlowReported=!0,bo("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function Jx(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function B4(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+BE;t=t===null?r:Math.min(t,r)}return t}function I4(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Lp){fo(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++m4).toString(36)}`;bo("terminal.input.delivery_probe_started",e,{pendingInputs:ho(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(bo("terminal.input.delivery_probe_timeout",e,{pendingInputs:ho(e)}),Cd(e),fo(e))},s4);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{Cd(e),fo(e)}}function wr(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function fo(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),So(e),Qs(e),kr(e),wo(e),wr(e,"reconnecting"),xo(e);const t=e.socket;e.socket=null,so(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Uc(e)}function P4(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),So(e),Qs(e),kr(e),wo(e),wr(e,"skipped"),xo(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Ef(e),e.listeners.clear()}function z4(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function H4(){return bv=(bv+1)%Number.MAX_SAFE_INTEGER,`${v4}-${bv.toString(36)}`.slice(0,ck)}function U4(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=H4();return n.length===0||n.length>ck?null:{...t,messageId:n}}function $4(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<sb&&e.unackedInputBytes+t.bytes<=rb)}function eC(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function bl(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function F4(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const l=e.pendingAckReceipts.get(n.messageId);l?.terminalId===n.terminalId&&db(e,t,l);return}if(bl(e,r),vl(e),!Ly(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),db(e,t,o)}function W4(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",vl(e))}function K4(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(bl(e,n),vl(e))}function KE(e,t){if(t.message.type!=="input"||!t.message.messageId||!Ly(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",vl(e)}function q4(e){if(ub(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){bl(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function ub(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[l,d]of e.unackedInputs)d.firstSentAt!==null&&n-d.firstSentAt>=BE&&(r.add(l),d.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(l=>{const d=l.message.type==="input"?l.message.messageId:void 0;return!d||!r.has(d)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-l.bytes),!1)});for(const l of r){const d=e.unackedInputs.get(l);d&&bl(e,d)}return o>0&&(YE(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&Ay(e)),!0}function V4(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function Y4(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){qE(e,t);return}kr(e);const l=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,l===n?(q4(e),G4(e,t)):l!==null&&(VE(e),GE(e)),yo(e,t)}function qE(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",kr(e),e.serverInstanceId=null,VE(e),GE(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;bl(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const l=fa(n.encoded);e.pendingOutBytes+=l-n.bytes,n.bytes=l}yo(e,t)}}function VE(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&bl(e,o)}n>0&&YE(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function YE(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Ay(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)xd(e,{type:"message",message:{type:"error",message:n.message}})}}function Ef(e){So(e),Qs(e),kr(e),wo(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function db(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Ly(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Ly(e){return e==="ack"||e==="receipt-ack"}function G4(e,t){for(const n of e.pendingAckReceipts.values())if(db(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function X4(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function GE(e){e.pendingAckReceipts.clear()}function Z4(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(d4,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,yo(e,t)},n)}function fa(e){return g4.encode(e).byteLength}function Q4(e,t){if(fa(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);fa(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const J4=[0,50,150,350],eI=[100,300,750],tI=2,nI=[300,1200,2500],iI=1e3,sI=1e5,rI="",hb="\x1B[?1049l\x1B[?1047l\x1B[?47l",aI=new Set(["47","1047","1049"]),oI=400,wv=9,lI=9,cI=32,uI=1.42,dI=2,hI=24,fI=720,pI=60,mI=1260,gI=6,vI=2,tC=[500,1500,3e3,5e3,8e3],nC=15e3,_I=2,bI=1e3,iC="Do not take action. Wait for my next input.",sp=6e4,yI=sp+5*6e4,sC=sp+6e4,SI=40,sf=240,wI=5e3,ld=new Map,pc=new Map;function rC({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:l=!1,tabId:d,codeServerContext:f,onSelect:g,onClose:p,onExit:b,onSnapshot:_,onAuthClose:w}){const C=v.useSyncExternalStore(iT,i_,()=>cl),x=v.useSyncExternalStore(sT,s_,()=>Nc),T=v.useSyncExternalStore(rT,a_,()=>!0),A=v.useSyncExternalStore(mf,o_,()=>!0),M=v.useSyncExternalStore(mf,l_,()=>!0),W=v.useSyncExternalStore(Pb,po,()=>Rc),U=v.useSyncExternalStore(nd,()=>id("history.toggle"),()=>"Alt+H"),P=v.useSyncExternalStore(nd,()=>id("scrollback.toggle"),()=>"Alt+S"),F=v.useSyncExternalStore(nd,()=>id("subagents.toggle"),()=>"Alt+A"),V=v.useRef(null),O=v.useRef(null),G=v.useRef(null),fe=v.useRef(null),ee=v.useRef(null),te=v.useRef(e.id),$=v.useRef({onExit:b,onSnapshot:_}),Z=v.useRef(t.createWebSocketUrl),ie=v.useRef(w),J=v.useRef(null),j=v.useRef(null),R=v.useRef(null),I=v.useRef(!1),re=v.useRef(new Map),_e=v.useRef(new Map),N=v.useRef(new Set),Y=v.useRef([]),oe=v.useRef(!1),Q=v.useRef(null),we=v.useRef(0),Se=v.useRef(!1),ue=v.useRef(!1),Re=v.useRef(!1),Oe=v.useRef({terminalId:e.id,enabled:!1}),ge=v.useRef([]),He=v.useRef([]),Be=v.useRef(0),L=v.useRef(!1),ve=v.useRef(null),Le=v.useRef(0),Pe=v.useRef(0),H=v.useRef(null),de=v.useRef(null),Te=v.useRef(!1),Me=v.useRef(!1),je=v.useRef(!1),be=v.useRef(null),Fe=v.useRef(!1),We=v.useRef(null),Ue=v.useRef(null),ut=v.useRef(!1),_t=v.useRef(!1),lt=v.useRef(!1),Nt=v.useRef(!1),Yt=v.useRef(!1),st=v.useRef(!1),On=v.useRef(!1),Sn=v.useRef(n),dt=v.useRef(r),Lt=v.useRef(l),Ct=v.useRef(C),gi=v.useRef(x),ki=v.useRef(!1),pe=v.useRef(!1),Ze=v.useRef(null),at=v.useRef(null),mt=v.useRef(0),St=v.useRef(0),It=v.useRef(e.id),$t=v.useRef(()=>{}),dn=v.useRef(null),Gt=v.useRef(null),rn=v.useRef(!1),hn=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),an=v.useRef(0),ln=v.useRef(null),En=v.useRef(0),wn=v.useRef(null),vi=v.useRef(0),si=v.useRef(!1),ht=v.useRef(!1),kt=v.useRef(null),ae=v.useRef(null),[,Ce]=v.useState("connecting"),[Ye,Xe]=v.useState(!1),[et,fn]=v.useState(null),[xn,Mi]=v.useState(!1),[Ft,Ai]=v.useState(null),[vs,$n]=v.useState(!1),[Li,Ki]=v.useState(!1),[pn,ri]=v.useState(!1),[Tr,ji]=v.useState(!1),[cn,_s]=v.useState(null),[Co,ga]=v.useState([]),Er=v.useRef([]),Xn=e.agentCache&&cn&&e.agentCache.source.provider===cn.provider&&e.agentCache.source.sessionId===cn.sessionId?e.agentCache:null,[zs,qi]=v.useState(()=>Date.now()),[Rn,Rr]=v.useState(!1),[va,Dr]=v.useState(null),[_a,bs]=v.useState(!1),[ko,Bn]=v.useState(!1),[_i,ir]=v.useState(null),[To,Vi]=v.useState(!1),[Eo,Nr]=v.useState(!1),[Hs,sr]=v.useState(null),[Ro,Do]=v.useState(null),ss=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[$c,ba]=v.useState(()=>Wg(e.id)),Oi=cn?.provider??e.agentStatus?.provider??null,Bi=Oi!==null||mc(e.currentCommand),Us=Oi==="claude"||e2(e.currentCommand),ys=Oi!==null||mc(e.currentCommand),Ti=e.capabilities?.tmuxScrollback===!0,ai=Ti&&($c??(ys?M:A)),[ya,Ar]=v.useState(!1);v.useLayoutEffect(()=>{Sn.current=n},[n]),v.useLayoutEffect(()=>{dt.current=r},[r]),v.useLayoutEffect(()=>{Lt.current=l},[l]),v.useLayoutEffect(()=>{Ct.current=C},[C]),v.useLayoutEffect(()=>{gi.current=x},[x]),v.useLayoutEffect(()=>{ki.current=_a},[_a]),v.useLayoutEffect(()=>{pe.current=ko},[ko]),v.useLayoutEffect(()=>{at.current=cn},[cn]);const Ii=v.useCallback((E,K={})=>{!E&&K.preserveOnNull||(jx(at.current,E)||(St.current+=1),at.current=E,_s(ze=>ze&&E&&ze.provider===E.provider&&ze.sessionId===E.sessionId?ze:E))},[]),Yi=v.useCallback(async()=>{const E=await t.getTerminalTranscriptSource(e.id);return It.current===e.id&&(Er.current=E.candidates??[],ga(E.candidates??[])),E.source},[t,e.id]),Lr=v.useCallback(()=>{Bn(!1),bs(!0)},[]),$s=v.useCallback(()=>{at.current&&(bs(!1),Bn(!0))},[]),Ei=v.useCallback(async(E={})=>{const K=await oC(ss,t,E);return ir(K),K},[ss,t]),Pi=v.useCallback((E,K="info")=>{wn.current!==null&&window.clearTimeout(wn.current),Do({id:En.current++,message:E,tone:K}),wn.current=window.setTimeout(()=>{Do(null),wn.current=null},3200)},[]),jr=v.useCallback(()=>{const E=f?.serverKey.trim()||"local",K=f?.serverName.trim()||"Local",ze=f?.tabName.trim()||e.title||"Terminal",Je=_i?.instances.find(Tt=>Tt.cwd===e.cwd);if(Je&&lC(rf(E,Je.id))){Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Je&&xv(rf(E,Je.id),Je.url)){Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let tt=null;const pt=()=>((!tt||ZE(tt))&&(tt=window.open("about:blank","_blank"),xI(tt)),tt);_i?.installed!==!0&&pt(),Nr(!0),sr(null),(async()=>{let Tt=_i;if(Tt?.installed||(Tt=await Ei({force:!0})),!Tt?.installed||Tt.supported===!1){Cv(tt),Vi(!0);return}const Et=Tt.instances.find(Jt=>Jt.cwd===e.cwd);if(Et){const Jt=rf(E,Et.id);if(cC(tt,Jt,Et.url)||xv(Jt,Et.url)!==null){Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const rt=pt();return{response:await t.openCodeServer({terminalId:e.id,serverName:K,tabName:ze}),targetPopup:rt}})().then(Tt=>{if(!Tt)return;const{response:Et,targetPopup:rt}=Tt;fb(ss,Et.status),ir(Et.status);const un=rf(E,Et.instance.id);if(lC(un)){Cv(rt),Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}cC(rt,un,Et.url)||xv(un,Et.url)?Pi("Opening VS Code..."):Pi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(Tt=>{Cv(tt),Vi(!0),sr(af(Tt))}).finally(()=>Nr(!1))},[f?.serverName,f?.tabName,ss,_i,Ei,t,Pi,e.cwd,e.id,e.title]);v.useEffect(()=>{let E=!1;return oC(ss,t).then(K=>{E||ir(K)}).catch(()=>{}),()=>{E=!0}},[ss,t]),v.useEffect(()=>{if(_i?.job?.status!=="running")return;const E=window.setInterval(()=>{Ei({force:!0}).catch(K=>sr(af(K)))},1e3);return()=>window.clearInterval(E)},[_i?.job?.status,Ei]),v.useEffect(()=>()=>{wn.current!==null&&window.clearTimeout(wn.current)},[]),v.useLayoutEffect(()=>{$t.current=Lr},[Lr]),v.useLayoutEffect(()=>{Gt.current=Xn},[Xn]),v.useLayoutEffect(()=>{rn.current=Rn},[Rn]),v.useLayoutEffect(()=>{si.current=Bi},[Bi]),v.useLayoutEffect(()=>{ht.current=Us},[Us]),v.useLayoutEffect(()=>{const E=Oe.current;ue.current=ai,Re.current=Ti,Oe.current={terminalId:e.id,enabled:ai},dC(V.current,ai),E.terminalId===e.id&&E.enabled&&!ai&&Ir(),ai||ri(!1)},[e.id,ai,Ti]),v.useEffect(()=>{ba(Wg(e.id)),we.current=0,Se.current=!1,ri(!1),Wt()},[e.id]),v.useEffect(()=>mf(()=>{ba(Wg(e.id))}),[e.id]),v.useEffect(()=>()=>{Gc()},[]),v.useEffect(()=>{ee.current?.(r&&e.status==="running"),r&&e.status==="running"&&Ws()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&ws("auto")},[n,r,e.status]),v.useEffect(()=>{$.current={onExit:b,onSnapshot:_}},[b,_]),v.useLayoutEffect(()=>{Z.current=t.createWebSocketUrl,ie.current=w},[t,w]),v.useLayoutEffect(()=>{te.current=e.id,On.current=!1,ji(!1)},[e.id]),v.useEffect(()=>{let E=!1,K=null,ze=0;const Je=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",tt=Je||qI(e.currentCommand),pt=Je||mc(e.currentCommand);function Tt(){K!==null&&(window.clearTimeout(K),K=null)}function Et(un){if(E)return;let Jt;if(un)Jt=nC;else if(ze<tC.length){if(!tt)return;Jt=tC[ze++]}else{if(!pt)return;Jt=nC}K=window.setTimeout(()=>{K=null,rt()},Jt)}async function rt(){try{const un=at.current!==null,Jt=await Yi();if(E)return;if(Jt){mt.current=0,Ii(Jt),Et(!0);return}mt.current+=1;const Xt=!!(un&&tt&&mt.current<_I);Ii(null,{preserveOnNull:Xt}),Et(Xt)}catch(un){if(E)return;Tv(un)&&Ii(null),Et(!1)}}return It.current!==e.id&&(Er.current=[],ga([]),It.current=e.id,St.current+=1,at.current=null,mt.current=0,_s(null)),e.status!=="running"?(St.current+=1,at.current=null,mt.current=0,_s(null),()=>{E=!0,Tt()}):(rt(),()=>{E=!0,Tt()})},[Ii,Yi,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const E=TI(e.id,cn),K=dn.current;K!==null&&E!==null&&K!==E&&(de.current=null,Te.current=!1,Me.current=!1,Bn(!1)),dn.current=E},[e.id,cn?.provider,cn?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!cn){Rr(!1);return}const E=window.setInterval(()=>{qi(Date.now())},bI);return()=>{window.clearInterval(E)}},[e.status,cn?.provider,cn?.sessionId]),v.useEffect(()=>{const E=kI(Xn);hn.current.key!==E&&(hn.current={key:E,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[Xn?.expiresAt,Xn?.source?.provider,Xn?.source?.sessionId]),v.useEffect(()=>{if(!Rn||!Xn||Xn.status!=="ready")return;const E=QE(Xn,zs);if(E===null||E<=0)return;const K=hn.current;!K.warnedFiveMinutes&&E<=yI&&E>sC&&(K.warnedFiveMinutes=!0,dr({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!K.warnedOneMinute&&E<=sC&&E>sp&&(K.warnedOneMinute=!0,dr({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!K.sent&&!K.skipped&&E<=sp&&$d()},[Rn,zs,Xn,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function E(K){if(!Sn.current||!dt.current||K.isComposing||K.key==="Process"||DI(K.target))return;const ze=cT(K);if(ze?.id==="history.toggle"&&(at.current||Er.current.length)){K.preventDefault(),K.stopPropagation(),ki.current?bs(!1):$t.current();return}if(ze?.id==="subagents.toggle"&&at.current){K.preventDefault(),K.stopPropagation(),pe.current?Bn(!1):$s();return}if(ze?.id==="scrollback.toggle"&&Re.current){K.preventDefault(),K.stopPropagation(),qs();return}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[]),v.useEffect(()=>{const E=O.current;E&&(E.options.disableStdin=e.status==="exited"),e.status==="exited"&&Ce("closed")},[e.status]),v.useEffect(()=>{const E=O.current;E&&(E.options.fontSize=C,Fg(C,gi.current).then(()=>{Ct.current===C&&Fn()}))},[C]),v.useEffect(()=>{const E=O.current;E&&(E.options.fontFamily=n_(x),Fg(Ct.current,x).then(()=>{gi.current===x&&Fn()}))},[x]),v.useEffect(()=>{const E=O.current;E&&(E.options.theme=aC(W))},[W]),v.useEffect(()=>{const E=V.current;if(!E)return;let K=!1,ze=null,Je=null,tt=null,pt=null,Tt=null,Et=null,rt=null;J.current=null,Yt.current=!1,st.current=!1,Fe.current=!1,Rl(),Dl(),rr(),oe.current=!1;const un=Ct.current,Jt=gi.current,Xt=new s5({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:n_(Jt),fontSize:un,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:sI,theme:{...aC(po())}}),Vs=new GL;return Xt.loadAddon(Vs),pt=ZB(Xt),O.current=Xt,G.current=Vs,Fg(un,Jt).then(()=>{if(K)return;Xt.open(E),dC(E,ue.current),Yt.current=!0,ze=UB(Xt,{onPasteText:Wd,onInterrupt:Fd,shouldInterruptPlainCtrlC:()=>ht.current}),dt.current&&Sn.current&&e.status==="running"&&ws("auto"),Fn(),Tt=QI(E,Xt,()=>Ct.current*1.2,Gi,xs=>{ot(xs)},ka,S,()=>ue.current,Dn),Et=GI(E,Xt,Gi,xs=>{ot(xs)},ka,S,()=>ue.current,Dn);const Po=new j5;Je=Xt.onData(xs=>{if(On.current){const zo=F5(xs);if(zo){Bo(!1),rs(zo);return}}const Xi=Po.accept(xs);Xi&&rs(Xi)}),tt=Xt.onScroll(xs=>{if(_t.current||Nt.current||lt.current){Qn();return}Ml(),ps(Xt)&&li({scrollToBottom:!0}),Gi(),!ue.current&&xs<=3&&ot()}),rt=new ResizeObserver(()=>{Tl()}),rt.observe(E),st.current&&(oi(),st.current=!1,Fn()),cr()}),()=>{Pr(fe.current,{updateUi:!1}),K=!0,Yt.current=!1,st.current=!1,Rl(),Dl(),j.current=null,R.current=null,I.current=!1,Nl(),oe.current=!1,jo(),lt.current=!1,L.current=!1,Le.current+=1,Pe.current+=1,ve.current=null,kt.current=null,ae.current=null,je.current=!1,be.current=null,Xe(!1),Tt?.(),Et?.(),rt?.disconnect(),ze?.dispose(),Je?.dispose(),tt?.dispose(),pt?.dispose(),Xt.dispose(),O.current=null,G.current=null}},[e.id]),v.useEffect(()=>{const E=Z.current(e.id),K=_4(E,xl);return fe.current=K.send,ee.current=K.setForeground,K.setForeground(dt.current&&e.status==="running"),Ce(K.status),K.status==="connected"&&Fn(),K.snapshot&&($.current.onSnapshot(K.snapshot,{notifyCompletion:!1}),O.current&&(Fn(),Fs(K.output,K.history),Fn())),()=>{Pr(K.send,{updateUi:!1}),K.setForeground(!1),K.detach(),fe.current=null,ee.current=null}},[e.id,e.status]);function xl(E){if(E.type==="status"){Ce(E.status),E.status==="unauthorized"&&ie.current?.({source:"terminal-ws-1008",terminalId:e.id}),E.status==="connected"&&(Fn(),Lo());return}if(E.type==="upgrade_rejected"){ie.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(E.type==="outbound_flushed"){oe.current&&(oe.current=!1,Xc());return}Sa(E.message)}function rr(E=[],K=null){ge.current=[],He.current=of(E),Be.current=0,L.current=!1,ve.current=null,lt.current=!1,Le.current+=1,H.current=K,de.current=null,Te.current=!1,Me.current=!1,je.current=!1,be.current=null,st.current=!1,kt.current=null,ae.current=null,We.current=null,ut.current=!1,Xe(!1),fn(null),Mi(!1),Ai(null),$n(!1),Ki(!1)}function Fs(E=[],K=null){if(lt.current||L.current){ae.current={output:E,history:K,appendFromLiveOutputIndex:He.current.length};return}rr(E,K),Zn()}function ar(){if(lt.current||L.current)return!1;const E=ae.current;if(!E)return!1;const K=He.current.slice(E.appendFromLiveOutputIndex);return ae.current=null,rr([...E.output,...K],E.history),Zn(),!0}function Zn(){if(!O.current||!Yt.current){st.current=!0;return}st.current=!1,oi()}async function oi(){const E=O.current;if(!E)return;const K=lf(E,ut.current),ze=K?He.current.length:Be.current,Je=await Ss(E,{liveOutputLimit:ze,scrollToBottom:K});O.current===E&&(Qn(),Je&&Lo())}function Ss(E,K={}){return new Promise(ze=>{lt.current=!0,L.current=!1;const Je=Le.current+1;Le.current=Je;const tt=Math.max(0,Math.min(K.liveOutputLimit??He.current.length,He.current.length)),pt=K.historyPages??ge.current,Tt=()=>O.current===E&&Le.current===Je,Et=()=>Tt()&&(K.isCurrent?.()??!0),rt=()=>{Tt()&&(lt.current=!1),ze(!1)},un=()=>{if(!Et()){rt();return}try{Be.current=tt,K.scrollToBottom&&k(E)}finally{if(lt.current=!1,ar()){ze(!1);return}const Xt=Al();Xt?li(Xt):K.applyDeferredSnapshot!==!1&&Ca(),ze(!0)}},Jt=()=>{if(!Et()){rt();return}E.clear();const Xt=of([...pt,...He.current.slice(0,tt)]);if(Xt.length===0){un();return}for(let Vs=0;Vs<Xt.length;Vs+=1){const Po=Xt[Vs];Vs===Xt.length-1?E.write(Po,un):E.write(Po)}};if(E.buffer.active.type==="alternate"){E.write(hb,Jt);return}Jt()})}async function ot(E=0){const K=O.current;if(je.current||!K)return;if(Or(K)){Qn();return}const ze=H.current,Je=Pe.current,tt=Symbol("history-load"),pt=()=>O.current===K&&Pe.current===Je;be.current=tt,je.current=!0,Xe(!0);const Tt=K.buffer.active.viewportY;try{let Et=!!(ze&&!ze.hasMore);if(!Et)try{const rt=await t.getTerminalHistory(e.id,{beforeLine:ze?.startLine??0,...ze?.snapshotHistorySize!==void 0?{snapshotHistorySize:ze.snapshotHistorySize}:{},...ze?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:ze.snapshotHistoryLimit}:{},...ze?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:ze.snapshotHistoryToken}:{},...ze?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:ze.snapshotPaneWidth}:{},limit:iI});if(!pt()||H.current!==ze)return;const un=()=>pt()&&H.current===ze;if(rt.invalidated){Ks();return}const Jt=rt.hasMore&&rt.snapshotHistorySize!==void 0&&rt.snapshotPaneWidth!==void 0,Xt={startLine:rt.startLine,endLine:rt.endLine,hasMore:Jt,...rt.snapshotHistorySize!==void 0?{snapshotHistorySize:rt.snapshotHistorySize}:{},...rt.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:rt.snapshotHistoryLimit}:{},...rt.snapshotHistoryToken!==void 0?{snapshotHistoryToken:rt.snapshotHistoryToken}:{},...rt.snapshotPaneWidth!==void 0?{snapshotPaneWidth:rt.snapshotPaneWidth}:{}};if(rt.output.length>0){await or(K,rt.output,Tt,E)&&un()&&(H.current=Xt);return}if(!un())return;H.current=Xt,Et=!Jt}catch(rt){Et=pt()&&Tv(rt)}if(Et){if(!pt()||Or(K)){Qn();return}await No(K,Tt,E,pt)}}catch{}finally{be.current===tt&&(be.current=null,je.current=!1,Xe(!1))}}async function No(E,K,ze,Je){if(!Je()||Te.current||Me.current)return;const tt=at.current,pt=St.current,Tt=de.current,Et=()=>Je()&&St.current===pt&&jx(tt,at.current)&&de.current===Tt;try{const rt=await t.getTerminalTranscriptHistory(e.id,{...Tt?{cursor:Tt}:{},limit:oI}),un=rt.output.map(Cy);if(!rt.source||rt.terminalId!==e.id||!Et())return;if(tt&&!ca(tt,rt.source)){de.current=null,Te.current=!1,Me.current=!1,Ii(rt.source);return}if(un.length===0){Ii(rt.source),de.current=rt.cursor,Me.current=!rt.hasMore||!rt.cursor;return}await or(E,un,K,ze,Et)&&Et()&&(Ii(rt.source),de.current=rt.cursor,Me.current=!rt.hasMore||!rt.cursor)}catch(rt){Et()&&Tv(rt)&&(Te.current=!0)}}async function or(E,K,ze,Je,tt){if(Or(E)||tt&&!tt())return Qn(),!1;const pt=ge.current,Tt=[...K,...pt],Et=VI(K),rt=Le.current+1,un=await Ss(E,{liveOutputLimit:Be.current,scrollToBottom:!1,historyPages:Tt,applyDeferredSnapshot:!1,...tt?{isCurrent:tt}:{}}),Jt=tt!==void 0&&!tt();return!un||Jt||O.current!==E?(Jt&&O.current===E&&Le.current===rt&&await Ss(E,{liveOutputLimit:Be.current,scrollToBottom:!1,historyPages:pt,applyDeferredSnapshot:!1})&&O.current===E&&(B(E,ze),ut.current=!ps(E),Gi()),!1):(ge.current=Tt,B(E,Math.max(0,ze+Et+Math.min(0,Je))),ut.current=!ps(E),Gi(),!0)}v.useEffect(()=>{const E=window.visualViewport;function K(){document.visibilityState!=="hidden"&&Ws()}function ze(){Ws()}function Je(){Ws()}function tt(){Tl()}function pt(){Mo()}return document.addEventListener("visibilitychange",K),window.addEventListener("pageshow",ze),window.addEventListener("online",Je),window.addEventListener("resize",tt),window.addEventListener(Qf,pt),E?.addEventListener("resize",tt),E?.addEventListener("scroll",tt),()=>{document.removeEventListener("visibilitychange",K),window.removeEventListener("pageshow",ze),window.removeEventListener("online",Je),window.removeEventListener("resize",tt),window.removeEventListener(Qf,pt),E?.removeEventListener("resize",tt),E?.removeEventListener("scroll",tt)}},[e.id]);function Ws(){document.visibilityState==="hidden"||!dt.current||(Lo(),Fn())}function Ks(){const E=Z.current(e.id);Pe.current+=1,Fe.current=!0,kt.current=null,Ce("reconnecting"),Fn(),b4(E)}function Sa(E){if(E.type==="snapshot"&&E.terminal.id===e.id){Pe.current+=1,$.current.onSnapshot(E.terminal,{notifyCompletion:!1});const ze=Fe.current;Fe.current=!1;const Je=O.current;if(!Je)return;if(Fn(),ze){Cl(E.output,E.history??null);return}if(Oo(Je,E.terminal)){Yc(E.output,E.history??null),Qn(),Fn();return}Fs(E.output,E.history??null),Fn();return}if(E.type==="terminal_updated"&&E.terminal.id===e.id){$.current.onSnapshot(E.terminal,{notifyCompletion:!0});return}if(E.type==="output"&&E.terminalId===e.id){const ze=t2(E.data);if(!ze)return;He.current.push(ze),O.current&&Yt.current?li({scrollToBottom:!0}):st.current=!0;return}const K=O.current;if(K){if(E.type==="exit"&&E.terminalId===e.id){$.current.onExit(E.exitCode),Ce("closed");return}E.type==="error"&&K.writeln(`\r
|
|
51
|
+
[nterminal] ${E.message}`)}}function Cl(E,K){Fs(E,K),Fn()}function kl(E=25){if(document.visibilityState==="hidden"||!dt.current||re.current.has(E))return;const K=window.setTimeout(()=>{re.current.delete(E),!El()&&qe()},E);re.current.set(E,K)}function Tl(){El()||cr()}function El(){const E=Ao();return E&&Fc(E)?(I.current=!0,R.current=E,!0):E&&Wc(E)?(I.current=!1,R.current=null,!0):((!E||!E.composeOpen&&!E.keyboardVisible)&&(I.current=!1,R.current=null),!1)}function Mo(){if(!I.current)return;const E=Ao();E&&(E.composeOpen||E.keyboardVisible)||(I.current=!1,R.current=null)}function Fc(E){if(!E.mobileLike||!E.composeOpen&&!E.keyboardVisible)return!1;const K=j.current;return K?bi(E.windowWidth,K.windowWidth)&&bi(E.visualViewportWidth,K.visualViewportWidth)&&bi(E.containerWidth,K.containerWidth):!1}function Wc(E){if(!E.mobileLike||E.composeOpen||E.keyboardVisible)return!1;const K=R.current;return!K||!K.composeOpen&&!K.keyboardVisible?!1:bi(E.windowWidth,K.windowWidth)&&bi(E.visualViewportWidth,K.visualViewportWidth)&&bi(E.containerWidth,K.containerWidth)}function Ao(){const E=V.current;if(!E||E.isConnected===!1)return null;const K=E.getBoundingClientRect(),ze=lr(window.innerWidth)??0,Je=lr(window.visualViewport?.width)??ze,tt=lr(K.width)??lr(E.clientWidth)??ze;if(ze<=0||Je<=0||tt<=0)return null;const{keyboardVisible:pt}=eb(),Tt=document.documentElement.hasAttribute(Np),Et=Kc()||pt;return{windowWidth:ze,visualViewportWidth:Je,containerWidth:tt,composeOpen:Tt,keyboardVisible:pt,mobileLike:Et}}function Kc(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function wa(){return eb().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function lr(E){return typeof E=="number"&&Number.isFinite(E)&&E>0?E:null}function bi(E,K){return Math.abs(E-K)<=tI}function cr(){for(const E of J4)kl(E)}function Fn(){J.current=null,cr()}function Lo(){if(ur(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const E=window.requestAnimationFrame(()=>{N.current.delete(E),ur();const K=window.requestAnimationFrame(()=>{N.current.delete(K),ur()});N.current.add(K)});N.current.add(E)}for(const E of eI){if(_e.current.has(E))continue;const K=window.setTimeout(()=>{_e.current.delete(E),ur()},E);_e.current.set(E,K)}}function ur(){const E=O.current;if(!(!E||!Yt.current||document.visibilityState==="hidden"||!dt.current||V.current?.isConnected===!1))try{E.refresh(0,Math.max(0,E.rows-1))}catch{}}function Rl(){for(const E of re.current.values())window.clearTimeout(E);re.current.clear()}function Dl(){for(const E of _e.current.values())window.clearTimeout(E);_e.current.clear();for(const E of N.current)window.cancelAnimationFrame(E);N.current.clear()}function Nl(){for(const E of Y.current)window.clearTimeout(E);Y.current=[]}function Gi(){if(Qn(),!We.current){Mi(!1);return}Mi(!0),jo(),Ue.current=window.setTimeout(()=>{Ue.current=null,Mi(!1)},1200)}function Qn(){const E=O.current,K=E?YI(E):null;if(We.current=K,fn(K),Ki(!!(E&&K)),$n(!!(E&&K&&!ps(E))),K||!E||!qc()){Ai(null);return}Ai({alternate:E.buffer.active.type==="alternate"})}function qc(){const E=H.current;return ge.current.length>0||!!E?.hasMore}function jo(){Ue.current!==null&&(window.clearTimeout(Ue.current),Ue.current=null)}function Ml(){const E=O.current;E&&(ut.current=!ps(E),Qn())}function xa(E){ve.current=Ev(ve.current,E)}function Vc(E){const K=ve.current;return ve.current=null,Ev(K,E)}function Al(){const E=ve.current;return ve.current=null,E}function li(E={}){const K=O.current;if(!K||!Yt.current){st.current=!0;return}if(kt.current&&!lt.current&&!L.current&&ps(K)){Ca();return}if(lt.current){xa(E);return}if(L.current){xa(E);return}const ze=Vc(E);if(!ze.force&&!lf(K,ut.current)){Qn();return}L.current=!0;const Je=Le.current,tt=()=>{if(O.current!==K||Le.current!==Je)return;if(!ze.force&&!lf(K,ut.current)){if(L.current=!1,ar())return;Qn();return}const pt=Be.current,Tt=He.current[pt];if(Tt===void 0){if(L.current=!1,ar())return;ze.scrollToBottom&&k(K),Qn();const Et=Al();Et?li(Ev(ze,Et)):Ca();return}K.write(Tt,()=>{O.current!==K||Le.current!==Je||(Be.current=pt+1,tt())})};tt()}function Or(E){return kt.current!==null||!ps(E)&&(Br()||L.current||lt.current)}function Oo(E,K){return(K?.agentStatus?.provider==="codex"||K?.agentStatus?.provider==="claude"||si.current||mc(K?.currentCommand))&&!ps(E)}function Br(){return Be.current<He.current.length}function Yc(E,K){kt.current={output:E,history:K,appendFromLiveOutputIndex:He.current.length}}function Ca(){const E=O.current,K=kt.current;if(!E||!K||!ps(E)||L.current||lt.current)return;const ze=of(K.output),Je=of(He.current.slice(K.appendFromLiveOutputIndex));kt.current=null,Fs([...ze,...Je],K.history),Fn()}function ka(){Nt.current=!0}function S(){Ml(),Nt.current=!1;const E=O.current;E&&ps(E)&&li({scrollToBottom:!0})}function k(E){X(()=>hC(E))&&(ut.current=!1)}function B(E,K){X(()=>(E.scrollToLine(K),!0))}function X(E){_t.current=!0;try{return E()}finally{_t.current=!1}}function se(){const E=O.current;if(!E)return;const K=()=>{ue.current&&(Ta(fe.current),ri(!1)),hC(E),ut.current=!1,Qn(),li({force:!0,scrollToBottom:!0}),ws("scroll-action")};if(E.buffer.active.type==="alternate"){E.write(hb,K);return}K()}function le(E){const K=O.current,ze=V.current;if(!K||!ze)return;const Je=ze.getBoundingClientRect();if(Je.height<=0)return;const tt=Math.max(0,Math.min(1,(E-Je.top)/Je.height)),pt=Math.round(K.buffer.active.baseY*tt);ka();try{K.scrollToLine(pt)}finally{S()}ut.current=!ps(K),Qn(),Gi(),pt<=3&&ot()}function De(E){E.preventDefault(),E.stopPropagation(),E.currentTarget.setPointerCapture?.(E.pointerId),le(E.clientY)}function Ie(E){(E.buttons&1)!==0&&(E.preventDefault(),E.stopPropagation(),le(E.clientY))}function qe(){const E=O.current,K=G.current;if(!(!E||!K)&&!(document.visibilityState==="hidden"||!dt.current||V.current?.isConnected===!1))try{const ze=lf(E,ut.current),Je=Ao();K.fit(),Je&&(j.current=Je),ze&&k(E),E.refresh(0,Math.max(0,E.rows-1)),Qn();const tt={cols:E.cols,rows:E.rows},pt=J.current;if(pt&&pt.cols===tt.cols&&pt.rows===tt.rows)return;ft({type:"resize",terminalId:e.id,cols:tt.cols,rows:tt.rows})&&(J.current=tt)}catch{}}function Ke(E,K){const ze=fe.current;return ze?ze(E,K):"rejected"}function ft(E){return Ke(E)!=="rejected"}function Wt(){Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)}function jt(){Wt();const E=Math.max(-sf,Math.min(sf,we.current));if(we.current=0,E===0)return!1;const K=ft({type:"scrollback_scroll",terminalId:e.id,lines:E});return K&&(Se.current=!0,E<0&&ri(!0)),K}function Dn(E){if(!ue.current||E===0)return;const K=we.current+E;we.current=Math.max(-sf,Math.min(sf,K)),Q.current===null&&(Q.current=window.setTimeout(()=>{Q.current=null,jt()},SI))}function Ir(){Ta(fe.current)}function Pr(E=fe.current,K={}){const ze=Se.current;Wt(),we.current=0,Se.current=!1,K.updateUi!==!1&&ri(!1),ze&&E?.({type:"cancel_scrollback",terminalId:e.id})}function Ta(E){Wt(),we.current=0,Se.current=!1,ri(!1),E?.({type:"cancel_scrollback",terminalId:e.id})}function qs(){if(!Re.current)return;const E=!ue.current;ba(aL(te.current,E)),zi()}function Ud(){const E=!rn.current;rn.current=E,Rr(E),dr({tone:E?"info":"skipped",message:E?"Cache keep-alive enabled":"Cache keep-alive off",...E?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Gc(){ln.current!==null&&(window.clearTimeout(ln.current),ln.current=null)}function dr(E,K={}){Gc();const ze=an.current+1;an.current=ze,Dr({...E,id:ze}),!K.sticky&&(ln.current=window.setTimeout(()=>{ln.current=null,Dr(Je=>Je?.id===ze?null:Je)},12e3))}function Pp(){hn.current.skipped=!0,dr({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function zp(){rn.current=!1,Rr(!1),dr({tone:"skipped",message:"Cache keep-alive off"})}async function $d(){const E=hn.current;if(E.sent||E.skipped)return;const K=Hp();if(E.sent=!0,K){dr({tone:"skipped",message:"Skipped cache keep-alive",detail:K});return}if(rs(`${iC}\r`,{userInitiated:!1})==="rejected"){dr({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}dr({tone:"success",message:"Cache keep-alive sent",detail:iC})}function Hp(){const E=Gt.current,K=at.current;return rn.current?e.status!=="running"?"Pane is not running.":!E||E.status!=="ready"||!E.source||!K?"Transcript cache status is unavailable.":E.source.provider!==K.provider||E.source.sessionId!==K.sessionId?"The transcript session changed.":e.agentStatus&&["working","finishing","waiting"].includes(e.agentStatus.state)?`${co(K.provider)} has an active turn or is waiting for a response.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":kc(e.id).text.trim()?"Compose has an unsent draft.":NI(V.current)?"Pane input is focused.":Date.now()-vi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function zi(){const E=O.current;E&&(k(E),Qn())}function rs(E,K={}){jt();const ze=Se.current;li({force:!0,scrollToBottom:!0});const Je=Ke({type:"input",terminalId:e.id,data:E,...ze?{cancelScrollbackMode:!0}:{}},{durability:K.userInitiated===!1?"live-only":"durable"});return Je==="rejected"?(K.userInitiated!==!1&&Pi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Je):(K.userInitiated!==!1&&(vi.current=Date.now()),ze&&(Se.current=!1,ri(!1)),KI(E)&&(Je==="sent"?Xc():Je==="queued"&&(oe.current=!0)),Je)}function Fd(){On.current&&Bo(!1),rs(rI)}function Wd(E){const K=hv(E,{bracketedPasteMode:O.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});K&&rs(K)}function Kd(E,K){const ze=O.current?.modes.bracketedPasteMode===!0,Je=Oi==="codex"||Oi==="claude"||mc(e.currentCommand),tt=E.parts.map(pt=>pt.kind==="image"&&Je?hv(pt.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):hv(pt.kind==="image"?pt.path:pt.value,{bracketedPasteMode:ze,stripTrailingLineBreaks:!1})).join("");return tt?rs(`${tt}${_B(K)}`)!=="rejected":!1}function Xc(){!Lt.current||!Sn.current||(Nl(),Y.current=nI.map(E=>{const K=window.setTimeout(()=>{Y.current=Y.current.filter(ze=>ze!==K),Lt.current&&Sn.current&&ft({type:"refresh_cwd",terminalId:e.id})},E);return K}))}function ws(E="terminal-interaction"){ki.current||wa()&&(E==="auto"||E==="scroll-action")||O.current?.focus()}const Up=v.useCallback(()=>{bs(!1)},[]);function Ea(){ji(E=>{const K=!E;return On.current=K,K}),ws("input-action")}function Bo(E){On.current=E,ji(E)}function Io(E){On.current&&Bo(!1),rs($5(E)),ws("input-action")}async function Ll(E="install"){Nr(!0),sr(null);try{const K=E==="update"?await t.updateCodeServer():await t.installCodeServer();fb(ss,K.status),ir(K.status)}catch(K){sr(af(K))}finally{Nr(!1)}}return u.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":ai?"true":"false",onMouseDown:()=>{n||g()},children:[u.jsx(MI,{terminal:e,canClose:o,tabId:d,transcriptSource:cn,hasTranscriptCandidates:Co.length>0,transcriptShortcutLabel:U,subagentsShortcutLabel:F,transcriptCacheStatus:Xn,transcriptCacheNow:zs,cacheKeepAliveEnabled:Rn,codeServerAvailable:!0,codeServerInstallState:_i===null?"unknown":_i.installed?"installed":"missing",codeServerBusy:Eo||_i?.job?.status==="running",codeServerSupported:_i?.supported!==!1,scrollbackShortcutLabel:P,tmuxScrollbackSupported:Ti,tmuxScrollbackEnabled:ai,onToggleCacheKeepAlive:Ud,onOpenCodeServer:jr,onToggleTmuxScrollback:qs,onOpenTranscript:Lr,onOpenSubagents:$s,onReload:Ks,onClose:p}),u.jsx("div",{className:"xterm-container",ref:V}),Ye?u.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:u.jsx("span",{"aria-hidden":"true"})}):null,T&&!ai&&et?u.jsxs("div",{className:"terminal-scroll-progress","data-active":xn,"aria-hidden":"true",children:[et.current,"/",et.total]}):T&&!ai&&Ft?u.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,vs||ai&&pn?u.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),se()},children:"↓"}):null,Li&&!ai?u.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:De,onPointerMove:Ie,children:u.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?ya?u.jsx(H5,{ctrlActive:Tr,onCtrl:Ea,onStandaloneKey:Io,onPreserveFocus:()=>ws("input-action"),onHide:()=>Ar(!1)}):u.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:E=>{E.stopPropagation(),ws("input-action")},onPointerDown:E=>{E.stopPropagation(),ws("input-action")},onClick:()=>Ar(!0),children:"⌨"}):null,u.jsx(DB,{terminalId:e.id,onSubmit:Kd,onUploadAttachments:(E,K)=>t.uploadComposeAttachments({terminalId:e.id,files:E,signal:K.signal,onProgress:K.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:E=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:E})}:{},queueAvailable:Oi==="codex"||JE(e.currentCommand),disabled:e.status!=="running"}),u.jsx(OI,{toast:va,onSendNow:()=>{$d()},onSkipOnce:Pp,onTurnOff:zp,onDismiss:()=>Dr(null)}),_a?u.jsx(BI,{terminalId:e.id,serverApi:t,source:cn,candidates:Co,rememberedSelection:Ze,fontSize:C,onClose:Up},e.id):null,ko&&cn?u.jsx(_5,{terminalId:e.id,serverApi:t,source:cn,fontSize:C,onClose:()=>Bn(!1)}):null,Ro?u.jsx(LI,{notice:Ro}):null,To?u.jsx(AI,{status:_i,busy:Eo,error:Hs,onInstall:()=>{Ll("install")},onUpdate:()=>{Ll("update")},onOpen:jr,onRefresh:()=>{Ei({checkLatest:!0}).catch(E=>sr(af(E)))},onClose:()=>Vi(!1)}):null]})}function aC(e){return uD(e)}async function oC(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,l=Date.now(),d=pc.get(e);if(!o&&d?.status&&l-d.fetchedAt<=wI)return d.status;if(d?.inflight&&(!r||d.inflightCheckLatest))return d.inflight;let f;return f=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(fb(e,g),g)).catch(g=>{const p=pc.get(e);throw p?.inflight===f&&(p.status?pc.set(e,{status:p.status,fetchedAt:p.fetchedAt}):pc.delete(e)),g}),pc.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:l},inflight:f,inflightCheckLatest:r}),f}function fb(e,t){pc.set(e,{status:t,fetchedAt:Date.now()})}function rf(e,t){return`${e}:${t}`}function XE(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function lC(e){const t=ld.get(e);if(!t)return!1;try{return t.closed?(ld.delete(e),!1):(t.focus(),!0)}catch{return ld.delete(e),!1}}function xv(e,t){const n=window.open(t,XE(e));if(!n)return null;ld.set(e,n);try{n.focus()}catch{}return n}function cC(e,t,n){if(!e||ZE(e))return!1;try{return e.name=XE(t),e.location.href=n,ld.set(t,e),e.focus(),!0}catch{return!1}}function xI(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function ZE(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Cv(e){if(e)try{e.closed||e.close()}catch{}}function kv(e,t,n){const r=CI(e,t),o=uC(r*Math.max(1,n),pI,mI);return{limit:uC(Math.ceil(o/dI),hI,fI),maxLines:o}}function CI(e,t){const n=e?.clientHeight??0;if(n<=0)return cI;const r=Math.max(10,t*uI);return Math.max(1,Math.floor(n/r))}function uC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function kI(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function TI(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function QE(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function EI(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function RI(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const l=Math.floor(r/24),d=r%24;return d>0?`${l}d ${d}h`:`${l}d`}function DI(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function af(e){return e instanceof Un||e instanceof Error?e.message:"Something went wrong."}function NI(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function MI({terminal:e,canClose:t,tabId:n,transcriptSource:r,hasTranscriptCandidates:o,transcriptShortcutLabel:l,subagentsShortcutLabel:d,transcriptCacheStatus:f,transcriptCacheNow:g,cacheKeepAliveEnabled:p,codeServerAvailable:b,codeServerInstallState:_,codeServerBusy:w,codeServerSupported:C,scrollbackShortcutLabel:x,tmuxScrollbackSupported:T,tmuxScrollbackEnabled:A,onToggleCacheKeepAlive:M,onOpenCodeServer:W,onToggleTmuxScrollback:U,onOpenTranscript:P,onOpenSubagents:F,onReload:V,onClose:O}){const G=Vb({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),fe={cursor:n?"grab":"default",opacity:G.isDragging?.5:void 0};return u.jsxs("header",{ref:G.setNodeRef,className:"terminal-pane-header",style:fe,"data-dragging":G.isDragging,...G.attributes,...G.listeners,children:[u.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),u.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),u.jsx("span",{className:"terminal-pane-spacer"}),b?u.jsx("button",{type:"button",className:"terminal-pane-code","data-state":_,"data-busy":w?"true":"false",disabled:!C||w,title:_==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":_==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),W()},children:u.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r||o?u.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r?.provider,title:"View transcript history","aria-label":"View transcript history",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),P()},children:[u.jsx("span",{className:"pane-button-label-full",children:"View history"}),u.jsx("span",{className:"pane-button-label-short",children:"History"}),u.jsx("kbd",{children:l})]}):null,r?u.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),F()},children:[u.jsx("span",{className:"pane-button-label-full",children:"View agents"}),u.jsx("span",{className:"pane-button-label-short",children:"Agents"}),u.jsx("kbd",{children:d})]}):null,r?u.jsx(jI,{status:f,now:g,keepAliveEnabled:p,onToggle:M}):null,e.status==="exited"?u.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,T&&e.status==="running"?u.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":A?"true":"false","aria-pressed":A,"aria-label":`Toggle tmux scrollback (${x})`,title:A?`Scroll input uses tmux scrollback (${x}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${x}).`,onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),U()},children:[A?u.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),u.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):u.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),u.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),u.jsx("kbd",{children:x})]}):null,e.status==="running"?u.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),V()},children:"↻"}):null,t?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),O()},children:"x"}):null]})}function AI({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:l,onRefresh:d,onClose:f}){const g=e?.job??null,p=g?.status==="running",b=e?.installed===!0,_=e?.supported!==!1,w=e===null&&t,C=e?.updateAvailable===!0,x=b?"VS Code add-on":"Install VS Code add-on";return u.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:f,children:u.jsxs("section",{className:"security-panel code-server-dialog",onClick:T=>T.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{children:[u.jsx("h2",{children:x}),u.jsx("p",{children:w?"Checking code-server status...":b?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),u.jsxs("div",{className:"code-server-dialog-scroll",children:[u.jsxs("div",{className:"code-server-dialog-body",children:[u.jsxs("p",{children:["NTerminal installs code-server under ",u.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?u.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),_?null:u.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?u.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?u.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[u.jsxs("div",{className:"code-server-progress-heading",children:[u.jsx("span",{children:g.action}),u.jsx("strong",{children:g.status})]}),u.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
52
|
+
`):"Preparing..."})]}):null]}),u.jsxs("div",{className:"code-server-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||p||!_,children:"Check"}),b?u.jsxs(u.Fragment,{children:[C?u.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!_,children:"Update"}):null,u.jsx("button",{type:"button",onClick:l,disabled:t||p,children:"Open"})]}):u.jsx("button",{type:"button",onClick:r,disabled:t||p||!_,children:p?"Installing...":"Install"})]})]})})}function LI({notice:e}){return u.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function jI({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=QE(e,t),l=EI(e,o),d=o===null?"?":RI(o),f=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return u.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":l,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:f,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[u.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),u.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{children:d})]})}function OI({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const l=e.tone==="info"||e.tone==="warning";return u.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[u.jsxs("header",{children:[u.jsx("strong",{children:e.message}),u.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?u.jsx("p",{children:e.detail}):null,l?u.jsxs("div",{className:"cache-keepalive-toast-actions",children:[u.jsx("button",{type:"button",onClick:t,children:"Send now"}),u.jsx("button",{type:"button",onClick:n,children:"Skip once"}),u.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}function BI(e){const[t,n]=v.useState(null),[r,o]=v.useState(),[l,d]=v.useState(e.candidates),[f,g]=v.useState(e.source),[p,b]=v.useState(null),[_,w]=v.useState(!0),C=v.useRef(0);async function x(M=!1,W=!1){const U=++C.current;w(!0);try{const P=await e.serverApi.getTerminalTranscriptSource(e.terminalId);if(U!==C.current)return;if(d(P.candidates??[]),g(P.source),W&&!P.source&&e.source){g(e.source),n(e.source),b(null);return}const F=e.rememberedSelection?.current;let V=!1;if((M||!t)&&F?.terminalId===e.terminalId){const O=P.candidates?.find(G=>G.id===F.candidateId);O?(n({provider:O.provider,sessionId:O.sessionId}),o(O.id),V=!0):e.rememberedSelection&&(e.rememberedSelection.current=null)}if((M||!t)&&P.source)n(P.source),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);else if((M||!t)&&!V&&P.candidates?.length===1){const O=P.candidates[0];n({provider:O.provider,sessionId:O.sessionId}),o(O.id)}b(null)}catch(P){if(U!==C.current)return;if(W&&e.source){n(e.source);return}b(P instanceof Error?P.message:"Could not load sessions.")}finally{U===C.current&&w(!1)}}v.useEffect(()=>(x(!1,!0),()=>{C.current+=1}),[]),v.useEffect(()=>{if(t)return;function M(W){W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),e.onClose())}return document.addEventListener("keydown",M,!0),()=>document.removeEventListener("keydown",M,!0)},[t,e.onClose]);const T=[];t&&T.push({id:r??"__pinned",title:l.find(M=>M.id===r)?.title||`${co(t.provider)} · ${t.sessionId}`,detail:l.find(M=>M.id===r)?.cwd||t.sessionId}),f&&(!t||!ca(f,t))&&T.push({id:"__current",title:`Current session · ${co(f.provider)}`,detail:f.sessionId});for(const M of l)t&&ca(t,M)||f&&ca(f,M)||T.push({id:M.id,title:M.title||M.sessionId,detail:`${co(M.provider)} · ${M.cwd}${M.updatedAt?` · ${new Date(M.updatedAt).toLocaleString()}`:""}`});const A=t&&T.length<=1?null:u.jsxs("div",{className:"transcript-session-picker",children:[T.length>1?u.jsx(T5,{options:T,value:r??(t?"__pinned":void 0),onSelect:M=>{if(C.current+=1,w(!1),M==="__current"&&f){n(f),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);return}const W=l.find(U=>U.id===M);W&&(n({provider:W.provider,sessionId:W.sessionId}),o(W.id),e.rememberedSelection&&(e.rememberedSelection.current={terminalId:e.terminalId,candidateId:W.id}))}}):null,u.jsx("button",{type:"button","aria-label":"Refresh sessions",title:"Refresh sessions",disabled:_,onClick:()=>{x()},children:u.jsx(Dc,{size:16})}),p?u.jsx("span",{role:"alert",children:p}):null,!t&&!f&&!_&&!l.length?u.jsx("span",{children:"No sessions available."}):null]});return t?v.createElement(II,{...e,key:`${t.provider}:${t.sessionId}:${r??""}`,source:t,...r?{candidateId:r}:{},sessionPicker:A,liveSourceChanged:!!(e.source&&!ca(e.source,t)),onReloadLatest:async()=>{e.rememberedSelection&&(e.rememberedSelection.current=null),n(null),o(void 0),await x(!0)}}):u.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-picker-title",onPointerDown:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),onClick:M=>{M.stopPropagation(),e.onClose()},children:u.jsxs("div",{className:"security-panel transcript-dialog",onClick:M=>M.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"transcript-picker-title",children:"History"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e.onClose,children:"×"})]}),A,_?u.jsx("div",{className:"transcript-dialog-status",children:"Loading sessions..."}):null]})})}const II=zt.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:l,onReloadLatest:d,candidateId:f,sessionPicker:g,liveSourceChanged:p}){const b=v.useRef(null),_=v.useRef(null),w=v.useRef(null),C=v.useRef(null),x=v.useRef(!0),T=v.useRef(null),[A,M]=v.useState(!1),W=v.useRef(!1),U=v.useRef(null),P=v.useRef(!1),F=v.useRef(()=>{});F.current=an;const V=v.useRef(0),O=v.useRef(!1),G=v.useRef(!1),fe=v.useRef(null),ee=v.useRef(null),te=v.useRef(null),[$,Z]=v.useState([]),[ie,J]=v.useState(!1),[j,R]=v.useState(""),[I,re]=v.useState(null),[_e,N]=v.useState(null),[Y,oe]=v.useState(!1),[Q,we]=v.useState(!1),[Se,ue]=v.useState(-1),[Re,Oe]=v.useState(null),[ge,He]=v.useState(null),[Be,L]=v.useState(!1),[ve,Le]=v.useState(!0),[Pe,H]=v.useState(!1),[de,Te]=v.useState(null),[Me,je]=v.useState(!1),be=L5(n,t,r,f,ie,j),Fe=v.useRef(0),We=v.useRef(null),Ue=v.useRef(null);function ut(){if(W.current)return!0;const ae=b.current,Ce=window.getSelection();if(!ae||!Ce||Ce.isCollapsed)return!1;for(let Ye=0;Ye<Ce.rangeCount;Ye++)if(Ce.getRangeAt(Ye).intersectsNode(ae))return!0;return!1}v.useEffect(()=>{const ae=()=>{ut()||(U.current?U.current.resume():P.current&&(P.current=!1,F.current()))},Ce=()=>{W.current=!1,ae()};return document.addEventListener("selectionchange",ae),document.addEventListener("pointerup",Ce,!0),document.addEventListener("pointercancel",Ce,!0),window.addEventListener("blur",Ce),()=>{document.removeEventListener("selectionchange",ae),document.removeEventListener("pointerup",Ce,!0),document.removeEventListener("pointercancel",Ce,!0),window.removeEventListener("blur",Ce),U.current?.cancel()}},[]);function _t(ae){return ae?.aborted?Promise.reject(new DOMException("Aborted","AbortError")):ut()?new Promise((Ce,Ye)=>{const Xe=()=>{ae?.removeEventListener("abort",et),U.current?.cancel===et&&(U.current=null)},et=()=>{Xe(),Ye(new DOMException("Aborted","AbortError"))};U.current={resume:()=>{Xe(),Ce()},cancel:et},ae?.addEventListener("abort",et,{once:!0})}):Promise.resolve()}v.useEffect(()=>{En(),re(null),N(null)},[j,ie]),v.useEffect(()=>()=>{Fe.current+=1,Ue.current?.abort()},[]),v.useEffect(()=>{function ae(Ce){Ce.key==="Escape"&&(Ce.preventDefault(),Ce.stopPropagation(),l())}return document.addEventListener("keydown",ae,!0),()=>document.removeEventListener("keydown",ae,!0)},[l]),v.useLayoutEffect(()=>{V.current+=1;const ae=V.current;O.current=!1,G.current=!0,fe.current=null,ee.current=null,te.current=null;const Ce=M5(n,t,r,ie);return _.current=Ce,w.current=Ce.snapshot,x.current=!0,T.current=null,M(!1),He(null),L(!1),Te(null),je(!1),re(null),N(null),ue(-1),Oe(null),Ce.snapshot?(G.current=!1,T.current={top:Ce.snapshot.scrollTop,atBottom:Ce.snapshot.atBottom,...Ce.snapshot.scrollAnchor},$t(Ce.snapshot),Le(!1),dn(Ce.snapshot,ae)):(Z([]),Le(!0),Gt(null,"initial",ae)),()=>{It(),Ce.release(),_.current===Ce&&(_.current=null),V.current+=1,We.current?.abort(),O.current=!1}},[n,ie,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ae=b.current;if(!ae)return;const Ce=T.current;if(Ce&&!ve&&C.current===$){T.current=null;const Xe=Ce.key?Array.from(ae.querySelectorAll("[data-transcript-entry-key]")).find(et=>et.dataset.transcriptEntryKey===Ce.key):null;ae.scrollTop=Ce.atBottom?ae.scrollHeight:Xe?ae.scrollTop+Xe.getBoundingClientRect().top-ae.getBoundingClientRect().top-(Ce.offset??0):Ce.top;return}if(G.current){if(ve||$.length===0)return;G.current=!1;const Xe=()=>{ae.scrollTop=ae.scrollHeight};Xe(),window.requestAnimationFrame?.(Xe);return}const Ye=fe.current;Ye!==null&&(fe.current=null,ae.scrollTop+=ae.scrollHeight-Ye)},[$,ve,ie]);const lt=co(r.provider),Nt=zt.useMemo(()=>Gf($,ie),[$,ie]),Yt=zt.useMemo(()=>G_(Nt),[Nt]),st=zt.useMemo(()=>PI(Yt),[Yt]),On=st.map(ae=>ae.key).join(""),Sn=Re?st.find(ae=>ae.key===Re)?.entryIndex??null:null,dt=j.trim().length>0,Lt=be.result?.hits.length??0,Ct=be.result?.hits.findIndex(ae=>ae.id===I?.id)??-1,gi=_e?.entryIndex??null,ki=dt?gi:Sn,pe=dt?gi===null?null:"search":Sn===null?null:"prompt",Ze=Nt?Nt.split(`
|
|
53
|
+
`).length-1:0,at=st.length>0&&Se>=0&&Se<st.length?Se:st.length-1,mt=Re??(at>=0?st[at]?.key??null:null),St=dt?Lt>0?`${Ct+1}/${Lt} ${Lt===1?"match":"matches"} · ${Ze} ${Ze===1?"line":"lines"}`:`0 matches · ${Ze} ${Ze===1?"line":"lines"}`:st.length>0?`${at+1}/${st.length} prompts · ${Ze} ${Ze===1?"line":"lines"}`:`0 prompts · ${Ze} ${Ze===1?"line":"lines"}`;v.useEffect(()=>{if(dt){Oe(null);return}Re&&!st.some(ae=>ae.key===Re)&&Oe(null),ue(ae=>{if(st.length===0)return te.current=null,-1;const Ce=te.current?st.findIndex(Xe=>Xe.key===te.current):-1,Ye=Ce>=0?Ce:ae>=0&&ae<st.length?ae:st.length-1;return te.current=st[Ye]?.key??null,Ye})},[Re,dt,On]),v.useEffect(()=>{const ae=ee.current;if(!ae||st.length===0)return;ee.current=null;const Ce=ae.anchorKey?st.findIndex(Xe=>Xe.key===ae.anchorKey):-1,Ye=Ce>0?Ce-1:0;si(Ye)},[On]);function It(){const ae=w.current,Ce=b.current;if(!ae||!Ce||!x.current)return;const Ye=Array.from(Ce.querySelectorAll("[data-transcript-entry-key]")).find(et=>et.getBoundingClientRect().bottom>Ce.getBoundingClientRect().top),Xe={...ae,scrollTop:Ce.scrollTop,atBottom:Ce.scrollHeight-Ce.clientHeight-Ce.scrollTop<=4,...Ye?{scrollAnchor:{key:Ye.dataset.transcriptEntryKey,offset:Ye.getBoundingClientRect().top-Ce.getBoundingClientRect().top}}:{}};w.current=Xe,_.current?.write(Xe)}function $t(ae){w.current=ae,_.current?.write(ae);const Ce=dc([ae.page.records.map(Xe=>Xe.block).join(`
|
|
54
|
+
|
|
55
|
+
`)],r.provider,{includeTools:ie}),Ye=Ce?[Ce]:[];C.current=Ye,Z(Ye),He(ae.cursor),L(ae.hasMore)}async function dn(ae,Ce){We.current?.abort();const Ye=new AbortController;We.current=Ye,O.current=!0,Le(!1),H(!1),M(!0),Te(null);let Xe=null;try{for(;;){const Ft=await n.getTerminalTranscriptHistory(t,{...kv(b.current,o,wv),...Xe?.cursor?{cursor:Xe.cursor}:{ifSnapshot:ae.page.snapshot},includeTools:ie,expectedSessionId:r.sessionId,...f?{candidateId:f}:{}},Ye.signal);if(V.current!==Ce||!_.current?.current())return;if(!Ft.source)throw new Error("Transcript source is temporarily unavailable. Retry loading newest.");if(!ca(r,Ft.source))throw je(!0),_.current?.invalidate(),new Error("Transcript session changed. Load newest to refresh.");if(je(!1),Ft.page?.unchanged)return;if(!Ft.page){if(await _t(Ye.signal),V.current!==Ce)return;w.current=null,_.current?.invalidate(),Z([dc(Ft.output,r.provider,{includeTools:ie})]),He(Ft.cursor),L(Ft.hasMore);return}if(Xe=Xe?Ox(Xe,Ft):X_(Ft),!Xe)throw new Error("Transcript changed while loading. Load newest to retry.");if(gE(ae,Xe)||!Xe.hasMore||!Xe.cursor)break;await new Promise(Ai=>window.setTimeout(Ai,0))}if(await _t(Ye.signal),V.current!==Ce||!_.current?.current())return;It();const et=b.current,fn=w.current??ae,xn=E5(fn,Xe),Mi=et?Array.from(et.querySelectorAll("[data-transcript-entry-key]")).find(Ft=>Ft.getBoundingClientRect().bottom>et.getBoundingClientRect().top):void 0;T.current={top:xn.scrollTop,atBottom:xn.atBottom,...Mi&&et&&xn.page.identity===ae.page.identity?{key:Mi.dataset.transcriptEntryKey,offset:Mi.getBoundingClientRect().top-et.getBoundingClientRect().top}:{}},$t(xn)}catch(et){V.current===Ce&&!Ye.signal.aborted&&(Te(et instanceof Error?et.message:"Could not check the latest history."),et instanceof Un&&et.status===409&&(_.current?.invalidate(),je(!0)))}finally{V.current===Ce&&(O.current=!1,M(!1))}}async function Gt(ae,Ce,Ye=V.current){if(!O.current){O.current=!0,We.current?.abort(),We.current=new AbortController,M(!1),Le(Ce==="initial"),H(Ce==="older"),Ce==="older"&&(fe.current=b.current?.scrollHeight??null),Te(null);try{await rn(ae,Ce,Ye)}catch(Xe){if(V.current!==Ye)return;Te(Xe instanceof Error?Xe.message:"Failed to load transcript history."),Xe instanceof Un&&Xe.status===409&&je(!0)}finally{V.current===Ye&&(O.current=!1,Le(!1),H(!1))}}}async function rn(ae,Ce,Ye){const Xe=We.current?.signal;let et=ae,fn=0,xn=[];const Mi=Ce==="initial"&&r.provider!=="claude"?vI:gI;for(;V.current===Ye;){const Ft=await n.getTerminalTranscriptHistory(t,{...et?{cursor:et}:{},...kv(b.current,o,Ce==="initial"?wv:lI),includeTools:ie,expectedSessionId:r.sessionId,...f?{candidateId:f}:{}},Xe);if(V.current!==Ye||(Ce==="older"&&await _t(Xe),V.current!==Ye))return;if(!Ft.source){Te("Transcript source is temporarily unavailable.");return}if(!ca(r,Ft.source)){_.current?.invalidate(),je(!0),L(!1);return}const Ai=dc(Ft.output,r.provider,{includeTools:ie}),vs=hn(Ft,Ce,xn,Ai);if(Ai&&(xn=[Ai,...xn],vs))return;if(!Ft.hasMore||!Ft.cursor||fn>=Mi){xn.length>0&&Z($n=>Ce==="older"?[...xn,...$n]:xn);return}et=Ft.cursor,fn+=1}}function hn(ae,Ce,Ye,Xe=dc(ae.output,r.provider,{includeTools:ie})){if(x.current&&ae.page&&!ae.page.unchanged){const fn=w.current,xn=Ce==="older"&&fn?Ox(fn,ae):X_(ae);if(!xn)throw new Error("Transcript changed while loading. Load newest to retry.");return Ce==="older"&&(fe.current=b.current?.scrollHeight??null),$t(xn),!!Xe}if(He(ae.cursor),L(!!(ae.hasMore&&ae.cursor)),!Xe)return!1;const et=[Xe,...Ye];return Gf(et,ie)?(Z(fn=>Ce==="older"?[...et,...fn]:et),!0):!1}function an(){const ae=b.current;if(ae){if(ut()){P.current=!0;return}P.current=!1,kt(),!(dt||ae.scrollTop>72||!Be||!ge||O.current)&&Gt(ge,"older")}}function ln(ae){if(Lt===0)return;const Ce=Ct>=0?Ct:ae>0?-1:0;vi((Ce+ae+Lt)%Lt)}function En(){Fe.current+=1,Ue.current?.abort(),Ue.current=null,oe(!1)}function wn(){const ae=w.current;x.current||(x.current=!0,We.current?.abort(),V.current+=1,O.current=!1,H(!1),fe.current=null,ae?(T.current={top:ae.scrollTop,atBottom:ae.atBottom,...ae.scrollAnchor},$t(ae),dn(ae,V.current)):(Z([]),He(null),L(!1),G.current=!0,Gt(null,"initial")))}async function vi(ae){const Ce=be.result?.hits[ae];if(!Ce)return;It(),x.current=!1,M(!1);const Ye=++Fe.current;Ue.current?.abort(),We.current?.abort();const Xe=new AbortController;Ue.current=Xe,V.current+=1,O.current=!1,G.current=!1,fe.current=null,Le(!1),oe(!0),H(!1),Te(null),re(Ce),N(null);try{const et=await n.getTerminalTranscriptHistory(t,{around:Ce.cursor,expectedSessionId:r.sessionId,...f?{candidateId:f}:{},includeTools:ie,...kv(b.current,o,wv)},Xe.signal);if(Ye!==Fe.current)return;if(!et.source||!ca(r,et.source)){je(!0);return}const fn=dc(et.output,r.provider,{includeTools:ie});Z([fn]),N(A5(G_(fn),Ce,j)),He(et.cursor),L(!!(et.hasMore&&et.cursor)),b.current&&(b.current.scrollTop=0)}catch(et){Ye===Fe.current&&(Te(et instanceof Error?et.message:"Could not load search result."),et instanceof Un&&et.status===409&&je(!0))}finally{Ye===Fe.current&&oe(!1)}}function si(ae){const Ce=st[ae];Ce&&(te.current=Ce.key,ue(ae),Oe(Ce.key))}async function ht(ae){if(st.length===0){ae<0&&Be&&ge&&!O.current&&(ee.current={anchorKey:null},await Gt(ge,"older"));return}const Ye=(Se>=0&&Se<st.length?Se:ae<0?st.length-1:-1)+ae;if(Ye>=0&&Ye<st.length){si(Ye);return}ae<0&&Ye<0&&Be&&ge&&!O.current&&(ee.current={anchorKey:st[0]?.key??null},await Gt(ge,"older"))}function kt(){if(dt)return;const ae=b.current;if(!ae)return;const Ye=ae.getBoundingClientRect().top+Math.min(140,Math.max(48,ae.clientHeight*.28));let Xe=null;for(const et of FI(ae)){const fn=WI(et);if(fn!==null)if(et.getBoundingClientRect().top<=Ye)Xe=fn;else break}if(Xe!==null){const et=st[Xe]?.key??null;te.current=et,ue(Xe),Re&&Re!==et&&Oe(null)}}return u.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ae=>ae.stopPropagation(),onMouseDown:ae=>ae.stopPropagation(),onClick:ae=>{ae.stopPropagation(),l()},children:u.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ae=>ae.stopPropagation(),onMouseDown:ae=>ae.stopPropagation(),onClick:ae=>ae.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"transcript-dialog-title",children:[u.jsxs("h2",{id:"transcript-dialog-title",children:[lt," JSONL"]}),u.jsx("span",{title:r.sessionId,children:r.sessionId})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:l,children:"×"})]}),g,p?u.jsx("div",{className:"transcript-dialog-status",children:"The live pane uses another session. History remains pinned to this session."}):null,u.jsxs("div",{className:"transcript-dialog-controls",children:[u.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[u.jsx("input",{type:"checkbox",checked:ie,onChange:ae=>J(ae.currentTarget.checked)}),"Show tool output"]}),u.jsx("label",{className:"transcript-search",children:u.jsx("input",{type:"search",value:j,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ae=>{be.cancel(),En(),R(ae.currentTarget.value),ae.currentTarget.value.trim()||wn()},onKeyDown:ae=>{ae.nativeEvent.isComposing||ae.key==="Enter"&&(ae.preventDefault(),dt?be.result?.query===Dp(j)?Lt>0?ln(ae.shiftKey?-1:1):!be.result.complete&&be.result.cursor&&!be.busy&&be.search(!0):be.busy||(En(),re(null),N(null),be.search()):ht(ae.shiftKey?-1:1))}})}),u.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":Q,"aria-label":"Toggle prompt list",title:"Toggle prompt list",onClick:()=>we(ae=>!ae),disabled:st.length===0,children:u.jsx(dA,{size:16})}),u.jsxs("div",{className:"transcript-search-actions","aria-label":dt?"Search result navigation":"Prompt navigation",children:[u.jsx("button",{type:"button",onClick:()=>dt?ln(-1):void ht(-1),disabled:dt?Lt===0:st.length===0&&!Be,"aria-label":dt?"Previous search match":"Previous user prompt",title:dt?"Previous search match":"Previous user prompt",children:u.jsx(aA,{size:16})}),u.jsx("button",{type:"button",onClick:()=>dt?ln(1):void ht(1),disabled:dt?Lt===0:st.length===0,"aria-label":dt?"Next search match":"Next user prompt",title:dt?"Next search match":"Next user prompt",children:u.jsx(iA,{size:16})})]}),u.jsx("span",{className:"transcript-result-count",children:St}),u.jsx("button",{type:"button",title:A?"Checking latest history...":"Load newest entries","aria-label":"Load newest entries","aria-busy":A,onClick:()=>{be.cancel(),En(),We.current?.abort(),V.current+=1,O.current=!1,H(!1),fe.current=null,ee.current=null,T.current=null,G.current=!0,re(null),N(null),x.current=!0;const ae=w.current;ae?(G.current=!1,T.current={top:0,atBottom:!0},$t({...ae,atBottom:!0}),dn(ae,V.current)):Gt(null,"initial")},children:u.jsx(Dc,{size:16})})]}),dt?u.jsxs("div",{className:"transcript-search-results","aria-label":"Search results","aria-busy":be.busy,children:[u.jsxs("div",{className:"transcript-search-summary",role:"status",children:[be.busy?"Searching...":be.result?`${Lt} ${Lt>=200?"retained results":"results"}${be.result.complete?" · Complete":" · More to scan"} · ${be.result.scannedBytes.toLocaleString()} bytes scanned`:"Search history",be.result&&!be.result.complete&&be.result.cursor?u.jsx("button",{type:"button",disabled:be.busy,onClick:()=>{be.search(!0)},children:"Search more"}):null]}),I&&Ct<0&&be.result?u.jsx("div",{className:"transcript-dialog-status",children:"Selected result is outside the retained result window."}):null,be.error?u.jsx("div",{className:"transcript-dialog-error",role:"alert",children:be.error}):null,be.result?.hits.map((ae,Ce)=>u.jsxs("button",{type:"button",className:`transcript-prompt-index-item${I?.id===ae.id?" transcript-prompt-index-item-active":""}`,"aria-current":I?.id===ae.id?"true":void 0,onClick:()=>{vi(Ce)},children:[u.jsxs("span",{children:[ae.timestamp?new Date(ae.timestamp).toLocaleString():""," · ",ae.role]}),u.jsx("strong",{children:ae.preview.slice(0,500)})]},ae.id))]}):null,Q?u.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:st.length>0?st.map((ae,Ce)=>u.jsxs("button",{type:"button",className:mt===ae.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>si(Ce),children:[u.jsx("span",{children:ae.timestampLabel}),u.jsx("strong",{children:ae.snippet})]},`${ae.key}:${Ce}`)):u.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,Me?u.jsxs("div",{className:"transcript-dialog-status",role:"status",children:["The pinned transcript session changed."," ",u.jsx("button",{type:"button",onClick:()=>{d()},children:"Choose session"})]}):null,de?u.jsx("div",{className:"transcript-dialog-error",role:"alert",children:de}):null,Y?u.jsx("div",{className:"transcript-dialog-status",role:"status",children:"Loading search result..."}):null,u.jsxs("div",{ref:b,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:an,onPointerDownCapture:()=>{W.current=!0},children:[Pe?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ve&&Be?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Nt?u.jsx(lE,{entries:Yt,searchQuery:j,activeEntryIndex:ki,activeEntryMode:pe,activeSearchMatch:_e,fontSize:o}):null,ve?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Me&&!ve&&!Nt&&!de?Be&&ge?u.jsxs("div",{className:"transcript-dialog-status",children:[ie?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",u.jsx("button",{type:"button",onClick:()=>{Gt(ge,"older")},disabled:Pe,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null]})]})})});function PI(e){const t=[];for(let o=0;o<e.length;o+=1){const l=e[o];!l||l.kind!=="user"||t.push({contentKey:zI(l),entry:l,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const l=t[o];if(!l)continue;const d=n.get(l.contentKey)??0;n.set(l.contentKey,d+1),r.set(o,JSON.stringify([l.contentKey,d]))}return t.map((o,l)=>({entryIndex:o.entryIndex,key:r.get(l)??JSON.stringify([o.contentKey,0]),snippet:UI(o.entry.body),timestampLabel:$I(o.entry.header)}))}function zI(e){return JSON.stringify([e.header??"",e.body.length,HI(e.body)])}function HI(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function UI(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function $I(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function FI(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function WI(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function KI(e){return e.includes("\r")||e.includes(`
|
|
56
|
+
`)}function Tv(e){return e instanceof Un&&e.status===404}function mc(e){return JE(e)||e2(e)}function JE(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function e2(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function qI(e){if(mc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function VI(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function of(e){const t=[];for(const n of e){const r=t2(n);r&&t.push(r)}return t}function t2(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(l=>!aI.has(l.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function Ev(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function YI(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function dC(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function ps(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function lf(e,t){return!t||ps(e)}function hC(e){return ps(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function GI(e,t,n,r,o,l,d,f){const g=p=>{const b=ZI(p);if(b!==0){if(d()){if(e6(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(b);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),XI(t,b,n,r,o,l)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function XI(e,t,n,r,o,l){const d=()=>{o();try{e.scrollLines(t)}finally{l()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(hb,d);return}d()}function ZI(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function QI(e,t,n,r,o,l,d,f,g){let p=null,b=0;const _={passive:!1};function w(T){p=Rv(T),b=0}function C(T){const A=Rv(T);if(A===null){p=null,b=0;return}if(p===null){p=A;return}const M=A.clientY-p.clientY;if(p=A,T.cancelable&&T.preventDefault(),M===0)return;if(JI(t)&&t6(t,A,-M)){b=0;return}b-=M/n();const W=b<0?Math.ceil(b):Math.floor(b);if(W!==0){if(b-=W,f()){g(W);return}l();try{t.scrollLines(W)}finally{d()}r(),W<0&&t.buffer.active.viewportY<=3&&o(W)}}function x(T){if(T.touches.length>0){p=Rv(T);return}p=null,b=0}return e.addEventListener("touchstart",w,_),e.addEventListener("touchmove",C,_),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",w,_),e.removeEventListener("touchmove",C,_),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Rv(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function JI(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function e6(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function t6(e,t,n){const r=e.element;return r?(r.dispatchEvent(n6(t,n)),!0):!1}function n6(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function pb({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l=!0,refreshCwdOnEnter:d=!1,tabId:f,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:b=null,mobileFocusLeafKey:_=null,path:w=[],totalPanes:C,onSelect:x,onClose:T,onResize:A,onExit:M,onSnapshot:W,onCloseEditor:U,onAuthClose:P}){const F=C??mb(e);if(w.length===0&&_){const fe=gb(e),ee=fe.some(te=>te.key===_)?_:fe[0]?.key;if(fe.length>1&&ee)return u.jsx("div",{className:"mobile-focused-split",children:fe.map(te=>{const $=te.key===ee;if(te.type==="editor"){const ie=n[te.editorId];return u.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:ie?u.jsx(P1,{api:r,editor:ie,canClose:F>1,onClose:()=>U(te.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},te.key)}const Z=t[te.terminalId];return Z?u.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:u.jsx(rC,{terminal:Z,serverApi:r,active:$,visible:l&&$,canClose:F>1,refreshCwdOnEnter:d&&$,tabId:f,codeServerContext:g,onSelect:()=>x(te.terminalId),onClose:()=>T(te.terminalId),onExit:ie=>M(te.terminalId,ie),onSnapshot:W,...P?{onAuthClose:P}:{}})},te.key):u.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},te.key)})})}if(e.type==="pane"){const fe=t[e.terminalId];if(!fe)return u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ee=u.jsx(rC,{terminal:fe,serverApi:r,active:e.terminalId===o,visible:l,canClose:F>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:f,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>T(e.terminalId),onExit:$=>M(e.terminalId,$),onSnapshot:W,...P?{onAuthClose:P}:{}});return p&&b!==e.terminalId?u.jsxs("div",{className:"pane-drop-host",children:[ee,u.jsx(cf,{terminalId:e.terminalId,side:"top"}),u.jsx(cf,{terminalId:e.terminalId,side:"right"}),u.jsx(cf,{terminalId:e.terminalId,side:"bottom"}),u.jsx(cf,{terminalId:e.terminalId,side:"left"})]}):ee}if(e.type==="editor"){const fe=n[e.editorId];return fe?u.jsx(P1,{api:r,editor:fe,canClose:F>1,onClose:()=>U(e.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const V=Math.max(.1,Math.min(.9,e.ratio)),O=1-V,G=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${V}fr) 1px minmax(0, ${O}fr)`}:{gridTemplateRows:`minmax(0, ${V}fr) 1px minmax(0, ${O}fr)`};return u.jsxs("div",{className:"split-pane","data-direction":e.direction,style:G,children:[u.jsx("div",{className:"split-cell",children:u.jsx(pb,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,0],totalPanes:F,onSelect:x,onClose:T,onResize:A,onExit:M,onSnapshot:W,onCloseEditor:U,...P?{onAuthClose:P}:{}})}),u.jsx(i6,{direction:e.direction,path:w,onResize:A}),u.jsx("div",{className:"split-cell",children:u.jsx(pb,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,1],totalPanes:F,onSelect:x,onClose:T,onResize:A,onExit:M,onSnapshot:W,onCloseEditor:U,...P?{onAuthClose:P}:{}})})]})}function cf({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=vp({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return u.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function i6({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const l=o.currentTarget;l.setPointerCapture?.(o.pointerId),l.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=l.parentElement;if(!d)return;const f=d.getBoundingClientRect();function g(b){const _=e==="vertical"?(b.clientX-f.left)/f.width:(b.clientY-f.top)/f.height;n(t,Math.min(.9,Math.max(.1,_)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),l.removeEventListener("lostpointercapture",p),l.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),l.addEventListener("lostpointercapture",p)}return u.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:u.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function mb(e){return e.type==="pane"||e.type==="editor"?1:mb(e.first)+mb(e.second)}function gb(e){return e.type==="pane"?[{key:s6(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:r6(e.editorId),type:"editor",editorId:e.editorId}]:[...gb(e.first),...gb(e.second)]}function s6(e){return`terminal:${e}`}function r6(e){return`editor:${e}`}const jp="workspace-default",a6="NTerminal";function o6(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function gc(e,t){switch(t.type){case"workspace.hydrated":return rp(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return l6(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return h6(e,t.workspaceId);case"workspace.selected":return n2(e,t.workspaceId);case"workspace.renamed":return c6(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return u6(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return d6(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return jy(e,t.terminal);case"terminal.split":return p6(e,t.terminal,t.direction);case"terminal.updated":return C6(e,t.terminal);case"terminal.exited":return k6(e,t.terminalId,t.exitCode);case"terminal.closed":return a2(e,t.terminalId);case"terminal.detached":return T6(e,t.terminalId,t.workspaceId);case"terminal.revealed":return f6(e,t.terminalId);case"editor.split":return m6(e,t.editorId,t.title,t.direction);case"editor.closed":return E6(e,t.editorId);case"pane.selected":return r2(e,t.terminalId);case"pane.resized":return x6(e,t.path,t.ratio);case"tab.selected":return v6(e,t.tabId);case"tab.renamed":return w6(e,t.tabId,t.title);case"tab.reordered":return Oy(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return _6(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return i2(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return s2(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return b6(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return g6(e);default:return e}}function l6(e,t){if(e.workspaces.some(r=>r.id===t.id))return n2(e,t.id);const n={id:t.id,title:t.title,defaultCwd:nr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function n2(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function c6(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.title===r?d:(o=!0,{...d,title:r}));return o?{...e,workspaces:l}:e}function u6(e,t,n){const r=nr(n);let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.defaultCwd===r?d:(o=!0,{...d,defaultCwd:r}));return o?{...e,workspaces:l}:e}function d6(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(_=>_.id===t),l=e.workspaces.findIndex(_=>_.id===n);if(o<0||l<0)return e;const d=e.workspaces.slice(),[f]=d.splice(o,1);if(!f)return e;const g=d.findIndex(_=>_.id===n);if(g<0)return e;const p=r==="before"?g:g+1,b=d.slice();return b.splice(p,0,f),S6(e.workspaces,b)?e:{...e,workspaces:b}}function h6(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const n=e.workspaces.find(f=>f.id===t),r=new Set(n?xr(n):[]),o={...e.terminals};for(const f of r)delete o[f];const l=e.workspaces.filter(f=>f.id!==t),d=e.activeWorkspaceId===t?l[0]?.id??null:e.activeWorkspaceId;return{workspaces:l,activeWorkspaceId:d,terminals:o}}function jy(e,t){const n=l2(e),r=yl(n)??Bp(),o=m2(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(l=>l.id===r.id?{...l,defaultCwd:l.defaultCwd??nr(t.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...l.tabs,o],activeTabId:o.id}:p2(l,t.id))}}function f6(e,t){if(u2(e,t))return r2(e,t);const n=d2(e,t),r=e.terminals[t];return!n||!r?e:jy({...e,activeWorkspaceId:n.id},r)}function p6(e,t,n){const r=yl(e),o=r?Op(r):void 0;if(!r||!o)return jy(e,t);const l=o.activeTerminalId,d=kd(o.root,l,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:l},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??nr(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:d,activeTerminalId:t.id}:g)}:p2(f,t.id))}}function m6(e,t,n,r){const o=yl(e),l=o?Op(o):void 0;if(!o||!l)return e;const d=l.activeTerminalId,f=kd(l.root,d,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===l.id?{...p,root:f,activeTerminalId:d}:p)}:g)}}function g6(e){const t=yl(e),n=t?Op(t):void 0;return n?a2(e,n.activeTerminalId):e}function v6(e,t){const n=yl(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function Oy(e,t,n){const r=e.workspaces.map(o=>{const l=o.tabs.findIndex(b=>b.id===t);if(l<0)return o;const d=o.tabs.slice(),[f]=d.splice(l,1);if(!f)return o;const g=Math.max(0,Math.min(d.length,n)),p=d.slice();return p.splice(g,0,f),y6(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,l)=>o===e.workspaces[l])?e:{...e,workspaces:r}}function _6(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let l=e.workspaces.map(g=>{const p=g.tabs.findIndex(x=>x.id===t);if(p<0)return g;const b=g.tabs[p];if(!b)return g;const _=Lc(b.root,n);if(!_){const x=g.tabs.filter((T,A)=>A!==p);return{...g,tabs:x}}const w={...b,root:_,activeTerminalId:Tn(_)[0]??b.activeTerminalId},C=g.tabs.slice();return C[p]=w,{...g,tabs:C}});const d=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return l=l.map(g=>{const p=g.tabs.findIndex(T=>Tn(T.root).includes(r));if(p<0)return g;const b=g.tabs[p];if(!b)return g;const _={type:"pane",terminalId:n},w={type:"split",direction:d,ratio:.5,first:f?_:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:_},C=kd(b.root,r,w),x=g.tabs.slice();return x[p]={...b,root:C,activeTerminalId:n},{...g,tabs:x,activeTabId:b.id}}),l2({...e,workspaces:l})}function i2(e,t,n,r){let o=-1,l=-1;for(let A=0;A<e.workspaces.length;A+=1){const M=e.workspaces[A].tabs.findIndex(W=>W.id===t);if(M>=0){o=A,l=M;break}}if(o<0)return e;const d=e.workspaces[o],f=d.tabs[l],g=Tn(f.root);if(!g.includes(n))return e;if(g.length===1)return Oy(e,t,r);const p=Lc(f.root,n);if(!p)return e;const b={...f,root:p,activeTerminalId:Tn(p)[0]??f.activeTerminalId},_=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:_?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},C=d.tabs.slice();C[l]=b;const x=Math.max(0,Math.min(C.length,r));C.splice(x,0,w);const T=e.workspaces.slice();return T[o]={...d,tabs:C,activeTabId:w.id},{...e,workspaces:T}}function s2(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=c2(e.workspaces,t),l=e.workspaces.find(p=>p.id===n);if(!o||!l)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:Oy(e,t,r);const d=Tn(o.tab.root),f=d.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Sl({...p,tabs:p.tabs.filter(b=>b.id!==t)});if(p.id===n){const b=p.tabs.slice(),_=Math.max(0,Math.min(b.length,r));return b.splice(_,0,o.tab),{...p,defaultCwd:p.defaultCwd??nr(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!d.includes(w)),tabs:b,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function b6(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const l=e.workspaces.find(C=>C.id===r),d=c2(e.workspaces,t);if(!l||!d||!e.terminals[n]||!Tn(d.tab.root).includes(n))return e;if(d.workspace.id===r)return i2(e,t,n,o);if(Tn(d.tab.root).length===1)return s2(e,t,r,o);const g=Lc(d.tab.root,n);if(!g)return e;const p={...d.tab,root:g,activeTerminalId:Tn(g)[0]??d.tab.activeTerminalId},b=e.terminals[n],_={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},w=e.workspaces.map(C=>{if(C.id===d.workspace.id)return Sl({...C,tabs:C.tabs.map(x=>x.id===t?p:x)});if(C.id===r){const x=C.tabs.slice(),T=Math.max(0,Math.min(x.length,o));return x.splice(T,0,_),{...C,defaultCwd:C.defaultCwd??nr(b.cwd),detachedTerminalIds:C.detachedTerminalIds.filter(A=>A!==n),tabs:x,activeTabId:_.id}}return C});return{...e,workspaces:w,activeWorkspaceId:r}}function y6(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function S6(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function w6(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const l=e.workspaces.map(d=>{let f=!1;const g=d.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,f=!0,{...p,title:r}));return f?{...d,tabs:g}:d});return o?{...e,workspaces:l}:e}function r2(e,t){const n=e.workspaces.find(o=>o.tabs.some(l=>jc(l.root,t))),r=n?.tabs.find(o=>jc(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(l=>l.id===r.id?{...l,activeTerminalId:t}:l)}:o)}}function x6(e,t,n){const r=yl(e),o=r?Op(r):void 0;if(!r||!o)return e;const l=Sb(o.root,t,_2(n));return l===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===r.id?{...d,tabs:d.tabs.map(f=>f.id===o.id?{...f,root:l}:f)}:d)}}function rp(e,t,n,r){const o=Object.fromEntries(e.map(_=>[_.id,_])),l=new Set(e.map(_=>_.id)),d=new Set,f=!!(n&&n.some(_=>g2(_))||t&&t.some(_=>v2(_)));let g=R6(t,n,l,d);g.length===0&&(g=[Bp()]);const p=typeof r=="string"&&g.some(_=>_.id===r)?r:g[0]?.id??null,b=p??g[0]?.id??jp;for(const _ of e)if(!d.has(_.id)){if(f)g=D6(g,b,_.id,_);else{const w=m2(_);g=M6(g,b,w,_)}d.add(_.id)}return{workspaces:g.map(_=>Sl(N6(_,o))),activeWorkspaceId:p,terminals:o}}function ll(e){return Tn(e.root)}function ap(e){return wb(e.root)}function xr(e){return By([...e.tabs.flatMap(t=>Tn(t.root)),...e.detachedTerminalIds])}function ro(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const l=bb(o.root);return l?[{...o,root:l}]:[]});return Sl({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function C6(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>jc(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function k6(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function a2(e,t){const n={...e.terminals};return delete n[t],o2(e,t,n)}function T6(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(l=>l.id===n)?n:null)??u2(e,t)?.id??d2(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??jp,o=e.workspaces.find(l=>l.id===r);return!o||!f2(o,t)?e:o2(e,t,{...e.terminals},{detachToWorkspaceId:r})}function o2(e,t,n,r={}){let o=e.workspaces.map(d=>{const f=[];for(const g of d.tabs){const p=Lc(g.root,t);if(!p)continue;const b=Tn(p),_=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];_&&f.push({...g,root:p,activeTerminalId:_})}return Sl({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===r.detachToWorkspaceId?h2(d,t,n[t]):d));const l=o.some(d=>d.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:l?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function E6(e,t){const n=e.workspaces.map(o=>{const l=[];for(const d of o.tabs){const f=vb(d.root,t);if(!f)continue;const g=Tn(f),p=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];p&&l.push({...d,root:f,activeTerminalId:p})}return Sl({...o,tabs:l})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function R6(e,t,n,r){if(t&&t.length>0){const o=[];for(const l of t)g2(l)&&o.push(fC(l,n,r));if(o.length>0)return o}return[fC({...Bp(),tabs:e??[]},n,r)]}function fC(e,t,n){const r=[];for(const l of e.tabs){if(!v2(l))continue;const d=_b(l.root,t);if(!d)continue;const f=Tn(d);for(const p of f)n.add(p);const g=f.includes(l.activeTerminalId)?l.activeTerminalId:f[0];g&&r.push({...l,root:d,activeTerminalId:g})}const o=[];for(const l of e.detachedTerminalIds??[])!t.has(l)||n.has(l)||(n.add(l),o.push(l));return Sl({...e,defaultCwd:nr(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function l2(e){return yl(e)?e:{...e,workspaces:[Bp()],activeWorkspaceId:jp}}function yl(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Op(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function c2(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function u2(e,t){return e.workspaces.find(n=>n.tabs.some(r=>jc(r.root,t)))}function d2(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function D6(e,t,n,r){return e.map(o=>o.id===t?h2(o,n,r):o)}function h2(e,t,n){return f2(e,t)?{...e,defaultCwd:e.defaultCwd??nr(n?.cwd),detachedTerminalIds:By([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function f2(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<mo}function p2(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function N6(e,t){if(e.defaultCwd)return e;const n=xr(e).find(o=>!!t[o]),r=n?nr(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Bp(){return{id:jp,title:a6,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Sl(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:nr(e.defaultCwd),detachedTerminalIds:By(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function M6(e,t,n,r){const o=Tn(n.root);return e.map(l=>l.id===t?{...l,defaultCwd:l.defaultCwd??nr(r?.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(d=>!o.includes(d)),tabs:[...l.tabs,n],activeTabId:l.activeTabId??n.id}:l)}function m2(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function kd(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:kd(e.first,t,n),second:kd(e.second,t,n)}}function Lc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Lc(e.first,t),r=Lc(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function vb(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=vb(e.first,t),r=vb(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function _b(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=_b(e.first,t),r=_b(e.second,t);return n&&r?{...e,ratio:_2(e.ratio),first:n,second:r}:n??r}function bb(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=bb(e.first),n=bb(e.second);return t&&n?{...e,first:t,second:n}:t??n}function g2(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 v2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&yb(t.root)}function yb(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")&&yb(t.first)&&yb(t.second):!1}function Sb(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const l=Sb(e.first,o,n);return l===e.first?e:{...e,first:l}}if(r===1){const l=Sb(e.second,o,n);return l===e.second?e:{...e,second:l}}return e}function _2(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function nr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function By(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function jc(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:jc(e.first,t)||jc(e.second,t)}function Tn(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Tn(e.first),...Tn(e.second)]}function wb(e){return e.type==="pane"||e.type==="editor"?1:wb(e.first)+wb(e.second)}function op(e,t,n=!1){if(!e)return t;const r=e.agentStatus,o=t.agentStatus,l=Date.parse(e.updatedAt),d=Date.parse(t.updatedAt);return e.status===t.status&&r?.source==="hook"&&o?.source==="hook"&&r.epoch&&r.epoch===o.epoch&&r.revision!==void 0&&o.revision!==void 0&&r.revision!==o.revision?o.revision>r.revision?t:e:Number.isFinite(l)&&(!Number.isFinite(d)||d<l)?e:Number.isFinite(d)&&(!Number.isFinite(l)||d>l)?t:e.status!==t.status?e.status==="exited"?e:t:n?e:t}function A6(e,t){const n=[],r=l=>{l.type==="split"?(r(l.first),r(l.second)):l.type==="pane"?n.push({key:`terminal:${l.terminalId}`,terminalId:l.terminalId}):n.push({key:`editor:${l.editorId}`})};r(e);const o=t&&n.length>1?[n.find(l=>l.key===t)??n[0]]:n;return new Set(o.flatMap(l=>l.terminalId===void 0?[]:[l.terminalId]))}const is=new Map,Td=new Map,Ed=new Map,Rd=new Map,Dd=new Map,Yu=new Set;let aa=null,L6=0;const xb=new Set;let b2=0;function gs(e){return e??"__local__"}function j6(e){return{agentId:e,generation:++L6,state:o6(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,hydration:{requestId:0,layoutSequence:0,metadataSequence:0,pending:null,mutations:new Map,overflow:!1},saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function gt(e){const t=gs(e);let n=is.get(t);return n||(n=j6(e),is.set(t,n)),n}function Ja(e){return is.get(gs(e))??null}function y2(e,t){const n=gs(e);let r=Td.get(n);return r||(r=new Set,Td.set(n,r)),r.add(t),()=>{r.delete(t)}}function O6(e){const t=gs(e),n=Td.get(t);if(n)for(const r of Array.from(n))r()}function wl(e,t,n=!0){const r=is.get(gs(e)),o=n&&pC(r)!==pC(t);is.set(gs(e),t),O6(e),o&&Py()}function Cb(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="finishing"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function Iy(e,t){const n=e.state.workspaces.find(d=>d.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const d of n.tabs)for(const f of Tn(d.root))r.add(f);let o=0,l=0;for(const d of r)Cb(e.state.terminals[d])&&(o+=1),e.unreadCompletions.has(d)&&(l+=1);return{workingTerminalCount:o,unreadCompletionCount:l}}function pC(e){return e?e.state.workspaces.map(t=>{const n=Iy(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function S2(e){return!!(e&&e.state.workspaces.some(t=>{const n=Iy(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function Py(){b2+=1;for(const e of Array.from(xb))e()}function B6(e){return xb.add(e),()=>{xb.delete(e)}}function mC(){return b2}function I6(e,t){return Iy(gt(e),t)}const kb=new Set;function P6(e){return kb.add(e),()=>{kb.delete(e)}}function zy(e,t,n=gt(e).state){const r=aa;if(!r||r.agentId!==e||r.generation!==is.get(gs(e))?.generation)return!1;const o=n.workspaces.find(d=>d.id===r.workspaceId),l=o?.tabs.find(d=>d.id===r.tabId);return!!(o?.id===n.activeWorkspaceId&&l?.id===o?.activeTabId&&l?.root===r.root&&n.terminals[t]&&r.terminalIds.has(t))}function uf(e,t=!0){let n=typeof e=="object"&&e!==null?e:null;if(e!==void 0&&!n&&t){const d=is.get(gs(e)),f=d?.state.workspaces.find(p=>p.id===d.state.activeWorkspaceId),g=f?.tabs.find(p=>p.id===f.activeTabId);d&&f&&g&&(n={generation:d.generation,agentId:d.agentId,workspaceId:f.id,tabId:g.id,root:g.root,terminalIds:new Set(Tn(g.root))})}if(aa=t&&n?{...n,terminalIds:new Set(Tn(n.root).filter(d=>n.terminalIds.has(d)))}:null,!aa)return;const r=aa.agentId,o=is.get(gs(r));if(!o||o.generation!==aa.generation){aa=null;return}const l=new Set([...o.unreadCompletions].filter(d=>!zy(r,d,o.state)));l.size!==o.unreadCompletions.size&&(wl(r,{...o,unreadCompletions:l}),Ip())}function rl(e,t){const n=gt(e),r=gs(e);if(t.type==="terminal.updated"){const b=n.state.terminals[t.terminal.id];if(n.mutable.hydration.mutations.get(t.terminal.id)==="delete"||b&&op(b,t.terminal)===b&&t.terminal!==b)return}const o=H6(n.state,t);t.type==="workspace.hydrated"&&(Ed.delete(r),Rd.delete(r),Dd.delete(r));const l=gc(n.state,t);G6(n,t,l);let d=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const b=n.state.terminals[t.terminal.id],_=Q6(r),w=J6(r),C=U6(r);if(t.terminal.agentStatus?.source==="hook"){_.delete(t.terminal.id),w.delete(t.terminal.id),C.delete(t.terminal.id);const x=t.terminal.agentStatus.completion;if(x){const T=`${r}:${x.id}`,A=Yu.has(T)||b?.agentStatus?.completion?.id===x.id;x2(T),!A&&t.notifyCompletion===!0&&(f=_C(l,t.terminal.id,t.terminal.currentCommand??null,x.outcome))}}else if(t.terminal.agentStatus){const x=t.terminal.agentStatus.state,T=t.terminal.agentStatus.sessionId,A=C.get(t.terminal.id),M=!!(b&&(b.currentCommand!==t.terminal.currentCommand||b.agentStatus?.provider!==t.terminal.agentStatus.provider||z6(A,T)));M&&(w.delete(t.terminal.id),_.delete(t.terminal.id),C.delete(t.terminal.id)),T&&C.set(t.terminal.id,T),t.notifyCompletion===!0&&(x==="working"?(w.add(t.terminal.id),_.delete(t.terminal.id)):x==="unknown"&&t.terminal.activity==="busy"&&_.add(t.terminal.id)),!M&&(x==="done"||x==="stopped")&&(w.has(t.terminal.id)||_.has(t.terminal.id))&&(f=_C(l,t.terminal.id,b?.currentCommand??null,x==="stopped"?"stopped":"finished"),w.delete(t.terminal.id),_.delete(t.terminal.id)),x==="idle"&&(w.delete(t.terminal.id),_.delete(t.terminal.id))}else b?.agentStatus&&(w.delete(t.terminal.id),C.delete(t.terminal.id)),_.delete(t.terminal.id);f&&!zy(e,t.terminal.id,l)&&!d.has(t.terminal.id)&&(d=new Set(d),d.add(t.terminal.id)),t.terminal.status==="exited"&&(_.delete(t.terminal.id),w.delete(t.terminal.id),C.delete(t.terminal.id))}if(t.type==="terminal.closed"||t.type==="workspace.closed"){const b=new Set([...d].filter(_=>l.terminals[_]));b.size!==d.size&&(d=b)}const g=l!==n.state,p=d!==n.unreadCompletions;if((g||p)&&wl(e,{...n,state:l,unreadCompletions:d},o||p),p&&Ip(),f)for(const b of Array.from(kb))b({agentId:e,...f})}function z6(e,t){return e!==void 0&&t!==void 0&&e!==t}function H6(e,t){switch(t.type){case"terminal.updated":return Cb(e.terminals[t.terminal.id])!==Cb(t.terminal);case"workspace.renamed":case"workspace.defaultCwdChanged":case"workspace.reordered":case"editor.split":case"editor.closed":case"pane.selected":case"pane.resized":case"tab.renamed":case"tab.reordered":return!1;default:return!0}}function U6(e){let t=Dd.get(e);return t||(t=new Map,Dd.set(e,t)),t}function $6(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Tn(r.root).includes(t))return{workspace:n,tab:r};return null}const Tb=new Set;function F6(e){return Tb.add(e),()=>{Tb.delete(e)}}function W6(){let e=0;for(const t of is.values())e+=t.unreadCompletions.size;return e}function Ip(){for(const e of Array.from(Tb))e()}function gC(e,t){const n=gt(e);if(t!==n.state){n.mutable.hydration.layoutSequence++;for(const r of new Set([...Object.keys(n.state.terminals),...Object.keys(t.terminals)]))n.state.terminals[r]!==t.terminals[r]&&vc(n,r,t.terminals[r]?t.terminals[r].status==="exited"?"exit":"upsert":"delete");wl(e,{...n,state:t})}}function K6(e){const t=gt(e),n=t.mutable.hydration,r={generation:t.generation,requestId:++n.requestId,layoutSequence:n.layoutSequence,metadataSequence:n.metadataSequence};return n.pending=r,n.mutations.clear(),n.overflow=!1,r}function Nd(e,t){const n=is.get(gs(e));return n?.generation===t.generation&&n.mutable.hydration.pending===t}function vC(e,t){if(!Nd(e,t))return;const n=gt(e).mutable.hydration;n.pending=null,n.mutations.clear()}function w2(e,t,n){if(!Nd(e,t))return null;const r=gt(e),o=r.mutable.hydration;if(o.overflow)throw new Error("Workspace changed too much while loading. Retry loading it.");const l=new Map;if(o.layoutSequence!==t.layoutSequence||o.metadataSequence!==t.metadataSequence)for(const d of r.state.workspaces.flatMap(xr)){const f=r.state.terminals[d];f&&l.set(d,f)}for(const d of n){const f=o.mutations.get(d.id);if(f==="delete")continue;const g=r.state.terminals[d.id];l.set(d.id,f==="exit"&&g?g:op(g,d,!0))}for(const[d,f]of o.mutations)f==="delete"?l.delete(d):r.state.terminals[d]&&l.set(d,op(l.get(d),r.state.terminals[d]));return[...l.values()]}function q6(e,t,n){if(!Nd(e,t)||n.length>0)return!1;const r=gt(e).mutable.hydration;return r.layoutSequence===t.layoutSequence&&r.metadataSequence===t.metadataSequence&&r.mutations.size===0}function V6(e,t,n){const r=w2(e,t,n.terminals);if(!r)return null;const o=gt(e),l=o.mutable.hydration,d=l.metadataSequence!==t.metadataSequence,f=l.layoutSequence!==t.layoutSequence||d,g=f?{...o.state,terminals:Object.fromEntries(r.map(_=>[_.id,_]))}:rp(r,n.savedTabs,n.savedWorkspaces,n.savedActiveWorkspaceId),p=Y6(g,n.savedWorkspaces??n.persistedLayout?.workspaces),b=d?o.lastPersistedLayoutJson:f?n.persistedLayout?JSON.stringify(n.persistedLayout):o.lastPersistedLayoutJson:JSON.stringify(ro(p));l.pending=null,l.mutations.clear();for(const _ of r)_.agentStatus?.source==="hook"&&_.agentStatus.completion&&x2(`${gs(e)}:${_.agentStatus.completion.id}`);return wl(e,{...o,state:p,loaded:!0,error:null,layoutRevision:d?o.layoutRevision:n.revision,lastPersistedLayoutJson:b}),{state:p,layoutPreserved:f,metadataPreserved:d}}function Y6(e,t=[]){const n=new Set(e.workspaces.flatMap(xr)),r=Object.values(e.terminals).filter(_=>!n.has(_.id));if(r.length===0)return e;const o=e.workspaces.find(_=>_.id===e.activeWorkspaceId)??e.workspaces[0];if(!o)throw new Error("Loaded terminals have no workspace. Retry loading the workspace.");const l=new Set(e.workspaces.map(_=>_.id)),d=new Map;for(const _ of t)if(l.has(_.id))for(const w of xr(_))d.has(w)||d.set(w,_.id);const f=e.workspaces.slice(),g=new Set(f.flatMap(_=>_.tabs.map(w=>w.id)));let p=!1;for(const _ of r){const w=f.findIndex(x=>x.id===(d.get(_.id)??o.id)),C=f[w];if(C.detachedTerminalIds.length<mo)f[w]={...C,detachedTerminalIds:[...C.detachedTerminalIds,_.id]};else{if(!C.tabs.some(A=>A.id===C.activeTabId))throw new Error(`This workspace already has ${mo} hidden terminal sessions and no selected tab. Re-open or delete hidden sessions before retrying.`);const x=`hydrated-${_.id}`;let T=x;for(let A=1;g.has(T);A++)T=`${x}-${A}`;g.add(T),f[w]={...C,tabs:[...C.tabs,{id:T,title:_.title||_.id,activeTerminalId:_.id,root:{type:"pane",terminalId:_.id}}]},p=!0}}const b={...e,workspaces:f};if(p&&!_p(ro(b)))throw new Error("Loaded terminals exceed the workspace layout limit. Re-open or delete hidden sessions before retrying.");return b}function x2(e){for(Yu.add(e);Yu.size>2048;)Yu.delete(Yu.values().next().value)}function vc(e,t,n){const r=e.mutable.hydration;if(r.pending){if(!r.mutations.has(t)&&r.mutations.size>=4096){r.overflow=!0;return}r.mutations.set(t,n)}}function G6(e,t,n){if(t.type!=="terminal.updated"&&t.type!=="terminal.exited"&&(n.workspaces!==e.state.workspaces||n.activeWorkspaceId!==e.state.activeWorkspaceId)&&e.mutable.hydration.layoutSequence++,t.type==="terminal.updated")t.notifyCompletion===!0&&vc(e,t.terminal.id,t.terminal.status==="exited"?"exit":"upsert");else if(t.type==="terminal.created"||t.type==="terminal.split")vc(e,t.terminal.id,"upsert");else if(t.type==="terminal.exited"&&n.terminals[t.terminalId])vc(e,t.terminalId,"exit");else if(t.type==="terminal.closed")vc(e,t.terminalId,"delete");else if(t.type==="workspace.closed")for(const r of Object.keys(e.state.terminals))n.terminals[r]||vc(e,r,"delete")}function Dv(e,t){const n=gt(e),r=t(n.editors);r!==n.editors&&wl(e,{...n,editors:r},!1)}function eo(e,t,n){const r=gt(e);r.loaded===t&&r.error===n||wl(e,{...r,loaded:t,error:n},!1)}function df(e,t,n){const r=gt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||(r.mutable.hydration.metadataSequence++,wl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1))}function X6(e){const t=gt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function Z6(e){const t=gs(e),n=is.get(t);aa?.agentId===e&&(aa=null),n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=S2(n);is.delete(t),Td.delete(t),Ed.delete(t),Rd.delete(t),Dd.delete(t),r&&Ip(),o&&Py()}function Nv(){aa=null;let e=!1,t=!1;for(const n of is.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),S2(n)&&(t=!0)}is.clear(),Td.clear(),Ed.clear(),Rd.clear(),Dd.clear(),e&&Ip(),t&&Py()}function Q6(e){let t=Ed.get(e);return t||(t=new Set,Ed.set(e,t)),t}function J6(e){let t=Rd.get(e);return t||(t=new Set,Rd.set(e,t)),t}function _C(e,t,n,r){const o=$6(e,t);return{terminalId:t,tabId:o?.tab.id??null,commandName:n,outcome:r}}function eP(e,t,n){const r=op(e.terminals[t.id],t,!0);if(r.status!=="running")throw new Error("This terminal is no longer running.");let o=gc(e,{type:"terminal.updated",terminal:r});if(o.workspaces.some(l=>xr(l).includes(t.id)))o=gc(o,{type:"terminal.revealed",terminalId:t.id});else{const l=n?.workspaces.find(d=>xr(d).includes(t.id));l&&(o.workspaces.some(d=>d.id===l.id)?o=gc(o,{type:"workspace.selected",workspaceId:l.id}):o=gc(o,{type:"workspace.created",workspaceId:l.id,title:l.title,defaultCwd:l.defaultCwd})),o=gc(o,{type:"terminal.created",terminal:r})}if(!_p(ro(o)))throw new Error("This terminal cannot be opened because the workspace layout limit was reached.");return o}function Eb(e,t){let n=!1,r=!1,o=null,l=!1;for(const d of ll(e)){const f=t[d];if(!f)continue;if(f.status==="exited"){l=!0,n=!0;continue}const g=f.agentStatus?.state,p=g&&g!=="unknown"?["working","finishing"].includes(g)?"busy":"idle":f.activity;p==="busy"?(r=!0,n=!0,!o&&f.currentCommand&&(o=f.currentCommand)):p==="idle"&&(n=!0)}return n?l?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Hy(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Rb(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function tP(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function nP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,onSelectTab:d,onCreateTab:f,onToggleWorkspaces:g,onCloseTerminals:p,onReattachTerminal:b,onDeleteTerminal:_,onSplitVertical:w,onSplitHorizontal:C,onRenameTab:x,onToggleFavorite:T,onOpenFavorites:A,activePaneAvailable:M}){const[W,U]=v.useState(null),[P,F]=v.useState(!1),[V,O]=v.useState(null),G=v.useRef(null),fe=e.findIndex(R=>R.id===t),ee=fe>=0?e[fe]:e[0]??null,te=ee?Eb(ee,n):null,$=ee?ap(ee):0,Z=ee?Rb(ee,n):"No tab";v.useEffect(()=>{G.current?.focus(),G.current?.select()},[W?.tabId]),v.useEffect(()=>{if(!P)return;const R=I=>{I.key==="Escape"&&F(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[P]),v.useEffect(()=>{P&&e.length===0&&F(!1)},[P,e.length]);function ie(R,I){U({tabId:R,title:I})}function J(){if(!W)return;const R=W.title.trim();R&&x(W.tabId,R),U(null)}function j(){return u.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[u.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${hL()}`,onClick:w,disabled:!M,children:u.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),u.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${fL()}`,onClick:C,disabled:!M,children:u.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return u.jsxs(u.Fragment,{children:[u.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[u.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:g,children:u.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]})}),u.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Z,onClick:()=>F(!0),disabled:e.length===0,children:[te?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":te.state,"aria-hidden":"true",title:Hy(te)}):null,u.jsx("span",{children:Z}),u.jsxs("small",{children:[fe>=0?fe+1:0,"/",e.length||0,$>1?` / ${$}`:""]})]}),u.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,I)=>{const re=ll(R),_e=ap(R),N=Rb(R,n),Y=R.id===t,oe=W?.tabId===R.id,Q=Eb(R,n),we=r?.has(R.id)??!1;return u.jsxs(zt.Fragment,{children:[u.jsx(bC,{index:I}),u.jsx(iP,{tab:R,active:Y,editing:oe,title:N,paneCount:_e,terminalIds:re,canClose:e.length>1,editValue:oe?W.title:null,editInputRef:oe?G:null,activity:Q,unread:we,favorite:o?.has(R.id)??!1,onSelect:()=>d(R.id),onBeginRename:()=>ie(R.id,N),onCloseAll:()=>p(re),onCommitRename:J,onCancelRename:()=>U(null),onRenameChange:Se=>U({tabId:R.id,title:Se}),onToggleFavorite:()=>T?.(R)})]},R.id)}),u.jsx(bC,{index:e.length}),u.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),u.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>A?.(),children:"★"}),(l?.length??0)>0?u.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(R=>u.jsx(rP,{terminal:R,onReattach:()=>b?.(R.id),onDelete:()=>O(R)},R.id))}):null]}),u.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),M?j():null]}),P?u.jsx(sP,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,editingTab:W,editInputRef:G,onClose:()=>F(!1),onSelectTab:R=>{d(R),F(!1)},onCreateTab:()=>{f(),F(!1)},onBeginRename:ie,onCloseTerminals:R=>{p(R),F(!1)},onCommitRename:J,onCancelRename:()=>U(null),onRenameChange:(R,I)=>U({tabId:R,title:I}),onToggleFavorite:T,onOpenFavorites:A,onReattachTerminal:R=>{b?.(R),F(!1)},onDeleteTerminal:R=>{O(R),F(!1)}}):null,V?u.jsx(aP,{terminal:V,onCancel:()=>O(null),onConfirm:()=>{_?.(V.id),O(null)}}):null]})}function iP({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:l,editValue:d,editInputRef:f,activity:g,unread:p,favorite:b,onSelect:_,onBeginRename:w,onCloseAll:C,onCommitRename:x,onCancelRename:T,onRenameChange:A,onToggleFavorite:M}){const{attributes:W,listeners:U,setNodeRef:P,transform:F,isDragging:V}=Vb({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),O={transform:ha.Translate.toString(F),opacity:V?.4:void 0,zIndex:V?2:void 0};return u.jsxs("div",{ref:P,className:"terminal-tab","data-active":t,"data-dragging":V,"data-unread":p?"true":void 0,style:O,...W,...U,children:[g?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Hy(g)}):null,n&&f&&d!==null?u.jsxs("form",{className:"terminal-tab-editor",onSubmit:G=>{G.preventDefault(),x()},children:[u.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:d,onBlur:x,onChange:G=>A(G.target.value),onKeyDown:G=>{if(G.key==="Enter"){G.preventDefault(),x();return}G.key==="Escape"&&(G.preventDefault(),T())}}),u.jsx("small",{children:o})]}):u.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:_,onDoubleClick:G=>{G.preventDefault(),w()},children:[u.jsx("span",{children:r}),u.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:u.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":b?`Remove ${r} from favorites`:`Add ${r} to favorites`,title:b?"Remove from favorites":"Add to favorites",onPointerDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),M()},children:b?"★":"☆"}),l&&!n?u.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),C()},children:"x"}):null]})}function sP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,editingTab:d,editInputRef:f,onClose:g,onSelectTab:p,onCreateTab:b,onBeginRename:_,onCloseTerminals:w,onCommitRename:C,onCancelRename:x,onRenameChange:T,onToggleFavorite:A,onOpenFavorites:M,onReattachTerminal:W,onDeleteTerminal:U}){const P=v.useRef(null);return v.useEffect(()=>{P.current?.scrollIntoView?.({block:"nearest"})},[t]),u.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:g,children:u.jsxs("section",{className:"mobile-tab-sheet",onClick:F=>F.stopPropagation(),children:[u.jsxs("header",{children:[u.jsxs("div",{children:[u.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),u.jsxs("small",{children:[e.length," open"]})]}),u.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[u.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:b,children:"+"}),u.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{g(),M?.()},children:"★"}),u.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:g,children:"×"})]})]}),u.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((F,V)=>{const O=ll(F),G=ap(F),fe=Rb(F,n),ee=F.id===t,te=d?.tabId===F.id,$=Eb(F,n),Z=r?.has(F.id)??!1,ie=o?.has(F.id)??!1;return u.jsxs("div",{ref:ee?P:null,className:"mobile-tab-sheet-row","data-active":ee,"data-unread":Z?"true":void 0,children:[te&&d?u.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:J=>{J.preventDefault(),C()},children:u.jsx("input",{ref:f,"aria-label":`Rename ${fe}`,value:d.title,onBlur:C,onChange:J=>T(F.id,J.target.value),onKeyDown:J=>{if(J.key==="Enter"){J.preventDefault(),C();return}J.key==="Escape"&&(J.preventDefault(),x())}})}):u.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${fe}`,onClick:()=>p(F.id),children:[u.jsx("span",{className:"mobile-tab-sheet-index",children:V+1}),u.jsxs("span",{className:"mobile-tab-sheet-copy",children:[u.jsx("strong",{children:fe}),u.jsx("small",{children:tP(F,n,G,$)})]}),u.jsxs("span",{className:"mobile-tab-sheet-meta",children:[$?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":$.state,"aria-hidden":"true",title:Hy($)}):null,u.jsx("span",{children:G})]})]}),u.jsxs("div",{className:"mobile-tab-sheet-actions",children:[te?u.jsx("button",{type:"button","aria-label":`Done renaming ${fe}`,onClick:C,children:"Done"}):u.jsx("button",{type:"button","aria-label":`Rename ${fe}`,onClick:()=>_(F.id,fe),children:"Rename"}),te?null:u.jsx("button",{type:"button","aria-label":ie?`Remove ${fe} from favorites`:`Add ${fe} to favorites`,title:ie?"Remove from favorites":"Add to favorites",onClick:()=>A?.(F),children:ie?"★":"☆"}),e.length>1?u.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${fe}`,onClick:()=>w(O),children:"×"}):null]})]},F.id)}),(l?.length??0)>0?u.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[u.jsx("span",{children:"Detached"}),(l??[]).map(F=>{const V=F.title||F.cwd||F.id.slice(0,8);return u.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[u.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${V}`,onClick:()=>W(F.id),children:[u.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),u.jsxs("span",{className:"mobile-tab-sheet-copy",children:[u.jsx("strong",{children:V}),u.jsx("small",{children:F.cwd})]}),u.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),u.jsx("div",{className:"mobile-tab-sheet-actions",children:u.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${V}`,onClick:()=>U(F),children:"×"})})]},F.id)})]}):null]})]})})}function bC({index:e}){const{setNodeRef:t,isOver:n}=vp({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return u.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function rP({terminal:e,onReattach:t,onDelete:n}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
57
|
+
${e.cwd}
|
|
58
|
+
(detached — click to re-open, × to delete)`;return u.jsxs("span",{className:"terminal-detached-pill",title:o,children:[u.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),u.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:l=>{l.stopPropagation(),n()},children:"×"})]})}function aP({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:"Delete this terminal?"}),u.jsx("span",{children:r}),u.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}const oP="nonce-v1",yC=512,Mv=3e4,Av=1e4;function lP(e){if(e.length>yC||new TextEncoder().encode(e).byteLength>yC)return null;try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;return Object.keys(n).length!==3||!Object.hasOwn(n,"type")||!Object.hasOwn(n,"version")||!Object.hasOwn(n,"nonce")||!["activity.ping","activity.pong"].includes(n.type)||n.version!==1||typeof n.nonce!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(n.nonce)?null:n}catch{return null}}const cP=1024*1024,uP=1e3,dP=5e3,hP=1e3;function fP(e,t,n,r={...typeof document>"u"?{}:{document},...typeof window>"u"?{}:{window}},o){const l=r.now??Date.now,d=r.document,f=r.window;let g=!1,p=!1,b="",_=0,w=0,C=!1,x=d?.visibilityState==="hidden",T,A,M,W,U=0,P=0,F=0,V,O=l(),G=-1/0;const fe=[],ee=()=>!C&&d?.visibilityState!=="hidden",te=ge=>!g&&T===ge,$=(ge,He)=>!ge.ready&&He>=ge.handshakeUntil||ge.pending!==void 0&&He>=ge.pending.until,Z=()=>{clearTimeout(M),M=void 0},ie=()=>{clearTimeout(W),W=void 0},J=()=>{for(const ge of fe.splice(0))ge()},j=ge=>Math.min(3e4,1e3*2**Math.min(ge,5)),R=()=>{g||p||A!==void 0||(A=setTimeout(()=>{A=void 0,ue()},j(U++)))},I=ge=>{p&&(b=ge,w=l()+j(_++));try{o?.(ge)}catch{}},re=(ge,He=1e3,Be="activity reconnect",L=!1,ve=!0)=>{if(T===ge){if(T=void 0,ge.pending=void 0,Z(),ie(),ge.socket.onmessage=null,ge.socket.onerror=null,ge.socket.onclose=null,L&&(g=!0,clearTimeout(A),A=void 0,J()),ve)try{ge.socket.close(He,Be)}catch{}L||R()}},_e=()=>{M!==void 0||g||!T||!ee()||(M=setTimeout(()=>{M=void 0,Q()},uP))},N=ge=>{if(!te(ge)||!ge.ready||!ge.probes||ge.pending||!ee())return;if(ge.socket.readyState!==1||ge.socket.bufferedAmount>512){re(ge);return}const He=`${ge.generation}-${++F}`;ge.pending={nonce:He,until:l()+Av},ge.nextProbeAt=l()+Mv;const Be={type:"activity.ping",version:1,nonce:He};try{ge.socket.send(JSON.stringify(Be))}catch{re(ge)}},Y=(ge=!1)=>{if(g||!ee())return;if(O=l(),G=O,p){I(b);return}const He=T;He&&(He.pending=void 0,He.ready?He.probes?N(He):re(He):((ge||!Number.isFinite(He.handshakeUntil))&&(He.handshakeUntil=O+Av),He.resumeProbe=!0),_e())},oe=()=>{const ge=l();return ge>=O&&ge-O<=dP?!1:(ie(),Y(!0),!0)},Q=()=>{if(g||!ee()||!T)return;oe(),O=l();const ge=T;ge&&($(ge,O)?re(ge):ge.ready&&O>=ge.nextProbeAt&&N(ge),_e())},we=()=>{if(g||!ee()||W!==void 0||!p&&l()>=G&&l()-G<hP)return;const ge=p?Math.min(3e4,Math.max(0,w-l())):0;W=setTimeout(()=>{W=void 0,Y()},ge)},Se=()=>{T&&(T.pending=void 0,T.ready||(T.handshakeUntil=1/0)),Z(),ie(),G=-1/0},ue=()=>{if(g||p)return;const ge=V;let He;try{const Le=new URL(e);ge&&Le.searchParams.set("cursor",ge),He=t(Le.toString())}catch{R();return}const Be={socket:He,generation:++P,ready:!1,probes:!1,handshakeUntil:ee()?l()+Av:1/0,nextProbeAt:1/0,pending:void 0,resumeProbe:!1};T=Be,O=l();let L=ge!==void 0,ve=!1;He.onmessage=Le=>{if(te(Be)&&(ee()&&oe(),!!te(Be))){if(ee()&&$(Be,l())){re(Be);return}try{if(typeof Le.data!="string"||Le.data.length>cP)throw new Error("invalid activity frame");const Pe=JSON.parse(Le.data);if(Pe?.type==="activity.pong"){const H=lP(Le.data);if(!Be.ready||!Be.probes||!H)throw new Error("invalid activity probe");ee()&&Be.pending?.nonce===H.nonce&&(Be.pending=void 0,Be.nextProbeAt=l()+Mv);return}if(Pe?.type==="activity.ready"){if(Be.ready||Pe.version!==1||!SC(Pe.cursor)||!["snapshot","resume","gap"].includes(Pe.mode)||(Pe.mode==="resume"?!ge:!ve))throw new Error("invalid activity acknowledgement");V=Pe.cursor,Be.ready=!0,Be.probes=Pe.probe===oP,Be.nextProbeAt=l()+Mv,L=!0,U=0,Be.resumeProbe&&N(Be),_e();return}if(!mP(Pe)||!L&&!Pe.initial)throw new Error("invalid activity snapshot");if(Pe.initial)ve=!0;else if(!SC(Pe.cursor))throw new Error("activity cursor required");L=!0,n(Pe),(Be.ready||!ve&&ge)&&(V=Pe.cursor)}catch{re(Be,1e3,"invalid activity message",!0)}}},He.onerror=()=>{te(Be)&&(re(Be),Be.ready||I("activity handshake failed"))},He.onclose=Le=>{if(!te(Be))return;const Pe=Le.code===1008&&pP(Le.reason);Pe&&(p=!0),re(Be,Le.code,"",Le.code===1008&&!Pe,!1),Pe?I(Le.reason):Le.code!==1008&&!Be.ready&&I("activity handshake failed")},_e()},Re=(ge,He,Be)=>{ge?.addEventListener(He,Be),fe.push(()=>ge?.removeEventListener(He,Be))};Re(d,"visibilitychange",()=>{const ge=x;x=d?.visibilityState==="hidden",x?Se():ge&&we()}),Re(d,"freeze",()=>{C=!0,Se()}),Re(d,"resume",()=>{C=!1,we()}),Re(f,"pagehide",()=>{C=!0,Se()}),Re(f,"pageshow",ge=>{const He=C;C=!1,(He||ge.persisted)&&we()}),Re(f,"offline",()=>{G=-1/0}),Re(f,"online",we),ue();const Oe=()=>{g=!0,clearTimeout(A),A=void 0,Z(),ie(),J(),T&&re(T,1e3,"activity disposed",!0)};return Oe.reauthenticate=()=>{g||!p||(ie(),p=!1,b="",_=0,w=0,R())},Oe}function pP(e){return["unauthorized","session expired","session revoked","authentication no longer valid"].includes(e?.trim().toLowerCase()??"")}function SC(e){return typeof e=="string"&&e.length<=128&&/^[a-f0-9-]+:\d+$/.test(e)}function mP(e){const t=e;return!!t&&t.type==="activity"&&t.version===1&&typeof t.initial=="boolean"&&(t.agentId===null||typeof t.agentId=="string"&&t.agentId.length>0&&t.agentId.length<=256)&&Array.isArray(t.terminals)&&t.terminals.length<=2048&&t.terminals.every(n=>n&&typeof n.id=="string"&&n.id.length>0&&n.id.length<=256&&typeof n.title=="string"&&typeof n.cwd=="string"&&["running","exited"].includes(n.status))}let wC=0,Rf;const Db=new Set;let Md;function gP(e){return Db.add(e),Md!==void 0&&e(Md),()=>{Db.delete(e)}}function vP(){Md=void 0,Rf?.reauthenticate()}function _P(e=!0){v.useEffect(()=>{if(e){if(wC++===0){const t=new URL("/api/activity/ws",window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:",Rf=yP(t.toString(),void 0,void 0,n=>{Md=n;for(const r of Db)r(n)})}return()=>{--wC===0&&(Rf?.(),Rf=void 0,Md=void 0)}}},[e])}function bP(e){for(const t of e.terminals){const n=gt(e.agentId).state.terminals[t.id];e.initial&&n&&Date.parse(t.updatedAt)<Date.parse(n.updatedAt)||rl(e.agentId,{type:"terminal.updated",terminal:t,notifyCompletion:!e.initial})}}function yP(e,t=o=>new WebSocket(o),n=bP,r){return fP(e,t,n,void 0,r)}function C2(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function SP(e,t){return e.reduce((n,r,o)=>{const l=t.get(r);return l&&(n[o]=l),n},Array(e.length))}function hf(e){return e!==null&&e>=0}function wP(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function xP(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Uy=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const l=C2(t,r,n),d=t[o],f=l[o];return!f||!d?null:{x:f.left-d.left,y:f.top-d.top,scaleX:f.width/d.width,scaleY:f.height/d.height}},ff={scaleX:1,scaleY:1},CP=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:l,overIndex:d}=e;const f=(t=l[n])!=null?t:r;if(!f)return null;if(o===n){const p=l[d];return p?{x:0,y:n<d?p.top+p.height-(f.top+f.height):p.top-f.top,...ff}:null}const g=kP(l,o,n);return o>n&&o<=d?{x:0,y:-f.height-g,...ff}:o<n&&o>=d?{x:0,y:f.height+g,...ff}:{x:0,y:0,...ff}};function kP(e,t,n){const r=e[t],o=e[t-1],l=e[t+1];return r?n<t?o?r.top-(o.top+o.height):l?l.top-(r.top+r.height):0:l?l.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const k2="Sortable",T2=zt.createContext({activeIndex:-1,containerId:k2,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Uy,disabled:{draggable:!1,droppable:!1}});function TP(e){let{children:t,id:n,items:r,strategy:o=Uy,disabled:l=!1}=e;const{active:d,dragOverlay:f,droppableRects:g,over:p,measureDroppableContainers:b}=ak(),_=jd(k2,n),w=f.rect!==null,C=v.useMemo(()=>r.map(V=>typeof V=="object"&&"id"in V?V.id:V),[r]),x=d!=null,T=d?C.indexOf(d.id):-1,A=p?C.indexOf(p.id):-1,M=v.useRef(C),W=!wP(C,M.current),U=A!==-1&&T===-1||W,P=xP(l);Js(()=>{W&&x&&b(C)},[W,C,x,b]),v.useEffect(()=>{M.current=C},[C]);const F=v.useMemo(()=>({activeIndex:T,containerId:_,disabled:P,disableTransforms:U,items:C,overIndex:A,useDragOverlay:w,sortedRects:SP(C,g),strategy:o}),[T,_,P.draggable,P.droppable,U,C,A,g,w,o]);return zt.createElement(T2.Provider,{value:F},t)}const EP=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return C2(n,r,o).indexOf(t)},RP=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:l,newIndex:d,previousItems:f,previousContainerId:g,transition:p}=e;return!p||!r||f!==l&&o===d?!1:n?!0:d!==o&&t===g},DP={duration:200,easing:"ease"},E2="transform",NP=ha.Transition.toString({property:E2,duration:0,easing:"linear"}),MP={roleDescription:"sortable"};function AP(e){let{disabled:t,index:n,node:r,rect:o}=e;const[l,d]=v.useState(null),f=v.useRef(n);return Js(()=>{if(!t&&n!==f.current&&r.current){const g=o.current;if(g){const p=Ic(r.current,{ignoreTransform:!0}),b={x:g.left-p.left,y:g.top-p.top,scaleX:g.width/p.width,scaleY:g.height/p.height};(b.x||b.y)&&d(b)}}n!==f.current&&(f.current=n)},[t,n,r,o]),v.useEffect(()=>{l&&d(null)},[l]),l}function LP(e){let{animateLayoutChanges:t=RP,attributes:n,disabled:r,data:o,getNewIndex:l=EP,id:d,strategy:f,resizeObserverConfig:g,transition:p=DP}=e;const{items:b,containerId:_,activeIndex:w,disabled:C,disableTransforms:x,sortedRects:T,overIndex:A,useDragOverlay:M,strategy:W}=v.useContext(T2),U=jP(r,C),P=b.indexOf(d),F=v.useMemo(()=>({sortable:{containerId:_,index:P,items:b},...o}),[_,o,P,b]),V=v.useMemo(()=>b.slice(b.indexOf(d)),[b,d]),{rect:O,node:G,isOver:fe,setNodeRef:ee}=vp({id:d,data:F,disabled:U.droppable,resizeObserverConfig:{updateMeasurementsFor:V,...g}}),{active:te,activatorEvent:$,activeNodeRect:Z,attributes:ie,setNodeRef:J,listeners:j,isDragging:R,over:I,setActivatorNodeRef:re,transform:_e}=Vb({id:d,data:F,attributes:{...MP,...n},disabled:U.draggable}),N=pD(ee,J),Y=!!te,oe=Y&&!x&&hf(w)&&hf(A),Q=!M&&R,we=Q&&oe?_e:null,ue=oe?we??(f??W)({rects:T,activeNodeRect:Z,activeIndex:w,overIndex:A,index:P}):null,Re=hf(w)&&hf(A)?l({id:d,items:b,activeIndex:w,overIndex:A}):P,Oe=te?.id,ge=v.useRef({activeId:Oe,items:b,newIndex:Re,containerId:_}),He=b!==ge.current.items,Be=t({active:te,containerId:_,isDragging:R,isSorting:Y,id:d,index:P,items:b,newIndex:ge.current.newIndex,previousItems:ge.current.items,previousContainerId:ge.current.containerId,transition:p,wasDragging:ge.current.activeId!=null}),L=AP({disabled:!Be,index:P,node:G,rect:O});return v.useEffect(()=>{Y&&ge.current.newIndex!==Re&&(ge.current.newIndex=Re),_!==ge.current.containerId&&(ge.current.containerId=_),b!==ge.current.items&&(ge.current.items=b)},[Y,Re,_,b]),v.useEffect(()=>{if(Oe===ge.current.activeId)return;if(Oe!=null&&ge.current.activeId==null){ge.current.activeId=Oe;return}const Le=setTimeout(()=>{ge.current.activeId=Oe},50);return()=>clearTimeout(Le)},[Oe]),{active:te,activeIndex:w,attributes:ie,data:F,rect:O,index:P,newIndex:Re,items:b,isOver:fe,isSorting:Y,isDragging:R,listeners:j,node:G,overIndex:A,over:I,setNodeRef:N,setActivatorNodeRef:re,setDroppableNodeRef:ee,setDraggableNodeRef:J,transform:L??ue,transition:ve()};function ve(){if(L||He&&ge.current.newIndex===P)return NP;if(!(Q&&!pp($)||!p)&&(Y||Be))return ha.Transition.toString({...p,property:E2})}}function jP(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}qt.Down,qt.Right,qt.Up,qt.Left;function OP({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:r=null,getRuntimeStatus:o,onClose:l,onOpen:d,onRemove:f,onReorder:g}){const p=v.useRef(null),[b,_]=v.useState(()=>Date.now()),[w,C]=v.useState("grid"),[x,T]=v.useState(null),A=UC(Pf(Wb,{activationConstraint:{distance:6}}),Pf(Kb,{activationConstraint:{delay:180,tolerance:8}})),M=v.useMemo(()=>e.map(Xs),[e]),W=v.useMemo(()=>new Map(e.map(O=>[Xs(O),o?.(O)??null])),[e,o,b]);v.useEffect(()=>{const O=window.setInterval(()=>_(Date.now()),3e4);return()=>window.clearInterval(O)},[]),v.useEffect(()=>{const O=G=>{if(G.key==="Escape"){G.preventDefault(),G.stopImmediatePropagation(),l();return}const fe=G.target;if((fe instanceof HTMLInputElement||fe instanceof HTMLTextAreaElement)&&p.current?.contains(fe)||G.ctrlKey||G.altKey||G.metaKey)return;const ee=Number.parseInt(G.key,10)-1;ee>=0&&ee<Math.min(9,e.length)&&(G.preventDefault(),G.stopImmediatePropagation(),d(e[ee]))};return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[e,l,d]);const U=O=>{T(null);const G=String(O.active.id),fe=O.over?String(O.over.id):null;if(!fe||G===fe)return;const ee=e.find($=>Xs($)===G),te=e.find($=>Xs($)===fe);ee&&te&&g(ee,te)},P=O=>T({activeId:String(O.active.id),overId:null}),F=O=>{const G=String(O.active.id),fe=O.over?String(O.over.id):null;T(ee=>ee?.activeId===G&&ee.overId===fe?ee:{activeId:G,overId:fe})},V=x?e.find(O=>Xs(O)===x.activeId)??null:null;return u.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:l,children:u.jsxs("section",{ref:p,className:"favorite-tabs-dialog",onClick:O=>O.stopPropagation(),children:[u.jsxs("header",{className:"favorite-tabs-header",children:[u.jsxs("div",{children:[u.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",u.jsx("span",{children:e.length})]}),u.jsx("p",{children:"Press 1–9 to open a favorite"})]}),u.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[u.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":w==="grid",onClick:()=>C("grid"),children:"▦"}),u.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":w==="list",onClick:()=>C("list"),children:"☷"}),u.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:l,children:"×"})]})]}),u.jsxs(rk,{sensors:A,collisionDetection:LD,onDragStart:P,onDragOver:F,onDragEnd:U,onDragCancel:()=>T(null),children:[u.jsxs("div",{className:"favorite-tabs-list","data-view":w,children:[r?u.jsx("p",{className:"favorite-tabs-error",role:"alert",children:r}):null,e.length===0?u.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):u.jsx(TP,{items:M,strategy:w==="grid"?Uy:CP,children:e.map((O,G)=>u.jsx(BP,{favorite:O,index:G,busy:n,unavailable:t?.has(Xs(O))??!1,runtimeStatus:W.get(Xs(O))??null,now:b,isDropTarget:x?.overId===Xs(O)&&x.activeId!==Xs(O),onOpen:d,onRemove:f},Xs(O)))})]}),u.jsx(UN,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:V?u.jsx(IP,{favorite:V}):null})]})]})})}const BP=v.memo(function({favorite:t,index:n,busy:r,unavailable:o,runtimeStatus:l,now:d,isDropTarget:f,onOpen:g,onRemove:p}){const b=Xs(t),{attributes:_,listeners:w,setActivatorNodeRef:C,setNodeRef:x,transform:T,transition:A,isDragging:M}=LP({id:b,disabled:r,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),W={transform:ha.Transform.toString(T),transition:A,zIndex:M?1:void 0,opacity:M?.16:void 0};return u.jsxs("div",{ref:x,className:"favorite-tab-row","data-dragging":M||void 0,"data-drop-target":f||void 0,style:W,children:[u.jsx("button",{ref:C,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:U=>U.stopPropagation(),..._,...w,children:"⋮⋮"}),u.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>g(t),disabled:r||o,title:o?"Server is no longer registered":void 0,children:[u.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),u.jsxs("span",{className:"favorite-tab-copy",children:[u.jsx("strong",{children:t.tabName}),u.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),l&&!o?u.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${l.state}`,title:"Last observed terminal status",children:[u.jsx("i",{"aria-hidden":"true"}),PP(l.state),l.lastActivityAt?` · ${zP(l.lastActivityAt,d)}`:""]}):null,l?.unread&&!o?u.jsxs("small",{className:"favorite-tab-runtime favorite-tab-runtime--unread",title:"Unread completion",children:[u.jsx("i",{"aria-hidden":"true"}),"Unread"]}):null]}),u.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(U=>u.jsx("img",{src:`/brand/${U}.webp`,alt:"","aria-hidden":"true"},U)),u.jsx("em",{children:t.paneCount})]})]}),u.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:r,onClick:()=>p(t),children:"×"})]})}),IP=v.memo(function({favorite:t}){return u.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[u.jsx("span",{className:"favorite-tab-index",children:"★"}),u.jsxs("span",{className:"favorite-tab-copy",children:[u.jsx("strong",{children:t.tabName}),u.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),u.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(n=>u.jsx("img",{src:`/brand/${n}.webp`,alt:""},n)),u.jsx("em",{children:t.paneCount})]})]})});function Xs(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function PP(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function zP(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"recently";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return"now";const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const l=Math.floor(o/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function HP({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const d=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return u.jsxs("aside",{className:`upload-toast upload-toast-${KP(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[u.jsxs("header",{className:"upload-toast-header",children:[u.jsx("strong",{children:e.length===1?Df(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),u.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),u.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>u.jsx(UP,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function UP({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const l="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return u.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Df(e),children:[u.jsxs("div",{className:"upload-queue-item-header",children:[u.jsx("strong",{children:Df(e)}),u.jsxs("div",{className:"upload-queue-actions",children:[f?u.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?u.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,u.jsx("button",{type:"button","aria-label":`Dismiss ${Df(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?u.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?u.jsx($P,{toast:e}):null,l&&"message"in e&&e.message?u.jsx("p",{className:"upload-toast-muted",children:e.message}):null,l?u.jsx(FP,{response:l,compact:t}):null,e.status==="failed"&&!l&&e.message?u.jsx("p",{children:e.message}):null]})}function $P({toast:e}){const t=e.percent===null?qP(e.loaded):`${e.percent}%`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"upload-progress-row",children:[u.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),u.jsx("span",{children:t})]}),u.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:u.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function FP({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),r=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,l=[...n,...r].slice(0,o);return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),l.length>0?u.jsx("ul",{className:"upload-result-list",children:l.map((d,f)=>u.jsx(WP,{result:d},`${d.relativePath}-${f}`))}):null,e.results.length>l.length?u.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-l.length," more"]}):null]})}function WP({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return u.jsxs("li",{"data-status":e.status,children:[u.jsx("span",{className:"upload-result-path",children:t}),n?u.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?u.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Df(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function KP(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 qP(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function VP({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",l=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function d(g){g.stopPropagation(),n()}function f(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return u.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:f,children:[u.jsxs("header",{className:"completion-toast-header",children:[u.jsxs("div",{className:"completion-toast-copy",children:[u.jsx("strong",{children:r.tabTitle}),u.jsx("span",{children:l})]}),u.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),u.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const YP=Xu(0,0,1,1),sa=1e-6;function GP(e){return R2(e).map(t=>t.terminalId)}function R2(e){return Gu(e,YP).sort(JP).map((t,n)=>({...t,index:n+1}))}function XP(e,t,n){const r=R2(e),o=r.find(d=>d.terminalId===t);return o?r.filter(d=>d.terminalId!==t).map(d=>QP(o,d,n)).filter(d=>d!==null).sort(ez)[0]?.entry.terminalId??null:null}function ZP(e,t){return!Number.isInteger(t)||t<1?null:GP(e)[t-1]??null}function Gu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=tz(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Gu(e.first,Xu(t.left,t.top,o,t.bottom)),...Gu(e.second,Xu(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...Gu(e.first,Xu(t.left,t.top,t.right,r)),...Gu(e.second,Xu(t.left,r,t.right,t.bottom))]}function QP(e,t,n){const r=e.bounds,o=t.bounds,l=xC(r.left,r.right,o.left,o.right),d=xC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-sa||d<=sa?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"right":return o.centerX<=r.centerX+sa||d<=sa?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"up":return o.centerY>=r.centerY-sa||l<=sa?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:l};case"down":return o.centerY<=r.centerY+sa||l<=sa?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:l};default:return null}}function JP(e,t){return wc(e.bounds.top,t.bounds.top)||wc(e.bounds.left,t.bounds.left)}function ez(e,t){return wc(e.primaryDistance,t.primaryDistance)||wc(e.perpendicularDistance,t.perpendicularDistance)||wc(t.overlap,e.overlap)||wc(e.entry.index,t.entry.index)}function wc(e,t){const n=e-t;return Math.abs(n)<=sa?0:n}function xC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function Xu(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function tz(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const CC="nterminal.terminalWorkspaces.v2",D2="nterminal.sidebarCollapsed.v1",nz=75,kC=lk.map(e=>e.url),iz=lk[0].url,sz=6;function rz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:l=!1,onLogout:d=async()=>{},onSessionInvalid:f}){_P();const g=v.useMemo(()=>e??up(),[e]),p=v.useMemo(()=>t??Zs(null),[t]),b=v.useMemo(()=>Tz(n),[n]),_=v.useMemo(()=>S=>y2(n,S),[n]),w=v.useMemo(()=>()=>gt(n),[n]),C=v.useSyncExternalStore(_,w,w),x=C.state,T=C.editors,A=!C.loaded,M=C.error,[W,U]=v.useState(!1),[P,F]=v.useState(()=>Lz()),[V,O]=v.useState("servers"),[G,fe]=v.useState(!1),[ee,te]=v.useState(!1),[$,Z]=v.useState([]),[ie,J]=v.useState(!1),[j,R]=v.useState(null),[I,re]=v.useState(null),[_e,N]=v.useState(null),Y=v.useMemo(()=>Zs(_e?.agentId??null),[_e?.agentId]),oe=v.useMemo(()=>Zs(I?.agentId??null),[I?.agentId]),Q=v.useSyncExternalStore(xL,L1,L1);v.useSyncExternalStore(nd,A1,A1);const[we,Se]=v.useState(0),[ue,Re]=v.useState(null),[Oe,ge]=v.useState(()=>[null]),[He,Be]=v.useState(()=>({[Vt]:"Local"})),L=v.useRef(new Set),[ve,Le]=v.useState(0),[Pe,H]=v.useState(()=>[n]),[de,Te]=v.useState(()=>new Set),[Me,je]=v.useState({}),[be,Fe]=v.useState(null),We=v.useRef(0),Ue=v.useRef(0),[ut,_t]=v.useState(null),[lt,Nt]=v.useState(null),Yt=v.useRef(null),st=v.useRef(0),On=v.useRef(null),Sn=v.useRef(null),dt=v.useRef(null),Lt=v.useRef(null),Ct=v.useRef([]),gi=v.useRef(0),ki=v.useRef(!1),pe=v.useRef(0),Ze=v.useRef(0),at=v.useRef([]),mt=v.useRef(null),St=v.useRef(null),It=v.useRef(null),$t=v.useRef(new Map),dn=v.useRef(!0),[Gt,rn]=v.useState(0),hn=v.useRef(()=>{});v.useEffect(()=>(dn.current=!0,()=>{dn.current=!1}),[]);const[an,ln]=v.useState(null),En=UC(Pf(Wb,{activationConstraint:{distance:8}}),Pf(Kb,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>CL(g),[g]);function wn(S){const k=S.active.data.current;if(k){if(k.kind==="tab"&&typeof k.tabId=="string"&&typeof k.terminalId=="string"){ln({tabId:k.tabId,terminalId:k.terminalId});return}k.kind==="pane"&&typeof k.sourceTabId=="string"&&typeof k.terminalId=="string"&&ln({tabId:k.sourceTabId,terminalId:k.terminalId})}}function vi(S){ln(null);const k=S.active.data.current,B=S.over?.data.current;if(!(!k||!B||typeof k.terminalId!="string")){if(k.kind==="tab"&&typeof k.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){ot({type:"tab.reordered",sourceTabId:k.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){ot({type:"tab.moved_to_workspace",sourceTabId:k.tabId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&ot({type:"tab.dropped_into_pane",sourceTabId:k.tabId,sourceTerminalId:k.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(k.kind==="pane"&&typeof k.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){ot({type:"terminal.extracted_to_tab",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){ot({type:"terminal.extracted_to_workspace",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&ot({type:"tab.dropped_into_pane",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function si(){ln(null)}const ht=x.workspaces.find(S=>S.id===x.activeWorkspaceId)??x.workspaces[0],kt=ht?.tabs.find(S=>S.id===ht.activeTabId)??ht?.tabs[0],ae=kt?.activeTerminalId??null,Ce=ae?x.terminals[ae]:void 0,Ye=wz("(max-width: 760px)"),Xe=v.useMemo(()=>kt?lp(kt.root):[],[kt]),et=ht&&kt?Zu(n,ht.id,kt.id):null,fn=kt?N2(Xe,kt.activeTerminalId,et?Me[et]:void 0):null,xn=Ye&&Xe.length>1;v.useLayoutEffect(()=>{Er.current=n;const S=()=>{if(uf(void 0),document.visibilityState!=="visible"||!C.loaded||Qn()||!ht||!kt)return;const k=gt(n);k.generation!==C.generation||k.state!==x||uf({generation:C.generation,agentId:n,workspaceId:ht.id,tabId:kt.id,root:kt.root,terminalIds:A6(kt.root,xn?fn:null)})};return S(),document.addEventListener("visibilitychange",S),()=>{document.removeEventListener("visibilitychange",S),uf(void 0)}},[n,x,C.generation,C.loaded,C.error,ht?.id,kt?.id,kt?.root,kt?.activeTerminalId,Ye,fn,Gt]);const Mi=v.useMemo(()=>(ht?.detachedTerminalIds??[]).flatMap(S=>{const k=x.terminals[S];return k?[k]:[]}),[ht?.detachedTerminalIds,x.terminals]),Ft=v.useMemo(()=>{const S=new Set;for(const k of ht?.tabs??[])ll(k).some(B=>C.unreadCompletions.has(B))&&S.add(k.id);return S},[ht?.tabs,C.unreadCompletions]);v.useSyncExternalStore(B6,mC,mC);const[Ai,vs]=v.useState([]),$n=v.useRef([]),Li=v.useRef(null),[Ki,pn]=v.useState(null),[ri,Tr]=v.useState(null),[ji,cn]=v.useState([]),[_s,Co]=v.useState(()=>fl()),ga=v.useRef(0),Er=v.useRef(n),Xn=v.useRef(kC),zs=v.useRef(_s),qi=v.useRef(()=>{});qi.current=Cl,hn.current=Gi;const Rn=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();cn(S.assets.filter(k=>k.enabled).map(k=>k.url))}catch{cn([])}},[g]),Rr=v.useCallback(S=>{for(const k of S)L.current.add(al(k.agentId));Be(k=>{const B={...k};for(const X of S)B[al(X.agentId)]=X.label;return jv(k,B)?k:B})},[]);v.useEffect(()=>{const S=Ze.current+1;Ze.current=S;const k=pe.current;g.getFavorites().then(B=>{S!==Ze.current||k!==pe.current||(Us(B.favorites,B.revision),Ti(B.favorites,n,x))}).catch(()=>{})},[g]),v.useEffect(()=>{Ti(Ct.current,n,x)},[n,He]),v.useEffect(()=>{H(S=>S.some(k=>Hn(k,n))?S:[...S,n])},[n]);const va=v.useCallback(S=>{const k=gt(S),B=Zs(S);for(const X of Object.keys(k.state.terminals))fc(B.createWebSocketUrl(X)),Hu(X),hc(X);Z6(S),H(X=>X.filter(se=>!Hn(se,S))),Te(X=>{const se=`${Mf(S)}:`;let le=!1;const De=new Set;for(const Ie of X){if(Ie.startsWith(se)){le=!0;continue}De.add(Ie)}return le?De:X}),je(X=>{const se=`${Mf(S)}:`;let le=!1;const De={};for(const[Ie,qe]of Object.entries(X)){if(Ie.startsWith(se)){le=!0;continue}De[Ie]=qe}return le?De:X})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(k=>{if(S)return;const B=k.name?.trim()||"Local";L.current.add(Vt),Be(X=>{const se={...X,[Vt]:B};return jv(X,se)?X:se})}).catch(()=>{}),g.listAgents().then(k=>{if(!S){const B=k.agents.map(le=>le.id),X=vA(k.serverOrder,k.agents);for(const le of k.agents)L.current.add(al(le.id));Be(le=>{const De={[Vt]:le[Vt]??"Local"};for(const Ie of k.agents)De[Ie.id]=Ie.name;return jv(le,De)?le:De}),n!==null&&!B.includes(n)&&(va(n),r?.(null));const se=Lt.current;se&&se.serverId!==Vt&&!B.includes(se.serverId)&&(Lt.current=null,R(`${se.serverName} is no longer registered.`),te(!0)),ge(X)}}).catch(()=>{}),()=>{S=!0}},[n,g,va,r,ve]);const Dr=v.useCallback(S=>{va(S),Le(k=>k+1),Hn(S,Er.current)&&r?.(null)},[va,r]);v.useEffect(()=>{ge(S=>S.some(k=>Hn(k,n))?S:[...S,n])},[n]),v.useEffect(()=>{Re(null)},[n]),v.useEffect(()=>{const S=On.current;if(!S)return;if(!Hn(S.agentId,n)){On.current=null;return}if(!C.loaded||x.workspaces.length===0)return;On.current=null;const k=S.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];k&&k.id!==x.activeWorkspaceId&&ot({type:"workspace.selected",workspaceId:k.id})},[n,C.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const S=Sn.current;if(S){if(!Hn(S.agentId,n)){Sn.current=null;return}C.loaded&&(Sn.current=null,x.workspaces.some(k=>k.id===S.workspaceId)&&ot({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,C.loaded,x.workspaces]),v.useEffect(()=>{const S=dt.current;if(S){if(!Hn(S.agentId,n)){dt.current=null;return}C.loaded&&(dt.current=null,C.error||Bn())}},[n,C.error,C.loaded]),v.useEffect(()=>{const S=Lt.current;if(!(!S||!Hn(S.serverId===Vt?null:S.serverId,n)||!C.loaded)){if(Lt.current=null,C.error){R(`Could not reach ${S.serverName}.`),te(!0);return}ya(S)}},[n,C.loaded]),v.useEffect(()=>{const S=()=>{const X=Cz();X&&hn.current(X)},k=X=>{const se=kz(X.data);se&&hn.current(se)},B=X=>{const se=bp(X.detail);se&&hn.current(se)};return S(),window.addEventListener("hashchange",S),window.addEventListener($v,B),navigator.serviceWorker?.addEventListener?.("message",k),()=>{window.removeEventListener("hashchange",S),window.removeEventListener($v,B),navigator.serviceWorker?.removeEventListener?.("message",k)}},[]),v.useEffect(()=>{Rn()},[Rn]),v.useEffect(()=>_k(()=>Co(fl())),[]),v.useEffect(()=>{const S=k=>{qi.current(k)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{Xn.current=ji.length>0?ji:kC},[ji]),v.useEffect(()=>{zs.current=_s},[_s]),v.useEffect(()=>{if(!C.loaded||!ht||!kt)return;const S=Zu(n,ht.id,kt.id);Te(k=>{if(k.has(S))return k;const B=new Set(k);return B.add(S),B})},[n,C.loaded,ht?.id,kt?.id]),v.useEffect(()=>()=>{Ml()},[]),v.useEffect(()=>{const S=PM(g),k=UM(g);return()=>{S(),k()}},[g]),v.useEffect(()=>P6(S=>{const k=gt(S.agentId).state,B=k.workspaces.flatMap(De=>De.tabs).find(De=>De.id===S.tabId),X=k.terminals[S.terminalId],se=B?.title?.trim()||X?.title||S.commandName||"terminal",le=zy(S.agentId,S.terminalId);if(le||AM({agentId:S.agentId,tabTitle:se,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!le&&document.visibilityState==="visible"&&zs.current.enabled){const De=ga.current+1;ga.current=De;const Ie=Xn.current;pn({id:De,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:se,commandName:S.commandName,outcome:S.outcome,assetSrc:Ie[Math.floor(Math.random()*Ie.length)]??iz})}}),[]),v.useEffect(()=>{if(!Ki||_s.persistUntilDismissed)return;const S=window.setTimeout(()=>{pn(k=>k?.id===Ki.id?null:k)},_s.durationSeconds*1e3);return()=>window.clearTimeout(S)},[Ki,_s]),v.useEffect(()=>{jz(P),P&&bs()},[P]),v.useEffect(()=>{let S=!1,k;async function B(){if(!gt(n).loaded){k=K6(n),eo(n,!1,null);try{let se=null,le=null;try{se=Ez(b)}catch(qe){if(!(qe instanceof cp))throw qe;le=qe}const[De,Ie]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]);if(!S&&Nd(n,k)){const qe=Ie.layout?Mb(Ie.layout):null;if(!qe&&le)throw le;const Ke=qe??se??{},ft=$t.current.get(n);let Wt=ft?.generation===k.generation&&!De.terminals.some(qs=>qs.id===ft.terminal.id)?[...De.terminals,ft.terminal]:De.terminals;const jt=w2(n,k,Wt);if(!jt)return;if(q6(n,k,jt)){const qs=await p.createTerminal({cols:80,rows:24});Wt=[...Wt,qs.terminal]}if(S)return;const Dn=$t.current.get(n);Dn?.generation===k.generation&&!Wt.some(qs=>qs.id===Dn.terminal.id)&&(Wt=[...Wt,Dn.terminal]);const Ir=V6(n,k,{terminals:Wt,...Ke,revision:Ie.revision,persistedLayout:Ie.layout});if(!Ir)return;$t.current.get(n)===Dn&&$t.current.delete(n);const Pr=ro(Ir.state),Ta=gt(n);(Ir.layoutPreserved&&JSON.stringify(Pr)!==Ta.lastPersistedLayoutJson||!Ir.metadataPreserved&&!qe&&se)&&xa(Pr,{},k.generation)}}catch(se){!S&&k&&Nd(n,k)&&!Ss(se)&&eo(n,!0,na(se))}finally{k&&vC(n,k)}}}return B(),()=>{S=!0,k&&vC(n,k)}},[n,p,we]);function _a(){eo(n,!1,null),Se(S=>S+1)}function bs(){We.current+=1,Ue.current+=1,Fe(null)}function ko(S){We.current+=1,Ue.current+=1,Fe(k=>k&&{...k,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Bn(){We.current+=1,Ue.current+=1;const S=x.workspaces.length+1,k=To();Fe({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),k&&Vi(k)}function _i(S){if(Hn(S,n)){Bn();return}dt.current={agentId:S},r?.(S)}function ir(S){if(P&&!W)return;const k=x.workspaces.find(X=>X.id===S);if(!k)return;We.current+=1,Ue.current+=1;const B=k.defaultCwd??Ce?.cwd??"";Fe({mode:"edit",workspaceId:S,title:k.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Vi(B)}function To(){return ht?.defaultCwd??Ce?.cwd??""}async function Vi(S){const k=We.current+1;We.current=k;const B=S.trim();if(Fe(X=>X&&{...X,cwd:S,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const X=await p.createFileRoot({path:B}),se=await p.listFiles({rootToken:X.rootToken,path:""});if(We.current!==k)return;Fe(le=>le&&{...le,cwd:X.rootPath,browseRoot:{rootToken:X.rootToken,rootPath:X.rootPath},browseEntries:se.entries.filter(De=>De.kind==="directory"),browseStatus:"idle",error:null})}catch(X){if(We.current!==k)return;Fe(se=>se&&{...se,browseStatus:"idle",error:na(X)})}}async function Eo(){const S=be;if(!S)return;const k=S.title.trim(),B=S.cwd.trim();if(!k||!B){Fe({...S,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const X=Ue.current+1;Ue.current=X,Fe({...S,submitStatus:"submitting",error:null});try{const se=await p.createFileRoot({path:B});if(Ue.current!==X)return;if(S.mode==="create"){const le=x.workspaces.length+1;ot({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${le}`,title:k,defaultCwd:se.rootPath})}else S.workspaceId&&(ot({type:"workspace.renamed",workspaceId:S.workspaceId,title:k}),ot({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:se.rootPath}));Fe(null)}catch(se){if(Ue.current!==X)return;Fe(le=>le&&{...le,submitStatus:"idle",error:na(se)})}}function Nr(S){Ue.current+=1,Fe(S)}function Hs(S,k,B){if(S===k)return;const X=x.workspaces.some(le=>le.id===S),se=x.workspaces.some(le=>le.id===k);!X||!se||ot({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:k,placement:B})}function sr(S,k){const B=x.workspaces.findIndex(se=>se.id===S),X=x.workspaces[B+k];B<0||!X||Hs(S,X.id,k<0?"before":"after")}function Ro(S,k){k.pointerType==="mouse"&&k.button!==0||(k.preventDefault(),k.stopPropagation(),Yt.current={sourceId:S,pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,active:!1,targetId:null,placement:"after"},k.currentTarget.setPointerCapture?.(k.pointerId))}function Do(S){const k=Yt.current;if(!k||k.pointerId!==S.pointerId)return;const B=Math.hypot(S.clientX-k.startX,S.clientY-k.startY);if(!k.active){if(B<sz)return;k.active=!0,_t(k.sourceId)}const se=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),le=se?.dataset.workspaceId??null;if(!se||!le||le===k.sourceId||!x.workspaces.some(qe=>qe.id===le)){k.targetId=null,Nt(null);return}const De=se.getBoundingClientRect(),Ie=S.clientY<De.top+De.height/2?"before":"after";k.targetId=le,k.placement=Ie,Nt({workspaceId:le,placement:Ie})}function ss(S){const k=Yt.current;!k||k.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Yt.current=null,_t(null),Nt(null),k.active&&k.targetId&&Hs(k.sourceId,k.targetId,k.placement))}function $c(S){const k=Yt.current;k&&k.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Yt.current=null,_t(null),Nt(null)}async function ba(){await oi(async()=>{const S=ht?.defaultCwd?{cols:80,rows:24,cwd:ht.defaultCwd}:{cols:80,rows:24},k=await p.createTerminal(S);ot({type:"terminal.created",terminal:k.terminal})})}function Oi(S,k=ht,B=x,X=n){const se=B.terminals[S.activeTerminalId],le=Array.from(new Set(ll(S).flatMap(De=>{const Ie=B.terminals[De]?.agentStatus?.provider;return Ie==="codex"||Ie==="claude"?[Ie]:[]})));return{serverId:X??Vt,workspaceId:k.id,tabId:S.id,serverName:He[al(X)]??(X===null?"Local":"Server"),workspaceName:k.title,tabName:S.title||se?.title||"Terminal",cwd:se?.cwd||k.defaultCwd,paneCount:ap(S),providers:le}}function Bi(S){const k=S.serverId===Vt?null:S.serverId,B=Ja(k);if(!B?.loaded||B.error)return null;const X=B.state,le=X.workspaces.find(Ke=>Ke.tabs.some(ft=>ft.id===S.tabId))?.tabs.find(Ke=>Ke.id===S.tabId);if(!le)return null;const De=ll(le).flatMap(Ke=>{const ft=X.terminals[Ke];return ft?[ft]:[]});if(De.length===0)return null;const Ie=De.reduce((Ke,ft)=>{const Wt=ft.agentCache?.lastCallAt;return Wt&&(!Ke||Date.parse(Wt)>Date.parse(Ke))?Wt:Ke},null),qe=De.some(Ke=>B.unreadCompletions.has(Ke.id));return De.some(Ke=>Ke.status==="running"&&(Ke.agentStatus?.state==="working"||Ke.agentStatus?.state==="finishing"||!Ke.agentStatus&&Ke.activity==="busy"))?{state:"working",lastActivityAt:Ie,unread:qe}:De.some(Ke=>Ke.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Ie,unread:qe}:De.some(Ke=>Ke.agentStatus?.state==="done")?{state:"done",lastActivityAt:Ie,unread:qe}:De.every(Ke=>Ke.status==="exited")?{state:"exited",lastActivityAt:Ie,unread:qe}:{state:"idle",lastActivityAt:Ie,unread:qe}}function Us(S,k){Ct.current=S,gi.current=k,Z(S)}function ys(S){pe.current+=1,at.current.push(S),!ki.current&&(ki.current=!0,J(!0),R(null),(async()=>{try{for(;at.current.length>0;){const k=at.current.shift();let B=0;for(;B<2;){const X=k(Ct.current);if(EC(X,Ct.current))break;Us(X,gi.current);try{const se=await g.saveFavorites({favorites:X,baseRevision:gi.current});Us(se.favorites,se.revision);break}catch(se){const le=await g.getFavorites().catch(()=>null);if(le&&Us(le.favorites,le.revision),se instanceof Un&&se.status===409&&le){B+=1;continue}at.current=[],R("Could not save favorites. Please try again.");return}}if(B>=2){at.current=[],R("Favorites changed on another device. Please try again.");return}}}finally{ki.current=!1,J(!1)}})())}function Ti(S,k,B){const X=k??Vt,se=le=>le.map(De=>{if(De.serverId!==X)return De;const Ie=B.workspaces.find(ft=>ft.tabs.some(Wt=>Wt.id===De.tabId)),qe=Ie?.tabs.find(ft=>ft.id===De.tabId);if(!Ie||!qe)return De;const Ke=Oi(qe,Ie,B,k);return L.current.has(al(k))?Ke:{...Ke,serverName:De.serverName}});EC(S,se(S))||ys(se)}function Mr(S){const k=n??Vt,B=Ct.current.find(se=>se.serverId===k&&se.tabId===S.id);if(B){const se=js(B);ys(le=>le.filter(De=>js(De)!==se));return}if(!ht||Ct.current.length>=100)return;const X=Oi(S);ys(se=>se.length>=100?se:[...se,X])}function ai(S){const k=S.serverId===Vt?null:S.serverId;if(k!==null&&!Oe.some(B=>Hn(B,k))){R(`${S.serverName} is no longer registered.`);return}if(R(null),te(!1),!Hn(k,n)){Lt.current=S,r?.(k);return}ya(S)}async function ya(S){const k=gt(n).state,B=k.workspaces.find(se=>se.tabs.some(le=>le.id===S.tabId));if(B){ot({type:"workspace.selected",workspaceId:B.id}),ot({type:"tab.selected",tabId:S.tabId});return}let X=k.workspaces.find(se=>se.id===S.workspaceId);if(!X){const se=`workspace-favorite-${Date.now().toString(36)}`;ot({type:"workspace.created",workspaceId:se,title:S.workspaceName,defaultCwd:S.cwd}),X=gt(n).state.workspaces.find(le=>le.id===se)}X&&ot({type:"workspace.selected",workspaceId:X.id}),await oi(async()=>{const se=await p.createTerminal(S.cwd?{cols:80,rows:24,cwd:S.cwd}:{cols:80,rows:24});ot({type:"terminal.created",terminal:se.terminal});const De=gt(n).state.workspaces.find(jt=>jt.tabs.some(Dn=>Dn.activeTerminalId===se.terminal.id)),Ie=De?.tabs.find(jt=>jt.activeTerminalId===se.terminal.id);if(!Ie||!De)return;Ie.title!==S.tabName&&ot({type:"tab.renamed",tabId:Ie.id,title:S.tabName});const qe=gt(n).state,Ke=qe.workspaces.find(jt=>jt.id===De.id)??De,ft=Ke.tabs.find(jt=>jt.id===Ie.id)??Ie,Wt=Oi(ft,Ke,qe);ys(jt=>jt.map(Dn=>Dn.serverId===S.serverId&&Dn.workspaceId===S.workspaceId&&Dn.tabId===S.tabId?Wt:Dn))})}async function Ar(S){await oi(async()=>{const k=ae?{parentTerminalId:ae,cols:80,rows:24}:ht?.defaultCwd?{cols:80,rows:24,cwd:ht.defaultCwd}:{cols:80,rows:24},B=await p.createTerminal(k);ot({type:"terminal.split",terminal:B.terminal,direction:S})})}async function Ii(S){let k=ae,B=et;const X=ht?.defaultCwd?.trim();if(!k&&!X)throw new Error("No active pane is available.");const se=await p.readFile(S);if(!k&&X){const Ie=await p.createTerminal({cols:80,rows:24,cwd:X});k=Ie.terminal.id,ot({type:"terminal.created",terminal:Ie.terminal})}if(k){ot({type:"pane.selected",terminalId:k});const Ie=gt(n).state,qe=Ie.workspaces.find(ft=>ft.id===Ie.activeWorkspaceId)??Ie.workspaces[0],Ke=qe?.tabs.find(ft=>ft.id===qe.activeTabId)??qe?.tabs[0];B=qe&&Ke?Zu(n,qe.id,Ke.id):null}const le=`editor-${Date.now().toString(36)}-${X6(n)}`,De=Az(se.path);Dv(n,Ie=>({...Ie,[le]:{id:le,title:De,rootToken:S.rootToken,path:se.path,read:se}})),B&&je(Ie=>({...Ie,[B]:M2(le)})),ot({type:"editor.split",editorId:le,title:De,direction:"vertical"})}function Yi(S){Dv(n,k=>{const B={...k};return delete B[S],B}),ot({type:"editor.closed",editorId:S})}function Lr(S){$s([S])}function $s(S){const k=[...new Set(S)].filter(X=>x.terminals[X]);if(k.length===0)return;const B=k.length===1?x.terminals[k[0]]?.title||x.terminals[k[0]]?.cwd||k[0]:`${k.length} panes`;Re(null),Tr({terminalIds:k,label:B,workspaceId:ht?.id??x.activeWorkspaceId??null})}function Ei(S,k){const B=Mo(S,k);if(!B)return!1;const X=S.filter(se=>!B.detachedTerminalIds.includes(se));if(B.detachedTerminalIds.length+X.length>mo)return Re(Dz(B.detachedTerminalIds.length)),!1;Re(null);for(const se of S)ot(B.id?{type:"terminal.detached",terminalId:se,workspaceId:B.id}:{type:"terminal.detached",terminalId:se});return!0}async function Pi(S){await oi(async()=>{for(const k of S)await ar(k),fc(p.createWebSocketUrl(k)),Hu(k),hc(k),ot({type:"terminal.closed",terminalId:k})})}async function jr(S){const k=x.workspaces.find(B=>B.id===S);!k||x.workspaces.length<=1||window.confirm(`Delete workspace "${k.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await oi(async()=>{const B=xr(k),X=[];let se=null;for(const De of B)try{await ar(De)}catch(Ie){X.push(na(Ie)),Ie instanceof Un&&Ie.status===401&&!p.isAgent&&(se=Ie)}finally{fc(p.createWebSocketUrl(De)),Hu(De),hc(De)}const le=k.tabs.flatMap(De=>Nb(De.root));if(le.length>0){const De=new Set(le);Dv(n,Ie=>{const qe={...Ie};for(const Ke of De)delete qe[Ke];return qe})}if(ot({type:"workspace.closed",workspaceId:S}),se)throw se;if(X.length>0)throw new Error(`Workspace was removed, but ${X.length} terminal session${X.length===1?"":"s"} may still be running. ${X[0]}`)})}async function xl(S){await oi(async()=>{await ar(S),fc(p.createWebSocketUrl(S)),Hu(S),hc(S),ot({type:"terminal.closed",terminalId:S})})}async function rr(S,k){const B=k.trim();if(!B)return;let X=null;for(const se of x.workspaces){const le=se.tabs.find(De=>De.id===S);if(le){X=le.activeTerminalId;break}}if(ot({type:"tab.renamed",tabId:S,title:B}),!!X)try{const se=await p.renameTerminal(X,B);No({type:"terminal.updated",terminal:se.terminal})}catch(se){eo(n,!0,na(se))}}function Fs(S){const k=x.terminals[S];k&&ot({type:"terminal.created",terminal:k})}async function ar(S){try{await p.closeTerminal(S)}catch(k){if(k instanceof Un&&k.status===404)return;throw k}}async function Zn(){await oi(async()=>{await d()})}async function oi(S){eo(n,!0,null);try{await S()}catch(k){if(Ss(k))return;eo(n,!0,na(k))}}function Ss(S){return S instanceof Un&&S.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function ot(S){rl(n,S);const k=gt(n),B=k.state;if(Ti(Ct.current,n,B),!k.loaded||B.workspaces.length===0)return;const X=ro(B);JSON.stringify(X)!==k.lastPersistedLayoutJson&&jo(X)}function No(S){rl(n,S),Ti(Ct.current,n,gt(n).state)}function or(S,k,B,X){const se=Zu(S,k,B);je(le=>({...le,[se]:X}))}function Ws(S){et&&je(k=>({...k,[et]:S}))}function Ks(S,k){const B=xc(S);k?or(n,k.workspaceId,k.tabId,B):Ws(B),ot({type:"pane.selected",terminalId:S})}function Sa(S){Ws(S.key),S.type==="terminal"&&ot({type:"pane.selected",terminalId:S.terminalId})}function Cl(S){if(G||_e||ri||S.isComposing||S.key==="Process"||dz(S.target))return;const k=oz(S);if(!k)return;if(S.preventDefault(),S.stopPropagation(),k.type==="server.previous"||k.type==="server.next"){Tl(k.type==="server.next"?1:-1);return}if(k.type==="favorites.toggle"){te(!0);return}const B=gt(n).state,X=B.workspaces.find(De=>De.id===B.activeWorkspaceId)??B.workspaces[0],se=X?.tabs.find(De=>De.id===X.activeTabId)??X?.tabs[0];if(k.type==="split"){if(!se)return;Ar(k.direction);return}if(!X||!se)return;if(k.type==="tab.previous"||k.type==="tab.next"){const De=uz(X.tabs,se.id,k.type==="tab.next"?1:-1);De&&ot({type:"tab.selected",tabId:De.id});return}if(k.type==="tab.index"){const De=X.tabs[k.index-1];De&&ot({type:"tab.selected",tabId:De.id});return}const le=lz(se.root,se.activeTerminalId,k);le&&Ks(le,{workspaceId:X.id,tabId:se.id})}function kl(S,k){if(!r||Oe.length===0)return;const B=Oe.findIndex(De=>Hn(De,n)),se=((B===-1?0:B)+S+Oe.length)%Oe.length,le=Oe[se]??null;Hn(le,n)||(k&&(On.current={agentId:le,edge:k}),r(le))}function Tl(S){const k=gt(n).state,B=k.workspaces;if(B.length===0){kl(S,S===1?"first":"last");return}const X=B.findIndex(De=>De.id===k.activeWorkspaceId),le=(X===-1?0:X)+S;if(le>=0&&le<B.length){ot({type:"workspace.selected",workspaceId:B[le].id});return}kl(S,S===1?"first":"last")}function El(S,k){if(Hn(S,n)){ot({type:"workspace.selected",workspaceId:k});return}Sn.current={agentId:S,workspaceId:k},r?.(S)}function Mo(S,k){if(k)return x.workspaces.find(B=>B.id===k)??null;for(const B of S){const X=x.workspaces.find(le=>le.tabs.some(De=>ll(De).includes(B)));if(X)return X;const se=x.workspaces.find(le=>le.detachedTerminalIds.includes(B));if(se)return se}return x.workspaces.find(B=>B.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Fc(S){yc(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function Wc(S){if(!yc(S.dataTransfer))return;S.preventDefault();const k=Nz(gt(n).state),B=st.current+1;if(st.current=B,!k){lr({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}lr({id:B,status:"queued",fileCount:0,terminalId:k.id,message:"Preparing upload..."}),Ao(B,k.id,S.dataTransfer)}async function Ao(S,k,B){try{const X=await NE(B);if(X.length===0)throw new Error("No files were found in the drop.");bi(S,{id:S,status:"queued",fileCount:X.length,message:"Queued"},{terminalId:k,files:X})}catch(X){bi(S,{id:S,status:"failed",fileCount:0,message:na(X)},{terminalId:k})}finally{wa()}}async function Kc(S){const k=$n.current.find(le=>le.id===S);if(!k?.terminalId||!k.files||k.files.length===0)return;const B=k.terminalId,X=k.files,se=new AbortController;Li.current=S,bi(S,{id:S,status:"uploading",fileCount:X.length,loaded:0,total:null,percent:null},{terminalId:B,files:X,abortController:se});try{const le=await AC({terminalId:B,files:X,signal:se.signal,onProgress:Ke=>{bi(S,{id:S,status:"uploading",fileCount:X.length,loaded:Ke.loaded,total:Ke.total,percent:Ke.percent},{terminalId:B,files:X,abortController:se})}}),De=le.failed>0?le.uploaded>0?"partial":"failed":"success",Ie=le.failed>0?Mz(le):void 0,qe={id:S,status:De,fileCount:X.length,response:le};Ie&&(qe.message=Ie),bi(S,qe,{terminalId:B,files:X})}catch(le){bi(S,{id:S,status:"failed",fileCount:X.length,message:se.signal.aborted?"Upload canceled.":na(le)},{terminalId:B,files:X})}finally{Li.current===S&&(Li.current=null),wa()}}function wa(){if(Li.current!==null)return;const S=$n.current.find(k=>k.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&Kc(S.id)}function lr(S){cr(k=>[...k,S])}function bi(S,k,B={}){cr(X=>X.map(se=>{if(se.id!==S)return se;const le={...k},De=B.terminalId??se.terminalId,Ie=B.files??se.files;return De!==void 0&&(le.terminalId=De),Ie!==void 0&&(le.files=Ie),B.abortController!==void 0&&(le.abortController=B.abortController),le}))}function cr(S){const k=S($n.current);$n.current=k,vs(k)}function Fn(S){$n.current.find(B=>B.id===S)?.abortController?.abort(),Li.current===S&&(Li.current=null),cr(B=>B.filter(X=>X.id!==S)),wa()}function Lo(){for(const S of $n.current)S.abortController?.abort();Li.current=null,cr(()=>[])}function ur(S){const k=$n.current.find(B=>B.id===S);if(k){if(k.status==="queued"){Fn(S);return}k.abortController?.abort()}}function Rl(S){const k=$n.current.find(X=>X.id===S);if(!k?.terminalId||!k.files||k.files.length===0)return;const B=Dl(k);if(B.length===0){bi(S,{id:S,status:"failed",fileCount:k.fileCount,message:"No failed files are available to retry."},{terminalId:k.terminalId,files:k.files});return}bi(S,{id:S,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:k.terminalId,files:B}),wa()}function Dl(S){const k=S.files??[],B="response"in S?S.response:void 0;if(!B)return k;const X=B.results.filter(De=>De.status==="failed").map(De=>De.relativePath);if(X.length===0)return[];const se=new Map;for(const De of k){const Ie=se.get(De.relativePath)??[];Ie.push(De),se.set(De.relativePath,Ie)}const le=[];for(const De of X){const qe=se.get(De)?.shift();qe&&le.push(qe)}return le}function Nl(S){Gi({kind:"terminal",agentId:S.agentId,terminalId:S.terminalId}),pn(null)}function Gi(S){if(mt.current=S,St.current=null,It.current=null,rn(k=>k+1),uf(void 0),!Hn(S.agentId,n)){r?r(S.agentId):mt.current=null;return}}function Qn(){const S=mt.current;if(!S||!Hn(S.agentId,n))return!1;if(!C.loaded||document.visibilityState!=="visible")return!0;if(It.current?.target===S){const X=It.current;return X.generation===C.generation&&(X.applying||X.layoutSequence===gt(S.agentId).mutable.hydration.layoutSequence)?!0:(It.current=null,mt.current=null,St.current=null,!1)}if(St.current?.target!==S||St.current.generation!==C.generation){if(St.current={target:S,generation:C.generation},!gt(S.agentId).state.workspaces.some(le=>xr(le).includes(S.terminalId)))return qc(S),!0;ot({type:"terminal.revealed",terminalId:S.terminalId});const se=Lv(gt(S.agentId).state,S.terminalId);if(se)return or(S.agentId,se.workspaceId,se.tabId,xc(S.terminalId)),rn(le=>le+1),!0}const k=gt(S.agentId),B=Lv(k.state,S.terminalId);return B&&(x!==k.state||ht?.id!==B.workspaceId||kt?.id!==B.tabId||xn&&fn!==xc(S.terminalId))?!0:(mt.current=null,St.current=null,!1)}async function qc(S){const k=gt(S.agentId),B={target:S,generation:k.generation,layoutSequence:k.mutable.hydration.layoutSequence,applying:!1};It.current=B;let X=!1;const se=()=>dn.current&&It.current===B&&mt.current===S&&Ja(S.agentId)?.generation===B.generation;try{const le=Zs(S.agentId),[De,Ie]=await Promise.all([le.listTerminals(),le.getTerminalLayout()]);if(!se())return;const qe=gt(S.agentId);if(!Hn(Er.current,S.agentId)||!qe.loaded||qe.mutable.hydration.layoutSequence!==B.layoutSequence)return;const Ke=De.terminals.find(Dn=>Dn.id===S.terminalId);if(!Ke)throw new Error("This terminal is no longer available.");const ft=eP(qe.state,Ke,Ie.layout);B.applying=!0,gC(S.agentId,ft);const Wt=ro(ft);Ie.revision===qe.layoutRevision?jo(Wt):lc(Wt,b);const jt=Lv(ft,S.terminalId);or(S.agentId,jt.workspaceId,jt.tabId,xc(S.terminalId)),St.current={target:S,generation:B.generation},X=!0}catch(le){se()&&!Ss(le)&&eo(S.agentId,!0,na(le))}finally{se()&&(It.current=null,X||(mt.current=null,St.current=null),rn(le=>le+1))}}function jo(S){const k=Ja(n);if(k?.generation!==C.generation)return;const B=k.mutable.saveCoord;B.pendingLayoutSave=S,lc(S,b),B.saveTimer!==null&&window.clearTimeout(B.saveTimer),B.saveTimer=window.setTimeout(()=>{B.saveTimer=null;const X=B.pendingLayoutSave;B.pendingLayoutSave=null,X&&xa(X,{},k.generation)},nz)}function Ml(){const S=Ja(n);if(S?.generation!==C.generation)return;const k=S.mutable.saveCoord;k.saveTimer!==null&&(window.clearTimeout(k.saveTimer),k.saveTimer=null);const B=k.pendingLayoutSave;k.pendingLayoutSave=null,B&&(lc(B,b),xa(B,{},S.generation))}function xa(S,k={},B=C.generation){const X=Ja(n);if(X?.generation!==B)return;const se=X.mutable.saveCoord;se.nextPersistLayout=S,k.baseRevision!==void 0&&(se.queuedBaseRevision=k.baseRevision),!se.nextPersistQueued&&(se.nextPersistQueued=!0,se.persistChain=se.persistChain.then(async()=>{if(Ja(n)?.generation!==B)return;se.nextPersistQueued=!1;const le=se.nextPersistLayout,De=se.queuedBaseRevision;se.nextPersistLayout=null,se.queuedBaseRevision=void 0,le&&await Vc(le,De!==void 0?{baseRevision:De}:{},B)}))}async function Vc(S,k,B){const X=Ja(n);if(X?.generation!==B||JSON.stringify(ro(X.state))!==JSON.stringify(S))return;const se=X.mutable.hydration.layoutSequence,le=()=>Ja(n)?.generation===B,De=k.baseRevision??X.layoutRevision,Ie={layout:S,...typeof De=="number"?{baseRevision:De}:{}};try{const qe=await p.saveTerminalLayout(Ie);if(!le())return;const Ke=qe.layout??S;df(n,qe.revision,JSON.stringify(Ke)),lc(Ke,b);return}catch(qe){if(!le())return;if(qe instanceof Un&&qe.status===400&&qe.message===WN){Rz(n,b),eo(n,!0,A2());return}if(qe instanceof Un&&qe.status===409)try{const Ke=await p.getTerminalLayout();if(!le())return;const ft=gt(n).mutable.saveCoord;if(ft.nextPersistLayout||ft.pendingLayoutSave||gt(n).mutable.hydration.layoutSequence!==se){const Wt=Ke.layout?JSON.stringify(Ke.layout):gt(n).lastPersistedLayoutJson;df(n,Ke.revision,Wt);return}if(Ke.layout){const Wt=gt(n).state,jt=rp(Object.values(Wt.terminals),void 0,Ke.layout.workspaces,Ke.layout.activeWorkspaceId),Dn=ro(jt);gC(n,jt),df(n,Ke.revision,JSON.stringify(Dn)),lc(Dn,b)}else df(n,Ke.revision,X.lastPersistedLayoutJson);return}catch{}le()&&lc(S,b)}}const Al=Oz(o),li=!P||W,Or=li?V:"servers";function Oo(S){const k=S.active?C:gt(S.agentId),B=S.active?x:k.state,X=S.active?C.loaded:k.loaded,se=S.active?M:k.error;return u.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[u.jsxs("div",{className:"workspace-list-header",children:[u.jsx("span",{children:"Workspaces"}),u.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>_i(S.agentId),children:"+"})]}),X?se?u.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(S.agentId),children:se}):u.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(le=>{const De=S.active&&le.id===ht?.id,Ie=xr(le).length,qe=I6(S.agentId,le.id),Ke=gz(qe),ft=S.active&&B.workspaces.length>1,Wt=lt?.workspaceId===le.id&&ut!==le.id?lt.placement:null;return u.jsxs(_z,{workspaceId:le.id,active:De,disabled:!S.active,reorderable:ft,dragging:ut===le.id,dropPlacement:Wt,working:qe.workingTerminalCount>0,unread:qe.unreadCompletionCount>0,children:[ft?u.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":le.id,title:"Drag to reorder","aria-label":`Reorder ${le.title}`,"aria-grabbed":ut===le.id,onPointerDown:jt=>Ro(le.id,jt),onPointerMove:Do,onPointerUp:ss,onPointerCancel:$c,onKeyDown:jt=>{(jt.key==="ArrowUp"||jt.key==="ArrowDown")&&(jt.preventDefault(),jt.stopPropagation(),sr(le.id,jt.key==="ArrowUp"?-1:1))},onClick:jt=>jt.stopPropagation(),children:"::"}):null,u.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":De?"page":void 0,title:le.defaultCwd??void 0,onClick:()=>El(S.agentId,le.id),onDoubleClick:()=>{S.active&&ir(le.id)},children:[u.jsxs("span",{className:"workspace-list-title-row",children:[u.jsx("span",{className:"workspace-list-name",children:le.title}),qe.workingTerminalCount>0||qe.unreadCompletionCount>0?u.jsxs("span",{className:"workspace-list-attention",title:Ke,"aria-label":Ke,children:[qe.workingTerminalCount>0?u.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,qe.unreadCompletionCount>0?u.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:mz(qe.unreadCompletionCount)}):null]}):null]}),u.jsxs("small",{children:[le.defaultCwd??"No folder"," · ",Ie," ",Ie===1?"session":"sessions"]})]}),S.active?u.jsxs("div",{className:"workspace-list-actions",children:[u.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${le.title}`,title:"Edit workspace",onClick:()=>ir(le.id),children:"..."}),u.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${le.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{jr(le.id)},children:"x"})]}):null]},le.id)})}):u.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(S.agentId),children:"Open server to load workspaces"})]})}function Br(S,k){re({...S,provider:k})}async function Yc(S){if(N(S),!gt(S.agentId).loaded)try{const k=Zs(S.agentId),[B,X]=await Promise.all([k.listTerminals(),k.getTerminalLayout()]),se=X.layout?Mb(X.layout):null,le=rp(B.terminals,void 0,se?.savedWorkspaces,se?.savedActiveWorkspaceId),De=le.workspaces.flatMap(Ie=>Ie.tabs.flatMap(qe=>Tn(qe.root).flatMap(Ke=>{const ft=le.terminals[Ke];return ft?[{terminalId:Ke,cwd:ft.cwd,label:`${Ie.title} / ${qe.title} / ${ft.title}`}]:[]})));N(Ie=>Ie===S?{...Ie,targets:De}:Ie)}catch{N(k=>k===S?{...k,targetError:"Could not retrieve open tabs."}:k)}}function Ca(S,k){const B=gt(S);if(!B.loaded){$t.current.set(S,{generation:B.generation,terminal:k}),Gi({kind:"terminal",agentId:S,terminalId:k.id});return}if(Hn(S,n)){ot({type:"terminal.created",terminal:k});return}rl(S,{type:"terminal.created",terminal:k}),r?.(S)}async function ka(S,k){const B=Zs(S);try{await B.closeTerminal(k)}catch(se){if(!(se instanceof Un)||se.status!==404)throw se}$t.current.get(S)?.terminal.id===k&&$t.current.delete(S);const X=mt.current;if(X?.agentId===S&&X.terminalId===k&&(mt.current=null,St.current=null,It.current=null,rn(se=>se+1)),fc(B.createWebSocketUrl(k)),Hu(k),hc(k),Hn(S,n)){ot({type:"terminal.closed",terminalId:k});return}rl(S,{type:"terminal.closed",terminalId:k})}return u.jsx(rk,{sensors:En,onDragStart:wn,onDragEnd:vi,onDragCancel:si,children:u.jsxs("main",{className:"terminal-shell","data-collapsed":P,"data-sidebar-open":W,onDragOver:Fc,onDrop:Wc,children:[u.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>U(!1)}),u.jsxs("aside",{className:"workspace-sidebar",children:[u.jsxs("header",{className:"workspace-brand",children:[u.jsxs("div",{className:"workspace-brand-lockup",children:[li?u.jsx(IC,{height:20}):u.jsx(BC,{size:24}),l&&li?u.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),u.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":P?"Expand sidebar":"Collapse sidebar",title:P?"Expand sidebar":"Collapse sidebar",onClick:()=>F(S=>!S),children:P?">":"<"}),u.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>U(!1),children:"x"})]}),u.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Or==="files"?"files":"servers"}`,children:[li?u.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[u.jsx("button",{type:"button",role:"tab","aria-selected":V==="servers",onClick:()=>{O("servers")},children:"Workspaces"}),u.jsx("button",{type:"button",role:"tab","aria-selected":V==="files",onClick:()=>{O("files")},children:"Files"})]}):null,Or==="servers"&&li?u.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:u.jsx(D1,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:ve,onServerLabelsChange:Rr,onManageAccounts:Br,onServerInfo:S=>{Yc(S)},renderServerChildren:Oo})}):null,li?null:u.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:u.jsx(D1,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:ve,onServerLabelsChange:Rr,compact:!0})}),Or==="files"?u.jsx(HL,{api:p,activeTerminalId:ae,activeTerminalCwd:Ce?.cwd??null,workspaceRootPath:ae?null:ht?.defaultCwd??null,onOpenFile:Ii},`${n??"local"}:${ht?.id??"no-workspace"}`):null]}),u.jsxs("div",{className:"workspace-sidebar-footer",children:[li?u.jsx("span",{children:Al}):null,u.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[u.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>fe(!0),children:[u.jsx(RC,{name:"settings"}),Q.hasUpdates?u.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),li?u.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{Zn()},children:u.jsx(RC,{name:"logout"})}):null]})]})]}),G?u.jsx(jL,{api:g,onClose:()=>fe(!1),updateAvailable:Q.hasUpdates,onNotificationAssetsChanged:()=>{Rn()},onAgentRemoved:Dr}):null,I?u.jsx(HA,{provider:I.provider,serverLabel:I.label,api:oe,onClose:()=>re(null),onLoginStarted:S=>Ca(I.agentId,S),onLoginFinished:S=>ka(I.agentId,S)}):null,_e&&u.jsx(ZA,{api:Y,label:_e.label,main:_e.agentId===null,getRuntimeStatus:Bi,favorites:$.filter(S=>S.serverId===(_e.agentId??Vt)),targetStatus:_e.targetError??(!gt(_e.agentId).loaded&&!_e.targets?"Loading open tabs...":null),targets:_e.targets??gt(_e.agentId).state.workspaces.flatMap(S=>S.tabs.flatMap(k=>Tn(k.root).flatMap(B=>{const X=gt(_e.agentId).state.terminals[B];return X?[{terminalId:B,cwd:X.cwd,label:`${S.title} / ${k.title} / ${X.title}`}]:[]}))),onClose:()=>N(null),onFavorite:S=>{N(null),ai(S)},onTarget:S=>{Gi({kind:"terminal",agentId:_e.agentId,terminalId:S.terminalId}),N(null)}},_e.agentId??Vt),be?u.jsx(hz,{dialog:be,activePaneCwd:Ce?.cwd??null,activeWorkspaceCwd:ht?.defaultCwd??null,onChange:Nr,onManualCwdChange:ko,onBrowse:Vi,onCancel:bs,onSubmit:()=>{Eo()}}):null,u.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":xn?"true":void 0,children:[u.jsx(nP,{tabs:ht?.tabs??[],activeTabId:ht?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Ft,favoriteTabIds:new Set($.filter(S=>S.serverId===(n??Vt)).map(S=>S.tabId)),detachedTerminals:Mi,onSelectTab:S=>ot({type:"tab.selected",tabId:S}),onCreateTab:()=>{ba()},onToggleWorkspaces:()=>U(S=>!S),onCloseTerminals:S=>$s(S),onReattachTerminal:S=>Fs(S),onDeleteTerminal:S=>{xl(S)},onSplitVertical:()=>{Ar("vertical")},onSplitHorizontal:()=>{Ar("horizontal")},onRenameTab:(S,k)=>{rr(S,k)},onToggleFavorite:Mr,onOpenFavorites:()=>te(!0),activePaneAvailable:!!ae}),ee?u.jsx(OP,{favorites:$,unavailableFavoriteIds:new Set($.filter(S=>S.serverId!==Vt&&!Oe.some(k=>Hn(k,S.serverId))).map(js)),busy:ie,error:j,getRuntimeStatus:Bi,onClose:()=>{te(!1),R(null)},onOpen:ai,onRemove:S=>{ys(k=>k.filter(B=>js(B)!==js(S)))},onReorder:(S,k)=>{const B=js(S),X=js(k);ys(se=>{const le=se.findIndex(ft=>js(ft)===B),De=se.findIndex(ft=>js(ft)===X);if(le<0||De<0||le===De)return se;const Ie=se.slice(),[qe]=Ie.splice(le,1),Ke=Ie.findIndex(ft=>js(ft)===X);return qe&&Ke>=0&&Ie.splice(Ke,0,qe),Ie})}}):null,xn?u.jsx(yz,{targets:Xe,activeLeafKey:fn,terminals:x.terminals,editors:T,onSelect:Sa}):null,M?u.jsxs("div",{className:"workspace-error",role:"alert",children:[u.jsx("span",{children:M}),u.jsxs("div",{className:"workspace-error-actions",children:[u.jsx("button",{type:"button",onClick:_a,children:"Retry"}),n!==null&&r?u.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,u.jsxs("section",{className:"workspace-body","aria-busy":A,children:[A?u.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!A&&!kt?u.jsx(vz,{onCreate:()=>{ba()}}):null,Pe.map(S=>{const k=Hn(S,n);return u.jsx(az,{agentId:S,serverName:He[al(S)]??(S===null?"Local":"Server"),active:k,activeServerApi:k?p:void 0,visitedTabKeys:de,refreshCwdOnEnter:k,draggingTab:k?an:null,mobileSplitFocus:Ye,mobileFocusedLeafByTabKey:Me,onSelect:B=>{k&&Ks(B)},onClose:B=>{k&&Lr(B)},onCloseEditor:B=>{k&&Yi(B)},onResize:(B,X)=>{k&&ot({type:"pane.resized",path:B,ratio:X})},onExit:(B,X)=>{k?No({type:"terminal.exited",terminalId:B,exitCode:X}):rl(S,{type:"terminal.exited",terminalId:B,exitCode:X})},onSnapshot:(B,X)=>{const se={type:"terminal.updated",terminal:B,notifyCompletion:X?.notifyCompletion===!0};k?No(se):rl(S,se)},...f?{onAuthClose:B=>f({...B,source:B?.source??"terminal-ws-1008",activeAgentId:S})}:{}},Mf(S))})]}),ri?u.jsx(bz,{label:ri.label,count:ri.terminalIds.length,warning:ue,onCancel:()=>{Re(null),Tr(null)},onHide:()=>{Ei(ri.terminalIds,ri.workspaceId)&&Tr(null)},onDelete:()=>{const S=ri.terminalIds;Re(null),Tr(null),Pi(S)}}):null,u.jsx(VP,{toast:Ki,onActivate:Nl,onDismiss:()=>pn(null)}),u.jsx(HP,{uploads:Ai,onDismiss:Fn,onDismissAll:Lo,onRetry:Rl,onCancel:ur})]})]})})}function az({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:l,draggingTab:d,mobileSplitFocus:f,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:C,onSnapshot:x,onAuthClose:T}){const A=v.useMemo(()=>ee=>y2(e,ee),[e]),M=v.useMemo(()=>()=>gt(e),[e]),W=v.useSyncExternalStore(A,M,M),U=v.useMemo(()=>Zs(e),[e]),P=r??U,F=W.state,V=F.workspaces.find(ee=>ee.id===F.activeWorkspaceId)??F.workspaces[0],O=V?.id??null,fe=(V?.tabs.find(ee=>ee.id===V.activeTabId)??V?.tabs[0])?.id??null;return!W.loaded||F.workspaces.length===0?null:u.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:F.workspaces.flatMap(ee=>ee.tabs.map(te=>{const $=n&&ee.id===O&&te.id===fe,Z=Zu(e,ee.id,te.id),ie=lp(te.root),J=f&&ie.length>1?N2(ie,te.activeTerminalId,g[Z]):null;return!$&&!o.has(Z)?null:u.jsx("div",{className:"workspace-tab-surface","data-active":$,"aria-hidden":!$,children:u.jsx(pb,{node:te.root,terminals:F.terminals,editors:W.editors,api:P,activeTerminalId:te.activeTerminalId,visible:$,refreshCwdOnEnter:$&&l,tabId:te.id,codeServerContext:{serverKey:al(e),serverName:t,tabName:te.title||F.terminals[te.activeTerminalId]?.title||"Terminal"},dropZoneActive:$&&d!==null,draggingTerminalId:$?d?.terminalId??null:null,mobileFocusLeafKey:J,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:C,onSnapshot:x,...T?{onAuthClose:T}:{}})},te.id)}))})}function oz(e){const t=cT(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":case"favorites.toggle":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=cz(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function lz(e,t,n){switch(n.type){case"pane.direction":return XP(e,t,n.direction);case"pane.index":return ZP(e,n.index);default:return null}}function cz(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function uz(e,t,n){if(e.length===0)return null;const r=e.findIndex(l=>l.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function lp(e){return e.type==="pane"?[{key:xc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:M2(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...lp(e.first),...lp(e.second)]}function Nb(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Nb(e.first),...Nb(e.second)]}function N2(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?xc(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function xc(e){return`terminal:${e}`}function M2(e){return`editor:${e}`}function dz(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 hz({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:l,onCancel:d,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(C=>C.kind==="directory"),b=e.submitStatus==="submitting";function _(C){r(x=>x&&{...x,...C})}function w(C){C&&(_({cwd:C,error:null}),l(C))}return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:u.jsxs("form",{className:"security-panel workspace-dialog",onClick:C=>C.stopPropagation(),onSubmit:C=>{C.preventDefault(),b||f()},children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),u.jsxs("section",{className:"workspace-dialog-body",children:[u.jsxs("label",{className:"workspace-dialog-field",children:[u.jsx("span",{children:"Name"}),u.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:C=>_({title:C.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),u.jsxs("label",{className:"workspace-dialog-field",children:[u.jsx("span",{children:"Default cwd"}),u.jsxs("div",{className:"workspace-dialog-path-row",children:[u.jsx("input",{value:e.cwd,disabled:b,onChange:C=>o(C.currentTarget.value),placeholder:"/home/user/project"}),u.jsx("button",{type:"button",onClick:()=>{l(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),u.jsxs("div",{className:"workspace-dialog-quick-actions",children:[u.jsx("button",{type:"button",onClick:()=>w(t),disabled:b||!t,children:"Use active pane"}),u.jsx("button",{type:"button",onClick:()=>w(n),disabled:b||!n,children:"Use current workspace"})]}),u.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[u.jsxs("div",{className:"workspace-dialog-browser-header",children:[u.jsx("span",{title:g,children:g||"No folder selected"}),u.jsx("button",{type:"button",onClick:()=>{l(pz(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?u.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?u.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?u.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(C=>u.jsxs("button",{type:"button","aria-label":`Choose folder ${C.name}`,disabled:b,onClick:()=>{l(fz(g,C.path))},children:[u.jsx("span",{children:C.name}),u.jsx("small",{children:C.path})]},C.path))}):null]}),e.error?u.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),u.jsxs("div",{className:"workspace-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),u.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function fz(e,t){return t?t.startsWith("/")?Nf(t):Nf(`${e||"/"}/${t}`):Nf(e)}function pz(e){const t=Nf(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Nf(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function mz(e){return e>99?"99+":String(e)}function gz(e){const t=[];return e.workingTerminalCount>0&&t.push(`${e.workingTerminalCount} ${e.workingTerminalCount===1?"pane is":"panes are"} working`),e.unreadCompletionCount>0&&t.push(`${e.unreadCompletionCount} unreviewed completion${e.unreadCompletionCount===1?"":"s"}`),t.join(" · ")}function vz({onCreate:e}){return u.jsxs("div",{className:"empty-workspace",children:[u.jsx("span",{children:"No terminal is open."}),u.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function _z({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:l=null,working:d=!1,unread:f=!1,children:g}){const{setNodeRef:p,isOver:b}=vp({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),_=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",d?"workspace-list-item--working":"",f?"workspace-list-item--unread":"",l?"workspace-list-item--drop-target":"",l?`workspace-list-item--drop-${l}`:""].filter(Boolean).join(" ");return u.jsx("div",{ref:p,className:_,"data-workspace-id":e,"data-drop-over":b?"true":void 0,children:g})}function bz({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:l}){return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),u.jsx("span",{children:e}),u.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?u.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:l,children:"Delete"})]})]})})}function yz({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[l,d]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],b=TC(p,n,r);function _(w){const C=(g+w+e.length)%e.length,x=e[C];x&&o(x)}return u.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[u.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>_(-1),children:"<"}),u.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":l,title:b,onClick:()=>d(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),u.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>_(1),children:">"}),l?u.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:u.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[u.jsxs("header",{children:[u.jsx("strong",{children:"Panes"}),u.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),u.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,C)=>{const x=TC(w,n,r),T=Sz(w,n,r),A=w.key===p.key;return u.jsxs("button",{type:"button","data-active":A,onClick:()=>{o(w),d(!1)},children:[u.jsx("span",{className:"mobile-pane-sheet-index",children:C+1}),u.jsxs("span",{className:"mobile-pane-sheet-copy",children:[u.jsx("strong",{children:x}),u.jsx("small",{children:T})]}),u.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function TC(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function Sz(e,t,n){if(e.type==="editor"){const l=n[e.editorId];return l?.path?`editor | ${l.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function wz(e){const[t,n]=v.useState(()=>xz(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function xz(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function Cz(){if(typeof window>"u")return null;const e=tM(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function kz(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:bp(t.focus)}function Lv(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Tn(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function Hn(e,t){return e===t}function js(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function EC(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o!==void 0&&js(n)===js(o)&&n.serverName===o.serverName&&n.workspaceName===o.workspaceName&&n.tabName===o.tabName&&n.cwd===o.cwd&&n.paneCount===o.paneCount&&n.providers.length===o.providers.length&&n.providers.every((l,d)=>l===o.providers[d])})}function Mf(e){return e??"__local__"}function Zu(e,t,n){return`${Mf(e)}:${t}:${n}`}class cp extends Error{constructor(){super(A2())}}function Tz(e){return e?{workspaceKey:`${CC}:${e}`}:{workspaceKey:CC}}function Ez(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(ok(n))throw new cp;const r=_p(n);return r?Mb(r):null}catch(n){if(n instanceof cp)throw n;return null}}function Mb(e){if(ok(e))throw new cp;const t=_p(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function lc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function Rz(e,t){const n=gt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function Dz(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${mo}. Re-open or delete hidden sessions before hiding more.`}function A2(){return`A saved terminal layout has more than ${mo} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function Nz(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function Mz(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function Az(e){return e.split("/").filter(Boolean).pop()??e}function Lz(){try{return localStorage.getItem(D2)==="true"}catch{return!1}}function jz(e){try{localStorage.setItem(D2,e?"true":"false")}catch{}}function al(e){return e??Vt}function jv(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function Oz(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function RC({name:e}){return u.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M4 7h9"}),u.jsx("path",{d:"M17 7h3"}),u.jsx("circle",{cx:"15",cy:"7",r:"2"}),u.jsx("path",{d:"M4 12h3"}),u.jsx("path",{d:"M11 12h9"}),u.jsx("circle",{cx:"9",cy:"12",r:"2"}),u.jsx("path",{d:"M4 17h9"}),u.jsx("path",{d:"M17 17h3"}),u.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M10 6H6v12h4"}),u.jsx("path",{d:"M13 8l4 4-4 4"}),u.jsx("path",{d:"M8 12h9"})]}):null]})}function na(e){return e instanceof Error?e.message:"Request failed"}function Bz({api:e,onDone:t}){const[n,r]=v.useState(null),[o,l]=v.useState(null),[d,f]=v.useState(""),[g,p]=v.useState(!1),[b,_]=v.useState(null),[w,C]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(A=>{T||(r(A.qrDataUrl),l(A.secret))}).catch(A=>{T||C(A instanceof Error?A.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function x(T){if(T.preventDefault(),!!o){p(!0),_(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(A){_(A instanceof Error?A.message:"Verification failed")}finally{p(!1)}}}return w?u.jsx("p",{className:"form-error",children:w}):!n||!o?u.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):u.jsxs("div",{className:"totp-setup",children:[u.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."}),u.jsx("div",{className:"totp-qr-container",children:u.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),u.jsxs("details",{className:"totp-secret-details",children:[u.jsx("summary",{children:"Can't scan? Enter manually"}),u.jsx("p",{className:"totp-secret-text",children:o})]}),u.jsxs("form",{className:"auth-form",onSubmit:x,children:[u.jsxs("label",{children:["Verification code",u.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:T=>f(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?u.jsx("p",{className:"form-error",children:b}):null,u.jsx("button",{type:"submit",disabled:g||d.length!==6,children:"Activate 2FA"})]})]})}function Iz(e){return{source:Ov(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Ov(e.terminalId)}:{},...e?.detail?{detail:Ov(e.detail)}:{}}}function Pz(e){return{invalidationSource:e.source}}function zz(e){Ni("auth.session_invalid.request",L2(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Gb("session-invalid-request").catch(()=>{}))}function Hz(e,t){Ni("auth.session_invalid.result",{...L2(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Gb("session-invalid-result").catch(()=>{}))}function L2(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 Ov(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function Uz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??up(),[e]),l=v.useMemo(()=>t??Zs(null),[t]),[d,f]=v.useState(null),[g,p]=v.useState(null),b=v.useRef(null),_=v.useRef(0),w=v.useRef("loading"),C=v.useCallback(()=>{_.current++,b.current=null},[]);v.useEffect(()=>C,[C]),v.useEffect(()=>{let U=!1;return o.getSession().then(P=>{U||(f(P),p(null))}).catch(P=>{U||(p(hl(P)),f(null))}),()=>{U=!0}},[o]);const x=Kz(d);v.useEffect(()=>{const U=w.current;Ni("auth.view",{view:x,previousView:U,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),U==="workspace"&&x!=="workspace"&&(cv(),Gb(`auth-left-workspace-${x}`).catch(()=>{})),w.current=x},[d,x]);async function T(){const U=await o.getSession();f(U),p(null)}async function A(){C(),cv(),Sv(),Nv(),Hx(),Ux(),p(null),f(null);try{await T()}catch(U){p(hl(U))}}const M=v.useCallback(U=>{const P=Iz(U);if(zz(P),b.current)return b.current;const F=_.current,V=(async()=>{p(null);try{const O=await o.getSession(Pz(P));if(F!==_.current)return;if(Hz(P,O.authenticated),f(O),O.authenticated){vP(),w4();return}Sv(),Nv(),Hx(),Ux()}catch(O){F===_.current&&p(hl(O))}finally{F===_.current&&(b.current=null)}})();return b.current=V,V},[o]);if(v.useEffect(()=>{if(x==="workspace")return gP(U=>{M({source:"activity-auth-check",detail:U})})},[x,M]),x==="workspace")return u.jsx(rz,{api:o,serverApi:l,activeAgentId:n,onSelectServer:r,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:U=>{M(U)},onLogout:async()=>{C(),cv(),Sv(),Nv();const U=await o.logout();f(U)}});const W={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return u.jsxs("main",{className:"auth-screen",children:[u.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[u.jsx("div",{className:"auth-grid"}),u.jsx("div",{className:"auth-glow"})]}),u.jsxs("section",{className:"auth-panel","aria-busy":x==="loading",children:[u.jsxs("header",{className:"auth-header",children:[u.jsxs("div",{className:"auth-brand",children:[u.jsx(BC,{size:26}),u.jsxs("div",{children:[u.jsx(IC,{height:17}),u.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),u.jsx("h1",{children:W[x]})]}),g?u.jsx("p",{className:"form-error",children:g}):null,x==="loading"?u.jsx("p",{className:"muted",children:"Checking session..."}):null,x==="loading"&&g?u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{A()},children:"Retry"}):null,x==="setup_password"?u.jsx($z,{api:o,onSession:U=>{f(U)}}):null,x==="setup_totp"?u.jsx(Bz,{api:o,onDone:()=>{T()}}):null,x==="login"?u.jsx(Fz,{api:o,session:d,onSession:f,onRefresh:T}):null,x==="reauth"?u.jsx(Wz,{api:o,session:d,onSession:f,onFullLogin:()=>f(U=>U&&{...U,deviceTrusted:!1})}):null]})]})}function $z({api:e,onSession:t}){const[n,r]=v.useState(""),[o,l]=v.useState(""),[d,f]=v.useState(!1),[g,p]=v.useState(null);async function b(_){_.preventDefault(),f(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(w){p(hl(w))}finally{f(!1)}}return u.jsxs("form",{className:"auth-form",onSubmit:b,children:[u.jsxs("label",{children:["Password",u.jsx("input",{autoFocus:!0,value:n,onChange:_=>r(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),u.jsxs("label",{children:["Confirm password",u.jsx("input",{value:o,onChange:_=>l(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?u.jsx("p",{className:"form-error",children:g}):null,u.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function Fz({api:e,session:t,onSession:n,onRefresh:r}){const[o,l]=v.useState(""),[d,f]=v.useState(""),[g,p]=v.useState(!1),[b,_]=v.useState(!1),[w,C]=v.useState(null),x=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function A(M){M.preventDefault(),_(!0),C(null);try{n(await e.login({password:o,...x?{otp:d}:{},rememberNetwork:g}))}catch(W){C(hl(W))}finally{_(!1)}}return u.jsxs("form",{className:"auth-form",onSubmit:A,children:[u.jsxs("label",{children:["Password",u.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:M=>l(M.currentTarget.value),required:!0})]}),x?u.jsxs("label",{children:["Authenticator code",u.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:M=>f(M.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:g,onChange:M=>p(M.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?u.jsx("p",{className:"form-error",children:w}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:b||o.length===0||x&&d.length!==6,children:"Unlock"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:b,children:"Refresh"})]})]})}function Wz({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[l,d]=v.useState(""),[f,g]=v.useState(!1),[p,b]=v.useState(!1),[_,w]=v.useState(!1),[C,x]=v.useState(!1),[T,A]=v.useState(null),M=zt.useCallback(async(U,P)=>{b(!0),A(null);try{n(await e.reauth({...U?{otp:U}:{},rememberNetwork:P}))}catch(F){A(hl(F))}finally{b(!1)}},[e,n]);v.useEffect(()=>{if(o){let U=!1;w(!0),x(!1),A(null);const P=window.setTimeout(()=>{U||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(F=>{U||n(F)}).catch(F=>{U||(A(hl(F)),x(!0))}).finally(()=>{window.clearTimeout(P),U||w(!1)}),()=>{U=!0,window.clearTimeout(P)}}},[e,o,n]);async function W(U){U.preventDefault(),await M(l,f)}return o&&_&&!C&&!T?u.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):u.jsxs("form",{className:"auth-form",onSubmit:W,children:[o&&C&&!T?u.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,u.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),u.jsxs("label",{children:["Authenticator code",u.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:l,onChange:U=>d(U.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:f,onChange:U=>g(U.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?u.jsx("p",{className:"form-error",children:T}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:p||l.length!==6,children:"Continue"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function Kz(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function hl(e){return e instanceof Error?e.message:"Request failed"}const DC="NTerminal",Ab="nterminal.activeAgentId";function qz(){const[e,t]=v.useState(()=>Vz()),n=v.useMemo(()=>up(),[]),r=v.useMemo(()=>Zs(e),[e]);v.useEffect(()=>{const l=()=>{const d=W6();document.title=d>0?`(${d}) ${DC}`:DC};return l(),F6(l)},[]);function o(l){Yz(l),t(l)}return u.jsx(Uz,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function Vz(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ab);return e&&e.trim()?e:null}catch{return null}}function Yz(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Ab,e);return}window.localStorage.removeItem(Ab)}catch{}}const NC=["gesturestart","gesturechange","gestureend"],Gz=[".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 Xz(e=window){if(!Qz(e))return()=>{};const t={passive:!1},n=e.document;function r(l){l.cancelable&&l.preventDefault()}function o(l){if(l.defaultPrevented)return;const d=l.touches;!d||d.length===0||(d.length>1||!Zz(l.target))&&r(l)}for(const l of NC)n.addEventListener(l,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const l of NC)n.removeEventListener(l,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function Zz(e){return e instanceof Element&&e.closest(Gz)!==null}function Qz(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}oM();K5();Xz();Ib();aD.createRoot(document.getElementById("root")).render(u.jsx(zt.StrictMode,{children:u.jsx(qz,{})}));export{zt as R,ZR as g,u as j};
|