nterminal 1.3.6 → 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 +2 -2
- package/dist/client/assets/MarkdownPreview-D3Oa7_1H.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-3aYVmqQz.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-Dd_o8KCL.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/notifications/agentCompletionMonitor.js +2 -1
- package/dist/server/notifications/agentCompletionMonitor.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/server/terminal/TerminalManager.js +4 -2
- package/dist/server/terminal/TerminalManager.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 +4 -3
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-B-LrTjTM.js +0 -1
- package/dist/client/assets/index-D3LN5iAH.js +0 -58
- package/dist/client/assets/index-W-zGfY1a.css +0 -1
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-B-LrTjTM.js","assets/index-Dd_o8KCL.js","assets/TranscriptMarkdownBody-3aYVmqQz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).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 s(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function XR(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rg={exports:{}},Du={};var Kw;function ZR(){if(Kw)return Du;Kw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,l){var u=null;if(l!==void 0&&(u=""+l),o.key!==void 0&&(u=""+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:s,key:u,ref:o!==void 0?o:null,props:l}}return Du.Fragment=t,Du.jsx=n,Du.jsxs=n,Du}var qw;function QR(){return qw||(qw=1,Rg.exports=ZR()),Rg.exports}var d=QR(),Dg={exports:{}},_t={};var Vw;function JR(){if(Vw)return _t;Vw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=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,M={};function A(N,V,pe){this.props=N,this.context=V,this.refs=M,this.updater=pe||x}A.prototype.isReactComponent={},A.prototype.setState=function(N,V){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,V,"setState")},A.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function F(){}F.prototype=A.prototype;function z(N,V,pe){this.props=N,this.context=V,this.refs=M,this.updater=pe||x}var P=z.prototype=new F;P.constructor=z,T(P,A.prototype),P.isPureReactComponent=!0;var W=Array.isArray;function $(){}var L={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function ge(N,V,pe){var Z=pe.ref;return{$$typeof:e,type:N,key:V,ref:Z!==void 0?Z:null,props:pe}}function ne(N,V){return ge(N.type,V,N.props)}function ie(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function G(N){var V={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(pe){return V[pe]})}var J=/\/+/g;function ae(N,V){return typeof N=="object"&&N!==null&&N.key!=null?G(""+N.key):V.toString(36)}function ee(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then($,$):(N.status="pending",N.then(function(V){N.status==="pending"&&(N.status="fulfilled",N.value=V)},function(V){N.status==="pending"&&(N.status="rejected",N.reason=V)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function O(N,V,pe,Z,Q){var le=typeof N;(le==="undefined"||le==="boolean")&&(N=null);var Te=!1;if(N===null)Te=!0;else switch(le){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(N.$$typeof){case e:case t:Te=!0;break;case b:return Te=N._init,O(Te(N._payload),V,pe,Z,Q)}}if(Te)return Q=Q(N),Te=Z===""?"."+ae(N,0):Z,W(Q)?(pe="",Te!=null&&(pe=Te.replace(J,"$&/")+"/"),O(Q,V,pe,"",function(Se){return Se})):Q!=null&&(ie(Q)&&(Q=ne(Q,pe+(Q.key==null||N&&N.key===Q.key?"":(""+Q.key).replace(J,"$&/")+"/")+Te)),V.push(Q)),1;Te=0;var je=Z===""?".":Z+":";if(W(N))for(var Fe=0;Fe<N.length;Fe++)Z=N[Fe],le=je+ae(Z,Fe),Te+=O(Z,V,pe,le,Q);else if(Fe=C(N),typeof Fe=="function")for(N=Fe.call(N),Fe=0;!(Z=N.next()).done;)Z=Z.value,le=je+ae(Z,Fe++),Te+=O(Z,V,pe,le,Q);else if(le==="object"){if(typeof N.then=="function")return O(ee(N),V,pe,Z,Q);throw V=String(N),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return Te}function R(N,V,pe){if(N==null)return N;var Z=[],Q=0;return O(N,Z,"","",function(le){return V.call(pe,le,Q++)}),Z}function I(N){if(N._status===-1){var V=N._result;V=V(),V.then(function(pe){(N._status===0||N._status===-1)&&(N._status=1,N._result=pe)},function(pe){(N._status===0||N._status===-1)&&(N._status=2,N._result=pe)}),N._status===-1&&(N._status=0,N._result=V)}if(N._status===1)return N._result.default;throw N._result}var se=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=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(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},_e={map:R,forEach:function(N,V,pe){R(N,function(){V.apply(this,arguments)},pe)},count:function(N){var V=0;return R(N,function(){V++}),V},toArray:function(N){return R(N,function(V){return V})||[]},only:function(N){if(!ie(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return _t.Activity=_,_t.Children=_e,_t.Component=A,_t.Fragment=n,_t.Profiler=o,_t.PureComponent=z,_t.StrictMode=s,_t.Suspense=g,_t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,_t.__COMPILER_RUNTIME={__proto__:null,c:function(N){return L.H.useMemoCache(N)}},_t.cache=function(N){return function(){return N.apply(null,arguments)}},_t.cacheSignal=function(){return null},_t.cloneElement=function(N,V,pe){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Z=T({},N.props),Q=N.key;if(V!=null)for(le in V.key!==void 0&&(Q=""+V.key),V)!X.call(V,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&V.ref===void 0||(Z[le]=V[le]);var le=arguments.length-2;if(le===1)Z.children=pe;else if(1<le){for(var Te=Array(le),je=0;je<le;je++)Te[je]=arguments[je+2];Z.children=Te}return ge(N.type,Q,Z)},_t.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:l,_context:N},N},_t.createElement=function(N,V,pe){var Z,Q={},le=null;if(V!=null)for(Z in V.key!==void 0&&(le=""+V.key),V)X.call(V,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(Q[Z]=V[Z]);var Te=arguments.length-2;if(Te===1)Q.children=pe;else if(1<Te){for(var je=Array(Te),Fe=0;Fe<Te;Fe++)je[Fe]=arguments[Fe+2];Q.children=je}if(N&&N.defaultProps)for(Z in Te=N.defaultProps,Te)Q[Z]===void 0&&(Q[Z]=Te[Z]);return ge(N,le,Q)},_t.createRef=function(){return{current:null}},_t.forwardRef=function(N){return{$$typeof:f,render:N}},_t.isValidElement=ie,_t.lazy=function(N){return{$$typeof:b,_payload:{_status:-1,_result:N},_init:I}},_t.memo=function(N,V){return{$$typeof:p,type:N,compare:V===void 0?null:V}},_t.startTransition=function(N){var V=L.T,pe={};L.T=pe;try{var Z=N(),Q=L.S;Q!==null&&Q(pe,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then($,se)}catch(le){se(le)}finally{V!==null&&pe.types!==null&&(V.types=pe.types),L.T=V}},_t.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},_t.use=function(N){return L.H.use(N)},_t.useActionState=function(N,V,pe){return L.H.useActionState(N,V,pe)},_t.useCallback=function(N,V){return L.H.useCallback(N,V)},_t.useContext=function(N){return L.H.useContext(N)},_t.useDebugValue=function(){},_t.useDeferredValue=function(N,V){return L.H.useDeferredValue(N,V)},_t.useEffect=function(N,V){return L.H.useEffect(N,V)},_t.useEffectEvent=function(N){return L.H.useEffectEvent(N)},_t.useId=function(){return L.H.useId()},_t.useImperativeHandle=function(N,V,pe){return L.H.useImperativeHandle(N,V,pe)},_t.useInsertionEffect=function(N,V){return L.H.useInsertionEffect(N,V)},_t.useLayoutEffect=function(N,V){return L.H.useLayoutEffect(N,V)},_t.useMemo=function(N,V){return L.H.useMemo(N,V)},_t.useOptimistic=function(N,V){return L.H.useOptimistic(N,V)},_t.useReducer=function(N,V,pe){return L.H.useReducer(N,V,pe)},_t.useRef=function(N){return L.H.useRef(N)},_t.useState=function(N){return L.H.useState(N)},_t.useSyncExternalStore=function(N,V,pe){return L.H.useSyncExternalStore(N,V,pe)},_t.useTransition=function(){return L.H.useTransition()},_t.version="19.2.6",_t}var Yw;function jb(){return Yw||(Yw=1,Dg.exports=JR()),Dg.exports}var v=jb();const zt=XR(v);var Ng={exports:{}},Nu={},Mg={exports:{}},Ag={};var Gw;function eD(){return Gw||(Gw=1,(function(e){function t(O,R){var I=O.length;O.push(R);e:for(;0<I;){var se=I-1>>>1,_e=O[se];if(0<o(_e,R))O[se]=R,O[I]=_e,I=se;else break e}}function n(O){return O.length===0?null:O[0]}function s(O){if(O.length===0)return null;var R=O[0],I=O.pop();if(I!==R){O[0]=I;e:for(var se=0,_e=O.length,N=_e>>>1;se<N;){var V=2*(se+1)-1,pe=O[V],Z=V+1,Q=O[Z];if(0>o(pe,I))Z<_e&&0>o(Q,pe)?(O[se]=Q,O[Z]=I,se=Z):(O[se]=pe,O[V]=I,se=V);else if(Z<_e&&0>o(Q,I))O[se]=Q,O[Z]=I,se=Z;else break e}}return R}function o(O,R){var I=O.sortIndex-R.sortIndex;return I!==0?I:O.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 u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var g=[],p=[],b=1,_=null,w=3,C=!1,x=!1,T=!1,M=!1,A=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function P(O){for(var R=n(p);R!==null;){if(R.callback===null)s(p);else if(R.startTime<=O)s(p),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(p)}}function W(O){if(T=!1,P(O),!x)if(n(g)!==null)x=!0,$||($=!0,G());else{var R=n(p);R!==null&&ee(W,R.startTime-O)}}var $=!1,L=-1,X=5,ge=-1;function ne(){return M?!0:!(e.unstable_now()-ge<X)}function ie(){if(M=!1,$){var O=e.unstable_now();ge=O;var R=!0;try{e:{x=!1,T&&(T=!1,F(L),L=-1),C=!0;var I=w;try{t:{for(P(O),_=n(g);_!==null&&!(_.expirationTime>O&&ne());){var se=_.callback;if(typeof se=="function"){_.callback=null,w=_.priorityLevel;var _e=se(_.expirationTime<=O);if(O=e.unstable_now(),typeof _e=="function"){_.callback=_e,P(O),R=!0;break t}_===n(g)&&s(g),P(O)}else s(g);_=n(g)}if(_!==null)R=!0;else{var N=n(p);N!==null&&ee(W,N.startTime-O),R=!1}}break e}finally{_=null,w=I,C=!1}R=void 0}}finally{R?G():$=!1}}}var G;if(typeof z=="function")G=function(){z(ie)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,ae=J.port2;J.port1.onmessage=ie,G=function(){ae.postMessage(null)}}else G=function(){A(ie,0)};function ee(O,R){L=A(function(){O(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(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(O){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var I=w;w=R;try{return O()}finally{w=I}},e.unstable_requestPaint=function(){M=!0},e.unstable_runWithPriority=function(O,R){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var I=w;w=O;try{return R()}finally{w=I}},e.unstable_scheduleCallback=function(O,R,I){var se=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?se+I:se):I=se,O){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,O={id:b++,callback:R,priorityLevel:O,startTime:I,expirationTime:_e,sortIndex:-1},I>se?(O.sortIndex=I,t(p,O),n(g)===null&&O===n(p)&&(T?(F(L),L=-1):T=!0,ee(W,I-se))):(O.sortIndex=_e,t(g,O),x||C||(x=!0,$||($=!0,G()))),O},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(O){var R=w;return function(){var I=w;w=R;try{return O.apply(this,arguments)}finally{w=I}}}})(Ag)),Ag}var Xw;function tD(){return Xw||(Xw=1,Mg.exports=eD()),Mg.exports}var Lg={exports:{}},Ri={};var Zw;function nD(){if(Zw)return Ri;Zw=1;var e=jb();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 s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function 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 u=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=s,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=u.T,b=s.p;try{if(u.T=null,s.p=2,g)return g()}finally{u.T=p,s.p=b,s.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,s.d.C(g,p))},Ri.prefetchDNS=function(g){typeof g=="string"&&s.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"?s.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:_,integrity:w,fetchPriority:C}):b==="script"&&s.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);s.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&&s.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);s.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);s.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 s.d.m(g)},Ri.requestFormReset=function(g){s.d.r(g)},Ri.unstable_batchedUpdates=function(g,p){return g(p)},Ri.useFormState=function(g,p,b){return u.H.useFormState(g,p,b)},Ri.useFormStatus=function(){return u.H.useHostTransitionStatus()},Ri.version="19.2.6",Ri}var Qw;function MC(){if(Qw)return Lg.exports;Qw=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=nD(),Lg.exports}var Jw;function iD(){if(Jw)return Nu;Jw=1;var e=tD(),t=jb(),n=MC();function s(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function u(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function f(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function g(i){if(l(i)!==i)throw Error(s(188))}function p(i){var r=i.alternate;if(!r){if(r=l(i),r===null)throw Error(s(188));return r!==i?null:i}for(var a=i,c=r;;){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),r;m=m.sibling}throw Error(s(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(s(189))}}if(a.alternate!==c)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:r}function b(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=b(i),r!==null)return r;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"),M=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),z=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ge=Symbol.for("react.activity"),ne=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function G(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var J=Symbol.for("react.client.reference");function ae(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===J?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case A:return"Profiler";case M:return"StrictMode";case W:return"Suspense";case $:return"SuspenseList";case ge:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case z:return i.displayName||"Context";case F:return(i._context.displayName||"Context")+".Consumer";case P:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return r=i.displayName||null,r!==null?r:ae(i.type)||"Memo";case X:r=i._payload,i=i._init;try{return ae(i(r))}catch{}}return null}var ee=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},se=[],_e=-1;function N(i){return{current:i}}function V(i){0>_e||(i.current=se[_e],se[_e]=null,_e--)}function pe(i,r){_e++,se[_e]=i.current,i.current=r}var Z=N(null),Q=N(null),le=N(null),Te=N(null);function je(i,r){switch(pe(le,r),pe(Q,i),pe(Z,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?pw(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=pw(r),i=mw(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(Z),pe(Z,i)}function Fe(){V(Z),V(Q),V(le)}function Se(i){i.memoizedState!==null&&pe(Te,i);var r=Z.current,a=mw(r,i.type);r!==a&&(pe(Q,i),pe(Z,a))}function ze(i){Q.current===i&&(V(Z),V(Q)),Te.current===i&&(V(Te),ku._currentValue=I)}var Oe,j;function ve(i){if(Oe===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);Oe=r&&r[1]||"",j=-1<a.stack.indexOf(`
|
|
3
|
-
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+Oe+i+j}var Ae=!1;function Ie(i,r){if(!i||Ae)return"";Ae=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){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 H=y.split(`
|
|
5
|
-
`),he=D.split(`
|
|
6
|
-
`);for(h=c=0;c<H.length&&!H[c].includes("DetermineComponentFrameRoot");)c++;for(;h<he.length&&!he[h].includes("DetermineComponentFrameRoot");)h++;if(c===H.length||h===he.length)for(c=H.length-1,h=he.length-1;1<=c&&0<=h&&H[c]!==he[h];)h--;for(;1<=c&&0<=h;c--,h--)if(H[c]!==he[h]){if(c!==1||h!==1)do if(c--,h--,0>h||H[c]!==he[h]){var we=`
|
|
7
|
-
`+H[c].replace(" at new "," at ");return i.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",i.displayName)),we}while(1<=c&&0<=h);break}}}finally{Ae=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?ve(a):""}function U(i,r){switch(i.tag){case 26:case 27:case 5:return ve(i.type);case 16:return ve("Lazy");case 13:return i.child!==r&&r!==null?ve("Suspense Fallback"):ve("Suspense");case 19:return ve("SuspenseList");case 0:case 15:return Ie(i.type,!1);case 11:return Ie(i.type.render,!1);case 1:return Ie(i.type,!0);case 31:return ve("Activity");default:return""}}function de(i){try{var r="",a=null;do r+=U(i,a),a=i,i=i.return;while(i);return r}catch(c){return`
|
|
8
|
-
Error generating stack: `+c.message+`
|
|
9
|
-
`+c.stack}}var ke=Object.prototype.hasOwnProperty,Me=e.unstable_scheduleCallback,Le=e.unstable_cancelCallback,be=e.unstable_shouldYield,$e=e.unstable_requestPaint,We=e.unstable_now,He=e.unstable_getCurrentPriorityLevel,vt=e.unstable_ImmediatePriority,wt=e.unstable_UserBlockingPriority,lt=e.unstable_NormalPriority,Nt=e.unstable_LowPriority,Yt=e.unstable_IdlePriority,rt=e.log,jn=e.unstable_setDisableYieldValue,Sn=null,ut=null;function Lt(i){if(typeof rt=="function"&&jn(i),ut&&typeof ut.setStrictMode=="function")try{ut.setStrictMode(Sn,i)}catch{}}var Ct=Math.clz32?Math.clz32:fe,gi=Math.log,ki=Math.LN2;function fe(i){return i>>>=0,i===0?32:31-(gi(i)/ki|0)|0}var Ze=256,at=262144,pt=4194304;function yt(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function It(i,r,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=yt(c):(y&=D,y!==0?h=yt(y):a||(a=D&~i,a!==0&&(h=yt(a))))):(D=c&~m,D!==0?h=yt(D):y!==0?h=yt(y):a||(a=c&~i,a!==0&&(h=yt(a)))),h===0?0:r!==0&&r!==h&&(r&m)===0&&(m=h&-h,a=r&-r,m>=a||m===32&&(a&4194048)!==0)?r:h}function $t(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function dn(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=pt;return pt<<=1,(pt&62914560)===0&&(pt=4194304),i}function sn(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function hn(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function an(i,r,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,H=i.expirationTimes,he=i.hiddenUpdates;for(a=y&~a;0<a;){var we=31-Ct(a),Ee=1<<we;D[we]=0,H[we]=-1;var me=he[we];if(me!==null)for(he[we]=null,we=0;we<me.length;we++){var ye=me[we];ye!==null&&(ye.lane&=-536870913)}a&=~Ee}c!==0&&ln(i,c,0),m!==0&&h===0&&i.tag!==0&&(i.suspendedLanes|=m&~(y&~r))}function ln(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var c=31-Ct(r);i.entangledLanes|=r,i.entanglements[c]=i.entanglements[c]|1073741824|a&261930}function En(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var c=31-Ct(a),h=1<<c;h&r|i[c]&r&&(i[c]|=r),a&=~h}}function wn(i,r){var a=r&-r;return a=(a&42)!==0?1:vi(a),(a&(i.suspendedLanes|r))!==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 ri(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function dt(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:Pw(i.type))}function kt(i,r){var a=R.p;try{return R.p=i,r()}finally{R.p=a}}var oe=Math.random().toString(36).slice(2),xe="__reactFiber$"+oe,Ye="__reactProps$"+oe,Xe="__reactContainer$"+oe,et="__reactEvents$"+oe,fn="__reactListeners$"+oe,xn="__reactHandles$"+oe,Mi="__reactResources$"+oe,Ft="__reactMarker$"+oe;function Ai(i){delete i[xe],delete i[Ye],delete i[et],delete i[fn],delete i[xn]}function vr(i){var r=i[xe];if(r)return r;for(var a=i.parentNode;a;){if(r=a[Xe]||a[xe]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=ww(i);i!==null;){if(a=i[xe])return a;i=ww(i)}return r}i=a,a=i.parentNode}return null}function $n(i){if(i=i[xe]||i[Xe]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function Li(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function Ki(i){var r=i[Mi];return r||(r=i[Mi]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function pn(i){i[Ft]=!0}var si=new Set,Ts={};function ji(i,r){cn(i,r),cn(i+"Capture",r)}function cn(i,r){for(Ts[i]=r,i=0;i<r.length;i++)si.add(r[i])}var _r=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 Es(i){return ke.call(ga,i)?!0:ke.call(Co,i)?!1:_r.test(i)?ga[i]=!0:(Co[i]=!0,!1)}function Xn(i,r,a){if(Es(r))if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var c=r.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+a)}}function zr(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function qi(i,r,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(r,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 Rs(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function va(i,r,a){var c=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var h=c.get,m=c.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,m.call(this,y)}}),Object.defineProperty(i,r,{enumerable:c.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Ds(i){if(!i._valueTracker){var r=Rs(i)?"checked":"value";i._valueTracker=va(i,r,""+i[r])}}function _a(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return i&&(c=Rs(i)?i.checked?"true":"false":i.value),i=c,i!==a?(r.setValue(i),!0):!1}function br(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 On(i){return i.replace(ko,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function _i(i,r,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"),r!=null?y==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Rn(r)):i.value!==""+Rn(r)&&(i.value=""+Rn(r)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),r!=null?To(i,y,Rn(r)):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 is(i,r,a,c,h,m,y,D){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||a!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){Ds(i);return}a=a!=null?""+Rn(a):"",r=r!=null?""+Rn(r):a,D||r===i.value||(i.value=r),i.defaultValue=r}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),Ds(i)}function To(i,r,a){r==="number"&&br(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Vi(i,r,a,c){if(i=i.options,r){r={};for(var h=0;h<a.length;h++)r["$"+a[h]]=!0;for(a=0;a<i.length;a++)h=r.hasOwnProperty("$"+i[a].value),i[a].selected!==h&&(i[a].selected=h),h&&c&&(i[a].defaultSelected=!0)}else{for(a=""+Rn(a),r=null,h=0;h<i.length;h++){if(i[h].value===a){i[h].selected=!0,c&&(i[h].defaultSelected=!0);return}r!==null||i[h].disabled||(r=i[h])}r!==null&&(r.selected=!0)}}function Eo(i,r,a){if(r!=null&&(r=""+Rn(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+Rn(a):""}function Ns(i,r,a,c){if(r==null){if(c!=null){if(a!=null)throw Error(s(92));if(ee(c)){if(1<c.length)throw Error(s(93));c=c[0]}a=c}a==null&&(a=""),r=a}a=Rn(r),i.defaultValue=a,c=i.textContent,c===a&&c!==""&&c!==null&&(i.value=c),Ds(i)}function Hr(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var rs=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,r,a){var c=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?c?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":c?i.setProperty(r,a):typeof a!="number"||a===0||rs.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function Do(i,r,a){if(r!=null&&typeof r!="object")throw Error(s(62));if(i=i.style,a!=null){for(var c in a)!a.hasOwnProperty(c)||r!=null&&r.hasOwnProperty(c)||(c.indexOf("--")===0?i.setProperty(c,""):c==="float"?i.cssFloat="":i[c]="");for(var h in r)c=r[h],r.hasOwnProperty(h)&&a[h]!==c&&Ro(i,h,c)}else for(var m in r)r.hasOwnProperty(m)&&Ro(i,m,r[m])}function rr(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var $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 Ur=null;function yr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ti=null,Ms=null;function ai(i){var r=$n(i);if(r&&(i=r.stateNode)){var a=i[Ye]||null;e:switch(i=r.stateNode,r.type){case"input":if(_i(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+On(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var c=a[r];if(c!==i&&c.form===i.form){var h=c[Ye]||null;if(!h)throw Error(s(90));_i(c,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(r=0;r<a.length;r++)c=a[r],c.form===i.form&&_a(c)}break e;case"textarea":Eo(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&Vi(i,!!a.multiple,r,!1)}}}var ya=!1;function As(i,r,a){if(ya)return i(r,a);ya=!0;try{var c=i(r);return c}finally{if(ya=!1,(Ti!==null||Ms!==null)&&(kh(),Ti&&(r=Ti,i=Ms,Ms=Ti=null,ai(r),i)))for(r=0;r<i.length;r++)ai(i[r])}}function Ii(i,r){var a=i.stateNode;if(a===null)return null;var c=a[Ye]||null;if(c===null)return null;a=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(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(s(231,r,typeof a));return a}var Yi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ls=!1;if(Yi)try{var $r={};Object.defineProperty($r,"passive",{get:function(){Ls=!0}}),window.addEventListener("test",$r,$r),window.removeEventListener("test",$r,$r)}catch{Ls=!1}var Ei=null,Pi=null,js=null;function xl(){if(js)return js;var i,r=Pi,a=r.length,c,h="value"in Ei?Ei.value:Ei.textContent,m=h.length;for(i=0;i<a&&r[i]===h[i];i++);var y=a-i;for(c=1;c<=y&&r[a-c]===h[m-c];c++);return js=h.slice(i,1<c?1-c:void 0)}function ss(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Fr(){return!0}function as(){return!1}function Zn(i){function r(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)?Fr:as,this.isPropagationStopped=as,this}return _(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Fr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Fr)},persist:function(){},isPersistent:Fr}),r}var oi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Sr=Zn(oi),ot=_({},oi,{view:0,detail:0}),No=Zn(ot),os,Wr,Kr,Sa=_({},ot,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:us,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!==Kr&&(Kr&&i.type==="mousemove"?(os=i.screenX-Kr.screenX,Wr=i.screenY-Kr.screenY):Wr=os=0,Kr=i),os)},movementY:function(i){return"movementY"in i?i.movementY:Wr}}),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}),ls=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"},cs={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 r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Fn[i])?!!r[i]:!1}function us(){return Lo}var Rl=_({},ot,{key:function(i){if(i.key){var r=bi[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=ss(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?cs[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:us,charCode:function(i){return i.type==="keypress"?ss(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ss(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:us}),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),Os=[9,13,27,32],Oo=Yi&&"CompositionEvent"in window,Bs=null;Yi&&"documentMode"in document&&(Bs=document.documentMode);var Yc=Yi&&"TextEvent"in window&&!Bs,Ca=Yi&&(!Oo||Bs&&8<Bs&&11>=Bs),ka=" ",S=!1;function k(i,r){switch(i){case"keyup":return Os.indexOf(r.keyCode)!==-1;case"keydown":return r.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 Y=!1;function re(i,r){switch(i){case"compositionend":return B(r);case"keypress":return r.which!==32?null:(S=!0,ka);case"textInput":return i=r.data,i===ka&&S?null:i;default:return null}}function ce(i,r){if(Y)return i==="compositionend"||!Oo&&k(i,r)?(i=xl(),js=Pi=Ei=null,Y=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Ca&&r.locale!=="ko"?null:r.data;default:return null}}var Re={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 Be(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Re[i.type]:r==="textarea"}function qe(i,r,a,c){Ti?Ms?Ms.push(c):Ms=[c]:Ti=c,r=Ah(r,"onChange"),0<r.length&&(a=new Sr("onChange","change",null,a,c),i.push({event:a,listeners:r}))}var Ke=null,ht=null;function Wt(i){lw(i,0)}function jt(i){var r=Li(i);if(_a(r))return i}function Dn(i,r){if(i==="change")return r}var Is=!1;if(Yi){var Ps;if(Yi){var Ta="oninput"in document;if(!Ta){var qr=document.createElement("div");qr.setAttribute("oninput","return;"),Ta=typeof qr.oninput=="function"}Ps=Ta}else Ps=!1;Is=Ps&&(!document.documentMode||9<document.documentMode)}function Ud(){Ke&&(Ke.detachEvent("onpropertychange",Gc),ht=Ke=null)}function Gc(i){if(i.propertyName==="value"&&jt(ht)){var r=[];qe(r,ht,i,yr(i)),As(Wt,r)}}function ds(i,r,a){i==="focusin"?(Ud(),Ke=r,ht=a,Ke.attachEvent("onpropertychange",Gc)):i==="focusout"&&Ud()}function Pp(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return jt(ht)}function zp(i,r){if(i==="click")return jt(r)}function $d(i,r){if(i==="input"||i==="change")return jt(r)}function Hp(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var zi=typeof Object.is=="function"?Object.is:Hp;function sr(i,r){if(zi(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),c=Object.keys(r);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var h=a[c];if(!ke.call(r,h)||!zi(i[h],r[h]))return!1}return!0}function Fd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Wd(i,r){var a=Fd(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=r&&c>=r)return{node:a,offset:r-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,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Kd(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Xc(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=br(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=br(i.document)}return r}function wr(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Up=Yi&&"documentMode"in document&&11>=document.documentMode,Ea=null,Bo=null,Io=null,Ll=!1;function E(i,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ll||Ea==null||Ea!==br(c)||(c=Ea,"selectionStart"in c&&wr(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&&sr(Io,c)||(Io=c,c=Ah(Bo,"onSelect"),0<c.length&&(r=new Sr("onSelect","select",null,r,a),i.push({event:r,listeners:c}),r.target=Ea)))}function K(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var Pe={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 Pe.animationend.animation,delete Pe.animationiteration.animation,delete Pe.animationstart.animation),"TransitionEvent"in window||delete Pe.transitionend.transition);function ft(i){if(Je[i])return Je[i];if(!Pe[i])return i;var r=Pe[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in tt)return Je[i]=r[a];return i}var Tt=ft("animationend"),Et=ft("animationiteration"),st=ft("animationstart"),un=ft("transitionrun"),Jt=ft("transitionstart"),Xt=ft("transitioncancel"),Vr=ft("transitionend"),Po=new Map,xr="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(" ");xr.push("scrollEnd");function Xi(i,r){Po.set(i,r),ji(r,[i])}var zo=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Cr=[],jl=0,$p=0;function qd(){for(var i=jl,r=$p=jl=0;r<i;){var a=Cr[r];Cr[r++]=null;var c=Cr[r];Cr[r++]=null;var h=Cr[r];Cr[r++]=null;var m=Cr[r];if(Cr[r++]=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&&Fy(a,h,m)}}function Vd(i,r,a,c){Cr[jl++]=i,Cr[jl++]=r,Cr[jl++]=a,Cr[jl++]=c,$p|=c,i.lanes|=c,i=i.alternate,i!==null&&(i.lanes|=c)}function Fp(i,r,a,c){return Vd(i,r,a,c),Yd(i)}function Ho(i,r){return Vd(i,null,null,r),Yd(i)}function Fy(i,r,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&&r!==null&&(h=31-Ct(a),i=m.hiddenUpdates,c=i[h],c===null?i[h]=[r]:c.push(r),r.lane=a|536870912),m):null}function Yd(i){if(50<_u)throw _u=0,Qm=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var Ol={};function L2(i,r,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=r,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 ar(i,r,a,c){return new L2(i,r,a,c)}function Wp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function zs(i,r){var a=i.alternate;return a===null?(a=ar(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function Wy(i,r){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,r=a.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function Gd(i,r,a,c,h,m){var y=0;if(c=i,typeof i=="function")Wp(i)&&(y=1);else if(typeof i=="string")y=PR(i,a,Z.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ge:return i=ar(31,a,r,h),i.elementType=ge,i.lanes=m,i;case T:return Uo(a.children,h,m,r);case M:y=8,h|=24;break;case A:return i=ar(12,a,r,h|2),i.elementType=A,i.lanes=m,i;case W:return i=ar(13,a,r,h),i.elementType=W,i.lanes=m,i;case $:return i=ar(19,a,r,h),i.elementType=$,i.lanes=m,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case z:y=10;break e;case F:y=9;break e;case P:y=11;break e;case L:y=14;break e;case X:y=16,c=null;break e}y=29,a=Error(s(130,i===null?"null":typeof i,"")),c=null}return r=ar(y,a,r,h),r.elementType=i,r.type=c,r.lanes=m,r}function Uo(i,r,a,c){return i=ar(7,i,c,r),i.lanes=a,i}function Kp(i,r,a){return i=ar(6,i,null,r),i.lanes=a,i}function Ky(i){var r=ar(18,null,null,0);return r.stateNode=i,r}function qp(i,r,a){return r=ar(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var qy=new WeakMap;function kr(i,r){if(typeof i=="object"&&i!==null){var a=qy.get(i);return a!==void 0?a:(r={value:i,source:r,stack:de(r)},qy.set(i,r),r)}return{value:i,source:r,stack:de(r)}}var Bl=[],Il=0,Xd=null,Zc=0,Tr=[],Er=0,Ra=null,hs=1,fs="";function Hs(i,r){Bl[Il++]=Zc,Bl[Il++]=Xd,Xd=i,Zc=r}function Vy(i,r,a){Tr[Er++]=hs,Tr[Er++]=fs,Tr[Er++]=Ra,Ra=i;var c=hs;i=fs;var h=32-Ct(c)-1;c&=~(1<<h),a+=1;var m=32-Ct(r)+h;if(30<m){var y=h-h%5;m=(c&(1<<y)-1).toString(32),c>>=y,h-=y,hs=1<<32-Ct(r)+h|a<<h|c,fs=m+i}else hs=1<<m|a<<h|c,fs=i}function Vp(i){i.return!==null&&(Hs(i,1),Vy(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=Tr[--Er],Tr[Er]=null,fs=Tr[--Er],Tr[Er]=null,hs=Tr[--Er],Tr[Er]=null}function Yy(i,r){Tr[Er++]=hs,Tr[Er++]=fs,Tr[Er++]=Ra,hs=r.id,fs=r.overflow,Ra=i}var yi=null,mn=null,Pt=!1,Da=null,Rr=!1,Gp=Error(s(519));function Na(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qc(kr(r,i)),Gp}function Gy(i){var r=i.stateNode,a=i.type,c=i.memoizedProps;switch(r[xe]=i,r[Ye]=c,a){case"dialog":At("cancel",r),At("close",r);break;case"iframe":case"object":case"embed":At("load",r);break;case"video":case"audio":for(a=0;a<yu.length;a++)At(yu[a],r);break;case"source":At("error",r);break;case"img":case"image":case"link":At("error",r),At("load",r);break;case"details":At("toggle",r);break;case"input":At("invalid",r),is(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":At("invalid",r);break;case"textarea":At("invalid",r),Ns(r,c.value,c.defaultValue,c.children)}a=c.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||c.suppressHydrationWarning===!0||hw(r.textContent,a)?(c.popover!=null&&(At("beforetoggle",r),At("toggle",r)),c.onScroll!=null&&At("scroll",r),c.onScrollEnd!=null&&At("scrollend",r),c.onClick!=null&&(r.onclick=Bi),r=!0):r=!1,r||Na(i,!0)}function Xy(i){for(yi=i.return;yi;)switch(yi.tag){case 5:case 31:case 13:Rr=!1;return;case 27:case 3:Rr=!0;return;default:yi=yi.return}}function Pl(i){if(i!==yi)return!1;if(!Pt)return Xy(i),Pt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||fg(i.type,i.memoizedProps)),a=!a),a&&mn&&Na(i),Xy(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));mn=Sw(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));mn=Sw(i)}else r===27?(r=mn,Wa(i.type)?(i=_g,_g=null,mn=i):mn=r):mn=yi?Nr(i.stateNode.nextSibling):null;return!0}function $o(){mn=yi=null,Pt=!1}function Xp(){var i=Da;return i!==null&&(er===null?er=i:er.push.apply(er,i),Da=null),i}function Qc(i){Da===null?Da=[i]:Da.push(i)}var Zp=N(null),Fo=null,Us=null;function Ma(i,r,a){pe(Zp,r._currentValue),r._currentValue=a}function $s(i){i._currentValue=Zp.current,V(Zp)}function Qp(i,r,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),i===a)break;i=i.return}}function Jp(i,r,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 H=0;H<r.length;H++)if(D.context===r[H]){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(s(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,r,a,c){i=null;for(var h=r,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(s(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===Te.current){if(y=h.alternate,y===null)throw Error(s(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(i!==null?i.push(ku):i=[ku])}h=h.return}i!==null&&Jp(r,i,a,c),r.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,Us=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Si(i){return Zy(Fo,i)}function Qd(i,r){return Fo===null&&Wo(i),Zy(i,r)}function Zy(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Us===null){if(i===null)throw Error(s(308));Us=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Us=Us.next=r;return a}var j2=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(a,c){i.push(c)}};this.abort=function(){r.aborted=!0,i.forEach(function(a){return a()})}},O2=e.unstable_scheduleCallback,B2=e.unstable_NormalPriority,Wn={$$typeof:z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function em(){return{controller:new j2,data:new Map,refCount:0}}function Jc(i){i.refCount--,i.refCount===0&&O2(B2,function(){i.controller.abort()})}var eu=null,tm=0,Hl=0,Ul=null;function I2(i,r){if(eu===null){var a=eu=[];tm=0,Hl=rg(),Ul={status:"pending",value:void 0,then:function(c){a.push(c)}}}return tm++,r.then(Qy,Qy),r}function Qy(){if(--tm===0&&eu!==null){Ul!==null&&(Ul.status="fulfilled");var i=eu;eu=null,Hl=0,Ul=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function P2(i,r){var a=[],c={status:"pending",value:null,reason:null,then:function(h){a.push(h)}};return i.then(function(){c.status="fulfilled",c.value=r;for(var h=0;h<a.length;h++)(0,a[h])(r)},function(h){for(c.status="rejected",c.reason=h,h=0;h<a.length;h++)(0,a[h])(void 0)}),c}var Jy=O.S;O.S=function(i,r){B0=We(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&I2(i,r),Jy!==null&&Jy(i,r)};var Ko=N(null);function nm(){var i=Ko.current;return i!==null?i:on.pooledCache}function Jd(i,r){r===null?pe(Ko,Ko.current):pe(Ko,r.pool)}function eS(){var i=nm();return i===null?null:{parent:Wn._currentValue,pool:i}}var $l=Error(s(460)),im=Error(s(474)),eh=Error(s(542)),th={then:function(){}};function tS(i){return i=i.status,i==="fulfilled"||i==="rejected"}function nS(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(Bi,Bi),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,rS(i),i;default:if(typeof r.status=="string")r.then(Bi,Bi);else{if(i=on,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=r,i.status="pending",i.then(function(c){if(r.status==="pending"){var h=r;h.status="fulfilled",h.value=c}},function(c){if(r.status==="pending"){var h=r;h.status="rejected",h.reason=c}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,rS(i),i}throw Vo=r,$l}}function qo(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Vo=a,$l):a}}var Vo=null;function iS(){if(Vo===null)throw Error(s(459));var i=Vo;return Vo=null,i}function rS(i){if(i===$l||i===eh)throw Error(s(483))}var Fl=null,tu=0;function nh(i){var r=tu;return tu+=1,Fl===null&&(Fl=[]),nS(Fl,i,r)}function nu(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function ih(i,r){throw r.$$typeof===w?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function sS(i){function r(te,q){if(i){var ue=te.deletions;ue===null?(te.deletions=[q],te.flags|=16):ue.push(q)}}function a(te,q){if(!i)return null;for(;q!==null;)r(te,q),q=q.sibling;return null}function c(te){for(var q=new Map;te!==null;)te.key!==null?q.set(te.key,te):q.set(te.index,te),te=te.sibling;return q}function h(te,q){return te=zs(te,q),te.index=0,te.sibling=null,te}function m(te,q,ue){return te.index=ue,i?(ue=te.alternate,ue!==null?(ue=ue.index,ue<q?(te.flags|=67108866,q):ue):(te.flags|=67108866,q)):(te.flags|=1048576,q)}function y(te){return i&&te.alternate===null&&(te.flags|=67108866),te}function D(te,q,ue,Ce){return q===null||q.tag!==6?(q=Kp(ue,te.mode,Ce),q.return=te,q):(q=h(q,ue),q.return=te,q)}function H(te,q,ue,Ce){var nt=ue.type;return nt===T?we(te,q,ue.props.children,Ce,ue.key):q!==null&&(q.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===X&&qo(nt)===q.type)?(q=h(q,ue.props),nu(q,ue),q.return=te,q):(q=Gd(ue.type,ue.key,ue.props,null,te.mode,Ce),nu(q,ue),q.return=te,q)}function he(te,q,ue,Ce){return q===null||q.tag!==4||q.stateNode.containerInfo!==ue.containerInfo||q.stateNode.implementation!==ue.implementation?(q=qp(ue,te.mode,Ce),q.return=te,q):(q=h(q,ue.children||[]),q.return=te,q)}function we(te,q,ue,Ce,nt){return q===null||q.tag!==7?(q=Uo(ue,te.mode,Ce,nt),q.return=te,q):(q=h(q,ue),q.return=te,q)}function Ee(te,q,ue){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=Kp(""+q,te.mode,ue),q.return=te,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case C:return ue=Gd(q.type,q.key,q.props,null,te.mode,ue),nu(ue,q),ue.return=te,ue;case x:return q=qp(q,te.mode,ue),q.return=te,q;case X:return q=qo(q),Ee(te,q,ue)}if(ee(q)||G(q))return q=Uo(q,te.mode,ue,null),q.return=te,q;if(typeof q.then=="function")return Ee(te,nh(q),ue);if(q.$$typeof===z)return Ee(te,Qd(te,q),ue);ih(te,q)}return null}function me(te,q,ue,Ce){var nt=q!==null?q.key:null;if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return nt!==null?null:D(te,q,""+ue,Ce);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case C:return ue.key===nt?H(te,q,ue,Ce):null;case x:return ue.key===nt?he(te,q,ue,Ce):null;case X:return ue=qo(ue),me(te,q,ue,Ce)}if(ee(ue)||G(ue))return nt!==null?null:we(te,q,ue,Ce,null);if(typeof ue.then=="function")return me(te,q,nh(ue),Ce);if(ue.$$typeof===z)return me(te,q,Qd(te,ue),Ce);ih(te,ue)}return null}function ye(te,q,ue,Ce,nt){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return te=te.get(ue)||null,D(q,te,""+Ce,nt);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case C:return te=te.get(Ce.key===null?ue:Ce.key)||null,H(q,te,Ce,nt);case x:return te=te.get(Ce.key===null?ue:Ce.key)||null,he(q,te,Ce,nt);case X:return Ce=qo(Ce),ye(te,q,ue,Ce,nt)}if(ee(Ce)||G(Ce))return te=te.get(ue)||null,we(q,te,Ce,nt,null);if(typeof Ce.then=="function")return ye(te,q,ue,nh(Ce),nt);if(Ce.$$typeof===z)return ye(te,q,ue,Qd(q,Ce),nt);ih(q,Ce)}return null}function Ge(te,q,ue,Ce){for(var nt=null,Ht=null,Qe=q,xt=q=0,Bt=null;Qe!==null&&xt<ue.length;xt++){Qe.index>xt?(Bt=Qe,Qe=null):Bt=Qe.sibling;var Ut=me(te,Qe,ue[xt],Ce);if(Ut===null){Qe===null&&(Qe=Bt);break}i&&Qe&&Ut.alternate===null&&r(te,Qe),q=m(Ut,q,xt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut,Qe=Bt}if(xt===ue.length)return a(te,Qe),Pt&&Hs(te,xt),nt;if(Qe===null){for(;xt<ue.length;xt++)Qe=Ee(te,ue[xt],Ce),Qe!==null&&(q=m(Qe,q,xt),Ht===null?nt=Qe:Ht.sibling=Qe,Ht=Qe);return Pt&&Hs(te,xt),nt}for(Qe=c(Qe);xt<ue.length;xt++)Bt=ye(Qe,te,xt,ue[xt],Ce),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 r(te,Ga)}),Pt&&Hs(te,xt),nt}function ct(te,q,ue,Ce){if(ue==null)throw Error(s(151));for(var nt=null,Ht=null,Qe=q,xt=q=0,Bt=null,Ut=ue.next();Qe!==null&&!Ut.done;xt++,Ut=ue.next()){Qe.index>xt?(Bt=Qe,Qe=null):Bt=Qe.sibling;var Ga=me(te,Qe,Ut.value,Ce);if(Ga===null){Qe===null&&(Qe=Bt);break}i&&Qe&&Ga.alternate===null&&r(te,Qe),q=m(Ga,q,xt),Ht===null?nt=Ga:Ht.sibling=Ga,Ht=Ga,Qe=Bt}if(Ut.done)return a(te,Qe),Pt&&Hs(te,xt),nt;if(Qe===null){for(;!Ut.done;xt++,Ut=ue.next())Ut=Ee(te,Ut.value,Ce),Ut!==null&&(q=m(Ut,q,xt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut);return Pt&&Hs(te,xt),nt}for(Qe=c(Qe);!Ut.done;xt++,Ut=ue.next())Ut=ye(Qe,te,xt,Ut.value,Ce),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(GR){return r(te,GR)}),Pt&&Hs(te,xt),nt}function nn(te,q,ue,Ce){if(typeof ue=="object"&&ue!==null&&ue.type===T&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case C:e:{for(var nt=ue.key;q!==null;){if(q.key===nt){if(nt=ue.type,nt===T){if(q.tag===7){a(te,q.sibling),Ce=h(q,ue.props.children),Ce.return=te,te=Ce;break e}}else if(q.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===X&&qo(nt)===q.type){a(te,q.sibling),Ce=h(q,ue.props),nu(Ce,ue),Ce.return=te,te=Ce;break e}a(te,q);break}else r(te,q);q=q.sibling}ue.type===T?(Ce=Uo(ue.props.children,te.mode,Ce,ue.key),Ce.return=te,te=Ce):(Ce=Gd(ue.type,ue.key,ue.props,null,te.mode,Ce),nu(Ce,ue),Ce.return=te,te=Ce)}return y(te);case x:e:{for(nt=ue.key;q!==null;){if(q.key===nt)if(q.tag===4&&q.stateNode.containerInfo===ue.containerInfo&&q.stateNode.implementation===ue.implementation){a(te,q.sibling),Ce=h(q,ue.children||[]),Ce.return=te,te=Ce;break e}else{a(te,q);break}else r(te,q);q=q.sibling}Ce=qp(ue,te.mode,Ce),Ce.return=te,te=Ce}return y(te);case X:return ue=qo(ue),nn(te,q,ue,Ce)}if(ee(ue))return Ge(te,q,ue,Ce);if(G(ue)){if(nt=G(ue),typeof nt!="function")throw Error(s(150));return ue=nt.call(ue),ct(te,q,ue,Ce)}if(typeof ue.then=="function")return nn(te,q,nh(ue),Ce);if(ue.$$typeof===z)return nn(te,q,Qd(te,ue),Ce);ih(te,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint"?(ue=""+ue,q!==null&&q.tag===6?(a(te,q.sibling),Ce=h(q,ue),Ce.return=te,te=Ce):(a(te,q),Ce=Kp(ue,te.mode,Ce),Ce.return=te,te=Ce),y(te)):a(te,q)}return function(te,q,ue,Ce){try{tu=0;var nt=nn(te,q,ue,Ce);return Fl=null,nt}catch(Qe){if(Qe===$l||Qe===eh)throw Qe;var Ht=ar(29,Qe,null,te.mode);return Ht.lanes=Ce,Ht.return=te,Ht}}}var Yo=sS(!0),aS=sS(!1),Aa=!1;function rm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function sm(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function La(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ja(i,r,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Kt&2)!==0){var h=c.pending;return h===null?r.next=r:(r.next=h.next,h.next=r),c.pending=r,r=Yd(i),Fy(i,null,a),r}return Vd(i,c,r,a),Yd(i)}function iu(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,En(i,a)}}function am(i,r){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=r:m=m.next=r}else h=m=r;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=r:i.next=r,a.lastBaseUpdate=r}var om=!1;function ru(){if(om){var i=Ul;if(i!==null)throw i}}function su(i,r,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 H=D,he=H.next;H.next=null,y===null?m=he:y.next=he,y=H;var we=i.alternate;we!==null&&(we=we.updateQueue,D=we.lastBaseUpdate,D!==y&&(D===null?we.firstBaseUpdate=he:D.next=he,we.lastBaseUpdate=H))}if(m!==null){var Ee=h.baseState;y=0,we=he=H=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),we!==null&&(we=we.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Ge=i,ct=D;me=r;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},we===null?(he=we=ye,H=Ee):we=we.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);we===null&&(H=Ee),h.baseState=H,h.firstBaseUpdate=he,h.lastBaseUpdate=we,m===null&&(h.shared.lanes=0),za|=y,i.lanes=y,i.memoizedState=Ee}}function oS(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function lS(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)oS(a[i],r)}var Wl=N(null),rh=N(0);function cS(i,r){i=Zs,pe(rh,i),pe(Wl,r),Zs=i|r.baseLanes}function lm(){pe(rh,Zs),pe(Wl,Wl.current)}function cm(){Zs=rh.current,V(Wl),V(rh)}var or=N(null),Dr=null;function Oa(i){var r=i.alternate;pe(Bn,Bn.current&1),pe(or,i),Dr===null&&(r===null||Wl.current!==null||r.memoizedState!==null)&&(Dr=i)}function um(i){pe(Bn,Bn.current),pe(or,i),Dr===null&&(Dr=i)}function uS(i){i.tag===22?(pe(Bn,Bn.current),pe(or,i),Dr===null&&(Dr=i)):Ba()}function Ba(){pe(Bn,Bn.current),pe(or,or.current)}function lr(i){V(or),Dr===i&&(Dr=null),V(Bn)}var Bn=N(0);function sh(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||gg(a)||vg(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Fs=0,St=null,en=null,Kn=null,ah=!1,Kl=!1,Go=!1,oh=0,au=0,ql=null,z2=0;function Nn(){throw Error(s(321))}function dm(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!zi(i[a],r[a]))return!1;return!0}function hm(i,r,a,c,h,m){return Fs=m,St=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,O.H=i===null||i.memoizedState===null?VS:Em,Go=!1,m=a(c,h),Go=!1,Kl&&(m=hS(r,a,c,h)),dS(i),m}function dS(i){O.H=cu;var r=en!==null&&en.next!==null;if(Fs=0,Kn=en=St=null,ah=!1,au=0,ql=null,r)throw Error(s(300));i===null||qn||(i=i.dependencies,i!==null&&Zd(i)&&(qn=!0))}function hS(i,r,a,c){St=i;var h=0;do{if(Kl&&(ql=null),au=0,Kl=!1,25<=h)throw Error(s(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)}O.H=YS,m=r(a,c)}while(Kl);return m}function H2(){var i=O.H,r=i.useState()[0];return r=typeof r.then=="function"?ou(r):r,i=i.useState()[0],(en!==null?en.memoizedState:null)!==i&&(St.flags|=1024),r}function fm(){var i=oh!==0;return oh=0,i}function pm(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function mm(i){if(ah){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}ah=!1}Fs=0,Kn=en=St=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?St.memoizedState=Kn=i:Kn=Kn.next=i,Kn}function In(){if(en===null){var i=St.alternate;i=i!==null?i.memoizedState:null}else i=en.next;var r=Kn===null?St.memoizedState:Kn.next;if(r!==null)Kn=r,en=i;else{if(i===null)throw St.alternate===null?Error(s(467)):Error(s(310));en=i,i={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},Kn===null?St.memoizedState=Kn=i:Kn=Kn.next=i}return Kn}function lh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ou(i){var r=au;return au+=1,ql===null&&(ql=[]),i=nS(ql,i,r),r=St,(Kn===null?r.memoizedState:Kn.next)===null&&(r=r.alternate,O.H=r===null||r.memoizedState===null?VS:Em),i}function ch(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return ou(i);if(i.$$typeof===z)return Si(i)}throw Error(s(438,String(i)))}function gm(i){var r=null,a=St.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var c=St.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(r={data:c.data.map(function(h){return h.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=lh(),St.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(i),c=0;c<i;c++)a[c]=ne;return r.index++,a}function Ws(i,r){return typeof r=="function"?r(i):r}function uh(i){var r=In();return vm(r,en,i)}function vm(i,r,a){var c=i.queue;if(c===null)throw Error(s(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}r.baseQueue=h=m,c.pending=null}if(m=i.baseState,h===null)i.memoizedState=m;else{r=h.next;var D=y=null,H=null,he=r,we=!1;do{var Ee=he.lane&-536870913;if(Ee!==he.lane?(Ot&Ee)===Ee:(Fs&Ee)===Ee){var me=he.revertLane;if(me===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),Ee===Hl&&(we=!0);else if((Fs&me)===me){he=he.next,me===Hl&&(we=!0);continue}else Ee={lane:0,revertLane:he.revertLane,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null},H===null?(D=H=Ee,y=m):H=H.next=Ee,St.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},H===null?(D=H=me,y=m):H=H.next=me,St.lanes|=Ee,za|=Ee;he=he.next}while(he!==null&&he!==r);if(H===null?y=m:H.next=D,!zi(m,i.memoizedState)&&(qn=!0,we&&(a=Ul,a!==null)))throw a;i.memoizedState=m,i.baseState=y,i.baseQueue=H,c.lastRenderedState=m}return h===null&&(c.lanes=0),[i.memoizedState,c.dispatch]}function _m(i){var r=In(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var c=a.dispatch,h=a.pending,m=r.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,r.memoizedState)||(qn=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),a.lastRenderedState=m}return[m,c]}function fS(i,r,a){var c=St,h=In(),m=Pt;if(m){if(a===void 0)throw Error(s(407));a=a()}else a=r();var y=!zi((en||h).memoizedState,a);if(y&&(h.memoizedState=a,qn=!0),h=h.queue,Sm(gS.bind(null,c,h,i),[i]),h.getSnapshot!==r||y||Kn!==null&&Kn.memoizedState.tag&1){if(c.flags|=2048,Vl(9,{destroy:void 0},mS.bind(null,c,h,a,r),null),on===null)throw Error(s(349));m||(Fs&127)!==0||pS(c,r,a)}return a}function pS(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=St.updateQueue,r===null?(r=lh(),St.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function mS(i,r,a,c){r.value=a,r.getSnapshot=c,vS(r)&&_S(i)}function gS(i,r,a){return a(function(){vS(r)&&_S(i)})}function vS(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!zi(i,a)}catch{return!0}}function _S(i){var r=Ho(i,2);r!==null&&tr(r,i,2)}function bm(i){var r=Hi();if(typeof i=="function"){var a=i;if(i=a(),Go){Lt(!0);try{a()}finally{Lt(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ws,lastRenderedState:i},r}function bS(i,r,a,c){return i.baseState=a,vm(i,en,typeof c=="function"?c:Ws)}function U2(i,r,a,c,h){if(fh(i))throw Error(s(485));if(i=r.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)}};O.T!==null?a(!0):m.isTransition=!1,c(m),a=r.pending,a===null?(m.next=r.pending=m,yS(r,m)):(m.next=a.next,r.pending=a.next=m)}}function yS(i,r){var a=r.action,c=r.payload,h=i.state;if(r.isTransition){var m=O.T,y={};O.T=y;try{var D=a(h,c),H=O.S;H!==null&&H(y,D),SS(i,r,D)}catch(he){ym(i,r,he)}finally{m!==null&&y.types!==null&&(m.types=y.types),O.T=m}}else try{m=a(h,c),SS(i,r,m)}catch(he){ym(i,r,he)}}function SS(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(c){wS(i,r,c)},function(c){return ym(i,r,c)}):wS(i,r,a)}function wS(i,r,a){r.status="fulfilled",r.value=a,xS(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,yS(i,a)))}function ym(i,r,a){var c=i.pending;if(i.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=a,xS(r),r=r.next;while(r!==c)}i.action=null}function xS(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function CS(i,r){return r}function kS(i,r){if(Pt){var a=on.formState;if(a!==null){e:{var c=St;if(Pt){if(mn){t:{for(var h=mn,m=Rr;h.nodeType!==8;){if(!m){h=null;break t}if(h=Nr(h.nextSibling),h===null){h=null;break t}}m=h.data,h=m==="F!"||m==="F"?h:null}if(h){mn=Nr(h.nextSibling),c=h.data==="F!";break e}}Na(c)}c=!1}c&&(r=a[0])}}return a=Hi(),a.memoizedState=a.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:CS,lastRenderedState:r},a.queue=c,a=WS.bind(null,St,c),c.dispatch=a,c=bm(!1),m=Tm.bind(null,St,!1,c.queue),c=Hi(),h={state:r,dispatch:null,action:i,pending:null},c.queue=h,a=U2.bind(null,St,h,m,a),h.dispatch=a,c.memoizedState=i,[r,a,!1]}function TS(i){var r=In();return ES(r,en,i)}function ES(i,r,a){if(r=vm(i,r,CS)[0],i=uh(Ws)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=ou(r)}catch(y){throw y===$l?eh:y}else c=r;r=In();var h=r.queue,m=h.dispatch;return a!==r.memoizedState&&(St.flags|=2048,Vl(9,{destroy:void 0},$2.bind(null,h,a),null)),[c,m,i]}function $2(i,r){i.action=r}function RS(i){var r=In(),a=en;if(a!==null)return ES(r,a,i);In(),r=r.memoizedState,a=In();var c=a.queue.dispatch;return a.memoizedState=i,[r,c,!1]}function Vl(i,r,a,c){return i={tag:i,create:a,deps:c,inst:r,next:null},r=St.updateQueue,r===null&&(r=lh(),St.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,r.lastEffect=i),i}function DS(){return In().memoizedState}function dh(i,r,a,c){var h=Hi();St.flags|=i,h.memoizedState=Vl(1|r,{destroy:void 0},a,c===void 0?null:c)}function hh(i,r,a,c){var h=In();c=c===void 0?null:c;var m=h.memoizedState.inst;en!==null&&c!==null&&dm(c,en.memoizedState.deps)?h.memoizedState=Vl(r,m,a,c):(St.flags|=i,h.memoizedState=Vl(1|r,m,a,c))}function NS(i,r){dh(8390656,8,i,r)}function Sm(i,r){hh(2048,8,i,r)}function F2(i){St.flags|=4;var r=St.updateQueue;if(r===null)r=lh(),St.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function MS(i){var r=In().memoizedState;return F2({ref:r,nextImpl:i}),function(){if((Kt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function AS(i,r){return hh(4,2,i,r)}function LS(i,r){return hh(4,4,i,r)}function jS(i,r){if(typeof r=="function"){i=i();var a=r(i);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function OS(i,r,a){a=a!=null?a.concat([i]):null,hh(4,4,jS.bind(null,r,i),a)}function wm(){}function BS(i,r){var a=In();r=r===void 0?null:r;var c=a.memoizedState;return r!==null&&dm(r,c[1])?c[0]:(a.memoizedState=[i,r],i)}function IS(i,r){var a=In();r=r===void 0?null:r;var c=a.memoizedState;if(r!==null&&dm(r,c[1]))return c[0];if(c=i(),Go){Lt(!0);try{i()}finally{Lt(!1)}}return a.memoizedState=[c,r],c}function xm(i,r,a){return a===void 0||(Fs&1073741824)!==0&&(Ot&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=P0(),St.lanes|=i,za|=i,a)}function PS(i,r,a,c){return zi(a,r)?a:Wl.current!==null?(i=xm(i,a,c),zi(i,r)||(qn=!0),i):(Fs&42)===0||(Fs&1073741824)!==0&&(Ot&261930)===0?(qn=!0,i.memoizedState=a):(i=P0(),St.lanes|=i,za|=i,r)}function zS(i,r,a,c,h){var m=R.p;R.p=m!==0&&8>m?m:8;var y=O.T,D={};O.T=D,Tm(i,!1,r,a);try{var H=h(),he=O.S;if(he!==null&&he(D,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var we=P2(H,c);lu(i,r,we,dr(i))}else lu(i,r,c,dr(i))}catch(Ee){lu(i,r,{then:function(){},status:"rejected",reason:Ee},dr())}finally{R.p=m,y!==null&&D.types!==null&&(y.types=D.types),O.T=y}}function W2(){}function Cm(i,r,a,c){if(i.tag!==5)throw Error(s(476));var h=HS(i).queue;zS(i,h,r,I,a===null?W2:function(){return US(i),a(c)})}function HS(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ws,lastRenderedState:I},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ws,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function US(i){var r=HS(i);r.next===null&&(r=i.alternate.memoizedState),lu(i,r.next.queue,{},dr())}function km(){return Si(ku)}function $S(){return In().memoizedState}function FS(){return In().memoizedState}function K2(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=dr();i=La(a);var c=ja(r,i,a);c!==null&&(tr(c,r,a),iu(c,r,a)),r={cache:em()},i.payload=r;return}r=r.return}}function q2(i,r,a){var c=dr();a={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fh(i)?KS(r,a):(a=Fp(i,r,a,c),a!==null&&(tr(a,i,c),qS(a,r,c)))}function WS(i,r,a){var c=dr();lu(i,r,a,c)}function lu(i,r,a,c){var h={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(fh(i))KS(r,h);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var y=r.lastRenderedState,D=m(y,a);if(h.hasEagerState=!0,h.eagerState=D,zi(D,y))return Vd(i,r,h,0),on===null&&qd(),!1}catch{}if(a=Fp(i,r,h,c),a!==null)return tr(a,i,c),qS(a,r,c),!0}return!1}function Tm(i,r,a,c){if(c={lane:2,revertLane:rg(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},fh(i)){if(r)throw Error(s(479))}else r=Fp(i,a,c,2),r!==null&&tr(r,i,2)}function fh(i){var r=i.alternate;return i===St||r!==null&&r===St}function KS(i,r){Kl=ah=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function qS(i,r,a){if((a&4194048)!==0){var c=r.lanes;c&=i.pendingLanes,a|=c,r.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 VS={readContext:Si,use:ch,useCallback:function(i,r){return Hi().memoizedState=[i,r===void 0?null:r],i},useContext:Si,useEffect:NS,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,dh(4194308,4,jS.bind(null,r,i),a)},useLayoutEffect:function(i,r){return dh(4194308,4,i,r)},useInsertionEffect:function(i,r){dh(4,2,i,r)},useMemo:function(i,r){var a=Hi();r=r===void 0?null:r;var c=i();if(Go){Lt(!0);try{i()}finally{Lt(!1)}}return a.memoizedState=[c,r],c},useReducer:function(i,r,a){var c=Hi();if(a!==void 0){var h=a(r);if(Go){Lt(!0);try{a(r)}finally{Lt(!1)}}}else h=r;return c.memoizedState=c.baseState=h,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:h},c.queue=i,i=i.dispatch=q2.bind(null,St,i),[c.memoizedState,i]},useRef:function(i){var r=Hi();return i={current:i},r.memoizedState=i},useState:function(i){i=bm(i);var r=i.queue,a=WS.bind(null,St,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:wm,useDeferredValue:function(i,r){var a=Hi();return xm(a,i,r)},useTransition:function(){var i=bm(!1);return i=zS.bind(null,St,i.queue,!0,!1),Hi().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var c=St,h=Hi();if(Pt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),on===null)throw Error(s(349));(Ot&127)!==0||pS(c,r,a)}h.memoizedState=a;var m={value:a,getSnapshot:r};return h.queue=m,NS(gS.bind(null,c,m,i),[i]),c.flags|=2048,Vl(9,{destroy:void 0},mS.bind(null,c,m,a,r),null),a},useId:function(){var i=Hi(),r=on.identifierPrefix;if(Pt){var a=fs,c=hs;a=(c&~(1<<32-Ct(c)-1)).toString(32)+a,r="_"+r+"R_"+a,a=oh++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=z2++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:km,useFormState:kS,useActionState:kS,useOptimistic:function(i){var r=Hi();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Tm.bind(null,St,!0,a),a.dispatch=r,[i,r]},useMemoCache:gm,useCacheRefresh:function(){return Hi().memoizedState=K2.bind(null,St)},useEffectEvent:function(i){var r=Hi(),a={impl:i};return r.memoizedState=a,function(){if((Kt&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Em={readContext:Si,use:ch,useCallback:BS,useContext:Si,useEffect:Sm,useImperativeHandle:OS,useInsertionEffect:AS,useLayoutEffect:LS,useMemo:IS,useReducer:uh,useRef:DS,useState:function(){return uh(Ws)},useDebugValue:wm,useDeferredValue:function(i,r){var a=In();return PS(a,en.memoizedState,i,r)},useTransition:function(){var i=uh(Ws)[0],r=In().memoizedState;return[typeof i=="boolean"?i:ou(i),r]},useSyncExternalStore:fS,useId:$S,useHostTransitionStatus:km,useFormState:TS,useActionState:TS,useOptimistic:function(i,r){var a=In();return bS(a,en,i,r)},useMemoCache:gm,useCacheRefresh:FS};Em.useEffectEvent=MS;var YS={readContext:Si,use:ch,useCallback:BS,useContext:Si,useEffect:Sm,useImperativeHandle:OS,useInsertionEffect:AS,useLayoutEffect:LS,useMemo:IS,useReducer:_m,useRef:DS,useState:function(){return _m(Ws)},useDebugValue:wm,useDeferredValue:function(i,r){var a=In();return en===null?xm(a,i,r):PS(a,en.memoizedState,i,r)},useTransition:function(){var i=_m(Ws)[0],r=In().memoizedState;return[typeof i=="boolean"?i:ou(i),r]},useSyncExternalStore:fS,useId:$S,useHostTransitionStatus:km,useFormState:RS,useActionState:RS,useOptimistic:function(i,r){var a=In();return en!==null?bS(a,en,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:gm,useCacheRefresh:FS};YS.useEffectEvent=MS;function Rm(i,r,a,c){r=i.memoizedState,a=a(c,r),a=a==null?r:_({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Dm={enqueueSetState:function(i,r,a){i=i._reactInternals;var c=dr(),h=La(c);h.payload=r,a!=null&&(h.callback=a),r=ja(i,h,c),r!==null&&(tr(r,i,c),iu(r,i,c))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var c=dr(),h=La(c);h.tag=1,h.payload=r,a!=null&&(h.callback=a),r=ja(i,h,c),r!==null&&(tr(r,i,c),iu(r,i,c))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=dr(),c=La(a);c.tag=2,r!=null&&(c.callback=r),r=ja(i,c,a),r!==null&&(tr(r,i,a),iu(r,i,a))}};function GS(i,r,a,c,h,m,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,m,y):r.prototype&&r.prototype.isPureReactComponent?!sr(a,c)||!sr(h,m):!0}function XS(i,r,a,c){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,c),r.state!==i&&Dm.enqueueReplaceState(r,r.state,null)}function Xo(i,r){var a=r;if("ref"in r){a={};for(var c in r)c!=="ref"&&(a[c]=r[c])}if(i=i.defaultProps){a===r&&(a=_({},a));for(var h in i)a[h]===void 0&&(a[h]=i[h])}return a}function ZS(i){zo(i)}function QS(i){console.error(i)}function JS(i){zo(i)}function ph(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function e0(i,r,a){try{var c=i.onCaughtError;c(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function Nm(i,r,a){return a=La(a),a.tag=3,a.payload={element:null},a.callback=function(){ph(i,r)},a}function t0(i){return i=La(i),i.tag=3,i}function n0(i,r,a,c){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var m=c.value;i.payload=function(){return h(m)},i.callback=function(){e0(r,a,c)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){e0(r,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 V2(i,r,a,c,h){if(a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=a.alternate,r!==null&&zl(r,a,h,!0),a=or.current,a!==null){switch(a.tag){case 31:case 13:return Dr===null?Th():a.alternate===null&&Mn===0&&(Mn=3),a.flags&=-257,a.flags|=65536,a.lanes=h,c===th?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([c]):r.add(c),tg(i,c,h)),!1;case 22:return a.flags|=65536,c===th?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([c])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([c]):a.add(c)),tg(i,c,h)),!1}throw Error(s(435,a.tag))}return tg(i,c,h),Th(),!1}if(Pt)return r=or.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=h,c!==Gp&&(i=Error(s(422),{cause:c}),Qc(kr(i,a)))):(c!==Gp&&(r=Error(s(423),{cause:c}),Qc(kr(r,a))),i=i.current.alternate,i.flags|=65536,h&=-h,i.lanes|=h,c=kr(c,a),h=Nm(i.stateNode,c,h),am(i,h),Mn!==4&&(Mn=2)),!1;var m=Error(s(520),{cause:c});if(m=kr(m,a),vu===null?vu=[m]:vu.push(m),Mn!==4&&(Mn=2),r===null)return!0;c=kr(c,a),a=r;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(r=a.type,m=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Ha===null||!Ha.has(m))))return a.flags|=65536,h&=-h,a.lanes|=h,h=t0(h),n0(h,i,a,c),am(a,h),!1}a=a.return}while(a!==null);return!1}var Mm=Error(s(461)),qn=!1;function wi(i,r,a,c){r.child=i===null?aS(r,null,a,c):Yo(r,i.child,a,c)}function i0(i,r,a,c,h){a=a.render;var m=r.ref;if("ref"in c){var y={};for(var D in c)D!=="ref"&&(y[D]=c[D])}else y=c;return Wo(r),c=hm(i,r,a,y,m,h),D=fm(),i!==null&&!qn?(pm(i,r,h),Ks(i,r,h)):(Pt&&D&&Vp(r),r.flags|=1,wi(i,r,c,h),r.child)}function r0(i,r,a,c,h){if(i===null){var m=a.type;return typeof m=="function"&&!Wp(m)&&m.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=m,s0(i,r,m,c,h)):(i=Gd(a.type,null,c,r,r.mode,h),i.ref=r.ref,i.return=r,r.child=i)}if(m=i.child,!zm(i,h)){var y=m.memoizedProps;if(a=a.compare,a=a!==null?a:sr,a(y,c)&&i.ref===r.ref)return Ks(i,r,h)}return r.flags|=1,i=zs(m,c),i.ref=r.ref,i.return=r,r.child=i}function s0(i,r,a,c,h){if(i!==null){var m=i.memoizedProps;if(sr(m,c)&&i.ref===r.ref)if(qn=!1,r.pendingProps=c=m,zm(i,h))(i.flags&131072)!==0&&(qn=!0);else return r.lanes=i.lanes,Ks(i,r,h)}return Am(i,r,a,c,h)}function a0(i,r,a,c){var h=c.children,m=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(m=m!==null?m.baseLanes|a:a,i!==null){for(c=r.child=i.child,h=0;c!==null;)h=h|c.lanes|c.childLanes,c=c.sibling;c=h&~m}else c=0,r.child=null;return o0(i,r,m,a,c)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Jd(r,m!==null?m.cachePool:null),m!==null?cS(r,m):lm(),uS(r);else return c=r.lanes=536870912,o0(i,r,m!==null?m.baseLanes|a:a,a,c)}else m!==null?(Jd(r,m.cachePool),cS(r,m),Ba(),r.memoizedState=null):(i!==null&&Jd(r,null),lm(),Ba());return wi(i,r,h,a),r.child}function uu(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function o0(i,r,a,c,h){var m=nm();return m=m===null?null:{parent:Wn._currentValue,pool:m},r.memoizedState={baseLanes:a,cachePool:m},i!==null&&Jd(r,null),lm(),uS(r),i!==null&&zl(i,r,c,!0),r.childLanes=h,null}function mh(i,r){return r=vh({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function l0(i,r,a){return Yo(r,i.child,null,a),i=mh(r,r.pendingProps),i.flags|=2,lr(r),r.memoizedState=null,i}function Y2(i,r,a){var c=r.pendingProps,h=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(Pt){if(c.mode==="hidden")return i=mh(r,c),r.lanes=536870912,uu(null,i);if(um(r),(i=mn)?(i=yw(i,Rr),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ra!==null?{id:hs,overflow:fs}:null,retryLane:536870912,hydrationErrors:null},a=Ky(i),a.return=r,r.child=a,yi=r,mn=null)):i=null,i===null)throw Na(r);return r.lanes=536870912,null}return mh(r,c)}var m=i.memoizedState;if(m!==null){var y=m.dehydrated;if(um(r),h)if(r.flags&256)r.flags&=-257,r=l0(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(qn||zl(i,r,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),tr(c,i,y),Mm;Th(),r=l0(i,r,a)}else i=m.treeContext,mn=Nr(y.nextSibling),yi=r,Pt=!0,Da=null,Rr=!1,i!==null&&Yy(r,i),r=mh(r,c),r.flags|=4096;return r}return i=zs(i.child,{mode:c.mode,children:c.children}),i.ref=r.ref,r.child=i,i.return=r,i}function gh(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function Am(i,r,a,c,h){return Wo(r),a=hm(i,r,a,c,void 0,h),c=fm(),i!==null&&!qn?(pm(i,r,h),Ks(i,r,h)):(Pt&&c&&Vp(r),r.flags|=1,wi(i,r,a,h),r.child)}function c0(i,r,a,c,h,m){return Wo(r),r.updateQueue=null,a=hS(r,c,a,h),dS(i),c=fm(),i!==null&&!qn?(pm(i,r,m),Ks(i,r,m)):(Pt&&c&&Vp(r),r.flags|=1,wi(i,r,a,m),r.child)}function u0(i,r,a,c,h){if(Wo(r),r.stateNode===null){var m=Ol,y=a.contextType;typeof y=="object"&&y!==null&&(m=Si(y)),m=new a(c,m),r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=Dm,r.stateNode=m,m._reactInternals=r,m=r.stateNode,m.props=c,m.state=r.memoizedState,m.refs={},rm(r),y=a.contextType,m.context=typeof y=="object"&&y!==null?Si(y):Ol,m.state=r.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Rm(r,a,y,c),m.state=r.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),su(r,c,m,h),ru(),m.state=r.memoizedState),typeof m.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(i===null){m=r.stateNode;var D=r.memoizedProps,H=Xo(a,D);m.props=H;var he=m.context,we=a.contextType;y=Ol,typeof we=="object"&&we!==null&&(y=Si(we));var Ee=a.getDerivedStateFromProps;we=typeof Ee=="function"||typeof m.getSnapshotBeforeUpdate=="function",D=r.pendingProps!==D,we||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(D||he!==y)&&XS(r,m,c,y),Aa=!1;var me=r.memoizedState;m.state=me,su(r,c,m,h),ru(),he=r.memoizedState,D||me!==he||Aa?(typeof Ee=="function"&&(Rm(r,a,Ee,c),he=r.memoizedState),(H=Aa||GS(r,a,H,c,me,he,y))?(we||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"&&(r.flags|=4194308)):(typeof m.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=he),m.props=c,m.state=he,m.context=y,c=H):(typeof m.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{m=r.stateNode,sm(i,r),y=r.memoizedProps,we=Xo(a,y),m.props=we,Ee=r.pendingProps,me=m.context,he=a.contextType,H=Ol,typeof he=="object"&&he!==null&&(H=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!==H)&&XS(r,m,c,H),Aa=!1,me=r.memoizedState,m.state=me,su(r,c,m,h),ru();var ye=r.memoizedState;y!==Ee||me!==ye||Aa||i!==null&&i.dependencies!==null&&Zd(i.dependencies)?(typeof D=="function"&&(Rm(r,a,D,c),ye=r.memoizedState),(we=Aa||GS(r,a,we,c,me,ye,H)||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,H),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(c,ye,H)),typeof m.componentDidUpdate=="function"&&(r.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(r.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=ye),m.props=c,m.state=ye,m.context=H,c=we):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(r.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&me===i.memoizedState||(r.flags|=1024),c=!1)}return m=c,gh(i,r),c=(r.flags&128)!==0,m||c?(m=r.stateNode,a=c&&typeof a.getDerivedStateFromError!="function"?null:m.render(),r.flags|=1,i!==null&&c?(r.child=Yo(r,i.child,null,h),r.child=Yo(r,null,a,h)):wi(i,r,a,h),r.memoizedState=m.state,i=r.child):i=Ks(i,r,h),i}function d0(i,r,a,c){return $o(),r.flags|=256,wi(i,r,a,c),r.child}var Lm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function jm(i){return{baseLanes:i,cachePool:eS()}}function Om(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=ur),i}function h0(i,r,a){var c=r.pendingProps,h=!1,m=(r.flags&128)!==0,y;if((y=m)||(y=i!==null&&i.memoizedState===null?!1:(Bn.current&2)!==0),y&&(h=!0,r.flags&=-129),y=(r.flags&32)!==0,r.flags&=-33,i===null){if(Pt){if(h?Oa(r):Ba(),(i=mn)?(i=yw(i,Rr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ra!==null?{id:hs,overflow:fs}:null,retryLane:536870912,hydrationErrors:null},a=Ky(i),a.return=r,r.child=a,yi=r,mn=null)):i=null,i===null)throw Na(r);return vg(i)?r.lanes=32:r.lanes=536870912,null}var D=c.children;return c=c.fallback,h?(Ba(),h=r.mode,D=vh({mode:"hidden",children:D},h),c=Uo(c,h,a,null),D.return=r,c.return=r,D.sibling=c,r.child=D,c=r.child,c.memoizedState=jm(a),c.childLanes=Om(i,y,a),r.memoizedState=Lm,uu(null,c)):(Oa(r),Bm(r,D))}var H=i.memoizedState;if(H!==null&&(D=H.dehydrated,D!==null)){if(m)r.flags&256?(Oa(r),r.flags&=-257,r=Im(i,r,a)):r.memoizedState!==null?(Ba(),r.child=i.child,r.flags|=128,r=null):(Ba(),D=c.fallback,h=r.mode,c=vh({mode:"visible",children:c.children},h),D=Uo(D,h,a,null),D.flags|=2,c.return=r,D.return=r,c.sibling=D,r.child=c,Yo(r,i.child,null,a),c=r.child,c.memoizedState=jm(a),c.childLanes=Om(i,y,a),r.memoizedState=Lm,r=uu(null,c));else if(Oa(r),vg(D)){if(y=D.nextSibling&&D.nextSibling.dataset,y)var he=y.dgst;y=he,c=Error(s(419)),c.stack="",c.digest=y,Qc({value:c,source:null,stack:null}),r=Im(i,r,a)}else if(qn||zl(i,r,a,!1),y=(a&i.childLanes)!==0,qn||y){if(y=on,y!==null&&(c=wn(y,a),c!==0&&c!==H.retryLane))throw H.retryLane=c,Ho(i,c),tr(y,i,c),Mm;gg(D)||Th(),r=Im(i,r,a)}else gg(D)?(r.flags|=192,r.child=i.child,r=null):(i=H.treeContext,mn=Nr(D.nextSibling),yi=r,Pt=!0,Da=null,Rr=!1,i!==null&&Yy(r,i),r=Bm(r,c.children),r.flags|=4096);return r}return h?(Ba(),D=c.fallback,h=r.mode,H=i.child,he=H.sibling,c=zs(H,{mode:"hidden",children:c.children}),c.subtreeFlags=H.subtreeFlags&65011712,he!==null?D=zs(he,D):(D=Uo(D,h,a,null),D.flags|=2),D.return=r,c.return=r,c.sibling=D,r.child=c,uu(null,c),c=r.child,D=i.child.memoizedState,D===null?D=jm(a):(h=D.cachePool,h!==null?(H=Wn._currentValue,h=h.parent!==H?{parent:H,pool:H}:h):h=eS(),D={baseLanes:D.baseLanes|a,cachePool:h}),c.memoizedState=D,c.childLanes=Om(i,y,a),r.memoizedState=Lm,uu(i.child,c)):(Oa(r),a=i.child,i=a.sibling,a=zs(a,{mode:"visible",children:c.children}),a.return=r,a.sibling=null,i!==null&&(y=r.deletions,y===null?(r.deletions=[i],r.flags|=16):y.push(i)),r.child=a,r.memoizedState=null,a)}function Bm(i,r){return r=vh({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function vh(i,r){return i=ar(22,i,null,r),i.lanes=0,i}function Im(i,r,a){return Yo(r,i.child,null,a),i=Bm(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function f0(i,r,a){i.lanes|=r;var c=i.alternate;c!==null&&(c.lanes|=r),Qp(i.return,r,a)}function Pm(i,r,a,c,h,m){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:h,treeForkCount:m}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=a,y.tailMode=h,y.treeForkCount=m)}function p0(i,r,a){var c=r.pendingProps,h=c.revealOrder,m=c.tail;c=c.children;var y=Bn.current,D=(y&2)!==0;if(D?(y=y&1|2,r.flags|=128):y&=1,pe(Bn,y),wi(i,r,c,a),c=Pt?Zc:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&f0(i,a,r);else if(i.tag===19)f0(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(h){case"forwards":for(a=r.child,h=null;a!==null;)i=a.alternate,i!==null&&sh(i)===null&&(h=a),a=a.sibling;a=h,a===null?(h=r.child,r.child=null):(h=a.sibling,a.sibling=null),Pm(r,!1,h,a,m,c);break;case"backwards":case"unstable_legacy-backwards":for(a=null,h=r.child,r.child=null;h!==null;){if(i=h.alternate,i!==null&&sh(i)===null){r.child=h;break}i=h.sibling,h.sibling=a,a=h,h=i}Pm(r,!0,a,null,m,c);break;case"together":Pm(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Ks(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),za|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(zl(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=zs(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=zs(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function zm(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&Zd(i)))}function G2(i,r,a){switch(r.tag){case 3:je(r,r.stateNode.containerInfo),Ma(r,Wn,i.memoizedState.cache),$o();break;case 27:case 5:Se(r);break;case 4:je(r,r.stateNode.containerInfo);break;case 10:Ma(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,um(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(Oa(r),r.flags|=128,null):(a&r.child.childLanes)!==0?h0(i,r,a):(Oa(r),i=Ks(i,r,a),i!==null?i.sibling:null);Oa(r);break;case 19:var h=(i.flags&128)!==0;if(c=(a&r.childLanes)!==0,c||(zl(i,r,a,!1),c=(a&r.childLanes)!==0),h){if(c)return p0(i,r,a);r.flags|=128}if(h=r.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),pe(Bn,Bn.current),c)break;return null;case 22:return r.lanes=0,a0(i,r,a,r.pendingProps);case 24:Ma(r,Wn,i.memoizedState.cache)}return Ks(i,r,a)}function m0(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)qn=!0;else{if(!zm(i,a)&&(r.flags&128)===0)return qn=!1,G2(i,r,a);qn=(i.flags&131072)!==0}else qn=!1,Pt&&(r.flags&1048576)!==0&&Vy(r,Zc,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(i=qo(r.elementType),r.type=i,typeof i=="function")Wp(i)?(c=Xo(i,c),r.tag=1,r=u0(null,r,i,c,a)):(r.tag=0,r=Am(null,r,i,c,a));else{if(i!=null){var h=i.$$typeof;if(h===P){r.tag=11,r=i0(null,r,i,c,a);break e}else if(h===L){r.tag=14,r=r0(null,r,i,c,a);break e}}throw r=ae(i)||i,Error(s(306,r,""))}}return r;case 0:return Am(i,r,r.type,r.pendingProps,a);case 1:return c=r.type,h=Xo(c,r.pendingProps),u0(i,r,c,h,a);case 3:e:{if(je(r,r.stateNode.containerInfo),i===null)throw Error(s(387));c=r.pendingProps;var m=r.memoizedState;h=m.element,sm(i,r),su(r,c,null,a);var y=r.memoizedState;if(c=y.cache,Ma(r,Wn,c),c!==m.cache&&Jp(r,[Wn],a,!0),ru(),c=y.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:y.cache},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){r=d0(i,r,c,a);break e}else if(c!==h){h=kr(Error(s(424)),r),Qc(h),r=d0(i,r,c,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,mn=Nr(i.firstChild),yi=r,Pt=!0,Da=null,Rr=!0,a=aS(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if($o(),c===h){r=Ks(i,r,a);break e}wi(i,r,c,a)}r=r.child}return r;case 26:return gh(i,r),i===null?(a=Tw(r.type,null,r.pendingProps,null))?r.memoizedState=a:Pt||(a=r.type,i=r.pendingProps,c=Lh(le.current).createElement(a),c[xe]=r,c[Ye]=i,xi(c,a,i),pn(c),r.stateNode=c):r.memoizedState=Tw(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Se(r),i===null&&Pt&&(c=r.stateNode=xw(r.type,r.pendingProps,le.current),yi=r,Rr=!0,h=mn,Wa(r.type)?(_g=h,mn=Nr(c.firstChild)):mn=h),wi(i,r,r.pendingProps.children,a),gh(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&Pt&&((h=c=mn)&&(c=kR(c,r.type,r.pendingProps,Rr),c!==null?(r.stateNode=c,yi=r,mn=Nr(c.firstChild),Rr=!1,h=!0):h=!1),h||Na(r)),Se(r),h=r.type,m=r.pendingProps,y=i!==null?i.memoizedProps:null,c=m.children,fg(h,m)?c=null:y!==null&&fg(h,y)&&(r.flags|=32),r.memoizedState!==null&&(h=hm(i,r,H2,null,null,a),ku._currentValue=h),gh(i,r),wi(i,r,c,a),r.child;case 6:return i===null&&Pt&&((i=a=mn)&&(a=TR(a,r.pendingProps,Rr),a!==null?(r.stateNode=a,yi=r,mn=null,i=!0):i=!1),i||Na(r)),null;case 13:return h0(i,r,a);case 4:return je(r,r.stateNode.containerInfo),c=r.pendingProps,i===null?r.child=Yo(r,null,c,a):wi(i,r,c,a),r.child;case 11:return i0(i,r,r.type,r.pendingProps,a);case 7:return wi(i,r,r.pendingProps,a),r.child;case 8:return wi(i,r,r.pendingProps.children,a),r.child;case 12:return wi(i,r,r.pendingProps.children,a),r.child;case 10:return c=r.pendingProps,Ma(r,r.type,c.value),wi(i,r,c.children,a),r.child;case 9:return h=r.type._context,c=r.pendingProps.children,Wo(r),h=Si(h),c=c(h),r.flags|=1,wi(i,r,c,a),r.child;case 14:return r0(i,r,r.type,r.pendingProps,a);case 15:return s0(i,r,r.type,r.pendingProps,a);case 19:return p0(i,r,a);case 31:return Y2(i,r,a);case 22:return a0(i,r,a,r.pendingProps);case 24:return Wo(r),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),r.memoizedState={parent:c,cache:h},rm(r),Ma(r,Wn,h)):((i.lanes&a)!==0&&(sm(i,r),su(r,null,null,a),ru()),h=i.memoizedState,m=r.memoizedState,h.parent!==c?(h={parent:c,cache:c},r.memoizedState=h,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=h),Ma(r,Wn,c)):(c=m.cache,Ma(r,Wn,c),c!==h.cache&&Jp(r,[Wn],a,!0))),wi(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function qs(i){i.flags|=4}function Hm(i,r,a,c,h){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(h&335544128)===h)if(i.stateNode.complete)i.flags|=8192;else if($0())i.flags|=8192;else throw Vo=th,im}else i.flags&=-16777217}function g0(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Mw(r))if($0())i.flags|=8192;else throw Vo=th,im}function _h(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?Gt():536870912,i.lanes|=r,Zl|=r)}function du(i,r){if(!Pt)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function gn(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(r)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,r}function X2(i,r,a){var c=r.pendingProps;switch(Yp(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(r),null;case 1:return gn(r),null;case 3:return a=r.stateNode,c=null,i!==null&&(c=i.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),$s(Wn),Fe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Pl(r)?qs(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Xp())),gn(r),null;case 26:var h=r.type,m=r.memoizedState;return i===null?(qs(r),m!==null?(gn(r),g0(r,m)):(gn(r),Hm(r,h,null,c,a))):m?m!==i.memoizedState?(qs(r),gn(r),g0(r,m)):(gn(r),r.flags&=-16777217):(i=i.memoizedProps,i!==c&&qs(r),gn(r),Hm(r,h,i,c,a)),null;case 27:if(ze(r),a=le.current,h=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==c&&qs(r);else{if(!c){if(r.stateNode===null)throw Error(s(166));return gn(r),null}i=Z.current,Pl(r)?Gy(r):(i=xw(h,c,a),r.stateNode=i,qs(r))}return gn(r),null;case 5:if(ze(r),h=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==c&&qs(r);else{if(!c){if(r.stateNode===null)throw Error(s(166));return gn(r),null}if(m=Z.current,Pl(r))Gy(r);else{var y=Lh(le.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[xe]=r,m[Ye]=c;e:for(y=r.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===r)break e;for(;y.sibling===null;){if(y.return===null||y.return===r)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}r.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&&qs(r)}}return gn(r),Hm(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==c&&qs(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(i=le.current,Pl(r)){if(i=r.stateNode,a=r.memoizedProps,c=null,h=yi,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}i[xe]=r,i=!!(i.nodeValue===a||c!==null&&c.suppressHydrationWarning===!0||hw(i.nodeValue,a)),i||Na(r,!0)}else i=Lh(i).createTextNode(c),i[xe]=r,r.stateNode=i}return gn(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(c=Pl(r),a!==null){if(i===null){if(!c)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[xe]=r}else $o(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),i=!1}else a=Xp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(lr(r),r):(lr(r),null);if((r.flags&128)!==0)throw Error(s(558))}return gn(r),null;case 13:if(c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(h=Pl(r),c!==null&&c.dehydrated!==null){if(i===null){if(!h)throw Error(s(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(s(317));h[xe]=r}else $o(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),h=!1}else h=Xp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=h),h=!0;if(!h)return r.flags&256?(lr(r),r):(lr(r),null)}return lr(r),(r.flags&128)!==0?(r.lanes=a,r):(a=c!==null,i=i!==null&&i.memoizedState!==null,a&&(c=r.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&&(r.child.flags|=8192),_h(r,r.updateQueue),gn(r),null);case 4:return Fe(),i===null&&lg(r.stateNode.containerInfo),gn(r),null;case 10:return $s(r.type),gn(r),null;case 19:if(V(Bn),c=r.memoizedState,c===null)return gn(r),null;if(h=(r.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=r.child;i!==null;){if(m=sh(i),m!==null){for(r.flags|=128,du(c,!1),i=m.updateQueue,r.updateQueue=i,_h(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)Wy(a,i),a=a.sibling;return pe(Bn,Bn.current&1|2),Pt&&Hs(r,c.treeForkCount),r.child}i=i.sibling}c.tail!==null&&We()>xh&&(r.flags|=128,h=!0,du(c,!1),r.lanes=4194304)}else{if(!h)if(i=sh(m),i!==null){if(r.flags|=128,h=!0,i=i.updateQueue,r.updateQueue=i,_h(r,i),du(c,!0),c.tail===null&&c.tailMode==="hidden"&&!m.alternate&&!Pt)return gn(r),null}else 2*We()-c.renderingStartTime>xh&&a!==536870912&&(r.flags|=128,h=!0,du(c,!1),r.lanes=4194304);c.isBackwards?(m.sibling=r.child,r.child=m):(i=c.last,i!==null?i.sibling=m:r.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=Bn.current,pe(Bn,h?a&1|2:a&1),Pt&&Hs(r,c.treeForkCount),i):(gn(r),null);case 22:case 23:return lr(r),cm(),c=r.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(a&536870912)!==0&&(r.flags&128)===0&&(gn(r),r.subtreeFlags&6&&(r.flags|=8192)):gn(r),a=r.updateQueue,a!==null&&_h(r,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==a&&(r.flags|=2048),i!==null&&V(Ko),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),$s(Wn),gn(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function Z2(i,r){switch(Yp(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return $s(Wn),Fe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return ze(r),null;case 31:if(r.memoizedState!==null){if(lr(r),r.alternate===null)throw Error(s(340));$o()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(lr(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));$o()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return V(Bn),null;case 4:return Fe(),null;case 10:return $s(r.type),null;case 22:case 23:return lr(r),cm(),i!==null&&V(Ko),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return $s(Wn),null;case 25:return null;default:return null}}function v0(i,r){switch(Yp(r),r.tag){case 3:$s(Wn),Fe();break;case 26:case 27:case 5:ze(r);break;case 4:Fe();break;case 31:r.memoizedState!==null&&lr(r);break;case 13:lr(r);break;case 19:V(Bn);break;case 10:$s(r.type);break;case 22:case 23:lr(r),cm(),i!==null&&V(Ko);break;case 24:$s(Wn)}}function hu(i,r){try{var a=r.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(r,r.return,D)}}function Ia(i,r,a){try{var c=r.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=r;var H=a,he=D;try{he()}catch(we){Qt(h,H,we)}}}c=c.next}while(c!==m)}}catch(we){Qt(r,r.return,we)}}function _0(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{lS(r,a)}catch(c){Qt(i,i.return,c)}}}function b0(i,r,a){a.props=Xo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(c){Qt(i,r,c)}}function fu(i,r){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,r,h)}}function ps(i,r){var a=i.ref,c=i.refCleanup;if(a!==null)if(typeof c=="function")try{c()}catch(h){Qt(i,r,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,r,h)}else a.current=null}function y0(i){var r=i.type,a=i.memoizedProps,c=i.stateNode;try{e:switch(r){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,r,a){try{var c=i.stateNode;bR(c,i.type,a,r),c[Ye]=r}catch(h){Qt(i,i.return,h)}}function S0(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||S0(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,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(i),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=Bi));else if(c!==4&&(c===27&&Wa(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(Fm(i,r,a),i=i.sibling;i!==null;)Fm(i,r,a),i=i.sibling}function bh(i,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(c!==4&&(c===27&&Wa(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(bh(i,r,a),i=i.sibling;i!==null;)bh(i,r,a),i=i.sibling}function w0(i){var r=i.stateNode,a=i.memoizedProps;try{for(var c=i.type,h=r.attributes;h.length;)r.removeAttributeNode(h[0]);xi(r,c,a),r[xe]=i,r[Ye]=a}catch(m){Qt(i,i.return,m)}}var Vs=!1,Vn=!1,Wm=!1,x0=typeof WeakSet=="function"?WeakSet:Set,ci=null;function Q2(i,r){if(i=i.containerInfo,dg=Hh,i=Xc(i),wr(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,H=-1,he=0,we=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||(H=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&&++we===c&&(H=y),(ye=Ee.nextSibling)!==null)break;Ee=me,me=Ee.parentNode}Ee=ye}a=D===-1||H===-1?null:{start:D,end:H}}else a=null}a=a||{start:0,end:0}}else a=null;for(hg={focusedElem:i,selectionRange:a},Hh=!1,ci=r;ci!==null;)if(r=ci,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,ci=i;else for(;ci!==null;){switch(r=ci,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)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=r,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=r.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(s(163))}if(i=r.sibling,i!==null){i.return=r.return,ci=i;break}ci=r.return}}function C0(i,r,a){var c=a.flags;switch(a.tag){case 0:case 11:case 15:Gs(i,a),c&4&&hu(5,a);break;case 1:if(Gs(i,a),c&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(y){Qt(a,a.return,y)}else{var h=Xo(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(h,r,i.__reactInternalSnapshotBeforeUpdate)}catch(y){Qt(a,a.return,y)}}c&64&&_0(a),c&512&&fu(a,a.return);break;case 3:if(Gs(i,a),c&64&&(i=a.updateQueue,i!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{lS(i,r)}catch(y){Qt(a,a.return,y)}}break;case 27:r===null&&c&4&&w0(a);case 26:case 5:Gs(i,a),r===null&&c&4&&y0(a),c&512&&fu(a,a.return);break;case 12:Gs(i,a);break;case 31:Gs(i,a),c&4&&E0(i,a);break;case 13:Gs(i,a),c&4&&R0(i,a),c&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=oR.bind(null,a),ER(i,a))));break;case 22:if(c=a.memoizedState!==null||Vs,!c){r=r!==null&&r.memoizedState!==null||Vn,h=Vs;var m=Vn;Vs=c,(Vn=r)&&!m?Xs(i,a,(a.subtreeFlags&8772)!==0):Gs(i,a),Vs=h,Vn=m}break;case 30:break;default:Gs(i,a)}}function k0(i){var r=i.alternate;r!==null&&(i.alternate=null,k0(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Ai(r)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var _n=null,Zi=!1;function Ys(i,r,a){for(a=a.child;a!==null;)T0(i,r,a),a=a.sibling}function T0(i,r,a){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(Sn,a)}catch{}switch(a.tag){case 26:Vn||ps(a,r),Ys(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Vn||ps(a,r);var c=_n,h=Zi;Wa(a.type)&&(_n=a.stateNode,Zi=!1),Ys(i,r,a),wu(a.stateNode),_n=c,Zi=h;break;case 5:Vn||ps(a,r);case 6:if(c=_n,h=Zi,_n=null,Ys(i,r,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,r,m)}else try{_n.removeChild(a.stateNode)}catch(m){Qt(a,r,m)}break;case 18:_n!==null&&(Zi?(i=_n,_w(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),sc(i)):_w(_n,a.stateNode));break;case 4:c=_n,h=Zi,_n=a.stateNode.containerInfo,Zi=!0,Ys(i,r,a),_n=c,Zi=h;break;case 0:case 11:case 14:case 15:Ia(2,a,r),Vn||Ia(4,a,r),Ys(i,r,a);break;case 1:Vn||(ps(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"&&b0(a,r,c)),Ys(i,r,a);break;case 21:Ys(i,r,a);break;case 22:Vn=(c=Vn)||a.memoizedState!==null,Ys(i,r,a),Vn=c;break;default:Ys(i,r,a)}}function E0(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{sc(i)}catch(a){Qt(r,r.return,a)}}}function R0(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{sc(i)}catch(a){Qt(r,r.return,a)}}function J2(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new x0),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new x0),r;default:throw Error(s(435,i.tag))}}function yh(i,r){var a=J2(i);r.forEach(function(c){if(!a.has(c)){a.add(c);var h=lR.bind(null,i,c);c.then(h,h)}})}function Qi(i,r){var a=r.deletions;if(a!==null)for(var c=0;c<a.length;c++){var h=a[c],m=i,y=r,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(s(160));T0(m,y,h),_n=null,Zi=!1,m=h.alternate,m!==null&&(m.return=null),h.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)D0(r,i),r=r.sibling}var Yr=null;function D0(i,r){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Qi(r,i),Ji(i),c&4&&(Ia(3,i,i.return),hu(3,i),Ia(5,i,i.return));break;case 1:Qi(r,i),Ji(i),c&512&&(Vn||a===null||ps(a,a.return)),c&64&&Vs&&(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=Yr;if(Qi(r,i),Ji(i),c&512&&(Vn||a===null||ps(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[xe]||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[xe]=i,pn(m),c=m;break e;case"link":var y=Dw("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=Dw("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(s(468,c))}m[xe]=i,pn(m),c=m}i.stateNode=c}else Nw(h,i.type,i.stateNode);else i.stateNode=Rw(h,c,i.memoizedProps);else m!==c?(m===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):m.count--,c===null?Nw(h,i.type,i.stateNode):Rw(h,c,i.memoizedProps)):c===null&&i.stateNode!==null&&Um(i,i.memoizedProps,a.memoizedProps)}break;case 27:Qi(r,i),Ji(i),c&512&&(Vn||a===null||ps(a,a.return)),a!==null&&c&4&&Um(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Qi(r,i),Ji(i),c&512&&(Vn||a===null||ps(a,a.return)),i.flags&32){h=i.stateNode;try{Hr(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(r,i),Ji(i),c&4){if(i.stateNode===null)throw Error(s(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=Yr,Yr=jh(r.containerInfo),Qi(r,i),Yr=h,Ji(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{sc(r.containerInfo)}catch(Ge){Qt(i,i.return,Ge)}Wm&&(Wm=!1,N0(i));break;case 4:c=Yr,Yr=jh(i.stateNode.containerInfo),Qi(r,i),Ji(i),Yr=c;break;case 12:Qi(r,i),Ji(i);break;case 31:Qi(r,i),Ji(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,yh(i,c)));break;case 13:Qi(r,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 H=a!==null&&a.memoizedState!==null,he=Vs,we=Vn;if(Vs=he||h,Vn=we||H,Qi(r,i),Vn=we,Vs=he,Ji(i),c&8192)e:for(r=i.stateNode,r._visibility=h?r._visibility&-2:r._visibility|1,h&&(a===null||H||Vs||Vn||Zo(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){H=a=r;try{if(m=H.stateNode,h)y=m.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{D=H.stateNode;var Ee=H.memoizedProps.style,me=Ee!=null&&Ee.hasOwnProperty("display")?Ee.display:null;D.style.display=me==null||typeof me=="boolean"?"":(""+me).trim()}}catch(Ge){Qt(H,H.return,Ge)}}}else if(r.tag===6){if(a===null){H=r;try{H.stateNode.nodeValue=h?"":H.memoizedProps}catch(Ge){Qt(H,H.return,Ge)}}}else if(r.tag===18){if(a===null){H=r;try{var ye=H.stateNode;h?bw(ye,!0):bw(H.stateNode,!1)}catch(Ge){Qt(H,H.return,Ge)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}c&4&&(c=i.updateQueue,c!==null&&(a=c.retryQueue,a!==null&&(c.retryQueue=null,yh(i,a))));break;case 19:Qi(r,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(r,i),Ji(i)}}function Ji(i){var r=i.flags;if(r&2){try{for(var a,c=i.return;c!==null;){if(S0(c)){a=c;break}c=c.return}if(a==null)throw Error(s(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&&(Hr(y,""),a.flags&=-33);var D=$m(i);bh(i,D,y);break;case 3:case 4:var H=a.stateNode.containerInfo,he=$m(i);Fm(i,he,H);break;default:throw Error(s(161))}}catch(we){Qt(i,i.return,we)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function N0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;N0(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function Gs(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)C0(i,r.alternate,r),r=r.sibling}function Zo(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Ia(4,r,r.return),Zo(r);break;case 1:ps(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&b0(r,r.return,a),Zo(r);break;case 27:wu(r.stateNode);case 26:case 5:ps(r,r.return),Zo(r);break;case 22:r.memoizedState===null&&Zo(r);break;case 30:Zo(r);break;default:Zo(r)}i=i.sibling}}function Xs(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,h=i,m=r,y=m.flags;switch(m.tag){case 0:case 11:case 15:Xs(h,m,a),hu(4,m);break;case 1:if(Xs(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 H=h.shared.hiddenCallbacks;if(H!==null)for(h.shared.hiddenCallbacks=null,h=0;h<H.length;h++)oS(H[h],D)}catch(he){Qt(c,c.return,he)}}a&&y&64&&_0(m),fu(m,m.return);break;case 27:w0(m);case 26:case 5:Xs(h,m,a),a&&c===null&&y&4&&y0(m),fu(m,m.return);break;case 12:Xs(h,m,a);break;case 31:Xs(h,m,a),a&&y&4&&E0(h,m);break;case 13:Xs(h,m,a),a&&y&4&&R0(h,m);break;case 22:m.memoizedState===null&&Xs(h,m,a),fu(m,m.return);break;case 30:break;default:Xs(h,m,a)}r=r.sibling}}function Km(i,r){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Jc(a))}function qm(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Jc(i))}function Gr(i,r,a,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)M0(i,r,a,c),r=r.sibling}function M0(i,r,a,c){var h=r.flags;switch(r.tag){case 0:case 11:case 15:Gr(i,r,a,c),h&2048&&hu(9,r);break;case 1:Gr(i,r,a,c);break;case 3:Gr(i,r,a,c),h&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Jc(i)));break;case 12:if(h&2048){Gr(i,r,a,c),i=r.stateNode;try{var m=r.memoizedProps,y=m.id,D=m.onPostCommit;typeof D=="function"&&D(y,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(H){Qt(r,r.return,H)}}else Gr(i,r,a,c);break;case 31:Gr(i,r,a,c);break;case 13:Gr(i,r,a,c);break;case 23:break;case 22:m=r.stateNode,y=r.alternate,r.memoizedState!==null?m._visibility&2?Gr(i,r,a,c):pu(i,r):m._visibility&2?Gr(i,r,a,c):(m._visibility|=2,Yl(i,r,a,c,(r.subtreeFlags&10256)!==0||!1)),h&2048&&Km(y,r);break;case 24:Gr(i,r,a,c),h&2048&&qm(r.alternate,r);break;default:Gr(i,r,a,c)}}function Yl(i,r,a,c,h){for(h=h&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var m=i,y=r,D=a,H=c,he=y.flags;switch(y.tag){case 0:case 11:case 15:Yl(m,y,D,H,h),hu(8,y);break;case 23:break;case 22:var we=y.stateNode;y.memoizedState!==null?we._visibility&2?Yl(m,y,D,H,h):pu(m,y):(we._visibility|=2,Yl(m,y,D,H,h)),h&&he&2048&&Km(y.alternate,y);break;case 24:Yl(m,y,D,H,h),h&&he&2048&&qm(y.alternate,y);break;default:Yl(m,y,D,H,h)}r=r.sibling}}function pu(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=i,c=r,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)}r=r.sibling}}var mu=8192;function Gl(i,r,a){if(i.subtreeFlags&mu)for(i=i.child;i!==null;)A0(i,r,a),i=i.sibling}function A0(i,r,a){switch(i.tag){case 26:Gl(i,r,a),i.flags&mu&&i.memoizedState!==null&&zR(a,Yr,i.memoizedState,i.memoizedProps);break;case 5:Gl(i,r,a);break;case 3:case 4:var c=Yr;Yr=jh(i.stateNode.containerInfo),Gl(i,r,a),Yr=c;break;case 22:i.memoizedState===null&&(c=i.alternate,c!==null&&c.memoizedState!==null?(c=mu,mu=16777216,Gl(i,r,a),mu=c):Gl(i,r,a));break;default:Gl(i,r,a)}}function L0(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function gu(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var c=r[a];ci=c,O0(c,i)}L0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)j0(i),i=i.sibling}function j0(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 r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,Sh(i)):gu(i);break;default:gu(i)}}function Sh(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var c=r[a];ci=c,O0(c,i)}L0(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Ia(8,r,r.return),Sh(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Sh(r));break;default:Sh(r)}i=i.sibling}}function O0(i,r){for(;ci!==null;){var a=ci;switch(a.tag){case 0:case 11:case 15:Ia(8,a,r);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(k0(c),c===a){ci=null;break e}if(h!==null){h.return=m,ci=h;break e}ci=m}}}var eR={getCacheForType:function(i){var r=Si(Wn),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Si(Wn).controller.signal}},tR=typeof WeakMap=="function"?WeakMap:Map,Kt=0,on=null,Mt=null,Ot=0,Zt=0,cr=null,Pa=!1,Xl=!1,Vm=!1,Zs=0,Mn=0,za=0,Qo=0,Ym=0,ur=0,Zl=0,vu=null,er=null,Gm=!1,wh=0,B0=0,xh=1/0,Ch=null,Ha=null,Jn=0,Ua=null,Ql=null,Qs=0,Xm=0,Zm=null,I0=null,_u=0,Qm=null;function dr(){return(Kt&2)!==0&&Ot!==0?Ot&-Ot:O.T!==null?rg():dt()}function P0(){if(ur===0)if((Ot&536870912)===0||Pt){var i=at;at<<=1,(at&3932160)===0&&(at=262144),ur=i}else ur=536870912;return i=or.current,i!==null&&(i.flags|=32),ur}function tr(i,r,a){(i===on&&(Zt===2||Zt===9)||i.cancelPendingCommit!==null)&&(Jl(i,0),$a(i,Ot,ur,!1)),hn(i,a),((Kt&2)===0||i!==on)&&(i===on&&((Kt&2)===0&&(Qo|=a),Mn===4&&$a(i,Ot,ur,!1)),ms(i))}function z0(i,r,a){if((Kt&6)!==0)throw Error(s(327));var c=!a&&(r&127)===0&&(r&i.expiredLanes)===0||$t(i,r),h=c?rR(i,r):eg(i,r,!0),m=c;do{if(h===0){Xl&&!c&&$a(i,r,0,!1);break}else{if(a=i.current.alternate,m&&!nR(a)){h=eg(i,r,!1),m=!1;continue}if(h===2){if(m=r,i.errorRecoveryDisabledLanes&m)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){r=y;e:{var D=i;h=vu;var H=D.current.memoizedState.isDehydrated;if(H&&(Jl(D,y).flags|=256),y=eg(D,y,!1),y!==2){if(Vm&&!H){D.errorRecoveryDisabledLanes|=m,Qo|=m,h=4;break e}m=er,er=h,m!==null&&(er===null?er=m:er.push.apply(er,m))}h=y}if(m=!1,h!==2)continue}}if(h===1){Jl(i,0),$a(i,r,0,!0);break}e:{switch(c=i,m=h,m){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:$a(c,r,ur,!Pa);break e;case 2:er=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(h=wh+300-We(),10<h)){if($a(c,r,ur,!Pa),It(c,0,!0)!==0)break e;Qs=r,c.timeoutHandle=gw(H0.bind(null,c,a,er,Ch,Gm,r,ur,Qo,Zl,Pa,m,"Throttled",-0,0),h);break e}H0(c,a,er,Ch,Gm,r,ur,Qo,Zl,Pa,m,null,-0,0)}}break}while(!0);ms(i)}function H0(i,r,a,c,h,m,y,D,H,he,we,Ee,me,ye){if(i.timeoutHandle=-1,Ee=r.subtreeFlags,Ee&8192||(Ee&16785408)===16785408){Ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Bi},A0(r,m,Ee);var Ge=(m&62914560)===m?wh-We():(m&4194048)===m?B0-We():0;if(Ge=HR(Ee,Ge),Ge!==null){Qs=m,i.cancelPendingCommit=Ge(Y0.bind(null,i,r,m,a,c,h,y,D,H,we,Ee,null,me,ye)),$a(i,m,y,!he);return}}Y0(i,r,m,a,c,h,y,D,H)}function nR(i){for(var r=i;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var 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=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function $a(i,r,a,c){r&=~Ym,r&=~Qo,i.suspendedLanes|=r,i.pingedLanes&=~r,c&&(i.warmLanes|=r),c=i.expirationTimes;for(var h=r;0<h;){var m=31-Ct(h),y=1<<m;c[m]=-1,h&=~y}a!==0&&ln(i,a,r)}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,Us=Fo=null,mm(i),Fl=null,tu=0,i=Mt;for(;i!==null;)v0(i.alternate,i),i=i.return;Mt=null}}function Jl(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,wR(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Qs=0,Jm(),on=i,Mt=a=zs(i.current,null),Ot=r,Zt=0,cr=null,Pa=!1,Xl=$t(i,r),Vm=!1,Zl=ur=Ym=Qo=za=Mn=0,er=vu=null,Gm=!1,(r&8)!==0&&(r|=r&32);var c=i.entangledLanes;if(c!==0)for(i=i.entanglements,c&=r;0<c;){var h=31-Ct(c),m=1<<h;r|=i[h],c&=~m}return Zs=r,qd(),a}function U0(i,r){St=null,O.H=cu,r===$l||r===eh?(r=iS(),Zt=3):r===im?(r=iS(),Zt=4):Zt=r===Mm?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,cr=r,Mt===null&&(Mn=1,ph(i,kr(r,i.current)))}function $0(){var i=or.current;return i===null?!0:(Ot&4194048)===Ot?Dr===null:(Ot&62914560)===Ot||(Ot&536870912)!==0?i===Dr:!1}function F0(){var i=O.H;return O.H=cu,i===null?cu:i}function W0(){var i=O.A;return O.A=eR,i}function Th(){Mn=4,Pa||(Ot&4194048)!==Ot&&or.current!==null||(Xl=!0),(za&134217727)===0&&(Qo&134217727)===0||on===null||$a(on,Ot,ur,!1)}function eg(i,r,a){var c=Kt;Kt|=2;var h=F0(),m=W0();(on!==i||Ot!==r)&&(Ch=null,Jl(i,r)),r=!1;var y=Mn;e:do try{if(Zt!==0&&Mt!==null){var D=Mt,H=cr;switch(Zt){case 8:Jm(),y=6;break e;case 3:case 2:case 9:case 6:or.current===null&&(r=!0);var he=Zt;if(Zt=0,cr=null,ec(i,D,H,he),a&&Xl){y=0;break e}break;default:he=Zt,Zt=0,cr=null,ec(i,D,H,he)}}iR(),y=Mn;break}catch(we){U0(i,we)}while(!0);return r&&i.shellSuspendCounter++,Us=Fo=null,Kt=c,O.H=h,O.A=m,Mt===null&&(on=null,Ot=0,qd()),y}function iR(){for(;Mt!==null;)K0(Mt)}function rR(i,r){var a=Kt;Kt|=2;var c=F0(),h=W0();on!==i||Ot!==r?(Ch=null,xh=We()+500,Jl(i,r)):Xl=$t(i,r);e:do try{if(Zt!==0&&Mt!==null){r=Mt;var m=cr;t:switch(Zt){case 1:Zt=0,cr=null,ec(i,r,m,1);break;case 2:case 9:if(tS(m)){Zt=0,cr=null,q0(r);break}r=function(){Zt!==2&&Zt!==9||on!==i||(Zt=7),ms(i)},m.then(r,r);break e;case 3:Zt=7;break e;case 4:Zt=5;break e;case 7:tS(m)?(Zt=0,cr=null,q0(r)):(Zt=0,cr=null,ec(i,r,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?Mw(y):D.stateNode.complete){Zt=0,cr=null;var H=D.sibling;if(H!==null)Mt=H;else{var he=D.return;he!==null?(Mt=he,Eh(he)):Mt=null}break t}}Zt=0,cr=null,ec(i,r,m,5);break;case 6:Zt=0,cr=null,ec(i,r,m,6);break;case 8:Jm(),Mn=6;break e;default:throw Error(s(462))}}sR();break}catch(we){U0(i,we)}while(!0);return Us=Fo=null,O.H=c,O.A=h,Kt=a,Mt!==null?0:(on=null,Ot=0,qd(),Mn)}function sR(){for(;Mt!==null&&!be();)K0(Mt)}function K0(i){var r=m0(i.alternate,i,Zs);i.memoizedProps=i.pendingProps,r===null?Eh(i):Mt=r}function q0(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=c0(a,r,r.pendingProps,r.type,void 0,Ot);break;case 11:r=c0(a,r,r.pendingProps,r.type.render,r.ref,Ot);break;case 5:mm(r);default:v0(a,r),r=Mt=Wy(r,Zs),r=m0(a,r,Zs)}i.memoizedProps=i.pendingProps,r===null?Eh(i):Mt=r}function ec(i,r,a,c){Us=Fo=null,mm(r),Fl=null,tu=0;var h=r.return;try{if(V2(i,h,r,a,Ot)){Mn=1,ph(i,kr(a,i.current)),Mt=null;return}}catch(m){if(h!==null)throw Mt=h,m;Mn=1,ph(i,kr(a,i.current)),Mt=null;return}r.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=or.current,c!==null&&c.tag===13&&(c.flags|=16384))),V0(r,i)):Eh(r)}function Eh(i){var r=i;do{if((r.flags&32768)!==0){V0(r,Pa);return}i=r.return;var a=X2(r.alternate,r,Zs);if(a!==null){Mt=a;return}if(r=r.sibling,r!==null){Mt=r;return}Mt=r=i}while(r!==null);Mn===0&&(Mn=5)}function V0(i,r){do{var a=Z2(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),!r&&(i=i.sibling,i!==null)){Mt=i;return}Mt=i=a}while(i!==null);Mn=6,Mt=null}function Y0(i,r,a,c,h,m,y,D,H){i.cancelPendingCommit=null;do Rh();while(Jn!==0);if((Kt&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(m=r.lanes|r.childLanes,m|=$p,an(i,a,m,y,D,H),i===on&&(Mt=on=null,Ot=0),Ql=r,Ua=i,Qs=a,Xm=m,Zm=h,I0=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,cR(lt,function(){return J0(),null})):(i.callbackNode=null,i.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=O.T,O.T=null,h=R.p,R.p=2,y=Kt,Kt|=4;try{Q2(i,r,a)}finally{Kt=y,R.p=h,O.T=c}}Jn=1,G0(),X0(),Z0()}}function G0(){if(Jn===1){Jn=0;var i=Ua,r=Ql,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var c=R.p;R.p=2;var h=Kt;Kt|=4;try{D0(r,i);var m=hg,y=Xc(i.containerInfo),D=m.focusedElem,H=m.selectionRange;if(y!==D&&D&&D.ownerDocument&&Kd(D.ownerDocument.documentElement,D)){if(H!==null&&wr(D)){var he=H.start,we=H.end;if(we===void 0&&(we=he),"selectionStart"in D)D.selectionStart=he,D.selectionEnd=Math.min(we,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(H.start,Ge),nn=H.end===void 0?ct:Math.min(H.end,Ge);!ye.extend&&ct>nn&&(y=nn,nn=ct,ct=y);var te=Wd(D,ct),q=Wd(D,nn);if(te&&q&&(ye.rangeCount!==1||ye.anchorNode!==te.node||ye.anchorOffset!==te.offset||ye.focusNode!==q.node||ye.focusOffset!==q.offset)){var ue=Ee.createRange();ue.setStart(te.node,te.offset),ye.removeAllRanges(),ct>nn?(ye.addRange(ue),ye.extend(q.node,q.offset)):(ue.setEnd(q.node,q.offset),ye.addRange(ue))}}}}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 Ce=Ee[D];Ce.element.scrollLeft=Ce.left,Ce.element.scrollTop=Ce.top}}Hh=!!dg,hg=dg=null}finally{Kt=h,R.p=c,O.T=a}}i.current=r,Jn=2}}function X0(){if(Jn===2){Jn=0;var i=Ua,r=Ql,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var c=R.p;R.p=2;var h=Kt;Kt|=4;try{C0(i,r.alternate,r)}finally{Kt=h,R.p=c,O.T=a}}Jn=3}}function Z0(){if(Jn===4||Jn===3){Jn=0,$e();var i=Ua,r=Ql,a=Qs,c=I0;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Jn=5:(Jn=0,Ql=Ua=null,Q0(i,i.pendingLanes));var h=i.pendingLanes;if(h===0&&(Ha=null),ri(a),r=r.stateNode,ut&&typeof ut.onCommitFiberRoot=="function")try{ut.onCommitFiberRoot(Sn,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=O.T,h=R.p,R.p=2,O.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{O.T=r,R.p=h}}(Qs&3)!==0&&Rh(),ms(i),h=i.pendingLanes,(a&261930)!==0&&(h&42)!==0?i===Qm?_u++:(_u=0,Qm=i):_u=0,bu(0)}}function Q0(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Jc(r)))}function Rh(){return G0(),X0(),Z0(),J0()}function J0(){if(Jn!==5)return!1;var i=Ua,r=Xm;Xm=0;var a=ri(Qs),c=O.T,h=R.p;try{R.p=32>a?32:a,O.T=null,a=Zm,Zm=null;var m=Ua,y=Qs;if(Jn=0,Ql=Ua=null,Qs=0,(Kt&6)!==0)throw Error(s(331));var D=Kt;if(Kt|=4,j0(m.current),M0(m,m.current,y,a),Kt=D,bu(0,!1),ut&&typeof ut.onPostCommitFiberRoot=="function")try{ut.onPostCommitFiberRoot(Sn,m)}catch{}return!0}finally{R.p=h,O.T=c,Q0(i,r)}}function ew(i,r,a){r=kr(a,r),r=Nm(i.stateNode,r,2),i=ja(i,r,2),i!==null&&(hn(i,2),ms(i))}function Qt(i,r,a){if(i.tag===3)ew(i,i,a);else for(;r!==null;){if(r.tag===3){ew(r,i,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ha===null||!Ha.has(c))){i=kr(a,i),a=t0(2),c=ja(r,a,2),c!==null&&(n0(a,c,r,i),hn(c,2),ms(c));break}}r=r.return}}function tg(i,r,a){var c=i.pingCache;if(c===null){c=i.pingCache=new tR;var h=new Set;c.set(r,h)}else h=c.get(r),h===void 0&&(h=new Set,c.set(r,h));h.has(a)||(Vm=!0,h.add(a),i=aR.bind(null,i,r,a),r.then(i,i))}function aR(i,r,a){var c=i.pingCache;c!==null&&c.delete(r),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)),ms(i)}function tw(i,r){r===0&&(r=Gt()),i=Ho(i,r),i!==null&&(hn(i,r),ms(i))}function oR(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),tw(i,a)}function lR(i,r){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(s(314))}c!==null&&c.delete(r),tw(i,a)}function cR(i,r){return Me(i,r)}var Dh=null,tc=null,ng=!1,Nh=!1,ig=!1,Fa=0;function ms(i){i!==tc&&i.next===null&&(tc===null?Dh=tc=i:tc=tc.next=i),Nh=!0,ng||(ng=!0,dR())}function bu(i,r){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 uR(){nw()}function nw(){Nh=ng=!1;var i=0;Fa!==0&&SR()&&(i=Fa);for(var r=We(),a=null,c=Dh;c!==null;){var h=c.next,m=iw(c,r);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 iw(i,r){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,H=h[y];H===-1?((D&a)===0||(D&c)!==0)&&(h[y]=dn(D,r)):H<=r&&(i.expiredLanes|=D),m&=~D}if(r=on,a=Ot,a=It(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c=i.callbackNode,a===0||i===r&&(Zt===2||Zt===9)||i.cancelPendingCommit!==null)return c!==null&&c!==null&&Le(c),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||$t(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(c!==null&&Le(c),ri(a)){case 2:case 8:a=wt;break;case 32:a=lt;break;case 268435456:a=Yt;break;default:a=lt}return c=rw.bind(null,i),a=Me(a,c),i.callbackPriority=r,i.callbackNode=a,r}return c!==null&&c!==null&&Le(c),i.callbackPriority=2,i.callbackNode=null,2}function rw(i,r){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:(z0(i,c,r),iw(i,We()),i.callbackNode!=null&&i.callbackNode===a?rw.bind(null,i):null)}function sw(i,r){if(Rh())return null;z0(i,r,!0)}function dR(){xR(function(){(Kt&6)!==0?Me(vt,uR):nw()})}function rg(){if(Fa===0){var i=Hl;i===0&&(i=Ze,Ze<<=1,(Ze&261888)===0&&(Ze=256)),Fa=i}return Fa}function aw(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Oi(""+i)}function ow(i,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,i.id&&a.setAttribute("form",i.id),r.parentNode.insertBefore(a,r),i=new FormData(i),a.parentNode.removeChild(a),i}function hR(i,r,a,c,h){if(r==="submit"&&a&&a.stateNode===h){var m=aw((h[Ye]||null).action),y=c.submitter;y&&(r=(r=y[Ye]||null)?aw(r.formAction):y.getAttribute("formAction"),r!==null&&(m=r,y=null));var D=new Sr("action","action",null,c,h);i.push({event:D,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Fa!==0){var H=y?ow(h,y):new FormData(h);Cm(a,{pending:!0,data:H,method:h.method,action:m},null,H)}}else typeof m=="function"&&(D.preventDefault(),H=y?ow(h,y):new FormData(h),Cm(a,{pending:!0,data:H,method:h.method,action:m},m,H))},currentTarget:h}]})}}for(var sg=0;sg<xr.length;sg++){var ag=xr[sg],fR=ag.toLowerCase(),pR=ag[0].toUpperCase()+ag.slice(1);Xi(fR,"on"+pR)}Xi(Tt,"onAnimationEnd"),Xi(Et,"onAnimationIteration"),Xi(st,"onAnimationStart"),Xi("dblclick","onDoubleClick"),Xi("focusin","onFocus"),Xi("focusout","onBlur"),Xi(un,"onTransitionRun"),Xi(Jt,"onTransitionStart"),Xi(Xt,"onTransitionCancel"),Xi(Vr,"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(" "),mR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yu));function lw(i,r){r=(r&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(r)for(var y=c.length-1;0<=y;y--){var D=c[y],H=D.instance,he=D.currentTarget;if(D=D.listener,H!==m&&h.isPropagationStopped())break e;m=D,h.currentTarget=he;try{m(h)}catch(we){zo(we)}h.currentTarget=null,m=H}else for(y=0;y<c.length;y++){if(D=c[y],H=D.instance,he=D.currentTarget,D=D.listener,H!==m&&h.isPropagationStopped())break e;m=D,h.currentTarget=he;try{m(h)}catch(we){zo(we)}h.currentTarget=null,m=H}}}}function At(i,r){var a=r[et];a===void 0&&(a=r[et]=new Set);var c=i+"__bubble";a.has(c)||(cw(r,i,2,!1),a.add(c))}function og(i,r,a){var c=0;r&&(c|=4),cw(a,i,c,r)}var Mh="_reactListening"+Math.random().toString(36).slice(2);function lg(i){if(!i[Mh]){i[Mh]=!0,si.forEach(function(a){a!=="selectionchange"&&(mR.has(a)||og(a,!1,i),og(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Mh]||(r[Mh]=!0,og("selectionchange",!1,r))}}function cw(i,r,a,c){switch(Pw(r)){case 2:var h=FR;break;case 8:h=WR;break;default:h=xg}a=h.bind(null,r,a,i),h=void 0,!Ls||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(h=!0),c?h!==void 0?i.addEventListener(r,a,{capture:!0,passive:h}):i.addEventListener(r,a,!0):h!==void 0?i.addEventListener(r,a,{passive:h}):i.addEventListener(r,a,!1)}function cg(i,r,a,c,h){var m=c;if((r&1)===0&&(r&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 H=y.tag;if((H===3||H===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;D!==null;){if(y=vr(D),y===null)return;if(H=y.tag,H===5||H===6||H===26||H===27){c=m=y;continue e}D=D.parentNode}}c=c.return}As(function(){var he=m,we=yr(a),Ee=[];e:{var me=Po.get(i);if(me!==void 0){var ye=Sr,Ge=i;switch(i){case"keypress":if(ss(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 st:ye=Wc;break;case Vr: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=(r&4)!==0,nn=!ct&&(i==="scroll"||i==="scrollend"),te=ct?me!==null?me+"Capture":null:me;ct=[];for(var q=he,ue;q!==null;){var Ce=q;if(ue=Ce.stateNode,Ce=Ce.tag,Ce!==5&&Ce!==26&&Ce!==27||ue===null||te===null||(Ce=Ii(q,te),Ce!=null&&ct.push(Su(q,Ce,ue))),nn)break;q=q.return}0<ct.length&&(me=new ye(me,Ge,null,a,we),Ee.push({event:me,listeners:ct}))}}if((r&7)===0){e:{if(me=i==="mouseover"||i==="pointerover",ye=i==="mouseout"||i==="pointerout",me&&a!==Ur&&(Ge=a.relatedTarget||a.fromElement)&&(vr(Ge)||Ge[Xe]))break e;if((ye||me)&&(me=we.window===we?we:(me=we.ownerDocument)?me.defaultView||me.parentWindow:window,ye?(Ge=a.relatedTarget||a.toElement,ye=he,Ge=Ge?vr(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,Ce="onMouseLeave",te="onMouseEnter",q="mouse",(i==="pointerout"||i==="pointerover")&&(ct=Gi,Ce="onPointerLeave",te="onPointerEnter",q="pointer"),nn=ye==null?me:Li(ye),ue=Ge==null?me:Li(Ge),me=new ct(Ce,q+"leave",ye,a,we),me.target=nn,me.relatedTarget=ue,Ce=null,vr(we)===he&&(ct=new ct(te,q+"enter",Ge,a,we),ct.target=ue,ct.relatedTarget=nn,Ce=ct),nn=Ce,ye&&Ge)t:{for(ct=gR,te=ye,q=Ge,ue=0,Ce=te;Ce;Ce=ct(Ce))ue++;Ce=0;for(var nt=q;nt;nt=ct(nt))Ce++;for(;0<ue-Ce;)te=ct(te),ue--;for(;0<Ce-ue;)q=ct(q),Ce--;for(;ue--;){if(te===q||q!==null&&te===q.alternate){ct=te;break t}te=ct(te),q=ct(q)}ct=null}else ct=null;ye!==null&&uw(Ee,me,ye,ct,!1),Ge!==null&&nn!==null&&uw(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(Be(me))if(Is)Ht=$d;else{Ht=Pp;var Qe=ds}else ye=me.nodeName,!ye||ye.toLowerCase()!=="input"||me.type!=="checkbox"&&me.type!=="radio"?he&&rr(he.elementType)&&(Ht=Dn):Ht=zp;if(Ht&&(Ht=Ht(i,he))){qe(Ee,Ht,a,we);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":(Be(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,we);break;case"selectionchange":if(Up)break;case"keydown":case"keyup":E(Ee,a,we)}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 Y?k(i,a)&&(Bt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Bt="onCompositionStart");Bt&&(Ca&&a.locale!=="ko"&&(Y||Bt!=="onCompositionStart"?Bt==="onCompositionEnd"&&Y&&(xt=xl()):(Ei=we,Pi="value"in Ei?Ei.value:Ei.textContent,Y=!0)),Qe=Ah(he,Bt),0<Qe.length&&(Bt=new ls(Bt,i,null,a,we),Ee.push({event:Bt,listeners:Qe}),xt?Bt.data=xt:(xt=B(a),xt!==null&&(Bt.data=xt)))),(xt=Yc?re(i,a):ce(i,a))&&(Bt=Ah(he,"onBeforeInput"),0<Bt.length&&(Qe=new ls("onBeforeInput","beforeinput",null,a,we),Ee.push({event:Qe,listeners:Bt}),Qe.data=xt)),hR(Ee,i,he,a,we)}lw(Ee,r)})}function Su(i,r,a){return{instance:i,listener:r,currentTarget:a}}function Ah(i,r){for(var a=r+"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,r),h!=null&&c.push(Su(i,h,m))),i.tag===3)return c;i=i.return}return[]}function gR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function uw(i,r,a,c,h){for(var m=r._reactName,y=[];a!==null&&a!==c;){var D=a,H=D.alternate,he=D.stateNode;if(D=D.tag,H!==null&&H===c)break;D!==5&&D!==26&&D!==27||he===null||(H=he,h?(he=Ii(a,m),he!=null&&y.unshift(Su(a,he,H))):h||(he=Ii(a,m),he!=null&&y.push(Su(a,he,H)))),a=a.return}y.length!==0&&i.push({event:r,listeners:y})}var vR=/\r\n?/g,_R=/\u0000|\uFFFD/g;function dw(i){return(typeof i=="string"?i:""+i).replace(vR,`
|
|
10
|
-
`).replace(_R,"")}function hw(i,r){return r=dw(r),dw(i)===r}function tn(i,r,a,c,h,m){switch(a){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||Hr(i,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&Hr(i,""+c);break;case"className":zr(i,"class",c);break;case"tabIndex":zr(i,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":zr(i,a,c);break;case"style":Do(i,c,m);break;case"data":if(r!=="object"){zr(i,"data",c);break}case"src":case"href":if(c===""&&(r!=="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"?(r!=="input"&&tn(i,r,"name",h.name,h,null),tn(i,r,"formEncType",h.formEncType,h,null),tn(i,r,"formMethod",h.formMethod,h,null),tn(i,r,"formTarget",h.formTarget,h,null)):(tn(i,r,"encType",h.encType,h,null),tn(i,r,"method",h.method,h,null),tn(i,r,"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(s(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(s(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,r,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(s(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof c=="string"?Hr(i,c):(typeof c=="number"||typeof c=="bigint")&&Hr(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(!Ts.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),r=a.slice(2,h?a.length-7:void 0),m=i[Ye]||null,m=m!=null?m[a]:null,typeof m=="function"&&i.removeEventListener(r,m,h),typeof c=="function")){typeof m!="function"&&m!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(r,c,h);break e}a in i?i[a]=c:c===!0?i.setAttribute(a,""):Xn(i,a,c)}}}function xi(i,r,a){switch(r){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(s(137,r));default:tn(i,r,m,y,a,null)}}h&&tn(i,r,"srcSet",a.srcSet,a,null),c&&tn(i,r,"src",a.src,a,null);return;case"input":At("invalid",i);var D=m=y=h=null,H=null,he=null;for(c in a)if(a.hasOwnProperty(c)){var we=a[c];if(we!=null)switch(c){case"name":h=we;break;case"type":y=we;break;case"checked":H=we;break;case"defaultChecked":he=we;break;case"value":m=we;break;case"defaultValue":D=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(s(137,r));break;default:tn(i,r,c,we,a,null)}}is(i,m,D,H,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,r,h,D,a,null)}r=m,a=y,i.multiple=!!c,r!=null?Vi(i,!!c,r,!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(s(91));break;default:tn(i,r,y,D,a,null)}Ns(i,c,h,m);return;case"option":for(H in a)a.hasOwnProperty(H)&&(c=a[H],c!=null)&&(H==="selected"?i.selected=c&&typeof c!="function"&&typeof c!="symbol":tn(i,r,H,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(s(137,r));default:tn(i,r,he,c,a,null)}return;default:if(rr(r)){for(we in a)a.hasOwnProperty(we)&&(c=a[we],c!==void 0&&ug(i,r,we,c,a,void 0));return}}for(D in a)a.hasOwnProperty(D)&&(c=a[D],c!=null&&tn(i,r,D,c,a,null))}function bR(i,r,a,c){switch(r){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,H=null,he=null,we=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":H=Ee;default:c.hasOwnProperty(ye)||tn(i,r,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":we=ye;break;case"value":y=ye;break;case"defaultValue":D=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(s(137,r));break;default:ye!==Ee&&tn(i,r,me,ye,c,Ee)}}_i(i,y,D,H,he,we,m,h);return;case"select":ye=y=D=me=null;for(m in a)if(H=a[m],a.hasOwnProperty(m)&&H!=null)switch(m){case"value":break;case"multiple":ye=H;default:c.hasOwnProperty(m)||tn(i,r,m,null,c,H)}for(h in c)if(m=c[h],H=a[h],c.hasOwnProperty(h)&&(m!=null||H!=null))switch(h){case"value":me=m;break;case"defaultValue":D=m;break;case"multiple":y=m;default:m!==H&&tn(i,r,h,m,c,H)}r=D,a=y,c=ye,me!=null?Vi(i,!!a,me,!1):!!c!=!!a&&(r!=null?Vi(i,!!a,r,!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,r,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(s(91));break;default:h!==m&&tn(i,r,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,r,Ge,null,c,me));for(H in c)me=c[H],ye=a[H],c.hasOwnProperty(H)&&me!==ye&&(me!=null||ye!=null)&&(H==="selected"?i.selected=me&&typeof me!="function"&&typeof me!="symbol":tn(i,r,H,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,r,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(s(137,r));break;default:tn(i,r,he,me,c,ye)}return;default:if(rr(r)){for(var nn in a)me=a[nn],a.hasOwnProperty(nn)&&me!==void 0&&!c.hasOwnProperty(nn)&&ug(i,r,nn,void 0,c,me);for(we in c)me=c[we],ye=a[we],!c.hasOwnProperty(we)||me===ye||me===void 0&&ye===void 0||ug(i,r,we,me,c,ye);return}}for(var te in a)me=a[te],a.hasOwnProperty(te)&&me!=null&&!c.hasOwnProperty(te)&&tn(i,r,te,null,c,me);for(Ee in c)me=c[Ee],ye=a[Ee],!c.hasOwnProperty(Ee)||me===ye||me==null&&ye==null||tn(i,r,Ee,me,c,ye)}function fw(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function yR(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=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&&fw(y)){for(y=0,D=h.responseEnd,c+=1;c<a.length;c++){var H=a[c],he=H.startTime;if(he>D)break;var we=H.transferSize,Ee=H.initiatorType;we&&fw(Ee)&&(H=H.responseEnd,y+=we*(H<D?1:(D-he)/(H-he)))}if(--c,r+=8*(m+y)/(h.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var dg=null,hg=null;function Lh(i){return i.nodeType===9?i:i.ownerDocument}function pw(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 mw(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function fg(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var pg=null;function SR(){var i=window.event;return i&&i.type==="popstate"?i===pg?!1:(pg=i,!0):(pg=null,!1)}var gw=typeof setTimeout=="function"?setTimeout:void 0,wR=typeof clearTimeout=="function"?clearTimeout:void 0,vw=typeof Promise=="function"?Promise:void 0,xR=typeof queueMicrotask=="function"?queueMicrotask:typeof vw<"u"?function(i){return vw.resolve(null).then(i).catch(CR)}:gw;function CR(i){setTimeout(function(){throw i})}function Wa(i){return i==="head"}function _w(i,r){var a=r,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),sc(r);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);sc(r)}function bw(i,r){var a=i;i=0;do{var c=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),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 r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":mg(a),Ai(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function kR(i,r,a,c){for(;i.nodeType===1;){var h=a;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(c){if(!i[Ft])switch(r){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(r==="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=Nr(i.nextSibling),i===null)break}return null}function TR(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Nr(i.nextSibling),i===null))return null;return i}function yw(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=Nr(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 ER(i,r){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||a.readyState!=="loading")r();else{var c=function(){r(),a.removeEventListener("DOMContentLoaded",c)};a.addEventListener("DOMContentLoaded",c),i._reactRetry=c}}function Nr(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var _g=null;function Sw(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return Nr(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function ww(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return i;r--}else a!=="/$"&&a!=="/&"||r++}i=i.previousSibling}return null}function xw(i,r,a){switch(r=Lh(a),i){case"html":if(i=r.documentElement,!i)throw Error(s(452));return i;case"head":if(i=r.head,!i)throw Error(s(453));return i;case"body":if(i=r.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function wu(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Ai(i)}var Mr=new Map,Cw=new Set;function jh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Js=R.d;R.d={f:RR,r:DR,D:NR,C:MR,L:AR,m:LR,X:OR,S:jR,M:BR};function RR(){var i=Js.f(),r=kh();return i||r}function DR(i){var r=$n(i);r!==null&&r.tag===5&&r.type==="form"?US(r):Js.r(i)}var nc=typeof document>"u"?null:document;function kw(i,r,a){var c=nc;if(c&&typeof r=="string"&&r){var h=On(r);h='link[rel="'+i+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),Cw.has(h)||(Cw.add(h),i={rel:i,crossOrigin:a,href:r},c.querySelector(h)===null&&(r=c.createElement("link"),xi(r,"link",i),pn(r),c.head.appendChild(r)))}}function NR(i){Js.D(i),kw("dns-prefetch",i,null)}function MR(i,r){Js.C(i,r),kw("preconnect",i,r)}function AR(i,r,a){Js.L(i,r,a);var c=nc;if(c&&i&&r){var h='link[rel="preload"][as="'+On(r)+'"]';r==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+On(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+On(a.imageSizes)+'"]')):h+='[href="'+On(i)+'"]';var m=h;switch(r){case"style":m=ic(i);break;case"script":m=rc(i)}Mr.has(m)||(i=_({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),Mr.set(m,i),c.querySelector(h)!==null||r==="style"&&c.querySelector(xu(m))||r==="script"&&c.querySelector(Cu(m))||(r=c.createElement("link"),xi(r,"link",i),pn(r),c.head.appendChild(r)))}}function LR(i,r){Js.m(i,r);var a=nc;if(a&&i){var c=r&&typeof r.as=="string"?r.as:"script",h='link[rel="modulepreload"][as="'+On(c)+'"][href="'+On(i)+'"]',m=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=rc(i)}if(!Mr.has(m)&&(i=_({rel:"modulepreload",href:i},r),Mr.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 jR(i,r,a){Js.S(i,r,a);var c=nc;if(c&&i){var h=Ki(c).hoistableStyles,m=ic(i);r=r||"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":r},a),(a=Mr.get(m))&&bg(i,a);var H=y=c.createElement("link");pn(H),xi(H,"link",i),H._p=new Promise(function(he,we){H.onload=he,H.onerror=we}),H.addEventListener("load",function(){D.loading|=1}),H.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Oh(y,r,c)}y={type:"stylesheet",instance:y,count:1,state:D},h.set(m,y)}}}function OR(i,r){Js.X(i,r);var a=nc;if(a&&i){var c=Ki(a).hoistableScripts,h=rc(i),m=c.get(h);m||(m=a.querySelector(Cu(h)),m||(i=_({src:i,async:!0},r),(r=Mr.get(h))&&yg(i,r),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 BR(i,r){Js.M(i,r);var a=nc;if(a&&i){var c=Ki(a).hoistableScripts,h=rc(i),m=c.get(h);m||(m=a.querySelector(Cu(h)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Mr.get(h))&&yg(i,r),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 Tw(i,r,a,c){var h=(h=le.current)?jh(h):null;if(!h)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=ic(a.href),a=Ki(h).hoistableStyles,c=a.get(r),c||(c={type:"style",instance:null,count:0,state:null},a.set(r,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),Mr.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},Mr.set(i,a),m||IR(h,i,a,y.state))),r&&c===null)throw Error(s(528,""));return y}if(r&&c!==null)throw Error(s(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=rc(a),a=Ki(h).hoistableScripts,c=a.get(r),c||(c={type:"script",instance:null,count:0,state:null},a.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function ic(i){return'href="'+On(i)+'"'}function xu(i){return'link[rel="stylesheet"]['+i+"]"}function Ew(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function IR(i,r,a,c){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=i.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),xi(r,"link",a),pn(r),i.head.appendChild(r))}function rc(i){return'[src="'+On(i)+'"]'}function Cu(i){return"script[async]"+i}function Rw(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var c=i.querySelector('style[data-href~="'+On(a.href)+'"]');if(c)return r.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),r.instance=c;case"stylesheet":h=ic(a.href);var m=i.querySelector(xu(h));if(m)return r.state.loading|=4,r.instance=m,pn(m),m;c=Ew(a),(h=Mr.get(h))&&bg(c,h),m=(i.ownerDocument||i).createElement("link"),pn(m);var y=m;return y._p=new Promise(function(D,H){y.onload=D,y.onerror=H}),xi(m,"link",c),r.state.loading|=4,Oh(m,a.precedence,i),r.instance=m;case"script":return m=rc(a.src),(h=i.querySelector(Cu(m)))?(r.instance=h,pn(h),h):(c=a,(h=Mr.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),r.instance=h);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Oh(c,a.precedence,i));return r.instance}function Oh(i,r,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===r)m=D;else if(m!==h)break}m?m.parentNode.insertBefore(i,m.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function bg(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function yg(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var Bh=null;function Dw(i,r,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[xe]||i==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var y=m.getAttribute(r)||"";y=i+y;var D=c.get(y);D?D.push(m):c.set(y,[m])}}return c}function Nw(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function PR(i,r,a){if(a===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(i=r.disabled,typeof r.precedence=="string"&&i==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Mw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function zR(i,r,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=r.querySelector(xu(h));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Ih.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=m,pn(m);return}m=r.ownerDocument||r,c=Ew(c),(h=Mr.get(h))&&bg(c,h),m=m.createElement("link"),pn(m);var y=m;y._p=new Promise(function(D,H){y.onload=D,y.onerror=H}),xi(m,"link",c),a.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Ih.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Sg=0;function HR(i,r){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+r);0<i.imgBytes&&Sg===0&&(Sg=62500*yR());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)+r);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,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ph=new Map,r.forEach(UR,i),Ph=null,Ih.call(i))}function UR(i,r){if(!(r.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=r.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)),r.state.loading|=4}}var ku={$$typeof:z,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function $R(i,r,a,c,h,m,y,D,H){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=sn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sn(0),this.hiddenUpdates=sn(null),this.identifierPrefix=c,this.onUncaughtError=h,this.onCaughtError=m,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function Aw(i,r,a,c,h,m,y,D,H,he,we,Ee){return i=new $R(i,r,a,y,H,he,we,Ee,D),r=1,m===!0&&(r|=24),m=ar(3,null,null,r),i.current=m,m.stateNode=i,r=em(),r.refCount++,i.pooledCache=r,r.refCount++,m.memoizedState={element:c,isDehydrated:a,cache:r},rm(m),i}function Lw(i){return i?(i=Ol,i):Ol}function jw(i,r,a,c,h,m){h=Lw(h),c.context===null?c.context=h:c.pendingContext=h,c=La(r),c.payload={element:a},m=m===void 0?null:m,m!==null&&(c.callback=m),a=ja(i,c,r),a!==null&&(tr(a,i,r),iu(a,i,r))}function Ow(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function wg(i,r){Ow(i,r),(i=i.alternate)&&Ow(i,r)}function Bw(i){if(i.tag===13||i.tag===31){var r=Ho(i,67108864);r!==null&&tr(r,i,67108864),wg(i,67108864)}}function Iw(i){if(i.tag===13||i.tag===31){var r=dr();r=vi(r);var a=Ho(i,r);a!==null&&tr(a,i,r),wg(i,r)}}var Hh=!0;function FR(i,r,a,c){var h=O.T;O.T=null;var m=R.p;try{R.p=2,xg(i,r,a,c)}finally{R.p=m,O.T=h}}function WR(i,r,a,c){var h=O.T;O.T=null;var m=R.p;try{R.p=8,xg(i,r,a,c)}finally{R.p=m,O.T=h}}function xg(i,r,a,c){if(Hh){var h=Cg(c);if(h===null)cg(i,r,c,Uh,a),zw(i,c);else if(qR(h,i,r,a,c))c.stopPropagation();else if(zw(i,c),r&4&&-1<KR.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=yt(m.pendingLanes);if(y!==0){var D=m;for(D.pendingLanes|=2,D.entangledLanes|=2;y;){var H=1<<31-Ct(y);D.entanglements[1]|=H,y&=~H}ms(m),(Kt&6)===0&&(xh=We()+500,bu(0))}}break;case 31:case 13:D=Ho(m,2),D!==null&&tr(D,m,2),kh(),wg(m,2)}if(m=Cg(c),m===null&&cg(i,r,c,Uh,a),m===h)break;h=m}h!==null&&c.stopPropagation()}else cg(i,r,c,null,a)}}function Cg(i){return i=yr(i),kg(i)}var Uh=null;function kg(i){if(Uh=null,i=vr(i),i!==null){var r=l(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=u(r),i!==null)return i;i=null}else if(a===31){if(i=f(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return Uh=i,null}function Pw(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(He()){case vt:return 2;case wt: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=[],KR="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 zw(i,r){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(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Eu.delete(r.pointerId)}}function Ru(i,r,a,c,h,m){return i===null||i.nativeEvent!==m?(i={blockedOn:r,domEventName:a,eventSystemFlags:c,nativeEvent:m,targetContainers:[h]},r!==null&&(r=$n(r),r!==null&&Bw(r)),i):(i.eventSystemFlags|=c,r=i.targetContainers,h!==null&&r.indexOf(h)===-1&&r.push(h),i)}function qR(i,r,a,c,h){switch(r){case"focusin":return Ka=Ru(Ka,i,r,a,c,h),!0;case"dragenter":return qa=Ru(qa,i,r,a,c,h),!0;case"mouseover":return Va=Ru(Va,i,r,a,c,h),!0;case"pointerover":var m=h.pointerId;return Tu.set(m,Ru(Tu.get(m)||null,i,r,a,c,h)),!0;case"gotpointercapture":return m=h.pointerId,Eu.set(m,Ru(Eu.get(m)||null,i,r,a,c,h)),!0}return!1}function Hw(i){var r=vr(i.target);if(r!==null){var a=l(r);if(a!==null){if(r=a.tag,r===13){if(r=u(a),r!==null){i.blockedOn=r,kt(i.priority,function(){Iw(a)});return}}else if(r===31){if(r=f(a),r!==null){i.blockedOn=r,kt(i.priority,function(){Iw(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function $h(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=Cg(i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);Ur=c,a.target.dispatchEvent(c),Ur=null}else return r=$n(a),r!==null&&Bw(r),i.blockedOn=a,!1;r.shift()}return!0}function Uw(i,r,a){$h(i)&&a.delete(r)}function VR(){Tg=!1,Ka!==null&&$h(Ka)&&(Ka=null),qa!==null&&$h(qa)&&(qa=null),Va!==null&&$h(Va)&&(Va=null),Tu.forEach(Uw),Eu.forEach(Uw)}function Fh(i,r){i.blockedOn===r&&(i.blockedOn=null,Tg||(Tg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,VR)))}var Wh=null;function $w(i){Wh!==i&&(Wh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Wh===i&&(Wh=null);for(var r=0;r<i.length;r+=3){var a=i[r],c=i[r+1],h=i[r+2];if(typeof c!="function"){if(kg(c||a)===null)continue;break}var m=$n(a);m!==null&&(i.splice(r,3),r-=3,Cm(m,{pending:!0,data:h,method:a.method,action:c},c,h))}}))}function sc(i){function r(H){return Fh(H,i)}Ka!==null&&Fh(Ka,i),qa!==null&&Fh(qa,i),Va!==null&&Fh(Va,i),Tu.forEach(r),Eu.forEach(r);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);)Hw(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||$w(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),$w(a)}}}function Fw(){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 r(){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",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){c=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),h!==null&&(h(),h=null)}}}function Eg(i){this._internalRoot=i}Kh.prototype.render=Eg.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,c=dr();jw(a,c,i,r,null,null)},Kh.prototype.unmount=Eg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;jw(i.current,2,null,i,null,null),kh(),r[Xe]=null}};function Kh(i){this._internalRoot=i}Kh.prototype.unstable_scheduleHydration=function(i){if(i){var r=dt();i={blockedOn:null,target:i,priority:r};for(var a=0;a<Ya.length&&r!==0&&r<Ya[a].priority;a++);Ya.splice(a,0,i),a===0&&Hw(i)}};var Ww=t.version;if(Ww!=="19.2.6")throw Error(s(527,Ww,"19.2.6"));R.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=p(r),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var YR={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,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(YR),ut=qh}catch{}}return Nu.createRoot=function(i,r){if(!o(i))throw Error(s(299));var a=!1,c="",h=ZS,m=QS,y=JS;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(h=r.onUncaughtError),r.onCaughtError!==void 0&&(m=r.onCaughtError),r.onRecoverableError!==void 0&&(y=r.onRecoverableError)),r=Aw(i,1,!1,null,null,a,c,null,h,m,y,Fw),i[Xe]=r.current,lg(i),new Eg(r)},Nu.hydrateRoot=function(i,r,a){if(!o(i))throw Error(s(299));var c=!1,h="",m=ZS,y=QS,D=JS,H=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&&(H=a.formState)),r=Aw(i,1,!0,r,a??null,c,h,H,m,y,D,Fw),r.context=Lw(null),a=r.current,c=dr(),c=vi(c),h=La(c),h.callback=null,ja(a,h,c),a=c,r.current.lanes=a,hn(r,a),ms(r),i[Xe]=r.current,lg(i),new Kh(r)},Nu.version="19.2.6",Nu}var e1;function rD(){if(e1)return Ng.exports;e1=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=iD(),Ng.exports}var sD=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,s=e.files.map((o,l)=>({fieldName:`file${l}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[o,l]of e.files.entries())n.append(`file${o}`,l.file);return new Promise((o,l)=>{let u=!1;const f=()=>{e.signal?.removeEventListener("abort",b)},g=_=>{u||(u=!0,f(),o(_))},p=_=>{u||(u=!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,aD(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 aD(e,t){try{const n=JSON.parse(e),s=typeof n.error=="string"?n.error:n.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}class Hn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function up(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${bs(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",it("POST",t)),login:t=>Ne(e,"/api/auth/login",it("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",it("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await cc(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await cc(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),addAgent:t=>Ne(e,"/api/agents",it("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await cc(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ne(e,"/api/stats"),getAgentStats:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ne(e,"/api/version"),checkUpdate:()=>Ne(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ne(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Ne(e,`/api/code-server/status${bs(t)}`),installCodeServer:()=>Ne(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ne(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Ne(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>Ne(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>Ne(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),getFavorites:()=>Ne(e,"/api/favorites"),saveFavorites:t=>Ne(e,"/api/favorites",it("PUT",t)),listTerminals:()=>Ne(e,"/api/terminals"),getTerminalLayout:()=>Ne(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ne(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",it("POST",t)),listFiles:t=>Ne(e,"/api/files/list",it("POST",t)),readFile:t=>Ne(e,"/api/files/read",it("POST",t)),writeFile:t=>Ne(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",it("POST",t)),previewFile:t=>LC(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await cc(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${bs(n)}`),getTerminalTranscriptHistory:(t,n={},s)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${bs(n)}`,s?{signal:s}:void 0),searchTerminalTranscript:(t,n,s)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-search`,{...it("POST",n),...s?{signal:s}:{}}),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${bs(s)}`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Ne(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)=>Ne(e,`/api/push-notifications/status${t||n?bs({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Ne(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>Ne(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>Ne(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>Ne(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>Ne(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>Ne(e,"/api/push-notifications/test",it("POST",t))}}function Zr(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{transcriptCacheScope:e?`agent:${e}`:"local",isAgent:e!==null,listTerminals:()=>Ne(t,n("terminals")),createTerminal:(s={})=>Ne(t,n("terminals"),it("POST",s)),closeTerminal:async s=>{await cc(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>Ne(t,n(`terminals/${encodeURIComponent(s)}`),it("PATCH",{title:o})),getTerminalHistory:(s,o={})=>Ne(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${bs(o)}`),getTerminalTranscriptHistory:(s,o={},l)=>Ne(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${bs(o)}`,l?{signal:l}:void 0),searchTerminalTranscript:(s,o,l)=>Ne(t,n(`terminals/${encodeURIComponent(s)}/transcript-search`),{...it("POST",o),...l?{signal:l}:{}}),getTerminalTranscriptSource:s=>Ne(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalSubagents:s=>Ne(t,n(`terminals/${encodeURIComponent(s)}/subagents`)),getTerminalSubagentTranscriptHistory:(s,o,l={})=>Ne(t,`${n(`terminals/${encodeURIComponent(s)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${bs(l)}`),getTerminalLayout:()=>Ne(t,n("terminal-layout")),saveTerminalLayout:s=>Ne(t,n("terminal-layout"),it("PUT",s)),createFileRoot:s=>Ne(t,n("files/root"),it("POST",s)),listFiles:s=>Ne(t,n("files/list"),it("POST",s)),readFile:s=>Ne(t,n("files/read"),it("POST",s)),writeFile:s=>Ne(t,n("files/write"),it("POST",s)),createFileEntry:s=>Ne(t,n("files/create"),it("POST",s)),moveFileEntry:s=>Ne(t,n("files/move"),it("POST",s)),previewDeleteFileEntry:s=>Ne(t,n("files/delete-preview"),it("POST",s)),deleteFileEntry:s=>Ne(t,n("files/delete"),it("POST",s)),openFileInTerminal:s=>Ne(t,n("files/open"),it("POST",s)),previewFile:s=>LC(t,n("files/preview"),it("POST",s)),uploadComposeAttachments:s=>AC({...s,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>Ne(t,n("attachments/limits")),deleteComposeAttachments:s=>Ne(t,n("attachments/delete"),it("POST",s)),getCodeServerStatus:(s={})=>Ne(t,`${n("code-server/status")}${bs(s)}`),installCodeServer:()=>Ne(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ne(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>Ne(t,n("code-server/open"),it("POST",s)),stopCodeServer:(s={})=>Ne(t,n("code-server/stop"),it("POST",s)),uninstallCodeServer:()=>Ne(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getProviderHooks:s=>Ne(t,n(`hooks/${s}`)),installProviderHooks:s=>Ne(t,n(`hooks/${s}/install`),{method:"POST",credentials:"same-origin"}),removeProviderHooks:s=>Ne(t,n(`hooks/${s}/remove`),{method:"POST",credentials:"same-origin"}),checkProviderHookTrust:s=>Ne(t,n(`hooks/${s}/trust`)),trustProviderHooks:s=>Ne(t,n(`hooks/${s}/trust`),{method:"POST",credentials:"same-origin"}),getAccounts:()=>Ne(t,n("accounts")),getAccountUsage:s=>Ne(t,n(`accounts/${s}/usage`),{method:"POST",credentials:"same-origin"}),getServerProcesses:()=>Ne(t,n("server-info/processes")),renameServerProject:(s,o)=>Ne(t,n("server-info/project-name"),it("POST",{path:s,name:o})),getServerExternalIp:(s=!1)=>Ne(t,n("server-info/external-ip")+(s?"?refresh=1":"")),selectAccount:(s,o)=>Ne(t,n(`accounts/${s}/select`),it("POST",{profileId:o})),removeAccount:(s,o)=>Ne(t,n(`accounts/${s}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:s=>Ne(t,n(`accounts/${s}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(s,o)=>Ne(t,n(`accounts/${s}/login/complete`),it("POST",{label:o})),cancelAccountLogin:s=>Ne(t,n(`accounts/${s}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(s,o)=>Ne(t,n(`accounts/${s}/refresh`),it("POST",o?{profileId:o}:{})),terminateProviderSessions:s=>Ne(t,n(`accounts/${s}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,o=window.location.href)=>oD(n(`terminals/${encodeURIComponent(s)}/ws`),o)}}function oD(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 bs(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 Ne(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await Ob(s);try{return await s.json()}catch{throw new Hn(s.status,"invalid_json_response")}}async function cc(e,t,n){const s=await e(t,n);await Ob(s)}async function LC(e,t,n){const s=await e(t,n);return await Ob(s),s.blob()}async function Ob(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),s=typeof n.error=="string"?n.error:n.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new Hn(e.status,t)}const Bb="nterminal.theme.id",jC="nterminal.theme.accent",Iv="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",...t1({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",...t1({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 Ib(e){return Af.find(t=>t.id===e)??Af[0]}function po(){if(typeof window>"u")return Rc;try{const e=window.localStorage.getItem(Bb);return e?dp(e):hD(window.localStorage.getItem(jC))}catch{return Rc}}function lD(e){const t=dp(e);if(typeof window<"u"){try{window.localStorage.setItem(Bb,t)}catch{}Pb(t),window.dispatchEvent(new CustomEvent(Iv,{detail:t}))}return t}function Pb(e=po()){if(typeof document>"u")return;const t=Ib(dp(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),bt(n,"--nt-bg",t.tokens.bg),bt(n,"--nt-bg-2",t.tokens.bg2),bt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),bt(n,"--nt-line",t.tokens.line),bt(n,"--nt-line-2",t.tokens.line2),bt(n,"--nt-fg",t.tokens.fg),bt(n,"--nt-fg-2",t.tokens.fg2),bt(n,"--nt-fg-3",t.tokens.fg3),bt(n,"--nt-fg-4",t.tokens.fg4),bt(n,"--nt-accent",t.tokens.accent),bt(n,"--nt-accent-soft",t.tokens.accentSoft),bt(n,"--nt-accent-glow",t.tokens.accentGlow),bt(n,"--nt-on-accent",t.tokens.onAccent),bt(n,"--nt-ok",t.tokens.ok),bt(n,"--nt-working",t.tokens.working),bt(n,"--nt-unread",t.tokens.unread),bt(n,"--nt-on-unread",t.tokens.onUnread),bt(n,"--nt-danger",t.tokens.danger),bt(n,"--nt-on-danger",t.tokens.onDanger),bt(n,"--nt-danger-soft",t.tokens.dangerSoft),bt(n,"--nt-danger-line",t.tokens.dangerLine),bt(n,"--nt-warning",t.tokens.warning),bt(n,"--nt-warn",t.tokens.warning),bt(n,"--nt-warning-soft",t.tokens.warningSoft),bt(n,"--nt-warning-glow",t.tokens.warningGlow),bt(n,"--nt-scrim",t.tokens.scrim),bt(n,"--nt-scrim-soft",t.tokens.scrimSoft),bt(n,"--nt-shadow",t.tokens.shadow),bt(n,"--nt-shadow-strong",t.tokens.shadowStrong),bt(n,"--nt-floating-bg",t.tokens.floatingBg),bt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),bt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),bt(n,"--nt-subtle-fill",t.tokens.subtleFill),bt(n,"--nt-hover-fill",t.tokens.hoverFill),bt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),bt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),bt(n,"--nt-transcript-user",t.tokens.transcriptUser),bt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),bt(n,"--nt-transcript-tool",t.tokens.transcriptTool),bt(n,"--nt-transcript-command",t.tokens.transcriptCommand),bt(n,"--nt-transcript-code",t.tokens.transcriptCode),bt(n,"--nt-transcript-search",t.tokens.transcriptSearch),bt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),bt(n,"--nt-qr-bg",t.tokens.qrBg)}function cD(e=po()){return Ib(dp(e)).xterm}function zb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Bb||n.key===jC)&&(Pb(po()),e())};return window.addEventListener(Iv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Iv,e),window.removeEventListener("storage",t)}}function bt(e,t,n){e.style.setProperty(t,n)}function t1(e){const t=uD(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 uD(e){const t=[];for(let n=16;n<=e;n+=1)t.push(dD(n));return t}function dD(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],s=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],l=n[t%6];return n1(s,o,l)}if(e>=232&&e<=255){const t=8+(e-232)*10;return n1(t,t,t)}return"#000000"}function n1(e,t,n){return`#${jg(e)}${jg(t)}${jg(n)}`}function jg(e){return e.toString(16).padStart(2,"0")}function hD(e){return e==="signal-red"?"signal-red":Rc}function OC(){const e=v.useSyncExternalStore(zb,po,()=>Rc);return Ib(e).mode==="light"?"-light":""}function BC({size:e=22}){const t=OC();return d.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 d.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var $u=MC();function fD(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>s=>{t.forEach(o=>o(s))},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 Hb(e){return"nodeType"in e}function $i(e){var t,n;return e?Oc(e)?e:Hb(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ub(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:Hb(e)?Ub(e)?e:Ad(e)||PC(e)?e.ownerDocument:document:document:document}const Jr=hp?v.useLayoutEffect:v.useEffect;function fp(e){const t=v.useRef(e);return Jr(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return t.current==null?void 0:t.current(...s)},[])}function pD(){const e=v.useRef(null),t=v.useCallback((s,o)=>{e.current=setInterval(s,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function cd(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Jr(()=>{n.current!==e&&(n.current=e)},t),n}function Ld(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function Lf(e){const t=fp(e),n=v.useRef(null),s=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,s]}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,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return s.reduce((l,u)=>{const f=Object.entries(u);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 mD(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 gD(e){if(!e)return!1;const{TouchEvent:t}=$i(e.target);return t&&e instanceof t}function Bf(e){if(gD(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 mD(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:s}=e;return t+" "+n+"ms "+s}}}),i1="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function vD(e){return e.matches(i1)?e:e.querySelector(i1)}const _D={display:"none"};function bD(e){let{id:t,value:n}=e;return zt.createElement("div",{id:t,style:_D},n)}function yD(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return zt.createElement("div",{id:t,style:o,role:"status","aria-live":s,"aria-atomic":!0},n)}function SD(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const HC=v.createContext(null);function wD(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 xD(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:o,event:l}=s;e.forEach(u=>{var f;return(f=u[o])==null?void 0:f.call(u,l)})},[e]),t]}const CD={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
|
-
`},kD={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 TD(e){let{announcements:t=kD,container:n,hiddenTextDescribedById:s,screenReaderInstructions:o=CD}=e;const{announce:l,announcement:u}=SD(),f=jd("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),wD(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(bD,{id:s,value:o.draggable}),zt.createElement(yD,{id:f,announcement:u}));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(s=>s!=null),[...t])}const es=Object.freeze({x:0,y:0});function ED(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function RD(e,t){const n=Bf(e);if(!n)return"0 0";const s={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return s.x+"% "+s.y+"%"}function DD(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return n-s}function ND(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function MD(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function r1(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 AD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=r1(t,t.left,t.top),l=[];for(const u of s){const{id:f}=u,g=n.get(f);if(g){const p=ED(r1(g),o);l.push({id:f,data:{droppableContainer:u,value:p}})}}return l.sort(DD)};function LD(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),u=o-s,f=l-n;if(s<o&&n<l){const g=t.width*t.height,p=e.width*e.height,b=u*f,_=b/(g+p-b);return Number(_.toFixed(4))}return 0}const jD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=[];for(const l of s){const{id:u}=l,f=n.get(u);if(f){const g=LD(f,t);g>0&&o.push({id:u,data:{droppableContainer:l,value:g}})}}return o.sort(ND)};function OD(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}:es}function BD(e){return function(n){for(var s=arguments.length,o=new Array(s>1?s-1:0),l=1;l<s;l++)o[l-1]=arguments[l];return o.reduce((u,f)=>({...u,top:u.top+e*f.y,bottom:u.bottom+e*f.y,left:u.left+e*f.x,right:u.right+e*f.x}),{...n})}}const ID=BD(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 PD(e,t,n){const s=FC(t);if(!s)return e;const{scaleX:o,scaleY:l,x:u,y:f}=s,g=e.left-u-(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 zD={ignoreTransform:!1};function Ic(e,t){t===void 0&&(t=zD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:b}=$i(e).getComputedStyle(e);p&&(n=PD(n,p,b))}const{top:s,left:o,width:l,height:u,bottom:f,right:g}=n;return{top:s,left:o,width:l,height:u,bottom:f,right:g}}function s1(e){return Ic(e,{ignoreTransform:!0})}function HD(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function UD(e,t){return t===void 0&&(t=$i(e).getComputedStyle(e)),t.position==="fixed"}function $D(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 $b(e,t){const n=[];function s(o){if(t!=null&&n.length>=t||!o)return n;if(Ub(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&&$D(o,l)&&n.push(o),UD(o,l)?n:s(o.parentNode)}return e?s(e):n}function WC(e){const[t]=$b(e,1);return t??null}function Bg(e){return!hp||!e?null:Oc(e)?e:Hb(e)?Ub(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 Pv(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},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,u=e.scrollTop>=s.y,f=e.scrollLeft>=s.x;return{isTop:o,isLeft:l,isBottom:u,isRight:f,maxScroll:s,minScroll:t}}const FD={x:.2,y:.2};function WD(e,t,n,s,o){let{top:l,left:u,right:f,bottom:g}=n;s===void 0&&(s=10),o===void 0&&(o=FD);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=s*Math.abs((t.top+T.height-l)/T.height)):!b&&g>=t.bottom-T.height&&(C.y=di.Forward,x.y=s*Math.abs((t.bottom-T.height-g)/T.height)),!w&&f>=t.right-T.width?(C.x=di.Forward,x.x=s*Math.abs((t.right-T.width-f)/T.width)):!_&&u<=t.left+T.width&&(C.x=di.Backward,x.x=s*Math.abs((t.left+T.width-u)/T.width)),{direction:C,speed:x}}function KD(e){if(e===document.scrollingElement){const{innerWidth:l,innerHeight:u}=window;return{top:0,left:0,right:l,bottom:u,width:l,height:u}}const{top:t,left:n,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function GC(e){return e.reduce((t,n)=>Cc(t,Pv(n)),es)}function qD(e){return e.reduce((t,n)=>t+KC(n),0)}function VD(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:s,bottom:o,right:l}=t(e);WC(e)&&(o<=0||l<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const YD=[["x",["left","right"],qD],["y",["top","bottom"],VD]];class Fb{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=$b(n),o=GC(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,u,f]of YD)for(const g of u)Object.defineProperty(this,g,{get:()=>{const p=f(s),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 s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var o;(o=this.target)==null||o.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function GD(e){const{EventTarget:t}=$i(e);return e instanceof t?e:Bc(e)}function Ig(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var Or;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Or||(Or={}));function a1(e){e.preventDefault()}function XD(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]},ZD=(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(Or.Resize,this.handleCancel),this.windowListeners.add(Or.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Or.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&XC(s),n(es)}handleKeyDown(t){if(pp(t)){const{active:n,context:s,options:o}=this.props,{keyboardCodes:l=ZC,coordinateGetter:u=ZD,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}=s.current,b=p?{x:p.left,y:p.top}:es;this.referenceCoordinates||(this.referenceCoordinates=b);const _=u(t,{active:n,context:s.current,currentCoordinates:b});if(_){const w=Of(_,b),C={x:0,y:0},{scrollableAncestors:x}=s.current;for(const T of x){const M=t.code,{isTop:A,isRight:F,isLeft:z,isBottom:P,maxScroll:W,minScroll:$}=YC(T),L=KD(T),X={x:Math.min(M===qt.Right?L.right-L.width/2:L.right,Math.max(M===qt.Right?L.left:L.left+L.width/2,_.x)),y:Math.min(M===qt.Down?L.bottom-L.height/2:L.bottom,Math.max(M===qt.Down?L.top:L.top+L.height/2,_.y))},ge=M===qt.Right&&!F||M===qt.Left&&!z,ne=M===qt.Down&&!P||M===qt.Up&&!A;if(ge&&X.x!==_.x){const ie=T.scrollLeft+w.x,G=M===qt.Right&&ie<=W.x||M===qt.Left&&ie>=$.x;if(G&&!w.y){T.scrollTo({left:ie,behavior:f});return}G?C.x=T.scrollLeft-ie:C.x=M===qt.Right?T.scrollLeft-W.x:T.scrollLeft-$.x,C.x&&T.scrollBy({left:-C.x,behavior:f});break}else if(ne&&X.y!==_.y){const ie=T.scrollTop+w.y,G=M===qt.Down&&ie<=W.y||M===qt.Up&&ie>=$.y;if(G&&!w.x){T.scrollTo({top:ie,behavior:f});return}G?C.y=T.scrollTop-ie:C.y=M===qt.Down?T.scrollTop-W.y:T.scrollTop-$.y,C.y&&T.scrollBy({top:-C.y,behavior:f});break}}this.handleMove(t,Cc(Of(_,this.referenceCoordinates),C))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}QC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=ZC,onActivation:o}=t,{active:l}=n;const{code:u}=e.nativeEvent;if(s.start.includes(u)){const f=l.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function o1(e){return!!(e&&"distance"in e)}function l1(e){return!!(e&&"delay"in e)}class Wb{constructor(t,n,s){var o;s===void 0&&(s=GD(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:u}=l;this.props=t,this.events=n,this.document=Bc(u),this.documentListeners=new Qu(this.document),this.listeners=new Qu(s),this.windowListeners=new Qu($i(u)),this.initialCoordinates=(o=Bf(l))!=null?o:es,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Or.Resize,this.handleCancel),this.windowListeners.add(Or.DragStart,a1),this.windowListeners.add(Or.VisibilityChange,this.handleCancel),this.windowListeners.add(Or.ContextMenu,a1),this.documentListeners.add(Or.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(l1(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(o1(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Or.Click,XD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Or.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:o,props:l}=this,{onMove:u,options:{activationConstraint:f}}=l;if(!o)return;const g=(n=Bf(t))!=null?n:es,p=Of(o,g);if(!s&&f){if(o1(f)){if(f.tolerance!=null&&Ig(p,f.tolerance))return this.handleCancel();if(Ig(p,f.distance))return this.handleStart()}if(l1(f)&&Ig(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===qt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const QD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class JC extends Wb{constructor(t){const{event:n}=t,s=Bc(n.target);super(t,QD,s)}}JC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const JD={move:{name:"mousemove"},end:{name:"mouseup"}};var zv;(function(e){e[e.RightClick=2]="RightClick"})(zv||(zv={}));class Kb extends Wb{constructor(t){super(t,JD,Bc(t.event.target))}}Kb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===zv.RightClick?!1:(s?.({event:n}),!0)}}];const Pg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class qb extends Wb{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(){}}}qb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:o}=n;return o.length>1?!1:(s?.({event:n}),!0)}}];var 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 eN(e){let{acceleration:t,activator:n=Ju.Pointer,canScroll:s,draggingRect:o,enabled:l,interval:u=5,order:f=zf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:b,delta:_,threshold:w}=e;const C=nN({delta:_,disabled:!l}),[x,T]=pD(),M=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),F=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]),z=v.useRef(null),P=v.useCallback(()=>{const $=z.current;if(!$)return;const L=M.current.x*A.current.x,X=M.current.y*A.current.y;$.scrollBy(L,X)},[]),W=v.useMemo(()=>f===zf.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!l||!p.length||!F){T();return}for(const $ of W){if(s?.($)===!1)continue;const L=p.indexOf($),X=b[L];if(!X)continue;const{direction:ge,speed:ne}=WD($,X,F,t,w);for(const ie of["x","y"])C[ie][ge[ie]]||(ne[ie]=0,ge[ie]=0);if(ne.x>0||ne.y>0){T(),z.current=$,x(P,u),M.current=ne,A.current=ge;return}}M.current={x:0,y:0},A.current={x:0,y:0},T()},[t,P,s,T,l,u,JSON.stringify(F),JSON.stringify(C),x,p,W,b,JSON.stringify(w)])}const tN={x:{[di.Backward]:!1,[di.Forward]:!1},y:{[di.Backward]:!1,[di.Forward]:!1}};function nN(e){let{delta:t,disabled:n}=e;const s=jf(t);return Ld(o=>{if(n||!s||!o)return tN;const l={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.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,s])}function iN(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return Ld(o=>{var l;return t==null?null:(l=s??o)!=null?l:null},[s,t])}function rN(e,t){return v.useMemo(()=>e.reduce((n,s)=>{const{sensor:o}=s,l=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,s)}));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 Hv;(function(e){e.Optimized="optimized"})(Hv||(Hv={}));const c1=new Map;function sN(e,t){let{dragging:n,dependencies:s,config:o}=t;const[l,u]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,b=v.useRef(e),_=M(),w=cd(_),C=v.useCallback(function(A){A===void 0&&(A=[]),!w.current&&u(F=>F===null?A:F.concat(A.filter(z=>!F.includes(z))))},[w]),x=v.useRef(null),T=Ld(A=>{if(_&&!n)return c1;if(!A||A===c1||b.current!==e||l!=null){const F=new Map;for(let z of e){if(!z)continue;if(l&&l.length>0&&!l.includes(z.id)&&z.rect.current){F.set(z.id,z.rect.current);continue}const P=z.node.current,W=P?new Fb(g(P),P):null;z.rect.current=W,W&&F.set(z.id,W)}return F}return A},[e,l,n,_,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{_||C()},[n,_]),v.useEffect(()=>{l&&l.length>0&&u(null)},[JSON.stringify(l)]),v.useEffect(()=>{_||typeof f!="number"||x.current!==null||(x.current=setTimeout(()=>{C(),x.current=null},f))},[f,_,C,...s]),{droppableRects:T,measureDroppableContainers:C,measuringScheduled:l!=null};function M(){switch(p){case ud.Always:return!1;case ud.BeforeDragging:return n;default:return!n}}}function Vb(e,t){return Ld(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function aN(e,t){return Vb(e,t)}function oN(e){let{callback:t,disabled:n}=e;const s=fp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(s)},[s,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function mp(e){let{callback:t,disabled:n}=e;const s=fp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(s)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function lN(e){return new Fb(Ic(e),e)}function u1(e,t,n){t===void 0&&(t=lN);const[s,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 u=oN({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 Jr(()=>{l(),e?(f?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),u?.disconnect())},[e]),s}function cN(e){const t=Vb(e);return $C(e,t)}const d1=[];function uN(e){const t=v.useRef(e),n=Ld(s=>e?s&&s!==d1&&e&&t.current&&e.parentNode===t.current.parentNode?s:$b(e):d1,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function dN(e){const[t,n]=v.useState(null),s=v.useRef(e),o=v.useCallback(l=>{const u=Bg(l.target);u&&n(f=>f?(f.set(u,Pv(u)),new Map(f)):null)},[]);return v.useEffect(()=>{const l=s.current;if(e!==l){u(l);const f=e.map(g=>{const p=Bg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Pv(p)]):null}).filter(g=>g!=null);n(f.length?new Map(f):null),s.current=e}return()=>{u(e),u(l)};function u(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,u)=>Cc(l,u),es):GC(e):es,[e,t])}function h1(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==es;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?Of(e,n.current):es}function hN(e){v.useEffect(()=>{if(!hp)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function fN(e,t){return v.useMemo(()=>e.reduce((n,s)=>{let{eventName:o,handler:l}=s;return n[o]=u=>{l(u,t)},n},{}),[e,t])}function ek(e){return v.useMemo(()=>e?HD(e):null,[e])}const f1=[];function pN(e,t){t===void 0&&(t=Ic);const[n]=e,s=ek(n?$i(n):null),[o,l]=v.useState(f1);function u(){l(()=>e.length?e.map(g=>VC(g)?s:new Fb(t(g),g)):f1)}const f=mp({callback:u});return Jr(()=>{f?.disconnect(),u(),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 mN(e){let{measure:t}=e;const[n,s]=v.useState(null),o=v.useCallback(p=>{for(const{target:b}of p)if(Ad(b)){s(_=>{const w=t(b);return _?{..._,width:w.width,height:w.height}:w});break}},[t]),l=mp({callback:o}),u=v.useCallback(p=>{const b=tk(p);l?.disconnect(),b&&l?.observe(b),s(b?t(b):null)},[t,l]),[f,g]=Lf(u);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:g}),[n,f,g])}const gN=[{sensor:JC,options:{}},{sensor:QC,options:{}}],vN={current:{}},pf={draggable:{measure:s1},droppable:{measure:s1,strategy:ud.WhileDragging,frequency:Hv.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,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const _N={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(_N);function bN(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ed}}}function yN(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:s}=n,o=new ed(e.droppable.containers);return o.set(s,n),{...e,droppable:{...e.droppable,containers:o}}}case ni.SetDroppableDisabled:{const{id:n,key:s,disabled:o}=t,l=e.droppable.containers.get(n);if(!l||s!==l.key)return e;const u=new ed(e.droppable.containers);return u.set(n,{...l,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case ni.UnregisterDroppable:{const{id:n,key:s}=t,o=e.droppable.containers.get(n);if(!o||s!==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 SN(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:o}=v.useContext(Od),l=jf(s),u=jf(n?.id);return v.useEffect(()=>{if(!t&&!s&&l&&u!=null){if(!pp(l)||document.activeElement===l.target)return;const f=o.get(u);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 _=vD(b);if(_){_.focus();break}}})}},[s,t,o,u,l]),null}function rk(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((o,l)=>l({transform:o,...s}),n):n}function wN(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 xN(e){let{activeNode:t,measure:n,initialRect:s,config:o=!0}=e;const l=v.useRef(!1),{x:u,y:f}=typeof o=="boolean"?{x:o,y:o}:o;Jr(()=>{if(!u&&!f||!t){l.current=!1;return}if(l.current||!s)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const b=n(p),_=$C(b,s);if(u||(_.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,u,f,s,n])}const gp=v.createContext({...es,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 sk=v.memo(function(t){var n,s,o,l;let{id:u,accessibility:f,autoScroll:g=!0,children:p,sensors:b=gN,collisionDetection:_=jD,measuring:w,modifiers:C,...x}=t;const T=v.useReducer(yN,void 0,bN),[M,A]=T,[F,z]=xD(),[P,W]=v.useState(no.Uninitialized),$=P===no.Initialized,{draggable:{active:L,nodes:X,translate:ge},droppable:{containers:ne}}=M,ie=L!=null?X.get(L):null,G=v.useRef({initial:null,translated:null}),J=v.useMemo(()=>{var pt;return L!=null?{id:L,data:(pt=ie?.data)!=null?pt:vN,rect:G}:null},[L,ie]),ae=v.useRef(null),[ee,O]=v.useState(null),[R,I]=v.useState(null),se=cd(x,Object.values(x)),_e=jd("DndDescribedBy",u),N=v.useMemo(()=>ne.getEnabled(),[ne]),V=wN(w),{droppableRects:pe,measureDroppableContainers:Z,measuringScheduled:Q}=sN(N,{dragging:$,dependencies:[ge.x,ge.y],config:V.droppable}),le=iN(X,L),Te=v.useMemo(()=>R?Bf(R):null,[R]),je=at(),Fe=aN(le,V.draggable.measure);xN({activeNode:L!=null?X.get(L):null,config:je.layoutShiftCompensation,initialRect:Fe,measure:V.draggable.measure});const Se=u1(le,V.draggable.measure,Fe),ze=u1(le?le.parentElement:null),Oe=v.useRef({activatorEvent:null,active:null,activeNode:le,collisionRect:null,collisions:null,droppableRects:pe,draggableNodes:X,draggingNode:null,draggingNodeRect:null,droppableContainers:ne,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),j=ne.getNodeFor((n=Oe.current.over)==null?void 0:n.id),ve=mN({measure:V.dragOverlay.measure}),Ae=(s=ve.nodeRef.current)!=null?s:le,Ie=$?(o=ve.rect)!=null?o:Se:null,U=!!(ve.nodeRef.current&&ve.rect),de=cN(U?null:Se),ke=ek(Ae?$i(Ae):null),Me=uN($?j??le:null),Le=pN(Me),be=rk(C,{transform:{x:ge.x-de.x,y:ge.y-de.y,scaleX:1,scaleY:1},activatorEvent:R,active:J,activeNodeRect:Se,containerNodeRect:ze,draggingNodeRect:Ie,over:Oe.current.over,overlayNodeRect:ve.rect,scrollableAncestors:Me,scrollableAncestorRects:Le,windowRect:ke}),$e=Te?Cc(Te,ge):null,We=dN(Me),He=h1(We),vt=h1(We,[Se]),wt=Cc(be,He),lt=Ie?ID(Ie,be):null,Nt=J&<?_({active:J,collisionRect:lt,droppableRects:pe,droppableContainers:N,pointerCoordinates:$e}):null,Yt=MD(Nt,"id"),[rt,jn]=v.useState(null),Sn=U?be:Cc(be,vt),ut=OD(Sn,(l=rt?.rect)!=null?l:null,Se),Lt=v.useRef(null),Ct=v.useCallback((pt,yt)=>{let{sensor:It,options:$t}=yt;if(ae.current==null)return;const dn=X.get(ae.current);if(!dn)return;const Gt=pt.nativeEvent,sn=new It({active:ae.current,activeNode:dn,event:Gt,options:$t,context:Oe,onAbort(an){if(!X.get(an))return;const{onDragAbort:En}=se.current,wn={id:an};En?.(wn),F({type:"onDragAbort",event:wn})},onPending(an,ln,En,wn){if(!X.get(an))return;const{onDragPending:ri}=se.current,dt={id:an,constraint:ln,initialCoordinates:En,offset:wn};ri?.(dt),F({type:"onDragPending",event:dt})},onStart(an){const ln=ae.current;if(ln==null)return;const En=X.get(ln);if(!En)return;const{onDragStart:wn}=se.current,vi={activatorEvent:Gt,active:{id:ln,data:En.data,rect:G}};$u.unstable_batchedUpdates(()=>{wn?.(vi),W(no.Initializing),A({type:ni.DragStart,initialCoordinates:an,active:ln}),F({type:"onDragStart",event:vi}),O(Lt.current),I(Gt)})},onMove(an){A({type:ni.DragMove,coordinates:an})},onEnd:hn(ni.DragEnd),onCancel:hn(ni.DragCancel)});Lt.current=sn;function hn(an){return async function(){const{active:En,collisions:wn,over:vi,scrollAdjustedTranslate:ri}=Oe.current;let dt=null;if(En&&ri){const{cancelDrop:kt}=se.current;dt={activatorEvent:Gt,active:En,collisions:wn,delta:ri,over:vi},an===ni.DragEnd&&typeof kt=="function"&&await Promise.resolve(kt(dt))&&(an=ni.DragCancel)}ae.current=null,$u.unstable_batchedUpdates(()=>{A({type:an}),W(no.Uninitialized),jn(null),O(null),I(null),Lt.current=null;const kt=an===ni.DragEnd?"onDragEnd":"onDragCancel";if(dt){const oe=se.current[kt];oe?.(dt),F({type:kt,event:dt})}})}}},[X]),gi=v.useCallback((pt,yt)=>(It,$t)=>{const dn=It.nativeEvent,Gt=X.get($t);if(ae.current!==null||!Gt||dn.dndKit||dn.defaultPrevented)return;const sn={active:Gt};pt(It,yt.options,sn)===!0&&(dn.dndKit={capturedBy:yt.sensor},ae.current=$t,Ct(It,yt))},[X,Ct]),ki=rN(b,gi);hN(b),Jr(()=>{Se&&P===no.Initializing&&W(no.Initialized)},[Se,P]),v.useEffect(()=>{const{onDragMove:pt}=se.current,{active:yt,activatorEvent:It,collisions:$t,over:dn}=Oe.current;if(!yt||!It)return;const Gt={active:yt,activatorEvent:It,collisions:$t,delta:{x:wt.x,y:wt.y},over:dn};$u.unstable_batchedUpdates(()=>{pt?.(Gt),F({type:"onDragMove",event:Gt})})},[wt.x,wt.y]),v.useEffect(()=>{const{active:pt,activatorEvent:yt,collisions:It,droppableContainers:$t,scrollAdjustedTranslate:dn}=Oe.current;if(!pt||ae.current==null||!yt||!dn)return;const{onDragOver:Gt}=se.current,sn=$t.get(Yt),hn=sn&&sn.rect.current?{id:sn.id,rect:sn.rect.current,data:sn.data,disabled:sn.disabled}:null,an={active:pt,activatorEvent:yt,collisions:It,delta:{x:dn.x,y:dn.y},over:hn};$u.unstable_batchedUpdates(()=>{jn(hn),Gt?.(an),F({type:"onDragOver",event:an})})},[Yt]),Jr(()=>{Oe.current={activatorEvent:R,active:J,activeNode:le,collisionRect:lt,collisions:Nt,droppableRects:pe,draggableNodes:X,draggingNode:Ae,draggingNodeRect:Ie,droppableContainers:ne,over:rt,scrollableAncestors:Me,scrollAdjustedTranslate:wt},G.current={initial:Ie,translated:lt}},[J,le,Nt,lt,X,Ae,Ie,pe,ne,rt,Me,wt]),eN({...je,delta:ge,draggingRect:lt,pointerCoordinates:$e,scrollableAncestors:Me,scrollableAncestorRects:Le});const fe=v.useMemo(()=>({active:J,activeNode:le,activeNodeRect:Se,activatorEvent:R,collisions:Nt,containerNodeRect:ze,dragOverlay:ve,draggableNodes:X,droppableContainers:ne,droppableRects:pe,over:rt,measureDroppableContainers:Z,scrollableAncestors:Me,scrollableAncestorRects:Le,measuringConfiguration:V,measuringScheduled:Q,windowRect:ke}),[J,le,Se,R,Nt,ze,ve,X,ne,pe,rt,Z,Me,Le,V,Q,ke]),Ze=v.useMemo(()=>({activatorEvent:R,activators:ki,active:J,activeNodeRect:Se,ariaDescribedById:{draggable:_e},dispatch:A,draggableNodes:X,over:rt,measureDroppableContainers:Z}),[R,ki,J,Se,A,_e,X,rt,Z]);return zt.createElement(HC.Provider,{value:z},zt.createElement(Od.Provider,{value:Ze},zt.createElement(ik.Provider,{value:fe},zt.createElement(gp.Provider,{value:ut},p)),zt.createElement(SN,{disabled:f?.restoreFocus===!1})),zt.createElement(TD,{...f,hiddenTextDescribedById:_e}));function at(){const pt=ee?.autoScrollEnabled===!1,yt=typeof g=="object"?g.enabled===!1:g===!1,It=$&&!pt&&!yt;return typeof g=="object"?{...g,enabled:It}:{enabled:It}}}),CN=v.createContext(null),p1="button",kN="Draggable";function Yb(e){let{id:t,data:n,disabled:s=!1,attributes:o}=e;const l=jd(kN),{activators:u,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:b,draggableNodes:_,over:w}=v.useContext(Od),{role:C=p1,roleDescription:x="draggable",tabIndex:T=0}=o??{},M=g?.id===t,A=v.useContext(M?gp:CN),[F,z]=Lf(),[P,W]=Lf(),$=fN(u,t),L=cd(n);Jr(()=>(_.set(t,{id:t,key:l,node:F,activatorNode:P,data:L}),()=>{const ge=_.get(t);ge&&ge.key===l&&_.delete(t)}),[_,t]);const X=v.useMemo(()=>({role:C,tabIndex:T,"aria-disabled":s,"aria-pressed":M&&C===p1?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[s,C,T,M,x,b.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:X,isDragging:M,listeners:s?void 0:$,node:F,over:w,setNodeRef:z,setActivatorNodeRef:W,transform:A}}function ak(){return v.useContext(ik)}const TN="Droppable",EN={timeout:25};function vp(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:o}=e;const l=jd(TN),{active:u,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:M}={...EN,...o},A=cd(T??s),F=v.useCallback(()=>{if(!_.current){_.current=!0;return}C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),C.current=null},M)},[M]),z=mp({callback:F,disabled:x||!u}),P=v.useCallback((X,ge)=>{z&&(ge&&(z.unobserve(ge),_.current=!1),X&&z.observe(X))},[z]),[W,$]=Lf(P),L=cd(t);return v.useEffect(()=>{!z||!W.current||(z.disconnect(),_.current=!1,z.observe(W.current))},[W,z]),v.useEffect(()=>(f({type:ni.RegisterDroppable,element:{id:s,key:l,disabled:n,node:W,rect:w,data:L}}),()=>f({type:ni.UnregisterDroppable,key:l,id:s})),[s]),v.useEffect(()=>{n!==b.current.disabled&&(f({type:ni.SetDroppableDisabled,id:s,key:l,disabled:n}),b.current.disabled=n)},[s,l,n,f]),{active:u,rect:w,isOver:g?.id===s,node:W,over:g,setNodeRef:$}}function RN(e){let{animation:t,children:n}=e;const[s,o]=v.useState(null),[l,u]=v.useState(null),f=jf(n);return!n&&!s&&f&&o(f),Jr(()=>{if(!l)return;const g=s?.key,p=s?.props.id;if(g==null||p==null){o(null);return}Promise.resolve(t(p,l)).then(()=>{o(null)})},[t,s,l]),zt.createElement(zt.Fragment,null,n,s?v.cloneElement(s,{ref:u}):null)}const DN={x:0,y:0,scaleX:1,scaleY:1};function NN(e){let{children:t}=e;return zt.createElement(Od.Provider,{value:nk},zt.createElement(gp.Provider,{value:DN},t))}const MN={position:"fixed",touchAction:"none"},AN=e=>pp(e)?"transform 250ms ease":void 0,LN=v.forwardRef((e,t)=>{let{as:n,activatorEvent:s,adjustScale:o,children:l,className:u,rect:f,style:g,transform:p,transition:b=AN}=e;if(!f)return null;const _=o?p:{...p,scaleX:1,scaleY:1},w={...MN,width:f.width,height:f.height,top:f.top,left:f.left,transform:ha.Transform.toString(_),transformOrigin:o&&s?RD(s,f):void 0,transition:typeof b=="function"?b(s):b,...g};return zt.createElement(n,{className:u,style:w,ref:t},l)}),jN=e=>t=>{let{active:n,dragOverlay:s}=t;const o={},{styles:l,className:u}=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&&s.node.style.setProperty(f,g);return u!=null&&u.active&&n.node.classList.add(u.active),u!=null&&u.dragOverlay&&s.node.classList.add(u.dragOverlay),function(){for(const[g,p]of Object.entries(o))n.node.style.setProperty(g,p);u!=null&&u.active&&n.node.classList.remove(u.active)}},ON=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ha.Transform.toString(t)},{transform:ha.Transform.toString(n)}]},BN={duration:250,easing:"ease",keyframes:ON,sideEffects:jN({styles:{active:{opacity:"0"}}})};function IN(e){let{config:t,draggableNodes:n,droppableContainers:s,measuringConfiguration:o}=e;return fp((l,u)=>{if(t===null)return;const f=n.get(l);if(!f)return;const g=f.node.current;if(!g)return;const p=tk(u);if(!p)return;const{transform:b}=$i(u).getComputedStyle(u),_=FC(b);if(!_)return;const w=typeof t=="function"?t:PN(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:u,rect:o.dragOverlay.measure(p)},droppableContainers:s,measuringConfiguration:o,transform:_})})}function PN(e){const{duration:t,easing:n,sideEffects:s,keyframes:o}={...BN,...e};return l=>{let{active:u,dragOverlay:f,transform:g,...p}=l;if(!t)return;const b={x:f.rect.left-u.rect.left,y:f.rect.top-u.rect.top},_={scaleX:g.scaleX!==1?u.rect.width*g.scaleX/f.rect.width:1,scaleY:g.scaleY!==1?u.rect.height*g.scaleY/f.rect.height:1},w={x:g.x-b.x,y:g.y-b.y,..._},C=o({...p,active:u,dragOverlay:f,transform:{initial:g,final:w}}),[x]=C,T=C[C.length-1];if(JSON.stringify(x)===JSON.stringify(T))return;const M=s?.({active:u,dragOverlay:f,...p}),A=f.node.animate(C,{duration:t,easing:n,fill:"forwards"});return new Promise(F=>{A.onfinish=()=>{M?.(),F()}})}}let m1=0;function zN(e){return v.useMemo(()=>{if(e!=null)return m1++,m1},[e])}const HN=zt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:s,style:o,transition:l,modifiers:u,wrapperElement:f="div",className:g,zIndex:p=999}=e;const{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:C,draggableNodes:x,droppableContainers:T,dragOverlay:M,over:A,measuringConfiguration:F,scrollableAncestors:z,scrollableAncestorRects:P,windowRect:W}=ak(),$=v.useContext(gp),L=zN(_?.id),X=rk(u,{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:C,draggingNodeRect:M.rect,over:A,overlayNodeRect:M.rect,scrollableAncestors:z,scrollableAncestorRects:P,transform:$,windowRect:W}),ge=Vb(w),ne=IN({config:s,draggableNodes:x,droppableContainers:T,measuringConfiguration:F}),ie=ge?M.setRef:void 0;return zt.createElement(NN,null,zt.createElement(RN,{animation:ne},_&&L?zt.createElement(LN,{key:L,id:_.id,ref:ie,as:f,activatorEvent:b,adjustScale:t,className:g,transition:l,rect:ge,style:{zIndex:p,...o},transform:X},n):null))}),UN=128,$N=512,mo=100,FN="too_many_detached_terminals",WN=64,KN=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>UN)return null;const n=t.workspaces.map(qN);if(n.some(u=>u===null))return null;const s=n,o=new Set,l=new Set;for(const u of s){if(o.has(u.id))return null;o.add(u.id);for(const f of u.tabs){if(l.has(f.id))return null;l.add(f.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}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 s=n.detachedTerminalIds;return Array.isArray(s)&&s.length>mo}):!1}function qN(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>$N)return null;const n=t.tabs.map(VN);if(n.some(o=>o===null))return null;const s=ZN(t.detachedTerminalIds,mo);return s===null?null:{id:t.id,title:t.title,defaultCwd:XN(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function VN(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=YN(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function YN(e){if(!e||typeof e!="object")return null;let t=0;return Uv(e,1,()=>(t+=1,t<=KN))}function Uv(e,t,n){if(!e||typeof e!="object"||t>WN||!n())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const o=Uv(s.first,t+1,n),l=Uv(s.second,t+1,n);return!o||!l?null:{type:"split",direction:s.direction,ratio:GN(s.ratio),first:o,second:l}}function GN(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function XN(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ZN(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,s=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),s.push(o));return s}const 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"}],QN="nterminal-focus",JN=/^[A-Za-z0-9_.:-]{1,128}$/;function eM(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(QN)!=="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"||!g1(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!g1(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function g1(e){return typeof e=="string"&&JN.test(e)}const Vt="__main__",ck=128,tM=600*1e3,uk="nterminal.clientDiagnostics.v1",dk="nterminal.terminalDiagnosticsCursor.v1",yp=150,nM=24,iM=160,rM=48*1024,sM="terminal-connection-recovery";let v1=!1,Mu=null,Au=null,zg=0;function aM(){v1||typeof window>"u"||(v1=!0,Ni("page.load",{navigation:xM(),visibility:document.visibilityState,online:navigator.onLine,viewport:gk(),standalone:wM()}),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:CM(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Ni("runtime.unhandledrejection",{reason:kM(e.reason)})}))}function Ni(e,t={}){const n={id:mM(),at:new Date().toISOString(),event:dd(e,80),data:mk({...t,visibility:t.visibility??yM(),online:t.online??SM(),viewport:t.viewport??gk()})},s=Gb();return s.push(n),fM(s.slice(-yp)),n}function Gb(){try{const e=window.localStorage.getItem(uk);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(pM).filter(n=>n!==null).slice(-yp):[]}catch{return[]}}async function Xb(e,t=fetch){if(Mu)return Mu;const n=Gb(),s={reason:dd(e,80),events:n},o=JSON.stringify(s);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 oM(e=fetch){if(Au)return Au;Au=lM(e);try{return await Au}finally{Au=null}}async function lM(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?(hM(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=Gb().filter(o=>cM(o)&&dM(o,e)),n=[];let s=_1([]);for(const o of t){const l=[...n,o],u=_1(l);if(uM(u)>rM)break;n.push(o),s=u}return{events:n,body:s,hasMore:n.length<t.length}}function _1(e){return JSON.stringify({reason:sM,events:e})}function cM(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function uM(e){return new TextEncoder().encode(e).byteLength}function dM(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 hM(e){const t=e.at(-1);if(!t)return;const n=fk(),s=new Set(n?.at===t.at?n.boundaryIds:[]);for(const l of e)l.at===t.at&&s.add(pk(l));const o={at:t.at.slice(0,40),boundaryIds:Array.from(s).slice(-yp)};try{window.localStorage.setItem(dk,JSON.stringify(o))}catch{}}function fM(e){try{window.localStorage.setItem(uk,JSON.stringify(e))}catch{}}function pM(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 mM(){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 s=0;s<n.length;s+=1)t^=n.charCodeAt(s),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function mk(e){const t={};for(const[n,s]of Object.entries(e).slice(0,nM)){const o=dd(n,64);if(!o||gM(o))continue;const l=vM(s);l!==void 0&&(t[o]=l)}return t}function gM(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function vM(e){if(typeof e=="string")return _M(e,iM);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 _M(e,t){return bM(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function bM(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 yM(){return typeof document>"u"?void 0:document.visibilityState}function SM(){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 wM(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function xM(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function CM(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 kM(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const vk="nterminal.notifications.completionEnabled",Zb="nterminal.notifications.completionToastEnabled",Qb="nterminal.notifications.completionToastDurationSeconds",Jb="nterminal.notifications.completionToastPersistent",$v="nterminal:completion-toast-display",Fv="nterminal:notification-focus",td=6.5,Wv=2,Kv=60;function wp(){return typeof window<"u"&&"Notification"in window}function ey(){try{return window.localStorage.getItem(vk)==="true"}catch{return!1}}function b1(e){try{window.localStorage.setItem(vk,e?"true":"false")}catch{}}function fl(){return{enabled:DM(),durationSeconds:RM(),persistUntilDismissed:NM()}}function TM(e){if(typeof window<"u"){try{window.localStorage.setItem(Zb,e?"true":"false")}catch{}ty()}return fl()}function y1(e){const t=bk(e);if(typeof window<"u"){try{window.localStorage.setItem(Qb,String(t))}catch{}ty()}return fl()}function EM(e){if(typeof window<"u"){try{window.localStorage.setItem(Jb,e?"true":"false")}catch{}ty()}return fl()}function _k(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Zb||n.key===Qb||n.key===Jb)&&e()};return window.addEventListener($v,e),window.addEventListener("storage",t),()=>{window.removeEventListener($v,e),window.removeEventListener("storage",t)}}function Pc(){return wp()?window.Notification.permission:"unsupported"}function RM(){if(typeof window>"u")return td;try{const e=window.localStorage.getItem(Qb);return e===null?td:bk(Number(e))}catch{return td}}function DM(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Zb)!=="false"}catch{return!0}}function NM(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jb)==="true"}catch{return!1}}function bk(e){if(!Number.isFinite(e))return td;const t=Math.round(e*2)/2;return Math.max(Wv,Math.min(Kv,t))}function ty(){typeof window<"u"&&window.dispatchEvent(new CustomEvent($v))}async function yk(){if(!wp())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Pc()}}function MM(e){if(!wp()||Pc()!=="granted"||!ey()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,s=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:s?{focus:s}:void 0,silent:!0});s&&(o.onclick=()=>{window.focus(),AM(s)})}catch{}}function AM(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Fv,{detail:e}))}const S1="nterminal.push.clientId",LM=2e4,w1=[5e3,3e4,12e4];function oa(){try{const e=window.localStorage.getItem(S1);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Vv()}`;return window.localStorage.setItem(S1,t),t}catch{return`client-${Vv()}`}}function jM(){return`page-${Vv()}`}function xp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=UM(),n=$M(),s=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&s;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":s?o?"supported":"unsupported":"not_mobile":"insecure"}}async function OM(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"),u=await e.preparePushNotifications(o),g=await WM(l,u.publicKey)??await l.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:xk(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:wk(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:Sk(n.deviceKind),alwaysNotify:t})}async function BM(e){const t=xp();if(!t.supported||Pc()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),s=await n?.pushManager.getSubscription();if(!n||!s)return!1;const o=oa(),l=await KM(s.endpoint),u=await e.getPushNotificationStatus(o,l);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&qv(s,u.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&qv(s,f.publicKey);g||await s.unsubscribe();const p=g?s: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 IM(e){let t=!1,n=!1,s=0,o=null;const l=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=b=>{t||n||(n=!0,BM(e).then(_=>{s=0,_&&Ni("push.subscription.reconciled",{trigger:b})}).catch(_=>{if(Ni("push.subscription.reconcile_failed",{trigger:b,reason:_ instanceof Error?_.message:String(_)}),!t&&s<w1.length){const w=w1[s++];o=window.setTimeout(()=>{o=null,u("retry")},w)}}).finally(()=>{n=!1}))},f=b=>{l(),s=0,u(b)},g=()=>f("online"),p=()=>f("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,l(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function PM(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 zM(e,t){await e.updatePushNotificationDevice({clientId:oa(),alwaysNotify:t})}function HM(e){if(typeof window>"u")return()=>{};const t=oa(),n=jM();let s=null,o=!1;const l=(p=!0)=>{const b=xp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:FM(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:ey()&&Pc()==="granted",active:p}).catch(()=>{})},u=()=>{o||s!==null||(s=window.setInterval(()=>l(!0),LM))},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),u(),()=>{o=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",f),window.removeEventListener("blur",f),document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",g),l(!1)}}function UM(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function $M(){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 FM(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function wk(e){const t=e.toJSON(),n=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!n||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:s}}}async function WM(e,t){const n=await e.pushManager.getSubscription();return n?qv(n,t)?n:(await n.unsubscribe(),null):null}function qv(e,t){const n=e.options.applicationServerKey;return n?Ck(n)===t:!0}async function KM(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,"/"),s=window.atob(n),o=new ArrayBuffer(s.length),l=new Uint8Array(o);for(let u=0;u<s.length;u+=1)l[u]=s.charCodeAt(u);return o}function Ck(e){const t=new Uint8Array(e);let n="";for(const s of t)n+=String.fromCharCode(s);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Vv(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const qM=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function VM(e,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:qM(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}const YM=e=>{let t="",n=!1;for(const s of e){if(s==="-"||s==="_"||s<=" "){n=t.length>0;continue}t.length===0?t+=s.toLowerCase():t+=n?s.toUpperCase():s,n=!1}return t};const GM=e=>{const t=YM(e);return t.charAt(0).toUpperCase()+t.slice(1)};const Yv=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.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 XM(e,t={}){const n=t.attributeNames??{},s=w=>n[w]??w,o=e.size??e.width??el.width,l=e.size??e.height??el.height,u=e.aliases?.filter(w=>typeof w=="string"&&w.trim()!=="").map(w=>`lucide-${w}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...u],g=t.className?.split(" ").filter(Boolean)??[],p=t.includeDefaultClasses===!1?Yv(...g):Yv("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[s(C)]=x,w),{}),..."color"in t&&t.color&&{[s("stroke")]:t.color},..."size"in t&&Hg(t.size)&&{[s("width")]:t.size,[s("height")]:t.size},..."width"in t&&Hg(t.width)&&{[s("width")]:t.width},..."height"in t&&Hg(t.height)&&{[s("height")]:t.height},[s("stroke-width")]:b,...p&&{[s("class")]:p},[s("viewBox")]:`0 0 ${o} ${l}`,...t.hasA11yProp===!1?{[s("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(w=>{const[C,x,T]=w,M=t.nonScalingStroke?{[s("vector-effect")]:"non-scaling-stroke",...x}:x;return T?[C,M,T]:[C,M]})]}function ZM(e,t={}){return XM(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const QM=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},JM=v.createContext({}),eA=()=>v.useContext(JM),tA=v.forwardRef(({color:e,size:t,width:n,height:s,strokeWidth:o,absoluteStrokeWidth:l,nonScalingStroke:u,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:M=!1,color:A="currentColor",className:F=""}=eA()??{},z=!!g||QM(_),[P,W,$=[]]=ZM(b,{color:e??A,width:n??t??C,height:s??t??C,strokeWidth:o??x,absoluteStrokeWidth:l??T,nonScalingStroke:u??M,className:Yv(F,f),hasA11yProp:z,attributes:_});return v.createElement(P,{ref:w,...W},[...$.map(([L,X])=>v.createElement(L,X)),...Array.isArray(g)?g:[g]])});function Un(e,t=[],n=[]){const s=typeof e=="string"?VM(e,t,n):e,o=v.forwardRef(({className:l,...u},f)=>v.createElement(tA,{ref:f,icon:s,className:l,...u}));return s.name&&(o.displayName=GM(s.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 nA=Un(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 iA=Un(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=Un(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 sA=Un(Rk);const Dk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Dk.node;const Nk=Un(Dk);const Mk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Mk.node;const aA=Un(Mk);const Ak={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ak.node;const Lk=Un(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 x1=Un(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 oA=Un(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 lA=Un(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 cA=Un(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 uA=Un(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 dA=Un(zk);const Hk={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"}]]};Hk.node;const hA=Un(Hk);const Uk={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"}]]};Uk.node;const Ug=Un(Uk);const $k={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};$k.node;const fA=Un($k);const Fk={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"}]]};Fk.node;const Dc=Un(Fk);const Wk={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"}]]};Wk.node;const C1=Un(Wk);const Kk={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"]};Kk.node;const pA=Un(Kk);const qk={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"}]]};qk.node;const k1=Un(qk);const Vk={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Vk.node;const Gv=Un(Vk);function sa(e,t){const n=[Vt,...t.map(u=>u.id)],s=new Set(n),o=new Set,l=[];for(const u of e??[])!s.has(u)||o.has(u)||(o.add(u),l.push(u));for(const u of n)o.has(u)||l.push(u);return l}function mA(e,t){return sa(e,t).map(n=>n===Vt?null:n)}function gA(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function vA(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const T1="Local",_A=3e4,bA=2,yA=6,Yk="nterminal.serverList.viewMode.v1";function SA(){try{return window.localStorage.getItem(Yk)==="list"?"list":"stats"}catch{return"stats"}}function wA(e){try{window.localStorage.setItem(Yk,e)}catch{}}function xA(e,t){const n=new Map(e.map(s=>[s.id,s]));return sa(t,e).flatMap(s=>{if(s===Vt)return[{kind:"main",id:Vt}];const o=n.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function E1(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function Gk(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Ir(e.value.cpuPercent)} ${ny(e.value)}`,`MEM ${Ir(e.value.memoryPercent)} ${da(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Ir(e.value.diskPercent)} ${da(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Ir(e.value.swapPercent)} ${da(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function R1(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Ir(e.value.cpuPercent)} (${ny(e.value)})`,`RAM ${Ir(e.value.memoryPercent)} (${da(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Ir(e.value.diskPercent)} (${da(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Ir(e.value.swapPercent)} (${da(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function CA(e,t){const n=Gk(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function Ir(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function ny(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`:`${Xv(e.cpuPercent/100*t)}/${t} cores`}function da(e,t){return!D1(e)||!D1(t)?"–/–":kA(e,t)}function kA(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Xv(e/s)}/${Xv(t/s)} ${n}`}function Xv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function D1(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 TA(e){return[{label:"CPU",percent:Ir(e.cpuPercent),detail:ny(e),tone:Vh(e.cpuPercent)},{label:"MEM",percent:Ir(e.memoryPercent),detail:da(e.memoryUsedBytes,e.memoryTotalBytes),tone:Vh(e.memoryPercent)},{label:"DISK",percent:Ir(e.diskPercent),detail:da(e.diskUsedBytes,e.diskTotalBytes),tone:Vh(e.diskPercent)},{label:"SWAP",percent:Ir(e.swapPercent),detail:da(e.swapUsedBytes,e.swapTotalBytes),tone:Vh(e.swapPercent)}]}function EA({entry:e}){return e?.status==="offline"?d.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?d.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=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t}),d.jsx("span",{className:"server-list-stat-value",children:"–"})]}),d.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):d.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:R1(e),"aria-label":R1(e),children:TA(e.value).map(t=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t.label}),d.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),d.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function N1({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:o=0,onServerLabelsChange:l,onManageAccounts:u,onServerInfo:f,renderServerChildren:g,compact:p=!1}){const[b,_]=v.useState([]),[w,C]=v.useState([Vt]),[x,T]=v.useState(null),[M,A]=v.useState(!1),[F,z]=v.useState(!1),[P,W]=v.useState(null),[$,L]=v.useState(""),X=v.useRef(null),[ge,ne]=v.useState(()=>SA()),[ie,G]=v.useState(null),[J,ae]=v.useState(null),[ee,O]=v.useState({}),R=v.useRef({}),I=v.useRef(0),se=v.useRef([]),_e=v.useRef([Vt]),N=v.useRef(null);v.useEffect(()=>{se.current=b},[b]),v.useEffect(()=>{const U=sa(w,b);_e.current=U,E1(U,w)||C(U)},[b,w]),v.useEffect(()=>{let U=!1;return e.listAgents().then(de=>{U||(_(de.agents),z(!0),C(sa(de.serverOrder,de.agents)))}).catch(()=>{}),e.getMainInfo().then(de=>{U||(T(de.name),A(!0))}).catch(()=>{}),()=>{U=!0}},[e,o]),v.useEffect(()=>{P&&(X.current?.focus(),X.current?.select())},[P]),v.useEffect(()=>{let U=!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}))],Le=new Set(Me.map(be=>be.key));for(const be of Object.keys(R.current))Le.has(be)||delete R.current[be];O(be=>{const $e={};for(const We of Le)We in be&&($e[We]=be[We]);return $e});for(const be of Me)be.load().then($e=>{U||(R.current[be.key]=0,O(We=>Le.has(be.key)?{...We,[be.key]:{status:"online",value:$e,stale:!1}}:We))}).catch(async $e=>{if(U)return;if($e instanceof Hn&&$e.status===401&&be.key===Vt){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(be.key===Vt&&$e instanceof Hn){R.current[be.key]=0,O(He=>{if(!Le.has(be.key))return He;const vt=He[be.key];return{...He,[be.key]:{status:"online",value:vt?.value??null,stale:!0}}});return}if(be.probe)try{if(await be.probe()){if(U)return;R.current[be.key]=0,O(He=>{if(!Le.has(be.key))return He;const vt=He[be.key];return{...He,[be.key]:{status:"online",value:vt?.value??null,stale:!0}}});return}}catch(He){if(U)return;if(He instanceof Hn&&He.status===401){s?.({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>=bA&&O(He=>Le.has(be.key)?{...He,[be.key]:{status:"offline",value:He[be.key]?.value??null,stale:!0}}:He)})}de();const ke=window.setInterval(de,_A);return()=>{U=!0,window.clearInterval(ke)}},[e,b,s]);function V(U){U==="main"?(L(x??""),W({kind:"main"})):(L(U.name),W({kind:"agent",id:U.id}))}async function pe(){if(!P)return;const U=$.trim(),de=P;if(W(null),de.kind==="main"){const ke=U||"";try{const Me=await e.renameMain(ke);T(Me.name)}catch{}}else{if(!U)return;const ke=b.find(Me=>Me.id===de.id)?.name;_(Me=>Me.map(Le=>Le.id===de.id?{...Le,name:U}:Le));try{await e.renameAgent(de.id,U)}catch{ke!==void 0&&_(Me=>Me.map(Le=>Le.id===de.id?{...Le,name:ke}:Le))}}}function Z(){W(null)}function Q(U){ne(U),wA(U)}function le(U,de,ke){if(U===de)return;const Me=sa(_e.current,se.current),Le=Me.findIndex(lt=>lt===U),be=Me.findIndex(lt=>lt===de);if(Le<0||be<0)return;const $e=[...Me],[We]=$e.splice(Le,1);if(!We)return;const He=$e.findIndex(lt=>lt===de);if(He<0)return;const vt=ke==="before"?He:He+1;if($e.splice(vt,0,We),E1($e,Me))return;const wt=I.current+1;I.current=wt,_e.current=$e,C($e),e.reorderAgents($e).then(lt=>{if(I.current===wt){se.current=lt.agents;const Nt=sa(lt.serverOrder,lt.agents);_e.current=Nt,_(lt.agents),C(Nt)}}).catch(async()=>{if(I.current===wt)try{const lt=await e.listAgents();if(I.current===wt){se.current=lt.agents;const Nt=sa(lt.serverOrder,lt.agents);_e.current=Nt,_(lt.agents),C(Nt)}}catch{I.current===wt&&(_e.current=Me,C(Me))}})}function Te(U,de){const ke=sa(_e.current,se.current),Me=ke.findIndex(be=>be===U),Le=ke[Me+de];Me<0||!Le||le(U,Le,de<0?"before":"after")}function je(U,de){de.pointerType==="mouse"&&de.button!==0||(de.stopPropagation(),N.current={sourceId:U,pointerId:de.pointerId,startX:de.clientX,startY:de.clientY,active:!1,targetId:null,placement:"after"},de.currentTarget.setPointerCapture?.(de.pointerId))}function Fe(U){const de=N.current;if(!de||de.pointerId!==U.pointerId)return;const ke=Math.hypot(U.clientX-de.startX,U.clientY-de.startY);if(!de.active){if(ke<yA)return;de.active=!0,G(de.sourceId)}const Le=document.elementFromPoint(U.clientX,U.clientY)?.closest("[data-server-id]"),be=Le?.dataset.serverId??null;if(!Le||!be||be===de.sourceId){de.targetId=null,ae(null);return}const $e=Le.getBoundingClientRect(),We=U.clientY<$e.top+$e.height/2?"before":"after";de.targetId=be,de.placement=We,ae({serverId:be,placement:We})}function Se(U){const de=N.current;!de||de.pointerId!==U.pointerId||(U.stopPropagation(),U.currentTarget.releasePointerCapture?.(U.pointerId),N.current=null,G(null),ae(null),de.active&&de.targetId&&le(de.sourceId,de.targetId,de.placement))}function ze(U){const de=N.current;de&&de.pointerId===U.pointerId&&U.currentTarget.releasePointerCapture?.(U.pointerId),N.current=null,G(null),ae(null)}const Oe=x?.trim()||T1,j=P?.kind==="main",ve=ge==="stats",Ae=xA(b,w),Ie=Ae.length>1;return v.useEffect(()=>{l?.([...M?[{agentId:null,label:Oe}]:[],...F?b.map(U=>({agentId:U.id,label:U.name})):[]])},[b,F,Oe,M,l]),p?d.jsx("div",{className:"server-list server-list--compact",children:Ae.map(U=>{const de=U.kind==="main",ke=de?Oe:U.agent.name,Me=de?Vt:U.id,Le=ee[Me],be=Gk(Le);return d.jsxs("button",{type:"button",className:`server-list-chip${(de?t===null:t===U.id)?" server-list-chip--active":""}`,onClick:()=>n(de?null:U.id),"aria-label":`${ke}${be?` — ${be}`:""}`,title:`${ke}${be?` — ${be}`:""}`,children:[d.jsx("span",{className:"server-list-chip-initial",children:vA(ke)}),d.jsx("span",{className:"server-list-chip-pip","data-status":gA(Le)})]},U.id)})}):d.jsxs("div",{className:`server-list server-list--${ge}`,children:[d.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":ge==="list",onClick:()=>Q("list"),title:"Show server names only",children:"List"}),d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":ge==="stats",onClick:()=>Q("stats"),title:"Show resource usage",children:"Stats"})]}),Ae.map(U=>{const de=U.kind==="main",ke=de?Oe:U.agent.name,Me=de?Vt:U.id,Le=de?t===null:t===U.id,be=de?j:P?.kind==="agent"&&P.id===U.id,$e=g?.({agentId:de?null:U.id,serverId:U.id,label:ke,active:Le}),We=J?.serverId===U.id&&ie!==U.id?` server-list-section--drop-target server-list-section--drop-${J.placement}`:"";return d.jsxs("section",{className:`server-list-section${We}`,"aria-label":`${ke} server`,children:[d.jsx("div",{className:["server-list-row",ie===U.id?"server-list-row--dragging":"",J?.serverId===U.id&&ie!==U.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":U.id,children:be?d.jsxs(d.Fragment,{children:[Ie?d.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,d.jsx("form",{className:"server-list-editor",onSubmit:He=>{He.preventDefault(),pe()},children:d.jsx("input",{ref:X,"aria-label":de?"Rename main server":`Rename ${ke}`,value:$,onChange:He=>L(He.target.value),onBlur:()=>{pe()},onKeyDown:He=>{He.key==="Escape"&&(He.preventDefault(),Z())},placeholder:de?T1:void 0})})]}):d.jsxs(d.Fragment,{children:[Ie?d.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":U.id,title:"Drag to reorder","aria-label":`Reorder ${ke}`,"aria-grabbed":ie===U.id,onPointerDown:He=>je(U.id,He),onPointerMove:Fe,onPointerUp:Se,onPointerCancel:ze,onKeyDown:He=>{(He.key==="ArrowUp"||He.key==="ArrowDown")&&(He.preventDefault(),He.stopPropagation(),Te(U.id,He.key==="ArrowUp"?-1:1))},onClick:He=>He.stopPropagation(),children:"::"}):null,d.jsxs("div",{className:`server-list-item${Le?" server-list-item--active":""}`,title:CA(ke,ee[Me]),children:[d.jsxs("div",{className:"server-list-item-header",children:[d.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(de?null:U.id),onDoubleClick:He=>{He.preventDefault(),V(de?"main":{id:U.id,name:ke})},children:[d.jsx("span",{className:"server-list-dot"}),d.jsx("span",{className:"server-list-name",title:de?void 0:U.agent.url??"Outbound connection to main",children:ke})]}),u?d.jsx("span",{className:"server-list-provider-actions","aria-label":`${ke} account management`,children:["codex","claude"].map(He=>d.jsx("button",{type:"button",className:"server-list-provider-button",title:`Manage ${He==="codex"?"Codex":"Claude"} accounts`,"aria-label":`Manage ${He==="codex"?"Codex":"Claude"} accounts on ${ke}`,onClick:()=>u({agentId:de?null:U.id,label:ke},He),children:d.jsx("img",{src:`/brand/${He}.webp`,alt:""})},He))}):null,f&&d.jsx("button",{type:"button",className:"server-list-provider-button",title:"Server information","aria-label":`Server information: ${ke}`,onClick:()=>f({agentId:de?null:U.id,label:ke}),children:d.jsx(lA,{size:17})})]}),ve?d.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(de?null:U.id),children:d.jsx(EA,{entry:ee[Me]})}):null]})]})}),$e?d.jsx("div",{className:"server-list-children",children:$e}):null]},U.id)})]})}function RA({provider:e,serverLabel:t,api:n,disabled:s=!1,onBusyChange:o}){const[l,u]=v.useState(null),[f,g]=v.useState(!0),[p,b]=v.useState(!1),[_,w]=v.useState(null),[C,x]=v.useState(null),[T,M]=v.useState(null),A=v.useRef(null),F=v.useRef(null),z=v.useRef(null),P=v.useRef(null),W=v.useRef(null),$=v.useRef(!1),L=v.useId(),X=v.useId(),ge=e==="codex"?"Codex":"Claude",ne=s||l?.reason==="preview_mode",ie=MA(l),G=e==="codex"&&!!l?.installed&&!ie&&l?.reason!=="hooks_disabled",J=v.useCallback(async()=>{const ee=A.current;if(!ee?.active||ee.busy)return;const O=++ee.generation;g(!0),x(null),M(null);let R=null;try{R=await n.getProviderHooks(e),ee.active&&O===ee.generation&&u(R)}catch(I){ee.active&&O===ee.generation&&x(A1(I))}finally{ee.active&&O===ee.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);ee.active&&O===ee.generation&&!ee.busy&&I.trust&&!I.trust.reason&&u(I)}catch{}},[n,e]);v.useEffect(()=>{const ee={active:!0,busy:!1,generation:0};return A.current=ee,u(null),w(null),b(!1),M(null),W.current=null,J(),()=>{ee.active=!1}},[J]),v.useEffect(()=>{_&&!p?F.current?.focus():!p&&$.current&&(W.current==="trust"&&P.current?P:z).current?.focus(),$.current=!!_||p;const ee=O=>{O.key!=="Escape"||!_&&!p||(O.preventDefault(),O.stopImmediatePropagation(),p||w(null))};return window.addEventListener("keydown",ee,!0),()=>window.removeEventListener("keydown",ee,!0)},[_,p]);async function ae(){const ee=A.current;if(!(!ee?.active||ee.busy||ne||!_)){ee.busy=!0,ee.generation++,b(!0),g(!1),x(null),M(null),o(!0),W.current=_;try{const O=await(_==="install"?n.installProviderHooks(e):_==="remove"?n.removeProviderHooks(e):n.trustProviderHooks(e));ee.active&&(u(O),w(null),_==="trust"?O.trust?O.trust.reason?x(jA(O.trust.reason)):M(LA(O.trust)):x("Codex did not report a trust result. Use /hooks in Codex instead."):O.installed!==(_==="install")&&x(O.reason?Zv(O.reason):"The requested hook change was not applied."))}catch(O){ee.active&&x(A1(O))}finally{ee.busy=!1,ee.active&&(b(!1),o(!1))}}}return d.jsxs("section",{className:"provider-hooks","aria-labelledby":L,"aria-busy":f||p,children:[d.jsxs("div",{className:"provider-hooks-heading",children:[d.jsxs("div",{children:[d.jsxs("h3",{id:L,children:[d.jsx(Ug,{size:14,"aria-hidden":"true"}),"Provider hooks"]}),d.jsx("span",{className:"provider-hooks-status",role:"status",children:f?"Checking...":l?NA(l):"Status unavailable"})]}),d.jsxs("div",{className:"provider-hooks-actions",children:[d.jsx("button",{type:"button",className:"account-icon-button",title:"Refresh hook status","aria-label":"Refresh hook status",disabled:s||f||p||!!_,onClick:()=>{J()},children:d.jsx(Dc,{size:14,"aria-hidden":"true"})}),d.jsxs("button",{ref:z,type:"button",disabled:ne||f||p||!l||!!_,onClick:()=>w(l?.installed?"remove":"install"),children:[l?.installed?d.jsx(k1,{size:14,"aria-hidden":"true"}):d.jsx(Ug,{size:14,"aria-hidden":"true"}),l?.installed?"Remove hooks":"Install hooks"]})]})]}),l?.configPath?d.jsx("code",{className:"provider-hooks-path",children:l.configPath}):null,l?.notifyConfigPath?d.jsx("code",{className:"provider-hooks-path",children:l.notifyConfigPath}):null,l?.reason&&l.reason!=="approval_unknown"&&l.reason!=="approval_required"?d.jsxs("p",{className:"provider-hooks-reason",children:[Zv(l.reason),l.reason==="unsafe_path"&&l.unsafePath?d.jsxs(d.Fragment,{children:[" ",d.jsx("code",{children:l.unsafePath})]}):null]}):null,l?.warnings?.length?d.jsx("ul",{className:"provider-hooks-warnings",children:l.warnings.map(ee=>d.jsx("li",{children:OA(ee)},ee))}):null,e==="codex"&&ie?d.jsxs("p",{className:"provider-hooks-trusted",children:["Codex reports ",AA(l?.trust?.total??l?.hookCount)," as trusted."]}):e==="codex"&&(l?.installed||l?.approvalRequired||l?.activity?.observed||_==="install")?d.jsxs("p",{className:"provider-hooks-trust",children:["In Codex, open ",d.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,G?d.jsx("div",{className:"provider-hooks-actions",children:d.jsxs("button",{ref:P,type:"button",disabled:ne||f||p||!!_,onClick:()=>w("trust"),children:[d.jsx(C1,{size:14,"aria-hidden":"true"}),"Trust NTerminal hooks in Codex"]})}):null,e==="codex"&&l?.installed&&l.activity?.unboundPanes?.length?d.jsx(DA,{panes:l.activity.unboundPanes}):null,_?d.jsxs("div",{className:"provider-hooks-confirm",role:"group","aria-labelledby":X,children:[_==="trust"?d.jsxs(d.Fragment,{children:[d.jsxs("p",{id:X,children:["Trust ",M1(l?.hookCount)," Codex hooks on ",t,"?"]}),d.jsxs("p",{children:["This marks only ",M1(l?.hookCount)," Codex hooks as trusted in Codex's ",d.jsx("code",{children:"config.toml"}),", the same as pressing Trust in ",d.jsx("code",{children:"/hooks"}),". Codex performs the change; other hooks stay as they are."]}),d.jsxs("p",{children:["Trusted hooks run outside the Codex sandbox. The command it trusts is the NTerminal hook helper",l?.hookCommand?":":"."]}),l?.hookCommand?d.jsx("code",{className:"provider-hooks-path",children:l.hookCommand}):null]}):d.jsxs(d.Fragment,{children:[d.jsxs("p",{id:X,children:[_==="install"?"Install":"Remove"," ",ge," hooks on ",t,"?"]}),d.jsx("p",{children:_==="install"?"Add NTerminal hooks to this provider's configuration?":"Remove NTerminal hooks from this provider's configuration?"})]}),d.jsxs("div",{className:"provider-hooks-actions",children:[d.jsx("button",{ref:F,type:"button",disabled:p,onClick:()=>w(null),children:"Cancel"}),d.jsxs("button",{type:"button",className:_==="remove"?"danger-button":"primary-button",disabled:ne||p,onClick:()=>{ae()},children:[p?d.jsx(dA,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"}):_==="install"?d.jsx(Ug,{size:14,"aria-hidden":"true"}):_==="trust"?d.jsx(C1,{size:14,"aria-hidden":"true"}):d.jsx(k1,{size:14,"aria-hidden":"true"}),p?"Applying...":_==="install"?"Confirm installation":_==="trust"?"Confirm trust":"Confirm removal"]})]})]}):null,T?d.jsx("p",{className:"provider-hooks-notice",role:"status",children:T}):null,C?d.jsx("p",{className:"provider-hooks-error",role:"alert",children:C}):null]})}function DA({panes:e}){const t=e.some(o=>o.reason==="shared_daemon_same_cwd"),n=e.map(o=>o.title).filter(Boolean),s=e.length===1?"1 Codex pane is":`${e.length} Codex panes are`;return d.jsxs("p",{className:"provider-hooks-note",role:"note",children:[s," 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 ",d.jsx("code",{children:"--no-daemon"}),"."]})}function NA(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 MA(e){return!!(e?.installed&&e.trust&&!e.trust.reason&&e.trust.pending===0&&e.trust.total>0)}function AA(e){return e===void 0?"all NTerminal hooks":e===1?"the NTerminal hook":`all ${e} NTerminal hooks`}function M1(e){return e===void 0?"NTerminal's":`NTerminal's ${e}`}function LA(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 jA(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]??Zv(e)}function A1(e){if(e instanceof Hn){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 Zv(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 OA(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 BA(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):d.jsx(IA,{...e},t.revision)}function IA({provider:e,serverLabel:t,api:n,onClose:s,onLoginStarted:o,onLoginFinished:l}){const[u,f]=v.useState(null),[g,p]=v.useState(!0),[b,_]=v.useState(null),[w,C]=v.useState(!1),[x,T]=v.useState(null),[M,A]=v.useState(""),[F,z]=v.useState(!1),[P,W]=v.useState(null),[$,L]=v.useState(!1),[X,ge]=v.useState(()=>Date.now()),[ne,ie]=v.useState({}),[G,J]=v.useState(!0),[ae,ee]=v.useState(!1),[O,R]=v.useState(!1),I=v.useRef(null),se=v.useCallback(async(Q=!1)=>{const le=I.current;if(!le?.active||le.actionPending||Q&&le.statusPending)return;const Te=++le.statusGeneration;le.statusPending=!0,Q||(p(!0),T(null));try{const je=await n.getAccounts();le.active&&Te===le.statusGeneration&&f(je)}catch(je){le.active&&Te===le.statusGeneration&&!Q&&T($g(je))}finally{le.active&&Te===le.statusGeneration&&(le.statusPending=!1,Q||p(!1))}},[n]),_e=v.useCallback(async()=>{const Q=I.current;if(!(!Q?.active||Q.actionPending)&&(Q.usageGeneration+=1,Q.usageQueued=!0,!Q.usagePending)){Q.usagePending=!0,J(!0);do{Q.usageQueued=!1;const le=Q.usageGeneration;try{const Te=await n.getAccountUsage(e);if(Te.provider!==e)throw new Error("Unexpected account usage provider");Q.active&&le===Q.usageGeneration&&(ie(Object.fromEntries(Te.profiles.map(je=>[je.profileId,je.usage]))),ee(!1),R(!1),ge(Date.now()))}catch{Q.active&&le===Q.usageGeneration&&(ee(!0),R(!0))}}while(Q.active&&Q.usageQueued&&!Q.actionPending);Q.usagePending=!1,Q.active&&J(!1)}},[n,e]),N=v.useMemo(()=>u?.providers.find(Q=>Q.provider===e)??null,[e,u]);v.useEffect(()=>{const Q={active:!0,actionPending:!1,statusGeneration:0,statusPending:!1,usageGeneration:0,usagePending:!1,usageQueued:!1};return I.current=Q,se(),_e(),()=>{Q.active=!1}},[se,_e]),v.useEffect(()=>{const Q=le=>{le.key==="Escape"&&!le.defaultPrevented&&!b&&!w&&(F?z(!1):s())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[s,b,w,F]),v.useEffect(()=>{const Q=window.setInterval(()=>ge(Date.now()),6e4);return()=>window.clearInterval(Q)},[]),v.useEffect(()=>{if(!N?.pendingLogin||b)return;const le=window.setInterval(()=>{se(!0)},1500);return()=>window.clearInterval(le)},[b,N?.pendingLogin,se]),v.useEffect(()=>{const Q=N?.pendingLogin,le=I.current;le?.active&&(!Q?.ready||!Q.terminalId||Q.terminalId===P||$||(L(!0),l(Q.terminalId).then(()=>{le.active&&W(Q.terminalId)}).catch(Te=>{le.active&&T($g(Te))}).finally(()=>{le.active&&L(!1)})))},[P,$,l,N?.pendingLogin]);async function V(Q,le){const Te=I.current;if(!(!Te?.active||Te.actionPending||w)){Te.actionPending=!0,Te.statusGeneration+=1,Te.statusPending=!1,Te.usageGeneration+=1,ee(!0),p(!1),_(Q),T(null);try{const je=await le();Te.active&&f(je)}catch(je){Te.active&&T($g(je))}finally{Te.actionPending=!1,Te.active&&(_(null),se(!0),_e())}}}async function pe(){await V("login",async()=>{const Q=I.current,le=await n.beginAccountLogin(e);return Q?.active&&o(le.terminal),Q?.active?n.getAccounts():{providers:[]}})}const Z=e==="codex"?"Codex":"Claude";return d.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:Q=>{Q.target===Q.currentTarget&&!b&&!w&&s()},children:[d.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${Z} accounts on ${t}`,children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"account-dialog-title",children:[d.jsx($A,{provider:e}),d.jsxs("div",{children:[d.jsxs("h2",{children:[Z," accounts"]}),d.jsx("p",{children:t})]})]}),d.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",title:"Close accounts",onClick:s,disabled:!!b||w,children:d.jsx(Gv,{size:16,"aria-hidden":"true"})})]}),d.jsxs("div",{className:"account-dialog-scroll",children:[g&&!N?d.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,N?d.jsx(PA,{provider:e,status:N,pendingAction:b??(w?"hooks":null),clock:X,usage:ne,usageLoading:G,usageStale:ae,label:M,onLabelChange:A,onSelect:Q=>{V(`select:${Q}`,()=>n.selectAccount(e,Q))},onDelete:Q=>{V(`delete:${Q}`,()=>n.removeAccount(e,Q))},onRefresh:Q=>{V(`refresh:${Q}`,()=>n.refreshAccount(e,Q))},onBeginLogin:()=>{pe()},onCompleteLogin:()=>{V("complete",()=>n.completeAccountLogin(e,M))},onCancelLogin:()=>{V("cancel",()=>n.cancelAccountLogin(e))},onRequestTerminate:()=>z(!0),loginPaneClosed:!N.pendingLogin?.terminalId||P===N.pendingLogin.terminalId,loginPaneClosing:$}):null,O?d.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?d.jsx("p",{className:"account-dialog-error",role:"alert",children:x}):null,d.jsx(RA,{provider:e,serverLabel:t,api:n,disabled:!!b||F,onBusyChange:C})]}),d.jsxs("footer",{className:"account-dialog-footer",children:[d.jsxs("button",{type:"button",title:"Reload account metadata and usage; does not refresh OAuth credentials",onClick:()=>{se(),_e()},disabled:g||!!b||w,children:[d.jsx(Dc,{size:14,"aria-hidden":"true"}),"Refresh"]}),d.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:!!b||w,children:"Close"})]})]}),F?d.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:Q=>{Q.target===Q.currentTarget&&!b&&z(!1)},children:d.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${Z} sessions`,children:[d.jsxs("h3",{children:["Exit all ",Z," sessions?"]}),d.jsxs("p",{children:["This stops detected ",Z," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),e==="codex"?d.jsx("p",{children:"The shared Codex daemon will also stop. All Codex work using that daemon is affected."}):null,d.jsxs("div",{children:[d.jsx("button",{type:"button",onClick:()=>z(!1),disabled:!!b,children:"Cancel"}),d.jsx("button",{type:"button",className:"danger-button",disabled:!!b,onClick:()=>{z(!1),V("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function PA({provider:e,status:t,pendingAction:n,clock:s,usage:o,usageLoading:l,usageStale:u,label:f,onLabelChange:g,onSelect:p,onDelete:b,onRefresh:_,onBeginLogin:w,onCompleteLogin:C,onCancelLogin:x,onRequestTerminate:T,loginPaneClosed:M,loginPaneClosing:A}){const F=t.runningProcesses??[],z=t.runningPanes.length>0||F.length>0||t.processCheckUnavailable===!0,P=F.length>0||t.processCheckUnavailable===!0||!t.terminationAcknowledged&&t.runningPanes.length>0,W=z||t.terminationAcknowledged?d.jsxs("div",{className:"account-dialog-running",role:"status",children:[d.jsx("strong",{children:t.terminationAcknowledged?"Termination requested.":`Exit ${e==="codex"?"Codex":"Claude"} before changing accounts.`}),t.runningPanes.map($=>d.jsxs("span",{children:[d.jsx("b",{children:$.title}),d.jsx("small",{children:$.cwd})]},$.terminalId)),F.map($=>d.jsxs("span",{children:[d.jsxs("b",{children:[$.command," ",d.jsxs("em",{children:["PID ",$.pid]})]}),d.jsx("small",{children:$.role==="daemon"?"Shared Codex daemon / manager":"Detected provider process on this server"})]},$.pid)),t.processCheckUnavailable?d.jsxs("span",{children:[d.jsx("b",{children:"Process check unavailable"}),d.jsx("small",{children:"Account changes stay blocked until this server can verify provider processes."})]}):null,t.terminationAcknowledged?d.jsxs("span",{children:[d.jsx("b",{children:"Proceeding after termination request"}),d.jsx("small",{children:"No provider processes remain. You can change accounts while pane status catches up."})]}):null,!t.processCheckUnavailable&&z?d.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:T,children:["Exit all ",e==="codex"?"Codex":"Claude"," sessions"]}):null]}):null;return t.pendingLogin?d.jsxs(d.Fragment,{children:[W,d.jsxs("div",{className:"account-dialog-section",children:[d.jsx("p",{children:t.pendingLogin.ready?A?"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&&M?d.jsxs("label",{className:"account-dialog-label",children:["Account name",d.jsx("input",{value:f,onChange:$=>g($.target.value),placeholder:`${e==="codex"?"Codex":"Claude"} account`,maxLength:80,autoFocus:!0})]}):null,d.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready&&M?d.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:C,children:"Save account"}):null,d.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:x,children:"Cancel and restore previous"})]})]})]}):d.jsxs(d.Fragment,{children:[W,d.jsxs("div",{className:"account-dialog-section",children:[d.jsxs("div",{className:"account-dialog-section-heading",children:[d.jsx("span",{children:"Saved accounts"}),d.jsxs("button",{type:"button",className:"primary-button",disabled:P||!!n,onClick:w,children:[d.jsx(fA,{size:14,"aria-hidden":"true"}),"Add account"]})]}),t.profiles.length===0?d.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map($=>{const L=$.id===t.activeProfileId;return d.jsxs("article",{className:`account-profile${L?" account-profile--active":""}`,children:[d.jsxs("div",{children:[d.jsx("strong",{children:$.label}),d.jsxs("small",{title:WA($.expiresAt),children:[L?"Active":"Saved"," · ",FA($.expiresAt,s)," · ",KA($.updatedAt,s)]}),d.jsx(UA,{refresh:$.refresh,clock:s})]}),d.jsxs("div",{className:"account-profile-actions",children:[d.jsxs("button",{type:"button",title:`Use ${$.label}`,disabled:P||!!n||L,onClick:()=>p($.id),children:[d.jsx(iA,{size:14,"aria-hidden":"true"}),"Use"]}),d.jsxs("button",{type:"button",title:L&&z?t.processCheckUnavailable?"Credential refresh deferred: process check unavailable":"Managed by running CLI":"Refresh OAuth credentials (rotates tokens); does not reset usage limits",disabled:L&&z||!!n,onClick:()=>_($.id),children:[d.jsx(cA,{size:14,"aria-hidden":"true"}),"Refresh credentials"]}),d.jsx("button",{type:"button",className:"danger-button account-icon-button","aria-label":`Remove ${$.label}`,title:`Remove ${$.label}`,disabled:!!n||L,onClick:()=>b($.id),children:d.jsx(pA,{size:14,"aria-hidden":"true"})})]}),d.jsx(HA,{usage:o[$.id],loading:l,stale:u,clock:s})]},$.id)})]})]})}const zA=2*6e4;function HA({usage:e,loading:t,stale:n,clock:s}){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,u=!!e&&(n||!Number.isFinite(l)||s-l>=zA||o.some(g=>g.resetsAt&&Date.parse(g.resetsAt)<=s)),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 d.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:d.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 d.jsxs("div",{className:"account-quota-window",children:[d.jsxs("span",{children:[g==="weekly"?"Weekly":"Session"," ",d.jsxs("b",{className:b<=10?"account-quota-critical":b<=25?"account-quota-warning":void 0,children:[b,"% remaining"]})]}),d.jsx("small",{title:Hf(p.resetsAt),children:p.resetsAt&&Number.isFinite(Date.parse(p.resetsAt))?`Resets ${Xk(p.resetsAt,s)}`:"Reset time unavailable"})]},g)}),d.jsxs("small",{className:"account-quota-check",children:[e?d.jsxs(d.Fragment,{children:["Last checked ",d.jsx("time",{dateTime:e.checkedAt,children:Hf(e.checkedAt)})]}):"Not yet checked",u?d.jsx("span",{className:"account-quota-warning",children:"Stale"}):null,t&&e?d.jsx("span",{children:"Updating..."}):null]}),e?.code?d.jsx("small",{className:"account-diagnostic-code",children:e.code}):null]})}function UA({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"},s=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 d.jsxs("div",{className:`account-refresh-status account-refresh-status--${e.state}`,children:[d.jsxs("span",{children:[s,e.nextRetryAt?` · Next retry ${Xk(e.nextRetryAt,t)}`:""]}),e.lastAttemptAt?d.jsxs("small",{children:["Last attempt ",Hf(e.lastAttemptAt)]}):null,e.lastSuccessAt?d.jsxs("small",{children:["Last success ",Hf(e.lastSuccessAt)]}):null,e.code||e.httpStatus!==null?d.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 Xk(e,t){const n=Date.parse(e)-t;if(!Number.isFinite(n))return"time unavailable";if(n<=0)return"due now";const s=Math.ceil(n/6e4),o=Math.floor(s/1440),l=Math.floor(s%1440/60);return`in ${o?`${o}d `:""}${l?`${l}h `:""}${o?"":`${s%60}m`}`.trim()}function $A({provider:e}){return d.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function FA(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 s=Math.floor(n/1440),o=Math.floor(n%1440/60),l=n%60;return`Access token ${[s?`${s}d`:null,o?`${o}h`:null,`${l}m`].filter(Boolean).join(" ")} remaining`}function WA(e){return!e||!Number.isFinite(Date.parse(e))?"Access token expiry timestamp unavailable":`Access token expires ${new Date(e).toLocaleString()}`}function KA(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 Hn?{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. Account changes and active credential refresh are blocked.",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 qA(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 u=t.get(l.process.ppid);u&&u!==l?u.children.push(l):n.push(l)}const s=[...n],o=new Set;for(let l=0;l<s.length;l++){const u=s[l];o.add(u.process.pid);for(const f of u.children)s.push(f)}for(const l of t.values())o.has(l.process.pid)||(l.children=[],n.push(l));for(let l=s.length-1;l>=0;l--){const u=s[l];for(const f of u.children)u.count+=f.count,u.cpuPercent+=f.cpuPercent,u.memoryBytes+=f.memoryBytes}return n}const Qv=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function VA({api:e,label:t,main:n,favorites:s,targets:o,onClose:l,onFavorite:u,onTarget:f,getRuntimeStatus:g,targetStatus:p}){const[b,_]=v.useState(null),[w,C]=v.useState(null),[x,T]=v.useState(!0),[M,A]=v.useState(!0),[F,z]=v.useState(null),[P,W]=v.useState(!1),[$,L]=v.useState(null),[X,ge]=v.useState(""),[ne,ie]=v.useState(!1),[G,J]=v.useState(null),ae=v.useRef(null),ee=v.useRef(l);ee.current=l;const O=v.useRef(!0);async function R(Z=!1){T(!0);try{const Q=await e.getServerExternalIp(Z);O.current&&_(Q)}catch{O.current&&_(Q=>({address:Q?.address??null,checkedAt:Q?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{O.current&&T(!1)}}async function I(){A(!0),z(null);try{const Z=await e.getServerProcesses();O.current&&C(Z)}catch{O.current&&z("Could not retrieve processes. The server may be offline or need an update.")}finally{O.current&&A(!1)}}v.useEffect(()=>(O.current=!0,R(),I(),()=>{O.current=!1}),[e]),v.useEffect(()=>{const Z=document.activeElement;ae.current?.focus();const Q=le=>{if(le.key==="Escape"){le.preventDefault(),le.stopImmediatePropagation(),ee.current();return}if(le.key==="Tab"){const Te=[...ae.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(Fe=>Fe.getClientRects().length>0),je=Te.indexOf(document.activeElement);Te.length&&(je<0||(le.shiftKey?je===0:je===Te.length-1))&&(le.preventDefault(),Te[le.shiftKey?Te.length-1:0]?.focus()),le.stopPropagation();return}ae.current?.contains(le.target)||(le.preventDefault(),le.stopImmediatePropagation())};return window.addEventListener("keydown",Q,!0),()=>{window.removeEventListener("keydown",Q,!0),Z instanceof HTMLButtonElement&&Z.isConnected&&Z.focus({preventScroll:!0})}},[]);async function se(Z){try{await navigator.clipboard.writeText(Z),W(!1)}catch{W(!0)}}async function _e(Z){if(!(ne||!X.trim())){ie(!0),J(null);try{const Q=await e.renameServerProject(Z,X.trim());if(!O.current)return;C(le=>le&&{...le,projects:le.projects.map(Te=>Te.path===Z?{...Te,name:Q.name}:Te)}),L(null)}catch{O.current&&J("Could not save project name.")}finally{O.current&&ie(!1)}}}const N=v.useMemo(()=>w?.projects.filter(Z=>Z.category!=="services")??[],[w]),V=v.useMemo(()=>{const Z=w?.projects.filter(Q=>Q.category==="services")??[];return N.length?[...Z,{name:"Development tools",path:"",category:"tools",cpuPercent:N.reduce((Q,le)=>Q+le.cpuPercent,0),memoryBytes:N.reduce((Q,le)=>Q+le.memoryBytes,0),processes:N.flatMap(Q=>Q.processes)}]:Z},[w,N]);function pe(Z){const Q=Z.path?o.filter(le=>le.cwd===Z.path||le.cwd.startsWith(Z.path.replace(/\/$/,"")+"/")):[];return d.jsxs(d.Fragment,{children:[Z.category!=="services"&&d.jsxs("div",{className:"server-info-tool-name",children:[d.jsx(oA,{size:15,"aria-hidden":"true"}),d.jsx("strong",{children:Z.path?Z.name:"Shared tools"})]}),d.jsxs("div",{className:"server-info-path",children:[d.jsx("code",{children:Z.path||"Shared across projects"}),Z.path&&d.jsxs(d.Fragment,{children:[d.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{se(Z.path)},children:d.jsx(x1,{size:14})}),d.jsx("button",{disabled:M||ne,title:"Rename project","aria-label":`Rename ${Z.name}`,onClick:()=>{L(`${Z.category}:${Z.path}`),ge(Z.name),J(null)},children:d.jsx(hA,{size:14})})]})]}),$===`${Z.category}:${Z.path}`&&d.jsxs("form",{className:"server-info-rename",onSubmit:le=>{le.preventDefault(),_e(Z.path)},children:[d.jsx("input",{"aria-label":"Project display name",maxLength:80,value:X,disabled:ne,onChange:le=>ge(le.target.value)}),d.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:ne||!X.trim(),children:d.jsx(Nk,{size:16})}),d.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:ne,onClick:()=>L(null),children:d.jsx(Gv,{size:16})}),G&&d.jsx("small",{role:"alert",className:"server-info-error",children:G})]}),Z.path&&d.jsx("div",{className:"server-info-targets",children:Q.length?Q.map(le=>d.jsxs("button",{onClick:()=>f(le),title:`Open ${le.label}`,children:[d.jsx(rA,{size:14}),le.label]},le.terminalId)):d.jsx("button",{disabled:!0,children:p??"No open tab"})}),d.jsx(YA,{processes:Z.processes})]})}return d.jsx("div",{className:"server-info-backdrop",onMouseDown:Z=>{Z.target===Z.currentTarget&&l()},children:d.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:ae,onKeyDown:Z=>Z.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("h2",{children:t}),d.jsx("small",{children:n?"Main":"Secondary"})]}),d.jsx("button",{title:"Close","aria-label":"Close server information",onClick:l,children:d.jsx(Gv,{size:18})})]}),d.jsxs("div",{className:"server-info-body",children:[d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-ip",children:[d.jsx("h3",{title:"External IPv4",children:"IPv4"}),d.jsx("code",{title:b?.checkedAt?`Checked ${new Date(b.checkedAt).toLocaleString()}`:void 0,children:b?.address??(x?"Loading...":"Unavailable")}),d.jsxs("span",{className:"server-info-ip-actions",children:[b?.address&&d.jsx("button",{title:"Copy IPv4","aria-label":"Copy IPv4",onClick:()=>{se(b.address)},children:d.jsx(x1,{size:16})}),d.jsx("button",{disabled:x,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{R(!0)},children:d.jsx(Dc,{size:16})})]})]}),b?.error&&d.jsx("p",{role:"status",className:"server-info-error",children:b.error})]}),d.jsxs("section",{children:[d.jsx("h3",{children:"Favorites"}),d.jsx("div",{className:"server-info-favorites",children:s.map(Z=>d.jsxs("button",{onClick:()=>u(Z),children:[d.jsx("strong",{children:Z.tabName}),d.jsxs("small",{children:[Z.workspaceName," · ",g?.(Z)?.state??"Not loaded"]}),d.jsx("span",{children:Z.providers.map(Q=>d.jsx("img",{alt:Q,src:`/brand/${Q}.webp`},Q))})]},`${Z.workspaceId}:${Z.tabId}`))}),!s.length&&d.jsx("small",{children:"No favorite tabs on this server."})]}),d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-heading",children:[d.jsx("h3",{children:"Projects"}),d.jsx("button",{disabled:M||ne,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{I()},children:d.jsx(Dc,{size:16})})]}),M&&d.jsx("p",{role:"status",children:"Sampling processes..."}),F&&d.jsx("p",{role:"alert",className:"server-info-error",children:F}),w&&d.jsxs("small",{children:["Sampled ",new Date(w.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),V.map(Z=>d.jsxs(Qk,{className:"server-info-project",children:[d.jsxs("summary",{children:[d.jsxs("span",{className:"server-info-project-label",children:[d.jsx(Lk,{className:"server-info-chevron",size:16,"aria-hidden":"true"}),d.jsx("strong",{title:Z.name,children:Z.name}),d.jsx("small",{className:"server-info-project-location",title:Z.path,children:Z.path}),d.jsx("small",{className:"server-info-project-count",title:`${Z.processes.length} processes`,children:Z.processes.length})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[Z.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Qv(Z.memoryBytes)})]})]}),d.jsx("div",{className:"server-info-project-body",children:Z.category==="services"?pe(Z):N.map(Q=>d.jsx("div",{className:"server-info-tool-project",children:pe(Q)},`${Q.category}:${Q.path}`))})]},`${Z.category}:${Z.path}`)),w&&!w.projects.length&&d.jsx("p",{children:"No processes found for the runtime user."})]}),P&&d.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function YA({processes:e}){const t=v.useMemo(()=>qA(e),[e]);return d.jsx("div",{className:"server-info-process-list",children:t.map(n=>d.jsx("div",{className:"server-info-process-root",children:d.jsx(Zk,{node:n})},n.process.pid))})}function Zk({node:e}){const t=e.process,n=d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"server-info-process-label",children:[e.children.length?d.jsx(Lk,{className:"server-info-chevron",size:14,"aria-hidden":"true"}):d.jsx("span",{className:"server-info-process-dot","aria-hidden":"true"}),d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · ",t.manager??"Unmanaged",e.count>1?` · ${e.count} processes · Total`:""]})]})]}),d.jsxs("span",{className:"server-info-metrics",title:e.count>1?"Total for this process and its descendants":"Process usage",children:[d.jsxs("span",{children:[e.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Qv(e.memoryBytes)})]})]});return e.children.length?d.jsxs(Qk,{className:"server-info-process-group",children:[d.jsx("summary",{className:"server-info-process",children:n}),d.jsxs("div",{className:"server-info-process-children",children:[d.jsxs("div",{className:"server-info-process",children:[d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · Parent"]})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[t.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Qv(t.memoryBytes)})]})]}),e.children.map(s=>d.jsx(Zk,{node:s},s.process.pid))]})]}):d.jsx("div",{className:"server-info-process",children:n})}function Qk({children:e,className:t}){const[n,s]=v.useState(!1),[o,...l]=zt.Children.toArray(e);return d.jsxs("details",{className:t,onToggle:u=>{u.target===u.currentTarget&&s(u.currentTarget.open)},children:[o,n?l:null]})}function GA({api:e}){const[t,n]=v.useState([]),[s,o]=v.useState([]),[l,u]=v.useState(!1),[f,g]=v.useState(null),[p,b]=v.useState(""),[_,w]=v.useState("");async function C(){try{const[A,F,z]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(F.networks),u(z.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{C()},[]);async function x(A){await e.revokeDevice(A),await C()}async function T(A){await e.removeNetwork(A),await C()}async function M(A){A.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:_.trim()}),b(""),w(""),await C()}catch(F){g(F instanceof Error?F.message:"Failed to add network")}}return d.jsxs(d.Fragment,{children:[f?d.jsx("p",{className:"form-error",children:f}):null,d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted devices"}),d.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?d.jsx("p",{className:"muted",children:"No trusted devices."}):d.jsx("ul",{className:"security-list",children:t.map(A=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[A.label,A.current?d.jsx("span",{className:"security-badge",children:"this device"}):null]}),d.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(A.id)},children:"revoke"})]},A.id))})]}),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted networks"}),d.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?d.jsx("p",{className:"muted",children:"No trusted networks."}):d.jsx("ul",{className:"security-list",children:s.map(A=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?d.jsx("span",{className:"security-item-meta",children:A.label}):null]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(A.id)},children:"remove"})]},A.id))}),d.jsxs("form",{className:"security-add-form",onSubmit:M,children:[d.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:A=>b(A.currentTarget.value),required:!0}),d.jsx("input",{type:"text",placeholder:"Label (optional)",value:_,onChange:A=>w(A.currentTarget.value)}),d.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),l?d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Two-factor authentication"}),d.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."}),d.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await C()},children:"Disable 2FA"})]}):null]})}const XA=1500,iy="nterminal.terminal.fontSize",ry="nterminal.terminal.fontFamily",Jv="nterminal:terminal-font-size",e_="nterminal:terminal-font-family",t_=11,n_=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";i_(Nc);async function Fg(e=cl,t=Nc){if(typeof document>"u"||!document.fonts)return;const n=tT(t).webFontFamilies;if(n.length===0)return;const s=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(o=>{globalThis.setTimeout(o,XA)})])}function Jk(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return cl;const n=Math.round(t);return Math.max(t_,Math.min(n_,n))}function eT(e){return Uf.some(t=>t.id===e)?e:Nc}function i_(e){return tT(e).cssFamily}function tT(e){return Uf.find(t=>t.id===e)??Uf[0]}function r_(){if(typeof window>"u")return cl;try{const e=window.localStorage.getItem(iy);return e?Jk(e):cl}catch{return cl}}function s_(){if(typeof window>"u")return Nc;try{return eT(window.localStorage.getItem(ry))}catch{return Nc}}function Yh(e){const t=Jk(e);if(typeof window>"u")return t;try{window.localStorage.setItem(iy,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Jv,{detail:t})),t}function ZA(e){const t=eT(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ry,t)}catch{}return window.dispatchEvent(new CustomEvent(e_,{detail:t})),t}function nT(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)}}function iT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ry&&e()};return window.addEventListener(e_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(e_,e),window.removeEventListener("storage",t)}}const sy="nterminal.terminal.showScrollProgress",a_="nterminal:terminal-scroll-progress",ay="nterminal.terminal.tmuxScrollback.shell",oy="nterminal.terminal.tmuxScrollback.agent",ly="nterminal.terminal.tmuxScrollback.overrides",hd="nterminal:terminal-tmux-scrollback",QA=200;function o_(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(sy)!=="false"}catch{return!0}}function JA(e){if(typeof window<"u"){try{window.localStorage.setItem(sy,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(a_,{detail:e}))}return e}function rT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===sy&&e()};return window.addEventListener(a_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(a_,e),window.removeEventListener("storage",t)}}function l_(){return sT(ay,!0)}function eL(e){return aT(ay,e,hd)}function c_(){return sT(oy,!0)}function tL(e){return aT(oy,e,hd)}function mf(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===ay||n.key===oy||n.key===ly)&&e()};return window.addEventListener(hd,e),window.addEventListener("storage",t),()=>{window.removeEventListener(hd,e),window.removeEventListener("storage",t)}}function Wg(e){const n=oT()[e];return typeof n=="boolean"?n:null}function nL(e,t){if(typeof window<"u"){try{const n=oT(),s=Object.entries(n).filter(([l])=>l!==e);s.push([e,t]);const o=s.slice(-QA);window.localStorage.setItem(ly,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(hd,{detail:{terminalId:e,enabled:t}}))}return t}function sT(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 aT(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 oT(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(ly);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t))typeof o=="boolean"&&(n[s]=o);return n}catch{return{}}}const cy="nterminal.shortcuts.workspace.v1",u_="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})},iL={"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=uT(Cp);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cy);if(!t)return e;const n=JSON.parse(t);for(const s of fd){const o=n[s.id];if(dL(o)){const l=dT(o,s);uL(l,iL[s.id])||(e[s.id]=l)}}}catch{return e}return e}function L1(){return JSON.stringify(pl())}function rL(e,t){const n=pl(),s=fd.find(o=>o.id===e);return s&&(n[e]=dT(t,s),uy(n)),n}function sL(e){const t=pl();return t[e]={...Cp[e]},uy(t),t}function aL(){const e=uT(Cp);return uy(e),e}function nd(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cy&&e()};return window.addEventListener(u_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(u_,e),window.removeEventListener("storage",t)}}function oL(e,t){const n=pT(e);return!n||fL(n)||t.indexed&&fT(e)===null||t.requiresPrimaryModifier&&!hT(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function lT(e){const t=pl();for(const n of fd){const s=t[n.id];if(!(!s||!hL(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const o=fT(e);if(o!==null)return{id:n.id,index:o};continue}if(pT(e)===s.code)return{id:n.id,index:null}}}return null}function id(e){return cT(pl()[e])}function cT(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(pL(e.code)),t.join("+")}const lL=()=>id("split.right"),cL=()=>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 uT(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function uL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function uy(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cy,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(u_))}}function dT(e,t){return t.requiresPrimaryModifier&&!hT(e)?{...Cp[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function hT(e){return e.ctrlKey||e.altKey||e.metaKey}function dL(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 hL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function fT(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 pT(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 fL(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function pL(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 mL="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 gL(e="nterminal",t=new Date){return{reason:"permission",message:mL,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function vL(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 mT=3600*1e3,_L="local",d_=new Set,oo=new Map;let go={checking:!1,hasUpdates:!1,lastCheckedAt:null},dy=null,rd=null,$f=0,to=null;function bL(e){return d_.add(e),()=>{d_.delete(e)}}function j1(){return go}function yL(e){const t=kL();dy=e,hy(),h_(e,t);const n=()=>{if(document.visibilityState!=="visible"||!vo(e,t))return;const s=go.lastCheckedAt;(s===null||Date.now()-s>=mT)&&h_(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),vo(e,t)&&CL()}}function SL(e,t){oo.set(e,gT(t)),Mc({...go,hasUpdates:fy(),lastCheckedAt:Date.now()})}function Kg(e){e===void 0?oo.clear():oo.set(e,!1),Mc({...go,hasUpdates:fy()})}async function h_(e,t){if(!vo(e,t))return;if(to&&to.api===e&&to.runId===t)return to.promise;Mc({...go,checking:!0});const n=wL(e,t).finally(()=>{to?.promise===n&&(to=null),vo(e,t)&&(Mc({...go,checking:!1,lastCheckedAt:Date.now()}),xL(e,t))});return to={api:e,runId:t,promise:n},n}async function wL(e,t){try{const n=await e.listAgents();if(!vo(e,t))return;const s=[{key:_L,check:()=>e.checkUpdate()},...n.agents.map(l=>({key:l.id,check:()=>e.checkAgentUpdate(l.id)}))],o=new Map;if(await Promise.all(s.map(async l=>{try{const u=await l.check();o.set(l.key,gT(u))}catch{o.set(l.key,oo.get(l.key)??!1)}})),!vo(e,t))return;oo.clear();for(const[l,u]of o)oo.set(l,u);Mc({...go,hasUpdates:fy()})}catch{}}function xL(e,t){vo(e,t)&&(hy(),rd=window.setTimeout(()=>{rd=null,vo(e,t)&&h_(e,t)},mT))}function CL(){$f+=1,hy(),dy=null,to=null,oo.clear(),Mc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function hy(){rd!==null&&(window.clearTimeout(rd),rd=null)}function kL(){return $f+=1,$f}function vo(e,t){return dy===e&&$f===t}function gT(e){return e.updateAvailable===!0}function fy(){return Array.from(oo.values()).some(Boolean)}function Mc(e){go=e;for(const t of Array.from(d_))t()}const TL=e=>new Promise(t=>setTimeout(t,e));function EL({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local"}]),[o,l]=v.useState({}),[u,f]=v.useState(!1),[g,p]=v.useState(null),[b,_]=v.useState(!1),[w,C]=v.useState({});function x(R,I){l(se=>({...se,[R]:{...se[R],...I}}))}function T(R,I){C(se=>({...se,[R]:{status:se[R]?.status??null,busy:se[R]?.busy??!1,error:se[R]?.error??null,...I}}))}const M=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),A=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),F=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),z=R=>R.id===null?e:Zr(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async I=>{if(R)return;let se="Local";try{se=(await e.getMainInfo()).name?.trim()||se}catch{}if(R)return;const _e=new Map(I.agents.map(V=>[V.id,V])),N=sa(I.serverOrder,I.agents).flatMap(V=>{if(V===Vt)return[{key:"local",id:null,name:se}];const pe=_e.get(V);return pe?[{key:pe.id,id:pe.id,name:pe.name}]:[]});s(N);for(const V of N)M(V).then(pe=>x(V.key,{version:pe,manualUpdate:pe.manualUpdate??null})).catch(pe=>x(V.key,{error:pe instanceof Error?pe.message:"unreachable"})),ae(V)}).catch(()=>{}),()=>{R=!0}},[]);async function P(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const I=await A(R);SL(R.key,I),x(R.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:ie(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 W(){f(!0),await Promise.all(n.map(R=>P(R))),f(!1)}async function $(R,I){const se=Date.now()+18e4;for(;Date.now()<se;){await TL(3e3);try{const _e=await M(R);if(I&&_e.runningVersion!==I.runningVersion)return _e}catch{}}return null}async function L(R){let I=o[R.key]?.version;if(!I)try{I=await M(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 se;try{se=await F(R)}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!se.ok){const N=se.manualUpdate??(vL(se.message)?gL():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:se.message}),"failed")}if(!se.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 $(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 X(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 se=await e.uninstallAgent(R.id);s(_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(se.message)}catch(se){x(R.key,{busy:!1,status:void 0,error:se instanceof Error?se.message:"delete failed"})}}}async function ge(){f(!0),p(null);const R=n.filter(pe=>pe.id!==null),I=n.find(pe=>pe.id===null),se=await Promise.all(R.map(pe=>L(pe))),_e=se.filter(pe=>pe==="failed").length;let N=se.filter(pe=>pe==="manual").length,V=null;if(I&&(V=await L(I),V==="manual"&&(N+=1),V==="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 ne(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function ie(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function G(R){const I=R?.version;return I?`npm package v${I.runningVersion}`:""}async function J(R,I){try{await DL(I),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(se){x(R,{error:se instanceof Error?se.message:"copy failed"})}}async function ae(R,I=!1){try{const se=await z(R).getCodeServerStatus(I?{checkLatest:!0}:void 0);T(R.key,{status:se,error:null})}catch(se){T(R.key,{error:se instanceof Error?se.message:"code-server status failed"})}}async function ee(R,I){if(I==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const se=z(R);T(R.key,{busy:!0,error:null});try{if(I==="install"){const _e=await se.installCodeServer();T(R.key,{status:_e.status})}else if(I==="update"){const _e=await se.updateCodeServer();T(R.key,{status:_e.status})}else{const _e=await se.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 O=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(se=>w[se.key]?.status?.job?.status==="running");if(R.length===0)return;const I=window.setInterval(()=>{for(const se of R)ae(se)},1e3);return()=>window.clearInterval(I)},[O]),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Servers"}),d.jsxs("div",{className:"update-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{W()},disabled:u,children:"Check for updates"}),d.jsx("button",{type:"button",onClick:()=>{ge()},disabled:u,children:"Update all"})]}),g?d.jsx("p",{className:"settings-status",children:g}):null,b?d.jsxs("div",{className:"server-reload-required",role:"status",children:[d.jsx("span",{children:"Main server update is ready."}),d.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,d.jsx("ul",{className:"security-list",children:n.map(R=>{const I=o[R.key],se=G(I),_e=I?.manualUpdate??null,N=w[R.key]??{status:null,busy:!1,error:null},V=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!u,pe=R.id!==null&&!I?.busy&&!u;return d.jsxs("li",{children:[d.jsxs("div",{className:"server-row-main",children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?d.jsx("span",{className:"security-badge",children:"Main"}):null]}),d.jsxs("span",{className:"security-item-meta",children:[se?`${se} — `:"",ne(I)]})]}),_e?d.jsxs("div",{className:"server-manual-update",children:[d.jsx("span",{children:_e.message}),d.jsxs("div",{className:"server-manual-command",children:[d.jsx("code",{children:_e.command}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{J(R.key,_e.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null,d.jsx(RL,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{ae(R,!0)},onInstall:()=>{ee(R,"install")},onUpdate:()=>{ee(R,"update")},onUninstall:()=>{ee(R,"uninstall")}})]}),d.jsxs("div",{className:"server-row-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{L(R)},disabled:!V,children:I?.busy?"…":"Update"}),R.id!==null?d.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{X(R)},disabled:!pe,children:"Delete"}):null]})]},R.key)})})]})}function RL({status:e,busy:t,error:n,onCheck:s,onInstall:o,onUpdate:l,onUninstall:u}){const f=e?.job??null,g=f?.status==="running",p=e!==null,b=e?.installed===!0,_=e?.supported!==!1,w=e===null&&!n;return d.jsxs("div",{className:"server-code-addon-inline",children:[d.jsxs("div",{className:"server-code-addon-summary",children:[d.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),d.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?d.jsx("p",{className:"settings-error",children:n}):null,f?d.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,d.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[d.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?d.jsxs(d.Fragment,{children:[e?.updateAvailable?d.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:"↑"}):d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:s,disabled:t||g||!_,title:"Check code-server updates","aria-label":"Check code-server updates",children:"↻"}),d.jsx("button",{type:"button",className:"server-code-addon-icon-button server-code-addon-icon-button--delete",onClick:u,disabled:t||g,title:"Uninstall code-server","aria-label":"Uninstall code-server",children:"×"})]}):d.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 DL(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 NL({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const l=v.useMemo(()=>t??up(),[t]),[u,f]=v.useState(()=>r_()),[g,p]=v.useState(()=>s_()),[b,_]=v.useState(()=>o_()),[w,C]=v.useState(()=>l_()),[x,T]=v.useState(()=>c_()),[M,A]=v.useState(()=>po()),[F,z]=v.useState(()=>pl()),[P,W]=v.useState(null),[$,L]=v.useState(null),[X,ge]=v.useState("appearance"),[ne,ie]=v.useState(()=>ey()),[G,J]=v.useState(()=>fl()),[ae,ee]=v.useState(()=>Pc()),[O,R]=v.useState([]),[I,se]=v.useState([]),[_e,N]=v.useState([]),[V,pe]=v.useState(5*1024*1024),[Z,Q]=v.useState(!1),[le,Te]=v.useState(null),[je,Fe]=v.useState(null),[Se,ze]=v.useState(!1),[Oe,j]=v.useState(null),[ve,Ae]=v.useState(null),Ie=v.useRef(null),U=v.useRef(null),de=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),ke=v.useMemo(()=>new Set(I),[I]),Me=!AL(I,_e),Le=v.useMemo(()=>xp(),[]),be=je?.displayMode==="standalone"&&(je.deviceKind==="mobile"||je.deviceKind==="tablet");v.useEffect(()=>nT(()=>f(r_())),[]),v.useEffect(()=>iT(()=>p(s_())),[]),v.useEffect(()=>rT(()=>_(o_())),[]),v.useEffect(()=>mf(()=>{C(l_()),T(c_())}),[]),v.useEffect(()=>zb(()=>A(po())),[]),v.useEffect(()=>nd(()=>z(pl())),[]),v.useEffect(()=>_k(()=>J(fl())),[]),v.useEffect(()=>{if(!P)return;const fe=fd.find(at=>at.id===P);if(!fe)return;const Ze=at=>{if(at.preventDefault(),at.stopPropagation(),at.key==="Escape"){W(null),L(null);return}const pt=oL(at,fe);if(!pt){L(ML(fe));return}z(rL(P,pt)),W(null),L(null)};return window.addEventListener("keydown",Ze,!0),()=>window.removeEventListener("keydown",Ze,!0)},[P]),v.useEffect(()=>{let fe=!1;return l.listNotificationAssets().then(Ze=>{fe||Nt(Ze)}).catch(Ze=>{fe||Te(uc(Ze))}),()=>{fe=!0}},[l]),v.useEffect(()=>{let fe=!1;return l.getPushNotificationStatus(oa()).then(Ze=>{fe||(Fe(Ze.currentDevice),j(null))}).catch(Ze=>{fe||j(uc(Ze))}),()=>{fe=!0}},[l]);function $e(fe){f(Yh(Number(fe)))}function We(fe){J(y1(Number(fe)))}function He(fe){ge(fe);const Ze=U.current,at=de.current[fe];if(!Ze||!at)return;const pt=Math.max(0,O1(at,Ze)-12);typeof Ze.scrollTo=="function"?Ze.scrollTo({top:pt,behavior:"smooth"}):Ze.scrollTop=pt}function vt(){const fe=U.current;if(!fe)return;if(fe.scrollTop+fe.clientHeight>=fe.scrollHeight-2){ge(Gh[Gh.length-1].id);return}let Ze="appearance";const at=fe.scrollTop+Math.min(180,Math.max(48,fe.clientHeight*.28));for(const pt of Gh){const yt=de.current[pt.id];yt&&O1(yt,fe)<=at&&(Ze=pt.id)}ge(Ze)}function wt(fe){z(sL(fe)),W(null),L(null)}function lt(){z(aL()),W(null),L(null)}function Nt(fe){const Ze=fe.assets.filter(at=>at.enabled).map(at=>at.id);R(fe.assets),se(Ze),N(Ze),pe(fe.maxFileBytes),Te(null)}async function Yt(){if(ne){b1(!1),ie(!1);return}let fe=ae;fe==="default"&&(fe=await yk(),ee(fe)),fe==="granted"&&(b1(!0),ie(!0))}async function rt(){ze(!0),j(null),Ae(null);try{if(je)await PM(l),Fe(null);else{await OM(l,!1);const fe=await l.getPushNotificationStatus(oa());Fe(fe.currentDevice)}}catch(fe){j(Vg(fe))}finally{ze(!1)}}async function jn(fe){ze(!0),j(null),Ae(null);try{await zM(l,fe);const Ze=await l.getPushNotificationStatus(oa());Fe(Ze.currentDevice)}catch(Ze){j(Vg(Ze))}finally{ze(!1)}}async function Sn(){ze(!0),j(null),Ae(null);try{await l.testPushNotification({clientId:oa()}),Ae("Test notification accepted by the push service.")}catch(fe){j(Vg(fe))}finally{ze(!1)}}async function ut(fe){const Ze=fe?.[0];if(Ze){if(Ze.size>V){Te(`File must be ${qg(V)} or smaller.`),Ct();return}if(Ze.type!=="video/mp4"&&Ze.type!=="video/webm"){Te("Upload an MP4 or WebM video."),Ct();return}Q(!0),Te(null);try{await l.uploadNotificationAsset(Ze),Nt(await l.listNotificationAssets()),s?.()}catch(at){Te(uc(at))}finally{Q(!1),Ct()}}}async function Lt(fe){Q(!0),Te(null);try{await l.deleteNotificationAsset(fe),Nt(await l.listNotificationAssets()),s?.()}catch(Ze){Te(uc(Ze))}finally{Q(!1)}}function Ct(){Ie.current&&(Ie.current.value="")}function gi(fe,Ze){const at=new Set(I);if(Ze?at.add(fe):at.delete(fe),at.size===0){Te("Keep at least one toast video selected.");return}Te(null),se(Array.from(at))}async function ki(){if(I.length===0){Te("Keep at least one toast video selected.");return}Q(!0),Te(null);try{const fe=await l.updateNotificationAssetSelection({enabledAssetIds:I});Nt(fe),s?.()}catch(fe){Te(uc(fe))}finally{Q(!1)}}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:d.jsxs("div",{className:"security-panel settings-panel",onClick:fe=>fe.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{children:"Settings"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),d.jsxs("div",{className:"settings-layout",children:[d.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Gh.map(fe=>d.jsxs("button",{type:"button","data-active":X===fe.id?"true":"false","aria-current":X===fe.id?"true":void 0,onClick:()=>He(fe.id),children:[fe.label,fe.id==="servers"&&n?d.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},fe.id))}),d.jsxs("div",{ref:U,className:"settings-content",onScroll:vt,children:[d.jsxs("section",{id:"settings-appearance",ref:fe=>{de.current.appearance=fe},className:"security-section settings-section",children:[d.jsx("h3",{children:"Appearance"}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Theme"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),d.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Af.map(fe=>d.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":M===fe.id,"data-active":M===fe.id?"true":"false",onClick:()=>A(lD(fe.id)),style:{"--settings-theme-bg":fe.tokens.bg,"--settings-theme-bg-2":fe.tokens.bg2,"--settings-theme-sidebar":fe.tokens.bgSidebar,"--settings-theme-line":fe.tokens.line,"--settings-theme-fg":fe.tokens.fg,"--settings-theme-fg-2":fe.tokens.fg2,"--settings-theme-accent":fe.tokens.accent,"--settings-theme-xterm-bg":fe.xterm.background,"--settings-theme-xterm-fg":fe.xterm.foreground,"--settings-theme-xterm-selection":fe.xterm.selectionBackground},children:[d.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[d.jsxs("span",{className:"settings-theme-preview-sidebar",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-main",children:[d.jsxs("span",{className:"settings-theme-preview-tabs",children:[d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-terminal",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})]})]}),d.jsxs("span",{className:"settings-theme-card-copy",children:[d.jsx("strong",{children:fe.label}),d.jsx("small",{children:fe.description})]})]},fe.id))}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font size"}),d.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),d.jsx("input",{type:"range",min:t_,max:n_,step:1,value:u,"aria-label":"Terminal font size",onChange:fe=>$e(fe.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row",children:[d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Yh(u-1)),children:"-"}),d.jsx("input",{type:"number",min:t_,max:n_,step:1,value:u,"aria-label":"Terminal font size value",onChange:fe=>$e(fe.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Yh(u+1)),children:"+"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Yh(cl)),children:"Reset"})]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font family"}),d.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:fe=>p(ZA(fe.currentTarget.value)),children:Uf.map(fe=>d.jsx("option",{value:fe.id,children:fe.label},fe.id))})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:b,onChange:fe=>_(JA(fe.currentTarget.checked))}),"Show scroll progress"]}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:w,onChange:fe=>C(eL(fe.currentTarget.checked))}),"Shell panes"]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:x,onChange:fe=>T(tL(fe.currentTarget.checked))}),"Codex/Claude panes"]})]}),d.jsxs("section",{id:"settings-shortcuts",ref:fe=>{de.current.shortcuts=fe},className:"security-section settings-section",children:[d.jsxs("div",{className:"settings-section-heading",children:[d.jsx("h3",{children:"Shortcuts"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:lt,children:"Reset all"})]}),d.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),$?d.jsx("p",{className:"settings-error",children:$}):null,d.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:fd.map(fe=>{const Ze=P===fe.id;return d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"settings-shortcut-label",children:fe.label}),d.jsx("span",{className:"settings-shortcut-group",children:fe.group})]}),d.jsxs("div",{className:"settings-shortcut-actions",children:[d.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ze?"true":"false",onClick:()=>{W(fe.id),L(null)},children:Ze?"Press keys…":cT(F[fe.id])}),d.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>wt(fe.id),children:"Reset"})]})]},fe.id)})})]}),d.jsxs("section",{id:"settings-notifications",ref:fe=>{de.current.notifications=fe},className:"security-section settings-section",children:[d.jsx("h3",{children:"Notifications"}),wp()?d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:ne&&ae==="granted",onChange:()=>{Yt()},disabled:ae==="denied"}),"System notification when page is hidden"]}),ae==="denied"?d.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."}):d.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):d.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),d.jsxs("div",{className:"settings-subsection",children:[d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:!!je,onChange:()=>{rt()},disabled:Se||!Le.supported}),"Installed app push notifications"]}),d.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."}),Le.supported?null:d.jsx("p",{className:"muted",children:gf(Le.reason)}),je?d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"muted",children:["Registered as ",je.label,". Last active ",new Date(je.lastActiveAt).toLocaleString(),"."]}),d.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{Sn()},disabled:Se,children:"Send test notification"})]}):null,be?d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:je?.alwaysNotify===!0,onChange:fe=>{jn(fe.currentTarget.checked)},disabled:Se||!je}),"Always notify this mobile device"]}):null,Oe?d.jsx("p",{className:"form-error",children:Oe}):null,ve?d.jsx("p",{className:"muted",role:"status",children:ve}):null]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:G.enabled,onChange:fe=>J(TM(fe.currentTarget.checked))}),"Show animated completion toast"]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Toast duration"}),d.jsx("span",{className:"settings-control-value",children:G.persistUntilDismissed?"Until closed":`${G.durationSeconds}s`}),d.jsx("input",{type:"range",min:Wv,max:Kv,step:.5,value:G.durationSeconds,disabled:!G.enabled||G.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:fe=>We(fe.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[d.jsx("input",{type:"number",min:Wv,max:Kv,step:.5,value:G.durationSeconds,disabled:!G.enabled||G.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:fe=>We(fe.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!G.enabled||G.persistUntilDismissed,onClick:()=>J(y1(td)),children:"Reset"})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:G.persistUntilDismissed,disabled:!G.enabled,onChange:fe=>J(EM(fe.currentTarget.checked))}),"Keep toast until dismissed"]}),d.jsxs("div",{className:"settings-assets-header",children:[d.jsx("span",{children:"Toast videos"}),d.jsxs("span",{children:[qg(V)," max"]})]}),d.jsx("input",{ref:Ie,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:fe=>{ut(fe.currentTarget.files)}}),d.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Z,onClick:()=>Ie.current?.click(),children:"Upload video"}),le?d.jsx("p",{className:"settings-error",children:le}):null,O.length>0?d.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(fe=>d.jsxs("li",{"data-enabled":ke.has(fe.id)?"true":"false",children:[d.jsxs("label",{className:"settings-asset-choice",children:[d.jsx("input",{type:"checkbox",checked:ke.has(fe.id),disabled:Z,"aria-label":`Use ${fe.filename}`,onChange:Ze=>gi(fe.id,Ze.currentTarget.checked)}),d.jsx("video",{src:fe.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),d.jsxs("span",{className:"settings-asset-copy",children:[d.jsx("span",{children:fe.filename}),d.jsx("small",{children:fe.source==="built-in"?"Built-in":qg(fe.size)})]})]}),fe.source==="uploaded"?d.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Z,"aria-label":`Delete ${fe.filename}`,onClick:()=>{Lt(fe.id)},children:"x"}):null]},fe.id))}):d.jsx("p",{className:"muted",children:"Built-in videos will be used."}),d.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Z||O.length===0||!Me,onClick:()=>{ki()},children:"Save selected videos"})]}),d.jsx("div",{id:"settings-security",ref:fe=>{de.current.security=fe},className:"settings-section-group",children:d.jsx(GA,{api:l})}),d.jsx("div",{id:"settings-servers",ref:fe=>{de.current.servers=fe},className:"settings-section-group",children:d.jsx(EL,{api:l,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function O1(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.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 ML(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 AL(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}const LL="modulepreload",jL=function(e){return"/"+e},B1={},py=function(t,n,s){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 u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");o=g(n.map(p=>{if(p=jL(p),p in B1)return;B1[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":LL,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(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return o.then(u=>{for(const f of u||[])f.status==="rejected"&&l(f.reason);return t().catch(l)})},OL=v.lazy(()=>py(()=>import("./MarkdownPreview-B-LrTjTM.js"),__vite__mapDeps([0,1])));function BL({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:o}){const[l,u]=v.useState(null),[f,g]=v.useState(""),[p,b]=v.useState({}),[_,w]=v.useState(()=>new Set),[C,x]=v.useState(null),[T,M]=v.useState({type:"empty"}),[A,F]=v.useState("idle"),[z,P]=v.useState(null),W=v.useRef(null),$=v.useRef(null),L=v.useRef(!1),X=v.useRef(0),ge=v.useRef(null);ge.current===null&&t&&(ge.current=t);const ne=ge.current,ie=s?PL(s):t?I1(t,n):null,G=l?[l.rootPath,f].filter(Boolean).join("/"):"",J=C?.path??null;v.useEffect(()=>(L.current=!0,()=>{L.current=!1,X.current+=1,ze()}),[]),v.useEffect(()=>{ge.current=t,$.current=null,ae(ie)},[e]),v.useEffect(()=>{s&&ie!==$.current&&ee(s,ie)},[s,ie]),v.useEffect(()=>{if(s||!ne||t!==ne)return;const U=I1(ne,n);U!==$.current&&O(ne,U)},[ne,t,n,s]);async function ae(U=ie){if(s){await ee(s,U);return}await O(t,U)}async function ee(U,de=ie){const ke=Oe();if($.current=de,ze(),u(null),g(""),b({}),w(new Set),x(null),M({type:"empty"}),P(null),!U){F("idle");return}F("loading");try{const Me=await e.createFileRoot({path:U});if(!j(ke))return;u({rootToken:Me.rootToken,rootPath:Me.rootPath});const Le=await e.listFiles({rootToken:Me.rootToken,path:""});if(!j(ke))return;se(Le),F("idle")}catch(Me){j(ke)&&(P(ea(Me)),F("idle"))}}async function O(U,de=ie){const ke=Oe();if($.current=de,ze(),u(null),g(""),b({}),w(new Set),x(null),M({type:"empty"}),P(null),!U){F("idle");return}F("loading");try{const Me=await e.createFileRoot({terminalId:U});if(!j(ke))return;u({rootToken:Me.rootToken,rootPath:Me.rootPath});const Le=await e.listFiles({rootToken:Me.rootToken,path:""});if(!j(ke))return;se(Le),F("idle")}catch(Me){if(await ve(Me,ke))return;j(ke)&&(P(ea(Me)),F("idle"))}}async function R(U=f,de=l){if(!de)return;const ke=Oe();F("loading"),P(null);try{const Me=await e.listFiles({rootToken:de.rootToken,path:U});if(!j(ke))return;se(Me),F("idle")}catch(Me){if(await ve(Me,ke))return;j(ke)&&(P(ea(Me)),F("idle"))}}async function I(){if(s){await ee(s,ie);return}ge.current=t,await O(t,ie)}function se(U){b(de=>({...de,[U.path]:zL(U.entries)}))}async function _e(U){if(!(!Yg(U)||!l)){if(x(U),P(null),U.kind==="directory"){g(U.path),Se(),await V(U);return}if(g(tl(U.path)),U.editable){await Z(U);return}U.previewKind!=="none"&&await le(U,U.previewKind)}}async function N(U){if(!(!Yg(U)||!l)){if(x(U),P(null),U.kind==="directory"){g(U.path),Se(),await V(U);return}if(g(tl(U.path)),U.editable){await Q(U);return}U.previewKind!=="none"&&await le(U,U.previewKind)}}async function V(U){if(_.has(U.path)){w(de=>{const ke=new Set(de);return ke.delete(U.path),ke});return}w(de=>new Set(de).add(U.path)),await R(U.path)}function pe(U,de){U.key==="Enter"&&(U.preventDefault(),N(de))}async function Z(U){if(!l)return;const de=Oe();F("loading"),ze();try{const ke=await e.readFile({rootToken:l.rootToken,path:U.path});if(!j(de))return;M({type:"text-preview",file:U,read:ke}),F("idle")}catch(ke){if(await ve(ke,de))return;j(de)&&(P(ea(ke)),F("idle"))}}async function Q(U){if(!l)return;const de=Oe();F("loading");try{await o({rootToken:l.rootToken,path:U.path,...t?{terminalId:t}:{}}),j(de)&&F("idle")}catch(ke){if(await ve(ke,de))return;j(de)&&(P(ea(ke)),F("idle"))}}async function le(U,de){if(!l)return;const ke=Oe();F("loading"),ze();try{const Me=await e.previewFile({rootToken:l.rootToken,path:U.path});if(!j(ke))return;const Le=URL.createObjectURL(Me);if(!j(ke)){URL.revokeObjectURL(Le);return}W.current=Le,M({type:"preview",file:U,previewKind:de,url:Le}),F("idle")}catch(Me){if(await ve(Me,ke))return;j(ke)&&(P(ea(Me)),F("idle"))}}async function Te(U){if(!l)return;const de=U==="file"?"New file":"New folder",ke=window.prompt(de,""),Me=C?C.kind==="directory"?C.path:tl(C.path):f,Le=P1(ke,Me);if(Le){P(null);try{const be=await e.createFileEntry({rootToken:l.rootToken,path:Le,kind:U});x(be.entry),await R(Me)}catch(be){if(await ve(be))return;P(ea(be))}}}async function je(){if(!l||!C)return;const U=window.prompt("Move selected entry",C.path),de=P1(U,"");if(!de||de===C.path)return;const ke=tl(C.path),Me=tl(de);P(null);try{const Le=await e.moveFileEntry({rootToken:l.rootToken,sourcePath:C.path,destinationPath:de});x(Le.entry),g(Le.entry.kind==="directory"?Le.entry.path:tl(Le.entry.path)),Se(),await R(ke),Me!==ke&&await R(Me)}catch(Le){if(await ve(Le))return;P(ea(Le))}}async function Fe(){if(!l||!C)return;const U=C.path,de=tl(U);P(null);try{const ke=await e.previewDeleteFileEntry({rootToken:l.rootToken,path:C.path}),Me=ke.descendantCount>0?` and ${ke.descendantCount} nested item${ke.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${ke.path}${Me}?`))return;await e.deleteFileEntry({rootToken:l.rootToken,path:C.path,previewToken:ke.previewToken}),x(null),g(de),w(Le=>{const be=new Set(Le);for(const $e of Le)($e===U||$e.startsWith(`${U}/`))&&be.delete($e);return be}),Se(),await R(de)}catch(ke){if(await ve(ke))return;P(ea(ke))}}function Se(){X.current+=1,ze(),M({type:"empty"})}function ze(){W.current&&(URL.revokeObjectURL(W.current),W.current=null)}function Oe(){return X.current+=1,X.current}function j(U){return L.current&&U===X.current}async function ve(U,de){return HL(U)?(de!==void 0&&!j(de)||await ae(ie),!0):!1}function Ae(U,de){const ke=Yg(U),Me=U.kind==="directory"&&_.has(U.path),Le=p[U.path]??[],be={"--file-tree-depth":de};return d.jsxs(zt.Fragment,{children:[d.jsxs("button",{type:"button",className:"file-entry-button","data-kind":U.kind,"data-expanded":Me,"data-active":J===U.path,disabled:!ke,style:be,"aria-expanded":U.kind==="directory"?Me:void 0,"aria-label":`${U.kind==="directory"?"Open folder":"Open file"} ${U.name}`,title:U.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{_e(U)},onDoubleClick:()=>{N(U)},onKeyDown:$e=>pe($e,U),children:[d.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:U.kind==="directory"?Me?"▾":"▸":""}),d.jsx("span",{className:"file-entry-name",children:U.name}),d.jsx("small",{children:IL(U)})]}),Me?d.jsx("div",{className:"file-tree-children",role:"group",children:Le.map($e=>Ae($e,de+1))}):null]},U.path)}const Ie=p[""]??[];return d.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[d.jsxs("header",{className:"file-explorer-header",children:[d.jsx("div",{className:"file-explorer-path",title:G,children:G||"No active pane"}),d.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[d.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{I()},children:"↻"}),d.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!l,onClick:()=>{Te("file")},children:"+"}),d.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!l,onClick:()=>{Te("directory")},children:"▣"})]})]}),z?d.jsx("div",{className:"file-explorer-alert",role:"alert",children:z}):null,d.jsxs("div",{className:"file-explorer-layout",children:[d.jsx("div",{className:"file-tree","aria-label":G?`Files in ${G}`:"Files",children:Ie.map(U=>Ae(U,0))}),d.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[d.jsxs("div",{className:"file-detail-header",children:[d.jsx("strong",{children:C?.name??"detail"}),d.jsxs("div",{className:"file-detail-actions",children:[d.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!C,onClick:()=>{je()},children:"Move"}),d.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!C,onClick:()=>{Fe()},children:"Delete"})]})]}),A==="loading"?d.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&A!=="loading"?d.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?d.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?d.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?d.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?d.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:d.jsx(OL,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?d.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 IL(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function I1(e,t){return`${e}\0${t??""}`}function PL(e){return`workspace\0${e}`}function zL(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 P1(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 HL(e){return e instanceof Hn&&e.status===409&&e.message==="terminal_cwd_changed"}const UL=v.lazy(()=>py(()=>import("./MarkdownPreview-B-LrTjTM.js"),__vite__mapDeps([0,1])));function z1({api:e,editor:t,canClose:n,onClose:s}){const[o,l]=v.useState(t.read),[u,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"),M=v.useRef(t),A=v.useRef(t.read),F=v.useRef(t.read.content),z=v.useRef(!1),P=v.useRef(!1),W=v.useRef(0),$=u!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,W.current+=1}),[]),v.useEffect(()=>{W.current+=1,z.current=!1,M.current=t,A.current=t.read,F.current=t.read.content,l(t.read),f(t.read.content),p("idle"),_(null),C(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{M.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{F.current=u},[u]),v.useEffect(()=>{if(u===o.content||w)return;const ie=window.setInterval(()=>{!z.current&&F.current!==A.current.content&&L()},1e3);return()=>window.clearInterval(ie)},[u===o.content,w,t.id]);async function L(){if(z.current)return;const ie=F.current,G=A.current;if(ie===G.content)return;const J=M.current,ae=W.current;z.current=!0,p("saving"),_(null),C(!1);try{const ee=await e.writeFile({rootToken:J.rootToken,path:J.path,content:ie,expectedVersion:G.version});if(!P.current||ae!==W.current)return;const O={...G,content:ie,version:ee.version};A.current=O,l(O),p(F.current===ie?"saved":"idle")}catch(ee){if(!P.current||ae!==W.current)return;if(ee instanceof Hn&&ee.status===409){C(!0),p("idle");return}_($L(ee)),p("idle")}finally{ae===W.current&&(z.current=!1)}}const X=g==="saving"?"saving":g==="saved"?"saved":o.language,ge=o.language==="markdown",ne=ge&&x==="preview";return d.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[d.jsxs("header",{className:"editor-pane-header",children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("strong",{children:t.title}),d.jsx("span",{className:"terminal-pane-spacer"}),d.jsx("span",{className:"terminal-pane-state",children:X}),d.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!$,onClick:()=>{L()},children:"Save"}),ge?d.jsx("button",{type:"button","aria-label":`${ne?"Edit":"Preview"} ${t.title}`,onClick:()=>T(ie=>ie==="preview"?"edit":"preview"),children:ne?"Edit":"Preview"}):null,n?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,w?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ne?d.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:d.jsx(UL,{content:u})})}):d.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ie=>{const G=ie.target.value;F.current=G,f(G),p("idle"),_(null),C(!1)}})]})}function $L(e){return e instanceof Error?e.message:"Request failed"}var FL=2,WL=1,KL=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={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=u.top+u.bottom,g=u.right+u.left,p=s-f,b=o-g-t;return{cols:Math.max(FL,Math.floor(b/e.css.cell.width)),rows:Math.max(WL,Math.floor(p/e.css.cell.height))}}};var vT=Object.defineProperty,qL=Object.getOwnPropertyDescriptor,VL=(e,t)=>{for(var n in t)vT(e,n,{get:t[n],enumerable:!0})},Ln=(e,t,n,s)=>{for(var o=s>1?void 0:s?qL(t,n):t,l=e.length-1,u;l>=0;l--)(u=e[l])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&vT(t,n,o),o},Ve=(e,t)=>(n,s)=>t(n,s,e),H1="Terminal input",f_={get:()=>H1,set:e=>H1=e},U1="Too much output to announce, navigate to rows manually to read",p_={get:()=>U1,set:e=>U1=e};function YL(e){return e.replace(/\r?\n/g,"\r")}function GL(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function XL(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ZL(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");_T(o,t,n,s)}}function _T(e,t,n,s){e=YL(e),e=GL(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function bT(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,l=e.clientY-s.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 $1(e,t,n,s,o){bT(e,t,n),o&&s.rightClickSelect(e),t.value=s.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 s="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,s+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):s+=String.fromCharCode(l)}return s}var QL=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[s++]=(this._interim-55296)*1024+l-56320+65536:(t[s++]=this._interim,t[s++]=l),this._interim=0}for(let l=o;l<n;++l){let u=e.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=n)return this._interim=u,s;let f=e.charCodeAt(l);56320<=f&&f<=57343?t[s++]=(u-55296)*1024+f-56320+65536:(t[s++]=u,t[s++]=f);continue}u!==65279&&(t[s++]=u)}return s}},JL=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,l,u,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 M=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=M-x;for(;p<A;){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||(M===2?C<128?p--:t[s++]=C:M===3?C<2048||C>=55296&&C<=57343||C===65279||(t[s++]=C):C<65536||C>1114111||(t[s++]=C)),this.interim.fill(0)}let b=n-4,_=p;for(;_<n;){for(;_<b&&!((o=e[_])&128)&&!((l=e[_+1])&128)&&!((u=e[_+2])&128)&&!((f=e[_+3])&128);)t[s++]=o,t[s++]=l,t[s++]=u,t[s++]=f,_+=4;if(o=e[_++],o<128)t[s++]=o;else if((o&224)===192){if(_>=n)return this.interim[0]=o,s;if(l=e[_++],(l&192)!==128){_--;continue}if(g=(o&31)<<6|l&63,g<128){_--;continue}t[s++]=g}else if((o&240)===224){if(_>=n)return this.interim[0]=o,s;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[_++],(u&192)!==128){_--;continue}if(g=(o&15)<<12|(l&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((o&248)===240){if(_>=n)return this.interim[0]=o,s;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[_++],(u&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=u,s;if(f=e[_++],(f&192)!==128){_--;continue}if(g=(o&7)<<18|(l&63)<<12|(u&63)<<6|f&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},yT="",ao=" ",Bd=class ST{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 ST;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 wT{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 wT(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pr=class xT 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 xT;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 s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},F1="di$target",m_="di$dependencies",Gg=new Map;function e3(e){return e[m_]||[]}function mi(e){if(Gg.has(e))return Gg.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");t3(t,n,o)};return t._id=e,Gg.set(e,t),t}function t3(e,t,n){t[F1]===t?t[m_].push({id:e,index:n}):(t[m_]=[{id:e,index:n}],t[F1]=t)}var Fi=mi("BufferService"),CT=mi("CoreMouseService"),_l=mi("CoreService"),n3=mi("CharsetService"),my=mi("InstantiationService"),kT=mi("LogService"),Wi=mi("OptionsService"),TT=mi("OscLinkService"),i3=mi("UnicodeService"),Id=mi("DecorationService"),g_=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Pr,u=n.getTrimmedLength(),f=-1,g=-1,p=!1;for(let b=0;b<u;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===u-1){let _=this._oscLinkService.getLinkData(f)?.uri;if(_){let w={start:{x:g+1,y:e},end:{x:b+(!p&&b===u-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||s.push({text:_,range:w,activate:(x,T)=>o?o.activate(x,T,w):r3(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(s)}};g_=Ln([Ve(0,Fi),Ve(1,Wi),Ve(2,TT)],g_);function r3(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"),gy=mi("MouseService"),ma=mi("RenderService"),s3=mi("SelectionService"),ET=mi("CharacterJoinerService"),zc=mi("ThemeService"),RT=mi("LinkProviderService"),a3=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?W1.isErrorNoTelemetry(e)?new W1(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)}},o3=new a3;function vf(e){l3(e)||o3.onUnexpectedError(e)}var v_="Canceled";function l3(e){return e instanceof c3?!0:e instanceof Error&&e.name===v_&&e.message===v_}var c3=class extends Error{constructor(){super(v_),this.name=this.message}};function u3(e){return new Error(`Illegal argument: ${e}`)}var W1=class __ extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof __)return t;let n=new __;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},b_=class DT extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,DT.prototype)}};function hr(e,t=0){return e[e.length-(1+t)]}var d3;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function s(l){return l>0}e.isGreaterThan=s;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(d3||={});function h3(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var NT;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(P){yield P}e.single=o;function l(P){return t(P)?P:o(P)}e.wrap=l;function u(P){return P||n}e.from=u;function*f(P){for(let W=P.length-1;W>=0;W--)yield P[W]}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,W){let $=0;for(let L of P)if(W(L,$++))return!0;return!1}e.some=b;function _(P,W){for(let $ of P)if(W($))return $}e.find=_;function*w(P,W){for(let $ of P)W($)&&(yield $)}e.filter=w;function*C(P,W){let $=0;for(let L of P)yield W(L,$++)}e.map=C;function*x(P,W){let $=0;for(let L of P)yield*W(L,$++)}e.flatMap=x;function*T(...P){for(let W of P)yield*W}e.concat=T;function M(P,W,$){let L=$;for(let X of P)L=W(L,X);return L}e.reduce=M;function*A(P,W,$=P.length){for(W<0&&(W+=P.length),$<0?$+=P.length:$>P.length&&($=P.length);W<$;W++)yield P[W]}e.slice=A;function F(P,W=Number.POSITIVE_INFINITY){let $=[];if(W===0)return[$,P];let L=P[Symbol.iterator]();for(let X=0;X<W;X++){let ge=L.next();if(ge.done)return[$,e.empty()];$.push(ge.value)}return[$,{[Symbol.iterator](){return L}}]}e.consume=F;async function z(P){let W=[];for await(let $ of P)W.push($);return Promise.resolve(W)}e.asyncToArray=z})(NT||={});function ml(e){if(NT.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function f3(...e){return yn(()=>ml(e))}function yn(e){return{dispose:h3(()=>{e()})}}var MT=class AT{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?AT.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)}};MT.DISABLE_DISPOSED_WARNING=!1;var lo=MT,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,y_=class S_{constructor(t){this.element=t,this.next=S_.Undefined,this.prev=S_.Undefined}};y_.Undefined=new y_(void 0);var Cn=y_,K1=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 s=!1;return()=>{s||(s=!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}},p3=globalThis.performance&&typeof globalThis.performance.now=="function",m3=class LT{static create(t){return new LT(t)}constructor(t){this._now=p3&&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(G,J){return _(G,()=>{},0,void 0,!0,void 0,J)}e.defer=t;function n(G){return(J,ae=null,ee)=>{let O=!1,R;return R=G(I=>{if(!O)return R?R.dispose():O=!0,J.call(ae,I)},null,ee),O&&R.dispose(),R}}e.once=n;function s(G,J,ae){return p((ee,O=null,R)=>G(I=>ee.call(O,J(I)),null,R),ae)}e.map=s;function o(G,J,ae){return p((ee,O=null,R)=>G(I=>{J(I),ee.call(O,I)},null,R),ae)}e.forEach=o;function l(G,J,ae){return p((ee,O=null,R)=>G(I=>J(I)&&ee.call(O,I),null,R),ae)}e.filter=l;function u(G){return G}e.signal=u;function f(...G){return(J,ae=null,ee)=>{let O=f3(...G.map(R=>R(I=>J.call(ae,I))));return b(O,ee)}}e.any=f;function g(G,J,ae,ee){let O=ae;return s(G,R=>(O=J(O,R),O),ee)}e.reduce=g;function p(G,J){let ae,ee={onWillAddFirstListener(){ae=G(O.fire,O)},onDidRemoveLastListener(){ae?.dispose()}},O=new Ue(ee);return J?.add(O),O.event}function b(G,J){return J instanceof Array?J.push(G):J&&J.add(G),G}function _(G,J,ae=100,ee=!1,O=!1,R,I){let se,_e,N,V=0,pe,Z={leakWarningThreshold:R,onWillAddFirstListener(){se=G(le=>{V++,_e=J(_e,le),ee&&!N&&(Q.fire(_e),_e=void 0),pe=()=>{let Te=_e;_e=void 0,N=void 0,(!ee||V>1)&&Q.fire(Te),V=0},typeof ae=="number"?(clearTimeout(N),N=setTimeout(pe,ae)):N===void 0&&(N=0,queueMicrotask(pe))})},onWillRemoveListener(){O&&V>0&&pe?.()},onDidRemoveLastListener(){pe=void 0,se.dispose()}},Q=new Ue(Z);return I?.add(Q),Q.event}e.debounce=_;function w(G,J=0,ae){return e.debounce(G,(ee,O)=>ee?(ee.push(O),ee):[O],J,void 0,!0,void 0,ae)}e.accumulate=w;function C(G,J=(ee,O)=>ee===O,ae){let ee=!0,O;return l(G,R=>{let I=ee||!J(R,O);return ee=!1,O=R,I},ae)}e.latch=C;function x(G,J,ae){return[e.filter(G,J,ae),e.filter(G,ee=>!J(ee),ae)]}e.split=x;function T(G,J=!1,ae=[],ee){let O=ae.slice(),R=G(_e=>{O?O.push(_e):se.fire(_e)});ee&&ee.add(R);let I=()=>{O?.forEach(_e=>se.fire(_e)),O=null},se=new Ue({onWillAddFirstListener(){R||(R=G(_e=>se.fire(_e)),ee&&ee.add(R))},onDidAddFirstListener(){O&&(J?setTimeout(I):I())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return ee&&ee.add(se),se.event}e.buffer=T;function M(G,J){return(ae,ee,O)=>{let R=J(new F);return G(function(I){let se=R.evaluate(I);se!==A&&ae.call(ee,se)},void 0,O)}}e.chain=M;let A=Symbol("HaltChainable");class F{constructor(){this.steps=[]}map(J){return this.steps.push(J),this}forEach(J){return this.steps.push(ae=>(J(ae),ae)),this}filter(J){return this.steps.push(ae=>J(ae)?ae:A),this}reduce(J,ae){let ee=ae;return this.steps.push(O=>(ee=J(ee,O),ee)),this}latch(J=(ae,ee)=>ae===ee){let ae=!0,ee;return this.steps.push(O=>{let R=ae||!J(O,ee);return ae=!1,ee=O,R?O:A}),this}evaluate(J){for(let ae of this.steps)if(J=ae(J),J===A)break;return J}}function z(G,J,ae=ee=>ee){let ee=(...se)=>I.fire(ae(...se)),O=()=>G.on(J,ee),R=()=>G.removeListener(J,ee),I=new Ue({onWillAddFirstListener:O,onDidRemoveLastListener:R});return I.event}e.fromNodeEventEmitter=z;function P(G,J,ae=ee=>ee){let ee=(...se)=>I.fire(ae(...se)),O=()=>G.addEventListener(J,ee),R=()=>G.removeEventListener(J,ee),I=new Ue({onWillAddFirstListener:O,onDidRemoveLastListener:R});return I.event}e.fromDOMEventEmitter=P;function W(G){return new Promise(J=>n(G)(J))}e.toPromise=W;function $(G){let J=new Ue;return G.then(ae=>{J.fire(ae)},()=>{J.fire(void 0)}).finally(()=>{J.dispose()}),J.event}e.fromPromise=$;function L(G,J){return G(ae=>J.fire(ae))}e.forward=L;function X(G,J,ae){return J(ae),G(ee=>J(ee))}e.runAndSubscribe=X;class ge{constructor(J,ae){this._observable=J,this._counter=0,this._hasChanged=!1;let ee={onWillAddFirstListener:()=>{J.addObserver(this)},onDidRemoveLastListener:()=>{J.removeObserver(this)}};this.emitter=new Ue(ee),ae&&ae.add(this.emitter)}beginUpdate(J){this._counter++}handlePossibleChange(J){}handleChange(J,ae){this._hasChanged=!0}endUpdate(J){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ne(G,J){return new ge(G,J).emitter.event}e.fromObservable=ne;function ie(G){return(J,ae,ee)=>{let O=0,R=!1,I={beginUpdate(){O++},endUpdate(){O--,O===0&&(G.reportChanges(),R&&(R=!1,J.call(ae)))},handlePossibleChange(){},handleChange(){R=!0}};G.addObserver(I),G.reportChanges();let se={dispose(){G.removeObserver(I)}};return ee instanceof lo?ee.add(se):Array.isArray(ee)&&ee.push(se),se}}e.fromObservableLight=ie})(Ci||={});var w_=class x_{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${x_._idPool++}`,x_.all.add(this)}start(t){this._stopWatch=new m3,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}}};w_.all=new Set,w_._idPool=0;var g3=w_,v3=-1,jT=class OT{constructor(t,n,s=(OT._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[l,u]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(f),console.warn(l);let g=new y3(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[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};jT._idPool=1;var _3=jT,b3=class BT{constructor(t){this.value=t}static create(){let t=new Error;return new BT(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
-
`).slice(2).join(`
|
|
23
|
-
`))}},y3=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},S3=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},w3=0,Xg=class{constructor(e){this.value=e,this.id=w3++}},x3=2,C3,Ue=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new _3(e?.onListenerError??vf,this._options?.leakWarningThreshold??v3):void 0,this._perfMon=this._options?._profName?new g3(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new S3(`${u}. 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 s=new Xg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=b3.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Xg?(this._deliveryQueue??=new k3,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let l=yn(()=>{o?.(),this._removeListener(s)});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 s=this._deliveryQueue.current===this;if(this._size*x3<=t.length){let o=0;for(let l=0;l<t.length;l++)t[l]?t[o++]=t[l]:s&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||vf;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof 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}},k3=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}},C_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ue,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ue,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};C_.INSTANCE=new C_;var vy=C_;function T3(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}vy.INSTANCE.onDidChangeZoomLevel;function E3(e){return vy.INSTANCE.getZoomFactor(e)}vy.INSTANCE.onDidChangeFullscreen;var Hc=typeof navigator=="object"?navigator.userAgent:"",k_=Hc.indexOf("Firefox")>=0,R3=Hc.indexOf("AppleWebKit")>=0,_y=Hc.indexOf("Chrome")>=0,D3=!_y&&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,T3(la,e,({matches:n})=>{Zg&&t.matches||(Zg=n)})}var _c="en",T_=!1,E_=!1,_f=!1,IT=!1,Xh,bf=_c,q1=_c,N3,ia,ul=globalThis,mr;typeof ul.vscode<"u"&&typeof ul.vscode.process<"u"?mr=ul.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(mr=process);var M3=typeof mr?.versions?.electron=="string",A3=M3&&mr?.type==="renderer";if(typeof mr=="object"){T_=mr.platform==="win32",E_=mr.platform==="darwin",_f=mr.platform==="linux",_f&&mr.env.SNAP&&mr.env.SNAP_REVISION,mr.env.CI||mr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Xh=_c,bf=_c;let e=mr.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Xh=t.userLocale,q1=t.osLocale,bf=t.resolvedLanguage||_c,N3=t.languagePack?.translationsConfigFile}catch{}IT=!0}else typeof navigator=="object"&&!A3?(ia=navigator.userAgent,T_=ia.indexOf("Windows")>=0,E_=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(),q1=Xh):console.error("Unable to resolve platform.");var PT=T_,Ss=E_,L3=_f,V1=IT,Cs=ia,Xa=bf,j3;(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 s(){return Xa==="en"}e.isDefault=s})(j3||={});var O3=typeof ul.postMessage=="function"&&!ul.importScripts;(()=>{if(O3){let e=[];ul.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),ul.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var B3=!!(Cs&&Cs.indexOf("Chrome")>=0);Cs&&Cs.indexOf("Firefox")>=0;!B3&&Cs&&Cs.indexOf("Safari")>=0;Cs&&Cs.indexOf("Edg/")>=0;Cs&&Cs.indexOf("Android")>=0;var ac=typeof navigator=="object"?navigator:{};V1||document.queryCommandSupported&&document.queryCommandSupported("copy")||ac&&ac.clipboard&&ac.clipboard.writeText,V1||ac&&ac.clipboard&&ac.clipboard.readText;var by=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 by,Y1=new by,G1=new by,I3=new Array(230),zT;(e=>{function t(f){return Qg.keyCodeToStr(f)}e.toString=t;function n(f){return Qg.strToKeyCode(f)}e.fromString=n;function s(f){return Y1.keyCodeToStr(f)}e.toUserSettingsUS=s;function o(f){return G1.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function l(f){return Y1.strToKeyCode(f)||G1.strToKeyCode(f)}e.fromUserSettings=l;function u(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=u})(zT||={});var P3=class HT{constructor(t,n,s,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof HT&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new z3([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},z3=class{constructor(e){if(e.length===0)throw u3("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 H3(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return zT.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(k_)switch(t){case 59:return 85;case 60:if(L3)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ss)return 57;break}else if(R3&&(Ss&&t===93||!Ss&&t===92))return 57;return I3[t]||0}var U3=Ss?256:2048,$3=512,F3=1024,W3=Ss?2048:256,X1=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=H3(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|=U3),this.altKey&&(t|=$3),this.shiftKey&&(t|=F3),this.metaKey&&(t|=W3),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new P3(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Z1=new WeakMap;function K3(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 q3=class{static getSameOriginWindowChain(e){let t=Z1.get(e);if(!t){t=[],Z1.set(e,t);let n=e,s;do s=K3(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let l of o){let u=l.window.deref();if(n+=u?.scrollY??0,s+=u?.scrollX??0,u===t||!l.iframeElement)break;let f=l.iframeElement.getBoundingClientRect();n+=f.top,s+=f.left}return{top:n,left:s}}},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=q3.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Q1=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(_y){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*u):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?k_&&!Ss?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")D3&&PT?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*u):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?k_&&!Ss?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},UT=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),V3;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Y3?!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:UT})})(V3||={});var Y3=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?UT:(this._emitter||(this._emitter=new Ue),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},yy=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 b_("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new b_("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},G3=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 b_("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=yn(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},X3;(e=>{async function t(s){let o,l=await Promise.all(s.map(u=>u.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(u){l(u)}})}e.withAsyncBody=n})(X3||={});var J1=class Lr{static fromArray(t){return new Lr(n=>{n.emitMany(t)})}static fromPromise(t){return new Lr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Lr(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Lr(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Ue,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ci.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new Lr(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Lr.map(this,t)}static filter(t,n){return new Lr(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Lr.filter(this,t)}static coalesce(t){return Lr.filter(t,n=>!!n)}coalesce(){return Lr.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Lr.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())}};J1.EMPTY=J1.fromArray([]);var{getWindow:ys,getWindowId:Z3,onDidRegisterWindow:Q3}=(function(){let e=new Map,t={window:la,disposables:new lo};e.set(la.vscodeWindowId,t);let n=new Ue,s=new Ue,o=new Ue;function l(u,f){return(typeof u=="number"?e.get(u):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Dt.None;let f=new lo,g={window:u,disposables:f.add(new lo)};return e.set(u.vscodeWindowId,g),f.add(yn(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),f.add(gt(u,ui.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:l,getWindow(u){let f=u;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:la},getDocument(u){return ys(u).document}}})(),J3=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function gt(e,t,n,s){return new J3(e,t,n,s)}var ex=function(e,t,n,s){return gt(e,t,n,s)},Sy,ej=class extends G3{constructor(e){super(),this.defaultTarget=e&&ys(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},tx=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,s=new Map,o=l=>{n.set(l,!1);let u=e.get(l)??[];for(t.set(l,u),e.set(l,[]),s.set(l,!0);u.length>0;)u.sort(tx.sort),u.shift().execute();s.set(l,!1)};Sy=(l,u,f=0)=>{let g=Z3(l),p=new tx(u,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 tj(e){let t=e.getBoundingClientRect(),n=ys(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"},nj=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=nr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=nr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=nr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=nr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=nr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=nr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=nr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=nr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=nr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=nr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=nr(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=nr(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=nr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=nr(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 nr(e){return typeof e=="number"?`${e}px`:e}function sd(e){return new nj(e)}var $T=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,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(yn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=ys(e)}this._hooks.add(gt(l,ui.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(gt(l,ui.POINTER_UP,u=>this.stopMonitoring(!0)))}};function ij(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[l]}}var _s;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(_s||={});var Fu=class Di extends Dt{constructor(){super(),this.dispatched=!1,this.targets=new K1,this.ignoreTargets=new K1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ci.runAndSubscribe(Q3,({window:t,disposables:n})=>{n.add(gt(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(gt(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(gt(t.document,"touchmove",s=>this.onTouchMove(s),{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 s=0,o=t.targetTouches.length;s<o;s++){let l=t.targetTouches.item(s);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 u=this.newGestureEvent(_s.Start,l.target);u.pageX=l.pageX,u.pageY=l.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,u=n.changedTouches.length;l<u;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-hr(g.rollingPageX))<30&&Math.abs(g.initialPageY-hr(g.rollingPageY))<30){let b=this.newGestureEvent(_s.Tap,g.initialTarget);b.pageX=hr(g.rollingPageX),b.pageY=hr(g.rollingPageY),this.dispatchEvent(b)}else if(p>=Di.HOLD_DELAY&&Math.abs(g.initialPageX-hr(g.rollingPageX))<30&&Math.abs(g.initialPageY-hr(g.rollingPageY))<30){let b=this.newGestureEvent(_s.Contextmenu,g.initialTarget);b.pageX=hr(g.rollingPageX),b.pageY=hr(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=hr(g.rollingPageX),_=hr(g.rollingPageY),w=hr(g.rollingTimestamps)-g.rollingTimestamps[0],C=b-g.rollingPageX[0],x=_-g.rollingPageY[0],T=[...this.targets].filter(M=>g.initialTarget instanceof Node&&M.contains(g.initialTarget));this.inertia(t,T,s,Math.abs(C)/w,C>0?1:-1,b,Math.abs(x)/w,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(_s.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===_s.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Di.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===_s.Change||t.type===_s.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==s;)o++,l=l.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,l,u,f,g,p){this.handle=Sy(t,()=>{let b=Date.now(),_=b-s,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(_s.Change);T.translationX=w,T.translationY=C,n.forEach(M=>M.dispatchEvent(T)),x||this.inertia(t,n,b,o,l,u+w,f,g,p+C)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let l=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let u=this.activeTouches[l.identifier],f=this.newGestureEvent(_s.Change,u.initialTarget);f.translationX=l.pageX-hr(u.rollingPageX),f.translationY=l.pageY-hr(u.rollingPageY),f.pageX=l.pageX,f.pageY=l.pageY,this.dispatchEvent(f),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(l.pageX),u.rollingPageY.push(l.pageY),u.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,Ln([ij],Fu,"isTouchDevice",1);var rj=Fu,wy=class extends Dt{onclick(e,t){this._register(gt(e,ui.CLICK,n=>t(new Zh(ys(e),n))))}onmousedown(e,t){this._register(gt(e,ui.MOUSE_DOWN,n=>t(new Zh(ys(e),n))))}onmouseover(e,t){this._register(gt(e,ui.MOUSE_OVER,n=>t(new Zh(ys(e),n))))}onmouseleave(e,t){this._register(gt(e,ui.MOUSE_LEAVE,n=>t(new Zh(ys(e),n))))}onkeydown(e,t){this._register(gt(e,ui.KEY_DOWN,n=>t(new X1(n))))}onkeyup(e,t){this._register(gt(e,ui.KEY_UP,n=>t(new X1(n))))}oninput(e,t){this._register(gt(e,ui.INPUT,t))}onblur(e,t){this._register(gt(e,ui.BLUR,t))}onfocus(e,t){this._register(gt(e,ui.FOCUS,t))}onchange(e,t){this._register(gt(e,ui.CHANGE,t))}ignoreGesture(e){return rj.ignoreTarget(e)}},nx=11,sj=class extends wy{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=nx+"px",this.domNode.style.height=nx+"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 $T),this._register(ex(this.bgDomNode,ui.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(ex(this.domNode,ui.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ej),this._pointerdownScheduleRepeatTimer=this._register(new yy)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ys(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()}},aj=class R_{constructor(t,n,s,o,l,u,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,l=l|0,u=u|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),l<0&&(l=0),f+l>u&&(f=u-l),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=u,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 R_(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 R_(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,u=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:s,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:u,scrollHeightChanged:f,scrollTopChanged:g}}},oj=class extends Dt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new aj(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new rx(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=rx.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)))}},ix=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Jg(e,t){let n=t-e;return function(s){return e+n*uj(s)}}function lj(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var rx=class D_{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,l;return t<n?(o=t+.75*s,l=n-.75*s):(o=t-.75*s,l=n+.75*s),lj(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 s=this.scrollLeft(n),o=this.scrollTop(n);return new ix(s,o,!1)}return new ix(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return D_.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new D_(t,n,o,s)}};function cj(e){return Math.pow(e,3)}function uj(e){return 1-cj(1-e)}var dj=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 yy)}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":"")))}},hj=140,FT=class extends wy{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 dj(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new $T),this._shouldRender=!0,this.domNode=sd(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(gt(this.domNode.domNode,ui.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new sj(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=sd(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(gt(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(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=tj(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),u=Math.abs(l-n);if(PT&&u>hj){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.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()}},WT=class N_{constructor(t,n,s,o,l,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new N_(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,l){let u=Math.max(0,s-t),f=Math.max(0,u-2*n),g=o>0&&o>s;if(!g)return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*f/o))),b=(f-p)/(o-s),_=l*b;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:b,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=N_._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},fj=class extends FT{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new WT(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},pj=class extends FT{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new WT(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},mj=500,sx=50,gj=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},M_=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-s);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(_y){let n=ys(t.browserEvent),s=E3(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,l=new gj(t,n,s);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 s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),u=Math.abs(n.deltaX),f=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),p=Math.max(Math.min(l,f),1),b=Math.max(o,u),_=Math.max(l,f);b%g===0&&_%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};M_.INSTANCE=new M_;var vj=M_,_j=class extends wy{constructor(e,t,n){super(),this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ue),this.onWillScroll=this._onWillScroll.event,this._options=yj(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new pj(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new fj(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=sd(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=sd(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=sd(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 yy),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,Ss&&(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 Q1(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ml(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Q1(n))};this._mouseWheelToDispose.push(gt(this._listenOnDomNode,ui.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=vj.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 u=!Ss&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!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 s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),mj)}},bj=class extends _j{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 yj(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,Ss&&(t.className+=" mac"),t}var A_=class extends Dt{constructor(e,t,n,s,o,l,u,f){super(),this._bufferService=n,this._optionsService=u,this._renderService=f,this._onRequestScrollLines=this._register(new Ue),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new oj({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Sy(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new bj(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=s.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}};A_=Ln([Ve(2,Fi),Ve(3,pa),Ve(4,CT),Ve(5,zc),Ve(6,Wi),Ve(7,ma)],A_);var L_=class extends Dt{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(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()}};L_=Ln([Ve(1,Fi),Ve(2,pa),Ve(3,Id),Ve(4,ma)],L_);var Sj=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)}},gs={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,s,o,l,u,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=u,this._coreBrowserService=f,this._colorZoneStore=new Sj,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(){gs.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);gs.left=t,gs.center=t,gs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gs.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)-gs[e.position||"full"]/2),Za[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+gs[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=Ln([Ve(2,Fi),Ve(3,Id),Ve(4,ma),Ve(5,Wi),Ve(6,zc),Ve(7,pa)],Wf);var De;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
25
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(De||={});var 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 KT;(e=>e.ST=`${De.ESC}\\`)(KT||={});var j_=class{constructor(e,t,n,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,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(`${De.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"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)}}};j_=Ln([Ve(2,Fi),Ve(3,Wi),Ve(4,_l),Ve(5,ma)],j_);var hi=0,fi=0,pi=0,An=0,ax={css:"#00000000",rgba:0},Gn;(e=>{function t(o,l,u,f){return f!==void 0?`#${nl(o)}${nl(l)}${nl(u)}${nl(f)}`:`#${nl(o)}${nl(l)}${nl(u)}`}e.toCss=t;function n(o,l,u,f=255){return(o<<24|l<<16|u<<8|f)>>>0}e.toRgba=n;function s(o,l,u,f){return{css:e.toCss(o,l,u,f),rgba:e.toRgba(o,l,u,f)}}e.toColor=s})(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 M=Gn.toCss(hi,fi,pi),A=Gn.toRgba(hi,fi,pi);return{css:M,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,p,b){let _=Sf.ensureContrastRatio(g.rgba,p.rgba,b);if(_)return Gn.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;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 u(g,p){return An=g.rgba&255,l(g,An*p/255)}e.multiplyOpacity=u;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 s(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=s})(kn||={});var Ui;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,l){let u=s/255,f=o/255,g=l/255,p=u<=.03928?u/12.92:Math.pow((u+.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(u,f){if(An=(f&255)/255,An===1)return f;let g=f>>24&255,p=f>>16&255,b=f>>8&255,_=u>>24&255,w=u>>16&255,C=u>>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(u,f,g){let p=Ui.relativeLuminance(u>>8),b=Ui.relativeLuminance(f>>8);if(ta(p,b)<g){if(b<p){let C=s(u,f,g),x=ta(p,Ui.relativeLuminance(C>>8));if(x<g){let T=o(u,f,g),M=ta(p,Ui.relativeLuminance(T>>8));return x>M?C:T}return C}let _=o(u,f,g),w=ta(p,Ui.relativeLuminance(_>>8));if(w<g){let C=s(u,f,g),x=ta(p,Ui.relativeLuminance(C>>8));return w>x?_:C}return _}}e.ensureContrastRatio=n;function s(u,f,g){let p=u>>24&255,b=u>>16&255,_=u>>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=s;function o(u,f,g){let p=u>>24&255,b=u>>16&255,_=u>>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(u){return[u>>24&255,u>>16&255,u>>8&255,u&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 wj=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 Pr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,l=0,u=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(s,u,l,t,o);for(let _=0;_<b.length;_++)n.push(b[_])}o=p,u=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(s,u,l,t,o);for(let b=0;b<p.length;b++)n.push(p[b])}return n}_getJoinedRanges(e,t,n,s,o){let l=e.substring(t,n),u=[];try{u=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(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,l=0,u=e[s];if(u){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&&u[0]<=l&&(u[0]=f,o=!0),u[1]<=l){if(u[1]=f,u=e[++s],!u)break;u[0]<=l?(u[0]=f,o=!0):o=!1}l+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Kf=Ln([Ve(0,Fi)],Kf);function xj(e){return 57508<=e&&e<=57558}function Cj(e){return 9472<=e&&e<=9631}function kj(e){return xj(e)||Cj(e)}function Tj(){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 O_=class{constructor(e,t,n,s,o,l,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=u,this._workCell=new Pr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,l,u,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,M=0,A="",F=0,z=0,P=0,W=0,$=!1,L=0,X=!1,ge=0,ne=0,ie=[],G=p!==-1&&b!==-1;for(let J=0;J<x;J++){e.loadCell(J,this._workCell);let ae=this._workCell.getWidth();if(ae===0)continue;let ee=!1,O=J>=ne,R=J,I=this._workCell;if(w.length>0&&J===w[0][0]&&O){let j=w.shift(),ve=this._isCellInSelection(j[0],t);for(F=j[0]+1;F<j[1];F++)O&&=ve===this._isCellInSelection(F,t);O&&=!n||l<j[0]||l>=j[1],O?(ee=!0,I=new wj(this._workCell,e.translateToString(!0,j[0],j[1]),j[1]-j[0]),R=j[1]-1,ae=I.getWidth()):ne=j[1]}let se=this._isCellInSelection(J,t),_e=n&&J===l,N=G&&J>=p&&J<=b,V=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,j=>{V=!0});let pe=I.getChars()||ao;if(pe===" "&&(I.isUnderline()||I.isOverline())&&(pe=" "),ge=ae*f-g.get(pe,I.isBold(),I.isItalic()),!T)T=this._document.createElement("span");else if(M&&(se&&X||!se&&!X&&I.bg===z)&&(se&&X&&C.selectionForeground||I.fg===P)&&I.extended.ext===W&&N===$&&ge===L&&!_e&&!ee&&!V&&O){I.isInvisible()?A+=ao:A+=pe,M++;continue}else M&&(T.textContent=A),T=this._document.createElement("span"),M=0,A="";if(z=I.bg,P=I.fg,W=I.extended.ext,$=N,L=ge,X=se,ee&&l>=J&&l<=R&&(l=J),!this._coreService.isCursorHidden&&_e&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ie.push("xterm-cursor-blink"),ie.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(I.isBold()&&ie.push("xterm-bold"),I.isItalic()&&ie.push("xterm-italic"),I.isDim()&&ie.push("xterm-dim"),I.isInvisible()?A=ao:A=I.getChars()||ao,I.isUnderline()&&(ie.push(`xterm-underline-${I.extended.underlineStyle}`),A===" "&&(A=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Bd.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let j=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&j<8&&(j+=8),T.style.textDecorationColor=C.ansi[j].css}I.isOverline()&&(ie.push("xterm-overline"),A===" "&&(A=" ")),I.isStrikethrough()&&ie.push("xterm-strikethrough"),N&&(T.style.textDecoration="underline");let Z=I.getFgColor(),Q=I.getFgColorMode(),le=I.getBgColor(),Te=I.getBgColorMode(),je=!!I.isInverse();if(je){let j=Z;Z=le,le=j;let ve=Q;Q=Te,Te=ve}let Fe,Se,ze=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,j=>{j.options.layer!=="top"&&ze||(j.backgroundColorRGB&&(Te=50331648,le=j.backgroundColorRGB.rgba>>8&16777215,Fe=j.backgroundColorRGB),j.foregroundColorRGB&&(Q=50331648,Z=j.foregroundColorRGB.rgba>>8&16777215,Se=j.foregroundColorRGB),ze=j.options.layer==="top")}),!ze&&se&&(Fe=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,le=Fe.rgba>>8&16777215,Te=50331648,ze=!0,C.selectionForeground&&(Q=50331648,Z=C.selectionForeground.rgba>>8&16777215,Se=C.selectionForeground)),ze&&ie.push("xterm-decoration-top");let Oe;switch(Te){case 16777216:case 33554432:Oe=C.ansi[le],ie.push(`xterm-bg-${le}`);break;case 50331648:Oe=Gn.toColor(le>>16,le>>8&255,le&255),this._addStyle(T,`background-color:#${ox((le>>>0).toString(16),"0",6)}`);break;default:je?(Oe=C.foreground,ie.push("xterm-bg-257")):Oe=C.background}switch(Fe||I.isDim()&&(Fe=vn.multiplyOpacity(Oe,.5)),Q){case 16777216:case 33554432:I.isBold()&&Z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Z+=8),this._applyMinimumContrast(T,Oe,C.ansi[Z],I,Fe,void 0)||ie.push(`xterm-fg-${Z}`);break;case 50331648:let j=Gn.toColor(Z>>16&255,Z>>8&255,Z&255);this._applyMinimumContrast(T,Oe,j,I,Fe,Se)||this._addStyle(T,`color:#${ox(Z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Oe,C.foreground,I,Fe,Se)||je&&ie.push("xterm-fg-257")}ie.length&&(T.className=ie.join(" "),ie.length=0),!_e&&!ee&&!V&&O?M++:T.textContent=A,ge!==this.defaultSpacing&&(T.style.letterSpacing=`${ge}px`),_.push(T),J=R}return T&&M&&(T.textContent=A),_}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||kj(s.getCode()))return!1;let u=this._getContrastCache(s),f;if(!o&&!l&&(f=u.getColor(t.rgba,n.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=vn.ensureContrastRatio(o||t,l||n,g),u.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,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};O_=Ln([Ve(1,ET),Ve(2,Wi),Ve(3,pa),Ve(4,_l),Ve(5,Id),Ve(6,zc)],O_);function ox(e,t,n){for(;e.length<n;)e=t+e;return e}var Ej=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,s,o,l],this._container.appendChild(n),this._container.appendChild(s),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,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let u=0;t&&(u|=1),n&&(u|=2),l=this._measure(e,u),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}},Rj=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,u=n[1]-o,f=Math.max(l,0),g=Math.min(u,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=u,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 Dj(){return new Rj}var ev="xterm-dom-renderer-owner-",Ar="xterm-rows",Jh="xterm-fg-",lx="xterm-bg-",ju="xterm-focus",ef="xterm-selection",Nj=1,B_=class extends Dt{constructor(e,t,n,s,o,l,u,f,g,p,b,_,w,C){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=u,this._charSizeService=g,this._optionsService=p,this._bufferService=b,this._coreService=_,this._coreBrowserService=w,this._themeService=C,this._terminalClass=Nj++,this._rowElements=[],this._selectionRenderModel=Dj(),this.onRequestRedraw=this._register(new Ue).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ar),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=Tj(),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(O_,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 Ej(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} .${Ar} 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} .${Ar} { 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} .${Ar} .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}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ar}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ar}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ar}.${ju} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ar} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ar} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ar} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ar} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ar} .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,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Jh}${l} { color: ${u.css}; }${this._terminalSelector} .${Jh}${l}.xterm-dim { color: ${vn.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${lx}${l} { background-color: ${u.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} .${lx}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(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 s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,u=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],u-l+1))}else{let g=s===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(l,g,p));let b=u-l-1;if(f.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,b)),l!==u){let _=o===u?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(u,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return l+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-l),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=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===s,u,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,s,o,l){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),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<=s;++C){let x=C+f.ydisp,T=this._rowElements[C],M=f.lines.get(x);if(!T||!M)break;T.replaceChildren(...this._rowFactory.createRow(M,x,x===g,_,w,p,b,this.dimensions.css.cell.width,this._widthCache,l?C===n?e:0:-1,l?(C===s?t:o)-1:-1))}}};B_=Ln([Ve(7,my),Ve(8,Tp),Ve(9,Wi),Ve(10,Fi),Ve(11,_l),Ve(12,pa),Ve(13,zc)],B_);var I_=class extends Dt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ue),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Aj(this._optionsService))}catch{this._measureStrategy=this._register(new Mj(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())}};I_=Ln([Ve(2,Wi)],I_);var qT=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)}},Mj=class extends qT{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}},Aj=class extends qT{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}},Lj=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 jj(this._window)),this._onDprChange=this._register(new Ue),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ue),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ci.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(gt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(gt(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}},jj=class extends Dt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ac),this._onDprChange=this._register(new Ue),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=gt(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)}},Oj=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 xy(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-u]}function Bj(e,t,n,s,o,l,u,f,g){if(!l)return;let p=xy(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),s+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var P_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return Bj(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=xy(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])}}};P_=Ln([Ve(0,ma),Ve(1,Tp)],P_);var Ij=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=[]}},VT={};VL(VT,{getSafariVersion:()=>zj,isChromeOS:()=>ZT,isFirefox:()=>YT,isIpad:()=>Hj,isIphone:()=>Uj,isLegacyEdge:()=>Pj,isLinux:()=>Cy,isMac:()=>qf,isNode:()=>Ep,isSafari:()=>GT,isWindows:()=>XT});var Ep=typeof process<"u"&&"title"in process,Pd=Ep?"node":navigator.userAgent,zd=Ep?"node":navigator.platform,YT=Pd.includes("Firefox"),Pj=Pd.includes("Edge"),GT=/^((?!chrome|android).)*safari/i.test(Pd);function zj(){if(!GT)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),Hj=zd==="iPad",Uj=zd==="iPhone",XT=["Windows","Win16","Win32","WinCE"].includes(zd),Cy=zd.indexOf("Linux")>=0,ZT=/\bCrOS\b/.test(Pd),QT=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},$j=class extends QT{_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())}}},Fj=class extends QT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Vf=!Ep&&"requestIdleCallback"in window?Fj:$j,Wj=class{constructor(){this._queue=new Vf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},z_=class extends Dt{constructor(e,t,n,s,o,l,u,f,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Ac),this._pausedResizeTask=new Wj,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 Ue),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ue),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ue),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ue),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Ij((p,b)=>this._renderRows(p,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Kj(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(yn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.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 s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};z_=Ln([Ve(2,Wi),Ve(3,Tp),Ve(4,_l),Ve(5,Id),Ve(6,Fi),Ve(7,pa),Ve(8,zc)],z_);var Kj=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 qj(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return Gj(o,l,e,t,n,s)+Rp(l,t,n,s)+Xj(o,l,e,t,n,s);let u;if(l===t)return u=o>e?"D":"C",md(Math.abs(o-e),pd(u,s));u=l>t?"D":"C";let f=Math.abs(l-t),g=Yj(l>t?e:o,n)+(f-1)*n.cols+1+Vj(l>t?o:e);return md(g,pd(u,s))}function Vj(e,t){return e-1}function Yj(e,t){return t.cols-e}function Gj(e,t,n,s,o,l){return Rp(t,s,o,l).length===0?"":md(eE(e,t,e,t-gl(t,o),!1,o).length,pd("D",l))}function Rp(e,t,n,s){let o=e-gl(e,n),l=t-gl(t,n),u=Math.abs(o-l)-Zj(e,t,n);return md(u,pd(JT(e,t),s))}function Xj(e,t,n,s,o,l){let u;Rp(t,s,o,l).length>0?u=s-gl(s,o):u=t;let f=s,g=Qj(e,t,n,s,o,l);return md(eE(e,u,n,f,g==="C",o).length,pd(g,l))}function Zj(e,t,n){let s=0,o=e-gl(e,n),l=t-gl(t,n);for(let u=0;u<Math.abs(o-l);u++){let f=JT(e,t)==="A"?-1:1;n.buffer.lines.get(o+f*u)?.isWrapped&&s++}return s}function gl(e,t){let n=0,s=t.buffer.lines.get(e),o=s?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s?.isWrapped;return n}function Qj(e,t,n,s,o,l){let u;return Rp(n,s,o,l).length>0?u=s-gl(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function JT(e,t){return e>t?"A":"B"}function eE(e,t,n,s,o,l){let u=e,f=t,g="";for(;(u!==n||f!==s)&&f>=0&&f<l.buffer.lines.length;)u+=o?1:-1,o&&u>l.cols-1?(g+=l.buffer.translateBufferLineToString(f,!1,e,u),u=0,e=0,f++):!o&&u<0&&(g+=l.buffer.translateBufferLineToString(f,!1,0,e+1),u=l.cols-1,e=u,f--);return g+l.buffer.translateBufferLineToString(f,!1,e,u)}function pd(e,t){let n=t?"O":"[";return De.ESC+n+e}function md(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var Jj=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 cx(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,eO=15,tO=50,nO=500,iO=" ",rO=new RegExp(iO,"g"),H_=class extends Dt{constructor(e,t,n,s,o,l,u,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=u,this._renderService=f,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Pr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ue),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ue),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ue),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ue),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 Jj(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,s=[];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 u=e[1];u<=t[1];u++){let f=n.translateBufferLineToString(u,!0,o,l);s.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let u=n.lines.get(l),f=n.translateBufferLineToString(l,!0);u?.isWrapped?s[s.length-1]+=f:s.push(f)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(rO," ")).join(XT?`\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())),Cy&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=cx(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=xy(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*(eO-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(),tO)}_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 s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<nO&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=qj(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let u=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(u.charAt(f)===" "){for(;f>0&&u.charAt(f-1)===" ";)f--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let M=e[0],A=e[0];l.getWidth(M)===0&&(b++,M--),l.getWidth(A)===2&&(_++,A++);let F=l.getString(A).length;for(F>1&&(C+=F-1,g+=F-1);M>0&&f>0&&!this._isCharWordSeparator(l.loadCell(M-1,this._workCell));){l.loadCell(M-1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,M--):z>1&&(w+=z-1,f-=z-1),f--,M--}for(;A<l.length&&g+1<u.length&&!this._isCharWordSeparator(l.loadCell(A+1,this._workCell));){l.loadCell(A+1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,A++):z>1&&(C+=z-1,g+=z-1),g++,A++}}g++;let x=f+p-b+w,T=Math.min(this._bufferService.cols,g-f+b+_-w-C);if(!(!t&&u.slice(f,g).trim()==="")){if(n&&x===0&&l.getCodePoint(0)!==32){let M=o.lines.get(e[1]-1);if(M&&l.isWrapped&&M.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let F=this._bufferService.cols-A.start;x-=F,T+=F}}}if(s&&x+T===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let M=o.lines.get(e[1]+1);if(M?.isWrapped&&M.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(T+=A.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=cx(n,this._bufferService.cols)}};H_=Ln([Ve(3,Fi),Ve(4,_l),Ve(5,gy),Ve(6,Wi),Ve(7,ma),Ve(8,pa)],H_);var ux=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={}}},dx=class{constructor(){this._color=new ux,this._css=new ux}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 s=t[n/36%6|0],o=t[n/6%6|0],l=t[n%6];e.push({css:Gn.toCss(s,o,l),rgba:Gn.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:Gn.toCss(s,s,s),rgba:Gn.toRgba(s,s,s)})}return e})()),il=kn.toColor("#ffffff"),Wu=kn.toColor("#000000"),hx=kn.toColor("#ffffff"),fx=Wu,Ou={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},sO=il,U_=class extends Dt{constructor(e){super(),this._optionsService=e,this._contrastCache=new dx,this._halfContrastCache=new dx,this._onChangeColors=this._register(new Ue),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:il,background:Wu,cursor:hx,cursorAccent:fx,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=rn(e.foreground,il),t.background=rn(e.background,Wu),t.cursor=vn.blend(t.background,rn(e.cursor,hx)),t.cursorAccent=vn.blend(t.background,rn(e.cursorAccent,fx)),t.selectionBackgroundTransparent=rn(e.selectionBackground,Ou),t.selectionBackgroundOpaque=vn.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=rn(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vn.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?rn(e.selectionForeground,ax):void 0,t.selectionForeground===ax&&(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=rn(e.scrollbarSliderBackground,vn.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=rn(e.scrollbarSliderHoverBackground,vn.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=rn(e.scrollbarSliderActiveBackground,vn.opacity(t.foreground,.5)),t.overviewRulerBorder=rn(e.overviewRulerBorder,sO),t.ansi=ei.slice(),t.ansi[0]=rn(e.black,ei[0]),t.ansi[1]=rn(e.red,ei[1]),t.ansi[2]=rn(e.green,ei[2]),t.ansi[3]=rn(e.yellow,ei[3]),t.ansi[4]=rn(e.blue,ei[4]),t.ansi[5]=rn(e.magenta,ei[5]),t.ansi[6]=rn(e.cyan,ei[6]),t.ansi[7]=rn(e.white,ei[7]),t.ansi[8]=rn(e.brightBlack,ei[8]),t.ansi[9]=rn(e.brightRed,ei[9]),t.ansi[10]=rn(e.brightGreen,ei[10]),t.ansi[11]=rn(e.brightYellow,ei[11]),t.ansi[12]=rn(e.brightBlue,ei[12]),t.ansi[13]=rn(e.brightMagenta,ei[13]),t.ansi[14]=rn(e.brightCyan,ei[14]),t.ansi[15]=rn(e.brightWhite,ei[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=rn(e.extendedAnsi[s],ei[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};U_=Ln([Ve(0,Wi)],U_);function rn(e,t){if(e!==void 0)try{return kn.toColor(e)}catch{}return t}var aO=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)}},oO=class{constructor(){this._services=new aO,this._services.set(my,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=e3(e).sort((l,u)=>l.index-u.index),s=[];for(let l of n){let u=this._services.get(l.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},lO={trace:0,debug:1,info:2,warn:3,error:4,off:5},cO="xterm.js: ",$_=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=lO[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?"":cO)+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)}};$_=Ln([Ve(0,Wi)],$_);var px=class extends Dt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ue),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ue),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ue),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Rt=3,Yn=Object.freeze(new Bd),tf=0,nv=2,Ku=class tE{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Rt);let o=n||Pr.fromCharData([0,yT,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],s=n&2097151;return[this._data[t*Rt+1],n&2097152?this._combined[t]:s?io(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}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,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Rt+0]=n|s<<22,this._data[t*Rt+1]=o.fg,this._data[t*Rt+2]=o.bg}addCodepointToCell(t,n,s){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,s&&(o&=-12582913,o|=s<<22),this._data[t*Rt+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new Pr;for(let 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,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new Pr;for(let 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,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*nv<this._data.buffer.byteLength;let s=t*Rt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let f=parseInt(o[u],10);f>=t&&delete this._combined[f]}let l=Object.keys(this._extendedAttrs);for(let u=0;u<l.length;u++){let f=parseInt(l[u],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,s*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 s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new tE(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,s,o,l){let u=t._data;if(l)for(let g=o-1;g>=0;g--){for(let p=0;p<Rt;p++)this._data[(s+g)*Rt+p]=u[(n+g)*Rt+p];u[(n+g)*Rt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<Rt;p++)this._data[(s+g)*Rt+p]=u[(n+g)*Rt+p];u[(n+g)*Rt+2]&268435456&&(this._extendedAttrs[s+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+s]=t._combined[p])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;n<s;){let u=this._data[n*Rt+0],f=u&2097151,g=u&2097152?this._combined[n]:f?io(f):ao;if(l+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),l}};function uO(e,t,n,s,o,l){let u=[];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&&s>=f&&s<g){f+=b.length-1;continue}let _=0,w=gd(b,_,t),C=1,x=0;for(;C<b.length;){let M=gd(b,C,t),A=M-x,F=n-w,z=Math.min(A,F);b[_].copyCellsFrom(b[C],x,w,z,!1),w+=z,w===n&&(_++,w=0),x+=z,x===M&&(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 M=b.length-1;M>0&&(M>_||b[M].getTrimmedLength()===0);M--)T++;T>0&&(u.push(f+b.length-T),u.push(T)),f+=b.length-1}return u}function dO(e,t){let n=[],s=0,o=t[s],l=0;for(let u=0;u<e.length;u++)if(o===u){let f=t[++s];e.onDeleteEmitter.fire({index:u-l,amount:f}),u+=f-1,l+=f,o=t[++s]}else n.push(u);return{layout:n,countRemoved:l}}function hO(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function fO(e,t,n){let s=[],o=e.map((g,p)=>gd(e,p,t)).reduce((g,p)=>g+p),l=0,u=0,f=0;for(;f<o;){if(o-f<n){s.push(o-f);break}l+=n;let g=gd(e,u,t);l>g&&(l-=g,u++);let p=e[u].getWidth(l-1)===2;p&&l--;let b=p?n-1:n;s.push(b),f+=b}return s}function gd(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var nE=class iE{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=iE._nextId++,this._onDispose=this.register(new Ue),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}};nE._nextId=1;var pO=nE,ii={},rl=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 mx=4294967295,gx=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=rl,this.markers=[],this._nullCell=Pr.fromCharData([0,yT,1,0]),this._whitespaceCell=Pr.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 px(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>mx?mx: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 px(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Yn),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let l=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new 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 u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),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++)s+=+this.lines.get(l).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=uO(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Yn),n);if(s.length>0){let o=dO(this.lines,s);hO(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=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,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Yn),o=[],l=0;for(let u=this.lines.length-1;u>=0;u--){let f=this.lines.get(u);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&u>0;)f=this.lines.get(--u),g.unshift(f);if(!n){let z=this.ybase+this.y;if(z>=u&&z<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),b=fO(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 z=0;z<_;z++){let P=this.getBlankLine(Yn,!0);C.push(P)}C.length>0&&(o.push({start:u+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 M=g.length-_-1,A=p;for(;M>=0;){let z=Math.min(A,T);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[M],A-z,T-z,z,!0),T-=z,T===0&&(x--,T=b[x]),A-=z,A===0){M--;let P=Math.max(M,0);A=gd(g,P,this._cols)}}for(let z=0;z<g.length;z++)b[z]<e&&g[z].setCell(b[z],s);let F=_-w;for(;F-- >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 u=[],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 M=_.newLines.length-1;M>=0;M--)this.lines.set(T--,_.newLines[M]);T++,u.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=u.length-1;T>=0;T--)u[T].index+=C,this.lines.onInsertEmitter.fire(u[T]),C+=u[T].amount;let x=Math.max(0,g+l-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new pO(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)}},mO=class extends Dt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ue),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 gx(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gx(!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,sE=1,F_=class extends Dt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ue),this.onResize=this._onResize.event,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,rE),this.rows=Math.max(e.rawOptions.rows||0,sE),this.buffers=this._register(new mO(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;l===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=l-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(l,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};F_=Ln([Ve(0,Wi)],F_);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:{}},gO=["normal","bold","100","200","300","400","500","600","700","800","900"],vO=class extends Dt{constructor(e){super(),this._onOptionChange=this._register(new Ue),this.onOptionChange=this._onOptionChange.event;let t={...oc};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(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,s)=>{if(!(n in oc))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=oc[e]),!_O(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=gO.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 _O(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 s in e)n[s]=t<=1?e[s]:e[s]&&qu(e[s],t-1);return n}var vx=Object.freeze({insertMode:!1}),_x=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),W_=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 Ue),this.onData=this._onData.event,this._onUserInput=this._register(new Ue),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ue),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ue),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=qu(vx),this.decPrivateModes=qu(_x)}reset(){this.modes=qu(vx),this.decPrivateModes=qu(_x)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};W_=Ln([Ve(0,Fi),Ve(1,kT),Ve(2,Wi)],W_);var bx={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 rv=String.fromCharCode,yx={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${rv(t[0])}${rv(t[1])}${rv(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}`}},K_=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 Ue),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(bx))this.addProtocol(s,bx[s]);for(let s of Object.keys(yx))this.addEncoding(s,yx[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};K_=Ln([Ve(0,Fi),Ve(1,_l),Ve(2,Wi)],K_);var sv=[[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]],bO=[[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 yO(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var SO=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<sv.length;++e)ti.fill(0,sv[e][0],sv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ti[e]:yO(e,bO)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=ol.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return ol.createPropertyValue(0,n,s)}},ol=class wf{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ue,this.onChange=this._onChange.event;let t=new SO;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let l=0;l<o;++l){let u=t.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=o)return n+this.wcwidth(u);let p=t.charCodeAt(l);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let f=this.charProperties(u,s),g=wf.extractWidth(f);wf.extractShouldJoin(f)&&(g-=wf.extractWidth(s)),n+=g,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},wO=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 Sx(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,xO=256,aE=class q_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>xO)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 q_;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new q_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>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,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Bu):t}},Iu=[],CO=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 s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=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 s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Iu,this._id=-1,this._state=0}}},fr=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=[],kO=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 s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=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 s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Pu,this._ident=0}},Vu=new aE;Vu.addParam(0);var wx=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}},TO=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},Br=160,EO=(function(){let e=new TO(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),n=(f,g)=>t.slice(f,g),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in l)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Br,0,2,0),e.add(Br,8,5,8),e.add(Br,6,0,6),e.add(Br,11,0,11),e.add(Br,13,13,13),e})(),RO=class extends Dt{constructor(e=EO){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 aE,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(yn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new CO),this._dcsParser=this._register(new kO),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 s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,l=0,u;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&&(u=f[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=f[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===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(s=e[f],o=this._transitions.table[this.currentState<<8|(s<160?s:Br)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(s=e[w])<32||s>126&&s<Br){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Br){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Br){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<Br){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],p=g?g.length-1:-1;for(;p>=0&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,f),u;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++f<t&&(s=e[f])>47&&s<60);f--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let b=this._escHandlers[this._collect<<8|s],_=b?b.length-1:-1;for(;_>=0&&(u=b[_](),u!==!0);_--)if(u instanceof Promise)return this._preserveStack(4,b,_,o,f),u;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let w=f+1;;++w)if(w>=t||(s=e[w])===24||s===26||s===27||s>127&&s<Br){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,f),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=f+1;;w++)if(w>=t||(s=e[w])<32||s>127&&s<Br){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,f),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},DO=/^([\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})$/,NO=/^[\da-f]+$/;function xx(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=DO.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),NO.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return s}}function av(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function MO(e,t=16){let[n,s,o]=e;return`rgb:${av(n,t)}/${av(s,t)}/${av(o,t)}`}var AO={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Qa=131072,Cx=10;function kx(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 Tx=5e3,Ex=0,LO=class extends Dt{constructor(e,t,n,s,o,l,u,f,g=new RO){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=u,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new QL,this._utf8Decoder=new JL,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Yn.clone(),this._eraseAttrDataInternal=Yn.clone(),this._onRequestBell=this._register(new Ue),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ue),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ue),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ue),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ue),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ue),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ue),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ue),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ue),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ue),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ue),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ue),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 V_(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(De.BEL,()=>this.bell()),this._parser.setExecuteHandler(De.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(De.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(De.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(De.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(De.BS,()=>this.backspace()),this._parser.setExecuteHandler(De.HT,()=>this.tab()),this._parser.setExecuteHandler(De.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(De.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(yf.IND,()=>this.index()),this._parser.setExecuteHandler(yf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(yf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new fr(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new fr(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new fr(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new fr(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new fr(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new fr(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new fr(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new fr(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new fr(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new fr(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new fr(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new fr(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 wx((p,b)=>this.requestStatusString(p,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Tx))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Tx} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>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))),u||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(s,o,_,p),this._logSlowResolvingAsync(n),n}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||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 s,o,l=this._charsetService.charset,u=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(s=e[C],s<127&&l){let A=l[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let x=this._unicodeService.charProperties(s,w);o=ol.extractWidth(x);let T=ol.extractShouldJoin(x),M=T?ol.extractWidth(w):0;if(w=x,u&&this._onA11yChar.fire(io(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-M>f){if(g){let A=_,F=this._activeBuffer.x-M;for(this._activeBuffer.x=M,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),M>0&&_ instanceof Ku&&_.copyCellsFrom(A,F,0,M,!1);F<f;)A.setCellFromCodepoint(F++,0,1,b)}else if(this._activeBuffer.x=f-1,o===2)continue}if(T&&this._activeBuffer.x){let A=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-A,s,o);for(let F=o-M;--F>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(p&&(_.insertCells(this._activeBuffer.x,o-M,this._activeBuffer.getNullCell(b)),_.getWidth(f-1)===2&&_.setCellFromCodepoint(f-1,0,1,b)),_.setCellFromCodepoint(this._activeBuffer.x++,s,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=>kx(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new wx(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new fr(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(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 s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=ol.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(l.length*n),f=0;for(let p=0;p<l.length;){let b=l.codePointAt(p)||0;u[f++]=b,p+=b>65535?2:1}let g=f;for(let p=1;p<n;++p)u.copyWithin(g,0,f),g+=f;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(De.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(De.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(De.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(De.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(De.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,rl),this._charsetService.setgCharset(1,rl),this._charsetService.setgCharset(2,rl),this._charsetService.setgCharset(3,rl);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 s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,u=this._coreService,{buffers:f,cols:g}=this._bufferService,{active:p,alt:b}=f,_=this._optionsService.rawOptions,w=(T,M)=>(u.triggerDataEvent(`${De.ESC}[${t?"":"?"}${T};${M}$y`),!0),C=T=>T?1:2,x=e.params[0];return t?x===2?w(x,4):x===4?w(x,C(u.modes.insertMode)):x===12?w(x,3):x===20?w(x,C(_.convertEol)):w(x,0):x===1?w(x,C(s.applicationCursorKeys)):x===3?w(x,_.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?w(x,C(s.origin)):x===7?w(x,C(s.wraparound)):x===8?w(x,3):x===9?w(x,C(o==="X10")):x===12?w(x,C(_.cursorBlink)):x===25?w(x,C(!u.isCursorHidden)):x===45?w(x,C(s.reverseWraparound)):x===66?w(x,C(s.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(s.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(s.bracketedPasteMode)):x===2026?w(x,C(s.synchronizedOutput)):w(x,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=Bd.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let u=e.getSubParams(t+l),f=0;do s[1]===5&&(o=1),s[l+f+1+o]=u[f];while(++f<u.length&&f+l+1+o<s.length);break}if(s[1]===5&&l+o>=2||s[1]===2&&l+o>=5)break;s[1]&&(o=1)}while(++l+t<e.length&&l+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return 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,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Yn.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Yn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Yn.fg&16777215,s.bg&=-67108864,s.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(`${De.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${De.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(`${De.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(!kx(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${De.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Cx&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Cx&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(Rx(l))if(o==="?")t.push({type:0,index:l});else{let u=xx(o);u&&t.push({type:1,index:l,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=xx(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Rx(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,rl),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(AO[e[0]],ii[e[1]]||rl),!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 Pr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${De.ESC}${u}${De.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},V_=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&&(Ex=e,e=t,t=Ex),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};V_=Ln([Ve(0,Fi)],V_);function Rx(e){return 0<=e&&e<256}var jO=5e7,Dx=12,OO=50,BO=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 Ue),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>jO)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=f=>performance.now()-n>=Dx?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(u);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Dx)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>OO&&(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()}},Y_=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,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(u,l)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Y_=Ln([Ve(0,Fi)],Y_);var Nx=!1,IO=class extends Dt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ac),this._onBinary=this._register(new Ue),this.onBinary=this._onBinary.event,this._onData=this._register(new Ue),this.onData=this._onData.event,this._onLineFeed=this._register(new Ue),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ue),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ue),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ue),this._instantiationService=new oO,this.optionsService=this._register(new vO(e)),this._instantiationService.setService(Wi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(F_)),this._instantiationService.setService(Fi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($_)),this._instantiationService.setService(kT,this._logService),this.coreService=this._register(this._instantiationService.createInstance(W_)),this._instantiationService.setService(_l,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(K_)),this._instantiationService.setService(CT,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ol)),this._instantiationService.setService(i3,this.unicodeService),this._charsetService=this._instantiationService.createInstance(wO),this._instantiationService.setService(n3,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Y_),this._instantiationService.setService(TT,this._oscLinkService),this._inputHandler=this._register(new LO(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 BO((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 Ue),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&&!Nx&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Nx=!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,sE),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(Sx.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Sx(this._bufferService),!1))),this._windowsWrappingHeuristics.value=yn(()=>{for(let t of e)t.dispose()})}}},PO={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 zO(e,t,n,s){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=De.ESC+"OA":o.key=De.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=De.ESC+"OD":o.key=De.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=De.ESC+"OC":o.key=De.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=De.ESC+"OB":o.key=De.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":De.DEL,e.altKey&&(o.key=De.ESC+o.key);break;case 9:if(e.shiftKey){o.key=De.ESC+"[Z";break}o.key=De.HT,o.cancel=!0;break;case 13:o.key=e.altKey?De.ESC+De.CR:De.CR,o.cancel=!0;break;case 27:o.key=De.ESC,e.altKey&&(o.key=De.ESC+De.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=De.ESC+"[1;"+(l+1)+"D":t?o.key=De.ESC+"OD":o.key=De.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=De.ESC+"[1;"+(l+1)+"C":t?o.key=De.ESC+"OC":o.key=De.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=De.ESC+"[1;"+(l+1)+"A":t?o.key=De.ESC+"OA":o.key=De.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=De.ESC+"[1;"+(l+1)+"B":t?o.key=De.ESC+"OB":o.key=De.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=De.ESC+"[2~");break;case 46:l?o.key=De.ESC+"[3;"+(l+1)+"~":o.key=De.ESC+"[3~";break;case 36:l?o.key=De.ESC+"[1;"+(l+1)+"H":t?o.key=De.ESC+"OH":o.key=De.ESC+"[H";break;case 35:l?o.key=De.ESC+"[1;"+(l+1)+"F":t?o.key=De.ESC+"OF":o.key=De.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=De.ESC+"[5;"+(l+1)+"~":o.key=De.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=De.ESC+"[6;"+(l+1)+"~":o.key=De.ESC+"[6~";break;case 112:l?o.key=De.ESC+"[1;"+(l+1)+"P":o.key=De.ESC+"OP";break;case 113:l?o.key=De.ESC+"[1;"+(l+1)+"Q":o.key=De.ESC+"OQ";break;case 114:l?o.key=De.ESC+"[1;"+(l+1)+"R":o.key=De.ESC+"OR";break;case 115:l?o.key=De.ESC+"[1;"+(l+1)+"S":o.key=De.ESC+"OS";break;case 116:l?o.key=De.ESC+"[15;"+(l+1)+"~":o.key=De.ESC+"[15~";break;case 117:l?o.key=De.ESC+"[17;"+(l+1)+"~":o.key=De.ESC+"[17~";break;case 118:l?o.key=De.ESC+"[18;"+(l+1)+"~":o.key=De.ESC+"[18~";break;case 119:l?o.key=De.ESC+"[19;"+(l+1)+"~":o.key=De.ESC+"[19~";break;case 120:l?o.key=De.ESC+"[20;"+(l+1)+"~":o.key=De.ESC+"[20~";break;case 121:l?o.key=De.ESC+"[21;"+(l+1)+"~":o.key=De.ESC+"[21~";break;case 122:l?o.key=De.ESC+"[23;"+(l+1)+"~":o.key=De.ESC+"[23~";break;case 123:l?o.key=De.ESC+"[24;"+(l+1)+"~":o.key=De.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=De.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=De.DEL:e.keyCode===219?o.key=De.ESC:e.keyCode===220?o.key=De.FS:e.keyCode===221&&(o.key=De.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let u=PO[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=De.ESC+u;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=De.ESC+g}else if(e.keyCode===32)o.key=De.ESC+(e.ctrlKey?De.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=De.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=De.US),e.key==="@"&&(o.key=De.NUL));break}return o}var Pn=0,HO=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,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Pn=this._search(t),Pn===-1)||this._getKey(this._array[Pn])!==t)return!1;do if(this._array[Pn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pn),!0;while(++Pn<this._array.length&&this._getKey(this._array[Pn])===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),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pn=this._search(e),!(Pn<0||Pn>=this._array.length)&&this._getKey(this._array[Pn])===e))do yield this._array[Pn];while(++Pn<this._array.length&&this._getKey(this._array[Pn])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pn=this._search(e),!(Pn<0||Pn>=this._array.length)&&this._getKey(this._array[Pn])===e))do t(this._array[Pn]);while(++Pn<this._array.length&&this._getKey(this._array[Pn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},ov=0,Mx=0,UO=class extends Dt{constructor(){super(),this._decorations=new HO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ue),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ue),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 $O(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{ov=o.options.x??0,Mx=ov+(o.options.width??1),e>=ov&&e<Mx&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},$O=class extends lo{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ue),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ue),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()}},FO=1e3,WO=class{constructor(e,t=FO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,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)}},Ax=20,Yf=class extends Dt{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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 WO(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(gt(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<Ax+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ax+1&&(this._liveRegion.textContent+=p_.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let l=n.lines.get(n.ydisp+o),u=[],f=l?.translateToString(!0,void 0,void 0,u)||"",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,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let u,f;if(t===0?(u=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(u=this._rowElements.shift(),f=n,this._rowContainer.removeChild(u)),u.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 s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node: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),u=o(n);if(!(!l||!u)){if(l.row>u.row||l.row===u.row&&l.column>=u.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(u.row-l.row)*this._terminal.cols-l.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Yf=Ln([Ve(1,my),Ve(2,pa),Ve(3,ma)],Yf);var G_=class extends Dt{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ue),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ue),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(gt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(gt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(gt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(gt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):o.provideLinks(e.y,l=>{if(this._isMouseOut)return;let u=l?.map(f=>({link:f}));this._activeProviderReplies?.set(s,u),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let u=o[l],f=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=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 s=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&&s){let l=s.find(u=>this._linkAtPosition(u.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 u=this._activeProviderReplies.get(l)?.find(f=>this._linkAtPosition(f.link,t));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&KO(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 s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let 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,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};G_=Ln([Ve(1,gy),Ve(2,ma),Ve(3,Fi),Ve(4,RT)],G_);function KO(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 qO=class extends IO{constructor(e={}){super(e),this._linkifier=this._register(new Ac),this.browser=VT,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ac),this._onCursorMove=this._register(new Ue),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ue),this.onKey=this._onKey.event,this._onRender=this._register(new Ue),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ue),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ue),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ue),this.onBell=this._onBell.event,this._onFocus=this._register(new Ue),this._onBlur=this._register(new Ue),this._onA11yCharEmitter=this._register(new Ue),this._onA11yTabEmitter=this._register(new Ue),this._onWillOpen=this._register(new Ue),this._setup(),this._decorationService=this._instantiationService.createInstance(UO),this._instantiationService.setService(Id,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Oj),this._instantiationService.setService(RT,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(g_)),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,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=vn.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${De.ESC}]${s};${MO(o)}${KT.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(u=>u[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(De.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(De.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,u=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=u+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(gt(this.element,"copy",t=>{this.hasSelection()&&XL(t,this._selectionService)}));let e=t=>ZL(t,this.textarea,this.coreService,this.optionsService);this._register(gt(this.textarea,"paste",e)),this._register(gt(this.element,"paste",e)),YT?this._register(gt(this.element,"mousedown",t=>{t.button===2&&$1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(gt(this.element,"contextmenu",t=>{$1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Cy&&this._register(gt(this.element,"auxclick",t=>{t.button===1&&bT(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(gt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(gt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(gt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(gt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(gt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(gt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(gt(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(gt(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",f_.get()),ZT||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(Lj,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(pa,this._coreBrowserService),this._register(gt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(gt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(I_,this._document,this._helperContainer),this._instantiationService.setService(Tp,this._charSizeService),this._themeService=this._instantiationService.createInstance(U_),this._instantiationService.setService(zc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Kf),this._instantiationService.setService(ET,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(z_,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(j_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(P_),this._instantiationService.setService(gy,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(G_,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(A_,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(H_,this.element,this.screenElement,s)),this._instantiationService.setService(s3,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(L_,this.screenElement)),this._register(gt(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(B_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){let u=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!u)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:u.col,row:u.row,x:u.x,y:u.y,button:f,action:g,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.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?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(gt(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register(gt(t,"wheel",l=>{if(!s.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 u=De.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!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){_T(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=zO(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===De.ETX||n.key===De.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)&&(VO(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(De.ESC+"[I"):this.coreService.triggerDataEvent(De.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${De.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${De.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function VO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var YO=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)}},GO=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Pr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Lx=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 GO(t)}getNullCell(){return new Pr}},XO=class extends Dt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ue),this.onBufferChange=this._onBufferChange.event,this._normal=new Lx(this._core.buffers.normal,"normal"),this._alternate=new Lx(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)}},ZO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},QO=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}},JO=["cols","rows"],vs=0,eB=class extends Dt{constructor(e){super(),this._core=this._register(new qO(e)),this._addonManager=this._register(new YO),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(JO.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 ZO(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new QO(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 XO(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 f_.get()},set promptLabel(e){f_.set(e)},get tooMuchOutput(){return p_.get()},set tooMuchOutput(e){p_.set(e)}}}_verifyIntegers(...e){for(vs of e)if(vs===1/0||isNaN(vs)||vs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(vs of e)if(vs&&(vs===1/0||isNaN(vs)||vs%1!==0||vs<0))throw new Error("This API only accepts positive integers")}};function Dp(e){return e.normalize("NFC").trim().toLowerCase()}function tB(e){const t=Dp(e);if(t.length>256)return"Use at most 256 characters.";const n=[...t.replace(/\s/gu,"")].length,s=/[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/u.test(t)?2:3;return n<s?`Enter at least ${s} non-space characters.`:null}const nB=zt.lazy(()=>py(()=>import("./TranscriptMarkdownBody-3aYVmqQz.js"),__vite__mapDeps([2,1])));function oE({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:o,fontSize:l}){const u=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 F=0;F<C.length;F++)x=Math.imul(x^C.charCodeAt(F),16777619),T=Math.imul(T,33)^C.charCodeAt(F);const M=`${C.length}:${x>>>0}:${T>>>0}`,A=p.get(M)??0;p.set(M,A+1),b[_]=`${M}:${A}`}return b},[e]);v.useEffect(()=>{if(n===null)return;const p=u.current.get(n);if(!p||typeof p.scrollIntoView!="function")return;if(s==="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,s,o,t]);let g=-1;return d.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?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return d.jsxs("section",{ref:C=>{C?u.current.set(b,C):u.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?d.jsx("div",{className:"transcript-entry-header",children:lE(p.header,t)}):null,p.body?d.jsx("div",{className:"transcript-entry-body",children:p.kind==="tool"?d.jsx(jx,{text:p.body,searchQuery:t}):d.jsx(zt.Suspense,{fallback:d.jsx(jx,{text:p.body,searchQuery:t}),children:d.jsx(nB,{text:p.body,searchQuery:t})})}):null]},f[b])})})}function jx({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
31
|
-
`)?e.slice(0,-1).split(`
|
|
32
|
-
`):e.split(`
|
|
33
|
-
`);return d.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,o)=>d.jsx("span",{className:`transcript-line transcript-line-${oB(s,o===0||n[o-1]?.trim()==="")}`,children:lE(s,t)},o))})}function lE(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),o=n.toLowerCase(),l=[];let u=0,f=s.indexOf(o);for(;f!==-1;){f>u&&l.push(e.slice(u,f));const g=f+n.length;l.push(d.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),u=g,f=s.indexOf(o,u)}return u<e.length&&l.push(e.slice(u)),l.length>0?l:e||" "}function iB(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const s=e.toLowerCase();let o=0,l=s.indexOf(n);for(;l!==-1;)o+=1,l=s.indexOf(n,l+n.length);return o}function X_(e){const t=e.endsWith(`
|
|
34
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,o="plain",l=[];function u(){const f=rB(l).join(`
|
|
35
|
-
`);(s||f)&&n.push({header:s,body:f,kind:o}),s=null,o="plain",l=[]}for(const f of t.split(`
|
|
36
|
-
`)){const g=sB(f);g?(u(),s=f,o=g):l.push(f)}return u(),n}function rB(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function sB(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 aB(e,t){const n=[];for(let s=0;s<e.length;s+=1){const o=e[s];if(!o)continue;const l=o.header?`${o.header}
|
|
37
|
-
${o.body}`:o.body,u=iB(l,t);for(let f=0;f<u;f+=1)n.push({entryIndex:s,matchIndexInEntry:f})}return n}function oB(e,t){const n=e.trim();if(!n)return"blank";const s=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(s)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(o||t)&&/^System$/.test(s)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||uE(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 s=`[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(s,"").replace(/\n{3,}/g,`
|
|
40
|
-
|
|
41
|
-
`).trimEnd(),l=ky(o),u=n.includeTools?l:cE(l);return u?`${u}
|
|
42
|
-
`:""}function ky(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const s=lB(n);return s?`[${s}]`:t})}function lB(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=zu(t.getMonth()+1),o=zu(t.getDate()),l=zu(t.getHours()),u=zu(t.getMinutes()),f=zu(t.getSeconds());return`${n}-${s}-${o} ${l}:${u}:${f}`}function zu(e){return e.toString().padStart(2,"0")}function Gf(e,t){return e.map(n=>t?n:cE(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
43
|
-
`)?n:`${n}
|
|
44
|
-
`).join("")}function cE(e){if(!e)return"";const t=e.split(`
|
|
45
|
-
`),n=[];let s=!1,o=!1,l=!0;for(const u of t){const f=u.trim()==="",g=l?cB(u):null;if(g&&(s=g==="tool",o=!1),uE(u)){o=!0,l=!1;continue}if(o){f?(o=!1,s||n.push(u),l=!0):l=!1;continue}s||n.push(u),l=f}return n.join(`
|
|
46
|
-
`).replace(/\n{3,}/g,`
|
|
47
|
-
|
|
48
|
-
`).trimEnd()}function cB(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function uE(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function ca(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Ox(e,t){return e===null?t===null:t!==null&&ca(e,t)}const uB=5e3,dB=200,hB=1200,fB=4,pB=zt.memo(function({terminalId:t,serverApi:n,source:s,fontSize:o,onClose:l}){const u=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),[M,A]=v.useState(null),[F,z]=v.useState(()=>new Set),[P,W]=v.useState(!1),[$,L]=v.useState(!1),[X,ge]=v.useState([]),[ne,ie]=v.useState(null),[G,J]=v.useState(!1),[ae,ee]=v.useState(!1),[O,R]=v.useState(!1),[I,se]=v.useState(null),_e=w?.find(j=>j.id===M)??null;v.useEffect(()=>{function j(ve){ve.key==="Escape"&&(ve.preventDefault(),ve.stopPropagation(),l())}return document.addEventListener("keydown",j,!0),()=>document.removeEventListener("keydown",j,!0)},[l]);const N=v.useCallback(async()=>{try{const j=await n.getTerminalSubagents(t);if(T(null),C(ve=>ve&&bB(ve,j.subagents)?ve:j.subagents),!_.current){const ve=j.subagents.find(Ae=>Ae.hasTranscript);ve&&(_.current=!0,A(Ae=>Ae??ve.id))}}catch(j){T(j instanceof Error?j.message:"Failed to load subagents."),C(ve=>ve??[])}},[n,t]);v.useEffect(()=>{N();const j=window.setInterval(()=>{document.hidden||N()},uB);function ve(){document.hidden||N()}return document.addEventListener("visibilitychange",ve),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",ve)}},[N]),v.useEffect(()=>{f.current+=1;const j=f.current;return g.current=!1,p.current=!0,b.current=null,ge([]),ie(null),J(!1),se(null),M&&V(null,"initial",j),()=>{f.current===j&&(f.current+=1)}},[n,t,M,$]),v.useLayoutEffect(()=>{const j=u.current;if(!j)return;if(p.current){if(ae||X.length===0)return;p.current=!1;const Ae=()=>{j.scrollTop=j.scrollHeight};Ae(),window.requestAnimationFrame?.(Ae);return}const ve=b.current;ve!==null&&(b.current=null,j.scrollTop+=j.scrollHeight-ve)},[X,ae,$]);async function V(j,ve,Ae=f.current){const Ie=M;if(!(!Ie||g.current)){g.current=!0,ve==="initial"?ee(!0):(R(!0),b.current=u.current?.scrollHeight??null),se(null);try{let U=j,de=0,ke=0,Me=[];for(;f.current===Ae;){const Le=await n.getTerminalSubagentTranscriptHistory(t,Ie,{...U?{cursor:U}:{},limit:dB,maxLines:hB,includeTools:$});if(f.current!==Ae)return;if(!Le.source){if(ke<1){ke+=1,await new Promise($e=>setTimeout($e,600));continue}se("Subagent transcript is unavailable.");return}const be=dc(Le.output,Le.source.provider,{includeTools:$});if(ie(Le.cursor),J(!!(Le.hasMore&&Le.cursor)),be&&(Me=[be,...Me],Gf(Me,$))){ge($e=>ve==="older"?[...Me,...$e]:Me);return}if(!Le.hasMore||!Le.cursor||de>=fB){Me.length>0&&ge($e=>ve==="older"?[...Me,...$e]:Me);return}U=Le.cursor,de+=1}}catch(U){if(f.current!==Ae)return;se(U instanceof Error?U.message:"Failed to load subagent transcript.")}finally{f.current===Ae&&(g.current=!1,ee(!1),R(!1))}}}function pe(){const j=u.current;j&&(j.scrollTop>72||!G||!ne||g.current||V(ne,"older"))}function Z(j){z(ve=>{const Ae=new Set(ve);return Ae.delete(j)||Ae.add(j),Ae})}function Q(j){_.current=!0,W(!0),j.id!==M&&A(j.id),le(j.id)}function le(j){const ve=vB(w??[],j);ve.length!==0&&z(Ae=>{if(ve.every(U=>Ae.has(U)))return Ae;const Ie=new Set(Ae);for(const U of ve)Ie.add(U);return Ie})}function Te(){f.current+=1;const j=f.current;g.current=!1,p.current=!0,b.current=null,ge([]),ie(null),J(!1),se(null),V(null,"initial",j)}const je=v.useMemo(()=>Gf(X,$),[X,$]),Fe=v.useMemo(()=>X_(je),[je]),Se=w===null;v.useEffect(()=>{if(ae||O||!G||!ne||g.current)return;const j=u.current;!j||X.length===0||j.scrollHeight<=j.clientHeight+4&&V(ne,"older")},[X,G,ne,ae,O]);const ze=w?.filter(j=>j.state==="working").length??0,Oe=v.useMemo(()=>fE(mB(w??[]),F),[w,F]);return d.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),onClick:j=>{j.stopPropagation(),l()},children:d.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":P?"transcript":"list",onPointerDown:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),onClick:j=>j.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?d.jsx("span",{className:"subagents-count",children:ze>0?`${ze} working · ${w.length} total`:`${w.length} total`}):null]}),d.jsxs("span",{title:s.sessionId,children:[co(s.provider)," session ",s.sessionId]})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:l,children:"×"})]}),d.jsxs("div",{className:"subagents-body",children:[d.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[Se?d.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Se&&x?d.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!Se&&!x&&w!==null&&w.length===0?d.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Oe.map(j=>{const ve=j.subagent,Ae=F.has(ve.id);return d.jsxs("div",{className:"subagent-row-wrap",style:j.level>0?{paddingLeft:`${Math.min(j.level,4)*14}px`}:void 0,children:[j.nestedCount>0?d.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":Ae,"aria-label":`${Ae?"Collapse":"Expand"} ${j.nestedCount} nested subagents of ${ve.name}`,title:j.nestedWorkingCount>0?`${j.nestedCount} nested · ${j.nestedWorkingCount} working`:`${j.nestedCount} nested`,onClick:()=>Z(ve.id),children:[d.jsx("span",{"aria-hidden":"true",children:Ae?"▾":"▸"}),d.jsx("span",{className:"subagent-expander-count","data-working":j.nestedWorkingCount>0?"true":"false",children:j.nestedCount})]}):d.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),d.jsxs("button",{type:"button",className:"subagent-row","data-selected":ve.id===M?"true":"false","data-state":ve.state,disabled:!ve.hasTranscript,title:ve.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Q(ve),children:[d.jsx("span",{className:"subagent-row-dot","data-state":ve.state,"aria-hidden":"true"}),d.jsxs("span",{className:"subagent-row-main",children:[d.jsxs("span",{className:"subagent-row-title",children:[d.jsx("strong",{children:ve.name}),d.jsx("span",{className:"subagent-row-badge","data-kind":ve.kind,children:ve.kind==="cross"?co(ve.provider):ve.provider})]}),ve.description?d.jsx("span",{className:"subagent-row-description",children:ve.description}):null,d.jsxs("span",{className:"subagent-row-meta",children:[yB(ve.state),ve.model?` · ${ve.model}`:"",ve.updatedAt?` · ${SB(ve.updatedAt)}`:"",j.nestedCount>0&&!Ae?` · ${j.nestedCount} nested${j.nestedWorkingCount>0?` (${j.nestedWorkingCount} working)`:""}`:""]})]})]})]},ve.id)})]}),d.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[d.jsxs("div",{className:"subagents-transcript-controls",children:[d.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>W(!1),children:"‹ List"}),d.jsx("span",{className:"subagents-transcript-name",children:_e?_e.name:"Select a subagent"}),d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:$,onChange:j=>L(j.currentTarget.checked)}),"Show tool output"]}),d.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!_e,onClick:Te,children:"↻"})]}),_e?d.jsx("div",{className:"subagents-transcript-hint",children:_B(_e)}):null,d.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:pe,children:[O?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ae&&G?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,je?d.jsx(oE,{entries:Fe,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,ae?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!ae&&_e&&!je&&!I?G&&ne?d.jsxs("div",{className:"transcript-dialog-status",children:[$?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{V(ne,"older")},disabled:O,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!_e&&!Se&&!je?d.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,I?d.jsx("div",{className:"transcript-dialog-error",children:I}):null]})]})]})]})})});function mB(e){const t=new Map;for(const s of e)t.set(s.id,{subagent:s,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const s of t.values()){const o=gB(s,t);o?o.children.push(s):n.push(s)}for(const s of n)dE(s);return hE(n),n}function gB(e,t){const n=e.subagent.parentId;if(!n)return null;const s=t.get(n);if(!s||s===e)return null;const o=new Set([e.subagent.id]);for(let l=s;l;){if(o.has(l.subagent.id))return null;o.add(l.subagent.id);const u=l.subagent.parentId;l=u?t.get(u):void 0}return s}function dE(e){let t=0,n=0;for(const s of e.children)dE(s),t+=1+s.nestedCount,n+=(s.subagent.state==="working"?1:0)+s.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,hE(e.children)}function hE(e){e.sort((t,n)=>{const s=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return s!==o?s-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function fE(e,t,n=0){const s=[];for(const o of e)s.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&s.push(...fE(o.children,t,n+1));return s}function vB(e,t){const n=new Map(e.map(u=>[u.id,u])),s=[],o=new Set([t]);let l=n.get(t)?.parentId??null;for(;l&&!o.has(l);)o.add(l),s.push(l),l=n.get(l)?.parentId??null;return s}function _B(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 bB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(s.id!==o.id||s.provider!==o.provider||s.kind!==o.kind||s.name!==o.name||s.description!==o.description||s.model!==o.model||s.spawnDepth!==o.spawnDepth||s.parentId!==o.parentId||s.state!==o.state||s.updatedAt!==o.updatedAt||s.hasTranscript!==o.hasTranscript)return!1}return!0}function yB(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function SB(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const s=Math.round(n/6e4);if(s<60)return`${s}m ago`;const o=Math.round(s/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function wB({options:e,value:t,onSelect:n}){const[s,o]=v.useState(!1),l=v.useRef(null),u=v.useRef(null),f=e.find(g=>g.id===t);return v.useEffect(()=>{if(!s)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),u.current?.focus();else if(["ArrowDown","ArrowUp","Home","End"].includes(w.key)){w.preventDefault(),w.stopPropagation();const C=g(),x=C.findIndex(M=>M===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)}},[s]),d.jsxs("div",{className:"transcript-session-menu",ref:l,children:[d.jsxs("button",{ref:u,type:"button",className:"transcript-session-trigger","aria-label":"Transcript session","aria-haspopup":"menu","aria-expanded":s,onClick:()=>o(!s),children:[d.jsx("span",{children:f?.title??"Choose a session"}),d.jsx(aA,{size:16,"aria-hidden":"true"})]}),s?d.jsx("div",{className:"transcript-session-options",role:"menu","aria-label":"Transcript sessions",children:e.map(g=>d.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t===g.id,tabIndex:-1,onClick:()=>{o(!1),u.current?.focus(),n(g.id)},children:[d.jsx("span",{className:"transcript-session-check",children:t===g.id?d.jsx(Nk,{size:16}):null}),d.jsxs("span",{className:"transcript-session-copy",children:[d.jsx("strong",{children:g.title}),d.jsx("small",{children:g.detail})]})]},g.id))}):null]})}function Ty(e){const t=new Set;return e.filter(n=>t.has(n.id)?!1:(t.add(n.id),!0))}function Z_(e){return!e.page||e.page.unchanged?null:{page:{...e.page,records:Ty(e.page.records)},cursor:e.cursor,hasMore:e.hasMore,scrollTop:0,atBottom:!0}}function Bx(e,t){const n=Z_(t);if(!n||n.page.identity!==e.page.identity||n.page.endOffset!==e.page.startOffset)return null;const s=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!s&&!o?null:{...e,page:{...e.page,startOffset:n.page.startOffset,records:Ty([...n.page.records,...e.page.records])},cursor:n.cursor,hasMore:n.hasMore}}function pE(e,t){return e.identity===t.identity&&(t.snapshotSize>e.snapshotSize||t.snapshotSize===e.snapshotSize&&t.snapshotMtime===e.snapshotMtime)}function mE(e,t){return!pE(e.page,t.page)||t.page.startOffset<=e.page.stableBefore||t.page.startOffset<=e.page.startOffset}function xB(e,t){if(!pE(e.page,t.page)||!mE(e,t))return t;const n=new Set(t.page.records.map(l=>l.id)),s=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:Ty([...s,...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 CB=64*1024*1024,kB=1800*1e3;let Q_=0,J_=new WeakMap;const vd=new Map,_d=new Set;function TB(e){const t=e.page;return 2*(t.identity.length+t.snapshot.length+(e.cursor?.length??0)+t.records.reduce((n,s)=>n+s.id.length+s.block.length,0))}function eb(e){e.owner.delete(e.key),_d.delete(e),e.snapshot=null,e.bytes=0}function lv(e){for(const s of _d)!s.leases&&e-s.closedAt>=kB&&eb(s);let t=0;const n=[];for(const s of _d)t+=s.bytes,s.leases||n.push(s);n.sort((s,o)=>s.closedAt-o.closedAt);for(const s of n){if(t<=CB)break;t-=s.bytes,eb(s)}for(const[s,o]of vd)o.size||vd.delete(s)}function cv(){Q_+=1;for(const e of _d)eb(e);vd.clear(),J_=new WeakMap}function EB(e,t,n,s){lv(Date.now());const o=e.transcriptCacheScope;let l=o===void 0?J_.get(e):vd.get(o);l||(l=new Map,o===void 0?J_.set(e,l):vd.set(o,l));const u=JSON.stringify([t,n.provider,n.sessionId,s]);let f=l.get(u);f||(f={snapshot:null,bytes:0,leases:0,closedAt:0,owner:l,key:u},l.set(u,f),_d.add(f));const g=Q_,p=f;p.leases+=1;let b=!1;const _=()=>!b&&g===Q_;return{get snapshot(){return _()?p.snapshot:null},current:_,write(w){_()&&(p.snapshot=w,p.bytes=TB(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 RB(e,t,n){if(!e.length)return null;const s=t.timestamp?ky(`[${t.timestamp}] ${t.role}`):null;let o=e.length-1;if(s){for(let u=e.length-1;u>=0;u-=1)if(e[u]?.header===s){o=u;break}}const l=aB(e,Dp(n)).filter(u=>u.entryIndex===o);return(s&&e[o]?.header===s?l[0]:l.at(-1))??{entryIndex:o,matchIndexInEntry:0}}function DB(e,t,n,s,o,l){const[u,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,s,o,l]);async function M(A=!1){const F=tB(l);if(F){_(F);return}x();const z=C.current,P=new AbortController;w.current=P,p(!0),_(null);let W=A?u:null;A||f(null);try{for(let $=0;$<4;$+=1){const L=await e.searchTerminalTranscript(t,{query:Dp(l),...W?.cursor?{cursor:W.cursor}:{},...s?{candidateId:s}:{},expectedSessionId:n.sessionId,includeTools:o},P.signal);if(P.signal.aborted||z!==C.current)return;if(!L.source||L.source.provider!==n.provider||L.source.sessionId!==n.sessionId)throw new Error("Transcript source changed or is unavailable. Choose a session again.");const X=new Set(W?.hits.map(ie=>ie.id)),ge=[...W?.hits??[],...L.hits.filter(ie=>!X.has(ie.id))],ne=W?.cursor;if(W={...L,hits:ge.slice(-200)},f(W),L.complete||!L.cursor||L.cursor===ne||L.hits.length)break}}catch($){!P.signal.aborted&&z===C.current&&_($ instanceof Error?$.message:"Search failed.")}finally{z===C.current&&p(!1)}}return{result:u,busy:g,error:b,search:M,cancel:T}}class NB{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():bE.has(t)?this.acceptConsonant(t):yE.has(t)?this.acceptVowel(t):jB(t)&&this.canReplacePendingWith(t)?(this.pending=Px(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(SE.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=LB.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const l=AB.get(`${this.pending.vowel}${t}`);return l?(this.pending.vowel=l,""):this.flushPending()+t}const n=Ix.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 s=this.pending.final,o=zx({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=Ix.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=Px(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=zx(this.pending);return this.pending=null,t}}const Xf=44032,Zf=21,bc=28,MB=19*Zf*bc,gE=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],vE=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],_E=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],bE=Ey(gE),yE=Ey(vE),SE=Ey(_E),AB=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),wE=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],LB=new Map(wE),Ix=new Map(wE.map(([e,t])=>[t,[e[0],e[1]]]));function Ey(e){return new Map(e.map((t,n)=>[t,n]))}function jB(e){const t=e.codePointAt(0);return t!==void 0&&t>=Xf&&t<Xf+MB}function Px(e){const t=e.codePointAt(0)-Xf,n=Math.floor(t/(Zf*bc)),s=Math.floor(t%(Zf*bc)/bc),o=t%bc,l={initial:gE[n],vowel:vE[s]};return o===0?l:{...l,final:_E[o]}}function zx(e){if(!e.vowel)return e.initial;const t=bE.get(e.initial),n=yE.get(e.vowel),s=e.final?SE.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Xf+(t*Zf+n)*bc+s)}const OB=[{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 BB({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:s,onHide:o}){function l(u){u.preventDefault(),u.stopPropagation(),s()}return d.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:l,onPointerDown:l,children:[d.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"}),OB.map(u=>d.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),d.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const IB={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function PB(e){return IB[e]}function zB(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const xE="--nterminal-viewport-height",CE="--nterminal-keyboard-inset-bottom",kE="data-nterminal-keyboard-visible",Np="data-nterminal-compose-open",Qf="nterminal:viewport-refresh",HB=120;function UB(e=window){const t=e.document.documentElement,n=e.visualViewport,s=VB(e);function o(){Ry(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),s?.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),s?.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(xE),t.style.removeProperty(CE),t.removeAttribute(kE)}}function Ry(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=tb(e),o=$B(e,s);return o!==null&&Hx(t,xE,`${o}px`),Hx(t,CE,`${n}px`),FB(t,kE,String(s)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:s}}function tb(e=window){const t=WB(e);return{keyboardInsetBottom:t,keyboardVisible:t>HB}}function $B(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 Hx(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function FB(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function WB(e){return Math.max(KB(e),qB(e))}function KB(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 qB(e){if(!dl(e.innerHeight))return 0;const n=TE(e)?.boundingRect?.height;return!dl(n)||n>=e.innerHeight*.8?0:Math.round(n)}function TE(e){return e.navigator.virtualKeyboard}function VB(e){const t=TE(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Hd=new Map,bd=new Map,YB=Object.freeze({open:!1,text:""});function GB(e){let t=bd.get(e);return t||(t=new Set,bd.set(e,t)),t}function EE(e){const t=bd.get(e);if(t)for(const n of Array.from(t))n()}function kc(e){return Hd.get(e)??YB}function XB(e,t){const n=GB(e);return n.add(t),()=>{n.delete(t)}}function ZB(e,t){const n=kc(e);n.open!==t&&(Hd.set(e,{...n,open:t}),EE(e))}function QB(e,t){const n=kc(e);n.text!==t&&(Hd.set(e,{...n,text:t}),EE(e))}function Hu(e){Hd.delete(e),bd.delete(e)}function Ux(){Hd.clear(),bd.clear()}const _o=new Map,yd=new Map,Jf=new Map,JB=Object.freeze([]);function Sd(e){return _o.get(e)??JB}function e5(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 nb(e){Jf.delete(e)}function Uu(e,t,n){const s=Sd(e);s.length!==0&&(_o.set(e,s.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 RE(e){const t=_o.get(e);if(t){for(const n of t)n.cancel?.();_o.delete(e),Mp(e)}}function hc(e){RE(e),nb(e),yd.delete(e)}function $x(){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 t5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function yc(e){return e?Array.from(e.types??[]).includes("Files")||Ny(e.items).some(n=>n.kind==="file")?!0:LE(e.files).length>0:!1}async function DE(e){const t=Ny(e.items).filter(n=>n.kind==="file");return t.length>0?i5(t):NE(e.files)}function n5(e){const t=Ny(e.items).filter(o=>o.kind==="file").flatMap(o=>{const l=o.getAsFile();return l?[{relativePath:Dy(l),file:l}]:[]}),n=NE(e.files);if(t.length===0)return n;if(n.length===0)return t;const s=[...t];for(const o of n)s.some(l=>o5(l.file,o.file))||s.push(o);return s}async function i5(e){const t=[];for(const n of e){const s=l5(n);if(s){await ME(s,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Dy(o),file:o});continue}throw new t5("Folder upload is not supported by this browser.")}return t}function NE(e){return LE(e).map(t=>({relativePath:Dy(t),file:t}))}async function ME(e,t,n){const s=u5(t,e.name);if(e.isFile){const u=await r5(e);n.push({relativePath:s,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),l=await s5(o);for(const u of l)await ME(u,s,n)}function r5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function s5(e){const t=[];for(;;){const n=await a5(e);if(n.length===0)return t;t.push(...n)}}function a5(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function Dy(e){const t=e.webkitRelativePath;return AE(typeof t=="string"&&t?t:e.name)}function o5(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified}function l5(e){const t=e.webkitGetAsEntry?.();return c5(t)?t:null}function c5(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 u5(e,t){return AE(e?`${e}/${t}`:t)}function AE(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Ny(e){return e?Array.from(e):[]}function LE(e){return e?Array.from(e):[]}const d5=120,h5="\x1B[200~",f5="\x1B[201~";function hv(e,t){const n=t.stripTrailingLineBreaks===!1?e:My(e),s=m5(n);return s?t.bracketedPasteMode?`${h5}${s}${f5}`:s:""}function p5(e){return e==="queue"?" ":"\r"}function My(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function m5(e){return e.replace(/\r\n/g,`
|
|
49
|
-
`).replace(/\r/g,`
|
|
50
|
-
`).replace(/\n/g,"\r")}const g5=420,v5=3e3,Fx=650,_5=80,b5=3,y5=10,S5=50*1024*1024,w5=100*1024*1024,x5=2,C5={maxFiles:y5,maxFileBytes:S5,maxBatchBytes:w5},xf=new Set;let Tc=null;function k5({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1,onUploadAttachments:o,onGetAttachmentLimits:l,onDeleteAttachments:u}){const f=v.useMemo(()=>j=>XB(e,j),[e]),g=v.useMemo(()=>()=>kc(e),[e]),p=v.useSyncExternalStore(f,g,g),{open:b,text:_}=p,w=v.useMemo(()=>j=>e5(e,j),[e]),C=v.useMemo(()=>()=>Sd(e),[e]),x=v.useSyncExternalStore(w,C,C),[T,M]=v.useState(C5),[A,F]=v.useState(!1),z=v.useRef(null),P=v.useRef(null),W=v.useRef(null),$=v.useRef(null),L=v.useRef(new Map),X=v.useRef(l),ge=v.useRef(u),ne=v.useRef(null),ie=v.useRef({start:0,end:0});X.current=l,ge.current=u,v.useEffect(()=>()=>{ne.current?.(),ne.current=null},[]),v.useEffect(()=>{if(!b||!X.current)return;let j=!0;return X.current().then(ve=>{j&&M(ve)}).catch(()=>{}),()=>{j=!1}},[b,e]),v.useLayoutEffect(()=>{if(!(!b||!Cf()))return L5(e),()=>j5(e)},[b,e]),v.useLayoutEffect(()=>{const j=z.current?.closest(".terminal-pane");if(!j)return;function ve(){j?.removeAttribute("data-compose-open"),j?.style.removeProperty("--compose-drawer-panel-height")}if(!b){ve();return}const Ae=P.current;j.setAttribute("data-compose-open","true");function Ie(){const Me=Ae?.getBoundingClientRect().height??0;Me>0&&j?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Me)}px`)}Ie();const U=[window.setTimeout(Ie,0),window.setTimeout(Ie,180),window.setTimeout(Ie,260)],de=window.requestAnimationFrame?.(Ie)??null,ke=typeof ResizeObserver=="function"&&Ae?new ResizeObserver(Ie):null;return ke&&Ae&&ke.observe(Ae),()=>{for(const Me of U)window.clearTimeout(Me);de!==null&&window.cancelAnimationFrame?.(de),ke?.disconnect(),ve()}},[b]),v.useEffect(()=>{if(!b){ne.current?.(),ne.current=null;return}gv(W.current),Se()},[b]);function G(j){ZB(e,j)}function J(j){QB(e,j)}function ae(){A5(z.current),G(!1),qx()}function ee(j="send"){const ve=x.filter(Ie=>Ie.status==="uploaded"&&Ie.path);if(s||x.some(Ie=>Ie.status==="uploading"||Ie.status==="failed")||!_&&ve.length===0)return;const Ae=R5(_,x);if(Ae.parts.some(Ie=>Ie.kind==="image"||Ie.value.trim())&&t(Ae,j)){if(J(""),RE(e),nb(e),Cf()){W.current?.blur(),qx();return}window.setTimeout(()=>W.current?.focus(),d5+20)}}async function O(j){if(s||j.length===0)return;const ve=Sd(e).filter(be=>be.status!=="failed"),Ae=ve.reduce((be,$e)=>be+$e.file.size,0);let Ie=0,U=ve.length;const de=[],ke=j.filter((be,$e)=>{const We=Ae+Ie+be.file.size,He=be.file.size>T.maxFileBytes?`File exceeds the ${Kx(T.maxFileBytes)} attachment limit.`:U>=T.maxFiles?`A compose message can include up to ${T.maxFiles} attachments.`:We>T.maxBatchBytes?`Compose attachments cannot exceed ${Kx(T.maxBatchBytes)} in total.`:null;return He?(de.push({id:pv($e),reference:dv(e),file:be.file,relativePath:Wx(be.relativePath,be.file.name),status:"failed",error:He}),!1):(U+=1,Ie+=be.file.size,!0)});if(de.length>0&&uv(e,de),ke.length===0)return;const Me=new Map,Le=ke.map((be,$e)=>{const We=pv($e),He=new AbortController;return Me.set(We,He),{id:We,reference:dv(e),file:be.file,relativePath:Wx(be.relativePath,be.file.name),status:"uploading",loaded:0,total:be.file.size,cancel:()=>He.abort()}});uv(e,Le),ze(Le.map(be=>be.reference));for(const be of Le)L.current.set(be.id,Me.get(be.id));await M5(Le,x5,async be=>{const $e=Me.get(be.id),We=new Set([be.id]);try{const vt=(await o([{relativePath:be.relativePath,file:be.file}],{signal:$e.signal,onProgress:wt=>{Uu(e,We,lt=>({...lt,loaded:wt.loaded,total:wt.total}))}})).results[0];if($e.signal.aborted){const wt=ge.current;vt?.status==="uploaded"&&vt.attachmentId&&wt&&wt([vt.attachmentId]).catch(()=>{});return}Uu(e,We,wt=>{const{error:lt,cancel:Nt,...Yt}=wt;return vt?.status==="uploaded"&&vt.path?{...Yt,status:"uploaded",...vt.attachmentId?{attachmentId:vt.attachmentId}:{},path:vt.path,loaded:vt.size??wt.file.size,total:vt.size??wt.file.size}:{...Yt,status:"failed",error:vt?.error??"upload_failed"}})}catch(He){const vt=$e.signal.aborted?"Upload canceled.":mv(He);Uu(e,We,wt=>{const{cancel:lt,...Nt}=wt;return{...Nt,status:"failed",error:vt}})}finally{L.current.get(be.id)===$e&&L.current.delete(be.id)}})}function R(j){if(j.status!=="removing"){if(Oe(j.reference),j.status!=="uploaded"&&j.status!=="failed"||!j.attachmentId||!ge.current){L.current.delete(j.id),nf(e,j.id);return}se([j])}}function I(){J(""),nb(e);const j=x.filter(ve=>!!(ve.path&&ve.attachmentId));for(const ve of x)j.includes(ve)||(L.current.delete(ve.id),nf(e,ve.id));j.length>0&&se(j)}function se(j){const ve=j.flatMap(Ie=>Ie.attachmentId?[Ie.attachmentId]:[]);if(ve.length===0||!ge.current){for(const Ie of j)nf(e,Ie.id);return}const Ae=new Set(j.map(Ie=>Ie.id));Uu(e,Ae,Ie=>{const{error:U,...de}=Ie;return{...de,status:"removing"}}),ge.current(ve).then(()=>{for(const Ie of j)nf(e,Ie.id)}).catch(Ie=>{Uu(e,Ae,U=>({...U,status:"failed",error:`Could not remove attachment: ${mv(Ie)}`}))})}function _e(j){const ve=Array.from(j.currentTarget.files??[]).map(Ae=>({relativePath:Ae.name,file:Ae}));j.currentTarget.value="",O(ve)}function N(j){const ve=n5(j.clipboardData);ve.length!==0&&(j.preventDefault(),O(ve))}function V(j){s||!yc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),j.dataTransfer.dropEffect="copy",F(!0))}function pe(j){s||!yc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),F(!0))}function Z(j){if(!yc(j.dataTransfer))return;const ve=j.relatedTarget;ve instanceof Node&&j.currentTarget.contains(ve)||F(!1)}function Q(j){yc(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),F(!1),DE(j.dataTransfer).then(O).catch(ve=>{const Ae={id:pv(0),reference:dv(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:mv(ve)};uv(e,[Ae])}))}const le=x.some(j=>j.status==="uploading"),Te=x.some(j=>j.status==="failed"),je=x.filter(j=>j.status==="uploaded"&&j.path).length,Fe=!s&&!le&&!Te&&(!!_||je>0);function Se(){Cf()&&(ne.current?.(),ne.current=O5())}function ze(j){if(j.length===0)return;const ve=j.map(He=>`@${He}`).join(" "),Ae=kc(e).text,Ie=Math.min(ie.current.start,Ae.length),U=Math.min(Math.max(Ie,ie.current.end),Ae.length),de=Ae.slice(0,Ie),ke=Ae.slice(U),Me=de&&!/\s$/.test(de)?" ":"",Le=ke&&!/^\s/.test(ke)?" ":"",be=`${Me}${ve}${Le}`,$e=`${de}${be}${ke}`,We=de.length+be.length;ie.current={start:We,end:We},J($e),window.requestAnimationFrame(()=>{const He=W.current;He&&(gv(He),He.setSelectionRange(We,We))})}function Oe(j){const ve=kc(e).text,Ae=ve.replace(new RegExp(`@${N5(j)}(?![A-Za-z0-9_])`,"g"),"");Ae!==ve&&J(Ae.replace(/[ \t]{2,}/g," "))}return d.jsxs("div",{ref:z,className:"compose-drawer","data-open":b?"true":"false",children:[d.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:()=>G(!0),children:[d.jsx("span",{"aria-hidden":"true",children:"▴"}),d.jsx("span",{children:"compose"}),_||x.length>0?d.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),d.jsxs("div",{ref:P,className:"compose-drawer-panel","aria-hidden":b?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:pe,onDragOver:V,onDragLeave:Z,onDrop:Q,children:[A?d.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,d.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:ae,children:[d.jsx("span",{"aria-hidden":"true",children:"▾"}),d.jsx("span",{className:"compose-drawer-title",children:"compose"}),d.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"}),d.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),d.jsx("textarea",{ref:W,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:b?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:_,onChange:j=>{ie.current={start:j.target.selectionStart,end:j.target.selectionEnd},J(j.target.value)},onSelect:j=>{ie.current={start:j.currentTarget.selectionStart,end:j.currentTarget.selectionEnd}},onPaste:N,onFocus:Se,onKeyDown:j=>{if(j.key==="Enter"&&(j.metaKey||j.ctrlKey)){if(j.preventDefault(),j.shiftKey){n&&ee("queue");return}ee("send");return}j.key==="Escape"&&(j.preventDefault(),ae())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),d.jsx("input",{ref:$,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:_e}),x.length>0?d.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:x.map(j=>d.jsx(T5,{attachment:j,onRemove:()=>R(j)},j.id))}):null,d.jsxs("div",{className:"compose-drawer-actions",children:[d.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:b?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>$.current?.click(),disabled:s,children:"+"}),d.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:b?0:-1,onClick:()=>{I(),gv(W.current),Se()},disabled:!_&&x.length===0,children:"Clear"}),n?d.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:b?0:-1,title:Te?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>ee("queue"),disabled:!Fe,children:"Queue"}):null,d.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:b?0:-1,title:Te?"Remove failed attachments before sending.":void 0,onClick:()=>ee("send"),disabled:!Fe,children:"Send"})]})]})]})}function T5({attachment:e,onRemove:t}){const n=E5(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),s=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return d.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[s&&n?d.jsx("img",{src:n,alt:""}):d.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),d.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),d.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),d.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"}),d.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function E5(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 R5(e,t){const n=new Map(t.map(f=>[f.reference,f])),s=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let l=0,u;for(;(u=o.exec(e))!==null;){const f=n.get(u[1]);f&&(fv(s,e.slice(l,u.index)),f.status==="uploaded"&&f.path&&(D5(f)?s.push({kind:"image",path:f.path}):fv(s,f.path)),l=o.lastIndex)}return fv(s,e.slice(l)),{parts:s}}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 D5(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function N5(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wx(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 Kx(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 M5(e,t,n){let s=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){const l=s;if(s+=1,l>=e.length)return;await n(e[l])}});await Promise.all(o)}function A5(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 qx(){if(!Cf())return;const e=Sc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function L5(e){Tc!==null&&(window.clearTimeout(Tc),Tc=null),xf.add(e),document.documentElement.setAttribute(Np,"true"),Sc()}function j5(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()},g5),Sc()}function O5(){let e=!1,t=null,n=null,s=null,o=0;const l=Date.now(),u=window.visualViewport,f=B5();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",_),u?.removeEventListener("scroll",_),f?.removeEventListener("geometrychange",_))}function b(w){if(!e){if(w<Fx&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(_);return}t=window.setTimeout(_,_5)}}function _(){if(e)return;g();const w=Ry(),C=Date.now()-l;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===s?o+=1:(o=w.keyboardInsetBottom>0?1:0,s=w.keyboardInsetBottom),C>=v5||C>=Fx&&o>=b5){p();return}b(C)}return u?.addEventListener("resize",_),u?.addEventListener("scroll",_),f?.addEventListener("geometrychange",_),_(),p}function Sc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Ry()}function B5(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function I5(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(H5(u))return u.preventDefault(),u.stopPropagation(),P5(e),!1;if(z5(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(U5(u)){const f=ib(e);return f?(u.preventDefault(),u.stopPropagation(),rb(f),!1):!0}return $5(u)?(u.preventDefault(),u.stopPropagation(),F5(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const f=ib(e);if(f){if(u.clipboardData){u.clipboardData.setData("text/plain",f),u.preventDefault();return}u.preventDefault(),rb(f)}},l=u=>{const f=u.clipboardData?.getData("text/plain");if(!f)return;const g=My(f);u.preventDefault(),u.stopImmediatePropagation(),jE(e,g,n.onPasteText)};return s.addEventListener("copy",o,!0),s.addEventListener("paste",l,!0),{dispose(){s.removeEventListener("copy",o,!0),s.removeEventListener("paste",l,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function P5(e){const t=ib(e);t&&await rb(t)}function z5(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function H5(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 U5(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function $5(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 F5(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;jE(e,My(n),t)}catch{}}function jE(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function ib(e){return e.hasSelection()?e.getSelection():W5(e.element??null)}function W5(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let s=0;s<t.rangeCount;s+=1){const o=t.getRangeAt(s);if(e.contains(o.commonAncestorContainer))return n}return""}async function rb(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}K5(e)}function K5(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 q5=[4,10,11,12];function V5(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>Vx(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>Vx(s)),e.parser.registerCsiHandler({final:"n"},s=>Y5(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>G5(s)),e.parser.registerCsiHandler({final:"t"},s=>X5(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...q5.map(s=>e.parser.registerOscHandler(s,o=>Z5(o)))];return{dispose(){for(const s of n)s.dispose()}}}function Vx(e){return Ap(e)===0}function Y5(e){const t=Ap(e);return t===5||t===6}function G5(e){return Ap(e)===6}function X5(e){const t=Ap(e);return t===14||t===16||t===18}function Z5(e){return e.split(";").some(t=>t==="?")}function Ap(e){const t=e[0];return typeof t=="number"?t:0}const ts=new Map,vv=2*1024*1024,Q5=1500,Yx=25e3,J5=2500,e4=2500,t4=1e3,n4=2e3,i4=3e4,r4=16*1024*1024,sb=256,OE=tM-3e4,s4=3e3,BE=1e4,a4=3e3,ab=16*1024*1024,Lp=4*1024*1024,ep=25,o4=1e3,l4=3e3,_v=8,c4=100,IE=1e3,Gx=[2e3,5e3,15e3,6e4];let u4=0,d4=0,bv=0,yv=null,kf=!1,ob=0,Tf=0,uo=!1,Xx=!1,ad=null,Zx=!1,lb=0,wd=document.visibilityState!=="hidden";const tp=new Set;let Ec=null,od=0;const h4=new TextEncoder,f4=O4();function p4(e,t){g4(),x4(),Sp()&&ua(0);let n=ts.get(e);n||(n=b4(e),ts.set(e,n),Uc(n)),n.listeners.add(t);const s=Symbol(e);queueMicrotask(()=>Ly(n));const o=(f,g)=>k4(n,f,g),l=f=>{f?(n.foregroundAttachments.add(s),np(),HE(n)):(n.foregroundAttachments.delete(s),cb())},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(s),cb()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:l,detach:u}}function fc(e){const t=ts.get(e);t&&(j4(t),ts.delete(e),cb())}function m4(e){const t=ts.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),So(t),Qr(t),ks(t),wo(t),ws(t,"reconnecting"),xo(t);const n=t.socket;return t.socket=null,ro(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Uc(t),!0}function g4(){if(Zx)return;Zx=!0;const e=()=>{if(document.visibilityState==="hidden"){wd=!1,lb+=1,UE(),zE(),v4();return}Ay(),od=Date.now(),np()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),np()}function np(){Ec!==null||document.visibilityState==="hidden"||!PE()||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>=n4){for(const n of ts.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&bo("terminal.connection.foreground_gap",n,{gapMs:t});Ay(void 0,{foregroundOnly:!0})}np()}))}function PE(){for(const e of ts.values())if(e.foregroundAttachments.size>0)return!0;return!1}function cb(){PE()||(zE(),od=0)}function zE(){Ec!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Ec),Ec=null}function HE(e){if(document.visibilityState!=="hidden"){if(!wd||e?.heartbeatSuspended){Ay(e);return}e&&ub(e)}}function Ay(e,t={}){if(document.visibilityState==="hidden")return;wd=!0;const n=++lb;UE();const s=Array.from(ts.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=s.filter(f=>f===e||f.foregroundAttachments.size>0||E4(f)),l=new Set(o),u=s.filter(f=>!l.has(f));for(const f of o)ub(f);if(!t.foregroundOnly)for(let f=0;f<u.length;f+=_v){const g=u.slice(f,f+_v),p=Math.floor(f/_v)*c4,b=window.setTimeout(()=>{if(tp.delete(b),!(n!==lb||!wd||document.visibilityState==="hidden"))for(const _ of g)ub(_)},p);tp.add(b)}}function UE(){for(const e of tp)window.clearTimeout(e);tp.clear()}function ub(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<t4)return Promise.resolve("alive");ws(e,"reconnecting"),xo(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const s=`resume-${n.toString(36)}-${(++u4).toString(36)}`;let o;const l=new Promise(f=>{o=f}),u={socket:t,nonce:s,timeout:0,promise:l,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(bo("terminal.connection.resume_timeout",e,{pendingInputs:ho(e)}),ws(e,"reconnecting"),fo(e))},J5);try{t.send(JSON.stringify({type:"ping",nonce:s}))}catch{ws(e,"reconnecting"),fo(e)}return l}function v4(){wd=!1;for(const e of ts.values())e.heartbeatSuspended=!0,So(e),Qr(e),ks(e),wo(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,ws(e,"skipped"),xo(e)}function _4(){uo=!1,Sp()&&ua(0);for(const e of ts.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),So(e),Qr(e),ks(e),wo(e),ws(e,"reconnecting"),xo(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,ro(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Uc(e)}}function Sv(){for(const e of Array.from(ts.keys()))fc(e)}function b4(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;ro(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Qr(e),ks(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),Qr(e),ro(e,"connected"),yo(e,t),$E(e,t),e.isAlive=!0,Qx(e))}),t.addEventListener("message",s=>{if(e.socket!==t)return;const o=typeof s.data=="string"?s.data:"";if(!o)return;let l=null;try{l=JSON.parse(o)}catch{return}if(!l||typeof l.type!="string")return;if(F4(l)){W4(e,t,l.instanceId,l.inputAck,l.inputReceipt===!0),uo&&(uo=!1,Sp()&&ua(0));return}if(e.inputProtocolMode==="unknown"&&KE(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)}),ws(e,"alive"),yo(e,t),Qx(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"){z4(e,t,l);return}if(l.type==="input_received"){H4(e,t,l);return}if(l.type==="error"&&U4(e,l),l.type==="input_ack_confirmed"){q4(e,l);return}const u=S4(e,l);if(xd(e,{type:"message",message:u}),l.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;Ly(e)}}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",So(e),Qr(e),ks(e),wo(e),ws(e,"reconnecting"),xo(e),s.code===1008){e.reconnectEnabled=!1,ro(e,y4(s.reason)?"unauthorized":"closed");return}if(!n&&s.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=i4)&&(e.lastUpgradeAuthProbeAt=o,xd(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){ro(e,"closed");return}ro(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Uc(e)},Q5)}}),t.addEventListener("error",()=>{})}function Qx(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(),s=n-e.heartbeatTickAt>Yx*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!s){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},Yx)}function xo(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function y4(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function S4(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+fa(s),0),Jx(e),e.exited&&Ef(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=fa(t.data),Jx(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 Jx(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]=Y4(e.output[0],vv),e.outputBytes=fa(e.output[0]))}function ro(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 w4(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??w4(t)}),ob+=1,Tf=0,ua(IE)}function x4(){if(Xx)return;Xx=!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,C4()},e))}async function C4(){if(kf||uo||document.visibilityState==="hidden"||navigator.onLine===!1)return;kf=!0;const e=ob;try{const t=await oM();if(t.outcome==="auth_blocked"){uo=!0;return}if(t.outcome==="retryable"){const n=Gx[Math.min(Tf,Gx.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),ob!==e&&!uo&&ua(IE)}}function k4(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const s=I4(e,t);if(!s)return"rejected";const o=JSON.stringify(s),l=fa(o);if(l>r4)return"rejected";const u=n.durability!=="live-only",f={message:s,encoded:o,bytes:l,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:s.type==="input"?"queued":null,durable:u};if(!P4(e,f))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;s.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(bo("terminal.input.foreground_resume",e,{terminalId:s.terminalId,pendingInputs:ho(e)}),HE(e));const _=s.type!=="ping"&&s.type!=="resize";if(_&&(!p||s.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Lp))return!u&&s.type==="input"?"rejected":T4(e,s)?(p&&g&&yo(e,g),"queued"):e.pendingOut.length>=sb||e.pendingOutBytes+l>ab?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=l,tC(e,f),p&&g&&yo(e,g),"queued");if(p){tC(e,f);try{return g.send(o),WE(e,f),"sent"}catch{if(_&&u&&e.pendingOut.length<sb&&e.pendingOutBytes+l<=ab)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"){Qr(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Lp){V4(e,t),D4(e,t);return}const s=e.pendingOut[0];if(s.message.type==="input"&&e.inputProtocolMode==="unknown"){$E(e,t);return}try{t.send(s.encoded),WE(e,s)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-s.bytes),e.outboundFlushDelayMs=ep,n=!0}e.outboundFlushDelayMs=ep,Qr(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&xd(e,{type:"outbound_flushed"})})}function T4(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let s=null;if(t.type==="resize"&&n.message.type==="resize")s=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;s={...t,lines:u}}}if(!s)return!1;const o=JSON.stringify(s),l=fa(o);return e.pendingOutBytes+=l-n.bytes,n.message=s,n.encoded=o,n.bytes=l,!0}function So(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=ep}function Qr(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function ip(e){return e.pendingOut.some(t=>t.message.type==="input")}function E4(e){return ip(e)||e.unackedInputs.size>0}function R4(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,s)=>n+s.bytes,0))}function D4(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",s=t.bufferedAmount>Lp;if(!n&&!s){yo(e,t);return}R4(e),fo(e)},l4))}function ks(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function $E(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)},a4))}function FE(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){FE(e),Cd(e)}function vl(e){FE(e),db(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=eC(e),s=N4(e),o=A4(e);if(n===null&&s===null&&o===null){Cd(e);return}if(e.inputAckProbe)return;const l=n===null?Number.POSITIVE_INFINITY:n+s4,u=Math.max(0,Math.min(l,s??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(db(e,{notifyImmediately:!0})){vl(e);return}if(M4(e),eC(e)===null){vl(e);return}L4(e,t)},u)}function N4(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const s=n.receivedAt+BE;t=t===null?s:Math.min(t,s)}return t}function M4(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<BE||(n.writeSlowReported=!0,bo("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function eC(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 A4(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const s=n.firstSentAt+OE;t=t===null?s:Math.min(t,s)}return t}function L4(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)}-${(++d4).toString(36)}`;bo("terminal.input.delivery_probe_started",e,{pendingInputs:ho(e)});const s={socket:t,nonce:n,timeout:0};e.inputAckProbe=s,s.timeout=window.setTimeout(()=>{e.inputAckProbe!==s||e.socket!==t||(bo("terminal.input.delivery_probe_timeout",e,{pendingInputs:ho(e)}),Cd(e),fo(e))},e4);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{Cd(e),fo(e)}}function ws(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),Qr(e),ks(e),wo(e),ws(e,"reconnecting"),xo(e);const t=e.socket;e.socket=null,ro(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Uc(e)}function j4(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),So(e),Qr(e),ks(e),wo(e),ws(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 O4(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function B4(){return bv=(bv+1)%Number.MAX_SAFE_INTEGER,`${f4}-${bv.toString(36)}`.slice(0,ck)}function I4(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:s,...o}=t;return o}const n=B4();return n.length===0||n.length>ck?null:{...t,messageId:n}}function P4(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<=ab)}function tC(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 z4(e,t,n){const s=e.unackedInputs.get(n.messageId);if(!s||s.message.type!=="input"||s.message.terminalId!==n.terminalId){const l=e.pendingAckReceipts.get(n.messageId);l?.terminalId===n.terminalId&&hb(e,t,l);return}if(bl(e,s),vl(e),!jy(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),hb(e,t,o)}function H4(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const s=e.unackedInputs.get(n.messageId);s?.message.type!=="input"||s.message.terminalId!==n.terminalId||s.sentInstanceId!==e.serverInstanceId||(s.receivedInstanceId=e.serverInstanceId,s.receivedAt=Date.now(),s.writeSlowReported=!1,s.inputState="received",vl(e))}function U4(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 WE(e,t){if(t.message.type!=="input"||!t.message.messageId||!jy(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 $4(e){if(db(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(s=>s.message.type==="input"&&s.message.messageId?[s.message.messageId]:[])),n=[];for(const s of Array.from(e.unackedInputs.values())){if(!s.durable){bl(e,s);continue}s.message.type==="input"&&s.message.messageId&&!t.has(s.message.messageId)&&(s.inputState="queued",n.push(s))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((s,o)=>s+o.bytes,0))}function db(e,t={}){const n=Date.now(),s=new Set;let o=0;for(const[l,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=OE&&(s.add(l),u.durable&&(o+=1));if(s.size===0)return!1;e.pendingOut=e.pendingOut.filter(l=>{const u=l.message.type==="input"?l.message.messageId:void 0;return!u||!s.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-l.bytes),!1)});for(const l of s){const u=e.unackedInputs.get(l);u&&bl(e,u)}return o>0&&(VE(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&&Ly(e)),!0}function F4(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function W4(e,t,n,s,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!s){KE(e,t);return}ks(e);const l=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,l===n?($4(e),K4(e,t)):l!==null&&(qE(e),YE(e)),yo(e,t)}function KE(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",ks(e),e.serverInstanceId=null,qE(e),YE(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;bl(e,n);const{messageId:s,...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 qE(e){const t=new Set;let n=0;for(const[s,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(s),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(s=>{const o=s.message.type==="input"?s.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-s.bytes),!1)});for(const s of t){const o=e.unackedInputs.get(s);o&&bl(e,o)}n>0&&VE(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 VE(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Ly(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),Qr(e),ks(e),wo(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function hb(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!jy(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function jy(e){return e==="ack"||e==="receipt-ack"}function K4(e,t){for(const n of e.pendingAckReceipts.values())if(hb(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function q4(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function YE(e){e.pendingAckReceipts.clear()}function V4(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(o4,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,yo(e,t)},n)}function fa(e){return h4.encode(e).byteLength}function Y4(e,t){if(fa(e)<=t)return e;let n=0,s=e.length;for(;n<s;){const o=Math.floor((n+s)/2);fa(e.slice(o))<=t?s=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const G4=[0,50,150,350],X4=[100,300,750],Z4=2,Q4=[300,1200,2500],J4=1e3,eI=1e5,tI="",fb="\x1B[?1049l\x1B[?1047l\x1B[?47l",nI=new Set(["47","1047","1049"]),iI=400,wv=9,rI=9,sI=32,aI=1.42,oI=2,lI=24,cI=720,uI=60,dI=1260,hI=6,fI=2,nC=[500,1500,3e3,5e3,8e3],iC=15e3,pI=2,mI=1e3,rC="Do not take action. Wait for my next input.",rp=6e4,gI=rp+5*6e4,sC=rp+6e4,vI=40,rf=240,_I=5e3,ld=new Map,pc=new Map;function aC({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:o,refreshCwdOnEnter:l=!1,tabId:u,codeServerContext:f,onSelect:g,onClose:p,onExit:b,onSnapshot:_,onAuthClose:w}){const C=v.useSyncExternalStore(nT,r_,()=>cl),x=v.useSyncExternalStore(iT,s_,()=>Nc),T=v.useSyncExternalStore(rT,o_,()=>!0),M=v.useSyncExternalStore(mf,l_,()=>!0),A=v.useSyncExternalStore(mf,c_,()=>!0),F=v.useSyncExternalStore(zb,po,()=>Rc),z=v.useSyncExternalStore(nd,()=>id("history.toggle"),()=>"Alt+H"),P=v.useSyncExternalStore(nd,()=>id("scrollback.toggle"),()=>"Alt+S"),W=v.useSyncExternalStore(nd,()=>id("subagents.toggle"),()=>"Alt+A"),$=v.useRef(null),L=v.useRef(null),X=v.useRef(null),ge=v.useRef(null),ne=v.useRef(null),ie=v.useRef(e.id),G=v.useRef({onExit:b,onSnapshot:_}),J=v.useRef(t.createWebSocketUrl),ae=v.useRef(w),ee=v.useRef(null),O=v.useRef(null),R=v.useRef(null),I=v.useRef(!1),se=v.useRef(new Map),_e=v.useRef(new Map),N=v.useRef(new Set),V=v.useRef([]),pe=v.useRef(!1),Z=v.useRef(null),Q=v.useRef(0),le=v.useRef(!1),Te=v.useRef(!1),je=v.useRef(!1),Fe=v.useRef({terminalId:e.id,enabled:!1}),Se=v.useRef([]),ze=v.useRef([]),Oe=v.useRef(0),j=v.useRef(!1),ve=v.useRef(null),Ae=v.useRef(0),Ie=v.useRef(0),U=v.useRef(null),de=v.useRef(null),ke=v.useRef(!1),Me=v.useRef(!1),Le=v.useRef(!1),be=v.useRef(null),$e=v.useRef(!1),We=v.useRef(null),He=v.useRef(null),vt=v.useRef(!1),wt=v.useRef(!1),lt=v.useRef(!1),Nt=v.useRef(!1),Yt=v.useRef(!1),rt=v.useRef(!1),jn=v.useRef(!1),Sn=v.useRef(n),ut=v.useRef(s),Lt=v.useRef(l),Ct=v.useRef(C),gi=v.useRef(x),ki=v.useRef(!1),fe=v.useRef(!1),Ze=v.useRef(null),at=v.useRef(null),pt=v.useRef(0),yt=v.useRef(0),It=v.useRef(e.id),$t=v.useRef(()=>{}),dn=v.useRef(null),Gt=v.useRef(null),sn=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),ri=v.useRef(!1),dt=v.useRef(!1),kt=v.useRef(null),oe=v.useRef(null),[,xe]=v.useState("connecting"),[Ye,Xe]=v.useState(!1),[et,fn]=v.useState(null),[xn,Mi]=v.useState(!1),[Ft,Ai]=v.useState(null),[vr,$n]=v.useState(!1),[Li,Ki]=v.useState(!1),[pn,si]=v.useState(!1),[Ts,ji]=v.useState(!1),[cn,_r]=v.useState(null),[Co,ga]=v.useState([]),Es=v.useRef([]),Xn=e.agentCache&&cn&&e.agentCache.source.provider===cn.provider&&e.agentCache.source.sessionId===cn.sessionId?e.agentCache:null,[zr,qi]=v.useState(()=>Date.now()),[Rn,Rs]=v.useState(!1),[va,Ds]=v.useState(null),[_a,br]=v.useState(!1),[ko,On]=v.useState(!1),[_i,is]=v.useState(null),[To,Vi]=v.useState(!1),[Eo,Ns]=v.useState(!1),[Hr,rs]=v.useState(null),[Ro,Do]=v.useState(null),rr=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),Ur=Oi==="claude"||JE(e.currentCommand),yr=Oi!==null||mc(e.currentCommand),Ti=e.capabilities?.tmuxScrollback===!0,ai=Ti&&($c??(yr?A:M)),[ya,As]=v.useState(!1);v.useLayoutEffect(()=>{Sn.current=n},[n]),v.useLayoutEffect(()=>{ut.current=s},[s]),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(()=>{fe.current=ko},[ko]),v.useLayoutEffect(()=>{at.current=cn},[cn]);const Ii=v.useCallback((E,K={})=>{!E&&K.preserveOnNull||(Ox(at.current,E)||(yt.current+=1),at.current=E,_r(Pe=>Pe&&E&&Pe.provider===E.provider&&Pe.sessionId===E.sessionId?Pe:E))},[]),Yi=v.useCallback(async()=>{const E=await t.getTerminalTranscriptSource(e.id);return It.current===e.id&&(Es.current=E.candidates??[],ga(E.candidates??[])),E.source},[t,e.id]),Ls=v.useCallback(()=>{On(!1),br(!0)},[]),$r=v.useCallback(()=>{at.current&&(br(!1),On(!0))},[]),Ei=v.useCallback(async(E={})=>{const K=await lC(rr,t,E);return is(K),K},[rr,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)},[]),js=v.useCallback(()=>{const E=f?.serverKey.trim()||"local",K=f?.serverName.trim()||"Local",Pe=f?.tabName.trim()||e.title||"Terminal",Je=_i?.instances.find(Tt=>Tt.cwd===e.cwd);if(Je&&cC(sf(E,Je.id))){Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Je&&xv(sf(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 ft=()=>((!tt||XE(tt))&&(tt=window.open("about:blank","_blank"),bI(tt)),tt);_i?.installed!==!0&&ft(),Ns(!0),rs(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=sf(E,Et.id);if(uC(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 st=ft();return{response:await t.openCodeServer({terminalId:e.id,serverName:K,tabName:Pe}),targetPopup:st}})().then(Tt=>{if(!Tt)return;const{response:Et,targetPopup:st}=Tt;pb(rr,Et.status),is(Et.status);const un=sf(E,Et.instance.id);if(cC(un)){Cv(st),Pi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}uC(st,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),rs(af(Tt))}).finally(()=>Ns(!1))},[f?.serverName,f?.tabName,rr,_i,Ei,t,Pi,e.cwd,e.id,e.title]);v.useEffect(()=>{let E=!1;return lC(rr,t).then(K=>{E||is(K)}).catch(()=>{}),()=>{E=!0}},[rr,t]),v.useEffect(()=>{if(_i?.job?.status!=="running")return;const E=window.setInterval(()=>{Ei({force:!0}).catch(K=>rs(af(K)))},1e3);return()=>window.clearInterval(E)},[_i?.job?.status,Ei]),v.useEffect(()=>()=>{wn.current!==null&&window.clearTimeout(wn.current)},[]),v.useLayoutEffect(()=>{$t.current=Ls},[Ls]),v.useLayoutEffect(()=>{Gt.current=Xn},[Xn]),v.useLayoutEffect(()=>{sn.current=Rn},[Rn]),v.useLayoutEffect(()=>{ri.current=Bi},[Bi]),v.useLayoutEffect(()=>{dt.current=Ur},[Ur]),v.useLayoutEffect(()=>{const E=Fe.current;Te.current=ai,je.current=Ti,Fe.current={terminalId:e.id,enabled:ai},hC($.current,ai),E.terminalId===e.id&&E.enabled&&!ai&&Is(),ai||si(!1)},[e.id,ai,Ti]),v.useEffect(()=>{ba(Wg(e.id)),Q.current=0,le.current=!1,si(!1),Wt()},[e.id]),v.useEffect(()=>mf(()=>{ba(Wg(e.id))}),[e.id]),v.useEffect(()=>()=>{Gc()},[]),v.useEffect(()=>{ne.current?.(s&&e.status==="running"),s&&e.status==="running"&&Wr()},[s,e.id,e.status]),v.useEffect(()=>{s&&n&&e.status==="running"&&wr("auto")},[n,s,e.status]),v.useEffect(()=>{G.current={onExit:b,onSnapshot:_}},[b,_]),v.useLayoutEffect(()=>{J.current=t.createWebSocketUrl,ae.current=w},[t,w]),v.useLayoutEffect(()=>{ie.current=e.id,jn.current=!1,ji(!1)},[e.id]),v.useEffect(()=>{let E=!1,K=null,Pe=0;const Je=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",tt=Je||$I(e.currentCommand),ft=Je||mc(e.currentCommand);function Tt(){K!==null&&(window.clearTimeout(K),K=null)}function Et(un){if(E)return;let Jt;if(un)Jt=iC;else if(Pe<nC.length){if(!tt)return;Jt=nC[Pe++]}else{if(!ft)return;Jt=iC}K=window.setTimeout(()=>{K=null,st()},Jt)}async function st(){try{const un=at.current!==null,Jt=await Yi();if(E)return;if(Jt){pt.current=0,Ii(Jt),Et(!0);return}pt.current+=1;const Xt=!!(un&&tt&&pt.current<pI);Ii(null,{preserveOnNull:Xt}),Et(Xt)}catch(un){if(E)return;Tv(un)&&Ii(null),Et(!1)}}return It.current!==e.id&&(Es.current=[],ga([]),It.current=e.id,yt.current+=1,at.current=null,pt.current=0,_r(null)),e.status!=="running"?(yt.current+=1,at.current=null,pt.current=0,_r(null),()=>{E=!0,Tt()}):(st(),()=>{E=!0,Tt()})},[Ii,Yi,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const E=wI(e.id,cn),K=dn.current;K!==null&&E!==null&&K!==E&&(de.current=null,ke.current=!1,Me.current=!1,On(!1)),dn.current=E},[e.id,cn?.provider,cn?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!cn){Rs(!1);return}const E=window.setInterval(()=>{qi(Date.now())},mI);return()=>{window.clearInterval(E)}},[e.status,cn?.provider,cn?.sessionId]),v.useEffect(()=>{const E=SI(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=ZE(Xn,zr);if(E===null||E<=0)return;const K=hn.current;!K.warnedFiveMinutes&&E<=gI&&E>sC&&(K.warnedFiveMinutes=!0,ds({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>rp&&(K.warnedOneMinute=!0,ds({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<=rp&&$d()},[Rn,zr,Xn,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function E(K){if(!Sn.current||!ut.current||K.isComposing||K.key==="Process"||kI(K.target))return;const Pe=lT(K);if(Pe?.id==="history.toggle"&&(at.current||Es.current.length)){K.preventDefault(),K.stopPropagation(),ki.current?br(!1):$t.current();return}if(Pe?.id==="subagents.toggle"&&at.current){K.preventDefault(),K.stopPropagation(),fe.current?On(!1):$r();return}if(Pe?.id==="scrollback.toggle"&&je.current){K.preventDefault(),K.stopPropagation(),qr();return}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[]),v.useEffect(()=>{const E=L.current;E&&(E.options.disableStdin=e.status==="exited"),e.status==="exited"&&xe("closed")},[e.status]),v.useEffect(()=>{const E=L.current;E&&(E.options.fontSize=C,Fg(C,gi.current).then(()=>{Ct.current===C&&Fn()}))},[C]),v.useEffect(()=>{const E=L.current;E&&(E.options.fontFamily=i_(x),Fg(Ct.current,x).then(()=>{gi.current===x&&Fn()}))},[x]),v.useEffect(()=>{const E=L.current;E&&(E.options.theme=oC(F))},[F]),v.useEffect(()=>{const E=$.current;if(!E)return;let K=!1,Pe=null,Je=null,tt=null,ft=null,Tt=null,Et=null,st=null;ee.current=null,Yt.current=!1,rt.current=!1,$e.current=!1,Rl(),Dl(),ss(),pe.current=!1;const un=Ct.current,Jt=gi.current,Xt=new eB({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:i_(Jt),fontSize:un,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:eI,theme:{...oC(po())}}),Vr=new KL;return Xt.loadAddon(Vr),ft=V5(Xt),L.current=Xt,X.current=Vr,Fg(un,Jt).then(()=>{if(K)return;Xt.open(E),hC(E,Te.current),Yt.current=!0,Pe=I5(Xt,{onPasteText:Wd,onInterrupt:Fd,shouldInterruptPlainCtrlC:()=>dt.current}),ut.current&&Sn.current&&e.status==="running"&&wr("auto"),Fn(),Tt=YI(E,Xt,()=>Ct.current*1.2,Gi,xr=>{ot(xr)},ka,S,()=>Te.current,Dn),Et=KI(E,Xt,Gi,xr=>{ot(xr)},ka,S,()=>Te.current,Dn);const Po=new NB;Je=Xt.onData(xr=>{if(jn.current){const zo=zB(xr);if(zo){Bo(!1),sr(zo);return}}const Xi=Po.accept(xr);Xi&&sr(Xi)}),tt=Xt.onScroll(xr=>{if(wt.current||Nt.current||lt.current){Qn();return}Ml(),pr(Xt)&&li({scrollToBottom:!0}),Gi(),!Te.current&&xr<=3&&ot()}),st=new ResizeObserver(()=>{Tl()}),st.observe(E),rt.current&&(oi(),rt.current=!1,Fn()),cs()}),()=>{Ps(ge.current,{updateUi:!1}),K=!0,Yt.current=!1,rt.current=!1,Rl(),Dl(),O.current=null,R.current=null,I.current=!1,Nl(),pe.current=!1,jo(),lt.current=!1,j.current=!1,Ae.current+=1,Ie.current+=1,ve.current=null,kt.current=null,oe.current=null,Le.current=!1,be.current=null,Xe(!1),Tt?.(),Et?.(),st?.disconnect(),Pe?.dispose(),Je?.dispose(),tt?.dispose(),ft?.dispose(),Xt.dispose(),L.current=null,X.current=null}},[e.id]),v.useEffect(()=>{const E=J.current(e.id),K=p4(E,xl);return ge.current=K.send,ne.current=K.setForeground,K.setForeground(ut.current&&e.status==="running"),xe(K.status),K.status==="connected"&&Fn(),K.snapshot&&(G.current.onSnapshot(K.snapshot,{notifyCompletion:!1}),L.current&&(Fn(),Fr(K.output,K.history),Fn())),()=>{Ps(K.send,{updateUi:!1}),K.setForeground(!1),K.detach(),ge.current=null,ne.current=null}},[e.id,e.status]);function xl(E){if(E.type==="status"){xe(E.status),E.status==="unauthorized"&&ae.current?.({source:"terminal-ws-1008",terminalId:e.id}),E.status==="connected"&&(Fn(),Lo());return}if(E.type==="upgrade_rejected"){ae.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(E.type==="outbound_flushed"){pe.current&&(pe.current=!1,Xc());return}Sa(E.message)}function ss(E=[],K=null){Se.current=[],ze.current=of(E),Oe.current=0,j.current=!1,ve.current=null,lt.current=!1,Ae.current+=1,U.current=K,de.current=null,ke.current=!1,Me.current=!1,Le.current=!1,be.current=null,rt.current=!1,kt.current=null,oe.current=null,We.current=null,vt.current=!1,Xe(!1),fn(null),Mi(!1),Ai(null),$n(!1),Ki(!1)}function Fr(E=[],K=null){if(lt.current||j.current){oe.current={output:E,history:K,appendFromLiveOutputIndex:ze.current.length};return}ss(E,K),Zn()}function as(){if(lt.current||j.current)return!1;const E=oe.current;if(!E)return!1;const K=ze.current.slice(E.appendFromLiveOutputIndex);return oe.current=null,ss([...E.output,...K],E.history),Zn(),!0}function Zn(){if(!L.current||!Yt.current){rt.current=!0;return}rt.current=!1,oi()}async function oi(){const E=L.current;if(!E)return;const K=lf(E,vt.current),Pe=K?ze.current.length:Oe.current,Je=await Sr(E,{liveOutputLimit:Pe,scrollToBottom:K});L.current===E&&(Qn(),Je&&Lo())}function Sr(E,K={}){return new Promise(Pe=>{lt.current=!0,j.current=!1;const Je=Ae.current+1;Ae.current=Je;const tt=Math.max(0,Math.min(K.liveOutputLimit??ze.current.length,ze.current.length)),ft=K.historyPages??Se.current,Tt=()=>L.current===E&&Ae.current===Je,Et=()=>Tt()&&(K.isCurrent?.()??!0),st=()=>{Tt()&&(lt.current=!1),Pe(!1)},un=()=>{if(!Et()){st();return}try{Oe.current=tt,K.scrollToBottom&&k(E)}finally{if(lt.current=!1,as()){Pe(!1);return}const Xt=Al();Xt?li(Xt):K.applyDeferredSnapshot!==!1&&Ca(),Pe(!0)}},Jt=()=>{if(!Et()){st();return}E.clear();const Xt=of([...ft,...ze.current.slice(0,tt)]);if(Xt.length===0){un();return}for(let Vr=0;Vr<Xt.length;Vr+=1){const Po=Xt[Vr];Vr===Xt.length-1?E.write(Po,un):E.write(Po)}};if(E.buffer.active.type==="alternate"){E.write(fb,Jt);return}Jt()})}async function ot(E=0){const K=L.current;if(Le.current||!K)return;if(Os(K)){Qn();return}const Pe=U.current,Je=Ie.current,tt=Symbol("history-load"),ft=()=>L.current===K&&Ie.current===Je;be.current=tt,Le.current=!0,Xe(!0);const Tt=K.buffer.active.viewportY;try{let Et=!!(Pe&&!Pe.hasMore);if(!Et)try{const st=await t.getTerminalHistory(e.id,{beforeLine:Pe?.startLine??0,...Pe?.snapshotHistorySize!==void 0?{snapshotHistorySize:Pe.snapshotHistorySize}:{},...Pe?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Pe.snapshotHistoryLimit}:{},...Pe?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Pe.snapshotHistoryToken}:{},...Pe?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Pe.snapshotPaneWidth}:{},limit:J4});if(!ft()||U.current!==Pe)return;const un=()=>ft()&&U.current===Pe;if(st.invalidated){Kr();return}const Jt=st.hasMore&&st.snapshotHistorySize!==void 0&&st.snapshotPaneWidth!==void 0,Xt={startLine:st.startLine,endLine:st.endLine,hasMore:Jt,...st.snapshotHistorySize!==void 0?{snapshotHistorySize:st.snapshotHistorySize}:{},...st.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:st.snapshotHistoryLimit}:{},...st.snapshotHistoryToken!==void 0?{snapshotHistoryToken:st.snapshotHistoryToken}:{},...st.snapshotPaneWidth!==void 0?{snapshotPaneWidth:st.snapshotPaneWidth}:{}};if(st.output.length>0){await os(K,st.output,Tt,E)&&un()&&(U.current=Xt);return}if(!un())return;U.current=Xt,Et=!Jt}catch(st){Et=ft()&&Tv(st)}if(Et){if(!ft()||Os(K)){Qn();return}await No(K,Tt,E,ft)}}catch{}finally{be.current===tt&&(be.current=null,Le.current=!1,Xe(!1))}}async function No(E,K,Pe,Je){if(!Je()||ke.current||Me.current)return;const tt=at.current,ft=yt.current,Tt=de.current,Et=()=>Je()&&yt.current===ft&&Ox(tt,at.current)&&de.current===Tt;try{const st=await t.getTerminalTranscriptHistory(e.id,{...Tt?{cursor:Tt}:{},limit:iI}),un=st.output.map(ky);if(!st.source||st.terminalId!==e.id||!Et())return;if(tt&&!ca(tt,st.source)){de.current=null,ke.current=!1,Me.current=!1,Ii(st.source);return}if(un.length===0){Ii(st.source),de.current=st.cursor,Me.current=!st.hasMore||!st.cursor;return}await os(E,un,K,Pe,Et)&&Et()&&(Ii(st.source),de.current=st.cursor,Me.current=!st.hasMore||!st.cursor)}catch(st){Et()&&Tv(st)&&(ke.current=!0)}}async function os(E,K,Pe,Je,tt){if(Os(E)||tt&&!tt())return Qn(),!1;const ft=Se.current,Tt=[...K,...ft],Et=FI(K),st=Ae.current+1,un=await Sr(E,{liveOutputLimit:Oe.current,scrollToBottom:!1,historyPages:Tt,applyDeferredSnapshot:!1,...tt?{isCurrent:tt}:{}}),Jt=tt!==void 0&&!tt();return!un||Jt||L.current!==E?(Jt&&L.current===E&&Ae.current===st&&await Sr(E,{liveOutputLimit:Oe.current,scrollToBottom:!1,historyPages:ft,applyDeferredSnapshot:!1})&&L.current===E&&(B(E,Pe),vt.current=!pr(E),Gi()),!1):(Se.current=Tt,B(E,Math.max(0,Pe+Et+Math.min(0,Je))),vt.current=!pr(E),Gi(),!0)}v.useEffect(()=>{const E=window.visualViewport;function K(){document.visibilityState!=="hidden"&&Wr()}function Pe(){Wr()}function Je(){Wr()}function tt(){Tl()}function ft(){Mo()}return document.addEventListener("visibilitychange",K),window.addEventListener("pageshow",Pe),window.addEventListener("online",Je),window.addEventListener("resize",tt),window.addEventListener(Qf,ft),E?.addEventListener("resize",tt),E?.addEventListener("scroll",tt),()=>{document.removeEventListener("visibilitychange",K),window.removeEventListener("pageshow",Pe),window.removeEventListener("online",Je),window.removeEventListener("resize",tt),window.removeEventListener(Qf,ft),E?.removeEventListener("resize",tt),E?.removeEventListener("scroll",tt)}},[e.id]);function Wr(){document.visibilityState==="hidden"||!ut.current||(Lo(),Fn())}function Kr(){const E=J.current(e.id);Ie.current+=1,$e.current=!0,kt.current=null,xe("reconnecting"),Fn(),m4(E)}function Sa(E){if(E.type==="snapshot"&&E.terminal.id===e.id){Ie.current+=1,G.current.onSnapshot(E.terminal,{notifyCompletion:!1});const Pe=$e.current;$e.current=!1;const Je=L.current;if(!Je)return;if(Fn(),Pe){Cl(E.output,E.history??null);return}if(Oo(Je,E.terminal)){Yc(E.output,E.history??null),Qn(),Fn();return}Fr(E.output,E.history??null),Fn();return}if(E.type==="terminal_updated"&&E.terminal.id===e.id){G.current.onSnapshot(E.terminal,{notifyCompletion:!0});return}if(E.type==="output"&&E.terminalId===e.id){const Pe=e2(E.data);if(!Pe)return;ze.current.push(Pe),L.current&&Yt.current?li({scrollToBottom:!0}):rt.current=!0;return}const K=L.current;if(K){if(E.type==="exit"&&E.terminalId===e.id){G.current.onExit(E.exitCode),xe("closed");return}E.type==="error"&&K.writeln(`\r
|
|
51
|
-
[nterminal] ${E.message}`)}}function Cl(E,K){Fr(E,K),Fn()}function kl(E=25){if(document.visibilityState==="hidden"||!ut.current||se.current.has(E))return;const K=window.setTimeout(()=>{se.current.delete(E),!El()&&qe()},E);se.current.set(E,K)}function Tl(){El()||cs()}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=O.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=$.current;if(!E||E.isConnected===!1)return null;const K=E.getBoundingClientRect(),Pe=ls(window.innerWidth)??0,Je=ls(window.visualViewport?.width)??Pe,tt=ls(K.width)??ls(E.clientWidth)??Pe;if(Pe<=0||Je<=0||tt<=0)return null;const{keyboardVisible:ft}=tb(),Tt=document.documentElement.hasAttribute(Np),Et=Kc()||ft;return{windowWidth:Pe,visualViewportWidth:Je,containerWidth:tt,composeOpen:Tt,keyboardVisible:ft,mobileLike:Et}}function Kc(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function wa(){return tb().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function ls(E){return typeof E=="number"&&Number.isFinite(E)&&E>0?E:null}function bi(E,K){return Math.abs(E-K)<=Z4}function cs(){for(const E of G4)kl(E)}function Fn(){ee.current=null,cs()}function Lo(){if(us(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const E=window.requestAnimationFrame(()=>{N.current.delete(E),us();const K=window.requestAnimationFrame(()=>{N.current.delete(K),us()});N.current.add(K)});N.current.add(E)}for(const E of X4){if(_e.current.has(E))continue;const K=window.setTimeout(()=>{_e.current.delete(E),us()},E);_e.current.set(E,K)}}function us(){const E=L.current;if(!(!E||!Yt.current||document.visibilityState==="hidden"||!ut.current||$.current?.isConnected===!1))try{E.refresh(0,Math.max(0,E.rows-1))}catch{}}function Rl(){for(const E of se.current.values())window.clearTimeout(E);se.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 V.current)window.clearTimeout(E);V.current=[]}function Gi(){if(Qn(),!We.current){Mi(!1);return}Mi(!0),jo(),He.current=window.setTimeout(()=>{He.current=null,Mi(!1)},1200)}function Qn(){const E=L.current,K=E?WI(E):null;if(We.current=K,fn(K),Ki(!!(E&&K)),$n(!!(E&&K&&!pr(E))),K||!E||!qc()){Ai(null);return}Ai({alternate:E.buffer.active.type==="alternate"})}function qc(){const E=U.current;return Se.current.length>0||!!E?.hasMore}function jo(){He.current!==null&&(window.clearTimeout(He.current),He.current=null)}function Ml(){const E=L.current;E&&(vt.current=!pr(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=L.current;if(!K||!Yt.current){rt.current=!0;return}if(kt.current&&!lt.current&&!j.current&&pr(K)){Ca();return}if(lt.current){xa(E);return}if(j.current){xa(E);return}const Pe=Vc(E);if(!Pe.force&&!lf(K,vt.current)){Qn();return}j.current=!0;const Je=Ae.current,tt=()=>{if(L.current!==K||Ae.current!==Je)return;if(!Pe.force&&!lf(K,vt.current)){if(j.current=!1,as())return;Qn();return}const ft=Oe.current,Tt=ze.current[ft];if(Tt===void 0){if(j.current=!1,as())return;Pe.scrollToBottom&&k(K),Qn();const Et=Al();Et?li(Ev(Pe,Et)):Ca();return}K.write(Tt,()=>{L.current!==K||Ae.current!==Je||(Oe.current=ft+1,tt())})};tt()}function Os(E){return kt.current!==null||!pr(E)&&(Bs()||j.current||lt.current)}function Oo(E,K){return(K?.agentStatus?.provider==="codex"||K?.agentStatus?.provider==="claude"||ri.current||mc(K?.currentCommand))&&!pr(E)}function Bs(){return Oe.current<ze.current.length}function Yc(E,K){kt.current={output:E,history:K,appendFromLiveOutputIndex:ze.current.length}}function Ca(){const E=L.current,K=kt.current;if(!E||!K||!pr(E)||j.current||lt.current)return;const Pe=of(K.output),Je=of(ze.current.slice(K.appendFromLiveOutputIndex));kt.current=null,Fr([...Pe,...Je],K.history),Fn()}function ka(){Nt.current=!0}function S(){Ml(),Nt.current=!1;const E=L.current;E&&pr(E)&&li({scrollToBottom:!0})}function k(E){Y(()=>fC(E))&&(vt.current=!1)}function B(E,K){Y(()=>(E.scrollToLine(K),!0))}function Y(E){wt.current=!0;try{return E()}finally{wt.current=!1}}function re(){const E=L.current;if(!E)return;const K=()=>{Te.current&&(Ta(ge.current),si(!1)),fC(E),vt.current=!1,Qn(),li({force:!0,scrollToBottom:!0}),wr("scroll-action")};if(E.buffer.active.type==="alternate"){E.write(fb,K);return}K()}function ce(E){const K=L.current,Pe=$.current;if(!K||!Pe)return;const Je=Pe.getBoundingClientRect();if(Je.height<=0)return;const tt=Math.max(0,Math.min(1,(E-Je.top)/Je.height)),ft=Math.round(K.buffer.active.baseY*tt);ka();try{K.scrollToLine(ft)}finally{S()}vt.current=!pr(K),Qn(),Gi(),ft<=3&&ot()}function Re(E){E.preventDefault(),E.stopPropagation(),E.currentTarget.setPointerCapture?.(E.pointerId),ce(E.clientY)}function Be(E){(E.buttons&1)!==0&&(E.preventDefault(),E.stopPropagation(),ce(E.clientY))}function qe(){const E=L.current,K=X.current;if(!(!E||!K)&&!(document.visibilityState==="hidden"||!ut.current||$.current?.isConnected===!1))try{const Pe=lf(E,vt.current),Je=Ao();K.fit(),Je&&(O.current=Je),Pe&&k(E),E.refresh(0,Math.max(0,E.rows-1)),Qn();const tt={cols:E.cols,rows:E.rows},ft=ee.current;if(ft&&ft.cols===tt.cols&&ft.rows===tt.rows)return;ht({type:"resize",terminalId:e.id,cols:tt.cols,rows:tt.rows})&&(ee.current=tt)}catch{}}function Ke(E,K){const Pe=ge.current;return Pe?Pe(E,K):"rejected"}function ht(E){return Ke(E)!=="rejected"}function Wt(){Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)}function jt(){Wt();const E=Math.max(-rf,Math.min(rf,Q.current));if(Q.current=0,E===0)return!1;const K=ht({type:"scrollback_scroll",terminalId:e.id,lines:E});return K&&(le.current=!0,E<0&&si(!0)),K}function Dn(E){if(!Te.current||E===0)return;const K=Q.current+E;Q.current=Math.max(-rf,Math.min(rf,K)),Z.current===null&&(Z.current=window.setTimeout(()=>{Z.current=null,jt()},vI))}function Is(){Ta(ge.current)}function Ps(E=ge.current,K={}){const Pe=le.current;Wt(),Q.current=0,le.current=!1,K.updateUi!==!1&&si(!1),Pe&&E?.({type:"cancel_scrollback",terminalId:e.id})}function Ta(E){Wt(),Q.current=0,le.current=!1,si(!1),E?.({type:"cancel_scrollback",terminalId:e.id})}function qr(){if(!je.current)return;const E=!Te.current;ba(nL(ie.current,E)),zi()}function Ud(){const E=!sn.current;sn.current=E,Rs(E),ds({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 ds(E,K={}){Gc();const Pe=an.current+1;an.current=Pe,Ds({...E,id:Pe}),!K.sticky&&(ln.current=window.setTimeout(()=>{ln.current=null,Ds(Je=>Je?.id===Pe?null:Je)},12e3))}function Pp(){hn.current.skipped=!0,ds({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function zp(){sn.current=!1,Rs(!1),ds({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){ds({tone:"skipped",message:"Skipped cache keep-alive",detail:K});return}if(sr(`${rC}\r`,{userInitiated:!1})==="rejected"){ds({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}ds({tone:"success",message:"Cache keep-alive sent",detail:rC})}function Hp(){const E=Gt.current,K=at.current;return sn.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.":TI($.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=L.current;E&&(k(E),Qn())}function sr(E,K={}){jt();const Pe=le.current;li({force:!0,scrollToBottom:!0});const Je=Ke({type:"input",terminalId:e.id,data:E,...Pe?{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()),Pe&&(le.current=!1,si(!1)),UI(E)&&(Je==="sent"?Xc():Je==="queued"&&(pe.current=!0)),Je)}function Fd(){jn.current&&Bo(!1),sr(tI)}function Wd(E){const K=hv(E,{bracketedPasteMode:L.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});K&&sr(K)}function Kd(E,K){const Pe=L.current?.modes.bracketedPasteMode===!0,Je=Oi==="codex"||Oi==="claude"||mc(e.currentCommand),tt=E.parts.map(ft=>ft.kind==="image"&&Je?hv(ft.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):hv(ft.kind==="image"?ft.path:ft.value,{bracketedPasteMode:Pe,stripTrailingLineBreaks:!1})).join("");return tt?sr(`${tt}${p5(K)}`)!=="rejected":!1}function Xc(){!Lt.current||!Sn.current||(Nl(),V.current=Q4.map(E=>{const K=window.setTimeout(()=>{V.current=V.current.filter(Pe=>Pe!==K),Lt.current&&Sn.current&&ht({type:"refresh_cwd",terminalId:e.id})},E);return K}))}function wr(E="terminal-interaction"){ki.current||wa()&&(E==="auto"||E==="scroll-action")||L.current?.focus()}const Up=v.useCallback(()=>{br(!1)},[]);function Ea(){ji(E=>{const K=!E;return jn.current=K,K}),wr("input-action")}function Bo(E){jn.current=E,ji(E)}function Io(E){jn.current&&Bo(!1),sr(PB(E)),wr("input-action")}async function Ll(E="install"){Ns(!0),rs(null);try{const K=E==="update"?await t.updateCodeServer():await t.installCodeServer();pb(rr,K.status),is(K.status)}catch(K){rs(af(K))}finally{Ns(!1)}}return d.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":ai?"true":"false",onMouseDown:()=>{n||g()},children:[d.jsx(EI,{terminal:e,canClose:o,tabId:u,transcriptSource:cn,hasTranscriptCandidates:Co.length>0,transcriptShortcutLabel:z,subagentsShortcutLabel:W,transcriptCacheStatus:Xn,transcriptCacheNow:zr,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:js,onToggleTmuxScrollback:qr,onOpenTranscript:Ls,onOpenSubagents:$r,onReload:Kr,onClose:p}),d.jsx("div",{className:"xterm-container",ref:$}),Ye?d.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:d.jsx("span",{"aria-hidden":"true"})}):null,T&&!ai&&et?d.jsxs("div",{className:"terminal-scroll-progress","data-active":xn,"aria-hidden":"true",children:[et.current,"/",et.total]}):T&&!ai&&Ft?d.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,vr||ai&&pn?d.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(),re()},children:"↓"}):null,Li&&!ai?d.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Re,onPointerMove:Be,children:d.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?ya?d.jsx(BB,{ctrlActive:Ts,onCtrl:Ea,onStandaloneKey:Io,onPreserveFocus:()=>wr("input-action"),onHide:()=>As(!1)}):d.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(),wr("input-action")},onPointerDown:E=>{E.stopPropagation(),wr("input-action")},onClick:()=>As(!0),children:"⌨"}):null,d.jsx(k5,{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"||QE(e.currentCommand),disabled:e.status!=="running"}),d.jsx(MI,{toast:va,onSendNow:()=>{$d()},onSkipOnce:Pp,onTurnOff:zp,onDismiss:()=>Ds(null)}),_a?d.jsx(AI,{terminalId:e.id,serverApi:t,source:cn,candidates:Co,rememberedSelection:Ze,fontSize:C,onClose:Up},e.id):null,ko&&cn?d.jsx(pB,{terminalId:e.id,serverApi:t,source:cn,fontSize:C,onClose:()=>On(!1)}):null,Ro?d.jsx(DI,{notice:Ro}):null,To?d.jsx(RI,{status:_i,busy:Eo,error:Hr,onInstall:()=>{Ll("install")},onUpdate:()=>{Ll("update")},onOpen:js,onRefresh:()=>{Ei({checkLatest:!0}).catch(E=>rs(af(E)))},onClose:()=>Vi(!1)}):null]})}function oC(e){return cD(e)}async function lC(e,t,n={}){const s=n.checkLatest===!0,o=n.force===!0||s,l=Date.now(),u=pc.get(e);if(!o&&u?.status&&l-u.fetchedAt<=_I)return u.status;if(u?.inflight&&(!s||u.inflightCheckLatest))return u.inflight;let f;return f=t.getCodeServerStatus(s?{checkLatest:!0}:void 0).then(g=>(pb(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,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:l},inflight:f,inflightCheckLatest:s}),f}function pb(e,t){pc.set(e,{status:t,fetchedAt:Date.now()})}function sf(e,t){return`${e}:${t}`}function GE(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function cC(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,GE(e));if(!n)return null;ld.set(e,n);try{n.focus()}catch{}return n}function uC(e,t,n){if(!e||XE(e))return!1;try{return e.name=GE(t),e.location.href=n,ld.set(t,e),e.focus(),!0}catch{return!1}}function bI(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 XE(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 s=yI(e,t),o=dC(s*Math.max(1,n),uI,dI);return{limit:dC(Math.ceil(o/oI),lI,cI),maxLines:o}}function yI(e,t){const n=e?.clientHeight??0;if(n<=0)return sI;const s=Math.max(10,t*aI);return Math.max(1,Math.floor(n/s))}function dC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function SI(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function wI(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function ZE(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 xI(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function CI(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const s=Math.floor(n/60),o=n%60;if(s<24&&o>0)return`${s}h ${o}m`;if(s<24)return`${s}h`;const l=Math.floor(s/24),u=s%24;return u>0?`${l}d ${u}h`:`${l}d`}function kI(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function af(e){return e instanceof Hn||e instanceof Error?e.message:"Something went wrong."}function TI(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function EI({terminal:e,canClose:t,tabId:n,transcriptSource:s,hasTranscriptCandidates:o,transcriptShortcutLabel:l,subagentsShortcutLabel:u,transcriptCacheStatus:f,transcriptCacheNow:g,cacheKeepAliveEnabled:p,codeServerAvailable:b,codeServerInstallState:_,codeServerBusy:w,codeServerSupported:C,scrollbackShortcutLabel:x,tmuxScrollbackSupported:T,tmuxScrollbackEnabled:M,onToggleCacheKeepAlive:A,onOpenCodeServer:F,onToggleTmuxScrollback:z,onOpenTranscript:P,onOpenSubagents:W,onReload:$,onClose:L}){const X=Yb({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),ge={cursor:n?"grab":"default",opacity:X.isDragging?.5:void 0};return d.jsxs("header",{ref:X.setNodeRef,className:"terminal-pane-header",style:ge,"data-dragging":X.isDragging,...X.attributes,...X.listeners,children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),d.jsx("span",{className:"terminal-pane-spacer"}),b?d.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:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),F()},children:d.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,s||o?d.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s?.provider,title:"View transcript history","aria-label":"View transcript history",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),P()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View history"}),d.jsx("span",{className:"pane-button-label-short",children:"History"}),d.jsx("kbd",{children:l})]}):null,s?d.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":s.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),W()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View agents"}),d.jsx("span",{className:"pane-button-label-short",children:"Agents"}),d.jsx("kbd",{children:u})]}):null,s?d.jsx(NI,{status:f,now:g,keepAliveEnabled:p,onToggle:A}):null,e.status==="exited"?d.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,T&&e.status==="running"?d.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":M?"true":"false","aria-pressed":M,"aria-label":`Toggle tmux scrollback (${x})`,title:M?`Scroll input uses tmux scrollback (${x}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${x}).`,onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),z()},children:[M?d.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.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"}),d.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"})]}):d.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.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"}),d.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),d.jsx("kbd",{children:x})]}):null,e.status==="running"?d.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),$()},children:"↻"}):null,t?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),L()},children:"x"}):null]})}function RI({status:e,busy:t,error:n,onInstall:s,onUpdate:o,onOpen:l,onRefresh:u,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 d.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:f,children:d.jsxs("section",{className:"security-panel code-server-dialog",onClick:T=>T.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{children:[d.jsx("h2",{children:x}),d.jsx("p",{children:w?"Checking code-server status...":b?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),d.jsxs("div",{className:"code-server-dialog-scroll",children:[d.jsxs("div",{className:"code-server-dialog-body",children:[d.jsxs("p",{children:["NTerminal installs code-server under ",d.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?d.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),_?null:d.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?d.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?d.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[d.jsxs("div",{className:"code-server-progress-heading",children:[d.jsx("span",{children:g.action}),d.jsx("strong",{children:g.status})]}),d.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
52
|
-
`):"Preparing..."})]}):null]}),d.jsxs("div",{className:"code-server-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!_,children:"Check"}),b?d.jsxs(d.Fragment,{children:[C?d.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!_,children:"Update"}):null,d.jsx("button",{type:"button",onClick:l,disabled:t||p,children:"Open"})]}):d.jsx("button",{type:"button",onClick:s,disabled:t||p||!_,children:p?"Installing...":"Install"})]})]})})}function DI({notice:e}){return d.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function NI({status:e,now:t,keepAliveEnabled:n,onToggle:s}){const o=ZE(e,t),l=xI(e,o),u=o===null?"?":CI(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 d.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(),s()},children:[d.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),d.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),d.jsx("span",{children:u})]})}function MI({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:s,onDismiss:o}){if(!e)return null;const l=e.tone==="info"||e.tone==="warning";return d.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[d.jsxs("header",{children:[d.jsx("strong",{children:e.message}),d.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?d.jsx("p",{children:e.detail}):null,l?d.jsxs("div",{className:"cache-keepalive-toast-actions",children:[d.jsx("button",{type:"button",onClick:t,children:"Send now"}),d.jsx("button",{type:"button",onClick:n,children:"Skip once"}),d.jsx("button",{type:"button",onClick:s,children:"Turn off"})]}):null]})}function AI(e){const[t,n]=v.useState(null),[s,o]=v.useState(),[l,u]=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(A=!1,F=!1){const z=++C.current;w(!0);try{const P=await e.serverApi.getTerminalTranscriptSource(e.terminalId);if(z!==C.current)return;if(u(P.candidates??[]),g(P.source),F&&!P.source&&e.source){g(e.source),n(e.source),b(null);return}const W=e.rememberedSelection?.current;let $=!1;if((A||!t)&&W?.terminalId===e.terminalId){const L=P.candidates?.find(X=>X.id===W.candidateId);L?(n({provider:L.provider,sessionId:L.sessionId}),o(L.id),$=!0):e.rememberedSelection&&(e.rememberedSelection.current=null)}if((A||!t)&&P.source)n(P.source),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);else if((A||!t)&&!$&&P.candidates?.length===1){const L=P.candidates[0];n({provider:L.provider,sessionId:L.sessionId}),o(L.id)}b(null)}catch(P){if(z!==C.current)return;if(F&&e.source){n(e.source);return}b(P instanceof Error?P.message:"Could not load sessions.")}finally{z===C.current&&w(!1)}}v.useEffect(()=>(x(!1,!0),()=>{C.current+=1}),[]),v.useEffect(()=>{if(t)return;function A(F){F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),e.onClose())}return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[t,e.onClose]);const T=[];t&&T.push({id:s??"__pinned",title:l.find(A=>A.id===s)?.title||`${co(t.provider)} · ${t.sessionId}`,detail:l.find(A=>A.id===s)?.cwd||t.sessionId}),f&&(!t||!ca(f,t))&&T.push({id:"__current",title:`Current session · ${co(f.provider)}`,detail:f.sessionId});for(const A of l)t&&ca(t,A)||f&&ca(f,A)||T.push({id:A.id,title:A.title||A.sessionId,detail:`${co(A.provider)} · ${A.cwd}${A.updatedAt?` · ${new Date(A.updatedAt).toLocaleString()}`:""}`});const M=t&&T.length<=1?null:d.jsxs("div",{className:"transcript-session-picker",children:[T.length>1?d.jsx(wB,{options:T,value:s??(t?"__pinned":void 0),onSelect:A=>{if(C.current+=1,w(!1),A==="__current"&&f){n(f),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);return}const F=l.find(z=>z.id===A);F&&(n({provider:F.provider,sessionId:F.sessionId}),o(F.id),e.rememberedSelection&&(e.rememberedSelection.current={terminalId:e.terminalId,candidateId:F.id}))}}):null,d.jsx("button",{type:"button","aria-label":"Refresh sessions",title:"Refresh sessions",disabled:_,onClick:()=>{x()},children:d.jsx(Dc,{size:16})}),p?d.jsx("span",{role:"alert",children:p}):null,!t&&!f&&!_&&!l.length?d.jsx("span",{children:"No sessions available."}):null]});return t?v.createElement(LI,{...e,key:`${t.provider}:${t.sessionId}:${s??""}`,source:t,...s?{candidateId:s}:{},sessionPicker:M,liveSourceChanged:!!(e.source&&!ca(e.source,t)),onReloadLatest:async()=>{e.rememberedSelection&&(e.rememberedSelection.current=null),n(null),o(void 0),await x(!0)}}):d.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-picker-title",onPointerDown:A=>A.stopPropagation(),onMouseDown:A=>A.stopPropagation(),onClick:A=>{A.stopPropagation(),e.onClose()},children:d.jsxs("div",{className:"security-panel transcript-dialog",onClick:A=>A.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"transcript-picker-title",children:"History"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e.onClose,children:"×"})]}),M,_?d.jsx("div",{className:"transcript-dialog-status",children:"Loading sessions..."}):null]})})}const LI=zt.memo(function({terminalId:t,serverApi:n,source:s,fontSize:o,onClose:l,onReloadLatest:u,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),[M,A]=v.useState(!1),F=v.useRef(!1),z=v.useRef(null),P=v.useRef(!1),W=v.useRef(()=>{});W.current=an;const $=v.useRef(0),L=v.useRef(!1),X=v.useRef(!1),ge=v.useRef(null),ne=v.useRef(null),ie=v.useRef(null),[G,J]=v.useState([]),[ae,ee]=v.useState(!1),[O,R]=v.useState(""),[I,se]=v.useState(null),[_e,N]=v.useState(null),[V,pe]=v.useState(!1),[Z,Q]=v.useState(!1),[le,Te]=v.useState(-1),[je,Fe]=v.useState(null),[Se,ze]=v.useState(null),[Oe,j]=v.useState(!1),[ve,Ae]=v.useState(!0),[Ie,U]=v.useState(!1),[de,ke]=v.useState(null),[Me,Le]=v.useState(!1),be=DB(n,t,s,f,ae,O),$e=v.useRef(0),We=v.useRef(null),He=v.useRef(null);function vt(){if(F.current)return!0;const oe=b.current,xe=window.getSelection();if(!oe||!xe||xe.isCollapsed)return!1;for(let Ye=0;Ye<xe.rangeCount;Ye++)if(xe.getRangeAt(Ye).intersectsNode(oe))return!0;return!1}v.useEffect(()=>{const oe=()=>{vt()||(z.current?z.current.resume():P.current&&(P.current=!1,W.current()))},xe=()=>{F.current=!1,oe()};return document.addEventListener("selectionchange",oe),document.addEventListener("pointerup",xe,!0),document.addEventListener("pointercancel",xe,!0),window.addEventListener("blur",xe),()=>{document.removeEventListener("selectionchange",oe),document.removeEventListener("pointerup",xe,!0),document.removeEventListener("pointercancel",xe,!0),window.removeEventListener("blur",xe),z.current?.cancel()}},[]);function wt(oe){return oe?.aborted?Promise.reject(new DOMException("Aborted","AbortError")):vt()?new Promise((xe,Ye)=>{const Xe=()=>{oe?.removeEventListener("abort",et),z.current?.cancel===et&&(z.current=null)},et=()=>{Xe(),Ye(new DOMException("Aborted","AbortError"))};z.current={resume:()=>{Xe(),xe()},cancel:et},oe?.addEventListener("abort",et,{once:!0})}):Promise.resolve()}v.useEffect(()=>{En(),se(null),N(null)},[O,ae]),v.useEffect(()=>()=>{$e.current+=1,He.current?.abort()},[]),v.useEffect(()=>{function oe(xe){xe.key==="Escape"&&(xe.preventDefault(),xe.stopPropagation(),l())}return document.addEventListener("keydown",oe,!0),()=>document.removeEventListener("keydown",oe,!0)},[l]),v.useLayoutEffect(()=>{$.current+=1;const oe=$.current;L.current=!1,X.current=!0,ge.current=null,ne.current=null,ie.current=null;const xe=EB(n,t,s,ae);return _.current=xe,w.current=xe.snapshot,x.current=!0,T.current=null,A(!1),ze(null),j(!1),ke(null),Le(!1),se(null),N(null),Te(-1),Fe(null),xe.snapshot?(X.current=!1,T.current={top:xe.snapshot.scrollTop,atBottom:xe.snapshot.atBottom,...xe.snapshot.scrollAnchor},$t(xe.snapshot),Ae(!1),dn(xe.snapshot,oe)):(J([]),Ae(!0),Gt(null,"initial",oe)),()=>{It(),xe.release(),_.current===xe&&(_.current=null),$.current+=1,We.current?.abort(),L.current=!1}},[n,ae,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const oe=b.current;if(!oe)return;const xe=T.current;if(xe&&!ve&&C.current===G){T.current=null;const Xe=xe.key?Array.from(oe.querySelectorAll("[data-transcript-entry-key]")).find(et=>et.dataset.transcriptEntryKey===xe.key):null;oe.scrollTop=xe.atBottom?oe.scrollHeight:Xe?oe.scrollTop+Xe.getBoundingClientRect().top-oe.getBoundingClientRect().top-(xe.offset??0):xe.top;return}if(X.current){if(ve||G.length===0)return;X.current=!1;const Xe=()=>{oe.scrollTop=oe.scrollHeight};Xe(),window.requestAnimationFrame?.(Xe);return}const Ye=ge.current;Ye!==null&&(ge.current=null,oe.scrollTop+=oe.scrollHeight-Ye)},[G,ve,ae]);const lt=co(s.provider),Nt=zt.useMemo(()=>Gf(G,ae),[G,ae]),Yt=zt.useMemo(()=>X_(Nt),[Nt]),rt=zt.useMemo(()=>jI(Yt),[Yt]),jn=rt.map(oe=>oe.key).join(""),Sn=je?rt.find(oe=>oe.key===je)?.entryIndex??null:null,ut=O.trim().length>0,Lt=be.result?.hits.length??0,Ct=be.result?.hits.findIndex(oe=>oe.id===I?.id)??-1,gi=_e?.entryIndex??null,ki=ut?gi:Sn,fe=ut?gi===null?null:"search":Sn===null?null:"prompt",Ze=Nt?Nt.split(`
|
|
53
|
-
`).length-1:0,at=rt.length>0&&le>=0&&le<rt.length?le:rt.length-1,pt=je??(at>=0?rt[at]?.key??null:null),yt=ut?Lt>0?`${Ct+1}/${Lt} ${Lt===1?"match":"matches"} · ${Ze} ${Ze===1?"line":"lines"}`:`0 matches · ${Ze} ${Ze===1?"line":"lines"}`:rt.length>0?`${at+1}/${rt.length} prompts · ${Ze} ${Ze===1?"line":"lines"}`:`0 prompts · ${Ze} ${Ze===1?"line":"lines"}`;v.useEffect(()=>{if(ut){Fe(null);return}je&&!rt.some(oe=>oe.key===je)&&Fe(null),Te(oe=>{if(rt.length===0)return ie.current=null,-1;const xe=ie.current?rt.findIndex(Xe=>Xe.key===ie.current):-1,Ye=xe>=0?xe:oe>=0&&oe<rt.length?oe:rt.length-1;return ie.current=rt[Ye]?.key??null,Ye})},[je,ut,jn]),v.useEffect(()=>{const oe=ne.current;if(!oe||rt.length===0)return;ne.current=null;const xe=oe.anchorKey?rt.findIndex(Xe=>Xe.key===oe.anchorKey):-1,Ye=xe>0?xe-1:0;ri(Ye)},[jn]);function It(){const oe=w.current,xe=b.current;if(!oe||!xe||!x.current)return;const Ye=Array.from(xe.querySelectorAll("[data-transcript-entry-key]")).find(et=>et.getBoundingClientRect().bottom>xe.getBoundingClientRect().top),Xe={...oe,scrollTop:xe.scrollTop,atBottom:xe.scrollHeight-xe.clientHeight-xe.scrollTop<=4,...Ye?{scrollAnchor:{key:Ye.dataset.transcriptEntryKey,offset:Ye.getBoundingClientRect().top-xe.getBoundingClientRect().top}}:{}};w.current=Xe,_.current?.write(Xe)}function $t(oe){w.current=oe,_.current?.write(oe);const xe=dc([oe.page.records.map(Xe=>Xe.block).join(`
|
|
54
|
-
|
|
55
|
-
`)],s.provider,{includeTools:ae}),Ye=xe?[xe]:[];C.current=Ye,J(Ye),ze(oe.cursor),j(oe.hasMore)}async function dn(oe,xe){We.current?.abort();const Ye=new AbortController;We.current=Ye,L.current=!0,Ae(!1),U(!1),A(!0),ke(null);let Xe=null;try{for(;;){const Ft=await n.getTerminalTranscriptHistory(t,{...kv(b.current,o,wv),...Xe?.cursor?{cursor:Xe.cursor}:{ifSnapshot:oe.page.snapshot},includeTools:ae,expectedSessionId:s.sessionId,...f?{candidateId:f}:{}},Ye.signal);if($.current!==xe||!_.current?.current())return;if(!Ft.source)throw new Error("Transcript source is temporarily unavailable. Retry loading newest.");if(!ca(s,Ft.source))throw Le(!0),_.current?.invalidate(),new Error("Transcript session changed. Load newest to refresh.");if(Le(!1),Ft.page?.unchanged)return;if(!Ft.page){if(await wt(Ye.signal),$.current!==xe)return;w.current=null,_.current?.invalidate(),J([dc(Ft.output,s.provider,{includeTools:ae})]),ze(Ft.cursor),j(Ft.hasMore);return}if(Xe=Xe?Bx(Xe,Ft):Z_(Ft),!Xe)throw new Error("Transcript changed while loading. Load newest to retry.");if(mE(oe,Xe)||!Xe.hasMore||!Xe.cursor)break;await new Promise(Ai=>window.setTimeout(Ai,0))}if(await wt(Ye.signal),$.current!==xe||!_.current?.current())return;It();const et=b.current,fn=w.current??oe,xn=xB(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===oe.page.identity?{key:Mi.dataset.transcriptEntryKey,offset:Mi.getBoundingClientRect().top-et.getBoundingClientRect().top}:{}},$t(xn)}catch(et){$.current===xe&&!Ye.signal.aborted&&(ke(et instanceof Error?et.message:"Could not check the latest history."),et instanceof Hn&&et.status===409&&(_.current?.invalidate(),Le(!0)))}finally{$.current===xe&&(L.current=!1,A(!1))}}async function Gt(oe,xe,Ye=$.current){if(!L.current){L.current=!0,We.current?.abort(),We.current=new AbortController,A(!1),Ae(xe==="initial"),U(xe==="older"),xe==="older"&&(ge.current=b.current?.scrollHeight??null),ke(null);try{await sn(oe,xe,Ye)}catch(Xe){if($.current!==Ye)return;ke(Xe instanceof Error?Xe.message:"Failed to load transcript history."),Xe instanceof Hn&&Xe.status===409&&Le(!0)}finally{$.current===Ye&&(L.current=!1,Ae(!1),U(!1))}}}async function sn(oe,xe,Ye){const Xe=We.current?.signal;let et=oe,fn=0,xn=[];const Mi=xe==="initial"&&s.provider!=="claude"?fI:hI;for(;$.current===Ye;){const Ft=await n.getTerminalTranscriptHistory(t,{...et?{cursor:et}:{},...kv(b.current,o,xe==="initial"?wv:rI),includeTools:ae,expectedSessionId:s.sessionId,...f?{candidateId:f}:{}},Xe);if($.current!==Ye||(xe==="older"&&await wt(Xe),$.current!==Ye))return;if(!Ft.source){ke("Transcript source is temporarily unavailable.");return}if(!ca(s,Ft.source)){_.current?.invalidate(),Le(!0),j(!1);return}const Ai=dc(Ft.output,s.provider,{includeTools:ae}),vr=hn(Ft,xe,xn,Ai);if(Ai&&(xn=[Ai,...xn],vr))return;if(!Ft.hasMore||!Ft.cursor||fn>=Mi){xn.length>0&&J($n=>xe==="older"?[...xn,...$n]:xn);return}et=Ft.cursor,fn+=1}}function hn(oe,xe,Ye,Xe=dc(oe.output,s.provider,{includeTools:ae})){if(x.current&&oe.page&&!oe.page.unchanged){const fn=w.current,xn=xe==="older"&&fn?Bx(fn,oe):Z_(oe);if(!xn)throw new Error("Transcript changed while loading. Load newest to retry.");return xe==="older"&&(ge.current=b.current?.scrollHeight??null),$t(xn),!!Xe}if(ze(oe.cursor),j(!!(oe.hasMore&&oe.cursor)),!Xe)return!1;const et=[Xe,...Ye];return Gf(et,ae)?(J(fn=>xe==="older"?[...et,...fn]:et),!0):!1}function an(){const oe=b.current;if(oe){if(vt()){P.current=!0;return}P.current=!1,kt(),!(ut||oe.scrollTop>72||!Oe||!Se||L.current)&&Gt(Se,"older")}}function ln(oe){if(Lt===0)return;const xe=Ct>=0?Ct:oe>0?-1:0;vi((xe+oe+Lt)%Lt)}function En(){$e.current+=1,He.current?.abort(),He.current=null,pe(!1)}function wn(){const oe=w.current;x.current||(x.current=!0,We.current?.abort(),$.current+=1,L.current=!1,U(!1),ge.current=null,oe?(T.current={top:oe.scrollTop,atBottom:oe.atBottom,...oe.scrollAnchor},$t(oe),dn(oe,$.current)):(J([]),ze(null),j(!1),X.current=!0,Gt(null,"initial")))}async function vi(oe){const xe=be.result?.hits[oe];if(!xe)return;It(),x.current=!1,A(!1);const Ye=++$e.current;He.current?.abort(),We.current?.abort();const Xe=new AbortController;He.current=Xe,$.current+=1,L.current=!1,X.current=!1,ge.current=null,Ae(!1),pe(!0),U(!1),ke(null),se(xe),N(null);try{const et=await n.getTerminalTranscriptHistory(t,{around:xe.cursor,expectedSessionId:s.sessionId,...f?{candidateId:f}:{},includeTools:ae,...kv(b.current,o,wv)},Xe.signal);if(Ye!==$e.current)return;if(!et.source||!ca(s,et.source)){Le(!0);return}const fn=dc(et.output,s.provider,{includeTools:ae});J([fn]),N(RB(X_(fn),xe,O)),ze(et.cursor),j(!!(et.hasMore&&et.cursor)),b.current&&(b.current.scrollTop=0)}catch(et){Ye===$e.current&&(ke(et instanceof Error?et.message:"Could not load search result."),et instanceof Hn&&et.status===409&&Le(!0))}finally{Ye===$e.current&&pe(!1)}}function ri(oe){const xe=rt[oe];xe&&(ie.current=xe.key,Te(oe),Fe(xe.key))}async function dt(oe){if(rt.length===0){oe<0&&Oe&&Se&&!L.current&&(ne.current={anchorKey:null},await Gt(Se,"older"));return}const Ye=(le>=0&&le<rt.length?le:oe<0?rt.length-1:-1)+oe;if(Ye>=0&&Ye<rt.length){ri(Ye);return}oe<0&&Ye<0&&Oe&&Se&&!L.current&&(ne.current={anchorKey:rt[0]?.key??null},await Gt(Se,"older"))}function kt(){if(ut)return;const oe=b.current;if(!oe)return;const Ye=oe.getBoundingClientRect().top+Math.min(140,Math.max(48,oe.clientHeight*.28));let Xe=null;for(const et of zI(oe)){const fn=HI(et);if(fn!==null)if(et.getBoundingClientRect().top<=Ye)Xe=fn;else break}if(Xe!==null){const et=rt[Xe]?.key??null;ie.current=et,Te(Xe),je&&je!==et&&Fe(null)}}return d.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:oe=>oe.stopPropagation(),onMouseDown:oe=>oe.stopPropagation(),onClick:oe=>{oe.stopPropagation(),l()},children:d.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:oe=>oe.stopPropagation(),onMouseDown:oe=>oe.stopPropagation(),onClick:oe=>oe.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"transcript-dialog-title",children:[lt," JSONL"]}),d.jsx("span",{title:s.sessionId,children:s.sessionId})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:l,children:"×"})]}),g,p?d.jsx("div",{className:"transcript-dialog-status",children:"The live pane uses another session. History remains pinned to this session."}):null,d.jsxs("div",{className:"transcript-dialog-controls",children:[d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:ae,onChange:oe=>ee(oe.currentTarget.checked)}),"Show tool output"]}),d.jsx("label",{className:"transcript-search",children:d.jsx("input",{type:"search",value:O,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:oe=>{be.cancel(),En(),R(oe.currentTarget.value),oe.currentTarget.value.trim()||wn()},onKeyDown:oe=>{oe.nativeEvent.isComposing||oe.key==="Enter"&&(oe.preventDefault(),ut?be.result?.query===Dp(O)?Lt>0?ln(oe.shiftKey?-1:1):!be.result.complete&&be.result.cursor&&!be.busy&&be.search(!0):be.busy||(En(),se(null),N(null),be.search()):dt(oe.shiftKey?-1:1))}})}),d.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":Z,"aria-label":"Toggle prompt list",title:"Toggle prompt list",onClick:()=>Q(oe=>!oe),disabled:rt.length===0,children:d.jsx(uA,{size:16})}),d.jsxs("div",{className:"transcript-search-actions","aria-label":ut?"Search result navigation":"Prompt navigation",children:[d.jsx("button",{type:"button",onClick:()=>ut?ln(-1):void dt(-1),disabled:ut?Lt===0:rt.length===0&&!Oe,"aria-label":ut?"Previous search match":"Previous user prompt",title:ut?"Previous search match":"Previous user prompt",children:d.jsx(sA,{size:16})}),d.jsx("button",{type:"button",onClick:()=>ut?ln(1):void dt(1),disabled:ut?Lt===0:rt.length===0,"aria-label":ut?"Next search match":"Next user prompt",title:ut?"Next search match":"Next user prompt",children:d.jsx(nA,{size:16})})]}),d.jsx("span",{className:"transcript-result-count",children:yt}),d.jsx("button",{type:"button",title:M?"Checking latest history...":"Load newest entries","aria-label":"Load newest entries","aria-busy":M,onClick:()=>{be.cancel(),En(),We.current?.abort(),$.current+=1,L.current=!1,U(!1),ge.current=null,ne.current=null,T.current=null,X.current=!0,se(null),N(null),x.current=!0;const oe=w.current;oe?(X.current=!1,T.current={top:0,atBottom:!0},$t({...oe,atBottom:!0}),dn(oe,$.current)):Gt(null,"initial")},children:d.jsx(Dc,{size:16})})]}),ut?d.jsxs("div",{className:"transcript-search-results","aria-label":"Search results","aria-busy":be.busy,children:[d.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?d.jsx("button",{type:"button",disabled:be.busy,onClick:()=>{be.search(!0)},children:"Search more"}):null]}),I&&Ct<0&&be.result?d.jsx("div",{className:"transcript-dialog-status",children:"Selected result is outside the retained result window."}):null,be.error?d.jsx("div",{className:"transcript-dialog-error",role:"alert",children:be.error}):null,be.result?.hits.map((oe,xe)=>d.jsxs("button",{type:"button",className:`transcript-prompt-index-item${I?.id===oe.id?" transcript-prompt-index-item-active":""}`,"aria-current":I?.id===oe.id?"true":void 0,onClick:()=>{vi(xe)},children:[d.jsxs("span",{children:[oe.timestamp?new Date(oe.timestamp).toLocaleString():""," · ",oe.role]}),d.jsx("strong",{children:oe.preview.slice(0,500)})]},oe.id))]}):null,Z?d.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:rt.length>0?rt.map((oe,xe)=>d.jsxs("button",{type:"button",className:pt===oe.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>ri(xe),children:[d.jsx("span",{children:oe.timestampLabel}),d.jsx("strong",{children:oe.snippet})]},`${oe.key}:${xe}`)):d.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,Me?d.jsxs("div",{className:"transcript-dialog-status",role:"status",children:["The pinned transcript session changed."," ",d.jsx("button",{type:"button",onClick:()=>{u()},children:"Choose session"})]}):null,de?d.jsx("div",{className:"transcript-dialog-error",role:"alert",children:de}):null,V?d.jsx("div",{className:"transcript-dialog-status",role:"status",children:"Loading search result..."}):null,d.jsxs("div",{ref:b,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:an,onPointerDownCapture:()=>{F.current=!0},children:[Ie?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ve&&Oe?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Nt?d.jsx(oE,{entries:Yt,searchQuery:O,activeEntryIndex:ki,activeEntryMode:fe,activeSearchMatch:_e,fontSize:o}):null,ve?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Me&&!ve&&!Nt&&!de?Oe&&Se?d.jsxs("div",{className:"transcript-dialog-status",children:[ae?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{Gt(Se,"older")},disabled:Ie,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null]})]})})});function jI(e){const t=[];for(let o=0;o<e.length;o+=1){const l=e[o];!l||l.kind!=="user"||t.push({contentKey:OI(l),entry:l,entryIndex:o})}const n=new Map,s=new Map;for(let o=t.length-1;o>=0;o-=1){const l=t[o];if(!l)continue;const u=n.get(l.contentKey)??0;n.set(l.contentKey,u+1),s.set(o,JSON.stringify([l.contentKey,u]))}return t.map((o,l)=>({entryIndex:o.entryIndex,key:s.get(l)??JSON.stringify([o.contentKey,0]),snippet:II(o.entry.body),timestampLabel:PI(o.entry.header)}))}function OI(e){return JSON.stringify([e.header??"",e.body.length,BI(e.body)])}function BI(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 II(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function PI(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function zI(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function HI(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 UI(e){return e.includes("\r")||e.includes(`
|
|
56
|
-
`)}function Tv(e){return e instanceof Hn&&e.status===404}function mc(e){return QE(e)||JE(e)}function QE(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function JE(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function $I(e){if(mc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function FI(e){let t=0;for(const n of e){if(!n)continue;const s=n.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function of(e){const t=[];for(const n of e){const s=e2(n);s&&t.push(s)}return t}function e2(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const o=n.split(";").filter(Boolean).filter(l=>!nI.has(l.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${s}`:""})}function Ev(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function WI(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 hC(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 pr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function lf(e,t){return!t||pr(e)}function fC(e){return pr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function KI(e,t,n,s,o,l,u,f){const g=p=>{const b=VI(p);if(b!==0){if(u()){if(XI(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(b);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),qI(t,b,n,s,o,l)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function qI(e,t,n,s,o,l){const u=()=>{o();try{e.scrollLines(t)}finally{l()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(fb,u);return}u()}function VI(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const s=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,s))}function YI(e,t,n,s,o,l,u,f,g){let p=null,b=0;const _={passive:!1};function w(T){p=Rv(T),b=0}function C(T){const M=Rv(T);if(M===null){p=null,b=0;return}if(p===null){p=M;return}const A=M.clientY-p.clientY;if(p=M,T.cancelable&&T.preventDefault(),A===0)return;if(GI(t)&&ZI(t,M,-A)){b=0;return}b-=A/n();const F=b<0?Math.ceil(b):Math.floor(b);if(F!==0){if(b-=F,f()){g(F);return}l();try{t.scrollLines(F)}finally{u()}s(),F<0&&t.buffer.active.viewportY<=3&&o(F)}}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 GI(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function XI(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function ZI(e,t,n){const s=e.element;return s?(s.dispatchEvent(QI(t,n)),!0):!1}function QI(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const o=new Event("wheel",s);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function mb({node:e,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l=!0,refreshCwdOnEnter:u=!1,tabId:f,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:b=null,mobileFocusLeafKey:_=null,path:w=[],totalPanes:C,onSelect:x,onClose:T,onResize:M,onExit:A,onSnapshot:F,onCloseEditor:z,onAuthClose:P}){const W=C??gb(e);if(w.length===0&&_){const ge=vb(e),ne=ge.some(ie=>ie.key===_)?_:ge[0]?.key;if(ge.length>1&&ne)return d.jsx("div",{className:"mobile-focused-split",children:ge.map(ie=>{const G=ie.key===ne;if(ie.type==="editor"){const ae=n[ie.editorId];return d.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,children:ae?d.jsx(z1,{api:s,editor:ae,canClose:W>1,onClose:()=>z(ie.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ie.key)}const J=t[ie.terminalId];return J?d.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,children:d.jsx(aC,{terminal:J,serverApi:s,active:G,visible:l&&G,canClose:W>1,refreshCwdOnEnter:u&&G,tabId:f,codeServerContext:g,onSelect:()=>x(ie.terminalId),onClose:()=>T(ie.terminalId),onExit:ae=>A(ie.terminalId,ae),onSnapshot:F,...P?{onAuthClose:P}:{}})},ie.key):d.jsx("div",{className:"mobile-focused-pane","data-active":G,"aria-hidden":!G,children:d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ie.key)})})}if(e.type==="pane"){const ge=t[e.terminalId];if(!ge)return d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ne=d.jsx(aC,{terminal:ge,serverApi:s,active:e.terminalId===o,visible:l,canClose:W>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:f,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>T(e.terminalId),onExit:G=>A(e.terminalId,G),onSnapshot:F,...P?{onAuthClose:P}:{}});return p&&b!==e.terminalId?d.jsxs("div",{className:"pane-drop-host",children:[ne,d.jsx(cf,{terminalId:e.terminalId,side:"top"}),d.jsx(cf,{terminalId:e.terminalId,side:"right"}),d.jsx(cf,{terminalId:e.terminalId,side:"bottom"}),d.jsx(cf,{terminalId:e.terminalId,side:"left"})]}):ne}if(e.type==="editor"){const ge=n[e.editorId];return ge?d.jsx(z1,{api:s,editor:ge,canClose:W>1,onClose:()=>z(e.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const $=Math.max(.1,Math.min(.9,e.ratio)),L=1-$,X=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${$}fr) 1px minmax(0, ${L}fr)`}:{gridTemplateRows:`minmax(0, ${$}fr) 1px minmax(0, ${L}fr)`};return d.jsxs("div",{className:"split-pane","data-direction":e.direction,style:X,children:[d.jsx("div",{className:"split-cell",children:d.jsx(mb,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,0],totalPanes:W,onSelect:x,onClose:T,onResize:M,onExit:A,onSnapshot:F,onCloseEditor:z,...P?{onAuthClose:P}:{}})}),d.jsx(JI,{direction:e.direction,path:w,onResize:M}),d.jsx("div",{className:"split-cell",children:d.jsx(mb,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,1],totalPanes:W,onSelect:x,onClose:T,onResize:M,onExit:A,onSnapshot:F,onCloseEditor:z,...P?{onAuthClose:P}:{}})})]})}function cf({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=vp({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return d.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function JI({direction:e,path:t,onResize:n}){function s(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 u=l.parentElement;if(!u)return;const f=u.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 d.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:d.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function gb(e){return e.type==="pane"||e.type==="editor"?1:gb(e.first)+gb(e.second)}function vb(e){return e.type==="pane"?[{key:e6(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:t6(e.editorId),type:"editor",editorId:e.editorId}]:[...vb(e.first),...vb(e.second)]}function e6(e){return`terminal:${e}`}function t6(e){return`editor:${e}`}const jp="workspace-default",n6="NTerminal";function i6(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function gc(e,t){switch(t.type){case"workspace.hydrated":return sp(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return r6(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return l6(e,t.workspaceId);case"workspace.selected":return t2(e,t.workspaceId);case"workspace.renamed":return s6(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return a6(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return o6(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return Oy(e,t.terminal);case"terminal.split":return u6(e,t.terminal,t.direction);case"terminal.updated":return y6(e,t.terminal);case"terminal.exited":return S6(e,t.terminalId,t.exitCode);case"terminal.closed":return s2(e,t.terminalId);case"terminal.detached":return w6(e,t.terminalId,t.workspaceId);case"terminal.revealed":return c6(e,t.terminalId);case"editor.split":return d6(e,t.editorId,t.title,t.direction);case"editor.closed":return x6(e,t.editorId);case"pane.selected":return r2(e,t.terminalId);case"pane.resized":return b6(e,t.path,t.ratio);case"tab.selected":return f6(e,t.tabId);case"tab.renamed":return _6(e,t.tabId,t.title);case"tab.reordered":return By(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return p6(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return n2(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return i2(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return m6(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return h6(e);default:return e}}function r6(e,t){if(e.workspaces.some(s=>s.id===t.id))return t2(e,t.id);const n={id:t.id,title:t.title,defaultCwd:ns(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function t2(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function s6(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const l=e.workspaces.map(u=>u.id!==t||u.title===s?u:(o=!0,{...u,title:s}));return o?{...e,workspaces:l}:e}function a6(e,t,n){const s=ns(n);let o=!1;const l=e.workspaces.map(u=>u.id!==t||u.defaultCwd===s?u:(o=!0,{...u,defaultCwd:s}));return o?{...e,workspaces:l}:e}function o6(e,t,n,s){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 u=e.workspaces.slice(),[f]=u.splice(o,1);if(!f)return e;const g=u.findIndex(_=>_.id===n);if(g<0)return e;const p=s==="before"?g:g+1,b=u.slice();return b.splice(p,0,f),v6(e.workspaces,b)?e:{...e,workspaces:b}}function l6(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),s=new Set(n?xs(n):[]),o={...e.terminals};for(const f of s)delete o[f];const l=e.workspaces.filter(f=>f.id!==t),u=e.activeWorkspaceId===t?l[0]?.id??null:e.activeWorkspaceId;return{workspaces:l,activeWorkspaceId:u,terminals:o}}function Oy(e,t){const n=o2(e),s=yl(n)??Bp(),o=p2(t);return{...n,activeWorkspaceId:s.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(l=>l.id===s.id?{...l,defaultCwd:l.defaultCwd??ns(t.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...l.tabs,o],activeTabId:o.id}:f2(l,t.id))}}function c6(e,t){if(c2(e,t))return r2(e,t);const n=u2(e,t),s=e.terminals[t];return!n||!s?e:Oy({...e,activeWorkspaceId:n.id},s)}function u6(e,t,n){const s=yl(e),o=s?Op(s):void 0;if(!s||!o)return Oy(e,t);const l=o.activeTerminalId,u=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===s.id?{...f,defaultCwd:f.defaultCwd??ns(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:f2(f,t.id))}}function d6(e,t,n,s){const o=yl(e),l=o?Op(o):void 0;if(!o||!l)return e;const u=l.activeTerminalId,f=kd(l.root,u,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===l.id?{...p,root:f,activeTerminalId:u}:p)}:g)}}function h6(e){const t=yl(e),n=t?Op(t):void 0;return n?s2(e,n.activeTerminalId):e}function f6(e,t){const n=yl(e);return!n||!n.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===n.id?{...s,activeTabId:t}:s)}}function By(e,t,n){const s=e.workspaces.map(o=>{const l=o.tabs.findIndex(b=>b.id===t);if(l<0)return o;const u=o.tabs.slice(),[f]=u.splice(l,1);if(!f)return o;const g=Math.max(0,Math.min(u.length,n)),p=u.slice();return p.splice(g,0,f),g6(o.tabs,p)?o:{...o,tabs:p}});return s.every((o,l)=>o===e.workspaces[l])?e:{...e,workspaces:s}}function p6(e,t,n,s,o){if(n===s||!e.terminals[n]||!e.terminals[s])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,M)=>M!==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 u=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(s));if(p<0)return g;const b=g.tabs[p];if(!b)return g;const _={type:"pane",terminalId:n},w={type:"split",direction:u,ratio:.5,first:f?_:{type:"pane",terminalId:s},second:f?{type:"pane",terminalId:s}:_},C=kd(b.root,s,w),x=g.tabs.slice();return x[p]={...b,root:C,activeTerminalId:n},{...g,tabs:x,activeTabId:b.id}}),o2({...e,workspaces:l})}function n2(e,t,n,s){let o=-1,l=-1;for(let M=0;M<e.workspaces.length;M+=1){const A=e.workspaces[M].tabs.findIndex(F=>F.id===t);if(A>=0){o=M,l=A;break}}if(o<0)return e;const u=e.workspaces[o],f=u.tabs[l],g=Tn(f.root);if(!g.includes(n))return e;if(g.length===1)return By(e,t,s);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=u.tabs.slice();C[l]=b;const x=Math.max(0,Math.min(C.length,s));C.splice(x,0,w);const T=e.workspaces.slice();return T[o]={...u,tabs:C,activeTabId:w.id},{...e,workspaces:T}}function i2(e,t,n,s=Number.MAX_SAFE_INTEGER){const o=l2(e.workspaces,t),l=e.workspaces.find(p=>p.id===n);if(!o||!l)return e;if(o.workspace.id===n)return s===Number.MAX_SAFE_INTEGER?e:By(e,t,s);const u=Tn(o.tab.root),f=u.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,s));return b.splice(_,0,o.tab),{...p,defaultCwd:p.defaultCwd??ns(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!u.includes(w)),tabs:b,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function m6(e,t,n,s,o=Number.MAX_SAFE_INTEGER){const l=e.workspaces.find(C=>C.id===s),u=l2(e.workspaces,t);if(!l||!u||!e.terminals[n]||!Tn(u.tab.root).includes(n))return e;if(u.workspace.id===s)return n2(e,t,n,o);if(Tn(u.tab.root).length===1)return i2(e,t,s,o);const g=Lc(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:Tn(g)[0]??u.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===u.workspace.id)return Sl({...C,tabs:C.tabs.map(x=>x.id===t?p:x)});if(C.id===s){const x=C.tabs.slice(),T=Math.max(0,Math.min(x.length,o));return x.splice(T,0,_),{...C,defaultCwd:C.defaultCwd??ns(b.cwd),detachedTerminalIds:C.detachedTerminalIds.filter(M=>M!==n),tabs:x,activeTabId:_.id}}return C});return{...e,workspaces:w,activeWorkspaceId:s}}function g6(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 v6(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 _6(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const l=e.workspaces.map(u=>{let f=!1;const g=u.tabs.map(p=>p.id!==t||p.title===s?p:(o=!0,f=!0,{...p,title:s}));return f?{...u,tabs:g}:u});return o?{...e,workspaces:l}:e}function r2(e,t){const n=e.workspaces.find(o=>o.tabs.some(l=>jc(l.root,t))),s=n?.tabs.find(o=>jc(o.root,t));return!n||!s?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:s.id,tabs:o.tabs.map(l=>l.id===s.id?{...l,activeTerminalId:t}:l)}:o)}}function b6(e,t,n){const s=yl(e),o=s?Op(s):void 0;if(!s||!o)return e;const l=wb(o.root,t,v2(n));return l===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===s.id?{...u,tabs:u.tabs.map(f=>f.id===o.id?{...f,root:l}:f)}:u)}}function sp(e,t,n,s){const o=Object.fromEntries(e.map(_=>[_.id,_])),l=new Set(e.map(_=>_.id)),u=new Set,f=!!(n&&n.some(_=>m2(_))||t&&t.some(_=>g2(_)));let g=C6(t,n,l,u);g.length===0&&(g=[Bp()]);const p=typeof s=="string"&&g.some(_=>_.id===s)?s:g[0]?.id??null,b=p??g[0]?.id??jp;for(const _ of e)if(!u.has(_.id)){if(f)g=k6(g,b,_.id,_);else{const w=p2(_);g=E6(g,b,w,_)}u.add(_.id)}return{workspaces:g.map(_=>Sl(T6(_,o))),activeWorkspaceId:p,terminals:o}}function ll(e){return Tn(e.root)}function ap(e){return xb(e.root)}function xs(e){return Iy([...e.tabs.flatMap(t=>Tn(t.root)),...e.detachedTerminalIds])}function so(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(o=>{const l=yb(o.root);return l?[{...o,root:l}]:[]});return Sl({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function y6(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>jc(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function S6(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function s2(e,t){const n={...e.terminals};return delete n[t],a2(e,t,n)}function w6(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(l=>l.id===n)?n:null)??c2(e,t)?.id??u2(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??jp,o=e.workspaces.find(l=>l.id===s);return!o||!h2(o,t)?e:a2(e,t,{...e.terminals},{detachToWorkspaceId:s})}function a2(e,t,n,s={}){let o=e.workspaces.map(u=>{const f=[];for(const g of u.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({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:f})});s.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===s.detachToWorkspaceId?d2(u,t,n[t]):u));const l=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:l?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function x6(e,t){const n=e.workspaces.map(o=>{const l=[];for(const u of o.tabs){const f=_b(u.root,t);if(!f)continue;const g=Tn(f),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&l.push({...u,root:f,activeTerminalId:p})}return Sl({...o,tabs:l})}),s=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function C6(e,t,n,s){if(t&&t.length>0){const o=[];for(const l of t)m2(l)&&o.push(pC(l,n,s));if(o.length>0)return o}return[pC({...Bp(),tabs:e??[]},n,s)]}function pC(e,t,n){const s=[];for(const l of e.tabs){if(!g2(l))continue;const u=bb(l.root,t);if(!u)continue;const f=Tn(u);for(const p of f)n.add(p);const g=f.includes(l.activeTerminalId)?l.activeTerminalId:f[0];g&&s.push({...l,root:u,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:ns(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function o2(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 l2(e,t){for(const n of e){const s=n.tabs.findIndex(o=>o.id===t);if(s>=0)return{workspace:n,tab:n.tabs[s],tabIndex:s}}return null}function c2(e,t){return e.workspaces.find(n=>n.tabs.some(s=>jc(s.root,t)))}function u2(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function k6(e,t,n,s){return e.map(o=>o.id===t?d2(o,n,s):o)}function d2(e,t,n){return h2(e,t)?{...e,defaultCwd:e.defaultCwd??ns(n?.cwd),detachedTerminalIds:Iy([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function h2(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<mo}function f2(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function T6(e,t){if(e.defaultCwd)return e;const n=xs(e).find(o=>!!t[o]),s=n?ns(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Bp(){return{id:jp,title:n6,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Sl(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:ns(e.defaultCwd),detachedTerminalIds:Iy(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function E6(e,t,n,s){const o=Tn(n.root);return e.map(l=>l.id===t?{...l,defaultCwd:l.defaultCwd??ns(s?.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...l.tabs,n],activeTabId:l.activeTabId??n.id}:l)}function p2(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),s=Lc(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function _b(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=_b(e.first,t),s=_b(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function bb(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=bb(e.first,t),s=bb(e.second,t);return n&&s?{...e,ratio:v2(e.ratio),first:n,second:s}:n??s}function yb(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=yb(e.first),n=yb(e.second);return t&&n?{...e,first:t,second:n}:t??n}function m2(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 g2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Sb(t.root)}function Sb(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")&&Sb(t.first)&&Sb(t.second):!1}function wb(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[s,...o]=t;if(s===0){const l=wb(e.first,o,n);return l===e.first?e:{...e,first:l}}if(s===1){const l=wb(e.second,o,n);return l===e.second?e:{...e,second:l}}return e}function v2(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ns(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Iy(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));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 xb(e){return e.type==="pane"||e.type==="editor"?1:xb(e.first)+xb(e.second)}function op(e,t,n=!1){if(!e)return t;const s=e.agentStatus,o=t.agentStatus,l=Date.parse(e.updatedAt),u=Date.parse(t.updatedAt);return e.status===t.status&&s?.source==="hook"&&o?.source==="hook"&&s.epoch&&s.epoch===o.epoch&&s.revision!==void 0&&o.revision!==void 0&&s.revision!==o.revision?o.revision>s.revision?t:e:Number.isFinite(l)&&(!Number.isFinite(u)||u<l)?e:Number.isFinite(u)&&(!Number.isFinite(l)||u>l)?t:e.status!==t.status?e.status==="exited"?e:t:n?e:t}function R6(e,t){const n=[],s=l=>{l.type==="split"?(s(l.first),s(l.second)):l.type==="pane"?n.push({key:`terminal:${l.terminalId}`,terminalId:l.terminalId}):n.push({key:`editor:${l.editorId}`})};s(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 ir=new Map,Td=new Map,Ed=new Map,Rd=new Map,Dd=new Map,Yu=new Set;let aa=null,D6=0;const Cb=new Set;let _2=0;function gr(e){return e??"__local__"}function N6(e){return{agentId:e,generation:++D6,state:i6(),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 mt(e){const t=gr(e);let n=ir.get(t);return n||(n=N6(e),ir.set(t,n)),n}function Ja(e){return ir.get(gr(e))??null}function b2(e,t){const n=gr(e);let s=Td.get(n);return s||(s=new Set,Td.set(n,s)),s.add(t),()=>{s.delete(t)}}function M6(e){const t=gr(e),n=Td.get(t);if(n)for(const s of Array.from(n))s()}function wl(e,t,n=!0){const s=ir.get(gr(e)),o=n&&mC(s)!==mC(t);ir.set(gr(e),t),M6(e),o&&zy()}function kb(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 Py(e,t){const n=e.state.workspaces.find(u=>u.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const s=new Set;for(const u of n.tabs)for(const f of Tn(u.root))s.add(f);let o=0,l=0;for(const u of s)kb(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(l+=1);return{workingTerminalCount:o,unreadCompletionCount:l}}function mC(e){return e?e.state.workspaces.map(t=>{const n=Py(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function y2(e){return!!(e&&e.state.workspaces.some(t=>{const n=Py(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function zy(){_2+=1;for(const e of Array.from(Cb))e()}function A6(e){return Cb.add(e),()=>{Cb.delete(e)}}function gC(){return _2}function L6(e,t){return Py(mt(e),t)}const Tb=new Set;function j6(e){return Tb.add(e),()=>{Tb.delete(e)}}function Hy(e,t,n=mt(e).state){const s=aa;if(!s||s.agentId!==e||s.generation!==ir.get(gr(e))?.generation)return!1;const o=n.workspaces.find(u=>u.id===s.workspaceId),l=o?.tabs.find(u=>u.id===s.tabId);return!!(o?.id===n.activeWorkspaceId&&l?.id===o?.activeTabId&&l?.root===s.root&&n.terminals[t]&&s.terminalIds.has(t))}function uf(e,t=!0){let n=typeof e=="object"&&e!==null?e:null;if(e!==void 0&&!n&&t){const u=ir.get(gr(e)),f=u?.state.workspaces.find(p=>p.id===u.state.activeWorkspaceId),g=f?.tabs.find(p=>p.id===f.activeTabId);u&&f&&g&&(n={generation:u.generation,agentId:u.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(u=>n.terminalIds.has(u)))}:null,!aa)return;const s=aa.agentId,o=ir.get(gr(s));if(!o||o.generation!==aa.generation){aa=null;return}const l=new Set([...o.unreadCompletions].filter(u=>!Hy(s,u,o.state)));l.size!==o.unreadCompletions.size&&(wl(s,{...o,unreadCompletions:l}),Ip())}function sl(e,t){const n=mt(e),s=gr(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=B6(n.state,t);t.type==="workspace.hydrated"&&(Ed.delete(s),Rd.delete(s),Dd.delete(s));const l=gc(n.state,t);K6(n,t,l);let u=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const b=n.state.terminals[t.terminal.id],_=Y6(s),w=G6(s),C=I6(s);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=`${s}:${x.id}`,M=Yu.has(T)||b?.agentStatus?.completion?.id===x.id;w2(T),!M&&t.notifyCompletion===!0&&(f=Mv(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,M=C.get(t.terminal.id),A=!!(b&&(b.currentCommand!==t.terminal.currentCommand||b.agentStatus?.provider!==t.terminal.agentStatus.provider||O6(M,T)));A&&(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)),!A&&(x==="done"||x==="stopped")&&(w.has(t.terminal.id)||_.has(t.terminal.id))&&(f=Mv(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));const x=b?.activity==="busy",T=t.terminal.activity==="busy",M=t.terminal.activity==="idle";t.notifyCompletion===!0&&T&&_.add(t.terminal.id),t.notifyCompletion===!0&&x&&M&&_.has(t.terminal.id)&&(f=Mv(l,t.terminal.id,b?.currentCommand??null,"finished")),(M||t.terminal.status==="exited")&&_.delete(t.terminal.id)}f&&!Hy(e,t.terminal.id,l)&&!u.has(t.terminal.id)&&(u=new Set(u),u.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([...u].filter(_=>l.terminals[_]));b.size!==u.size&&(u=b)}const g=l!==n.state,p=u!==n.unreadCompletions;if((g||p)&&wl(e,{...n,state:l,unreadCompletions:u},o||p),p&&Ip(),f)for(const b of Array.from(Tb))b({agentId:e,...f})}function O6(e,t){return e!==void 0&&t!==void 0&&e!==t}function B6(e,t){switch(t.type){case"terminal.updated":return kb(e.terminals[t.terminal.id])!==kb(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 I6(e){let t=Dd.get(e);return t||(t=new Map,Dd.set(e,t)),t}function P6(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Tn(s.root).includes(t))return{workspace:n,tab:s};return null}const Eb=new Set;function z6(e){return Eb.add(e),()=>{Eb.delete(e)}}function H6(){let e=0;for(const t of ir.values())e+=t.unreadCompletions.size;return e}function Ip(){for(const e of Array.from(Eb))e()}function vC(e,t){const n=mt(e);if(t!==n.state){n.mutable.hydration.layoutSequence++;for(const s of new Set([...Object.keys(n.state.terminals),...Object.keys(t.terminals)]))n.state.terminals[s]!==t.terminals[s]&&vc(n,s,t.terminals[s]?t.terminals[s].status==="exited"?"exit":"upsert":"delete");wl(e,{...n,state:t})}}function U6(e){const t=mt(e),n=t.mutable.hydration,s={generation:t.generation,requestId:++n.requestId,layoutSequence:n.layoutSequence,metadataSequence:n.metadataSequence};return n.pending=s,n.mutations.clear(),n.overflow=!1,s}function Nd(e,t){const n=ir.get(gr(e));return n?.generation===t.generation&&n.mutable.hydration.pending===t}function _C(e,t){if(!Nd(e,t))return;const n=mt(e).mutable.hydration;n.pending=null,n.mutations.clear()}function S2(e,t,n){if(!Nd(e,t))return null;const s=mt(e),o=s.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 u of s.state.workspaces.flatMap(xs)){const f=s.state.terminals[u];f&&l.set(u,f)}for(const u of n){const f=o.mutations.get(u.id);if(f==="delete")continue;const g=s.state.terminals[u.id];l.set(u.id,f==="exit"&&g?g:op(g,u,!0))}for(const[u,f]of o.mutations)f==="delete"?l.delete(u):s.state.terminals[u]&&l.set(u,op(l.get(u),s.state.terminals[u]));return[...l.values()]}function $6(e,t,n){if(!Nd(e,t)||n.length>0)return!1;const s=mt(e).mutable.hydration;return s.layoutSequence===t.layoutSequence&&s.metadataSequence===t.metadataSequence&&s.mutations.size===0}function F6(e,t,n){const s=S2(e,t,n.terminals);if(!s)return null;const o=mt(e),l=o.mutable.hydration,u=l.metadataSequence!==t.metadataSequence,f=l.layoutSequence!==t.layoutSequence||u,g=f?{...o.state,terminals:Object.fromEntries(s.map(_=>[_.id,_]))}:sp(s,n.savedTabs,n.savedWorkspaces,n.savedActiveWorkspaceId),p=W6(g,n.savedWorkspaces??n.persistedLayout?.workspaces),b=u?o.lastPersistedLayoutJson:f?n.persistedLayout?JSON.stringify(n.persistedLayout):o.lastPersistedLayoutJson:JSON.stringify(so(p));l.pending=null,l.mutations.clear();for(const _ of s)_.agentStatus?.source==="hook"&&_.agentStatus.completion&&w2(`${gr(e)}:${_.agentStatus.completion.id}`);return wl(e,{...o,state:p,loaded:!0,error:null,layoutRevision:u?o.layoutRevision:n.revision,lastPersistedLayoutJson:b}),{state:p,layoutPreserved:f,metadataPreserved:u}}function W6(e,t=[]){const n=new Set(e.workspaces.flatMap(xs)),s=Object.values(e.terminals).filter(_=>!n.has(_.id));if(s.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)),u=new Map;for(const _ of t)if(l.has(_.id))for(const w of xs(_))u.has(w)||u.set(w,_.id);const f=e.workspaces.slice(),g=new Set(f.flatMap(_=>_.tabs.map(w=>w.id)));let p=!1;for(const _ of s){const w=f.findIndex(x=>x.id===(u.get(_.id)??o.id)),C=f[w];if(C.detachedTerminalIds.length<mo)f[w]={...C,detachedTerminalIds:[...C.detachedTerminalIds,_.id]};else{if(!C.tabs.some(M=>M.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 M=1;g.has(T);M++)T=`${x}-${M}`;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(so(b)))throw new Error("Loaded terminals exceed the workspace layout limit. Re-open or delete hidden sessions before retrying.");return b}function w2(e){for(Yu.add(e);Yu.size>2048;)Yu.delete(Yu.values().next().value)}function vc(e,t,n){const s=e.mutable.hydration;if(s.pending){if(!s.mutations.has(t)&&s.mutations.size>=4096){s.overflow=!0;return}s.mutations.set(t,n)}}function K6(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 s of Object.keys(e.state.terminals))n.terminals[s]||vc(e,s,"delete")}function Dv(e,t){const n=mt(e),s=t(n.editors);s!==n.editors&&wl(e,{...n,editors:s},!1)}function eo(e,t,n){const s=mt(e);s.loaded===t&&s.error===n||wl(e,{...s,loaded:t,error:n},!1)}function df(e,t,n){const s=mt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||(s.mutable.hydration.metadataSequence++,wl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n},!1))}function q6(e){const t=mt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function V6(e){const t=gr(e),n=ir.get(t);aa?.agentId===e&&(aa=null),n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1,o=y2(n);ir.delete(t),Td.delete(t),Ed.delete(t),Rd.delete(t),Dd.delete(t),s&&Ip(),o&&zy()}function Nv(){aa=null;let e=!1,t=!1;for(const n of ir.values()){const s=n.mutable.saveCoord.saveTimer;s!==null&&window.clearTimeout(s),n.unreadCompletions.size>0&&(e=!0),y2(n)&&(t=!0)}ir.clear(),Td.clear(),Ed.clear(),Rd.clear(),Dd.clear(),e&&Ip(),t&&zy()}function Y6(e){let t=Ed.get(e);return t||(t=new Set,Ed.set(e,t)),t}function G6(e){let t=Rd.get(e);return t||(t=new Set,Rd.set(e,t)),t}function Mv(e,t,n,s){const o=P6(e,t);return{terminalId:t,tabId:o?.tab.id??null,commandName:n,outcome:s}}function X6(e,t,n){const s=op(e.terminals[t.id],t,!0);if(s.status!=="running")throw new Error("This terminal is no longer running.");let o=gc(e,{type:"terminal.updated",terminal:s});if(o.workspaces.some(l=>xs(l).includes(t.id)))o=gc(o,{type:"terminal.revealed",terminalId:t.id});else{const l=n?.workspaces.find(u=>xs(u).includes(t.id));l&&(o.workspaces.some(u=>u.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:s})}if(!_p(so(o)))throw new Error("This terminal cannot be opened because the workspace layout limit was reached.");return o}function Rb(e,t){let n=!1,s=!1,o=null,l=!1;for(const u of ll(e)){const f=t[u];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"?(s=!0,n=!0,!o&&f.currentCommand&&(o=f.currentCommand)):p==="idle"&&(n=!0)}return n?l?{state:"exited",commandName:null}:s?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Uy(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Db(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function Z6(e,t,n,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function Q6({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,onSelectTab:u,onCreateTab:f,onToggleWorkspaces:g,onCloseTerminals:p,onReattachTerminal:b,onDeleteTerminal:_,onSplitVertical:w,onSplitHorizontal:C,onRenameTab:x,onToggleFavorite:T,onOpenFavorites:M,activePaneAvailable:A}){const[F,z]=v.useState(null),[P,W]=v.useState(!1),[$,L]=v.useState(null),X=v.useRef(null),ge=e.findIndex(R=>R.id===t),ne=ge>=0?e[ge]:e[0]??null,ie=ne?Rb(ne,n):null,G=ne?ap(ne):0,J=ne?Db(ne,n):"No tab";v.useEffect(()=>{X.current?.focus(),X.current?.select()},[F?.tabId]),v.useEffect(()=>{if(!P)return;const R=I=>{I.key==="Escape"&&W(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[P]),v.useEffect(()=>{P&&e.length===0&&W(!1)},[P,e.length]);function ae(R,I){z({tabId:R,title:I})}function ee(){if(!F)return;const R=F.title.trim();R&&x(F.tabId,R),z(null)}function O(){return d.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${lL()}`,onClick:w,disabled:!A,children:d.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${cL()}`,onClick:C,disabled:!A,children:d.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return d.jsxs(d.Fragment,{children:[d.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[d.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:g,children:d.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}),d.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:J,onClick:()=>W(!0),disabled:e.length===0,children:[ie?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":ie.state,"aria-hidden":"true",title:Uy(ie)}):null,d.jsx("span",{children:J}),d.jsxs("small",{children:[ge>=0?ge+1:0,"/",e.length||0,G>1?` / ${G}`:""]})]}),d.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,I)=>{const se=ll(R),_e=ap(R),N=Db(R,n),V=R.id===t,pe=F?.tabId===R.id,Z=Rb(R,n),Q=s?.has(R.id)??!1;return d.jsxs(zt.Fragment,{children:[d.jsx(bC,{index:I}),d.jsx(J6,{tab:R,active:V,editing:pe,title:N,paneCount:_e,terminalIds:se,canClose:e.length>1,editValue:pe?F.title:null,editInputRef:pe?X:null,activity:Z,unread:Q,favorite:o?.has(R.id)??!1,onSelect:()=>u(R.id),onBeginRename:()=>ae(R.id,N),onCloseAll:()=>p(se),onCommitRename:ee,onCancelRename:()=>z(null),onRenameChange:le=>z({tabId:R.id,title:le}),onToggleFavorite:()=>T?.(R)})]},R.id)}),d.jsx(bC,{index:e.length}),d.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),d.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>M?.(),children:"★"}),(l?.length??0)>0?d.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(R=>d.jsx(tP,{terminal:R,onReattach:()=>b?.(R.id),onDelete:()=>L(R)},R.id))}):null]}),d.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),A?O():null]}),P?d.jsx(eP,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,editingTab:F,editInputRef:X,onClose:()=>W(!1),onSelectTab:R=>{u(R),W(!1)},onCreateTab:()=>{f(),W(!1)},onBeginRename:ae,onCloseTerminals:R=>{p(R),W(!1)},onCommitRename:ee,onCancelRename:()=>z(null),onRenameChange:(R,I)=>z({tabId:R,title:I}),onToggleFavorite:T,onOpenFavorites:M,onReattachTerminal:R=>{b?.(R),W(!1)},onDeleteTerminal:R=>{L(R),W(!1)}}):null,$?d.jsx(nP,{terminal:$,onCancel:()=>L(null),onConfirm:()=>{_?.($.id),L(null)}}):null]})}function J6({tab:e,active:t,editing:n,title:s,paneCount:o,canClose:l,editValue:u,editInputRef:f,activity:g,unread:p,favorite:b,onSelect:_,onBeginRename:w,onCloseAll:C,onCommitRename:x,onCancelRename:T,onRenameChange:M,onToggleFavorite:A}){const{attributes:F,listeners:z,setNodeRef:P,transform:W,isDragging:$}=Yb({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),L={transform:ha.Translate.toString(W),opacity:$?.4:void 0,zIndex:$?2:void 0};return d.jsxs("div",{ref:P,className:"terminal-tab","data-active":t,"data-dragging":$,"data-unread":p?"true":void 0,style:L,...F,...z,children:[g?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Uy(g)}):null,n&&f&&u!==null?d.jsxs("form",{className:"terminal-tab-editor",onSubmit:X=>{X.preventDefault(),x()},children:[d.jsx("input",{ref:f,"aria-label":`Rename ${s}`,value:u,onBlur:x,onChange:X=>M(X.target.value),onKeyDown:X=>{if(X.key==="Enter"){X.preventDefault(),x();return}X.key==="Escape"&&(X.preventDefault(),T())}}),d.jsx("small",{children:o})]}):d.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:_,onDoubleClick:X=>{X.preventDefault(),w()},children:[d.jsx("span",{children:s}),d.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:d.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":b?`Remove ${s} from favorites`:`Add ${s} to favorites`,title:b?"Remove from favorites":"Add to favorites",onPointerDown:X=>X.stopPropagation(),onClick:X=>{X.stopPropagation(),A()},children:b?"★":"☆"}),l&&!n?d.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:X=>X.stopPropagation(),onClick:X=>{X.stopPropagation(),C()},children:"x"}):null]})}function eP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,editingTab:u,editInputRef:f,onClose:g,onSelectTab:p,onCreateTab:b,onBeginRename:_,onCloseTerminals:w,onCommitRename:C,onCancelRename:x,onRenameChange:T,onToggleFavorite:M,onOpenFavorites:A,onReattachTerminal:F,onDeleteTerminal:z}){const P=v.useRef(null);return v.useEffect(()=>{P.current?.scrollIntoView?.({block:"nearest"})},[t]),d.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:g,children:d.jsxs("section",{className:"mobile-tab-sheet",onClick:W=>W.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),d.jsxs("small",{children:[e.length," open"]})]}),d.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[d.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:b,children:"+"}),d.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{g(),A?.()},children:"★"}),d.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:g,children:"×"})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((W,$)=>{const L=ll(W),X=ap(W),ge=Db(W,n),ne=W.id===t,ie=u?.tabId===W.id,G=Rb(W,n),J=s?.has(W.id)??!1,ae=o?.has(W.id)??!1;return d.jsxs("div",{ref:ne?P:null,className:"mobile-tab-sheet-row","data-active":ne,"data-unread":J?"true":void 0,children:[ie&&u?d.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ee=>{ee.preventDefault(),C()},children:d.jsx("input",{ref:f,"aria-label":`Rename ${ge}`,value:u.title,onBlur:C,onChange:ee=>T(W.id,ee.target.value),onKeyDown:ee=>{if(ee.key==="Enter"){ee.preventDefault(),C();return}ee.key==="Escape"&&(ee.preventDefault(),x())}})}):d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${ge}`,onClick:()=>p(W.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:$+1}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:ge}),d.jsx("small",{children:Z6(W,n,X,G)})]}),d.jsxs("span",{className:"mobile-tab-sheet-meta",children:[G?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":G.state,"aria-hidden":"true",title:Uy(G)}):null,d.jsx("span",{children:X})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ie?d.jsx("button",{type:"button","aria-label":`Done renaming ${ge}`,onClick:C,children:"Done"}):d.jsx("button",{type:"button","aria-label":`Rename ${ge}`,onClick:()=>_(W.id,ge),children:"Rename"}),ie?null:d.jsx("button",{type:"button","aria-label":ae?`Remove ${ge} from favorites`:`Add ${ge} to favorites`,title:ae?"Remove from favorites":"Add to favorites",onClick:()=>M?.(W),children:ae?"★":"☆"}),e.length>1?d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${ge}`,onClick:()=>w(L),children:"×"}):null]})]},W.id)}),(l?.length??0)>0?d.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[d.jsx("span",{children:"Detached"}),(l??[]).map(W=>{const $=W.title||W.cwd||W.id.slice(0,8);return d.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${$}`,onClick:()=>F(W.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:$}),d.jsx("small",{children:W.cwd})]}),d.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),d.jsx("div",{className:"mobile-tab-sheet-actions",children:d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${$}`,onClick:()=>z(W),children:"×"})})]},W.id)})]}):null]})]})})}function bC({index:e}){const{setNodeRef:t,isOver:n}=vp({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return d.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function tP({terminal:e,onReattach:t,onDelete:n}){const s=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 d.jsxs("span",{className:"terminal-detached-pill",title:o,children:[d.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),d.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:l=>{l.stopPropagation(),n()},children:"×"})]})}function nP({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:"Delete this terminal?"}),d.jsx("span",{children:s}),d.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}const iP="nonce-v1",yC=512,Av=3e4,Lv=1e4;function rP(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 sP=1024*1024,aP=1e3,oP=5e3,lP=1e3;function cP(e,t,n,s={...typeof document>"u"?{}:{document},...typeof window>"u"?{}:{window}},o){const l=s.now??Date.now,u=s.document,f=s.window;let g=!1,p=!1,b="",_=0,w=0,C=!1,x=u?.visibilityState==="hidden",T,M,A,F,z=0,P=0,W=0,$,L=l(),X=-1/0;const ge=[],ne=()=>!C&&u?.visibilityState!=="hidden",ie=Se=>!g&&T===Se,G=(Se,ze)=>!Se.ready&&ze>=Se.handshakeUntil||Se.pending!==void 0&&ze>=Se.pending.until,J=()=>{clearTimeout(A),A=void 0},ae=()=>{clearTimeout(F),F=void 0},ee=()=>{for(const Se of ge.splice(0))Se()},O=Se=>Math.min(3e4,1e3*2**Math.min(Se,5)),R=()=>{g||p||M!==void 0||(M=setTimeout(()=>{M=void 0,Te()},O(z++)))},I=Se=>{p&&(b=Se,w=l()+O(_++));try{o?.(Se)}catch{}},se=(Se,ze=1e3,Oe="activity reconnect",j=!1,ve=!0)=>{if(T===Se){if(T=void 0,Se.pending=void 0,J(),ae(),Se.socket.onmessage=null,Se.socket.onerror=null,Se.socket.onclose=null,j&&(g=!0,clearTimeout(M),M=void 0,ee()),ve)try{Se.socket.close(ze,Oe)}catch{}j||R()}},_e=()=>{A!==void 0||g||!T||!ne()||(A=setTimeout(()=>{A=void 0,Z()},aP))},N=Se=>{if(!ie(Se)||!Se.ready||!Se.probes||Se.pending||!ne())return;if(Se.socket.readyState!==1||Se.socket.bufferedAmount>512){se(Se);return}const ze=`${Se.generation}-${++W}`;Se.pending={nonce:ze,until:l()+Lv},Se.nextProbeAt=l()+Av;const Oe={type:"activity.ping",version:1,nonce:ze};try{Se.socket.send(JSON.stringify(Oe))}catch{se(Se)}},V=(Se=!1)=>{if(g||!ne())return;if(L=l(),X=L,p){I(b);return}const ze=T;ze&&(ze.pending=void 0,ze.ready?ze.probes?N(ze):se(ze):((Se||!Number.isFinite(ze.handshakeUntil))&&(ze.handshakeUntil=L+Lv),ze.resumeProbe=!0),_e())},pe=()=>{const Se=l();return Se>=L&&Se-L<=oP?!1:(ae(),V(!0),!0)},Z=()=>{if(g||!ne()||!T)return;pe(),L=l();const Se=T;Se&&(G(Se,L)?se(Se):Se.ready&&L>=Se.nextProbeAt&&N(Se),_e())},Q=()=>{if(g||!ne()||F!==void 0||!p&&l()>=X&&l()-X<lP)return;const Se=p?Math.min(3e4,Math.max(0,w-l())):0;F=setTimeout(()=>{F=void 0,V()},Se)},le=()=>{T&&(T.pending=void 0,T.ready||(T.handshakeUntil=1/0)),J(),ae(),X=-1/0},Te=()=>{if(g||p)return;const Se=$;let ze;try{const Ae=new URL(e);Se&&Ae.searchParams.set("cursor",Se),ze=t(Ae.toString())}catch{R();return}const Oe={socket:ze,generation:++P,ready:!1,probes:!1,handshakeUntil:ne()?l()+Lv:1/0,nextProbeAt:1/0,pending:void 0,resumeProbe:!1};T=Oe,L=l();let j=Se!==void 0,ve=!1;ze.onmessage=Ae=>{if(ie(Oe)&&(ne()&&pe(),!!ie(Oe))){if(ne()&&G(Oe,l())){se(Oe);return}try{if(typeof Ae.data!="string"||Ae.data.length>sP)throw new Error("invalid activity frame");const Ie=JSON.parse(Ae.data);if(Ie?.type==="activity.pong"){const U=rP(Ae.data);if(!Oe.ready||!Oe.probes||!U)throw new Error("invalid activity probe");ne()&&Oe.pending?.nonce===U.nonce&&(Oe.pending=void 0,Oe.nextProbeAt=l()+Av);return}if(Ie?.type==="activity.ready"){if(Oe.ready||Ie.version!==1||!SC(Ie.cursor)||!["snapshot","resume","gap"].includes(Ie.mode)||(Ie.mode==="resume"?!Se:!ve))throw new Error("invalid activity acknowledgement");$=Ie.cursor,Oe.ready=!0,Oe.probes=Ie.probe===iP,Oe.nextProbeAt=l()+Av,j=!0,z=0,Oe.resumeProbe&&N(Oe),_e();return}if(!dP(Ie)||!j&&!Ie.initial)throw new Error("invalid activity snapshot");if(Ie.initial)ve=!0;else if(!SC(Ie.cursor))throw new Error("activity cursor required");j=!0,n(Ie),(Oe.ready||!ve&&Se)&&($=Ie.cursor)}catch{se(Oe,1e3,"invalid activity message",!0)}}},ze.onerror=()=>{ie(Oe)&&(se(Oe),Oe.ready||I("activity handshake failed"))},ze.onclose=Ae=>{if(!ie(Oe))return;const Ie=Ae.code===1008&&uP(Ae.reason);Ie&&(p=!0),se(Oe,Ae.code,"",Ae.code===1008&&!Ie,!1),Ie?I(Ae.reason):Ae.code!==1008&&!Oe.ready&&I("activity handshake failed")},_e()},je=(Se,ze,Oe)=>{Se?.addEventListener(ze,Oe),ge.push(()=>Se?.removeEventListener(ze,Oe))};je(u,"visibilitychange",()=>{const Se=x;x=u?.visibilityState==="hidden",x?le():Se&&Q()}),je(u,"freeze",()=>{C=!0,le()}),je(u,"resume",()=>{C=!1,Q()}),je(f,"pagehide",()=>{C=!0,le()}),je(f,"pageshow",Se=>{const ze=C;C=!1,(ze||Se.persisted)&&Q()}),je(f,"offline",()=>{X=-1/0}),je(f,"online",Q),Te();const Fe=()=>{g=!0,clearTimeout(M),M=void 0,J(),ae(),ee(),T&&se(T,1e3,"activity disposed",!0)};return Fe.reauthenticate=()=>{g||!p||(ae(),p=!1,b="",_=0,w=0,R())},Fe}function uP(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 dP(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 Nb=new Set;let Md;function hP(e){return Nb.add(e),Md!==void 0&&e(Md),()=>{Nb.delete(e)}}function fP(){Md=void 0,Rf?.reauthenticate()}function pP(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=gP(t.toString(),void 0,void 0,n=>{Md=n;for(const s of Nb)s(n)})}return()=>{--wC===0&&(Rf?.(),Rf=void 0,Md=void 0)}}},[e])}function mP(e){for(const t of e.terminals){const n=mt(e.agentId).state.terminals[t.id];e.initial&&n&&Date.parse(t.updatedAt)<Date.parse(n.updatedAt)||sl(e.agentId,{type:"terminal.updated",terminal:t,notifyCompletion:!e.initial})}}function gP(e,t=o=>new WebSocket(o),n=mP,s){return cP(e,t,n,void 0,s)}function x2(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function vP(e,t){return e.reduce((n,s,o)=>{const l=t.get(s);return l&&(n[o]=l),n},Array(e.length))}function hf(e){return e!==null&&e>=0}function _P(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 bP(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const $y=e=>{let{rects:t,activeIndex:n,overIndex:s,index:o}=e;const l=x2(t,s,n),u=t[o],f=l[o];return!f||!u?null:{x:f.left-u.left,y:f.top-u.top,scaleX:f.width/u.width,scaleY:f.height/u.height}},ff={scaleX:1,scaleY:1},yP=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:o,rects:l,overIndex:u}=e;const f=(t=l[n])!=null?t:s;if(!f)return null;if(o===n){const p=l[u];return p?{x:0,y:n<u?p.top+p.height-(f.top+f.height):p.top-f.top,...ff}:null}const g=SP(l,o,n);return o>n&&o<=u?{x:0,y:-f.height-g,...ff}:o<n&&o>=u?{x:0,y:f.height+g,...ff}:{x:0,y:0,...ff}};function SP(e,t,n){const s=e[t],o=e[t-1],l=e[t+1];return s?n<t?o?s.top-(o.top+o.height):l?l.top-(s.top+s.height):0:l?l.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0}const C2="Sortable",k2=zt.createContext({activeIndex:-1,containerId:C2,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:$y,disabled:{draggable:!1,droppable:!1}});function wP(e){let{children:t,id:n,items:s,strategy:o=$y,disabled:l=!1}=e;const{active:u,dragOverlay:f,droppableRects:g,over:p,measureDroppableContainers:b}=ak(),_=jd(C2,n),w=f.rect!==null,C=v.useMemo(()=>s.map($=>typeof $=="object"&&"id"in $?$.id:$),[s]),x=u!=null,T=u?C.indexOf(u.id):-1,M=p?C.indexOf(p.id):-1,A=v.useRef(C),F=!_P(C,A.current),z=M!==-1&&T===-1||F,P=bP(l);Jr(()=>{F&&x&&b(C)},[F,C,x,b]),v.useEffect(()=>{A.current=C},[C]);const W=v.useMemo(()=>({activeIndex:T,containerId:_,disabled:P,disableTransforms:z,items:C,overIndex:M,useDragOverlay:w,sortedRects:vP(C,g),strategy:o}),[T,_,P.draggable,P.droppable,z,C,M,g,w,o]);return zt.createElement(k2.Provider,{value:W},t)}const xP=e=>{let{id:t,items:n,activeIndex:s,overIndex:o}=e;return x2(n,s,o).indexOf(t)},CP=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:o,items:l,newIndex:u,previousItems:f,previousContainerId:g,transition:p}=e;return!p||!s||f!==l&&o===u?!1:n?!0:u!==o&&t===g},kP={duration:200,easing:"ease"},T2="transform",TP=ha.Transition.toString({property:T2,duration:0,easing:"linear"}),EP={roleDescription:"sortable"};function RP(e){let{disabled:t,index:n,node:s,rect:o}=e;const[l,u]=v.useState(null),f=v.useRef(n);return Jr(()=>{if(!t&&n!==f.current&&s.current){const g=o.current;if(g){const p=Ic(s.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)&&u(b)}}n!==f.current&&(f.current=n)},[t,n,s,o]),v.useEffect(()=>{l&&u(null)},[l]),l}function DP(e){let{animateLayoutChanges:t=CP,attributes:n,disabled:s,data:o,getNewIndex:l=xP,id:u,strategy:f,resizeObserverConfig:g,transition:p=kP}=e;const{items:b,containerId:_,activeIndex:w,disabled:C,disableTransforms:x,sortedRects:T,overIndex:M,useDragOverlay:A,strategy:F}=v.useContext(k2),z=NP(s,C),P=b.indexOf(u),W=v.useMemo(()=>({sortable:{containerId:_,index:P,items:b},...o}),[_,o,P,b]),$=v.useMemo(()=>b.slice(b.indexOf(u)),[b,u]),{rect:L,node:X,isOver:ge,setNodeRef:ne}=vp({id:u,data:W,disabled:z.droppable,resizeObserverConfig:{updateMeasurementsFor:$,...g}}),{active:ie,activatorEvent:G,activeNodeRect:J,attributes:ae,setNodeRef:ee,listeners:O,isDragging:R,over:I,setActivatorNodeRef:se,transform:_e}=Yb({id:u,data:W,attributes:{...EP,...n},disabled:z.draggable}),N=fD(ne,ee),V=!!ie,pe=V&&!x&&hf(w)&&hf(M),Z=!A&&R,Q=Z&&pe?_e:null,Te=pe?Q??(f??F)({rects:T,activeNodeRect:J,activeIndex:w,overIndex:M,index:P}):null,je=hf(w)&&hf(M)?l({id:u,items:b,activeIndex:w,overIndex:M}):P,Fe=ie?.id,Se=v.useRef({activeId:Fe,items:b,newIndex:je,containerId:_}),ze=b!==Se.current.items,Oe=t({active:ie,containerId:_,isDragging:R,isSorting:V,id:u,index:P,items:b,newIndex:Se.current.newIndex,previousItems:Se.current.items,previousContainerId:Se.current.containerId,transition:p,wasDragging:Se.current.activeId!=null}),j=RP({disabled:!Oe,index:P,node:X,rect:L});return v.useEffect(()=>{V&&Se.current.newIndex!==je&&(Se.current.newIndex=je),_!==Se.current.containerId&&(Se.current.containerId=_),b!==Se.current.items&&(Se.current.items=b)},[V,je,_,b]),v.useEffect(()=>{if(Fe===Se.current.activeId)return;if(Fe!=null&&Se.current.activeId==null){Se.current.activeId=Fe;return}const Ae=setTimeout(()=>{Se.current.activeId=Fe},50);return()=>clearTimeout(Ae)},[Fe]),{active:ie,activeIndex:w,attributes:ae,data:W,rect:L,index:P,newIndex:je,items:b,isOver:ge,isSorting:V,isDragging:R,listeners:O,node:X,overIndex:M,over:I,setNodeRef:N,setActivatorNodeRef:se,setDroppableNodeRef:ne,setDraggableNodeRef:ee,transform:j??Te,transition:ve()};function ve(){if(j||ze&&Se.current.newIndex===P)return TP;if(!(Z&&!pp(G)||!p)&&(V||Oe))return ha.Transition.toString({...p,property:T2})}}function NP(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(s=e?.droppable)!=null?s:t.droppable}}qt.Down,qt.Right,qt.Up,qt.Left;function MP({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:s=null,getRuntimeStatus:o,onClose:l,onOpen:u,onRemove:f,onReorder:g}){const p=v.useRef(null),[b,_]=v.useState(()=>Date.now()),[w,C]=v.useState("grid"),[x,T]=v.useState(null),M=UC(Pf(Kb,{activationConstraint:{distance:6}}),Pf(qb,{activationConstraint:{delay:180,tolerance:8}})),A=v.useMemo(()=>e.map(Xr),[e]),F=v.useMemo(()=>new Map(e.map(L=>[Xr(L),o?.(L)??null])),[e,o,b]);v.useEffect(()=>{const L=window.setInterval(()=>_(Date.now()),3e4);return()=>window.clearInterval(L)},[]),v.useEffect(()=>{const L=X=>{if(X.key==="Escape"){X.preventDefault(),X.stopImmediatePropagation(),l();return}const ge=X.target;if((ge instanceof HTMLInputElement||ge instanceof HTMLTextAreaElement)&&p.current?.contains(ge)||X.ctrlKey||X.altKey||X.metaKey)return;const ne=Number.parseInt(X.key,10)-1;ne>=0&&ne<Math.min(9,e.length)&&(X.preventDefault(),X.stopImmediatePropagation(),u(e[ne]))};return window.addEventListener("keydown",L,!0),()=>window.removeEventListener("keydown",L,!0)},[e,l,u]);const z=L=>{T(null);const X=String(L.active.id),ge=L.over?String(L.over.id):null;if(!ge||X===ge)return;const ne=e.find(G=>Xr(G)===X),ie=e.find(G=>Xr(G)===ge);ne&&ie&&g(ne,ie)},P=L=>T({activeId:String(L.active.id),overId:null}),W=L=>{const X=String(L.active.id),ge=L.over?String(L.over.id):null;T(ne=>ne?.activeId===X&&ne.overId===ge?ne:{activeId:X,overId:ge})},$=x?e.find(L=>Xr(L)===x.activeId)??null:null;return d.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:l,children:d.jsxs("section",{ref:p,className:"favorite-tabs-dialog",onClick:L=>L.stopPropagation(),children:[d.jsxs("header",{className:"favorite-tabs-header",children:[d.jsxs("div",{children:[d.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",d.jsx("span",{children:e.length})]}),d.jsx("p",{children:"Press 1–9 to open a favorite"})]}),d.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":w==="grid",onClick:()=>C("grid"),children:"▦"}),d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":w==="list",onClick:()=>C("list"),children:"☷"}),d.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:l,children:"×"})]})]}),d.jsxs(sk,{sensors:M,collisionDetection:AD,onDragStart:P,onDragOver:W,onDragEnd:z,onDragCancel:()=>T(null),children:[d.jsxs("div",{className:"favorite-tabs-list","data-view":w,children:[s?d.jsx("p",{className:"favorite-tabs-error",role:"alert",children:s}):null,e.length===0?d.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):d.jsx(wP,{items:A,strategy:w==="grid"?$y:yP,children:e.map((L,X)=>d.jsx(AP,{favorite:L,index:X,busy:n,unavailable:t?.has(Xr(L))??!1,runtimeStatus:F.get(Xr(L))??null,now:b,isDropTarget:x?.overId===Xr(L)&&x.activeId!==Xr(L),onOpen:u,onRemove:f},Xr(L)))})]}),d.jsx(HN,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:$?d.jsx(LP,{favorite:$}):null})]})]})})}const AP=v.memo(function({favorite:t,index:n,busy:s,unavailable:o,runtimeStatus:l,now:u,isDropTarget:f,onOpen:g,onRemove:p}){const b=Xr(t),{attributes:_,listeners:w,setActivatorNodeRef:C,setNodeRef:x,transform:T,transition:M,isDragging:A}=DP({id:b,disabled:s,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),F={transform:ha.Transform.toString(T),transition:M,zIndex:A?1:void 0,opacity:A?.16:void 0};return d.jsxs("div",{ref:x,className:"favorite-tab-row","data-dragging":A||void 0,"data-drop-target":f||void 0,style:F,children:[d.jsx("button",{ref:C,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:z=>z.stopPropagation(),..._,...w,children:"⋮⋮"}),d.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>g(t),disabled:s||o,title:o?"Server is no longer registered":void 0,children:[d.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),l&&!o?d.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${l.state}`,title:"Last observed terminal status",children:[d.jsx("i",{"aria-hidden":"true"}),jP(l.state),l.lastActivityAt?` · ${OP(l.lastActivityAt,u)}`:""]}):null,l?.unread&&!o?d.jsxs("small",{className:"favorite-tab-runtime favorite-tab-runtime--unread",title:"Unread completion",children:[d.jsx("i",{"aria-hidden":"true"}),"Unread"]}):null]}),d.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(z=>d.jsx("img",{src:`/brand/${z}.webp`,alt:"","aria-hidden":"true"},z)),d.jsx("em",{children:t.paneCount})]})]}),d.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:s,onClick:()=>p(t),children:"×"})]})}),LP=v.memo(function({favorite:t}){return d.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[d.jsx("span",{className:"favorite-tab-index",children:"★"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),d.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(n=>d.jsx("img",{src:`/brand/${n}.webp`,alt:""},n)),d.jsx("em",{children:t.paneCount})]})]})});function Xr(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function jP(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function OP(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"recently";const s=Math.max(0,Math.floor((t-n)/1e3));if(s<60)return"now";const o=Math.floor(s/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 BP({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return d.jsxs("aside",{className:`upload-toast upload-toast-${UP(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[d.jsxs("header",{className:"upload-toast-header",children:[d.jsx("strong",{children:e.length===1?Df(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),d.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),d.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>d.jsx(IP,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>o(g.id)},g.id))})]})}function IP({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:o}){const l="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return d.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Df(e),children:[d.jsxs("div",{className:"upload-queue-item-header",children:[d.jsx("strong",{children:Df(e)}),d.jsxs("div",{className:"upload-queue-actions",children:[f?d.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?d.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,d.jsx("button",{type:"button","aria-label":`Dismiss ${Df(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?d.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?d.jsx(PP,{toast:e}):null,l&&"message"in e&&e.message?d.jsx("p",{className:"upload-toast-muted",children:e.message}):null,l?d.jsx(zP,{response:l,compact:t}):null,e.status==="failed"&&!l&&e.message?d.jsx("p",{children:e.message}):null]})}function PP({toast:e}){const t=e.percent===null?$P(e.loaded):`${e.percent}%`;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"upload-progress-row",children:[d.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),d.jsx("span",{children:t})]}),d.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:d.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function zP({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),s=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,l=[...n,...s].slice(0,o);return d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),l.length>0?d.jsx("ul",{className:"upload-result-list",children:l.map((u,f)=>d.jsx(HP,{result:u},`${u.relativePath}-${f}`))}):null,e.results.length>l.length?d.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-l.length," more"]}):null]})}function HP({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return d.jsxs("li",{"data-status":e.status,children:[d.jsx("span",{className:"upload-result-path",children:t}),n?d.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?d.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 UP(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 $P(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function FP({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const s=e,o=s.outcome==="stopped"?"stopped":"finished",l=s.commandName?`${s.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function f(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(s)))}return d.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:f,children:[d.jsxs("header",{className:"completion-toast-header",children:[d.jsxs("div",{className:"completion-toast-copy",children:[d.jsx("strong",{children:s.tabTitle}),d.jsx("span",{children:l})]}),d.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),d.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const WP=Xu(0,0,1,1),ra=1e-6;function KP(e){return E2(e).map(t=>t.terminalId)}function E2(e){return Gu(e,WP).sort(GP).map((t,n)=>({...t,index:n+1}))}function qP(e,t,n){const s=E2(e),o=s.find(u=>u.terminalId===t);return o?s.filter(u=>u.terminalId!==t).map(u=>YP(o,u,n)).filter(u=>u!==null).sort(XP)[0]?.entry.terminalId??null:null}function VP(e,t){return!Number.isInteger(t)||t<1?null:KP(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=ZP(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 s=t.top+(t.bottom-t.top)*n;return[...Gu(e.first,Xu(t.left,t.top,t.right,s)),...Gu(e.second,Xu(t.left,s,t.right,t.bottom))]}function YP(e,t,n){const s=e.bounds,o=t.bounds,l=xC(s.left,s.right,o.left,o.right),u=xC(s.top,s.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=s.centerX-ra||u<=ra?null:{entry:t,primaryDistance:Math.max(0,s.left-o.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:u};case"right":return o.centerX<=s.centerX+ra||u<=ra?null:{entry:t,primaryDistance:Math.max(0,o.left-s.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:u};case"up":return o.centerY>=s.centerY-ra||l<=ra?null:{entry:t,primaryDistance:Math.max(0,s.top-o.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:l};case"down":return o.centerY<=s.centerY+ra||l<=ra?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:l};default:return null}}function GP(e,t){return wc(e.bounds.top,t.bounds.top)||wc(e.bounds.left,t.bounds.left)}function XP(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)<=ra?0:n}function xC(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Xu(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function ZP(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const CC="nterminal.terminalWorkspaces.v2",R2="nterminal.sidebarCollapsed.v1",QP=75,kC=lk.map(e=>e.url),JP=lk[0].url,ez=6;function tz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:o=null,previewMode:l=!1,onLogout:u=async()=>{},onSessionInvalid:f}){pP();const g=v.useMemo(()=>e??up(),[e]),p=v.useMemo(()=>t??Zr(null),[t]),b=v.useMemo(()=>wz(n),[n]),_=v.useMemo(()=>S=>b2(n,S),[n]),w=v.useMemo(()=>()=>mt(n),[n]),C=v.useSyncExternalStore(_,w,w),x=C.state,T=C.editors,M=!C.loaded,A=C.error,[F,z]=v.useState(!1),[P,W]=v.useState(()=>Dz()),[$,L]=v.useState("servers"),[X,ge]=v.useState(!1),[ne,ie]=v.useState(!1),[G,J]=v.useState([]),[ae,ee]=v.useState(!1),[O,R]=v.useState(null),[I,se]=v.useState(null),[_e,N]=v.useState(null),V=v.useMemo(()=>Zr(_e?.agentId??null),[_e?.agentId]),pe=v.useMemo(()=>Zr(I?.agentId??null),[I?.agentId]),Z=v.useSyncExternalStore(bL,j1,j1);v.useSyncExternalStore(nd,L1,L1);const[Q,le]=v.useState(0),[Te,je]=v.useState(null),[Fe,Se]=v.useState(()=>[null]),[ze,Oe]=v.useState(()=>({[Vt]:"Local"})),j=v.useRef(new Set),[ve,Ae]=v.useState(0),[Ie,U]=v.useState(()=>[n]),[de,ke]=v.useState(()=>new Set),[Me,Le]=v.useState({}),[be,$e]=v.useState(null),We=v.useRef(0),He=v.useRef(0),[vt,wt]=v.useState(null),[lt,Nt]=v.useState(null),Yt=v.useRef(null),rt=v.useRef(0),jn=v.useRef(null),Sn=v.useRef(null),ut=v.useRef(null),Lt=v.useRef(null),Ct=v.useRef([]),gi=v.useRef(0),ki=v.useRef(!1),fe=v.useRef(0),Ze=v.useRef(0),at=v.useRef([]),pt=v.useRef(null),yt=v.useRef(null),It=v.useRef(null),$t=v.useRef(new Map),dn=v.useRef(!0),[Gt,sn]=v.useState(0),hn=v.useRef(()=>{});v.useEffect(()=>(dn.current=!0,()=>{dn.current=!1}),[]);const[an,ln]=v.useState(null),En=UC(Pf(Kb,{activationConstraint:{distance:8}}),Pf(qb,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>yL(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 ri(){ln(null)}const dt=x.workspaces.find(S=>S.id===x.activeWorkspaceId)??x.workspaces[0],kt=dt?.tabs.find(S=>S.id===dt.activeTabId)??dt?.tabs[0],oe=kt?.activeTerminalId??null,xe=oe?x.terminals[oe]:void 0,Ye=_z("(max-width: 760px)"),Xe=v.useMemo(()=>kt?lp(kt.root):[],[kt]),et=dt&&kt?Zu(n,dt.id,kt.id):null,fn=kt?D2(Xe,kt.activeTerminalId,et?Me[et]:void 0):null,xn=Ye&&Xe.length>1;v.useLayoutEffect(()=>{Es.current=n;const S=()=>{if(uf(void 0),document.visibilityState!=="visible"||!C.loaded||Qn()||!dt||!kt)return;const k=mt(n);k.generation!==C.generation||k.state!==x||uf({generation:C.generation,agentId:n,workspaceId:dt.id,tabId:kt.id,root:kt.root,terminalIds:R6(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,dt?.id,kt?.id,kt?.root,kt?.activeTerminalId,Ye,fn,Gt]);const Mi=v.useMemo(()=>(dt?.detachedTerminalIds??[]).flatMap(S=>{const k=x.terminals[S];return k?[k]:[]}),[dt?.detachedTerminalIds,x.terminals]),Ft=v.useMemo(()=>{const S=new Set;for(const k of dt?.tabs??[])ll(k).some(B=>C.unreadCompletions.has(B))&&S.add(k.id);return S},[dt?.tabs,C.unreadCompletions]);v.useSyncExternalStore(A6,gC,gC);const[Ai,vr]=v.useState([]),$n=v.useRef([]),Li=v.useRef(null),[Ki,pn]=v.useState(null),[si,Ts]=v.useState(null),[ji,cn]=v.useState([]),[_r,Co]=v.useState(()=>fl()),ga=v.useRef(0),Es=v.useRef(n),Xn=v.useRef(kC),zr=v.useRef(_r),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]),Rs=v.useCallback(S=>{for(const k of S)j.current.add(al(k.agentId));Oe(k=>{const B={...k};for(const Y of S)B[al(Y.agentId)]=Y.label;return Ov(k,B)?k:B})},[]);v.useEffect(()=>{const S=Ze.current+1;Ze.current=S;const k=fe.current;g.getFavorites().then(B=>{S!==Ze.current||k!==fe.current||(Ur(B.favorites,B.revision),Ti(B.favorites,n,x))}).catch(()=>{})},[g]),v.useEffect(()=>{Ti(Ct.current,n,x)},[n,ze]),v.useEffect(()=>{U(S=>S.some(k=>zn(k,n))?S:[...S,n])},[n]);const va=v.useCallback(S=>{const k=mt(S),B=Zr(S);for(const Y of Object.keys(k.state.terminals))fc(B.createWebSocketUrl(Y)),Hu(Y),hc(Y);V6(S),U(Y=>Y.filter(re=>!zn(re,S))),ke(Y=>{const re=`${Mf(S)}:`;let ce=!1;const Re=new Set;for(const Be of Y){if(Be.startsWith(re)){ce=!0;continue}Re.add(Be)}return ce?Re:Y}),Le(Y=>{const re=`${Mf(S)}:`;let ce=!1;const Re={};for(const[Be,qe]of Object.entries(Y)){if(Be.startsWith(re)){ce=!0;continue}Re[Be]=qe}return ce?Re:Y})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(k=>{if(S)return;const B=k.name?.trim()||"Local";j.current.add(Vt),Oe(Y=>{const re={...Y,[Vt]:B};return Ov(Y,re)?Y:re})}).catch(()=>{}),g.listAgents().then(k=>{if(!S){const B=k.agents.map(ce=>ce.id),Y=mA(k.serverOrder,k.agents);for(const ce of k.agents)j.current.add(al(ce.id));Oe(ce=>{const Re={[Vt]:ce[Vt]??"Local"};for(const Be of k.agents)Re[Be.id]=Be.name;return Ov(ce,Re)?ce:Re}),n!==null&&!B.includes(n)&&(va(n),s?.(null));const re=Lt.current;re&&re.serverId!==Vt&&!B.includes(re.serverId)&&(Lt.current=null,R(`${re.serverName} is no longer registered.`),ie(!0)),Se(Y)}}).catch(()=>{}),()=>{S=!0}},[n,g,va,s,ve]);const Ds=v.useCallback(S=>{va(S),Ae(k=>k+1),zn(S,Es.current)&&s?.(null)},[va,s]);v.useEffect(()=>{Se(S=>S.some(k=>zn(k,n))?S:[...S,n])},[n]),v.useEffect(()=>{je(null)},[n]),v.useEffect(()=>{const S=jn.current;if(!S)return;if(!zn(S.agentId,n)){jn.current=null;return}if(!C.loaded||x.workspaces.length===0)return;jn.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(!zn(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=ut.current;if(S){if(!zn(S.agentId,n)){ut.current=null;return}C.loaded&&(ut.current=null,C.error||On())}},[n,C.error,C.loaded]),v.useEffect(()=>{const S=Lt.current;if(!(!S||!zn(S.serverId===Vt?null:S.serverId,n)||!C.loaded)){if(Lt.current=null,C.error){R(`Could not reach ${S.serverName}.`),ie(!0);return}ya(S)}},[n,C.loaded]),v.useEffect(()=>{const S=()=>{const Y=yz();Y&&hn.current(Y)},k=Y=>{const re=Sz(Y.data);re&&hn.current(re)},B=Y=>{const re=bp(Y.detail);re&&hn.current(re)};return S(),window.addEventListener("hashchange",S),window.addEventListener(Fv,B),navigator.serviceWorker?.addEventListener?.("message",k),()=>{window.removeEventListener("hashchange",S),window.removeEventListener(Fv,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(()=>{zr.current=_r},[_r]),v.useEffect(()=>{if(!C.loaded||!dt||!kt)return;const S=Zu(n,dt.id,kt.id);ke(k=>{if(k.has(S))return k;const B=new Set(k);return B.add(S),B})},[n,C.loaded,dt?.id,kt?.id]),v.useEffect(()=>()=>{Ml()},[]),v.useEffect(()=>{const S=IM(g),k=HM(g);return()=>{S(),k()}},[g]),v.useEffect(()=>j6(S=>{const k=mt(S.agentId).state,B=k.workspaces.flatMap(Re=>Re.tabs).find(Re=>Re.id===S.tabId),Y=k.terminals[S.terminalId],re=B?.title?.trim()||Y?.title||S.commandName||"terminal",ce=Hy(S.agentId,S.terminalId);if(ce||MM({agentId:S.agentId,tabTitle:re,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!ce&&document.visibilityState==="visible"&&zr.current.enabled){const Re=ga.current+1;ga.current=Re;const Be=Xn.current;pn({id:Re,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:re,commandName:S.commandName,outcome:S.outcome,assetSrc:Be[Math.floor(Math.random()*Be.length)]??JP})}}),[]),v.useEffect(()=>{if(!Ki||_r.persistUntilDismissed)return;const S=window.setTimeout(()=>{pn(k=>k?.id===Ki.id?null:k)},_r.durationSeconds*1e3);return()=>window.clearTimeout(S)},[Ki,_r]),v.useEffect(()=>{Nz(P),P&&br()},[P]),v.useEffect(()=>{let S=!1,k;async function B(){if(!mt(n).loaded){k=U6(n),eo(n,!1,null);try{let re=null,ce=null;try{re=xz(b)}catch(qe){if(!(qe instanceof cp))throw qe;ce=qe}const[Re,Be]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]);if(!S&&Nd(n,k)){const qe=Be.layout?Ab(Be.layout):null;if(!qe&&ce)throw ce;const Ke=qe??re??{},ht=$t.current.get(n);let Wt=ht?.generation===k.generation&&!Re.terminals.some(qr=>qr.id===ht.terminal.id)?[...Re.terminals,ht.terminal]:Re.terminals;const jt=S2(n,k,Wt);if(!jt)return;if($6(n,k,jt)){const qr=await p.createTerminal({cols:80,rows:24});Wt=[...Wt,qr.terminal]}if(S)return;const Dn=$t.current.get(n);Dn?.generation===k.generation&&!Wt.some(qr=>qr.id===Dn.terminal.id)&&(Wt=[...Wt,Dn.terminal]);const Is=F6(n,k,{terminals:Wt,...Ke,revision:Be.revision,persistedLayout:Be.layout});if(!Is)return;$t.current.get(n)===Dn&&$t.current.delete(n);const Ps=so(Is.state),Ta=mt(n);(Is.layoutPreserved&&JSON.stringify(Ps)!==Ta.lastPersistedLayoutJson||!Is.metadataPreserved&&!qe&&re)&&xa(Ps,{},k.generation)}}catch(re){!S&&k&&Nd(n,k)&&!Sr(re)&&eo(n,!0,na(re))}finally{k&&_C(n,k)}}}return B(),()=>{S=!0,k&&_C(n,k)}},[n,p,Q]);function _a(){eo(n,!1,null),le(S=>S+1)}function br(){We.current+=1,He.current+=1,$e(null)}function ko(S){We.current+=1,He.current+=1,$e(k=>k&&{...k,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function On(){We.current+=1,He.current+=1;const S=x.workspaces.length+1,k=To();$e({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(zn(S,n)){On();return}ut.current={agentId:S},s?.(S)}function is(S){if(P&&!F)return;const k=x.workspaces.find(Y=>Y.id===S);if(!k)return;We.current+=1,He.current+=1;const B=k.defaultCwd??xe?.cwd??"";$e({mode:"edit",workspaceId:S,title:k.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Vi(B)}function To(){return dt?.defaultCwd??xe?.cwd??""}async function Vi(S){const k=We.current+1;We.current=k;const B=S.trim();if($e(Y=>Y&&{...Y,cwd:S,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const Y=await p.createFileRoot({path:B}),re=await p.listFiles({rootToken:Y.rootToken,path:""});if(We.current!==k)return;$e(ce=>ce&&{...ce,cwd:Y.rootPath,browseRoot:{rootToken:Y.rootToken,rootPath:Y.rootPath},browseEntries:re.entries.filter(Re=>Re.kind==="directory"),browseStatus:"idle",error:null})}catch(Y){if(We.current!==k)return;$e(re=>re&&{...re,browseStatus:"idle",error:na(Y)})}}async function Eo(){const S=be;if(!S)return;const k=S.title.trim(),B=S.cwd.trim();if(!k||!B){$e({...S,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const Y=He.current+1;He.current=Y,$e({...S,submitStatus:"submitting",error:null});try{const re=await p.createFileRoot({path:B});if(He.current!==Y)return;if(S.mode==="create"){const ce=x.workspaces.length+1;ot({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ce}`,title:k,defaultCwd:re.rootPath})}else S.workspaceId&&(ot({type:"workspace.renamed",workspaceId:S.workspaceId,title:k}),ot({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:re.rootPath}));$e(null)}catch(re){if(He.current!==Y)return;$e(ce=>ce&&{...ce,submitStatus:"idle",error:na(re)})}}function Ns(S){He.current+=1,$e(S)}function Hr(S,k,B){if(S===k)return;const Y=x.workspaces.some(ce=>ce.id===S),re=x.workspaces.some(ce=>ce.id===k);!Y||!re||ot({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:k,placement:B})}function rs(S,k){const B=x.workspaces.findIndex(re=>re.id===S),Y=x.workspaces[B+k];B<0||!Y||Hr(S,Y.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<ez)return;k.active=!0,wt(k.sourceId)}const re=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),ce=re?.dataset.workspaceId??null;if(!re||!ce||ce===k.sourceId||!x.workspaces.some(qe=>qe.id===ce)){k.targetId=null,Nt(null);return}const Re=re.getBoundingClientRect(),Be=S.clientY<Re.top+Re.height/2?"before":"after";k.targetId=ce,k.placement=Be,Nt({workspaceId:ce,placement:Be})}function rr(S){const k=Yt.current;!k||k.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Yt.current=null,wt(null),Nt(null),k.active&&k.targetId&&Hr(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,wt(null),Nt(null)}async function ba(){await oi(async()=>{const S=dt?.defaultCwd?{cols:80,rows:24,cwd:dt.defaultCwd}:{cols:80,rows:24},k=await p.createTerminal(S);ot({type:"terminal.created",terminal:k.terminal})})}function Oi(S,k=dt,B=x,Y=n){const re=B.terminals[S.activeTerminalId],ce=Array.from(new Set(ll(S).flatMap(Re=>{const Be=B.terminals[Re]?.agentStatus?.provider;return Be==="codex"||Be==="claude"?[Be]:[]})));return{serverId:Y??Vt,workspaceId:k.id,tabId:S.id,serverName:ze[al(Y)]??(Y===null?"Local":"Server"),workspaceName:k.title,tabName:S.title||re?.title||"Terminal",cwd:re?.cwd||k.defaultCwd,paneCount:ap(S),providers:ce}}function Bi(S){const k=S.serverId===Vt?null:S.serverId,B=Ja(k);if(!B?.loaded||B.error)return null;const Y=B.state,ce=Y.workspaces.find(Ke=>Ke.tabs.some(ht=>ht.id===S.tabId))?.tabs.find(Ke=>Ke.id===S.tabId);if(!ce)return null;const Re=ll(ce).flatMap(Ke=>{const ht=Y.terminals[Ke];return ht?[ht]:[]});if(Re.length===0)return null;const Be=Re.reduce((Ke,ht)=>{const Wt=ht.agentCache?.lastCallAt;return Wt&&(!Ke||Date.parse(Wt)>Date.parse(Ke))?Wt:Ke},null),qe=Re.some(Ke=>B.unreadCompletions.has(Ke.id));return Re.some(Ke=>Ke.status==="running"&&(Ke.agentStatus?.state==="working"||Ke.agentStatus?.state==="finishing"||!Ke.agentStatus&&Ke.activity==="busy"))?{state:"working",lastActivityAt:Be,unread:qe}:Re.some(Ke=>Ke.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Be,unread:qe}:Re.some(Ke=>Ke.agentStatus?.state==="done")?{state:"done",lastActivityAt:Be,unread:qe}:Re.every(Ke=>Ke.status==="exited")?{state:"exited",lastActivityAt:Be,unread:qe}:{state:"idle",lastActivityAt:Be,unread:qe}}function Ur(S,k){Ct.current=S,gi.current=k,J(S)}function yr(S){fe.current+=1,at.current.push(S),!ki.current&&(ki.current=!0,ee(!0),R(null),(async()=>{try{for(;at.current.length>0;){const k=at.current.shift();let B=0;for(;B<2;){const Y=k(Ct.current);if(EC(Y,Ct.current))break;Ur(Y,gi.current);try{const re=await g.saveFavorites({favorites:Y,baseRevision:gi.current});Ur(re.favorites,re.revision);break}catch(re){const ce=await g.getFavorites().catch(()=>null);if(ce&&Ur(ce.favorites,ce.revision),re instanceof Hn&&re.status===409&&ce){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,ee(!1)}})())}function Ti(S,k,B){const Y=k??Vt,re=ce=>ce.map(Re=>{if(Re.serverId!==Y)return Re;const Be=B.workspaces.find(ht=>ht.tabs.some(Wt=>Wt.id===Re.tabId)),qe=Be?.tabs.find(ht=>ht.id===Re.tabId);if(!Be||!qe)return Re;const Ke=Oi(qe,Be,B,k);return j.current.has(al(k))?Ke:{...Ke,serverName:Re.serverName}});EC(S,re(S))||yr(re)}function Ms(S){const k=n??Vt,B=Ct.current.find(re=>re.serverId===k&&re.tabId===S.id);if(B){const re=jr(B);yr(ce=>ce.filter(Re=>jr(Re)!==re));return}if(!dt||Ct.current.length>=100)return;const Y=Oi(S);yr(re=>re.length>=100?re:[...re,Y])}function ai(S){const k=S.serverId===Vt?null:S.serverId;if(k!==null&&!Fe.some(B=>zn(B,k))){R(`${S.serverName} is no longer registered.`);return}if(R(null),ie(!1),!zn(k,n)){Lt.current=S,s?.(k);return}ya(S)}async function ya(S){const k=mt(n).state,B=k.workspaces.find(re=>re.tabs.some(ce=>ce.id===S.tabId));if(B){ot({type:"workspace.selected",workspaceId:B.id}),ot({type:"tab.selected",tabId:S.tabId});return}let Y=k.workspaces.find(re=>re.id===S.workspaceId);if(!Y){const re=`workspace-favorite-${Date.now().toString(36)}`;ot({type:"workspace.created",workspaceId:re,title:S.workspaceName,defaultCwd:S.cwd}),Y=mt(n).state.workspaces.find(ce=>ce.id===re)}Y&&ot({type:"workspace.selected",workspaceId:Y.id}),await oi(async()=>{const re=await p.createTerminal(S.cwd?{cols:80,rows:24,cwd:S.cwd}:{cols:80,rows:24});ot({type:"terminal.created",terminal:re.terminal});const Re=mt(n).state.workspaces.find(jt=>jt.tabs.some(Dn=>Dn.activeTerminalId===re.terminal.id)),Be=Re?.tabs.find(jt=>jt.activeTerminalId===re.terminal.id);if(!Be||!Re)return;Be.title!==S.tabName&&ot({type:"tab.renamed",tabId:Be.id,title:S.tabName});const qe=mt(n).state,Ke=qe.workspaces.find(jt=>jt.id===Re.id)??Re,ht=Ke.tabs.find(jt=>jt.id===Be.id)??Be,Wt=Oi(ht,Ke,qe);yr(jt=>jt.map(Dn=>Dn.serverId===S.serverId&&Dn.workspaceId===S.workspaceId&&Dn.tabId===S.tabId?Wt:Dn))})}async function As(S){await oi(async()=>{const k=oe?{parentTerminalId:oe,cols:80,rows:24}:dt?.defaultCwd?{cols:80,rows:24,cwd:dt.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=oe,B=et;const Y=dt?.defaultCwd?.trim();if(!k&&!Y)throw new Error("No active pane is available.");const re=await p.readFile(S);if(!k&&Y){const Be=await p.createTerminal({cols:80,rows:24,cwd:Y});k=Be.terminal.id,ot({type:"terminal.created",terminal:Be.terminal})}if(k){ot({type:"pane.selected",terminalId:k});const Be=mt(n).state,qe=Be.workspaces.find(ht=>ht.id===Be.activeWorkspaceId)??Be.workspaces[0],Ke=qe?.tabs.find(ht=>ht.id===qe.activeTabId)??qe?.tabs[0];B=qe&&Ke?Zu(n,qe.id,Ke.id):null}const ce=`editor-${Date.now().toString(36)}-${q6(n)}`,Re=Rz(re.path);Dv(n,Be=>({...Be,[ce]:{id:ce,title:Re,rootToken:S.rootToken,path:re.path,read:re}})),B&&Le(Be=>({...Be,[B]:N2(ce)})),ot({type:"editor.split",editorId:ce,title:Re,direction:"vertical"})}function Yi(S){Dv(n,k=>{const B={...k};return delete B[S],B}),ot({type:"editor.closed",editorId:S})}function Ls(S){$r([S])}function $r(S){const k=[...new Set(S)].filter(Y=>x.terminals[Y]);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`;je(null),Ts({terminalIds:k,label:B,workspaceId:dt?.id??x.activeWorkspaceId??null})}function Ei(S,k){const B=Mo(S,k);if(!B)return!1;const Y=S.filter(re=>!B.detachedTerminalIds.includes(re));if(B.detachedTerminalIds.length+Y.length>mo)return je(kz(B.detachedTerminalIds.length)),!1;je(null);for(const re of S)ot(B.id?{type:"terminal.detached",terminalId:re,workspaceId:B.id}:{type:"terminal.detached",terminalId:re});return!0}async function Pi(S){await oi(async()=>{for(const k of S)await as(k),fc(p.createWebSocketUrl(k)),Hu(k),hc(k),ot({type:"terminal.closed",terminalId:k})})}async function js(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=xs(k),Y=[];let re=null;for(const Re of B)try{await as(Re)}catch(Be){Y.push(na(Be)),Be instanceof Hn&&Be.status===401&&!p.isAgent&&(re=Be)}finally{fc(p.createWebSocketUrl(Re)),Hu(Re),hc(Re)}const ce=k.tabs.flatMap(Re=>Mb(Re.root));if(ce.length>0){const Re=new Set(ce);Dv(n,Be=>{const qe={...Be};for(const Ke of Re)delete qe[Ke];return qe})}if(ot({type:"workspace.closed",workspaceId:S}),re)throw re;if(Y.length>0)throw new Error(`Workspace was removed, but ${Y.length} terminal session${Y.length===1?"":"s"} may still be running. ${Y[0]}`)})}async function xl(S){await oi(async()=>{await as(S),fc(p.createWebSocketUrl(S)),Hu(S),hc(S),ot({type:"terminal.closed",terminalId:S})})}async function ss(S,k){const B=k.trim();if(!B)return;let Y=null;for(const re of x.workspaces){const ce=re.tabs.find(Re=>Re.id===S);if(ce){Y=ce.activeTerminalId;break}}if(ot({type:"tab.renamed",tabId:S,title:B}),!!Y)try{const re=await p.renameTerminal(Y,B);No({type:"terminal.updated",terminal:re.terminal})}catch(re){eo(n,!0,na(re))}}function Fr(S){const k=x.terminals[S];k&&ot({type:"terminal.created",terminal:k})}async function as(S){try{await p.closeTerminal(S)}catch(k){if(k instanceof Hn&&k.status===404)return;throw k}}async function Zn(){await oi(async()=>{await u()})}async function oi(S){eo(n,!0,null);try{await S()}catch(k){if(Sr(k))return;eo(n,!0,na(k))}}function Sr(S){return S instanceof Hn&&S.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function ot(S){sl(n,S);const k=mt(n),B=k.state;if(Ti(Ct.current,n,B),!k.loaded||B.workspaces.length===0)return;const Y=so(B);JSON.stringify(Y)!==k.lastPersistedLayoutJson&&jo(Y)}function No(S){sl(n,S),Ti(Ct.current,n,mt(n).state)}function os(S,k,B,Y){const re=Zu(S,k,B);Le(ce=>({...ce,[re]:Y}))}function Wr(S){et&&Le(k=>({...k,[et]:S}))}function Kr(S,k){const B=xc(S);k?os(n,k.workspaceId,k.tabId,B):Wr(B),ot({type:"pane.selected",terminalId:S})}function Sa(S){Wr(S.key),S.type==="terminal"&&ot({type:"pane.selected",terminalId:S.terminalId})}function Cl(S){if(X||_e||si||S.isComposing||S.key==="Process"||oz(S.target))return;const k=iz(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"){ie(!0);return}const B=mt(n).state,Y=B.workspaces.find(Re=>Re.id===B.activeWorkspaceId)??B.workspaces[0],re=Y?.tabs.find(Re=>Re.id===Y.activeTabId)??Y?.tabs[0];if(k.type==="split"){if(!re)return;As(k.direction);return}if(!Y||!re)return;if(k.type==="tab.previous"||k.type==="tab.next"){const Re=az(Y.tabs,re.id,k.type==="tab.next"?1:-1);Re&&ot({type:"tab.selected",tabId:Re.id});return}if(k.type==="tab.index"){const Re=Y.tabs[k.index-1];Re&&ot({type:"tab.selected",tabId:Re.id});return}const ce=rz(re.root,re.activeTerminalId,k);ce&&Kr(ce,{workspaceId:Y.id,tabId:re.id})}function kl(S,k){if(!s||Fe.length===0)return;const B=Fe.findIndex(Re=>zn(Re,n)),re=((B===-1?0:B)+S+Fe.length)%Fe.length,ce=Fe[re]??null;zn(ce,n)||(k&&(jn.current={agentId:ce,edge:k}),s(ce))}function Tl(S){const k=mt(n).state,B=k.workspaces;if(B.length===0){kl(S,S===1?"first":"last");return}const Y=B.findIndex(Re=>Re.id===k.activeWorkspaceId),ce=(Y===-1?0:Y)+S;if(ce>=0&&ce<B.length){ot({type:"workspace.selected",workspaceId:B[ce].id});return}kl(S,S===1?"first":"last")}function El(S,k){if(zn(S,n)){ot({type:"workspace.selected",workspaceId:k});return}Sn.current={agentId:S,workspaceId:k},s?.(S)}function Mo(S,k){if(k)return x.workspaces.find(B=>B.id===k)??null;for(const B of S){const Y=x.workspaces.find(ce=>ce.tabs.some(Re=>ll(Re).includes(B)));if(Y)return Y;const re=x.workspaces.find(ce=>ce.detachedTerminalIds.includes(B));if(re)return re}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=Tz(mt(n).state),B=rt.current+1;if(rt.current=B,!k){ls({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}ls({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 Y=await DE(B);if(Y.length===0)throw new Error("No files were found in the drop.");bi(S,{id:S,status:"queued",fileCount:Y.length,message:"Queued"},{terminalId:k,files:Y})}catch(Y){bi(S,{id:S,status:"failed",fileCount:0,message:na(Y)},{terminalId:k})}finally{wa()}}async function Kc(S){const k=$n.current.find(ce=>ce.id===S);if(!k?.terminalId||!k.files||k.files.length===0)return;const B=k.terminalId,Y=k.files,re=new AbortController;Li.current=S,bi(S,{id:S,status:"uploading",fileCount:Y.length,loaded:0,total:null,percent:null},{terminalId:B,files:Y,abortController:re});try{const ce=await AC({terminalId:B,files:Y,signal:re.signal,onProgress:Ke=>{bi(S,{id:S,status:"uploading",fileCount:Y.length,loaded:Ke.loaded,total:Ke.total,percent:Ke.percent},{terminalId:B,files:Y,abortController:re})}}),Re=ce.failed>0?ce.uploaded>0?"partial":"failed":"success",Be=ce.failed>0?Ez(ce):void 0,qe={id:S,status:Re,fileCount:Y.length,response:ce};Be&&(qe.message=Be),bi(S,qe,{terminalId:B,files:Y})}catch(ce){bi(S,{id:S,status:"failed",fileCount:Y.length,message:re.signal.aborted?"Upload canceled.":na(ce)},{terminalId:B,files:Y})}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 ls(S){cs(k=>[...k,S])}function bi(S,k,B={}){cs(Y=>Y.map(re=>{if(re.id!==S)return re;const ce={...k},Re=B.terminalId??re.terminalId,Be=B.files??re.files;return Re!==void 0&&(ce.terminalId=Re),Be!==void 0&&(ce.files=Be),B.abortController!==void 0&&(ce.abortController=B.abortController),ce}))}function cs(S){const k=S($n.current);$n.current=k,vr(k)}function Fn(S){$n.current.find(B=>B.id===S)?.abortController?.abort(),Li.current===S&&(Li.current=null),cs(B=>B.filter(Y=>Y.id!==S)),wa()}function Lo(){for(const S of $n.current)S.abortController?.abort();Li.current=null,cs(()=>[])}function us(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(Y=>Y.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 Y=B.results.filter(Re=>Re.status==="failed").map(Re=>Re.relativePath);if(Y.length===0)return[];const re=new Map;for(const Re of k){const Be=re.get(Re.relativePath)??[];Be.push(Re),re.set(Re.relativePath,Be)}const ce=[];for(const Re of Y){const qe=re.get(Re)?.shift();qe&&ce.push(qe)}return ce}function Nl(S){Gi({kind:"terminal",agentId:S.agentId,terminalId:S.terminalId}),pn(null)}function Gi(S){if(pt.current=S,yt.current=null,It.current=null,sn(k=>k+1),uf(void 0),!zn(S.agentId,n)){s?s(S.agentId):pt.current=null;return}}function Qn(){const S=pt.current;if(!S||!zn(S.agentId,n))return!1;if(!C.loaded||document.visibilityState!=="visible")return!0;if(It.current?.target===S){const Y=It.current;return Y.generation===C.generation&&(Y.applying||Y.layoutSequence===mt(S.agentId).mutable.hydration.layoutSequence)?!0:(It.current=null,pt.current=null,yt.current=null,!1)}if(yt.current?.target!==S||yt.current.generation!==C.generation){if(yt.current={target:S,generation:C.generation},!mt(S.agentId).state.workspaces.some(ce=>xs(ce).includes(S.terminalId)))return qc(S),!0;ot({type:"terminal.revealed",terminalId:S.terminalId});const re=jv(mt(S.agentId).state,S.terminalId);if(re)return os(S.agentId,re.workspaceId,re.tabId,xc(S.terminalId)),sn(ce=>ce+1),!0}const k=mt(S.agentId),B=jv(k.state,S.terminalId);return B&&(x!==k.state||dt?.id!==B.workspaceId||kt?.id!==B.tabId||xn&&fn!==xc(S.terminalId))?!0:(pt.current=null,yt.current=null,!1)}async function qc(S){const k=mt(S.agentId),B={target:S,generation:k.generation,layoutSequence:k.mutable.hydration.layoutSequence,applying:!1};It.current=B;let Y=!1;const re=()=>dn.current&&It.current===B&&pt.current===S&&Ja(S.agentId)?.generation===B.generation;try{const ce=Zr(S.agentId),[Re,Be]=await Promise.all([ce.listTerminals(),ce.getTerminalLayout()]);if(!re())return;const qe=mt(S.agentId);if(!zn(Es.current,S.agentId)||!qe.loaded||qe.mutable.hydration.layoutSequence!==B.layoutSequence)return;const Ke=Re.terminals.find(Dn=>Dn.id===S.terminalId);if(!Ke)throw new Error("This terminal is no longer available.");const ht=X6(qe.state,Ke,Be.layout);B.applying=!0,vC(S.agentId,ht);const Wt=so(ht);Be.revision===qe.layoutRevision?jo(Wt):lc(Wt,b);const jt=jv(ht,S.terminalId);os(S.agentId,jt.workspaceId,jt.tabId,xc(S.terminalId)),yt.current={target:S,generation:B.generation},Y=!0}catch(ce){re()&&!Sr(ce)&&eo(S.agentId,!0,na(ce))}finally{re()&&(It.current=null,Y||(pt.current=null,yt.current=null),sn(ce=>ce+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 Y=B.pendingLayoutSave;B.pendingLayoutSave=null,Y&&xa(Y,{},k.generation)},QP)}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 Y=Ja(n);if(Y?.generation!==B)return;const re=Y.mutable.saveCoord;re.nextPersistLayout=S,k.baseRevision!==void 0&&(re.queuedBaseRevision=k.baseRevision),!re.nextPersistQueued&&(re.nextPersistQueued=!0,re.persistChain=re.persistChain.then(async()=>{if(Ja(n)?.generation!==B)return;re.nextPersistQueued=!1;const ce=re.nextPersistLayout,Re=re.queuedBaseRevision;re.nextPersistLayout=null,re.queuedBaseRevision=void 0,ce&&await Vc(ce,Re!==void 0?{baseRevision:Re}:{},B)}))}async function Vc(S,k,B){const Y=Ja(n);if(Y?.generation!==B||JSON.stringify(so(Y.state))!==JSON.stringify(S))return;const re=Y.mutable.hydration.layoutSequence,ce=()=>Ja(n)?.generation===B,Re=k.baseRevision??Y.layoutRevision,Be={layout:S,...typeof Re=="number"?{baseRevision:Re}:{}};try{const qe=await p.saveTerminalLayout(Be);if(!ce())return;const Ke=qe.layout??S;df(n,qe.revision,JSON.stringify(Ke)),lc(Ke,b);return}catch(qe){if(!ce())return;if(qe instanceof Hn&&qe.status===400&&qe.message===FN){Cz(n,b),eo(n,!0,M2());return}if(qe instanceof Hn&&qe.status===409)try{const Ke=await p.getTerminalLayout();if(!ce())return;const ht=mt(n).mutable.saveCoord;if(ht.nextPersistLayout||ht.pendingLayoutSave||mt(n).mutable.hydration.layoutSequence!==re){const Wt=Ke.layout?JSON.stringify(Ke.layout):mt(n).lastPersistedLayoutJson;df(n,Ke.revision,Wt);return}if(Ke.layout){const Wt=mt(n).state,jt=sp(Object.values(Wt.terminals),void 0,Ke.layout.workspaces,Ke.layout.activeWorkspaceId),Dn=so(jt);vC(n,jt),df(n,Ke.revision,JSON.stringify(Dn)),lc(Dn,b)}else df(n,Ke.revision,Y.lastPersistedLayoutJson);return}catch{}ce()&&lc(S,b)}}const Al=Mz(o),li=!P||F,Os=li?$:"servers";function Oo(S){const k=S.active?C:mt(S.agentId),B=S.active?x:k.state,Y=S.active?C.loaded:k.loaded,re=S.active?A:k.error;return d.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[d.jsxs("div",{className:"workspace-list-header",children:[d.jsx("span",{children:"Workspaces"}),d.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>_i(S.agentId),children:"+"})]}),Y?re?d.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(S.agentId),children:re}):d.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(ce=>{const Re=S.active&&ce.id===dt?.id,Be=xs(ce).length,qe=L6(S.agentId,ce.id),Ke=hz(qe),ht=S.active&&B.workspaces.length>1,Wt=lt?.workspaceId===ce.id&&vt!==ce.id?lt.placement:null;return d.jsxs(pz,{workspaceId:ce.id,active:Re,disabled:!S.active,reorderable:ht,dragging:vt===ce.id,dropPlacement:Wt,working:qe.workingTerminalCount>0,unread:qe.unreadCompletionCount>0,children:[ht?d.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ce.id,title:"Drag to reorder","aria-label":`Reorder ${ce.title}`,"aria-grabbed":vt===ce.id,onPointerDown:jt=>Ro(ce.id,jt),onPointerMove:Do,onPointerUp:rr,onPointerCancel:$c,onKeyDown:jt=>{(jt.key==="ArrowUp"||jt.key==="ArrowDown")&&(jt.preventDefault(),jt.stopPropagation(),rs(ce.id,jt.key==="ArrowUp"?-1:1))},onClick:jt=>jt.stopPropagation(),children:"::"}):null,d.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Re?"page":void 0,title:ce.defaultCwd??void 0,onClick:()=>El(S.agentId,ce.id),onDoubleClick:()=>{S.active&&is(ce.id)},children:[d.jsxs("span",{className:"workspace-list-title-row",children:[d.jsx("span",{className:"workspace-list-name",children:ce.title}),qe.workingTerminalCount>0||qe.unreadCompletionCount>0?d.jsxs("span",{className:"workspace-list-attention",title:Ke,"aria-label":Ke,children:[qe.workingTerminalCount>0?d.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,qe.unreadCompletionCount>0?d.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:dz(qe.unreadCompletionCount)}):null]}):null]}),d.jsxs("small",{children:[ce.defaultCwd??"No folder"," · ",Be," ",Be===1?"session":"sessions"]})]}),S.active?d.jsxs("div",{className:"workspace-list-actions",children:[d.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ce.title}`,title:"Edit workspace",onClick:()=>is(ce.id),children:"..."}),d.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ce.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{js(ce.id)},children:"x"})]}):null]},ce.id)})}):d.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(S.agentId),children:"Open server to load workspaces"})]})}function Bs(S,k){se({...S,provider:k})}async function Yc(S){if(N(S),!mt(S.agentId).loaded)try{const k=Zr(S.agentId),[B,Y]=await Promise.all([k.listTerminals(),k.getTerminalLayout()]),re=Y.layout?Ab(Y.layout):null,ce=sp(B.terminals,void 0,re?.savedWorkspaces,re?.savedActiveWorkspaceId),Re=ce.workspaces.flatMap(Be=>Be.tabs.flatMap(qe=>Tn(qe.root).flatMap(Ke=>{const ht=ce.terminals[Ke];return ht?[{terminalId:Ke,cwd:ht.cwd,label:`${Be.title} / ${qe.title} / ${ht.title}`}]:[]})));N(Be=>Be===S?{...Be,targets:Re}:Be)}catch{N(k=>k===S?{...k,targetError:"Could not retrieve open tabs."}:k)}}function Ca(S,k){const B=mt(S);if(!B.loaded){$t.current.set(S,{generation:B.generation,terminal:k}),Gi({kind:"terminal",agentId:S,terminalId:k.id});return}if(zn(S,n)){ot({type:"terminal.created",terminal:k});return}sl(S,{type:"terminal.created",terminal:k}),s?.(S)}async function ka(S,k){const B=Zr(S);try{await B.closeTerminal(k)}catch(re){if(!(re instanceof Hn)||re.status!==404)throw re}$t.current.get(S)?.terminal.id===k&&$t.current.delete(S);const Y=pt.current;if(Y?.agentId===S&&Y.terminalId===k&&(pt.current=null,yt.current=null,It.current=null,sn(re=>re+1)),fc(B.createWebSocketUrl(k)),Hu(k),hc(k),zn(S,n)){ot({type:"terminal.closed",terminalId:k});return}sl(S,{type:"terminal.closed",terminalId:k})}return d.jsx(sk,{sensors:En,onDragStart:wn,onDragEnd:vi,onDragCancel:ri,children:d.jsxs("main",{className:"terminal-shell","data-collapsed":P,"data-sidebar-open":F,onDragOver:Fc,onDrop:Wc,children:[d.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>z(!1)}),d.jsxs("aside",{className:"workspace-sidebar",children:[d.jsxs("header",{className:"workspace-brand",children:[d.jsxs("div",{className:"workspace-brand-lockup",children:[li?d.jsx(IC,{height:20}):d.jsx(BC,{size:24}),l&&li?d.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),d.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":P?"Expand sidebar":"Collapse sidebar",title:P?"Expand sidebar":"Collapse sidebar",onClick:()=>W(S=>!S),children:P?">":"<"}),d.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>z(!1),children:"x"})]}),d.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Os==="files"?"files":"servers"}`,children:[li?d.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":$==="servers",onClick:()=>{L("servers")},children:"Workspaces"}),d.jsx("button",{type:"button",role:"tab","aria-selected":$==="files",onClick:()=>{L("files")},children:"Files"})]}):null,Os==="servers"&&li?d.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:d.jsx(N1,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:f,refreshToken:ve,onServerLabelsChange:Rs,onManageAccounts:Bs,onServerInfo:S=>{Yc(S)},renderServerChildren:Oo})}):null,li?null:d.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:d.jsx(N1,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:f,refreshToken:ve,onServerLabelsChange:Rs,compact:!0})}),Os==="files"?d.jsx(BL,{api:p,activeTerminalId:oe,activeTerminalCwd:xe?.cwd??null,workspaceRootPath:oe?null:dt?.defaultCwd??null,onOpenFile:Ii},`${n??"local"}:${dt?.id??"no-workspace"}`):null]}),d.jsxs("div",{className:"workspace-sidebar-footer",children:[li?d.jsx("span",{children:Al}):null,d.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[d.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ge(!0),children:[d.jsx(RC,{name:"settings"}),Z.hasUpdates?d.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),li?d.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{Zn()},children:d.jsx(RC,{name:"logout"})}):null]})]})]}),X?d.jsx(NL,{api:g,onClose:()=>ge(!1),updateAvailable:Z.hasUpdates,onNotificationAssetsChanged:()=>{Rn()},onAgentRemoved:Ds}):null,I?d.jsx(BA,{provider:I.provider,serverLabel:I.label,api:pe,onClose:()=>se(null),onLoginStarted:S=>Ca(I.agentId,S),onLoginFinished:S=>ka(I.agentId,S)}):null,_e&&d.jsx(VA,{api:V,label:_e.label,main:_e.agentId===null,getRuntimeStatus:Bi,favorites:G.filter(S=>S.serverId===(_e.agentId??Vt)),targetStatus:_e.targetError??(!mt(_e.agentId).loaded&&!_e.targets?"Loading open tabs...":null),targets:_e.targets??mt(_e.agentId).state.workspaces.flatMap(S=>S.tabs.flatMap(k=>Tn(k.root).flatMap(B=>{const Y=mt(_e.agentId).state.terminals[B];return Y?[{terminalId:B,cwd:Y.cwd,label:`${S.title} / ${k.title} / ${Y.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?d.jsx(lz,{dialog:be,activePaneCwd:xe?.cwd??null,activeWorkspaceCwd:dt?.defaultCwd??null,onChange:Ns,onManualCwdChange:ko,onBrowse:Vi,onCancel:br,onSubmit:()=>{Eo()}}):null,d.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":xn?"true":void 0,children:[d.jsx(Q6,{tabs:dt?.tabs??[],activeTabId:dt?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Ft,favoriteTabIds:new Set(G.filter(S=>S.serverId===(n??Vt)).map(S=>S.tabId)),detachedTerminals:Mi,onSelectTab:S=>ot({type:"tab.selected",tabId:S}),onCreateTab:()=>{ba()},onToggleWorkspaces:()=>z(S=>!S),onCloseTerminals:S=>$r(S),onReattachTerminal:S=>Fr(S),onDeleteTerminal:S=>{xl(S)},onSplitVertical:()=>{As("vertical")},onSplitHorizontal:()=>{As("horizontal")},onRenameTab:(S,k)=>{ss(S,k)},onToggleFavorite:Ms,onOpenFavorites:()=>ie(!0),activePaneAvailable:!!oe}),ne?d.jsx(MP,{favorites:G,unavailableFavoriteIds:new Set(G.filter(S=>S.serverId!==Vt&&!Fe.some(k=>zn(k,S.serverId))).map(jr)),busy:ae,error:O,getRuntimeStatus:Bi,onClose:()=>{ie(!1),R(null)},onOpen:ai,onRemove:S=>{yr(k=>k.filter(B=>jr(B)!==jr(S)))},onReorder:(S,k)=>{const B=jr(S),Y=jr(k);yr(re=>{const ce=re.findIndex(ht=>jr(ht)===B),Re=re.findIndex(ht=>jr(ht)===Y);if(ce<0||Re<0||ce===Re)return re;const Be=re.slice(),[qe]=Be.splice(ce,1),Ke=Be.findIndex(ht=>jr(ht)===Y);return qe&&Ke>=0&&Be.splice(Ke,0,qe),Be})}}):null,xn?d.jsx(gz,{targets:Xe,activeLeafKey:fn,terminals:x.terminals,editors:T,onSelect:Sa}):null,A?d.jsxs("div",{className:"workspace-error",role:"alert",children:[d.jsx("span",{children:A}),d.jsxs("div",{className:"workspace-error-actions",children:[d.jsx("button",{type:"button",onClick:_a,children:"Retry"}),n!==null&&s?d.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,d.jsxs("section",{className:"workspace-body","aria-busy":M,children:[M?d.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!M&&!kt?d.jsx(fz,{onCreate:()=>{ba()}}):null,Ie.map(S=>{const k=zn(S,n);return d.jsx(nz,{agentId:S,serverName:ze[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&&Kr(B)},onClose:B=>{k&&Ls(B)},onCloseEditor:B=>{k&&Yi(B)},onResize:(B,Y)=>{k&&ot({type:"pane.resized",path:B,ratio:Y})},onExit:(B,Y)=>{k?No({type:"terminal.exited",terminalId:B,exitCode:Y}):sl(S,{type:"terminal.exited",terminalId:B,exitCode:Y})},onSnapshot:(B,Y)=>{const re={type:"terminal.updated",terminal:B,notifyCompletion:Y?.notifyCompletion===!0};k?No(re):sl(S,re)},...f?{onAuthClose:B=>f({...B,source:B?.source??"terminal-ws-1008",activeAgentId:S})}:{}},Mf(S))})]}),si?d.jsx(mz,{label:si.label,count:si.terminalIds.length,warning:Te,onCancel:()=>{je(null),Ts(null)},onHide:()=>{Ei(si.terminalIds,si.workspaceId)&&Ts(null)},onDelete:()=>{const S=si.terminalIds;je(null),Ts(null),Pi(S)}}):null,d.jsx(FP,{toast:Ki,onActivate:Nl,onDismiss:()=>pn(null)}),d.jsx(BP,{uploads:Ai,onDismiss:Fn,onDismissAll:Lo,onRetry:Rl,onCancel:us})]})]})})}function nz({agentId:e,serverName:t,active:n,activeServerApi:s,visitedTabKeys:o,refreshCwdOnEnter:l,draggingTab:u,mobileSplitFocus:f,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:C,onSnapshot:x,onAuthClose:T}){const M=v.useMemo(()=>ne=>b2(e,ne),[e]),A=v.useMemo(()=>()=>mt(e),[e]),F=v.useSyncExternalStore(M,A,A),z=v.useMemo(()=>Zr(e),[e]),P=s??z,W=F.state,$=W.workspaces.find(ne=>ne.id===W.activeWorkspaceId)??W.workspaces[0],L=$?.id??null,ge=($?.tabs.find(ne=>ne.id===$.activeTabId)??$?.tabs[0])?.id??null;return!F.loaded||W.workspaces.length===0?null:d.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:W.workspaces.flatMap(ne=>ne.tabs.map(ie=>{const G=n&&ne.id===L&&ie.id===ge,J=Zu(e,ne.id,ie.id),ae=lp(ie.root),ee=f&&ae.length>1?D2(ae,ie.activeTerminalId,g[J]):null;return!G&&!o.has(J)?null:d.jsx("div",{className:"workspace-tab-surface","data-active":G,"aria-hidden":!G,children:d.jsx(mb,{node:ie.root,terminals:W.terminals,editors:F.editors,api:P,activeTerminalId:ie.activeTerminalId,visible:G,refreshCwdOnEnter:G&&l,tabId:ie.id,codeServerContext:{serverKey:al(e),serverName:t,tabName:ie.title||W.terminals[ie.activeTerminalId]?.title||"Terminal"},dropZoneActive:G&&u!==null,draggingTerminalId:G?u?.terminalId??null:null,mobileFocusLeafKey:ee,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:C,onSnapshot:x,...T?{onAuthClose:T}:{}})},ie.id)}))})}function iz(e){const t=lT(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=sz(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function rz(e,t,n){switch(n.type){case"pane.direction":return qP(e,t,n.direction);case"pane.index":return VP(e,n.index);default:return null}}function sz(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function az(e,t,n){if(e.length===0)return null;const s=e.findIndex(l=>l.id===t);return e[((s===-1?0:s)+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:N2(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...lp(e.first),...lp(e.second)]}function Mb(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Mb(e.first),...Mb(e.second)]}function D2(e,t,n){if(n&&e.some(o=>o.key===n))return n;const s=t?xc(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function xc(e){return`terminal:${e}`}function N2(e){return`editor:${e}`}function oz(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 lz({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:o,onBrowse:l,onCancel:u,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(C=>C.kind==="directory"),b=e.submitStatus==="submitting";function _(C){s(x=>x&&{...x,...C})}function w(C){C&&(_({cwd:C,error:null}),l(C))}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:d.jsxs("form",{className:"security-panel workspace-dialog",onClick:C=>C.stopPropagation(),onSubmit:C=>{C.preventDefault(),b||f()},children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),d.jsxs("section",{className:"workspace-dialog-body",children:[d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:C=>_({title:C.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Default cwd"}),d.jsxs("div",{className:"workspace-dialog-path-row",children:[d.jsx("input",{value:e.cwd,disabled:b,onChange:C=>o(C.currentTarget.value),placeholder:"/home/user/project"}),d.jsx("button",{type:"button",onClick:()=>{l(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),d.jsxs("div",{className:"workspace-dialog-quick-actions",children:[d.jsx("button",{type:"button",onClick:()=>w(t),disabled:b||!t,children:"Use active pane"}),d.jsx("button",{type:"button",onClick:()=>w(n),disabled:b||!n,children:"Use current workspace"})]}),d.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[d.jsxs("div",{className:"workspace-dialog-browser-header",children:[d.jsx("span",{title:g,children:g||"No folder selected"}),d.jsx("button",{type:"button",onClick:()=>{l(uz(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?d.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?d.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?d.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(C=>d.jsxs("button",{type:"button","aria-label":`Choose folder ${C.name}`,disabled:b,onClick:()=>{l(cz(g,C.path))},children:[d.jsx("span",{children:C.name}),d.jsx("small",{children:C.path})]},C.path))}):null]}),e.error?d.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),d.jsxs("div",{className:"workspace-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),d.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function cz(e,t){return t?t.startsWith("/")?Nf(t):Nf(`${e||"/"}/${t}`):Nf(e)}function uz(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 dz(e){return e>99?"99+":String(e)}function hz(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 fz({onCreate:e}){return d.jsxs("div",{className:"empty-workspace",children:[d.jsx("span",{children:"No terminal is open."}),d.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function pz({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:l=null,working:u=!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":"",s?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",u?"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 d.jsx("div",{ref:p,className:_,"data-workspace-id":e,"data-drop-over":b?"true":void 0,children:g})}function mz({label:e,count:t,warning:n,onCancel:s,onHide:o,onDelete:l}){return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),d.jsx("span",{children:e}),d.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?d.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:l,children:"Delete"})]})]})})}function gz({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:o}){const[l,u]=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,s);function _(w){const C=(g+w+e.length)%e.length,x=e[C];x&&o(x)}return d.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[d.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>_(-1),children:"<"}),d.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":l,title:b,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),d.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>_(1),children:">"}),l?d.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:d.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[d.jsxs("header",{children:[d.jsx("strong",{children:"Panes"}),d.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),d.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,C)=>{const x=TC(w,n,s),T=vz(w,n,s),M=w.key===p.key;return d.jsxs("button",{type:"button","data-active":M,onClick:()=>{o(w),u(!1)},children:[d.jsx("span",{className:"mobile-pane-sheet-index",children:C+1}),d.jsxs("span",{className:"mobile-pane-sheet-copy",children:[d.jsx("strong",{children:x}),d.jsx("small",{children:T})]}),d.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 s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function vz(e,t,n){if(e.type==="editor"){const l=n[e.editorId];return l?.path?`editor | ${l.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function _z(e){const[t,n]=v.useState(()=>bz(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const s=window.matchMedia(e),o=()=>n(s.matches);return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):(s.addListener(o),()=>s.removeListener(o))},[e]),t}function bz(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function yz(){if(typeof window>"u")return null;const e=eM(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 Sz(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:bp(t.focus)}function jv(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Tn(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function zn(e,t){return e===t}function jr(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function EC(e,t){return e.length!==t.length?!1:e.every((n,s)=>{const o=t[s];return o!==void 0&&jr(n)===jr(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,u)=>l===o.providers[u])})}function Mf(e){return e??"__local__"}function Zu(e,t,n){return`${Mf(e)}:${t}:${n}`}class cp extends Error{constructor(){super(M2())}}function wz(e){return e?{workspaceKey:`${CC}:${e}`}:{workspaceKey:CC}}function xz(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(ok(n))throw new cp;const s=_p(n);return s?Ab(s):null}catch(n){if(n instanceof cp)throw n;return null}}function Ab(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 Cz(e,t){const n=mt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function kz(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 M2(){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 Tz(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],s=n?e.terminals[n.activeTerminalId]:void 0;return s?.status==="running"?s:null}function Ez(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function Rz(e){return e.split("/").filter(Boolean).pop()??e}function Dz(){try{return localStorage.getItem(R2)==="true"}catch{return!1}}function Nz(e){try{localStorage.setItem(R2,e?"true":"false")}catch{}}function al(e){return e??Vt}function Ov(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(o=>e[o]===t[o])}function Mz(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const s=Math.max(1,Math.floor(n/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function RC({name:e}){return d.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M4 7h9"}),d.jsx("path",{d:"M17 7h3"}),d.jsx("circle",{cx:"15",cy:"7",r:"2"}),d.jsx("path",{d:"M4 12h3"}),d.jsx("path",{d:"M11 12h9"}),d.jsx("circle",{cx:"9",cy:"12",r:"2"}),d.jsx("path",{d:"M4 17h9"}),d.jsx("path",{d:"M17 17h3"}),d.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 6H6v12h4"}),d.jsx("path",{d:"M13 8l4 4-4 4"}),d.jsx("path",{d:"M8 12h9"})]}):null]})}function na(e){return e instanceof Error?e.message:"Request failed"}function Az({api:e,onDone:t}){const[n,s]=v.useState(null),[o,l]=v.useState(null),[u,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(M=>{T||(s(M.qrDataUrl),l(M.secret))}).catch(M=>{T||C(M instanceof Error?M.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:u}),t()}catch(M){_(M instanceof Error?M.message:"Verification failed")}finally{p(!1)}}}return w?d.jsx("p",{className:"form-error",children:w}):!n||!o?d.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):d.jsxs("div",{className:"totp-setup",children:[d.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."}),d.jsx("div",{className:"totp-qr-container",children:d.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),d.jsxs("details",{className:"totp-secret-details",children:[d.jsx("summary",{children:"Can't scan? Enter manually"}),d.jsx("p",{className:"totp-secret-text",children:o})]}),d.jsxs("form",{className:"auth-form",onSubmit:x,children:[d.jsxs("label",{children:["Verification code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:T=>f(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?d.jsx("p",{className:"form-error",children:b}):null,d.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function Lz(e){return{source:Bv(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Bv(e.terminalId)}:{},...e?.detail?{detail:Bv(e.detail)}:{}}}function jz(e){return{invalidationSource:e.source}}function Oz(e){Ni("auth.session_invalid.request",A2(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),Xb("session-invalid-request").catch(()=>{}))}function Bz(e,t){Ni("auth.session_invalid.result",{...A2(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),Xb("session-invalid-result").catch(()=>{}))}function A2(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 Bv(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function Iz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const o=v.useMemo(()=>e??up(),[e]),l=v.useMemo(()=>t??Zr(null),[t]),[u,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 z=!1;return o.getSession().then(P=>{z||(f(P),p(null))}).catch(P=>{z||(p(hl(P)),f(null))}),()=>{z=!0}},[o]);const x=Uz(u);v.useEffect(()=>{const z=w.current;Ni("auth.view",{view:x,previousView:z,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),z==="workspace"&&x!=="workspace"&&(cv(),Xb(`auth-left-workspace-${x}`).catch(()=>{})),w.current=x},[u,x]);async function T(){const z=await o.getSession();f(z),p(null)}async function M(){C(),cv(),Sv(),Nv(),Ux(),$x(),p(null),f(null);try{await T()}catch(z){p(hl(z))}}const A=v.useCallback(z=>{const P=Lz(z);if(Oz(P),b.current)return b.current;const W=_.current,$=(async()=>{p(null);try{const L=await o.getSession(jz(P));if(W!==_.current)return;if(Bz(P,L.authenticated),f(L),L.authenticated){fP(),_4();return}Sv(),Nv(),Ux(),$x()}catch(L){W===_.current&&p(hl(L))}finally{W===_.current&&(b.current=null)}})();return b.current=$,$},[o]);if(v.useEffect(()=>{if(x==="workspace")return hP(z=>{A({source:"activity-auth-check",detail:z})})},[x,A]),x==="workspace")return d.jsx(tz,{api:o,serverApi:l,activeAgentId:n,onSelectServer:s,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:z=>{A(z)},onLogout:async()=>{C(),cv(),Sv(),Nv();const z=await o.logout();f(z)}});const F={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return d.jsxs("main",{className:"auth-screen",children:[d.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[d.jsx("div",{className:"auth-grid"}),d.jsx("div",{className:"auth-glow"})]}),d.jsxs("section",{className:"auth-panel","aria-busy":x==="loading",children:[d.jsxs("header",{className:"auth-header",children:[d.jsxs("div",{className:"auth-brand",children:[d.jsx(BC,{size:26}),d.jsxs("div",{children:[d.jsx(IC,{height:17}),d.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),d.jsx("h1",{children:F[x]})]}),g?d.jsx("p",{className:"form-error",children:g}):null,x==="loading"?d.jsx("p",{className:"muted",children:"Checking session..."}):null,x==="loading"&&g?d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{M()},children:"Retry"}):null,x==="setup_password"?d.jsx(Pz,{api:o,onSession:z=>{f(z)}}):null,x==="setup_totp"?d.jsx(Az,{api:o,onDone:()=>{T()}}):null,x==="login"?d.jsx(zz,{api:o,session:u,onSession:f,onRefresh:T}):null,x==="reauth"?d.jsx(Hz,{api:o,session:u,onSession:f,onFullLogin:()=>f(z=>z&&{...z,deviceTrusted:!1})}):null]})]})}function Pz({api:e,onSession:t}){const[n,s]=v.useState(""),[o,l]=v.useState(""),[u,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 d.jsxs("form",{className:"auth-form",onSubmit:b,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,value:n,onChange:_=>s(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),d.jsxs("label",{children:["Confirm password",d.jsx("input",{value:o,onChange:_=>l(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?d.jsx("p",{className:"form-error",children:g}):null,d.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function zz({api:e,session:t,onSession:n,onRefresh:s}){const[o,l]=v.useState(""),[u,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 M(A){A.preventDefault(),_(!0),C(null);try{n(await e.login({password:o,...x?{otp:u}:{},rememberNetwork:g}))}catch(F){C(hl(F))}finally{_(!1)}}return d.jsxs("form",{className:"auth-form",onSubmit:M,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>l(A.currentTarget.value),required:!0})]}),x?d.jsxs("label",{children:["Authenticator code",d.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:A=>f(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:g,onChange:A=>p(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?d.jsx("p",{className:"form-error",children:w}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:b||o.length===0||x&&u.length!==6,children:"Unlock"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function Hz({api:e,session:t,onSession:n,onFullLogin:s}){const o=t?.currentIpWhitelisted??!1,[l,u]=v.useState(""),[f,g]=v.useState(!1),[p,b]=v.useState(!1),[_,w]=v.useState(!1),[C,x]=v.useState(!1),[T,M]=v.useState(null),A=zt.useCallback(async(z,P)=>{b(!0),M(null);try{n(await e.reauth({...z?{otp:z}:{},rememberNetwork:P}))}catch(W){M(hl(W))}finally{b(!1)}},[e,n]);v.useEffect(()=>{if(o){let z=!1;w(!0),x(!1),M(null);const P=window.setTimeout(()=>{z||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(W=>{z||n(W)}).catch(W=>{z||(M(hl(W)),x(!0))}).finally(()=>{window.clearTimeout(P),z||w(!1)}),()=>{z=!0,window.clearTimeout(P)}}},[e,o,n]);async function F(z){z.preventDefault(),await A(l,f)}return o&&_&&!C&&!T?d.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):d.jsxs("form",{className:"auth-form",onSubmit:F,children:[o&&C&&!T?d.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,d.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),d.jsxs("label",{children:["Authenticator code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:l,onChange:z=>u(z.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:f,onChange:z=>g(z.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?d.jsx("p",{className:"form-error",children:T}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:p||l.length!==6,children:"Continue"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:p,children:"Use password instead"})]})]})}function Uz(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",Lb="nterminal.activeAgentId";function $z(){const[e,t]=v.useState(()=>Fz()),n=v.useMemo(()=>up(),[]),s=v.useMemo(()=>Zr(e),[e]);v.useEffect(()=>{const l=()=>{const u=H6();document.title=u>0?`(${u}) ${DC}`:DC};return l(),z6(l)},[]);function o(l){Wz(l),t(l)}return d.jsx(Iz,{api:n,activeAgentId:e,serverApi:s,onSelectServer:o})}function Fz(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Lb);return e&&e.trim()?e:null}catch{return null}}function Wz(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Lb,e);return}window.localStorage.removeItem(Lb)}catch{}}const NC=["gesturestart","gesturechange","gestureend"],Kz=[".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 qz(e=window){if(!Yz(e))return()=>{};const t={passive:!1},n=e.document;function s(l){l.cancelable&&l.preventDefault()}function o(l){if(l.defaultPrevented)return;const u=l.touches;!u||u.length===0||(u.length>1||!Vz(l.target))&&s(l)}for(const l of NC)n.addEventListener(l,s,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",s,t),()=>{for(const l of NC)n.removeEventListener(l,s,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",s,t)}}function Vz(e){return e instanceof Element&&e.closest(Kz)!==null}function Yz(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}aM();UB();qz();Pb();sD.createRoot(document.getElementById("root")).render(d.jsx(zt.StrictMode,{children:d.jsx($z,{})}));export{zt as R,XR as g,d as j};
|