nterminal 1.3.24 → 1.3.26
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 -1
- package/dist/client/assets/MarkdownPreview-Dz-gstWx.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-D_cxr-gq.js → TranscriptMarkdownBody-wSYk8MdN.js} +1 -1
- package/dist/client/assets/{index-BWGb94RV.js → index-D7G-v5g3.js} +1 -1
- package/dist/client/assets/index-WcP7tpZM.js +59 -0
- package/dist/client/index.html +1 -1
- package/dist/server/agent/agentRoutes.js +6 -1
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/index.js +14 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/activityRoutes.js +3 -2
- package/dist/server/routes/activityRoutes.js.map +1 -1
- package/dist/server/routes/agentManagementRoutes.js +19 -1
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/server/routes/terminalRoutes.d.ts +4 -1
- package/dist/server/routes/terminalRoutes.js +15 -1
- package/dist/server/routes/terminalRoutes.js.map +1 -1
- package/dist/server/routes/terminalWebSocket.js +4 -0
- package/dist/server/routes/terminalWebSocket.js.map +1 -1
- package/dist/server/storage/terminalLayoutCleanup.d.ts +4 -0
- package/dist/server/storage/terminalLayoutCleanup.js +103 -0
- package/dist/server/storage/terminalLayoutCleanup.js.map +1 -0
- package/dist/server/terminal/TerminalManager.d.ts +23 -1
- package/dist/server/terminal/TerminalManager.js +338 -77
- package/dist/server/terminal/TerminalManager.js.map +1 -1
- package/dist/server/terminal/terminalSessionStore.d.ts +27 -0
- package/dist/server/terminal/terminalSessionStore.js +124 -0
- package/dist/server/terminal/terminalSessionStore.js.map +1 -0
- package/dist/shared/layoutState.d.ts +2 -0
- package/dist/shared/layoutState.js +3 -0
- package/dist/shared/layoutState.js.map +1 -1
- package/dist/shared/protocol.d.ts +2 -0
- package/dist/shared/protocol.js.map +1 -1
- package/docs/configuration.md +53 -0
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview--8XdSXg9.js +0 -1
- package/dist/client/assets/index-B82gs1vu.js +0 -59
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview--8XdSXg9.js","assets/index-BWGb94RV.js","assets/TranscriptMarkdownBody-D_cxr-gq.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 d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function vN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hg={exports:{}},id={};var Qw;function _N(){if(Qw)return id;Qw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,l){var d=null;if(l!==void 0&&(d=""+l),o.key!==void 0&&(d=""+o.key),"key"in o){l={};for(var f in o)f!=="key"&&(l[f]=o[f])}else l=o;return o=l.ref,{$$typeof:e,type:s,key:d,ref:o!==void 0?o:null,props:l}}return id.Fragment=t,id.jsx=n,id.jsxs=n,id}var Jw;function bN(){return Jw||(Jw=1,Hg.exports=_N()),Hg.exports}var u=bN(),Ug={exports:{}},yt={};var e1;function yN(){if(e1)return yt;e1=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"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),S=Symbol.iterator;function w(N){return N===null||typeof N!="object"?null:(N=S&&N[S]||N["@@iterator"],typeof N=="function"?N:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,L={};function A(N,V,se){this.props=N,this.context=V,this.refs=L,this.updater=se||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 W(){}W.prototype=A.prototype;function z(N,V,se){this.props=N,this.context=V,this.refs=L,this.updater=se||x}var H=z.prototype=new W;H.constructor=z,R(H,A.prototype),H.isPureReactComponent=!0;var q=Array.isArray;function Y(){}var I={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function de(N,V,se){var J=se.ref;return{$$typeof:e,type:N,key:V,ref:J!==void 0?J:null,props:se}}function me(N,V){return de(N.type,V,N.props)}function K(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function ne(N){var V={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(se){return V[se]})}var ee=/\/+/g;function Z(N,V){return typeof N=="object"&&N!==null&&N.key!=null?ne(""+N.key):V.toString(36)}function X(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(Y,Y):(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 M(N,V,se,J,xe){var ye=typeof N;(ye==="undefined"||ye==="boolean")&&(N=null);var Pe=!1;if(N===null)Pe=!0;else switch(ye){case"bigint":case"string":case"number":Pe=!0;break;case"object":switch(N.$$typeof){case e:case t:Pe=!0;break;case b:return Pe=N._init,M(Pe(N._payload),V,se,J,xe)}}if(Pe)return xe=xe(N),Pe=J===""?"."+Z(N,0):J,q(xe)?(se="",Pe!=null&&(se=Pe.replace(ee,"$&/")+"/"),M(xe,V,se,"",function(ve){return ve})):xe!=null&&(K(xe)&&(xe=me(xe,se+(xe.key==null||N&&N.key===xe.key?"":(""+xe.key).replace(ee,"$&/")+"/")+Pe)),V.push(xe)),1;Pe=0;var Fe=J===""?".":J+":";if(q(N))for(var ze=0;ze<N.length;ze++)J=N[ze],ye=Fe+Z(J,ze),Pe+=M(J,V,se,ye,xe);else if(ze=w(N),typeof ze=="function")for(N=ze.call(N),ze=0;!(J=N.next()).done;)J=J.value,ye=Fe+Z(J,ze++),Pe+=M(J,V,se,ye,xe);else if(ye==="object"){if(typeof N.then=="function")return M(X(N),V,se,J,xe);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 Pe}function T(N,V,se){if(N==null)return N;var J=[],xe=0;return M(N,J,"","",function(ye){return V.call(se,ye,xe++)}),J}function O(N){if(N._status===-1){var V=N._result;V=V(),V.then(function(se){(N._status===0||N._status===-1)&&(N._status=1,N._result=se)},function(se){(N._status===0||N._status===-1)&&(N._status=2,N._result=se)}),N._status===-1&&(N._status=0,N._result=V)}if(N._status===1)return N._result.default;throw N._result}var re=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var 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)},he={map:T,forEach:function(N,V,se){T(N,function(){V.apply(this,arguments)},se)},count:function(N){var V=0;return T(N,function(){V++}),V},toArray:function(N){return T(N,function(V){return V})||[]},only:function(N){if(!K(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return yt.Activity=_,yt.Children=he,yt.Component=A,yt.Fragment=n,yt.Profiler=o,yt.PureComponent=z,yt.StrictMode=s,yt.Suspense=m,yt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,yt.__COMPILER_RUNTIME={__proto__:null,c:function(N){return I.H.useMemoCache(N)}},yt.cache=function(N){return function(){return N.apply(null,arguments)}},yt.cacheSignal=function(){return null},yt.cloneElement=function(N,V,se){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var J=R({},N.props),xe=N.key;if(V!=null)for(ye in V.key!==void 0&&(xe=""+V.key),V)!$.call(V,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&V.ref===void 0||(J[ye]=V[ye]);var ye=arguments.length-2;if(ye===1)J.children=se;else if(1<ye){for(var Pe=Array(ye),Fe=0;Fe<ye;Fe++)Pe[Fe]=arguments[Fe+2];J.children=Pe}return de(N.type,xe,J)},yt.createContext=function(N){return N={$$typeof:d,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:l,_context:N},N},yt.createElement=function(N,V,se){var J,xe={},ye=null;if(V!=null)for(J in V.key!==void 0&&(ye=""+V.key),V)$.call(V,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(xe[J]=V[J]);var Pe=arguments.length-2;if(Pe===1)xe.children=se;else if(1<Pe){for(var Fe=Array(Pe),ze=0;ze<Pe;ze++)Fe[ze]=arguments[ze+2];xe.children=Fe}if(N&&N.defaultProps)for(J in Pe=N.defaultProps,Pe)xe[J]===void 0&&(xe[J]=Pe[J]);return de(N,ye,xe)},yt.createRef=function(){return{current:null}},yt.forwardRef=function(N){return{$$typeof:f,render:N}},yt.isValidElement=K,yt.lazy=function(N){return{$$typeof:b,_payload:{_status:-1,_result:N},_init:O}},yt.memo=function(N,V){return{$$typeof:p,type:N,compare:V===void 0?null:V}},yt.startTransition=function(N){var V=I.T,se={};I.T=se;try{var J=N(),xe=I.S;xe!==null&&xe(se,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(Y,re)}catch(ye){re(ye)}finally{V!==null&&se.types!==null&&(V.types=se.types),I.T=V}},yt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},yt.use=function(N){return I.H.use(N)},yt.useActionState=function(N,V,se){return I.H.useActionState(N,V,se)},yt.useCallback=function(N,V){return I.H.useCallback(N,V)},yt.useContext=function(N){return I.H.useContext(N)},yt.useDebugValue=function(){},yt.useDeferredValue=function(N,V){return I.H.useDeferredValue(N,V)},yt.useEffect=function(N,V){return I.H.useEffect(N,V)},yt.useEffectEvent=function(N){return I.H.useEffectEvent(N)},yt.useId=function(){return I.H.useId()},yt.useImperativeHandle=function(N,V,se){return I.H.useImperativeHandle(N,V,se)},yt.useInsertionEffect=function(N,V){return I.H.useInsertionEffect(N,V)},yt.useLayoutEffect=function(N,V){return I.H.useLayoutEffect(N,V)},yt.useMemo=function(N,V){return I.H.useMemo(N,V)},yt.useOptimistic=function(N,V){return I.H.useOptimistic(N,V)},yt.useReducer=function(N,V,se){return I.H.useReducer(N,V,se)},yt.useRef=function(N){return I.H.useRef(N)},yt.useState=function(N){return I.H.useState(N)},yt.useSyncExternalStore=function(N,V,se){return I.H.useSyncExternalStore(N,V,se)},yt.useTransition=function(){return I.H.useTransition()},yt.version="19.2.6",yt}var t1;function qb(){return t1||(t1=1,Ug.exports=yN()),Ug.exports}var v=qb();const zt=vN(v);var $g={exports:{}},rd={},Fg={exports:{}},Wg={};var n1;function SN(){return n1||(n1=1,(function(e){function t(M,T){var O=M.length;M.push(T);e:for(;0<O;){var re=O-1>>>1,he=M[re];if(0<o(he,T))M[re]=T,M[O]=he,O=re;else break e}}function n(M){return M.length===0?null:M[0]}function s(M){if(M.length===0)return null;var T=M[0],O=M.pop();if(O!==T){M[0]=O;e:for(var re=0,he=M.length,N=he>>>1;re<N;){var V=2*(re+1)-1,se=M[V],J=V+1,xe=M[J];if(0>o(se,O))J<he&&0>o(xe,se)?(M[re]=xe,M[J]=O,re=J):(M[re]=se,M[V]=O,re=V);else if(J<he&&0>o(xe,O))M[re]=xe,M[J]=O,re=J;else break e}}return T}function o(M,T){var O=M.sortIndex-T.sortIndex;return O!==0?O:M.id-T.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],p=[],b=1,_=null,S=3,w=!1,x=!1,R=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,W=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function H(M){for(var T=n(p);T!==null;){if(T.callback===null)s(p);else if(T.startTime<=M)s(p),T.sortIndex=T.expirationTime,t(m,T);else break;T=n(p)}}function q(M){if(R=!1,H(M),!x)if(n(m)!==null)x=!0,Y||(Y=!0,ne());else{var T=n(p);T!==null&&X(q,T.startTime-M)}}var Y=!1,I=-1,$=5,de=-1;function me(){return L?!0:!(e.unstable_now()-de<$)}function K(){if(L=!1,Y){var M=e.unstable_now();de=M;var T=!0;try{e:{x=!1,R&&(R=!1,W(I),I=-1),w=!0;var O=S;try{t:{for(H(M),_=n(m);_!==null&&!(_.expirationTime>M&&me());){var re=_.callback;if(typeof re=="function"){_.callback=null,S=_.priorityLevel;var he=re(_.expirationTime<=M);if(M=e.unstable_now(),typeof he=="function"){_.callback=he,H(M),T=!0;break t}_===n(m)&&s(m),H(M)}else s(m);_=n(m)}if(_!==null)T=!0;else{var N=n(p);N!==null&&X(q,N.startTime-M),T=!1}}break e}finally{_=null,S=O,w=!1}T=void 0}}finally{T?ne():Y=!1}}}var ne;if(typeof z=="function")ne=function(){z(K)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,Z=ee.port2;ee.port1.onmessage=K,ne=function(){Z.postMessage(null)}}else ne=function(){A(K,0)};function X(M,T){I=A(function(){M(e.unstable_now())},T)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(M){switch(S){case 1:case 2:case 3:var T=3;break;default:T=S}var O=S;S=T;try{return M()}finally{S=O}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(M,T){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var O=S;S=M;try{return T()}finally{S=O}},e.unstable_scheduleCallback=function(M,T,O){var re=e.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0<O?re+O:re):O=re,M){case 1:var he=-1;break;case 2:he=250;break;case 5:he=1073741823;break;case 4:he=1e4;break;default:he=5e3}return he=O+he,M={id:b++,callback:T,priorityLevel:M,startTime:O,expirationTime:he,sortIndex:-1},O>re?(M.sortIndex=O,t(p,M),n(m)===null&&M===n(p)&&(R?(W(I),I=-1):R=!0,X(q,O-re))):(M.sortIndex=he,t(m,M),x||w||(x=!0,Y||(Y=!0,ne()))),M},e.unstable_shouldYield=me,e.unstable_wrapCallback=function(M){var T=S;return function(){var O=S;S=T;try{return M.apply(this,arguments)}finally{S=O}}}})(Wg)),Wg}var i1;function wN(){return i1||(i1=1,Fg.exports=SN()),Fg.exports}var Kg={exports:{}},Bi={};var r1;function xN(){if(r1)return Bi;r1=1;var e=qb();function t(m){var p="https://react.dev/errors/"+m;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 #"+m+"; 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(m,p,b){var _=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:_==null?null:""+_,children:m,containerInfo:p,implementation:b}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Bi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,Bi.createPortal=function(m,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(m,p,null,b)},Bi.flushSync=function(m){var p=d.T,b=s.p;try{if(d.T=null,s.p=2,m)return m()}finally{d.T=p,s.p=b,s.d.f()}},Bi.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,s.d.C(m,p))},Bi.prefetchDNS=function(m){typeof m=="string"&&s.d.D(m)},Bi.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var b=p.as,_=f(b,p.crossOrigin),S=typeof p.integrity=="string"?p.integrity:void 0,w=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;b==="style"?s.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:_,integrity:S,fetchPriority:w}):b==="script"&&s.d.X(m,{crossOrigin:_,integrity:S,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Bi.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var b=f(p.as,p.crossOrigin);s.d.M(m,{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(m)},Bi.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var b=p.as,_=f(b,p.crossOrigin);s.d.L(m,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})}},Bi.preloadModule=function(m,p){if(typeof m=="string")if(p){var b=f(p.as,p.crossOrigin);s.d.m(m,{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(m)},Bi.requestFormReset=function(m){s.d.r(m)},Bi.unstable_batchedUpdates=function(m,p){return m(p)},Bi.useFormState=function(m,p,b){return d.H.useFormState(m,p,b)},Bi.useFormStatus=function(){return d.H.useHostTransitionStatus()},Bi.version="19.2.6",Bi}var s1;function qC(){if(s1)return Kg.exports;s1=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(),Kg.exports=xN(),Kg.exports}var a1;function CN(){if(a1)return rd;a1=1;var e=wN(),t=qb(),n=qC();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 d(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function 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 m(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 g=h.alternate;if(g===null){if(c=h.return,c!==null){a=c;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===a)return m(h),i;if(g===c)return m(h),r;g=g.sibling}throw Error(s(188))}if(a.return!==c.return)a=h,c=g;else{for(var y=!1,D=h.child;D;){if(D===a){y=!0,a=h,c=g;break}if(D===c){y=!0,c=h,a=g;break}D=D.sibling}if(!y){for(D=g.child;D;){if(D===a){y=!0,a=g,c=h;break}if(D===c){y=!0,c=g,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,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),W=Symbol.for("react.consumer"),z=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),me=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function ne(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var ee=Symbol.for("react.client.reference");function Z(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===ee?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case R:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case q:return"Suspense";case Y:return"SuspenseList";case de:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case z:return i.displayName||"Context";case W:return(i._context.displayName||"Context")+".Consumer";case H:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case I:return r=i.displayName||null,r!==null?r:Z(i.type)||"Memo";case $:r=i._payload,i=i._init;try{return Z(i(r))}catch{}}return null}var X=Array.isArray,M=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O={pending:!1,data:null,method:null,action:null},re=[],he=-1;function N(i){return{current:i}}function V(i){0>he||(i.current=re[he],re[he]=null,he--)}function se(i,r){he++,re[he]=i.current,i.current=r}var J=N(null),xe=N(null),ye=N(null),Pe=N(null);function Fe(i,r){switch(se(ye,r),se(xe,i),se(J,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?Sw(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=Sw(r),i=ww(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(J),se(J,i)}function ze(){V(J),V(xe),V(ye)}function ve(i){i.memoizedState!==null&&se(Pe,i);var r=J.current,a=ww(r,i.type);r!==a&&(se(xe,i),se(J,a))}function We(i){xe.current===i&&(V(J),V(xe)),Pe.current===i&&(V(Pe),Ju._currentValue=O)}var Oe,j;function ge(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 Me=!1;function Le(i,r){if(!i||Me)return"";Me=!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(_e){var fe=_e}Reflect.construct(i,[],Ee)}else{try{Ee.call()}catch(_e){fe=_e}i.call(Ee.prototype)}}else{try{throw Error()}catch(_e){fe=_e}(Ee=i())&&typeof Ee.catch=="function"&&Ee.catch(function(){})}}catch(_e){if(_e&&fe&&typeof _e.stack=="string")return[_e.stack,fe.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 g=c.DetermineComponentFrameRoot(),y=g[0],D=g[1];if(y&&D){var U=y.split(`
|
|
5
|
-
`),ue=D.split(`
|
|
6
|
-
`);for(h=c=0;c<U.length&&!U[c].includes("DetermineComponentFrameRoot");)c++;for(;h<ue.length&&!ue[h].includes("DetermineComponentFrameRoot");)h++;if(c===U.length||h===ue.length)for(c=U.length-1,h=ue.length-1;1<=c&&0<=h&&U[c]!==ue[h];)h--;for(;1<=c&&0<=h;c--,h--)if(U[c]!==ue[h]){if(c!==1||h!==1)do if(c--,h--,0>h||U[c]!==ue[h]){var Se=`
|
|
7
|
-
`+U[c].replace(" at new "," at ");return i.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",i.displayName)),Se}while(1<=c&&0<=h);break}}}finally{Me=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?ge(a):""}function F(i,r){switch(i.tag){case 26:case 27:case 5:return ge(i.type);case 16:return ge("Lazy");case 13:return i.child!==r&&r!==null?ge("Suspense Fallback"):ge("Suspense");case 19:return ge("SuspenseList");case 0:case 15:return Le(i.type,!1);case 11:return Le(i.type.render,!1);case 1:return Le(i.type,!0);case 31:return ge("Activity");default:return""}}function pe(i){try{var r="",a=null;do r+=F(i,a),a=i,i=i.return;while(i);return r}catch(c){return`
|
|
8
|
-
Error generating stack: `+c.message+`
|
|
9
|
-
`+c.stack}}var Ce=Object.prototype.hasOwnProperty,Re=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,be=e.unstable_shouldYield,Ue=e.unstable_requestPaint,$e=e.unstable_now,Be=e.unstable_getCurrentPriorityLevel,ot=e.unstable_ImmediatePriority,ct=e.unstable_UserBlockingPriority,ht=e.unstable_NormalPriority,jt=e.unstable_LowPriority,Qt=e.unstable_IdlePriority,rt=e.log,Yn=e.unstable_setDisableYieldValue,_n=null,pt=null;function Et(i){if(typeof rt=="function"&&Yn(i),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(_n,i)}catch{}}var Nt=Math.clz32?Math.clz32:nn,Di=Math.log,Gn=Math.LN2;function nn(i){return i>>>=0,i===0?32:31-(Di(i)/Gn|0)|0}var fn=256,te=262144,Ke=4194304;function et(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 bt(i,r,a){var c=i.pendingLanes;if(c===0)return 0;var h=0,g=i.suspendedLanes,y=i.pingedLanes;i=i.warmLanes;var D=c&134217727;return D!==0?(c=D&~g,c!==0?h=et(c):(y&=D,y!==0?h=et(y):a||(a=D&~i,a!==0&&(h=et(a))))):(D=c&~g,D!==0?h=et(D):y!==0?h=et(y):a||(a=c&~i,a!==0&&(h=et(a)))),h===0?0:r!==0&&r!==h&&(r&g)===0&&(g=h&-h,a=r&-r,g>=a||g===32&&(a&4194048)!==0)?r:h}function Pt(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function bn(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 Ft(){var i=Ke;return Ke<<=1,(Ke&62914560)===0&&(Ke=4194304),i}function pn(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function Jt(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Dt(i,r,a,c,h,g){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,U=i.expirationTimes,ue=i.hiddenUpdates;for(a=y&~a;0<a;){var Se=31-Nt(a),Ee=1<<Se;D[Se]=0,U[Se]=-1;var fe=ue[Se];if(fe!==null)for(ue[Se]=null,Se=0;Se<fe.length;Se++){var _e=fe[Se];_e!==null&&(_e.lane&=-536870913)}a&=~Ee}c!==0&&yn(i,c,0),g!==0&&h===0&&i.tag!==0&&(i.suspendedLanes|=g&~(y&~r))}function yn(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var c=31-Nt(r);i.entangledLanes|=r,i.entanglements[c]=i.entanglements[c]|1073741824|a&261930}function Sn(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var c=31-Nt(a),h=1<<c;h&r|i[c]&r&&(i[c]|=r),a&=~h}}function Dn(i,r){var a=r&-r;return a=(a&42)!==0?1:rn(a),(a&(i.suspendedLanes|r))!==0?0:a}function rn(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 ft(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function wt(){var i=T.p;return i!==0?i:(i=window.event,i===void 0?32:Kw(i.type))}function wn(i,r){var a=T.p;try{return T.p=i,r()}finally{T.p=a}}var oe=Math.random().toString(36).slice(2),ke="__reactFiber$"+oe,Xe="__reactProps$"+oe,qe="__reactContainer$"+oe,nt="__reactEvents$"+oe,sn="__reactListeners$"+oe,On="__reactHandles$"+oe,dr="__reactResources$"+oe,Xt="__reactMarker$"+oe;function Xi(i){delete i[ke],delete i[Xe],delete i[nt],delete i[sn],delete i[On]}function Mn(i){var r=i[ke];if(r)return r;for(var a=i.parentNode;a;){if(r=a[qe]||a[ke]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=Nw(i);i!==null;){if(a=i[ke])return a;i=Nw(i)}return r}i=a,a=i.parentNode}return null}function Bn(i){if(i=i[ke]||i[qe]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function hr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function Ci(i){var r=i[dr];return r||(r=i[dr]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function an(i){i[Xt]=!0}var Zi=new Set,ms={};function fr(i,r){Mi(i,r),Mi(i+"Capture",r)}function Mi(i,r){for(ms[i]=r,i=0;i<r.length;i++)Zi.add(r[i])}var Fl=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]*$"),Aa={},Xn={};function Rr(i){return Ce.call(Xn,i)?!0:Ce.call(Aa,i)?!1:Fl.test(i)?Xn[i]=!0:(Aa[i]=!0,!1)}function Bs(i,r,a){if(Rr(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 pr(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function ri(i,r,a,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 ki(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Qi(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ho(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,g=c.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,g.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 La(i){if(!i._valueTracker){var r=Qi(i)?"checked":"value";i._valueTracker=Ho(i,r,""+i[r])}}function zi(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return i&&(c=Qi(i)?i.checked?"true":"false":i.value),i=c,i!==a?(r.setValue(i),!0):!1}function ja(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 Is=/[\n"\\]/g;function mi(i){return i.replace(Is,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ps(i,r,a,c,h,g,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=""+ki(r)):i.value!==""+ki(r)&&(i.value=""+ki(r)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),r!=null?Nr(i,y,ki(r)):a!=null?Nr(i,y,ki(a)):c!=null&&i.removeAttribute("value"),h==null&&g!=null&&(i.defaultChecked=!!g),h!=null&&(i.checked=h&&typeof h!="function"&&typeof h!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?i.name=""+ki(D):i.removeAttribute("name")}function Wl(i,r,a,c,h,g,y,D){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(i.type=g),r!=null||a!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){La(i);return}a=a!=null?""+ki(a):"",r=r!=null?""+ki(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),La(i)}function Nr(i,r,a){r==="number"&&ja(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Dr(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=""+ki(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 Oa(i,r,a){if(r!=null&&(r=""+ki(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+ki(a):""}function Uo(i,r,a,c){if(r==null){if(c!=null){if(a!=null)throw Error(s(92));if(X(c)){if(1<c.length)throw Error(s(93));c=c[0]}a=c}a==null&&(a=""),r=a}a=ki(r),i.defaultValue=a,c=i.textContent,c===a&&c!==""&&c!==null&&(i.value=c),La(i)}function Jr(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var lu=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 $o(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||lu.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function Kl(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&&$o(i,h,c)}else for(var g in r)r.hasOwnProperty(g)&&$o(i,g,r[g])}function Ai(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 ql=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"]]),zs=/^[\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 Hs(i){return zs.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Li(){}var on=null;function Mr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var es=null,Ar=null;function Us(i){var r=Bn(i);if(r&&(i=r.stateNode)){var a=i[Xe]||null;e:switch(i=r.stateNode,r.type){case"input":if(Ps(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="'+mi(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var c=a[r];if(c!==i&&c.form===i.form){var h=c[Xe]||null;if(!h)throw Error(s(90));Ps(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&&zi(c)}break e;case"textarea":Oa(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&Dr(i,!!a.multiple,r,!1)}}}var si=!1;function Ba(i,r,a){if(si)return i(r,a);si=!0;try{var c=i(r);return c}finally{if(si=!1,(es!==null||Ar!==null)&&(Xh(),es&&(r=es,i=Ar,Ar=es=null,Us(r),i)))for(r=0;r<i.length;r++)Us(i[r])}}function $s(i,r){var a=i.stateNode;if(a===null)return null;var c=a[Xe]||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 Ti=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gs=!1;if(Ti)try{var Fs={};Object.defineProperty(Fs,"passive",{get:function(){gs=!0}}),window.addEventListener("test",Fs,Fs),window.removeEventListener("test",Fs,Fs)}catch{gs=!1}var Ji=null,Ws=null,ts=null;function Ia(){if(ts)return ts;var i,r=Ws,a=r.length,c,h="value"in Ji?Ji.value:Ji.textContent,g=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[g-c];c++);return ts=h.slice(i,1<c?1-c:void 0)}function Lr(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 ai(){return!0}function Ks(){return!1}function xn(i){function r(a,c,h,g,y){this._reactName=a,this._targetInst=h,this.type=c,this.nativeEvent=g,this.target=y,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(a=i[D],this[D]=a?a(g):g[D]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ai:Ks,this.isPropagationStopped=Ks,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=ai)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ai)},persist:function(){},isPersistent:ai}),r}var Hi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mt=xn(Hi),er=_({},Hi,{view:0,detail:0}),Fo=xn(er),mr,qs,vs,Pa=_({},er,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gr,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!==vs&&(vs&&i.type==="mousemove"?(mr=i.screenX-vs.screenX,qs=i.screenY-vs.screenY):qs=mr=0,vs=i),mr)},movementY:function(i){return"movementY"in i?i.movementY:qs}}),za=xn(Pa),jr=_({},Pa,{dataTransfer:0}),cu=xn(jr),Wo=_({},er,{relatedTarget:0}),Ui=xn(Wo),Vl=_({},Hi,{animationName:0,elapsedTime:0,pseudoElement:0}),Ko=xn(Vl),Yl=_({},Hi,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Vs=xn(Yl),Gl=_({},Hi,{data:0}),ji=xn(Gl),qo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oi={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"},Vo={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Xl(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Vo[i])?!!r[i]:!1}function gr(){return Xl}var Zl=_({},er,{key:function(i){if(i.key){var r=qo[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Lr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?oi[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gr,charCode:function(i){return i.type==="keypress"?Lr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Lr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Yo=xn(Zl),Ha=_({},Pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ns=xn(Ha),is=_({},er,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gr}),Go=xn(is),uu=_({},Hi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ys=xn(uu),Ua=_({},Pa,{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}),Xo=xn(Ua),vr=_({},Hi,{newState:0,oldState:0}),$a=xn(vr),Zo=[9,13,27,32],rs=Ti&&"CompositionEvent"in window,Gs=null;Ti&&"documentMode"in document&&(Gs=document.documentMode);var C=Ti&&"TextEvent"in window&&!Gs,E=Ti&&(!rs||Gs&&8<Gs&&11>=Gs),B=" ",Q=!1;function ae(i,r){switch(i){case"keyup":return Zo.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function le(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Te=!1;function Ie(i,r){switch(i){case"compositionend":return le(r);case"keypress":return r.which!==32?null:(Q=!0,B);case"textInput":return i=r.data,i===B&&Q?null:i;default:return null}}function Ve(i,r){if(Te)return i==="compositionend"||!rs&&ae(i,r)?(i=Ia(),ts=Ws=Ji=null,Te=!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 E&&r.locale!=="ko"?null:r.data;default:return null}}var Ge={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 _t(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Ge[i.type]:r==="textarea"}function Cn(i,r,a,c){es?Ar?Ar.push(c):Ar=[c]:es=c,r=rf(r,"onChange"),0<r.length&&(a=new mt("onChange","change",null,a,c),i.push({event:a,listeners:r}))}var Rt=null,kn=null;function du(i){mw(i,0)}function Fa(i){var r=hr(i);if(zi(r))return i}function Qo(i,r){if(i==="change")return r}var Xs=!1;if(Ti){var Jo;if(Ti){var gi="oninput"in document;if(!gi){var el=document.createElement("div");el.setAttribute("oninput","return;"),gi=typeof el.oninput=="function"}Jo=gi}else Jo=!1;Xs=Jo&&(!document.documentMode||9<document.documentMode)}function tl(){Rt&&(Rt.detachEvent("onpropertychange",hu),kn=Rt=null)}function hu(i){if(i.propertyName==="value"&&Fa(kn)){var r=[];Cn(r,kn,i,Mr(i)),Ba(du,r)}}function vh(i,r,a){i==="focusin"?(tl(),Rt=r,kn=a,Rt.attachEvent("onpropertychange",hu)):i==="focusout"&&tl()}function nl(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Fa(kn)}function Wa(i,r){if(i==="click")return Fa(r)}function _h(i,r){if(i==="input"||i==="change")return Fa(r)}function Ka(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Vt=typeof Object.is=="function"?Object.is:Ka;function il(i,r){if(Vt(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(!Ce.call(r,h)||!Vt(i[h],r[h]))return!1}return!0}function fu(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function pu(i,r){var a=fu(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=fu(a)}}function mu(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?mu(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function bh(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=ja(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=ja(i.document)}return r}function Ql(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 Or=Ti&&"documentMode"in document&&11>=document.documentMode,_s=null,gu=null,Br=null,qa=!1;function vu(i,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;qa||_s==null||_s!==ja(c)||(c=_s,"selectionStart"in c&&Ql(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}),Br&&il(Br,c)||(Br=c,c=rf(gu,"onSelect"),0<c.length&&(r=new mt("onSelect","select",null,r,a),i.push({event:r,listeners:c}),r.target=_s)))}function Zs(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var Qs={animationend:Zs("Animation","AnimationEnd"),animationiteration:Zs("Animation","AnimationIteration"),animationstart:Zs("Animation","AnimationStart"),transitionrun:Zs("Transition","TransitionRun"),transitionstart:Zs("Transition","TransitionStart"),transitioncancel:Zs("Transition","TransitionCancel"),transitionend:Zs("Transition","TransitionEnd")},Jl={},_u={};Ti&&(_u=document.createElement("div").style,"AnimationEvent"in window||(delete Qs.animationend.animation,delete Qs.animationiteration.animation,delete Qs.animationstart.animation),"TransitionEvent"in window||delete Qs.transitionend.transition);function bs(i){if(Jl[i])return Jl[i];if(!Qs[i])return i;var r=Qs[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in _u)return Jl[i]=r[a];return i}var bu=bs("animationend"),ec=bs("animationiteration"),tc=bs("animationstart"),dm=bs("transitionrun"),nc=bs("transitionstart"),ic=bs("transitioncancel"),yu=bs("transitionend"),yh=new Map,rl="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(" ");rl.push("scrollEnd");function $i(i,r){yh.set(i,r),fr(r,[i])}var Va=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)},li=[],Js=0,rc=0;function sc(){for(var i=Js,r=rc=Js=0;r<i;){var a=li[r];li[r++]=null;var c=li[r];li[r++]=null;var h=li[r];li[r++]=null;var g=li[r];if(li[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}g!==0&&Sh(a,h,g)}}function sl(i,r,a,c){li[Js++]=i,li[Js++]=r,li[Js++]=a,li[Js++]=c,rc|=c,i.lanes|=c,i=i.alternate,i!==null&&(i.lanes|=c)}function Su(i,r,a,c){return sl(i,r,a,c),ss(i)}function ea(i,r){return sl(i,null,null,r),ss(i)}function Sh(i,r,a){i.lanes|=a;var c=i.alternate;c!==null&&(c.lanes|=a);for(var h=!1,g=i.return;g!==null;)g.childLanes|=a,c=g.alternate,c!==null&&(c.childLanes|=a),g.tag===22&&(i=g.stateNode,i===null||i._visibility&1||(h=!0)),i=g,g=g.return;return i.tag===3?(g=i.stateNode,h&&r!==null&&(h=31-Nt(a),i=g.hiddenUpdates,c=i[h],c===null?i[h]=[r]:c.push(r),r.lane=a|536870912),g):null}function ss(i){if(50<qu)throw qu=0,ug=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var ta={};function al(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 Oi(i,r,a,c){return new al(i,r,a,c)}function ac(i){return i=i.prototype,!(!i||!i.isReactComponent)}function as(i,r){var a=i.alternate;return a===null?(a=Oi(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 wu(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 ol(i,r,a,c,h,g){var y=0;if(c=i,typeof i=="function")ac(i)&&(y=1);else if(typeof i=="string")y=sN(i,a,J.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case de:return i=Oi(31,a,r,h),i.elementType=de,i.lanes=g,i;case R:return ys(a.children,h,g,r);case L:y=8,h|=24;break;case A:return i=Oi(12,a,r,h|2),i.elementType=A,i.lanes=g,i;case q:return i=Oi(13,a,r,h),i.elementType=q,i.lanes=g,i;case Y:return i=Oi(19,a,r,h),i.elementType=Y,i.lanes=g,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case z:y=10;break e;case W:y=9;break e;case H:y=11;break e;case I:y=14;break e;case $:y=16,c=null;break e}y=29,a=Error(s(130,i===null?"null":typeof i,"")),c=null}return r=Oi(y,a,r,h),r.elementType=i,r.type=c,r.lanes=g,r}function ys(i,r,a,c){return i=Oi(7,i,c,r),i.lanes=a,i}function xu(i,r,a){return i=Oi(6,i,null,r),i.lanes=a,i}function Cu(i){var r=Oi(18,null,null,0);return r.stateNode=i,r}function Ir(i,r,a){return r=Oi(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var wh=new WeakMap;function tr(i,r){if(typeof i=="object"&&i!==null){var a=wh.get(i);return a!==void 0?a:(r={value:i,source:r,stack:pe(r)},wh.set(i,r),r)}return{value:i,source:r,stack:pe(r)}}var na=[],Ya=0,oc=null,nr=0,ir=[],Fi=0,Ss=null,Pr=1,zr="";function os(i,r){na[Ya++]=nr,na[Ya++]=oc,oc=i,nr=r}function ku(i,r,a){ir[Fi++]=Pr,ir[Fi++]=zr,ir[Fi++]=Ss,Ss=i;var c=Pr;i=zr;var h=32-Nt(c)-1;c&=~(1<<h),a+=1;var g=32-Nt(r)+h;if(30<g){var y=h-h%5;g=(c&(1<<y)-1).toString(32),c>>=y,h-=y,Pr=1<<32-Nt(r)+h|a<<h|c,zr=g+i}else Pr=1<<g|a<<h|c,zr=i}function _r(i){i.return!==null&&(os(i,1),ku(i,1,0))}function Tu(i){for(;i===oc;)oc=na[--Ya],na[Ya]=null,nr=na[--Ya],na[Ya]=null;for(;i===Ss;)Ss=ir[--Fi],ir[Fi]=null,zr=ir[--Fi],ir[Fi]=null,Pr=ir[--Fi],ir[Fi]=null}function xh(i,r){ir[Fi++]=Pr,ir[Fi++]=zr,ir[Fi++]=Ss,Pr=r.id,zr=r.overflow,Ss=i}var In=null,Wt=null,Mt=!1,ws=null,Wi=!1,k=Error(s(519));function P(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ot(tr(r,i)),k}function Ae(i){var r=i.stateNode,a=i.type,c=i.memoizedProps;switch(r[ke]=i,r[Xe]=c,a){case"dialog":Lt("cancel",r),Lt("close",r);break;case"iframe":case"object":case"embed":Lt("load",r);break;case"video":case"audio":for(a=0;a<Yu.length;a++)Lt(Yu[a],r);break;case"source":Lt("error",r);break;case"img":case"image":case"link":Lt("error",r),Lt("load",r);break;case"details":Lt("toggle",r);break;case"input":Lt("invalid",r),Wl(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Lt("invalid",r);break;case"textarea":Lt("invalid",r),Uo(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||bw(r.textContent,a)?(c.popover!=null&&(Lt("beforetoggle",r),Lt("toggle",r)),c.onScroll!=null&&Lt("scroll",r),c.onScrollEnd!=null&&Lt("scrollend",r),c.onClick!=null&&(r.onclick=Li),r=!0):r=!1,r||P(i,!0)}function Je(i){for(In=i.return;In;)switch(In.tag){case 5:case 31:case 13:Wi=!1;return;case 27:case 3:Wi=!0;return;default:In=In.return}}function Ze(i){if(i!==In)return!1;if(!Mt)return Je(i),Mt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||kg(i.type,i.memoizedProps)),a=!a),a&&Wt&&P(i),Je(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Wt=Rw(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Wt=Rw(i)}else r===27?(r=Wt,oo(i.type)?(i=Dg,Dg=null,Wt=i):Wt=r):Wt=In?$r(i.stateNode.nextSibling):null;return!0}function lt(){Wt=In=null,Mt=!1}function Ht(){var i=ws;return i!==null&&(or===null?or=i:or.push.apply(or,i),ws=null),i}function Ot(i){ws===null?ws=[i]:ws.push(i)}var st=N(null),dt=null,Ut=null;function $t(i,r,a){se(st,r._currentValue),r._currentValue=a}function $n(i){i._currentValue=st.current,V(st)}function Hr(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 Fn(i,r,a,c){var h=i.child;for(h!==null&&(h.return=i);h!==null;){var g=h.dependencies;if(g!==null){var y=h.child;g=g.firstContext;e:for(;g!==null;){var D=g;g=h;for(var U=0;U<r.length;U++)if(D.context===r[U]){g.lanes|=a,D=g.alternate,D!==null&&(D.lanes|=a),Hr(g.return,a,i),c||(y=null);break e}g=D.next}}else if(h.tag===18){if(y=h.return,y===null)throw Error(s(341));y.lanes|=a,g=y.alternate,g!==null&&(g.lanes|=a),Hr(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 ia(i,r,a,c){i=null;for(var h=r,g=!1;h!==null;){if(!g){if((h.flags&524288)!==0)g=!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;Vt(h.pendingProps.value,y.value)||(i!==null?i.push(D):i=[D])}}else if(h===Pe.current){if(y=h.alternate,y===null)throw Error(s(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(i!==null?i.push(Ju):i=[Ju])}h=h.return}i!==null&&Fn(r,i,a,c),r.flags|=262144}function lc(i){for(i=i.firstContext;i!==null;){if(!Vt(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function mn(i){dt=i,Ut=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Zn(i){return rS(dt,i)}function ll(i,r){return dt===null&&mn(i),rS(i,r)}function rS(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Ut===null){if(i===null)throw Error(s(308));Ut=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Ut=Ut.next=r;return a}var tR=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()})}},nR=e.unstable_scheduleCallback,iR=e.unstable_NormalPriority,Qn={$$typeof:z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function hm(){return{controller:new tR,data:new Map,refCount:0}}function Eu(i){i.refCount--,i.refCount===0&&nR(iR,function(){i.controller.abort()})}var Ru=null,fm=0,cc=0,uc=null;function rR(i,r){if(Ru===null){var a=Ru=[];fm=0,cc=gg(),uc={status:"pending",value:void 0,then:function(c){a.push(c)}}}return fm++,r.then(sS,sS),r}function sS(){if(--fm===0&&Ru!==null){uc!==null&&(uc.status="fulfilled");var i=Ru;Ru=null,cc=0,uc=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function sR(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 aS=M.S;M.S=function(i,r){F0=$e(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&rR(i,r),aS!==null&&aS(i,r)};var cl=N(null);function pm(){var i=cl.current;return i!==null?i:hn.pooledCache}function Ch(i,r){r===null?se(cl,cl.current):se(cl,r.pool)}function oS(){var i=pm();return i===null?null:{parent:Qn._currentValue,pool:i}}var dc=Error(s(460)),mm=Error(s(474)),kh=Error(s(542)),Th={then:function(){}};function lS(i){return i=i.status,i==="fulfilled"||i==="rejected"}function cS(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(Li,Li),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,dS(i),i;default:if(typeof r.status=="string")r.then(Li,Li);else{if(i=hn,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,dS(i),i}throw dl=r,dc}}function ul(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(dl=a,dc):a}}var dl=null;function uS(){if(dl===null)throw Error(s(459));var i=dl;return dl=null,i}function dS(i){if(i===dc||i===kh)throw Error(s(483))}var hc=null,Nu=0;function Eh(i){var r=Nu;return Nu+=1,hc===null&&(hc=[]),cS(hc,i,r)}function Du(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Rh(i,r){throw r.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function hS(i){function r(ie,G){if(i){var ce=ie.deletions;ce===null?(ie.deletions=[G],ie.flags|=16):ce.push(G)}}function a(ie,G){if(!i)return null;for(;G!==null;)r(ie,G),G=G.sibling;return null}function c(ie){for(var G=new Map;ie!==null;)ie.key!==null?G.set(ie.key,ie):G.set(ie.index,ie),ie=ie.sibling;return G}function h(ie,G){return ie=as(ie,G),ie.index=0,ie.sibling=null,ie}function g(ie,G,ce){return ie.index=ce,i?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<G?(ie.flags|=67108866,G):ce):(ie.flags|=67108866,G)):(ie.flags|=1048576,G)}function y(ie){return i&&ie.alternate===null&&(ie.flags|=67108866),ie}function D(ie,G,ce,we){return G===null||G.tag!==6?(G=xu(ce,ie.mode,we),G.return=ie,G):(G=h(G,ce),G.return=ie,G)}function U(ie,G,ce,we){var at=ce.type;return at===R?Se(ie,G,ce.props.children,we,ce.key):G!==null&&(G.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===$&&ul(at)===G.type)?(G=h(G,ce.props),Du(G,ce),G.return=ie,G):(G=ol(ce.type,ce.key,ce.props,null,ie.mode,we),Du(G,ce),G.return=ie,G)}function ue(ie,G,ce,we){return G===null||G.tag!==4||G.stateNode.containerInfo!==ce.containerInfo||G.stateNode.implementation!==ce.implementation?(G=Ir(ce,ie.mode,we),G.return=ie,G):(G=h(G,ce.children||[]),G.return=ie,G)}function Se(ie,G,ce,we,at){return G===null||G.tag!==7?(G=ys(ce,ie.mode,we,at),G.return=ie,G):(G=h(G,ce),G.return=ie,G)}function Ee(ie,G,ce){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=xu(""+G,ie.mode,ce),G.return=ie,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return ce=ol(G.type,G.key,G.props,null,ie.mode,ce),Du(ce,G),ce.return=ie,ce;case x:return G=Ir(G,ie.mode,ce),G.return=ie,G;case $:return G=ul(G),Ee(ie,G,ce)}if(X(G)||ne(G))return G=ys(G,ie.mode,ce,null),G.return=ie,G;if(typeof G.then=="function")return Ee(ie,Eh(G),ce);if(G.$$typeof===z)return Ee(ie,ll(ie,G),ce);Rh(ie,G)}return null}function fe(ie,G,ce,we){var at=G!==null?G.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return at!==null?null:D(ie,G,""+ce,we);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return ce.key===at?U(ie,G,ce,we):null;case x:return ce.key===at?ue(ie,G,ce,we):null;case $:return ce=ul(ce),fe(ie,G,ce,we)}if(X(ce)||ne(ce))return at!==null?null:Se(ie,G,ce,we,null);if(typeof ce.then=="function")return fe(ie,G,Eh(ce),we);if(ce.$$typeof===z)return fe(ie,G,ll(ie,ce),we);Rh(ie,ce)}return null}function _e(ie,G,ce,we,at){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return ie=ie.get(ce)||null,D(G,ie,""+we,at);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case w:return ie=ie.get(we.key===null?ce:we.key)||null,U(G,ie,we,at);case x:return ie=ie.get(we.key===null?ce:we.key)||null,ue(G,ie,we,at);case $:return we=ul(we),_e(ie,G,ce,we,at)}if(X(we)||ne(we))return ie=ie.get(ce)||null,Se(G,ie,we,at,null);if(typeof we.then=="function")return _e(ie,G,ce,Eh(we),at);if(we.$$typeof===z)return _e(ie,G,ce,ll(G,we),at);Rh(G,we)}return null}function Qe(ie,G,ce,we){for(var at=null,Kt=null,tt=G,Ct=G=0,It=null;tt!==null&&Ct<ce.length;Ct++){tt.index>Ct?(It=tt,tt=null):It=tt.sibling;var qt=fe(ie,tt,ce[Ct],we);if(qt===null){tt===null&&(tt=It);break}i&&tt&&qt.alternate===null&&r(ie,tt),G=g(qt,G,Ct),Kt===null?at=qt:Kt.sibling=qt,Kt=qt,tt=It}if(Ct===ce.length)return a(ie,tt),Mt&&os(ie,Ct),at;if(tt===null){for(;Ct<ce.length;Ct++)tt=Ee(ie,ce[Ct],we),tt!==null&&(G=g(tt,G,Ct),Kt===null?at=tt:Kt.sibling=tt,Kt=tt);return Mt&&os(ie,Ct),at}for(tt=c(tt);Ct<ce.length;Ct++)It=_e(tt,ie,Ct,ce[Ct],we),It!==null&&(i&&It.alternate!==null&&tt.delete(It.key===null?Ct:It.key),G=g(It,G,Ct),Kt===null?at=It:Kt.sibling=It,Kt=It);return i&&tt.forEach(function(fo){return r(ie,fo)}),Mt&&os(ie,Ct),at}function ut(ie,G,ce,we){if(ce==null)throw Error(s(151));for(var at=null,Kt=null,tt=G,Ct=G=0,It=null,qt=ce.next();tt!==null&&!qt.done;Ct++,qt=ce.next()){tt.index>Ct?(It=tt,tt=null):It=tt.sibling;var fo=fe(ie,tt,qt.value,we);if(fo===null){tt===null&&(tt=It);break}i&&tt&&fo.alternate===null&&r(ie,tt),G=g(fo,G,Ct),Kt===null?at=fo:Kt.sibling=fo,Kt=fo,tt=It}if(qt.done)return a(ie,tt),Mt&&os(ie,Ct),at;if(tt===null){for(;!qt.done;Ct++,qt=ce.next())qt=Ee(ie,qt.value,we),qt!==null&&(G=g(qt,G,Ct),Kt===null?at=qt:Kt.sibling=qt,Kt=qt);return Mt&&os(ie,Ct),at}for(tt=c(tt);!qt.done;Ct++,qt=ce.next())qt=_e(tt,ie,Ct,qt.value,we),qt!==null&&(i&&qt.alternate!==null&&tt.delete(qt.key===null?Ct:qt.key),G=g(qt,G,Ct),Kt===null?at=qt:Kt.sibling=qt,Kt=qt);return i&&tt.forEach(function(gN){return r(ie,gN)}),Mt&&os(ie,Ct),at}function un(ie,G,ce,we){if(typeof ce=="object"&&ce!==null&&ce.type===R&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:e:{for(var at=ce.key;G!==null;){if(G.key===at){if(at=ce.type,at===R){if(G.tag===7){a(ie,G.sibling),we=h(G,ce.props.children),we.return=ie,ie=we;break e}}else if(G.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===$&&ul(at)===G.type){a(ie,G.sibling),we=h(G,ce.props),Du(we,ce),we.return=ie,ie=we;break e}a(ie,G);break}else r(ie,G);G=G.sibling}ce.type===R?(we=ys(ce.props.children,ie.mode,we,ce.key),we.return=ie,ie=we):(we=ol(ce.type,ce.key,ce.props,null,ie.mode,we),Du(we,ce),we.return=ie,ie=we)}return y(ie);case x:e:{for(at=ce.key;G!==null;){if(G.key===at)if(G.tag===4&&G.stateNode.containerInfo===ce.containerInfo&&G.stateNode.implementation===ce.implementation){a(ie,G.sibling),we=h(G,ce.children||[]),we.return=ie,ie=we;break e}else{a(ie,G);break}else r(ie,G);G=G.sibling}we=Ir(ce,ie.mode,we),we.return=ie,ie=we}return y(ie);case $:return ce=ul(ce),un(ie,G,ce,we)}if(X(ce))return Qe(ie,G,ce,we);if(ne(ce)){if(at=ne(ce),typeof at!="function")throw Error(s(150));return ce=at.call(ce),ut(ie,G,ce,we)}if(typeof ce.then=="function")return un(ie,G,Eh(ce),we);if(ce.$$typeof===z)return un(ie,G,ll(ie,ce),we);Rh(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,G!==null&&G.tag===6?(a(ie,G.sibling),we=h(G,ce),we.return=ie,ie=we):(a(ie,G),we=xu(ce,ie.mode,we),we.return=ie,ie=we),y(ie)):a(ie,G)}return function(ie,G,ce,we){try{Nu=0;var at=un(ie,G,ce,we);return hc=null,at}catch(tt){if(tt===dc||tt===kh)throw tt;var Kt=Oi(29,tt,null,ie.mode);return Kt.lanes=we,Kt.return=ie,Kt}}}var hl=hS(!0),fS=hS(!1),Ga=!1;function gm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vm(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 Xa(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Za(i,r,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Yt&2)!==0){var h=c.pending;return h===null?r.next=r:(r.next=h.next,h.next=r),c.pending=r,r=ss(i),Sh(i,null,a),r}return sl(i,c,r,a),ss(i)}function Mu(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,Sn(i,a)}}function _m(i,r){var a=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var h=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};g===null?h=g=y:g=g.next=y,a=a.next}while(a!==null);g===null?h=g=r:g=g.next=r}else h=g=r;a={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:g,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 bm=!1;function Au(){if(bm){var i=uc;if(i!==null)throw i}}function Lu(i,r,a,c){bm=!1;var h=i.updateQueue;Ga=!1;var g=h.firstBaseUpdate,y=h.lastBaseUpdate,D=h.shared.pending;if(D!==null){h.shared.pending=null;var U=D,ue=U.next;U.next=null,y===null?g=ue:y.next=ue,y=U;var Se=i.alternate;Se!==null&&(Se=Se.updateQueue,D=Se.lastBaseUpdate,D!==y&&(D===null?Se.firstBaseUpdate=ue:D.next=ue,Se.lastBaseUpdate=U))}if(g!==null){var Ee=h.baseState;y=0,Se=ue=U=null,D=g;do{var fe=D.lane&-536870913,_e=fe!==D.lane;if(_e?(Bt&fe)===fe:(c&fe)===fe){fe!==0&&fe===cc&&(bm=!0),Se!==null&&(Se=Se.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Qe=i,ut=D;fe=r;var un=a;switch(ut.tag){case 1:if(Qe=ut.payload,typeof Qe=="function"){Ee=Qe.call(un,Ee,fe);break e}Ee=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=ut.payload,fe=typeof Qe=="function"?Qe.call(un,Ee,fe):Qe,fe==null)break e;Ee=_({},Ee,fe);break e;case 2:Ga=!0}}fe=D.callback,fe!==null&&(i.flags|=64,_e&&(i.flags|=8192),_e=h.callbacks,_e===null?h.callbacks=[fe]:_e.push(fe))}else _e={lane:fe,tag:D.tag,payload:D.payload,callback:D.callback,next:null},Se===null?(ue=Se=_e,U=Ee):Se=Se.next=_e,y|=fe;if(D=D.next,D===null){if(D=h.shared.pending,D===null)break;_e=D,D=_e.next,_e.next=null,h.lastBaseUpdate=_e,h.shared.pending=null}}while(!0);Se===null&&(U=Ee),h.baseState=U,h.firstBaseUpdate=ue,h.lastBaseUpdate=Se,g===null&&(h.shared.lanes=0),no|=y,i.lanes=y,i.memoizedState=Ee}}function pS(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function mS(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)pS(a[i],r)}var fc=N(null),Nh=N(0);function gS(i,r){i=ha,se(Nh,i),se(fc,r),ha=i|r.baseLanes}function ym(){se(Nh,ha),se(fc,fc.current)}function Sm(){ha=Nh.current,V(fc),V(Nh)}var br=N(null),Ur=null;function Qa(i){var r=i.alternate;se(Wn,Wn.current&1),se(br,i),Ur===null&&(r===null||fc.current!==null||r.memoizedState!==null)&&(Ur=i)}function wm(i){se(Wn,Wn.current),se(br,i),Ur===null&&(Ur=i)}function vS(i){i.tag===22?(se(Wn,Wn.current),se(br,i),Ur===null&&(Ur=i)):Ja()}function Ja(){se(Wn,Wn.current),se(br,br.current)}function yr(i){V(br),Ur===i&&(Ur=null),V(Wn)}var Wn=N(0);function Dh(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Rg(a)||Ng(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 ra=0,xt=null,ln=null,Jn=null,Mh=!1,pc=!1,fl=!1,Ah=0,ju=0,mc=null,aR=0;function Pn(){throw Error(s(321))}function xm(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!Vt(i[a],r[a]))return!1;return!0}function Cm(i,r,a,c,h,g){return ra=g,xt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,M.H=i===null||i.memoizedState===null?e0:zm,fl=!1,g=a(c,h),fl=!1,pc&&(g=bS(r,a,c,h)),_S(i),g}function _S(i){M.H=Iu;var r=ln!==null&&ln.next!==null;if(ra=0,Jn=ln=xt=null,Mh=!1,ju=0,mc=null,r)throw Error(s(300));i===null||ei||(i=i.dependencies,i!==null&&lc(i)&&(ei=!0))}function bS(i,r,a,c){xt=i;var h=0;do{if(pc&&(mc=null),ju=0,pc=!1,25<=h)throw Error(s(301));if(h+=1,Jn=ln=null,i.updateQueue!=null){var g=i.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}M.H=t0,g=r(a,c)}while(pc);return g}function oR(){var i=M.H,r=i.useState()[0];return r=typeof r.then=="function"?Ou(r):r,i=i.useState()[0],(ln!==null?ln.memoizedState:null)!==i&&(xt.flags|=1024),r}function km(){var i=Ah!==0;return Ah=0,i}function Tm(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function Em(i){if(Mh){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}Mh=!1}ra=0,Jn=ln=xt=null,pc=!1,ju=Ah=0,mc=null}function Ki(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jn===null?xt.memoizedState=Jn=i:Jn=Jn.next=i,Jn}function Kn(){if(ln===null){var i=xt.alternate;i=i!==null?i.memoizedState:null}else i=ln.next;var r=Jn===null?xt.memoizedState:Jn.next;if(r!==null)Jn=r,ln=i;else{if(i===null)throw xt.alternate===null?Error(s(467)):Error(s(310));ln=i,i={memoizedState:ln.memoizedState,baseState:ln.baseState,baseQueue:ln.baseQueue,queue:ln.queue,next:null},Jn===null?xt.memoizedState=Jn=i:Jn=Jn.next=i}return Jn}function Lh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ou(i){var r=ju;return ju+=1,mc===null&&(mc=[]),i=cS(mc,i,r),r=xt,(Jn===null?r.memoizedState:Jn.next)===null&&(r=r.alternate,M.H=r===null||r.memoizedState===null?e0:zm),i}function jh(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Ou(i);if(i.$$typeof===z)return Zn(i)}throw Error(s(438,String(i)))}function Rm(i){var r=null,a=xt.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var c=xt.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(),xt.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]=me;return r.index++,a}function sa(i,r){return typeof r=="function"?r(i):r}function Oh(i){var r=Kn();return Nm(r,ln,i)}function Nm(i,r,a){var c=i.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=a;var h=i.baseQueue,g=c.pending;if(g!==null){if(h!==null){var y=h.next;h.next=g.next,g.next=y}r.baseQueue=h=g,c.pending=null}if(g=i.baseState,h===null)i.memoizedState=g;else{r=h.next;var D=y=null,U=null,ue=r,Se=!1;do{var Ee=ue.lane&-536870913;if(Ee!==ue.lane?(Bt&Ee)===Ee:(ra&Ee)===Ee){var fe=ue.revertLane;if(fe===0)U!==null&&(U=U.next={lane:0,revertLane:0,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),Ee===cc&&(Se=!0);else if((ra&fe)===fe){ue=ue.next,fe===cc&&(Se=!0);continue}else Ee={lane:0,revertLane:ue.revertLane,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},U===null?(D=U=Ee,y=g):U=U.next=Ee,xt.lanes|=fe,no|=fe;Ee=ue.action,fl&&a(g,Ee),g=ue.hasEagerState?ue.eagerState:a(g,Ee)}else fe={lane:Ee,revertLane:ue.revertLane,gesture:ue.gesture,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},U===null?(D=U=fe,y=g):U=U.next=fe,xt.lanes|=Ee,no|=Ee;ue=ue.next}while(ue!==null&&ue!==r);if(U===null?y=g:U.next=D,!Vt(g,i.memoizedState)&&(ei=!0,Se&&(a=uc,a!==null)))throw a;i.memoizedState=g,i.baseState=y,i.baseQueue=U,c.lastRenderedState=g}return h===null&&(c.lanes=0),[i.memoizedState,c.dispatch]}function Dm(i){var r=Kn(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var c=a.dispatch,h=a.pending,g=r.memoizedState;if(h!==null){a.pending=null;var y=h=h.next;do g=i(g,y.action),y=y.next;while(y!==h);Vt(g,r.memoizedState)||(ei=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,c]}function yS(i,r,a){var c=xt,h=Kn(),g=Mt;if(g){if(a===void 0)throw Error(s(407));a=a()}else a=r();var y=!Vt((ln||h).memoizedState,a);if(y&&(h.memoizedState=a,ei=!0),h=h.queue,Lm(xS.bind(null,c,h,i),[i]),h.getSnapshot!==r||y||Jn!==null&&Jn.memoizedState.tag&1){if(c.flags|=2048,gc(9,{destroy:void 0},wS.bind(null,c,h,a,r),null),hn===null)throw Error(s(349));g||(ra&127)!==0||SS(c,r,a)}return a}function SS(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=xt.updateQueue,r===null?(r=Lh(),xt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function wS(i,r,a,c){r.value=a,r.getSnapshot=c,CS(r)&&kS(i)}function xS(i,r,a){return a(function(){CS(r)&&kS(i)})}function CS(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!Vt(i,a)}catch{return!0}}function kS(i){var r=ea(i,2);r!==null&&lr(r,i,2)}function Mm(i){var r=Ki();if(typeof i=="function"){var a=i;if(i=a(),fl){Et(!0);try{a()}finally{Et(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:i},r}function TS(i,r,a,c){return i.baseState=a,Nm(i,ln,typeof c=="function"?c:sa)}function lR(i,r,a,c,h){if(Ph(i))throw Error(s(485));if(i=r.action,i!==null){var g={payload:h,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){g.listeners.push(y)}};M.T!==null?a(!0):g.isTransition=!1,c(g),a=r.pending,a===null?(g.next=r.pending=g,ES(r,g)):(g.next=a.next,r.pending=a.next=g)}}function ES(i,r){var a=r.action,c=r.payload,h=i.state;if(r.isTransition){var g=M.T,y={};M.T=y;try{var D=a(h,c),U=M.S;U!==null&&U(y,D),RS(i,r,D)}catch(ue){Am(i,r,ue)}finally{g!==null&&y.types!==null&&(g.types=y.types),M.T=g}}else try{g=a(h,c),RS(i,r,g)}catch(ue){Am(i,r,ue)}}function RS(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(c){NS(i,r,c)},function(c){return Am(i,r,c)}):NS(i,r,a)}function NS(i,r,a){r.status="fulfilled",r.value=a,DS(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,ES(i,a)))}function Am(i,r,a){var c=i.pending;if(i.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=a,DS(r),r=r.next;while(r!==c)}i.action=null}function DS(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function MS(i,r){return r}function AS(i,r){if(Mt){var a=hn.formState;if(a!==null){e:{var c=xt;if(Mt){if(Wt){t:{for(var h=Wt,g=Wi;h.nodeType!==8;){if(!g){h=null;break t}if(h=$r(h.nextSibling),h===null){h=null;break t}}g=h.data,h=g==="F!"||g==="F"?h:null}if(h){Wt=$r(h.nextSibling),c=h.data==="F!";break e}}P(c)}c=!1}c&&(r=a[0])}}return a=Ki(),a.memoizedState=a.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:MS,lastRenderedState:r},a.queue=c,a=ZS.bind(null,xt,c),c.dispatch=a,c=Mm(!1),g=Pm.bind(null,xt,!1,c.queue),c=Ki(),h={state:r,dispatch:null,action:i,pending:null},c.queue=h,a=lR.bind(null,xt,h,g,a),h.dispatch=a,c.memoizedState=i,[r,a,!1]}function LS(i){var r=Kn();return jS(r,ln,i)}function jS(i,r,a){if(r=Nm(i,r,MS)[0],i=Oh(sa)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Ou(r)}catch(y){throw y===dc?kh:y}else c=r;r=Kn();var h=r.queue,g=h.dispatch;return a!==r.memoizedState&&(xt.flags|=2048,gc(9,{destroy:void 0},cR.bind(null,h,a),null)),[c,g,i]}function cR(i,r){i.action=r}function OS(i){var r=Kn(),a=ln;if(a!==null)return jS(r,a,i);Kn(),r=r.memoizedState,a=Kn();var c=a.queue.dispatch;return a.memoizedState=i,[r,c,!1]}function gc(i,r,a,c){return i={tag:i,create:a,deps:c,inst:r,next:null},r=xt.updateQueue,r===null&&(r=Lh(),xt.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 BS(){return Kn().memoizedState}function Bh(i,r,a,c){var h=Ki();xt.flags|=i,h.memoizedState=gc(1|r,{destroy:void 0},a,c===void 0?null:c)}function Ih(i,r,a,c){var h=Kn();c=c===void 0?null:c;var g=h.memoizedState.inst;ln!==null&&c!==null&&xm(c,ln.memoizedState.deps)?h.memoizedState=gc(r,g,a,c):(xt.flags|=i,h.memoizedState=gc(1|r,g,a,c))}function IS(i,r){Bh(8390656,8,i,r)}function Lm(i,r){Ih(2048,8,i,r)}function uR(i){xt.flags|=4;var r=xt.updateQueue;if(r===null)r=Lh(),xt.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function PS(i){var r=Kn().memoizedState;return uR({ref:r,nextImpl:i}),function(){if((Yt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function zS(i,r){return Ih(4,2,i,r)}function HS(i,r){return Ih(4,4,i,r)}function US(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 $S(i,r,a){a=a!=null?a.concat([i]):null,Ih(4,4,US.bind(null,r,i),a)}function jm(){}function FS(i,r){var a=Kn();r=r===void 0?null:r;var c=a.memoizedState;return r!==null&&xm(r,c[1])?c[0]:(a.memoizedState=[i,r],i)}function WS(i,r){var a=Kn();r=r===void 0?null:r;var c=a.memoizedState;if(r!==null&&xm(r,c[1]))return c[0];if(c=i(),fl){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[c,r],c}function Om(i,r,a){return a===void 0||(ra&1073741824)!==0&&(Bt&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=K0(),xt.lanes|=i,no|=i,a)}function KS(i,r,a,c){return Vt(a,r)?a:fc.current!==null?(i=Om(i,a,c),Vt(i,r)||(ei=!0),i):(ra&42)===0||(ra&1073741824)!==0&&(Bt&261930)===0?(ei=!0,i.memoizedState=a):(i=K0(),xt.lanes|=i,no|=i,r)}function qS(i,r,a,c,h){var g=T.p;T.p=g!==0&&8>g?g:8;var y=M.T,D={};M.T=D,Pm(i,!1,r,a);try{var U=h(),ue=M.S;if(ue!==null&&ue(D,U),U!==null&&typeof U=="object"&&typeof U.then=="function"){var Se=sR(U,c);Bu(i,r,Se,xr(i))}else Bu(i,r,c,xr(i))}catch(Ee){Bu(i,r,{then:function(){},status:"rejected",reason:Ee},xr())}finally{T.p=g,y!==null&&D.types!==null&&(y.types=D.types),M.T=y}}function dR(){}function Bm(i,r,a,c){if(i.tag!==5)throw Error(s(476));var h=VS(i).queue;qS(i,h,r,O,a===null?dR:function(){return YS(i),a(c)})}function VS(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:O,baseState:O,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:O},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:sa,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function YS(i){var r=VS(i);r.next===null&&(r=i.alternate.memoizedState),Bu(i,r.next.queue,{},xr())}function Im(){return Zn(Ju)}function GS(){return Kn().memoizedState}function XS(){return Kn().memoizedState}function hR(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=xr();i=Xa(a);var c=Za(r,i,a);c!==null&&(lr(c,r,a),Mu(c,r,a)),r={cache:hm()},i.payload=r;return}r=r.return}}function fR(i,r,a){var c=xr();a={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ph(i)?QS(r,a):(a=Su(i,r,a,c),a!==null&&(lr(a,i,c),JS(a,r,c)))}function ZS(i,r,a){var c=xr();Bu(i,r,a,c)}function Bu(i,r,a,c){var h={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ph(i))QS(r,h);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var y=r.lastRenderedState,D=g(y,a);if(h.hasEagerState=!0,h.eagerState=D,Vt(D,y))return sl(i,r,h,0),hn===null&&sc(),!1}catch{}if(a=Su(i,r,h,c),a!==null)return lr(a,i,c),JS(a,r,c),!0}return!1}function Pm(i,r,a,c){if(c={lane:2,revertLane:gg(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Ph(i)){if(r)throw Error(s(479))}else r=Su(i,a,c,2),r!==null&&lr(r,i,2)}function Ph(i){var r=i.alternate;return i===xt||r!==null&&r===xt}function QS(i,r){pc=Mh=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function JS(i,r,a){if((a&4194048)!==0){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,Sn(i,a)}}var Iu={readContext:Zn,use:jh,useCallback:Pn,useContext:Pn,useEffect:Pn,useImperativeHandle:Pn,useLayoutEffect:Pn,useInsertionEffect:Pn,useMemo:Pn,useReducer:Pn,useRef:Pn,useState:Pn,useDebugValue:Pn,useDeferredValue:Pn,useTransition:Pn,useSyncExternalStore:Pn,useId:Pn,useHostTransitionStatus:Pn,useFormState:Pn,useActionState:Pn,useOptimistic:Pn,useMemoCache:Pn,useCacheRefresh:Pn};Iu.useEffectEvent=Pn;var e0={readContext:Zn,use:jh,useCallback:function(i,r){return Ki().memoizedState=[i,r===void 0?null:r],i},useContext:Zn,useEffect:IS,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,Bh(4194308,4,US.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Bh(4194308,4,i,r)},useInsertionEffect:function(i,r){Bh(4,2,i,r)},useMemo:function(i,r){var a=Ki();r=r===void 0?null:r;var c=i();if(fl){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[c,r],c},useReducer:function(i,r,a){var c=Ki();if(a!==void 0){var h=a(r);if(fl){Et(!0);try{a(r)}finally{Et(!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=fR.bind(null,xt,i),[c.memoizedState,i]},useRef:function(i){var r=Ki();return i={current:i},r.memoizedState=i},useState:function(i){i=Mm(i);var r=i.queue,a=ZS.bind(null,xt,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:jm,useDeferredValue:function(i,r){var a=Ki();return Om(a,i,r)},useTransition:function(){var i=Mm(!1);return i=qS.bind(null,xt,i.queue,!0,!1),Ki().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var c=xt,h=Ki();if(Mt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),hn===null)throw Error(s(349));(Bt&127)!==0||SS(c,r,a)}h.memoizedState=a;var g={value:a,getSnapshot:r};return h.queue=g,IS(xS.bind(null,c,g,i),[i]),c.flags|=2048,gc(9,{destroy:void 0},wS.bind(null,c,g,a,r),null),a},useId:function(){var i=Ki(),r=hn.identifierPrefix;if(Mt){var a=zr,c=Pr;a=(c&~(1<<32-Nt(c)-1)).toString(32)+a,r="_"+r+"R_"+a,a=Ah++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=aR++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:Im,useFormState:AS,useActionState:AS,useOptimistic:function(i){var r=Ki();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Pm.bind(null,xt,!0,a),a.dispatch=r,[i,r]},useMemoCache:Rm,useCacheRefresh:function(){return Ki().memoizedState=hR.bind(null,xt)},useEffectEvent:function(i){var r=Ki(),a={impl:i};return r.memoizedState=a,function(){if((Yt&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},zm={readContext:Zn,use:jh,useCallback:FS,useContext:Zn,useEffect:Lm,useImperativeHandle:$S,useInsertionEffect:zS,useLayoutEffect:HS,useMemo:WS,useReducer:Oh,useRef:BS,useState:function(){return Oh(sa)},useDebugValue:jm,useDeferredValue:function(i,r){var a=Kn();return KS(a,ln.memoizedState,i,r)},useTransition:function(){var i=Oh(sa)[0],r=Kn().memoizedState;return[typeof i=="boolean"?i:Ou(i),r]},useSyncExternalStore:yS,useId:GS,useHostTransitionStatus:Im,useFormState:LS,useActionState:LS,useOptimistic:function(i,r){var a=Kn();return TS(a,ln,i,r)},useMemoCache:Rm,useCacheRefresh:XS};zm.useEffectEvent=PS;var t0={readContext:Zn,use:jh,useCallback:FS,useContext:Zn,useEffect:Lm,useImperativeHandle:$S,useInsertionEffect:zS,useLayoutEffect:HS,useMemo:WS,useReducer:Dm,useRef:BS,useState:function(){return Dm(sa)},useDebugValue:jm,useDeferredValue:function(i,r){var a=Kn();return ln===null?Om(a,i,r):KS(a,ln.memoizedState,i,r)},useTransition:function(){var i=Dm(sa)[0],r=Kn().memoizedState;return[typeof i=="boolean"?i:Ou(i),r]},useSyncExternalStore:yS,useId:GS,useHostTransitionStatus:Im,useFormState:OS,useActionState:OS,useOptimistic:function(i,r){var a=Kn();return ln!==null?TS(a,ln,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Rm,useCacheRefresh:XS};t0.useEffectEvent=PS;function Hm(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 Um={enqueueSetState:function(i,r,a){i=i._reactInternals;var c=xr(),h=Xa(c);h.payload=r,a!=null&&(h.callback=a),r=Za(i,h,c),r!==null&&(lr(r,i,c),Mu(r,i,c))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var c=xr(),h=Xa(c);h.tag=1,h.payload=r,a!=null&&(h.callback=a),r=Za(i,h,c),r!==null&&(lr(r,i,c),Mu(r,i,c))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=xr(),c=Xa(a);c.tag=2,r!=null&&(c.callback=r),r=Za(i,c,a),r!==null&&(lr(r,i,a),Mu(r,i,a))}};function n0(i,r,a,c,h,g,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,y):r.prototype&&r.prototype.isPureReactComponent?!il(a,c)||!il(h,g):!0}function i0(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&&Um.enqueueReplaceState(r,r.state,null)}function pl(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 r0(i){Va(i)}function s0(i){console.error(i)}function a0(i){Va(i)}function zh(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function o0(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 $m(i,r,a){return a=Xa(a),a.tag=3,a.payload={element:null},a.callback=function(){zh(i,r)},a}function l0(i){return i=Xa(i),i.tag=3,i}function c0(i,r,a,c){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var g=c.value;i.payload=function(){return h(g)},i.callback=function(){o0(r,a,c)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){o0(r,a,c),typeof h!="function"&&(io===null?io=new Set([this]):io.add(this));var D=c.stack;this.componentDidCatch(c.value,{componentStack:D!==null?D:""})})}function pR(i,r,a,c,h){if(a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=a.alternate,r!==null&&ia(r,a,h,!0),a=br.current,a!==null){switch(a.tag){case 31:case 13:return Ur===null?Zh():a.alternate===null&&zn===0&&(zn=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),fg(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)),fg(i,c,h)),!1}throw Error(s(435,a.tag))}return fg(i,c,h),Zh(),!1}if(Mt)return r=br.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=h,c!==k&&(i=Error(s(422),{cause:c}),Ot(tr(i,a)))):(c!==k&&(r=Error(s(423),{cause:c}),Ot(tr(r,a))),i=i.current.alternate,i.flags|=65536,h&=-h,i.lanes|=h,c=tr(c,a),h=$m(i.stateNode,c,h),_m(i,h),zn!==4&&(zn=2)),!1;var g=Error(s(520),{cause:c});if(g=tr(g,a),Ku===null?Ku=[g]:Ku.push(g),zn!==4&&(zn=2),r===null)return!0;c=tr(c,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=h&-h,a.lanes|=i,i=$m(a.stateNode,c,i),_m(a,i),!1;case 1:if(r=a.type,g=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(io===null||!io.has(g))))return a.flags|=65536,h&=-h,a.lanes|=h,h=l0(h),c0(h,i,a,c),_m(a,h),!1}a=a.return}while(a!==null);return!1}var Fm=Error(s(461)),ei=!1;function Ei(i,r,a,c){r.child=i===null?fS(r,null,a,c):hl(r,i.child,a,c)}function u0(i,r,a,c,h){a=a.render;var g=r.ref;if("ref"in c){var y={};for(var D in c)D!=="ref"&&(y[D]=c[D])}else y=c;return mn(r),c=Cm(i,r,a,y,g,h),D=km(),i!==null&&!ei?(Tm(i,r,h),aa(i,r,h)):(Mt&&D&&_r(r),r.flags|=1,Ei(i,r,c,h),r.child)}function d0(i,r,a,c,h){if(i===null){var g=a.type;return typeof g=="function"&&!ac(g)&&g.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=g,h0(i,r,g,c,h)):(i=ol(a.type,null,c,r,r.mode,h),i.ref=r.ref,i.return=r,r.child=i)}if(g=i.child,!Zm(i,h)){var y=g.memoizedProps;if(a=a.compare,a=a!==null?a:il,a(y,c)&&i.ref===r.ref)return aa(i,r,h)}return r.flags|=1,i=as(g,c),i.ref=r.ref,i.return=r,r.child=i}function h0(i,r,a,c,h){if(i!==null){var g=i.memoizedProps;if(il(g,c)&&i.ref===r.ref)if(ei=!1,r.pendingProps=c=g,Zm(i,h))(i.flags&131072)!==0&&(ei=!0);else return r.lanes=i.lanes,aa(i,r,h)}return Wm(i,r,a,c,h)}function f0(i,r,a,c){var h=c.children,g=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(g=g!==null?g.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&~g}else c=0,r.child=null;return p0(i,r,g,a,c)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Ch(r,g!==null?g.cachePool:null),g!==null?gS(r,g):ym(),vS(r);else return c=r.lanes=536870912,p0(i,r,g!==null?g.baseLanes|a:a,a,c)}else g!==null?(Ch(r,g.cachePool),gS(r,g),Ja(),r.memoizedState=null):(i!==null&&Ch(r,null),ym(),Ja());return Ei(i,r,h,a),r.child}function Pu(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function p0(i,r,a,c,h){var g=pm();return g=g===null?null:{parent:Qn._currentValue,pool:g},r.memoizedState={baseLanes:a,cachePool:g},i!==null&&Ch(r,null),ym(),vS(r),i!==null&&ia(i,r,c,!0),r.childLanes=h,null}function Hh(i,r){return r=$h({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function m0(i,r,a){return hl(r,i.child,null,a),i=Hh(r,r.pendingProps),i.flags|=2,yr(r),r.memoizedState=null,i}function mR(i,r,a){var c=r.pendingProps,h=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(Mt){if(c.mode==="hidden")return i=Hh(r,c),r.lanes=536870912,Pu(null,i);if(wm(r),(i=Wt)?(i=Ew(i,Wi),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ss!==null?{id:Pr,overflow:zr}:null,retryLane:536870912,hydrationErrors:null},a=Cu(i),a.return=r,r.child=a,In=r,Wt=null)):i=null,i===null)throw P(r);return r.lanes=536870912,null}return Hh(r,c)}var g=i.memoizedState;if(g!==null){var y=g.dehydrated;if(wm(r),h)if(r.flags&256)r.flags&=-257,r=m0(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(ei||ia(i,r,a,!1),h=(a&i.childLanes)!==0,ei||h){if(c=hn,c!==null&&(y=Dn(c,a),y!==0&&y!==g.retryLane))throw g.retryLane=y,ea(i,y),lr(c,i,y),Fm;Zh(),r=m0(i,r,a)}else i=g.treeContext,Wt=$r(y.nextSibling),In=r,Mt=!0,ws=null,Wi=!1,i!==null&&xh(r,i),r=Hh(r,c),r.flags|=4096;return r}return i=as(i.child,{mode:c.mode,children:c.children}),i.ref=r.ref,r.child=i,i.return=r,i}function Uh(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 Wm(i,r,a,c,h){return mn(r),a=Cm(i,r,a,c,void 0,h),c=km(),i!==null&&!ei?(Tm(i,r,h),aa(i,r,h)):(Mt&&c&&_r(r),r.flags|=1,Ei(i,r,a,h),r.child)}function g0(i,r,a,c,h,g){return mn(r),r.updateQueue=null,a=bS(r,c,a,h),_S(i),c=km(),i!==null&&!ei?(Tm(i,r,g),aa(i,r,g)):(Mt&&c&&_r(r),r.flags|=1,Ei(i,r,a,g),r.child)}function v0(i,r,a,c,h){if(mn(r),r.stateNode===null){var g=ta,y=a.contextType;typeof y=="object"&&y!==null&&(g=Zn(y)),g=new a(c,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Um,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=c,g.state=r.memoizedState,g.refs={},gm(r),y=a.contextType,g.context=typeof y=="object"&&y!==null?Zn(y):ta,g.state=r.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Hm(r,a,y,c),g.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(y=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),y!==g.state&&Um.enqueueReplaceState(g,g.state,null),Lu(r,c,g,h),Au(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(i===null){g=r.stateNode;var D=r.memoizedProps,U=pl(a,D);g.props=U;var ue=g.context,Se=a.contextType;y=ta,typeof Se=="object"&&Se!==null&&(y=Zn(Se));var Ee=a.getDerivedStateFromProps;Se=typeof Ee=="function"||typeof g.getSnapshotBeforeUpdate=="function",D=r.pendingProps!==D,Se||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(D||ue!==y)&&i0(r,g,c,y),Ga=!1;var fe=r.memoizedState;g.state=fe,Lu(r,c,g,h),Au(),ue=r.memoizedState,D||fe!==ue||Ga?(typeof Ee=="function"&&(Hm(r,a,Ee,c),ue=r.memoizedState),(U=Ga||n0(r,a,U,c,fe,ue,y))?(Se||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=ue),g.props=c,g.state=ue,g.context=y,c=U):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{g=r.stateNode,vm(i,r),y=r.memoizedProps,Se=pl(a,y),g.props=Se,Ee=r.pendingProps,fe=g.context,ue=a.contextType,U=ta,typeof ue=="object"&&ue!==null&&(U=Zn(ue)),D=a.getDerivedStateFromProps,(ue=typeof D=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(y!==Ee||fe!==U)&&i0(r,g,c,U),Ga=!1,fe=r.memoizedState,g.state=fe,Lu(r,c,g,h),Au();var _e=r.memoizedState;y!==Ee||fe!==_e||Ga||i!==null&&i.dependencies!==null&&lc(i.dependencies)?(typeof D=="function"&&(Hm(r,a,D,c),_e=r.memoizedState),(Se=Ga||n0(r,a,Se,c,fe,_e,U)||i!==null&&i.dependencies!==null&&lc(i.dependencies))?(ue||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,_e,U),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,_e,U)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=_e),g.props=c,g.state=_e,g.context=U,c=Se):(typeof g.componentDidUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(r.flags|=1024),c=!1)}return g=c,Uh(i,r),c=(r.flags&128)!==0,g||c?(g=r.stateNode,a=c&&typeof a.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,i!==null&&c?(r.child=hl(r,i.child,null,h),r.child=hl(r,null,a,h)):Ei(i,r,a,h),r.memoizedState=g.state,i=r.child):i=aa(i,r,h),i}function _0(i,r,a,c){return lt(),r.flags|=256,Ei(i,r,a,c),r.child}var Km={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qm(i){return{baseLanes:i,cachePool:oS()}}function Vm(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=wr),i}function b0(i,r,a){var c=r.pendingProps,h=!1,g=(r.flags&128)!==0,y;if((y=g)||(y=i!==null&&i.memoizedState===null?!1:(Wn.current&2)!==0),y&&(h=!0,r.flags&=-129),y=(r.flags&32)!==0,r.flags&=-33,i===null){if(Mt){if(h?Qa(r):Ja(),(i=Wt)?(i=Ew(i,Wi),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Ss!==null?{id:Pr,overflow:zr}:null,retryLane:536870912,hydrationErrors:null},a=Cu(i),a.return=r,r.child=a,In=r,Wt=null)):i=null,i===null)throw P(r);return Ng(i)?r.lanes=32:r.lanes=536870912,null}var D=c.children;return c=c.fallback,h?(Ja(),h=r.mode,D=$h({mode:"hidden",children:D},h),c=ys(c,h,a,null),D.return=r,c.return=r,D.sibling=c,r.child=D,c=r.child,c.memoizedState=qm(a),c.childLanes=Vm(i,y,a),r.memoizedState=Km,Pu(null,c)):(Qa(r),Ym(r,D))}var U=i.memoizedState;if(U!==null&&(D=U.dehydrated,D!==null)){if(g)r.flags&256?(Qa(r),r.flags&=-257,r=Gm(i,r,a)):r.memoizedState!==null?(Ja(),r.child=i.child,r.flags|=128,r=null):(Ja(),D=c.fallback,h=r.mode,c=$h({mode:"visible",children:c.children},h),D=ys(D,h,a,null),D.flags|=2,c.return=r,D.return=r,c.sibling=D,r.child=c,hl(r,i.child,null,a),c=r.child,c.memoizedState=qm(a),c.childLanes=Vm(i,y,a),r.memoizedState=Km,r=Pu(null,c));else if(Qa(r),Ng(D)){if(y=D.nextSibling&&D.nextSibling.dataset,y)var ue=y.dgst;y=ue,c=Error(s(419)),c.stack="",c.digest=y,Ot({value:c,source:null,stack:null}),r=Gm(i,r,a)}else if(ei||ia(i,r,a,!1),y=(a&i.childLanes)!==0,ei||y){if(y=hn,y!==null&&(c=Dn(y,a),c!==0&&c!==U.retryLane))throw U.retryLane=c,ea(i,c),lr(y,i,c),Fm;Rg(D)||Zh(),r=Gm(i,r,a)}else Rg(D)?(r.flags|=192,r.child=i.child,r=null):(i=U.treeContext,Wt=$r(D.nextSibling),In=r,Mt=!0,ws=null,Wi=!1,i!==null&&xh(r,i),r=Ym(r,c.children),r.flags|=4096);return r}return h?(Ja(),D=c.fallback,h=r.mode,U=i.child,ue=U.sibling,c=as(U,{mode:"hidden",children:c.children}),c.subtreeFlags=U.subtreeFlags&65011712,ue!==null?D=as(ue,D):(D=ys(D,h,a,null),D.flags|=2),D.return=r,c.return=r,c.sibling=D,r.child=c,Pu(null,c),c=r.child,D=i.child.memoizedState,D===null?D=qm(a):(h=D.cachePool,h!==null?(U=Qn._currentValue,h=h.parent!==U?{parent:U,pool:U}:h):h=oS(),D={baseLanes:D.baseLanes|a,cachePool:h}),c.memoizedState=D,c.childLanes=Vm(i,y,a),r.memoizedState=Km,Pu(i.child,c)):(Qa(r),a=i.child,i=a.sibling,a=as(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 Ym(i,r){return r=$h({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function $h(i,r){return i=Oi(22,i,null,r),i.lanes=0,i}function Gm(i,r,a){return hl(r,i.child,null,a),i=Ym(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function y0(i,r,a){i.lanes|=r;var c=i.alternate;c!==null&&(c.lanes|=r),Hr(i.return,r,a)}function Xm(i,r,a,c,h,g){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:h,treeForkCount:g}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=a,y.tailMode=h,y.treeForkCount=g)}function S0(i,r,a){var c=r.pendingProps,h=c.revealOrder,g=c.tail;c=c.children;var y=Wn.current,D=(y&2)!==0;if(D?(y=y&1|2,r.flags|=128):y&=1,se(Wn,y),Ei(i,r,c,a),c=Mt?nr:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&y0(i,a,r);else if(i.tag===19)y0(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&&Dh(i)===null&&(h=a),a=a.sibling;a=h,a===null?(h=r.child,r.child=null):(h=a.sibling,a.sibling=null),Xm(r,!1,h,a,g,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&&Dh(i)===null){r.child=h;break}i=h.sibling,h.sibling=a,a=h,h=i}Xm(r,!0,a,null,g,c);break;case"together":Xm(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function aa(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),no|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(ia(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=as(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=as(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&&lc(i)))}function gR(i,r,a){switch(r.tag){case 3:Fe(r,r.stateNode.containerInfo),$t(r,Qn,i.memoizedState.cache),lt();break;case 27:case 5:ve(r);break;case 4:Fe(r,r.stateNode.containerInfo);break;case 10:$t(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,wm(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(Qa(r),r.flags|=128,null):(a&r.child.childLanes)!==0?b0(i,r,a):(Qa(r),i=aa(i,r,a),i!==null?i.sibling:null);Qa(r);break;case 19:var h=(i.flags&128)!==0;if(c=(a&r.childLanes)!==0,c||(ia(i,r,a,!1),c=(a&r.childLanes)!==0),h){if(c)return S0(i,r,a);r.flags|=128}if(h=r.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),se(Wn,Wn.current),c)break;return null;case 22:return r.lanes=0,f0(i,r,a,r.pendingProps);case 24:$t(r,Qn,i.memoizedState.cache)}return aa(i,r,a)}function w0(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)ei=!0;else{if(!Zm(i,a)&&(r.flags&128)===0)return ei=!1,gR(i,r,a);ei=(i.flags&131072)!==0}else ei=!1,Mt&&(r.flags&1048576)!==0&&ku(r,nr,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(i=ul(r.elementType),r.type=i,typeof i=="function")ac(i)?(c=pl(i,c),r.tag=1,r=v0(null,r,i,c,a)):(r.tag=0,r=Wm(null,r,i,c,a));else{if(i!=null){var h=i.$$typeof;if(h===H){r.tag=11,r=u0(null,r,i,c,a);break e}else if(h===I){r.tag=14,r=d0(null,r,i,c,a);break e}}throw r=Z(i)||i,Error(s(306,r,""))}}return r;case 0:return Wm(i,r,r.type,r.pendingProps,a);case 1:return c=r.type,h=pl(c,r.pendingProps),v0(i,r,c,h,a);case 3:e:{if(Fe(r,r.stateNode.containerInfo),i===null)throw Error(s(387));c=r.pendingProps;var g=r.memoizedState;h=g.element,vm(i,r),Lu(r,c,null,a);var y=r.memoizedState;if(c=y.cache,$t(r,Qn,c),c!==g.cache&&Fn(r,[Qn],a,!0),Au(),c=y.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:y.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=_0(i,r,c,a);break e}else if(c!==h){h=tr(Error(s(424)),r),Ot(h),r=_0(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,Wt=$r(i.firstChild),In=r,Mt=!0,ws=null,Wi=!0,a=fS(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(lt(),c===h){r=aa(i,r,a);break e}Ei(i,r,c,a)}r=r.child}return r;case 26:return Uh(i,r),i===null?(a=Lw(r.type,null,r.pendingProps,null))?r.memoizedState=a:Mt||(a=r.type,i=r.pendingProps,c=sf(ye.current).createElement(a),c[ke]=r,c[Xe]=i,Ri(c,a,i),an(c),r.stateNode=c):r.memoizedState=Lw(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return ve(r),i===null&&Mt&&(c=r.stateNode=Dw(r.type,r.pendingProps,ye.current),In=r,Wi=!0,h=Wt,oo(r.type)?(Dg=h,Wt=$r(c.firstChild)):Wt=h),Ei(i,r,r.pendingProps.children,a),Uh(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&Mt&&((h=c=Wt)&&(c=qR(c,r.type,r.pendingProps,Wi),c!==null?(r.stateNode=c,In=r,Wt=$r(c.firstChild),Wi=!1,h=!0):h=!1),h||P(r)),ve(r),h=r.type,g=r.pendingProps,y=i!==null?i.memoizedProps:null,c=g.children,kg(h,g)?c=null:y!==null&&kg(h,y)&&(r.flags|=32),r.memoizedState!==null&&(h=Cm(i,r,oR,null,null,a),Ju._currentValue=h),Uh(i,r),Ei(i,r,c,a),r.child;case 6:return i===null&&Mt&&((i=a=Wt)&&(a=VR(a,r.pendingProps,Wi),a!==null?(r.stateNode=a,In=r,Wt=null,i=!0):i=!1),i||P(r)),null;case 13:return b0(i,r,a);case 4:return Fe(r,r.stateNode.containerInfo),c=r.pendingProps,i===null?r.child=hl(r,null,c,a):Ei(i,r,c,a),r.child;case 11:return u0(i,r,r.type,r.pendingProps,a);case 7:return Ei(i,r,r.pendingProps,a),r.child;case 8:return Ei(i,r,r.pendingProps.children,a),r.child;case 12:return Ei(i,r,r.pendingProps.children,a),r.child;case 10:return c=r.pendingProps,$t(r,r.type,c.value),Ei(i,r,c.children,a),r.child;case 9:return h=r.type._context,c=r.pendingProps.children,mn(r),h=Zn(h),c=c(h),r.flags|=1,Ei(i,r,c,a),r.child;case 14:return d0(i,r,r.type,r.pendingProps,a);case 15:return h0(i,r,r.type,r.pendingProps,a);case 19:return S0(i,r,a);case 31:return mR(i,r,a);case 22:return f0(i,r,a,r.pendingProps);case 24:return mn(r),c=Zn(Qn),i===null?(h=pm(),h===null&&(h=hn,g=hm(),h.pooledCache=g,g.refCount++,g!==null&&(h.pooledCacheLanes|=a),h=g),r.memoizedState={parent:c,cache:h},gm(r),$t(r,Qn,h)):((i.lanes&a)!==0&&(vm(i,r),Lu(r,null,null,a),Au()),h=i.memoizedState,g=r.memoizedState,h.parent!==c?(h={parent:c,cache:c},r.memoizedState=h,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=h),$t(r,Qn,c)):(c=g.cache,$t(r,Qn,c),c!==h.cache&&Fn(r,[Qn],a,!0))),Ei(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function oa(i){i.flags|=4}function Qm(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(G0())i.flags|=8192;else throw dl=Th,mm}else i.flags&=-16777217}function x0(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Pw(r))if(G0())i.flags|=8192;else throw dl=Th,mm}function Fh(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?Ft():536870912,i.lanes|=r,yc|=r)}function zu(i,r){if(!Mt)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 vR(i,r,a){var c=r.pendingProps;switch(Tu(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),$n(Qn),ze(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ze(r)?oa(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ht())),gn(r),null;case 26:var h=r.type,g=r.memoizedState;return i===null?(oa(r),g!==null?(gn(r),x0(r,g)):(gn(r),Qm(r,h,null,c,a))):g?g!==i.memoizedState?(oa(r),gn(r),x0(r,g)):(gn(r),r.flags&=-16777217):(i=i.memoizedProps,i!==c&&oa(r),gn(r),Qm(r,h,i,c,a)),null;case 27:if(We(r),a=ye.current,h=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==c&&oa(r);else{if(!c){if(r.stateNode===null)throw Error(s(166));return gn(r),null}i=J.current,Ze(r)?Ae(r):(i=Dw(h,c,a),r.stateNode=i,oa(r))}return gn(r),null;case 5:if(We(r),h=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==c&&oa(r);else{if(!c){if(r.stateNode===null)throw Error(s(166));return gn(r),null}if(g=J.current,Ze(r))Ae(r);else{var y=sf(ye.current);switch(g){case 1:g=y.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:g=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":g=y.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":g=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":g=y.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?y.createElement("select",{is:c.is}):y.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?y.createElement(h,{is:c.is}):y.createElement(h)}}g[ke]=r,g[Xe]=c;e:for(y=r.child;y!==null;){if(y.tag===5||y.tag===6)g.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=g;e:switch(Ri(g,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&&oa(r)}}return gn(r),Qm(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==c&&oa(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(s(166));if(i=ye.current,Ze(r)){if(i=r.stateNode,a=r.memoizedProps,c=null,h=In,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}i[ke]=r,i=!!(i.nodeValue===a||c!==null&&c.suppressHydrationWarning===!0||bw(i.nodeValue,a)),i||P(r,!0)}else i=sf(i).createTextNode(c),i[ke]=r,r.stateNode=i}return gn(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(c=Ze(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[ke]=r}else lt(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),i=!1}else a=Ht(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(yr(r),r):(yr(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=Ze(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[ke]=r}else lt(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),h=!1}else h=Ht(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=h),h=!0;if(!h)return r.flags&256?(yr(r),r):(yr(r),null)}return yr(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),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==h&&(c.flags|=2048)),a!==i&&a&&(r.child.flags|=8192),Fh(r,r.updateQueue),gn(r),null);case 4:return ze(),i===null&&yg(r.stateNode.containerInfo),gn(r),null;case 10:return $n(r.type),gn(r),null;case 19:if(V(Wn),c=r.memoizedState,c===null)return gn(r),null;if(h=(r.flags&128)!==0,g=c.rendering,g===null)if(h)zu(c,!1);else{if(zn!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(g=Dh(i),g!==null){for(r.flags|=128,zu(c,!1),i=g.updateQueue,r.updateQueue=i,Fh(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)wu(a,i),a=a.sibling;return se(Wn,Wn.current&1|2),Mt&&os(r,c.treeForkCount),r.child}i=i.sibling}c.tail!==null&&$e()>Yh&&(r.flags|=128,h=!0,zu(c,!1),r.lanes=4194304)}else{if(!h)if(i=Dh(g),i!==null){if(r.flags|=128,h=!0,i=i.updateQueue,r.updateQueue=i,Fh(r,i),zu(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!Mt)return gn(r),null}else 2*$e()-c.renderingStartTime>Yh&&a!==536870912&&(r.flags|=128,h=!0,zu(c,!1),r.lanes=4194304);c.isBackwards?(g.sibling=r.child,r.child=g):(i=c.last,i!==null?i.sibling=g:r.child=g,c.last=g)}return c.tail!==null?(i=c.tail,c.rendering=i,c.tail=i.sibling,c.renderingStartTime=$e(),i.sibling=null,a=Wn.current,se(Wn,h?a&1|2:a&1),Mt&&os(r,c.treeForkCount),i):(gn(r),null);case 22:case 23:return yr(r),Sm(),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&&Fh(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(cl),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),$n(Qn),gn(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function _R(i,r){switch(Tu(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return $n(Qn),ze(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return We(r),null;case 31:if(r.memoizedState!==null){if(yr(r),r.alternate===null)throw Error(s(340));lt()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(yr(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));lt()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return V(Wn),null;case 4:return ze(),null;case 10:return $n(r.type),null;case 22:case 23:return yr(r),Sm(),i!==null&&V(cl),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return $n(Qn),null;case 25:return null;default:return null}}function C0(i,r){switch(Tu(r),r.tag){case 3:$n(Qn),ze();break;case 26:case 27:case 5:We(r);break;case 4:ze();break;case 31:r.memoizedState!==null&&yr(r);break;case 13:yr(r);break;case 19:V(Wn);break;case 10:$n(r.type);break;case 22:case 23:yr(r),Sm(),i!==null&&V(cl);break;case 24:$n(Qn)}}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 g=a.create,y=a.inst;c=g(),y.destroy=c}a=a.next}while(a!==h)}}catch(D){tn(r,r.return,D)}}function eo(i,r,a){try{var c=r.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var g=h.next;c=g;do{if((c.tag&i)===i){var y=c.inst,D=y.destroy;if(D!==void 0){y.destroy=void 0,h=r;var U=a,ue=D;try{ue()}catch(Se){tn(h,U,Se)}}}c=c.next}while(c!==g)}}catch(Se){tn(r,r.return,Se)}}function k0(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{mS(r,a)}catch(c){tn(i,i.return,c)}}}function T0(i,r,a){a.props=pl(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(c){tn(i,r,c)}}function Uu(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){tn(i,r,h)}}function xs(i,r){var a=i.ref,c=i.refCleanup;if(a!==null)if(typeof c=="function")try{c()}catch(h){tn(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){tn(i,r,h)}else a.current=null}function E0(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){tn(i,i.return,h)}}function Jm(i,r,a){try{var c=i.stateNode;HR(c,i.type,a,r),c[Xe]=r}catch(h){tn(i,i.return,h)}}function R0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&oo(i.type)||i.tag===4}function eg(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||R0(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&&oo(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 tg(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=Li));else if(c!==4&&(c===27&&oo(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(tg(i,r,a),i=i.sibling;i!==null;)tg(i,r,a),i=i.sibling}function Wh(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&&oo(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Wh(i,r,a),i=i.sibling;i!==null;)Wh(i,r,a),i=i.sibling}function N0(i){var r=i.stateNode,a=i.memoizedProps;try{for(var c=i.type,h=r.attributes;h.length;)r.removeAttributeNode(h[0]);Ri(r,c,a),r[ke]=i,r[Xe]=a}catch(g){tn(i,i.return,g)}}var la=!1,ti=!1,ng=!1,D0=typeof WeakSet=="function"?WeakSet:Set,vi=null;function bR(i,r){if(i=i.containerInfo,xg=hf,i=bh(i),Ql(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,g=c.focusNode;c=c.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var y=0,D=-1,U=-1,ue=0,Se=0,Ee=i,fe=null;t:for(;;){for(var _e;Ee!==a||h!==0&&Ee.nodeType!==3||(D=y+h),Ee!==g||c!==0&&Ee.nodeType!==3||(U=y+c),Ee.nodeType===3&&(y+=Ee.nodeValue.length),(_e=Ee.firstChild)!==null;)fe=Ee,Ee=_e;for(;;){if(Ee===i)break t;if(fe===a&&++ue===h&&(D=y),fe===g&&++Se===c&&(U=y),(_e=Ee.nextSibling)!==null)break;Ee=fe,fe=Ee.parentNode}Ee=_e}a=D===-1||U===-1?null:{start:D,end:U}}else a=null}a=a||{start:0,end:0}}else a=null;for(Cg={focusedElem:i,selectionRange:a},hf=!1,vi=r;vi!==null;)if(r=vi,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,vi=i;else for(;vi!==null;){switch(r=vi,g=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&&g!==null){i=void 0,a=r,h=g.memoizedProps,g=g.memoizedState,c=a.stateNode;try{var Qe=pl(a.type,h);i=c.getSnapshotBeforeUpdate(Qe,g),c.__reactInternalSnapshotBeforeUpdate=i}catch(ut){tn(a,a.return,ut)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)Eg(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Eg(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,vi=i;break}vi=r.return}}function M0(i,r,a){var c=a.flags;switch(a.tag){case 0:case 11:case 15:ua(i,a),c&4&&Hu(5,a);break;case 1:if(ua(i,a),c&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(y){tn(a,a.return,y)}else{var h=pl(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(h,r,i.__reactInternalSnapshotBeforeUpdate)}catch(y){tn(a,a.return,y)}}c&64&&k0(a),c&512&&Uu(a,a.return);break;case 3:if(ua(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{mS(i,r)}catch(y){tn(a,a.return,y)}}break;case 27:r===null&&c&4&&N0(a);case 26:case 5:ua(i,a),r===null&&c&4&&E0(a),c&512&&Uu(a,a.return);break;case 12:ua(i,a);break;case 31:ua(i,a),c&4&&j0(i,a);break;case 13:ua(i,a),c&4&&O0(i,a),c&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=RR.bind(null,a),YR(i,a))));break;case 22:if(c=a.memoizedState!==null||la,!c){r=r!==null&&r.memoizedState!==null||ti,h=la;var g=ti;la=c,(ti=r)&&!g?da(i,a,(a.subtreeFlags&8772)!==0):ua(i,a),la=h,ti=g}break;case 30:break;default:ua(i,a)}}function A0(i){var r=i.alternate;r!==null&&(i.alternate=null,A0(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Xi(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 Tn=null,rr=!1;function ca(i,r,a){for(a=a.child;a!==null;)L0(i,r,a),a=a.sibling}function L0(i,r,a){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(_n,a)}catch{}switch(a.tag){case 26:ti||xs(a,r),ca(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:ti||xs(a,r);var c=Tn,h=rr;oo(a.type)&&(Tn=a.stateNode,rr=!1),ca(i,r,a),Xu(a.stateNode),Tn=c,rr=h;break;case 5:ti||xs(a,r);case 6:if(c=Tn,h=rr,Tn=null,ca(i,r,a),Tn=c,rr=h,Tn!==null)if(rr)try{(Tn.nodeType===9?Tn.body:Tn.nodeName==="HTML"?Tn.ownerDocument.body:Tn).removeChild(a.stateNode)}catch(g){tn(a,r,g)}else try{Tn.removeChild(a.stateNode)}catch(g){tn(a,r,g)}break;case 18:Tn!==null&&(rr?(i=Tn,kw(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),Rc(i)):kw(Tn,a.stateNode));break;case 4:c=Tn,h=rr,Tn=a.stateNode.containerInfo,rr=!0,ca(i,r,a),Tn=c,rr=h;break;case 0:case 11:case 14:case 15:eo(2,a,r),ti||eo(4,a,r),ca(i,r,a);break;case 1:ti||(xs(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"&&T0(a,r,c)),ca(i,r,a);break;case 21:ca(i,r,a);break;case 22:ti=(c=ti)||a.memoizedState!==null,ca(i,r,a),ti=c;break;default:ca(i,r,a)}}function j0(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Rc(i)}catch(a){tn(r,r.return,a)}}}function O0(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Rc(i)}catch(a){tn(r,r.return,a)}}function yR(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new D0),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new D0),r;default:throw Error(s(435,i.tag))}}function Kh(i,r){var a=yR(i);r.forEach(function(c){if(!a.has(c)){a.add(c);var h=NR.bind(null,i,c);c.then(h,h)}})}function sr(i,r){var a=r.deletions;if(a!==null)for(var c=0;c<a.length;c++){var h=a[c],g=i,y=r,D=y;e:for(;D!==null;){switch(D.tag){case 27:if(oo(D.type)){Tn=D.stateNode,rr=!1;break e}break;case 5:Tn=D.stateNode,rr=!1;break e;case 3:case 4:Tn=D.stateNode.containerInfo,rr=!0;break e}D=D.return}if(Tn===null)throw Error(s(160));L0(g,y,h),Tn=null,rr=!1,g=h.alternate,g!==null&&(g.return=null),h.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)B0(r,i),r=r.sibling}var ls=null;function B0(i,r){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:sr(r,i),ar(i),c&4&&(eo(3,i,i.return),Hu(3,i),eo(5,i,i.return));break;case 1:sr(r,i),ar(i),c&512&&(ti||a===null||xs(a,a.return)),c&64&&la&&(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=ls;if(sr(r,i),ar(i),c&512&&(ti||a===null||xs(a,a.return)),c&4){var g=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":g=h.getElementsByTagName("title")[0],(!g||g[Xt]||g[ke]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=h.createElement(c),h.head.insertBefore(g,h.querySelector("head > title"))),Ri(g,c,a),g[ke]=i,an(g),c=g;break e;case"link":var y=Bw("link","href",h).get(c+(a.href||""));if(y){for(var D=0;D<y.length;D++)if(g=y[D],g.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&g.getAttribute("rel")===(a.rel==null?null:a.rel)&&g.getAttribute("title")===(a.title==null?null:a.title)&&g.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(D,1);break t}}g=h.createElement(c),Ri(g,c,a),h.head.appendChild(g);break;case"meta":if(y=Bw("meta","content",h).get(c+(a.content||""))){for(D=0;D<y.length;D++)if(g=y[D],g.getAttribute("content")===(a.content==null?null:""+a.content)&&g.getAttribute("name")===(a.name==null?null:a.name)&&g.getAttribute("property")===(a.property==null?null:a.property)&&g.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&g.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(D,1);break t}}g=h.createElement(c),Ri(g,c,a),h.head.appendChild(g);break;default:throw Error(s(468,c))}g[ke]=i,an(g),c=g}i.stateNode=c}else Iw(h,i.type,i.stateNode);else i.stateNode=Ow(h,c,i.memoizedProps);else g!==c?(g===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):g.count--,c===null?Iw(h,i.type,i.stateNode):Ow(h,c,i.memoizedProps)):c===null&&i.stateNode!==null&&Jm(i,i.memoizedProps,a.memoizedProps)}break;case 27:sr(r,i),ar(i),c&512&&(ti||a===null||xs(a,a.return)),a!==null&&c&4&&Jm(i,i.memoizedProps,a.memoizedProps);break;case 5:if(sr(r,i),ar(i),c&512&&(ti||a===null||xs(a,a.return)),i.flags&32){h=i.stateNode;try{Jr(h,"")}catch(Qe){tn(i,i.return,Qe)}}c&4&&i.stateNode!=null&&(h=i.memoizedProps,Jm(i,h,a!==null?a.memoizedProps:h)),c&1024&&(ng=!0);break;case 6:if(sr(r,i),ar(i),c&4){if(i.stateNode===null)throw Error(s(162));c=i.memoizedProps,a=i.stateNode;try{a.nodeValue=c}catch(Qe){tn(i,i.return,Qe)}}break;case 3:if(lf=null,h=ls,ls=af(r.containerInfo),sr(r,i),ls=h,ar(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{Rc(r.containerInfo)}catch(Qe){tn(i,i.return,Qe)}ng&&(ng=!1,I0(i));break;case 4:c=ls,ls=af(i.stateNode.containerInfo),sr(r,i),ar(i),ls=c;break;case 12:sr(r,i),ar(i);break;case 31:sr(r,i),ar(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Kh(i,c)));break;case 13:sr(r,i),ar(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Vh=$e()),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Kh(i,c)));break;case 22:h=i.memoizedState!==null;var U=a!==null&&a.memoizedState!==null,ue=la,Se=ti;if(la=ue||h,ti=Se||U,sr(r,i),ti=Se,la=ue,ar(i),c&8192)e:for(r=i.stateNode,r._visibility=h?r._visibility&-2:r._visibility|1,h&&(a===null||U||la||ti||ml(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){U=a=r;try{if(g=U.stateNode,h)y=g.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{D=U.stateNode;var Ee=U.memoizedProps.style,fe=Ee!=null&&Ee.hasOwnProperty("display")?Ee.display:null;D.style.display=fe==null||typeof fe=="boolean"?"":(""+fe).trim()}}catch(Qe){tn(U,U.return,Qe)}}}else if(r.tag===6){if(a===null){U=r;try{U.stateNode.nodeValue=h?"":U.memoizedProps}catch(Qe){tn(U,U.return,Qe)}}}else if(r.tag===18){if(a===null){U=r;try{var _e=U.stateNode;h?Tw(_e,!0):Tw(U.stateNode,!1)}catch(Qe){tn(U,U.return,Qe)}}}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,Kh(i,a))));break;case 19:sr(r,i),ar(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Kh(i,c)));break;case 30:break;case 21:break;default:sr(r,i),ar(i)}}function ar(i){var r=i.flags;if(r&2){try{for(var a,c=i.return;c!==null;){if(R0(c)){a=c;break}c=c.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var h=a.stateNode,g=eg(i);Wh(i,g,h);break;case 5:var y=a.stateNode;a.flags&32&&(Jr(y,""),a.flags&=-33);var D=eg(i);Wh(i,D,y);break;case 3:case 4:var U=a.stateNode.containerInfo,ue=eg(i);tg(i,ue,U);break;default:throw Error(s(161))}}catch(Se){tn(i,i.return,Se)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function I0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;I0(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function ua(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)M0(i,r.alternate,r),r=r.sibling}function ml(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:eo(4,r,r.return),ml(r);break;case 1:xs(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&T0(r,r.return,a),ml(r);break;case 27:Xu(r.stateNode);case 26:case 5:xs(r,r.return),ml(r);break;case 22:r.memoizedState===null&&ml(r);break;case 30:ml(r);break;default:ml(r)}i=i.sibling}}function da(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,h=i,g=r,y=g.flags;switch(g.tag){case 0:case 11:case 15:da(h,g,a),Hu(4,g);break;case 1:if(da(h,g,a),c=g,h=c.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(ue){tn(c,c.return,ue)}if(c=g,h=c.updateQueue,h!==null){var D=c.stateNode;try{var U=h.shared.hiddenCallbacks;if(U!==null)for(h.shared.hiddenCallbacks=null,h=0;h<U.length;h++)pS(U[h],D)}catch(ue){tn(c,c.return,ue)}}a&&y&64&&k0(g),Uu(g,g.return);break;case 27:N0(g);case 26:case 5:da(h,g,a),a&&c===null&&y&4&&E0(g),Uu(g,g.return);break;case 12:da(h,g,a);break;case 31:da(h,g,a),a&&y&4&&j0(h,g);break;case 13:da(h,g,a),a&&y&4&&O0(h,g);break;case 22:g.memoizedState===null&&da(h,g,a),Uu(g,g.return);break;case 30:break;default:da(h,g,a)}r=r.sibling}}function ig(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&&Eu(a))}function rg(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Eu(i))}function cs(i,r,a,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)P0(i,r,a,c),r=r.sibling}function P0(i,r,a,c){var h=r.flags;switch(r.tag){case 0:case 11:case 15:cs(i,r,a,c),h&2048&&Hu(9,r);break;case 1:cs(i,r,a,c);break;case 3:cs(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&&Eu(i)));break;case 12:if(h&2048){cs(i,r,a,c),i=r.stateNode;try{var g=r.memoizedProps,y=g.id,D=g.onPostCommit;typeof D=="function"&&D(y,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(U){tn(r,r.return,U)}}else cs(i,r,a,c);break;case 31:cs(i,r,a,c);break;case 13:cs(i,r,a,c);break;case 23:break;case 22:g=r.stateNode,y=r.alternate,r.memoizedState!==null?g._visibility&2?cs(i,r,a,c):$u(i,r):g._visibility&2?cs(i,r,a,c):(g._visibility|=2,vc(i,r,a,c,(r.subtreeFlags&10256)!==0||!1)),h&2048&&ig(y,r);break;case 24:cs(i,r,a,c),h&2048&&rg(r.alternate,r);break;default:cs(i,r,a,c)}}function vc(i,r,a,c,h){for(h=h&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=i,y=r,D=a,U=c,ue=y.flags;switch(y.tag){case 0:case 11:case 15:vc(g,y,D,U,h),Hu(8,y);break;case 23:break;case 22:var Se=y.stateNode;y.memoizedState!==null?Se._visibility&2?vc(g,y,D,U,h):$u(g,y):(Se._visibility|=2,vc(g,y,D,U,h)),h&&ue&2048&&ig(y.alternate,y);break;case 24:vc(g,y,D,U,h),h&&ue&2048&&rg(y.alternate,y);break;default:vc(g,y,D,U,h)}r=r.sibling}}function $u(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:$u(a,c),h&2048&&ig(c.alternate,c);break;case 24:$u(a,c),h&2048&&rg(c.alternate,c);break;default:$u(a,c)}r=r.sibling}}var Fu=8192;function _c(i,r,a){if(i.subtreeFlags&Fu)for(i=i.child;i!==null;)z0(i,r,a),i=i.sibling}function z0(i,r,a){switch(i.tag){case 26:_c(i,r,a),i.flags&Fu&&i.memoizedState!==null&&aN(a,ls,i.memoizedState,i.memoizedProps);break;case 5:_c(i,r,a);break;case 3:case 4:var c=ls;ls=af(i.stateNode.containerInfo),_c(i,r,a),ls=c;break;case 22:i.memoizedState===null&&(c=i.alternate,c!==null&&c.memoizedState!==null?(c=Fu,Fu=16777216,_c(i,r,a),Fu=c):_c(i,r,a));break;default:_c(i,r,a)}}function H0(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 Wu(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];vi=c,$0(c,i)}H0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)U0(i),i=i.sibling}function U0(i){switch(i.tag){case 0:case 11:case 15:Wu(i),i.flags&2048&&eo(9,i,i.return);break;case 3:Wu(i);break;case 12:Wu(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,qh(i)):Wu(i);break;default:Wu(i)}}function qh(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];vi=c,$0(c,i)}H0(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:eo(8,r,r.return),qh(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,qh(r));break;default:qh(r)}i=i.sibling}}function $0(i,r){for(;vi!==null;){var a=vi;switch(a.tag){case 0:case 11:case 15:eo(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:Eu(a.memoizedState.cache)}if(c=a.child,c!==null)c.return=a,vi=c;else e:for(a=i;vi!==null;){c=vi;var h=c.sibling,g=c.return;if(A0(c),c===a){vi=null;break e}if(h!==null){h.return=g,vi=h;break e}vi=g}}}var SR={getCacheForType:function(i){var r=Zn(Qn),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Zn(Qn).controller.signal}},wR=typeof WeakMap=="function"?WeakMap:Map,Yt=0,hn=null,At=null,Bt=0,en=0,Sr=null,to=!1,bc=!1,sg=!1,ha=0,zn=0,no=0,gl=0,ag=0,wr=0,yc=0,Ku=null,or=null,og=!1,Vh=0,F0=0,Yh=1/0,Gh=null,io=null,ci=0,ro=null,Sc=null,fa=0,lg=0,cg=null,W0=null,qu=0,ug=null;function xr(){return(Yt&2)!==0&&Bt!==0?Bt&-Bt:M.T!==null?gg():wt()}function K0(){if(wr===0)if((Bt&536870912)===0||Mt){var i=te;te<<=1,(te&3932160)===0&&(te=262144),wr=i}else wr=536870912;return i=br.current,i!==null&&(i.flags|=32),wr}function lr(i,r,a){(i===hn&&(en===2||en===9)||i.cancelPendingCommit!==null)&&(wc(i,0),so(i,Bt,wr,!1)),Jt(i,a),((Yt&2)===0||i!==hn)&&(i===hn&&((Yt&2)===0&&(gl|=a),zn===4&&so(i,Bt,wr,!1)),Cs(i))}function q0(i,r,a){if((Yt&6)!==0)throw Error(s(327));var c=!a&&(r&127)===0&&(r&i.expiredLanes)===0||Pt(i,r),h=c?kR(i,r):hg(i,r,!0),g=c;do{if(h===0){bc&&!c&&so(i,r,0,!1);break}else{if(a=i.current.alternate,g&&!xR(a)){h=hg(i,r,!1),g=!1;continue}if(h===2){if(g=r,i.errorRecoveryDisabledLanes&g)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=Ku;var U=D.current.memoizedState.isDehydrated;if(U&&(wc(D,y).flags|=256),y=hg(D,y,!1),y!==2){if(sg&&!U){D.errorRecoveryDisabledLanes|=g,gl|=g,h=4;break e}g=or,or=h,g!==null&&(or===null?or=g:or.push.apply(or,g))}h=y}if(g=!1,h!==2)continue}}if(h===1){wc(i,0),so(i,r,0,!0);break}e:{switch(c=i,g=h,g){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:so(c,r,wr,!to);break e;case 2:or=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(h=Vh+300-$e(),10<h)){if(so(c,r,wr,!to),bt(c,0,!0)!==0)break e;fa=r,c.timeoutHandle=xw(V0.bind(null,c,a,or,Gh,og,r,wr,gl,yc,to,g,"Throttled",-0,0),h);break e}V0(c,a,or,Gh,og,r,wr,gl,yc,to,g,null,-0,0)}}break}while(!0);Cs(i)}function V0(i,r,a,c,h,g,y,D,U,ue,Se,Ee,fe,_e){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:Li},z0(r,g,Ee);var Qe=(g&62914560)===g?Vh-$e():(g&4194048)===g?F0-$e():0;if(Qe=oN(Ee,Qe),Qe!==null){fa=g,i.cancelPendingCommit=Qe(tw.bind(null,i,r,g,a,c,h,y,D,U,Se,Ee,null,fe,_e)),so(i,g,y,!ue);return}}tw(i,r,g,a,c,h,y,D,U)}function xR(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],g=h.getSnapshot;h=h.value;try{if(!Vt(g(),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 so(i,r,a,c){r&=~ag,r&=~gl,i.suspendedLanes|=r,i.pingedLanes&=~r,c&&(i.warmLanes|=r),c=i.expirationTimes;for(var h=r;0<h;){var g=31-Nt(h),y=1<<g;c[g]=-1,h&=~y}a!==0&&yn(i,a,r)}function Xh(){return(Yt&6)===0?(Vu(0),!1):!0}function dg(){if(At!==null){if(en===0)var i=At.return;else i=At,Ut=dt=null,Em(i),hc=null,Nu=0,i=At;for(;i!==null;)C0(i.alternate,i),i=i.return;At=null}}function wc(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,FR(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),fa=0,dg(),hn=i,At=a=as(i.current,null),Bt=r,en=0,Sr=null,to=!1,bc=Pt(i,r),sg=!1,yc=wr=ag=gl=no=zn=0,or=Ku=null,og=!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-Nt(c),g=1<<h;r|=i[h],c&=~g}return ha=r,sc(),a}function Y0(i,r){xt=null,M.H=Iu,r===dc||r===kh?(r=uS(),en=3):r===mm?(r=uS(),en=4):en=r===Fm?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Sr=r,At===null&&(zn=1,zh(i,tr(r,i.current)))}function G0(){var i=br.current;return i===null?!0:(Bt&4194048)===Bt?Ur===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?i===Ur:!1}function X0(){var i=M.H;return M.H=Iu,i===null?Iu:i}function Z0(){var i=M.A;return M.A=SR,i}function Zh(){zn=4,to||(Bt&4194048)!==Bt&&br.current!==null||(bc=!0),(no&134217727)===0&&(gl&134217727)===0||hn===null||so(hn,Bt,wr,!1)}function hg(i,r,a){var c=Yt;Yt|=2;var h=X0(),g=Z0();(hn!==i||Bt!==r)&&(Gh=null,wc(i,r)),r=!1;var y=zn;e:do try{if(en!==0&&At!==null){var D=At,U=Sr;switch(en){case 8:dg(),y=6;break e;case 3:case 2:case 9:case 6:br.current===null&&(r=!0);var ue=en;if(en=0,Sr=null,xc(i,D,U,ue),a&&bc){y=0;break e}break;default:ue=en,en=0,Sr=null,xc(i,D,U,ue)}}CR(),y=zn;break}catch(Se){Y0(i,Se)}while(!0);return r&&i.shellSuspendCounter++,Ut=dt=null,Yt=c,M.H=h,M.A=g,At===null&&(hn=null,Bt=0,sc()),y}function CR(){for(;At!==null;)Q0(At)}function kR(i,r){var a=Yt;Yt|=2;var c=X0(),h=Z0();hn!==i||Bt!==r?(Gh=null,Yh=$e()+500,wc(i,r)):bc=Pt(i,r);e:do try{if(en!==0&&At!==null){r=At;var g=Sr;t:switch(en){case 1:en=0,Sr=null,xc(i,r,g,1);break;case 2:case 9:if(lS(g)){en=0,Sr=null,J0(r);break}r=function(){en!==2&&en!==9||hn!==i||(en=7),Cs(i)},g.then(r,r);break e;case 3:en=7;break e;case 4:en=5;break e;case 7:lS(g)?(en=0,Sr=null,J0(r)):(en=0,Sr=null,xc(i,r,g,7));break;case 5:var y=null;switch(At.tag){case 26:y=At.memoizedState;case 5:case 27:var D=At;if(y?Pw(y):D.stateNode.complete){en=0,Sr=null;var U=D.sibling;if(U!==null)At=U;else{var ue=D.return;ue!==null?(At=ue,Qh(ue)):At=null}break t}}en=0,Sr=null,xc(i,r,g,5);break;case 6:en=0,Sr=null,xc(i,r,g,6);break;case 8:dg(),zn=6;break e;default:throw Error(s(462))}}TR();break}catch(Se){Y0(i,Se)}while(!0);return Ut=dt=null,M.H=c,M.A=h,Yt=a,At!==null?0:(hn=null,Bt=0,sc(),zn)}function TR(){for(;At!==null&&!be();)Q0(At)}function Q0(i){var r=w0(i.alternate,i,ha);i.memoizedProps=i.pendingProps,r===null?Qh(i):At=r}function J0(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=g0(a,r,r.pendingProps,r.type,void 0,Bt);break;case 11:r=g0(a,r,r.pendingProps,r.type.render,r.ref,Bt);break;case 5:Em(r);default:C0(a,r),r=At=wu(r,ha),r=w0(a,r,ha)}i.memoizedProps=i.pendingProps,r===null?Qh(i):At=r}function xc(i,r,a,c){Ut=dt=null,Em(r),hc=null,Nu=0;var h=r.return;try{if(pR(i,h,r,a,Bt)){zn=1,zh(i,tr(a,i.current)),At=null;return}}catch(g){if(h!==null)throw At=h,g;zn=1,zh(i,tr(a,i.current)),At=null;return}r.flags&32768?(Mt||c===1?i=!0:bc||(Bt&536870912)!==0?i=!1:(to=i=!0,(c===2||c===9||c===3||c===6)&&(c=br.current,c!==null&&c.tag===13&&(c.flags|=16384))),ew(r,i)):Qh(r)}function Qh(i){var r=i;do{if((r.flags&32768)!==0){ew(r,to);return}i=r.return;var a=vR(r.alternate,r,ha);if(a!==null){At=a;return}if(r=r.sibling,r!==null){At=r;return}At=r=i}while(r!==null);zn===0&&(zn=5)}function ew(i,r){do{var a=_R(i.alternate,i);if(a!==null){a.flags&=32767,At=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){At=i;return}At=i=a}while(i!==null);zn=6,At=null}function tw(i,r,a,c,h,g,y,D,U){i.cancelPendingCommit=null;do Jh();while(ci!==0);if((Yt&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(g=r.lanes|r.childLanes,g|=rc,Dt(i,a,g,y,D,U),i===hn&&(At=hn=null,Bt=0),Sc=r,ro=i,fa=a,lg=g,cg=h,W0=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,DR(ht,function(){return aw(),null})):(i.callbackNode=null,i.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=M.T,M.T=null,h=T.p,T.p=2,y=Yt,Yt|=4;try{bR(i,r,a)}finally{Yt=y,T.p=h,M.T=c}}ci=1,nw(),iw(),rw()}}function nw(){if(ci===1){ci=0;var i=ro,r=Sc,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=M.T,M.T=null;var c=T.p;T.p=2;var h=Yt;Yt|=4;try{B0(r,i);var g=Cg,y=bh(i.containerInfo),D=g.focusedElem,U=g.selectionRange;if(y!==D&&D&&D.ownerDocument&&mu(D.ownerDocument.documentElement,D)){if(U!==null&&Ql(D)){var ue=U.start,Se=U.end;if(Se===void 0&&(Se=ue),"selectionStart"in D)D.selectionStart=ue,D.selectionEnd=Math.min(Se,D.value.length);else{var Ee=D.ownerDocument||document,fe=Ee&&Ee.defaultView||window;if(fe.getSelection){var _e=fe.getSelection(),Qe=D.textContent.length,ut=Math.min(U.start,Qe),un=U.end===void 0?ut:Math.min(U.end,Qe);!_e.extend&&ut>un&&(y=un,un=ut,ut=y);var ie=pu(D,ut),G=pu(D,un);if(ie&&G&&(_e.rangeCount!==1||_e.anchorNode!==ie.node||_e.anchorOffset!==ie.offset||_e.focusNode!==G.node||_e.focusOffset!==G.offset)){var ce=Ee.createRange();ce.setStart(ie.node,ie.offset),_e.removeAllRanges(),ut>un?(_e.addRange(ce),_e.extend(G.node,G.offset)):(ce.setEnd(G.node,G.offset),_e.addRange(ce))}}}}for(Ee=[],_e=D;_e=_e.parentNode;)_e.nodeType===1&&Ee.push({element:_e,left:_e.scrollLeft,top:_e.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<Ee.length;D++){var we=Ee[D];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}hf=!!xg,Cg=xg=null}finally{Yt=h,T.p=c,M.T=a}}i.current=r,ci=2}}function iw(){if(ci===2){ci=0;var i=ro,r=Sc,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=M.T,M.T=null;var c=T.p;T.p=2;var h=Yt;Yt|=4;try{M0(i,r.alternate,r)}finally{Yt=h,T.p=c,M.T=a}}ci=3}}function rw(){if(ci===4||ci===3){ci=0,Ue();var i=ro,r=Sc,a=fa,c=W0;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?ci=5:(ci=0,Sc=ro=null,sw(i,i.pendingLanes));var h=i.pendingLanes;if(h===0&&(io=null),ft(a),r=r.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(_n,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=M.T,h=T.p,T.p=2,M.T=null;try{for(var g=i.onRecoverableError,y=0;y<c.length;y++){var D=c[y];g(D.value,{componentStack:D.stack})}}finally{M.T=r,T.p=h}}(fa&3)!==0&&Jh(),Cs(i),h=i.pendingLanes,(a&261930)!==0&&(h&42)!==0?i===ug?qu++:(qu=0,ug=i):qu=0,Vu(0)}}function sw(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Eu(r)))}function Jh(){return nw(),iw(),rw(),aw()}function aw(){if(ci!==5)return!1;var i=ro,r=lg;lg=0;var a=ft(fa),c=M.T,h=T.p;try{T.p=32>a?32:a,M.T=null,a=cg,cg=null;var g=ro,y=fa;if(ci=0,Sc=ro=null,fa=0,(Yt&6)!==0)throw Error(s(331));var D=Yt;if(Yt|=4,U0(g.current),P0(g,g.current,y,a),Yt=D,Vu(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(_n,g)}catch{}return!0}finally{T.p=h,M.T=c,sw(i,r)}}function ow(i,r,a){r=tr(a,r),r=$m(i.stateNode,r,2),i=Za(i,r,2),i!==null&&(Jt(i,2),Cs(i))}function tn(i,r,a){if(i.tag===3)ow(i,i,a);else for(;r!==null;){if(r.tag===3){ow(r,i,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(io===null||!io.has(c))){i=tr(a,i),a=l0(2),c=Za(r,a,2),c!==null&&(c0(a,c,r,i),Jt(c,2),Cs(c));break}}r=r.return}}function fg(i,r,a){var c=i.pingCache;if(c===null){c=i.pingCache=new wR;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)||(sg=!0,h.add(a),i=ER.bind(null,i,r,a),r.then(i,i))}function ER(i,r,a){var c=i.pingCache;c!==null&&c.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,hn===i&&(Bt&a)===a&&(zn===4||zn===3&&(Bt&62914560)===Bt&&300>$e()-Vh?(Yt&2)===0&&wc(i,0):ag|=a,yc===Bt&&(yc=0)),Cs(i)}function lw(i,r){r===0&&(r=Ft()),i=ea(i,r),i!==null&&(Jt(i,r),Cs(i))}function RR(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),lw(i,a)}function NR(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),lw(i,a)}function DR(i,r){return Re(i,r)}var ef=null,Cc=null,pg=!1,tf=!1,mg=!1,ao=0;function Cs(i){i!==Cc&&i.next===null&&(Cc===null?ef=Cc=i:Cc=Cc.next=i),tf=!0,pg||(pg=!0,AR())}function Vu(i,r){if(!mg&&tf){mg=!0;do for(var a=!1,c=ef;c!==null;){if(i!==0){var h=c.pendingLanes;if(h===0)var g=0;else{var y=c.suspendedLanes,D=c.pingedLanes;g=(1<<31-Nt(42|i)+1)-1,g&=h&~(y&~D),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(a=!0,hw(c,g))}else g=Bt,g=bt(c,c===hn?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||Pt(c,g)||(a=!0,hw(c,g));c=c.next}while(a);mg=!1}}function MR(){cw()}function cw(){tf=pg=!1;var i=0;ao!==0&&$R()&&(i=ao);for(var r=$e(),a=null,c=ef;c!==null;){var h=c.next,g=uw(c,r);g===0?(c.next=null,a===null?ef=h:a.next=h,h===null&&(Cc=a)):(a=c,(i!==0||(g&3)!==0)&&(tf=!0)),c=h}ci!==0&&ci!==5||Vu(i),ao!==0&&(ao=0)}function uw(i,r){for(var a=i.suspendedLanes,c=i.pingedLanes,h=i.expirationTimes,g=i.pendingLanes&-62914561;0<g;){var y=31-Nt(g),D=1<<y,U=h[y];U===-1?((D&a)===0||(D&c)!==0)&&(h[y]=bn(D,r)):U<=r&&(i.expiredLanes|=D),g&=~D}if(r=hn,a=Bt,a=bt(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c=i.callbackNode,a===0||i===r&&(en===2||en===9)||i.cancelPendingCommit!==null)return c!==null&&c!==null&&je(c),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Pt(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(c!==null&&je(c),ft(a)){case 2:case 8:a=ct;break;case 32:a=ht;break;case 268435456:a=Qt;break;default:a=ht}return c=dw.bind(null,i),a=Re(a,c),i.callbackPriority=r,i.callbackNode=a,r}return c!==null&&c!==null&&je(c),i.callbackPriority=2,i.callbackNode=null,2}function dw(i,r){if(ci!==0&&ci!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Jh()&&i.callbackNode!==a)return null;var c=Bt;return c=bt(i,i===hn?c:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c===0?null:(q0(i,c,r),uw(i,$e()),i.callbackNode!=null&&i.callbackNode===a?dw.bind(null,i):null)}function hw(i,r){if(Jh())return null;q0(i,r,!0)}function AR(){WR(function(){(Yt&6)!==0?Re(ot,MR):cw()})}function gg(){if(ao===0){var i=cc;i===0&&(i=fn,fn<<=1,(fn&261888)===0&&(fn=256)),ao=i}return ao}function fw(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Hs(""+i)}function pw(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 LR(i,r,a,c,h){if(r==="submit"&&a&&a.stateNode===h){var g=fw((h[Xe]||null).action),y=c.submitter;y&&(r=(r=y[Xe]||null)?fw(r.formAction):y.getAttribute("formAction"),r!==null&&(g=r,y=null));var D=new mt("action","action",null,c,h);i.push({event:D,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(ao!==0){var U=y?pw(h,y):new FormData(h);Bm(a,{pending:!0,data:U,method:h.method,action:g},null,U)}}else typeof g=="function"&&(D.preventDefault(),U=y?pw(h,y):new FormData(h),Bm(a,{pending:!0,data:U,method:h.method,action:g},g,U))},currentTarget:h}]})}}for(var vg=0;vg<rl.length;vg++){var _g=rl[vg],jR=_g.toLowerCase(),OR=_g[0].toUpperCase()+_g.slice(1);$i(jR,"on"+OR)}$i(bu,"onAnimationEnd"),$i(ec,"onAnimationIteration"),$i(tc,"onAnimationStart"),$i("dblclick","onDoubleClick"),$i("focusin","onFocus"),$i("focusout","onBlur"),$i(dm,"onTransitionRun"),$i(nc,"onTransitionStart"),$i(ic,"onTransitionCancel"),$i(yu,"onTransitionEnd"),Mi("onMouseEnter",["mouseout","mouseover"]),Mi("onMouseLeave",["mouseout","mouseover"]),Mi("onPointerEnter",["pointerout","pointerover"]),Mi("onPointerLeave",["pointerout","pointerover"]),fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fr("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(" "),BR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yu));function mw(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 g=void 0;if(r)for(var y=c.length-1;0<=y;y--){var D=c[y],U=D.instance,ue=D.currentTarget;if(D=D.listener,U!==g&&h.isPropagationStopped())break e;g=D,h.currentTarget=ue;try{g(h)}catch(Se){Va(Se)}h.currentTarget=null,g=U}else for(y=0;y<c.length;y++){if(D=c[y],U=D.instance,ue=D.currentTarget,D=D.listener,U!==g&&h.isPropagationStopped())break e;g=D,h.currentTarget=ue;try{g(h)}catch(Se){Va(Se)}h.currentTarget=null,g=U}}}}function Lt(i,r){var a=r[nt];a===void 0&&(a=r[nt]=new Set);var c=i+"__bubble";a.has(c)||(gw(r,i,2,!1),a.add(c))}function bg(i,r,a){var c=0;r&&(c|=4),gw(a,i,c,r)}var nf="_reactListening"+Math.random().toString(36).slice(2);function yg(i){if(!i[nf]){i[nf]=!0,Zi.forEach(function(a){a!=="selectionchange"&&(BR.has(a)||bg(a,!1,i),bg(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[nf]||(r[nf]=!0,bg("selectionchange",!1,r))}}function gw(i,r,a,c){switch(Kw(r)){case 2:var h=uN;break;case 8:h=dN;break;default:h=Og}a=h.bind(null,r,a,i),h=void 0,!gs||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 Sg(i,r,a,c,h){var g=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 U=y.tag;if((U===3||U===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;D!==null;){if(y=Mn(D),y===null)return;if(U=y.tag,U===5||U===6||U===26||U===27){c=g=y;continue e}D=D.parentNode}}c=c.return}Ba(function(){var ue=g,Se=Mr(a),Ee=[];e:{var fe=yh.get(i);if(fe!==void 0){var _e=mt,Qe=i;switch(i){case"keypress":if(Lr(a)===0)break e;case"keydown":case"keyup":_e=Yo;break;case"focusin":Qe="focus",_e=Ui;break;case"focusout":Qe="blur",_e=Ui;break;case"beforeblur":case"afterblur":_e=Ui;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":_e=za;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":_e=cu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":_e=Go;break;case bu:case ec:case tc:_e=Ko;break;case yu:_e=Ys;break;case"scroll":case"scrollend":_e=Fo;break;case"wheel":_e=Xo;break;case"copy":case"cut":case"paste":_e=Vs;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":_e=ns;break;case"toggle":case"beforetoggle":_e=$a}var ut=(r&4)!==0,un=!ut&&(i==="scroll"||i==="scrollend"),ie=ut?fe!==null?fe+"Capture":null:fe;ut=[];for(var G=ue,ce;G!==null;){var we=G;if(ce=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||ce===null||ie===null||(we=$s(G,ie),we!=null&&ut.push(Gu(G,we,ce))),un)break;G=G.return}0<ut.length&&(fe=new _e(fe,Qe,null,a,Se),Ee.push({event:fe,listeners:ut}))}}if((r&7)===0){e:{if(fe=i==="mouseover"||i==="pointerover",_e=i==="mouseout"||i==="pointerout",fe&&a!==on&&(Qe=a.relatedTarget||a.fromElement)&&(Mn(Qe)||Qe[qe]))break e;if((_e||fe)&&(fe=Se.window===Se?Se:(fe=Se.ownerDocument)?fe.defaultView||fe.parentWindow:window,_e?(Qe=a.relatedTarget||a.toElement,_e=ue,Qe=Qe?Mn(Qe):null,Qe!==null&&(un=l(Qe),ut=Qe.tag,Qe!==un||ut!==5&&ut!==27&&ut!==6)&&(Qe=null)):(_e=null,Qe=ue),_e!==Qe)){if(ut=za,we="onMouseLeave",ie="onMouseEnter",G="mouse",(i==="pointerout"||i==="pointerover")&&(ut=ns,we="onPointerLeave",ie="onPointerEnter",G="pointer"),un=_e==null?fe:hr(_e),ce=Qe==null?fe:hr(Qe),fe=new ut(we,G+"leave",_e,a,Se),fe.target=un,fe.relatedTarget=ce,we=null,Mn(Se)===ue&&(ut=new ut(ie,G+"enter",Qe,a,Se),ut.target=ce,ut.relatedTarget=un,we=ut),un=we,_e&&Qe)t:{for(ut=IR,ie=_e,G=Qe,ce=0,we=ie;we;we=ut(we))ce++;we=0;for(var at=G;at;at=ut(at))we++;for(;0<ce-we;)ie=ut(ie),ce--;for(;0<we-ce;)G=ut(G),we--;for(;ce--;){if(ie===G||G!==null&&ie===G.alternate){ut=ie;break t}ie=ut(ie),G=ut(G)}ut=null}else ut=null;_e!==null&&vw(Ee,fe,_e,ut,!1),Qe!==null&&un!==null&&vw(Ee,un,Qe,ut,!0)}}e:{if(fe=ue?hr(ue):window,_e=fe.nodeName&&fe.nodeName.toLowerCase(),_e==="select"||_e==="input"&&fe.type==="file")var Kt=Qo;else if(_t(fe))if(Xs)Kt=_h;else{Kt=nl;var tt=vh}else _e=fe.nodeName,!_e||_e.toLowerCase()!=="input"||fe.type!=="checkbox"&&fe.type!=="radio"?ue&&Ai(ue.elementType)&&(Kt=Qo):Kt=Wa;if(Kt&&(Kt=Kt(i,ue))){Cn(Ee,Kt,a,Se);break e}tt&&tt(i,fe,ue),i==="focusout"&&ue&&fe.type==="number"&&ue.memoizedProps.value!=null&&Nr(fe,"number",fe.value)}switch(tt=ue?hr(ue):window,i){case"focusin":(_t(tt)||tt.contentEditable==="true")&&(_s=tt,gu=ue,Br=null);break;case"focusout":Br=gu=_s=null;break;case"mousedown":qa=!0;break;case"contextmenu":case"mouseup":case"dragend":qa=!1,vu(Ee,a,Se);break;case"selectionchange":if(Or)break;case"keydown":case"keyup":vu(Ee,a,Se)}var Ct;if(rs)e:{switch(i){case"compositionstart":var It="onCompositionStart";break e;case"compositionend":It="onCompositionEnd";break e;case"compositionupdate":It="onCompositionUpdate";break e}It=void 0}else Te?ae(i,a)&&(It="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(It="onCompositionStart");It&&(E&&a.locale!=="ko"&&(Te||It!=="onCompositionStart"?It==="onCompositionEnd"&&Te&&(Ct=Ia()):(Ji=Se,Ws="value"in Ji?Ji.value:Ji.textContent,Te=!0)),tt=rf(ue,It),0<tt.length&&(It=new ji(It,i,null,a,Se),Ee.push({event:It,listeners:tt}),Ct?It.data=Ct:(Ct=le(a),Ct!==null&&(It.data=Ct)))),(Ct=C?Ie(i,a):Ve(i,a))&&(It=rf(ue,"onBeforeInput"),0<It.length&&(tt=new ji("onBeforeInput","beforeinput",null,a,Se),Ee.push({event:tt,listeners:It}),tt.data=Ct)),LR(Ee,i,ue,a,Se)}mw(Ee,r)})}function Gu(i,r,a){return{instance:i,listener:r,currentTarget:a}}function rf(i,r){for(var a=r+"Capture",c=[];i!==null;){var h=i,g=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||g===null||(h=$s(i,a),h!=null&&c.unshift(Gu(i,h,g)),h=$s(i,r),h!=null&&c.push(Gu(i,h,g))),i.tag===3)return c;i=i.return}return[]}function IR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function vw(i,r,a,c,h){for(var g=r._reactName,y=[];a!==null&&a!==c;){var D=a,U=D.alternate,ue=D.stateNode;if(D=D.tag,U!==null&&U===c)break;D!==5&&D!==26&&D!==27||ue===null||(U=ue,h?(ue=$s(a,g),ue!=null&&y.unshift(Gu(a,ue,U))):h||(ue=$s(a,g),ue!=null&&y.push(Gu(a,ue,U)))),a=a.return}y.length!==0&&i.push({event:r,listeners:y})}var PR=/\r\n?/g,zR=/\u0000|\uFFFD/g;function _w(i){return(typeof i=="string"?i:""+i).replace(PR,`
|
|
10
|
-
`).replace(zR,"")}function bw(i,r){return r=_w(r),_w(i)===r}function cn(i,r,a,c,h,g){switch(a){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||Jr(i,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&Jr(i,""+c);break;case"className":pr(i,"class",c);break;case"tabIndex":pr(i,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":pr(i,a,c);break;case"style":Kl(i,c,g);break;case"data":if(r!=="object"){pr(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=Hs(""+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 g=="function"&&(a==="formAction"?(r!=="input"&&cn(i,r,"name",h.name,h,null),cn(i,r,"formEncType",h.formEncType,h,null),cn(i,r,"formMethod",h.formMethod,h,null),cn(i,r,"formTarget",h.formTarget,h,null)):(cn(i,r,"encType",h.encType,h,null),cn(i,r,"method",h.method,h,null),cn(i,r,"target",h.target,h,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){i.removeAttribute(a);break}c=Hs(""+c),i.setAttribute(a,c);break;case"onClick":c!=null&&(i.onclick=Li);break;case"onScroll":c!=null&&Lt("scroll",i);break;case"onScrollEnd":c!=null&&Lt("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=Hs(""+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":Lt("beforetoggle",i),Lt("toggle",i),Bs(i,"popover",c);break;case"xlinkActuate":ri(i,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":ri(i,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":ri(i,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":ri(i,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":ri(i,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":ri(i,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":ri(i,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":ri(i,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":ri(i,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Bs(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=ql.get(a)||a,Bs(i,a,c))}}function wg(i,r,a,c,h,g){switch(a){case"style":Kl(i,c,g);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"?Jr(i,c):(typeof c=="number"||typeof c=="bigint")&&Jr(i,""+c);break;case"onScroll":c!=null&&Lt("scroll",i);break;case"onScrollEnd":c!=null&&Lt("scrollend",i);break;case"onClick":c!=null&&(i.onclick=Li);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ms.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),r=a.slice(2,h?a.length-7:void 0),g=i[Xe]||null,g=g!=null?g[a]:null,typeof g=="function"&&i.removeEventListener(r,g,h),typeof c=="function")){typeof g!="function"&&g!==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,""):Bs(i,a,c)}}}function Ri(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Lt("error",i),Lt("load",i);var c=!1,h=!1,g;for(g in a)if(a.hasOwnProperty(g)){var y=a[g];if(y!=null)switch(g){case"src":c=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:cn(i,r,g,y,a,null)}}h&&cn(i,r,"srcSet",a.srcSet,a,null),c&&cn(i,r,"src",a.src,a,null);return;case"input":Lt("invalid",i);var D=g=y=h=null,U=null,ue=null;for(c in a)if(a.hasOwnProperty(c)){var Se=a[c];if(Se!=null)switch(c){case"name":h=Se;break;case"type":y=Se;break;case"checked":U=Se;break;case"defaultChecked":ue=Se;break;case"value":g=Se;break;case"defaultValue":D=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(s(137,r));break;default:cn(i,r,c,Se,a,null)}}Wl(i,g,D,U,ue,y,h,!1);return;case"select":Lt("invalid",i),c=y=g=null;for(h in a)if(a.hasOwnProperty(h)&&(D=a[h],D!=null))switch(h){case"value":g=D;break;case"defaultValue":y=D;break;case"multiple":c=D;default:cn(i,r,h,D,a,null)}r=g,a=y,i.multiple=!!c,r!=null?Dr(i,!!c,r,!1):a!=null&&Dr(i,!!c,a,!0);return;case"textarea":Lt("invalid",i),g=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":g=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(s(91));break;default:cn(i,r,y,D,a,null)}Uo(i,c,h,g);return;case"option":for(U in a)a.hasOwnProperty(U)&&(c=a[U],c!=null)&&(U==="selected"?i.selected=c&&typeof c!="function"&&typeof c!="symbol":cn(i,r,U,c,a,null));return;case"dialog":Lt("beforetoggle",i),Lt("toggle",i),Lt("cancel",i),Lt("close",i);break;case"iframe":case"object":Lt("load",i);break;case"video":case"audio":for(c=0;c<Yu.length;c++)Lt(Yu[c],i);break;case"image":Lt("error",i),Lt("load",i);break;case"details":Lt("toggle",i);break;case"embed":case"source":case"link":Lt("error",i),Lt("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(ue in a)if(a.hasOwnProperty(ue)&&(c=a[ue],c!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:cn(i,r,ue,c,a,null)}return;default:if(Ai(r)){for(Se in a)a.hasOwnProperty(Se)&&(c=a[Se],c!==void 0&&wg(i,r,Se,c,a,void 0));return}}for(D in a)a.hasOwnProperty(D)&&(c=a[D],c!=null&&cn(i,r,D,c,a,null))}function HR(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,g=null,y=null,D=null,U=null,ue=null,Se=null;for(_e in a){var Ee=a[_e];if(a.hasOwnProperty(_e)&&Ee!=null)switch(_e){case"checked":break;case"value":break;case"defaultValue":U=Ee;default:c.hasOwnProperty(_e)||cn(i,r,_e,null,c,Ee)}}for(var fe in c){var _e=c[fe];if(Ee=a[fe],c.hasOwnProperty(fe)&&(_e!=null||Ee!=null))switch(fe){case"type":g=_e;break;case"name":h=_e;break;case"checked":ue=_e;break;case"defaultChecked":Se=_e;break;case"value":y=_e;break;case"defaultValue":D=_e;break;case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(s(137,r));break;default:_e!==Ee&&cn(i,r,fe,_e,c,Ee)}}Ps(i,y,D,U,ue,Se,g,h);return;case"select":_e=y=D=fe=null;for(g in a)if(U=a[g],a.hasOwnProperty(g)&&U!=null)switch(g){case"value":break;case"multiple":_e=U;default:c.hasOwnProperty(g)||cn(i,r,g,null,c,U)}for(h in c)if(g=c[h],U=a[h],c.hasOwnProperty(h)&&(g!=null||U!=null))switch(h){case"value":fe=g;break;case"defaultValue":D=g;break;case"multiple":y=g;default:g!==U&&cn(i,r,h,g,c,U)}r=D,a=y,c=_e,fe!=null?Dr(i,!!a,fe,!1):!!c!=!!a&&(r!=null?Dr(i,!!a,r,!0):Dr(i,!!a,a?[]:"",!1));return;case"textarea":_e=fe=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:cn(i,r,D,null,c,h)}for(y in c)if(h=c[y],g=a[y],c.hasOwnProperty(y)&&(h!=null||g!=null))switch(y){case"value":fe=h;break;case"defaultValue":_e=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(s(91));break;default:h!==g&&cn(i,r,y,h,c,g)}Oa(i,fe,_e);return;case"option":for(var Qe in a)fe=a[Qe],a.hasOwnProperty(Qe)&&fe!=null&&!c.hasOwnProperty(Qe)&&(Qe==="selected"?i.selected=!1:cn(i,r,Qe,null,c,fe));for(U in c)fe=c[U],_e=a[U],c.hasOwnProperty(U)&&fe!==_e&&(fe!=null||_e!=null)&&(U==="selected"?i.selected=fe&&typeof fe!="function"&&typeof fe!="symbol":cn(i,r,U,fe,c,_e));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 ut in a)fe=a[ut],a.hasOwnProperty(ut)&&fe!=null&&!c.hasOwnProperty(ut)&&cn(i,r,ut,null,c,fe);for(ue in c)if(fe=c[ue],_e=a[ue],c.hasOwnProperty(ue)&&fe!==_e&&(fe!=null||_e!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(137,r));break;default:cn(i,r,ue,fe,c,_e)}return;default:if(Ai(r)){for(var un in a)fe=a[un],a.hasOwnProperty(un)&&fe!==void 0&&!c.hasOwnProperty(un)&&wg(i,r,un,void 0,c,fe);for(Se in c)fe=c[Se],_e=a[Se],!c.hasOwnProperty(Se)||fe===_e||fe===void 0&&_e===void 0||wg(i,r,Se,fe,c,_e);return}}for(var ie in a)fe=a[ie],a.hasOwnProperty(ie)&&fe!=null&&!c.hasOwnProperty(ie)&&cn(i,r,ie,null,c,fe);for(Ee in c)fe=c[Ee],_e=a[Ee],!c.hasOwnProperty(Ee)||fe===_e||fe==null&&_e==null||cn(i,r,Ee,fe,c,_e)}function yw(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function UR(){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],g=h.transferSize,y=h.initiatorType,D=h.duration;if(g&&D&&yw(y)){for(y=0,D=h.responseEnd,c+=1;c<a.length;c++){var U=a[c],ue=U.startTime;if(ue>D)break;var Se=U.transferSize,Ee=U.initiatorType;Se&&yw(Ee)&&(U=U.responseEnd,y+=Se*(U<D?1:(D-ue)/(U-ue)))}if(--c,r+=8*(g+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 xg=null,Cg=null;function sf(i){return i.nodeType===9?i:i.ownerDocument}function Sw(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 ww(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 kg(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 Tg=null;function $R(){var i=window.event;return i&&i.type==="popstate"?i===Tg?!1:(Tg=i,!0):(Tg=null,!1)}var xw=typeof setTimeout=="function"?setTimeout:void 0,FR=typeof clearTimeout=="function"?clearTimeout:void 0,Cw=typeof Promise=="function"?Promise:void 0,WR=typeof queueMicrotask=="function"?queueMicrotask:typeof Cw<"u"?function(i){return Cw.resolve(null).then(i).catch(KR)}:xw;function KR(i){setTimeout(function(){throw i})}function oo(i){return i==="head"}function kw(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),Rc(r);return}c--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")c++;else if(a==="html")Xu(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Xu(a);for(var g=a.firstChild;g;){var y=g.nextSibling,D=g.nodeName;g[Xt]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&g.rel.toLowerCase()==="stylesheet"||a.removeChild(g),g=y}}else a==="body"&&Xu(i.ownerDocument.body);a=h}while(a);Rc(r)}function Tw(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 Eg(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":Eg(a),Xi(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function qR(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[Xt])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(g=i.getAttribute("rel"),g==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(g!==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(g=i.getAttribute("src"),(g!==(h.src==null?null:h.src)||i.getAttribute("type")!==(h.type==null?null:h.type)||i.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&g&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var g=h.name==null?null:""+h.name;if(h.type==="hidden"&&i.getAttribute("name")===g)return i}else return i;if(i=$r(i.nextSibling),i===null)break}return null}function VR(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=$r(i.nextSibling),i===null))return null;return i}function Ew(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=$r(i.nextSibling),i===null))return null;return i}function Rg(i){return i.data==="$?"||i.data==="$~"}function Ng(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function YR(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 $r(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 Dg=null;function Rw(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return $r(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function Nw(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 Dw(i,r,a){switch(r=sf(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 Xu(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Xi(i)}var Fr=new Map,Mw=new Set;function af(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var pa=T.d;T.d={f:GR,r:XR,D:ZR,C:QR,L:JR,m:eN,X:nN,S:tN,M:iN};function GR(){var i=pa.f(),r=Xh();return i||r}function XR(i){var r=Bn(i);r!==null&&r.tag===5&&r.type==="form"?YS(r):pa.r(i)}var kc=typeof document>"u"?null:document;function Aw(i,r,a){var c=kc;if(c&&typeof r=="string"&&r){var h=mi(r);h='link[rel="'+i+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),Mw.has(h)||(Mw.add(h),i={rel:i,crossOrigin:a,href:r},c.querySelector(h)===null&&(r=c.createElement("link"),Ri(r,"link",i),an(r),c.head.appendChild(r)))}}function ZR(i){pa.D(i),Aw("dns-prefetch",i,null)}function QR(i,r){pa.C(i,r),Aw("preconnect",i,r)}function JR(i,r,a){pa.L(i,r,a);var c=kc;if(c&&i&&r){var h='link[rel="preload"][as="'+mi(r)+'"]';r==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+mi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+mi(a.imageSizes)+'"]')):h+='[href="'+mi(i)+'"]';var g=h;switch(r){case"style":g=Tc(i);break;case"script":g=Ec(i)}Fr.has(g)||(i=_({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),Fr.set(g,i),c.querySelector(h)!==null||r==="style"&&c.querySelector(Zu(g))||r==="script"&&c.querySelector(Qu(g))||(r=c.createElement("link"),Ri(r,"link",i),an(r),c.head.appendChild(r)))}}function eN(i,r){pa.m(i,r);var a=kc;if(a&&i){var c=r&&typeof r.as=="string"?r.as:"script",h='link[rel="modulepreload"][as="'+mi(c)+'"][href="'+mi(i)+'"]',g=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ec(i)}if(!Fr.has(g)&&(i=_({rel:"modulepreload",href:i},r),Fr.set(g,i),a.querySelector(h)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Qu(g)))return}c=a.createElement("link"),Ri(c,"link",i),an(c),a.head.appendChild(c)}}}function tN(i,r,a){pa.S(i,r,a);var c=kc;if(c&&i){var h=Ci(c).hoistableStyles,g=Tc(i);r=r||"default";var y=h.get(g);if(!y){var D={loading:0,preload:null};if(y=c.querySelector(Zu(g)))D.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},a),(a=Fr.get(g))&&Mg(i,a);var U=y=c.createElement("link");an(U),Ri(U,"link",i),U._p=new Promise(function(ue,Se){U.onload=ue,U.onerror=Se}),U.addEventListener("load",function(){D.loading|=1}),U.addEventListener("error",function(){D.loading|=2}),D.loading|=4,of(y,r,c)}y={type:"stylesheet",instance:y,count:1,state:D},h.set(g,y)}}}function nN(i,r){pa.X(i,r);var a=kc;if(a&&i){var c=Ci(a).hoistableScripts,h=Ec(i),g=c.get(h);g||(g=a.querySelector(Qu(h)),g||(i=_({src:i,async:!0},r),(r=Fr.get(h))&&Ag(i,r),g=a.createElement("script"),an(g),Ri(g,"link",i),a.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function iN(i,r){pa.M(i,r);var a=kc;if(a&&i){var c=Ci(a).hoistableScripts,h=Ec(i),g=c.get(h);g||(g=a.querySelector(Qu(h)),g||(i=_({src:i,async:!0,type:"module"},r),(r=Fr.get(h))&&Ag(i,r),g=a.createElement("script"),an(g),Ri(g,"link",i),a.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function Lw(i,r,a,c){var h=(h=ye.current)?af(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=Tc(a.href),a=Ci(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=Tc(a.href);var g=Ci(h).hoistableStyles,y=g.get(i);if(y||(h=h.ownerDocument||h,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(i,y),(g=h.querySelector(Zu(i)))&&!g._p&&(y.instance=g,y.state.loading=5),Fr.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},Fr.set(i,a),g||rN(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=Ec(a),a=Ci(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 Tc(i){return'href="'+mi(i)+'"'}function Zu(i){return'link[rel="stylesheet"]['+i+"]"}function jw(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function rN(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}),Ri(r,"link",a),an(r),i.head.appendChild(r))}function Ec(i){return'[src="'+mi(i)+'"]'}function Qu(i){return"script[async]"+i}function Ow(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var c=i.querySelector('style[data-href~="'+mi(a.href)+'"]');if(c)return r.instance=c,an(c),c;var h=_({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),an(c),Ri(c,"style",h),of(c,a.precedence,i),r.instance=c;case"stylesheet":h=Tc(a.href);var g=i.querySelector(Zu(h));if(g)return r.state.loading|=4,r.instance=g,an(g),g;c=jw(a),(h=Fr.get(h))&&Mg(c,h),g=(i.ownerDocument||i).createElement("link"),an(g);var y=g;return y._p=new Promise(function(D,U){y.onload=D,y.onerror=U}),Ri(g,"link",c),r.state.loading|=4,of(g,a.precedence,i),r.instance=g;case"script":return g=Ec(a.src),(h=i.querySelector(Qu(g)))?(r.instance=h,an(h),h):(c=a,(h=Fr.get(g))&&(c=_({},a),Ag(c,h)),i=i.ownerDocument||i,h=i.createElement("script"),an(h),Ri(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,of(c,a.precedence,i));return r.instance}function of(i,r,a){for(var c=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=c.length?c[c.length-1]:null,g=h,y=0;y<c.length;y++){var D=c[y];if(D.dataset.precedence===r)g=D;else if(g!==h)break}g?g.parentNode.insertBefore(i,g.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function Mg(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Ag(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var lf=null;function Bw(i,r,a){if(lf===null){var c=new Map,h=lf=new Map;h.set(a,c)}else h=lf,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 g=a[h];if(!(g[Xt]||g[ke]||i==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var y=g.getAttribute(r)||"";y=i+y;var D=c.get(y);D?D.push(g):c.set(y,[g])}}return c}function Iw(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function sN(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 Pw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function aN(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=Tc(c.href),g=r.querySelector(Zu(h));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=cf.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=g,an(g);return}g=r.ownerDocument||r,c=jw(c),(h=Fr.get(h))&&Mg(c,h),g=g.createElement("link"),an(g);var y=g;y._p=new Promise(function(D,U){y.onload=D,y.onerror=U}),Ri(g,"link",c),a.instance=g}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=cf.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Lg=0;function oN(i,r){return i.stylesheets&&i.count===0&&df(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var c=setTimeout(function(){if(i.stylesheets&&df(i,i.stylesheets),i.unsuspend){var g=i.unsuspend;i.unsuspend=null,g()}},6e4+r);0<i.imgBytes&&Lg===0&&(Lg=62500*UR());var h=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&df(i,i.stylesheets),i.unsuspend)){var g=i.unsuspend;i.unsuspend=null,g()}},(i.imgBytes>Lg?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(h)}}:null}function cf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)df(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var uf=null;function df(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,uf=new Map,r.forEach(lN,i),uf=null,cf.call(i))}function lN(i,r){if(!(r.state.loading&4)){var a=uf.get(i);if(a)var c=a.get(null);else{a=new Map,uf.set(i,a);for(var h=i.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<h.length;g++){var y=h[g];(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"),g=a.get(y)||c,g===c&&a.set(null,h),a.set(y,h),this.count++,c=cf.bind(this),h.addEventListener("load",c),h.addEventListener("error",c),g?g.parentNode.insertBefore(h,g.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(h,i.firstChild)),r.state.loading|=4}}var Ju={$$typeof:z,Provider:null,Consumer:null,_currentValue:O,_currentValue2:O,_threadCount:0};function cN(i,r,a,c,h,g,y,D,U){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=pn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pn(0),this.hiddenUpdates=pn(null),this.identifierPrefix=c,this.onUncaughtError=h,this.onCaughtError=g,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=U,this.incompleteTransitions=new Map}function zw(i,r,a,c,h,g,y,D,U,ue,Se,Ee){return i=new cN(i,r,a,y,U,ue,Se,Ee,D),r=1,g===!0&&(r|=24),g=Oi(3,null,null,r),i.current=g,g.stateNode=i,r=hm(),r.refCount++,i.pooledCache=r,r.refCount++,g.memoizedState={element:c,isDehydrated:a,cache:r},gm(g),i}function Hw(i){return i?(i=ta,i):ta}function Uw(i,r,a,c,h,g){h=Hw(h),c.context===null?c.context=h:c.pendingContext=h,c=Xa(r),c.payload={element:a},g=g===void 0?null:g,g!==null&&(c.callback=g),a=Za(i,c,r),a!==null&&(lr(a,i,r),Mu(a,i,r))}function $w(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function jg(i,r){$w(i,r),(i=i.alternate)&&$w(i,r)}function Fw(i){if(i.tag===13||i.tag===31){var r=ea(i,67108864);r!==null&&lr(r,i,67108864),jg(i,67108864)}}function Ww(i){if(i.tag===13||i.tag===31){var r=xr();r=rn(r);var a=ea(i,r);a!==null&&lr(a,i,r),jg(i,r)}}var hf=!0;function uN(i,r,a,c){var h=M.T;M.T=null;var g=T.p;try{T.p=2,Og(i,r,a,c)}finally{T.p=g,M.T=h}}function dN(i,r,a,c){var h=M.T;M.T=null;var g=T.p;try{T.p=8,Og(i,r,a,c)}finally{T.p=g,M.T=h}}function Og(i,r,a,c){if(hf){var h=Bg(c);if(h===null)Sg(i,r,c,ff,a),qw(i,c);else if(fN(h,i,r,a,c))c.stopPropagation();else if(qw(i,c),r&4&&-1<hN.indexOf(i)){for(;h!==null;){var g=Bn(h);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var y=et(g.pendingLanes);if(y!==0){var D=g;for(D.pendingLanes|=2,D.entangledLanes|=2;y;){var U=1<<31-Nt(y);D.entanglements[1]|=U,y&=~U}Cs(g),(Yt&6)===0&&(Yh=$e()+500,Vu(0))}}break;case 31:case 13:D=ea(g,2),D!==null&&lr(D,g,2),Xh(),jg(g,2)}if(g=Bg(c),g===null&&Sg(i,r,c,ff,a),g===h)break;h=g}h!==null&&c.stopPropagation()}else Sg(i,r,c,null,a)}}function Bg(i){return i=Mr(i),Ig(i)}var ff=null;function Ig(i){if(ff=null,i=Mn(i),i!==null){var r=l(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=d(r),i!==null)return i;i=null}else if(a===31){if(i=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 ff=i,null}function Kw(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(Be()){case ot:return 2;case ct:return 8;case ht:case jt:return 32;case Qt:return 268435456;default:return 32}default:return 32}}var Pg=!1,lo=null,co=null,uo=null,ed=new Map,td=new Map,ho=[],hN="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 qw(i,r){switch(i){case"focusin":case"focusout":lo=null;break;case"dragenter":case"dragleave":co=null;break;case"mouseover":case"mouseout":uo=null;break;case"pointerover":case"pointerout":ed.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":td.delete(r.pointerId)}}function nd(i,r,a,c,h,g){return i===null||i.nativeEvent!==g?(i={blockedOn:r,domEventName:a,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},r!==null&&(r=Bn(r),r!==null&&Fw(r)),i):(i.eventSystemFlags|=c,r=i.targetContainers,h!==null&&r.indexOf(h)===-1&&r.push(h),i)}function fN(i,r,a,c,h){switch(r){case"focusin":return lo=nd(lo,i,r,a,c,h),!0;case"dragenter":return co=nd(co,i,r,a,c,h),!0;case"mouseover":return uo=nd(uo,i,r,a,c,h),!0;case"pointerover":var g=h.pointerId;return ed.set(g,nd(ed.get(g)||null,i,r,a,c,h)),!0;case"gotpointercapture":return g=h.pointerId,td.set(g,nd(td.get(g)||null,i,r,a,c,h)),!0}return!1}function Vw(i){var r=Mn(i.target);if(r!==null){var a=l(r);if(a!==null){if(r=a.tag,r===13){if(r=d(a),r!==null){i.blockedOn=r,wn(i.priority,function(){Ww(a)});return}}else if(r===31){if(r=f(a),r!==null){i.blockedOn=r,wn(i.priority,function(){Ww(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 pf(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=Bg(i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);on=c,a.target.dispatchEvent(c),on=null}else return r=Bn(a),r!==null&&Fw(r),i.blockedOn=a,!1;r.shift()}return!0}function Yw(i,r,a){pf(i)&&a.delete(r)}function pN(){Pg=!1,lo!==null&&pf(lo)&&(lo=null),co!==null&&pf(co)&&(co=null),uo!==null&&pf(uo)&&(uo=null),ed.forEach(Yw),td.forEach(Yw)}function mf(i,r){i.blockedOn===r&&(i.blockedOn=null,Pg||(Pg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,pN)))}var gf=null;function Gw(i){gf!==i&&(gf=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){gf===i&&(gf=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(Ig(c||a)===null)continue;break}var g=Bn(a);g!==null&&(i.splice(r,3),r-=3,Bm(g,{pending:!0,data:h,method:a.method,action:c},c,h))}}))}function Rc(i){function r(U){return mf(U,i)}lo!==null&&mf(lo,i),co!==null&&mf(co,i),uo!==null&&mf(uo,i),ed.forEach(r),td.forEach(r);for(var a=0;a<ho.length;a++){var c=ho[a];c.blockedOn===i&&(c.blockedOn=null)}for(;0<ho.length&&(a=ho[0],a.blockedOn===null);)Vw(a),a.blockedOn===null&&ho.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(c=0;c<a.length;c+=3){var h=a[c],g=a[c+1],y=h[Xe]||null;if(typeof g=="function")y||Gw(a);else if(y){var D=null;if(g&&g.hasAttribute("formAction")){if(h=g,y=g[Xe]||null)D=y.formAction;else if(Ig(h)!==null)continue}else D=y.action;typeof D=="function"?a[c+1]=D:(a.splice(c,3),c-=3),Gw(a)}}}function Xw(){function i(g){g.canIntercept&&g.info==="react-transition"&&g.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 g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.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 zg(i){this._internalRoot=i}vf.prototype.render=zg.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,c=xr();Uw(a,c,i,r,null,null)},vf.prototype.unmount=zg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Uw(i.current,2,null,i,null,null),Xh(),r[qe]=null}};function vf(i){this._internalRoot=i}vf.prototype.unstable_scheduleHydration=function(i){if(i){var r=wt();i={blockedOn:null,target:i,priority:r};for(var a=0;a<ho.length&&r!==0&&r<ho[a].priority;a++);ho.splice(a,0,i),a===0&&Vw(i)}};var Zw=t.version;if(Zw!=="19.2.6")throw Error(s(527,Zw,"19.2.6"));T.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 mN={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _f=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_f.isDisabled&&_f.supportsFiber)try{_n=_f.inject(mN),pt=_f}catch{}}return rd.createRoot=function(i,r){if(!o(i))throw Error(s(299));var a=!1,c="",h=r0,g=s0,y=a0;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&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(y=r.onRecoverableError)),r=zw(i,1,!1,null,null,a,c,null,h,g,y,Xw),i[qe]=r.current,yg(i),new zg(r)},rd.hydrateRoot=function(i,r,a){if(!o(i))throw Error(s(299));var c=!1,h="",g=r0,y=s0,D=a0,U=null;return a!=null&&(a.unstable_strictMode===!0&&(c=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onUncaughtError!==void 0&&(g=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(D=a.onRecoverableError),a.formState!==void 0&&(U=a.formState)),r=zw(i,1,!0,r,a??null,c,h,U,g,y,D,Xw),r.context=Hw(null),a=r.current,c=xr(),c=rn(c),h=Xa(c),h.callback=null,Za(a,h,c),a=c,r.current.lanes=a,Jt(r,a),Cs(r),i[qe]=r.current,yg(i),new vf(r)},rd.version="19.2.6",rd}var o1;function kN(){if(o1)return $g.exports;o1=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(),$g.exports=CN(),$g.exports}var TN=kN();class vl extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function VC(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 d=!1;const f=()=>{e.signal?.removeEventListener("abort",b)},m=_=>{d||(d=!0,f(),o(_))},p=_=>{d||(d=!0,f(),l(_))},b=()=>{t.abort(),p(new vl(0,"Upload aborted."))};if(e.signal?.aborted){p(new vl(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{m(JSON.parse(t.responseText))}catch{p(new vl(t.status,"Invalid upload response."))}return}p(new vl(t.status,EN(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new vl(0,"Upload failed.")),t.onabort=()=>p(new vl(0,"Upload aborted.")),t.ontimeout=()=>p(new vl(0,"Upload timed out.")),t.send(n)})}function EN(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 Vn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Ip(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${Ns(t)}`),setupPassword:t=>De(e,"/api/auth/password",it("POST",t)),login:t=>De(e,"/api/auth/login",it("POST",t)),reauth:t=>De(e,"/api/auth/reauth",it("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Ac(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await Ac(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",it("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await Ac(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${Ns(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),getFavorites:()=>De(e,"/api/favorites"),saveFavorites:t=>De(e,"/api/favorites",it("PUT",t)),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",it("POST",t)),listFiles:t=>De(e,"/api/files/list",it("POST",t)),readFile:t=>De(e,"/api/files/read",it("POST",t)),writeFile:t=>De(e,"/api/files/write",it("POST",t)),createFileEntry:t=>De(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",it("POST",t)),previewFile:t=>YC(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await Ac(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${Ns(n)}`),getTerminalTranscriptHistory:(t,n={},s)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Ns(n)}`,s?{signal:s}:void 0),searchTerminalTranscript:(t,n,s)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-search`,{...it("POST",n),...s?{signal:s}:{}}),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,s={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${Ns(s)}`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await Ac(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?Ns({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",it("POST",t))}}function Rs(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{transcriptCacheScope:e?`agent:${e}`:"local",isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(s={})=>De(t,n("terminals"),it("POST",s)),closeTerminal:async s=>{await Ac(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,o)=>De(t,n(`terminals/${encodeURIComponent(s)}`),it("PATCH",{title:o})),getTerminalHistory:(s,o={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${Ns(o)}`),getTerminalTranscriptHistory:(s,o={},l)=>De(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${Ns(o)}`,l?{signal:l}:void 0),searchTerminalTranscript:(s,o,l)=>De(t,n(`terminals/${encodeURIComponent(s)}/transcript-search`),{...it("POST",o),...l?{signal:l}:{}}),getTerminalTranscriptSource:s=>De(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalSubagents:s=>De(t,n(`terminals/${encodeURIComponent(s)}/subagents`)),getTerminalSubagentTranscriptHistory:(s,o,l={})=>De(t,`${n(`terminals/${encodeURIComponent(s)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${Ns(l)}`),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:s=>De(t,n("terminal-layout"),it("PUT",s)),createFileRoot:s=>De(t,n("files/root"),it("POST",s)),listFiles:s=>De(t,n("files/list"),it("POST",s)),readFile:s=>De(t,n("files/read"),it("POST",s)),writeFile:s=>De(t,n("files/write"),it("POST",s)),createFileEntry:s=>De(t,n("files/create"),it("POST",s)),moveFileEntry:s=>De(t,n("files/move"),it("POST",s)),previewDeleteFileEntry:s=>De(t,n("files/delete-preview"),it("POST",s)),deleteFileEntry:s=>De(t,n("files/delete"),it("POST",s)),openFileInTerminal:s=>De(t,n("files/open"),it("POST",s)),previewFile:s=>YC(t,n("files/preview"),it("POST",s)),uploadComposeAttachments:s=>VC({...s,endpoint:n("attachments")}),getComposeAttachmentLimits:s=>De(t,n("attachments/limits"),s?{credentials:"same-origin",signal:s}:void 0),deleteComposeAttachments:s=>De(t,n("attachments/delete"),it("POST",s)),getCodeServerStatus:(s={})=>De(t,`${n("code-server/status")}${Ns(s)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:s=>De(t,n("code-server/open"),it("POST",s)),stopCodeServer:(s={})=>De(t,n("code-server/stop"),it("POST",s)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getProviderHooks:s=>De(t,n(`hooks/${s}`)),installProviderHooks:s=>De(t,n(`hooks/${s}/install`),{method:"POST",credentials:"same-origin"}),removeProviderHooks:s=>De(t,n(`hooks/${s}/remove`),{method:"POST",credentials:"same-origin"}),checkProviderHookTrust:s=>De(t,n(`hooks/${s}/trust`)),trustProviderHooks:s=>De(t,n(`hooks/${s}/trust`),{method:"POST",credentials:"same-origin"}),getAccounts:()=>De(t,n("accounts")),getAccountUsage:s=>De(t,n(`accounts/${s}/usage`),{method:"POST",credentials:"same-origin"}),getServerProcesses:()=>De(t,n("server-info/processes")),renameServerProject:(s,o)=>De(t,n("server-info/project-name"),it("POST",{path:s,name:o})),getServerExternalIp:(s=!1)=>De(t,n("server-info/external-ip")+(s?"?refresh=1":"")),selectAccount:(s,o)=>De(t,n(`accounts/${s}/select`),it("POST",{profileId:o})),renameAccount:(s,o,l)=>De(t,n(`accounts/${s}/rename`),it("POST",{profileId:o,label:l})),removeAccount:(s,o)=>De(t,n(`accounts/${s}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:s=>De(t,n(`accounts/${s}/login`),{method:"POST",credentials:"same-origin"}),submitAccountLoginCode:(s,o)=>De(t,n(`accounts/${s}/login/code`),it("POST",{code:o})),completeAccountLogin:(s,o)=>De(t,n(`accounts/${s}/login/complete`),it("POST",{label:o})),cancelAccountLogin:s=>De(t,n(`accounts/${s}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(s,o)=>De(t,n(`accounts/${s}/refresh`),it("POST",o?{profileId:o}:{})),terminateProviderSessions:s=>De(t,n(`accounts/${s}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(s,o=window.location.href)=>RN(n(`terminals/${encodeURIComponent(s)}/ws`),o)}}function RN(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 Ns(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 De(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await Vb(s);try{return await s.json()}catch{throw new Vn(s.status,"invalid_json_response")}}async function Ac(e,t,n){const s=await e(t,n);await Vb(s)}async function YC(e,t,n){const s=await e(t,n);return await Vb(s),s.blob()}async function Vb(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 Vn(e.status,t)}const Yb="nterminal.theme.id",GC="nterminal.theme.accent",Kv="nterminal:theme",tp=[{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",...l1({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",...l1({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Yc="midnight";function Pp(e){return tp.some(t=>t.id===e)?e:Yc}function Gb(e){return tp.find(t=>t.id===e)??tp[0]}function Mo(){if(typeof window>"u")return Yc;try{const e=window.localStorage.getItem(Yb);return e?Pp(e):LN(window.localStorage.getItem(GC))}catch{return Yc}}function NN(e){const t=Pp(e);if(typeof window<"u"){try{window.localStorage.setItem(Yb,t)}catch{}Xb(t),window.dispatchEvent(new CustomEvent(Kv,{detail:t}))}return t}function Xb(e=Mo()){if(typeof document>"u")return;const t=Gb(Pp(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),St(n,"--nt-bg",t.tokens.bg),St(n,"--nt-bg-2",t.tokens.bg2),St(n,"--nt-bg-sidebar",t.tokens.bgSidebar),St(n,"--nt-line",t.tokens.line),St(n,"--nt-line-2",t.tokens.line2),St(n,"--nt-fg",t.tokens.fg),St(n,"--nt-fg-2",t.tokens.fg2),St(n,"--nt-fg-3",t.tokens.fg3),St(n,"--nt-fg-4",t.tokens.fg4),St(n,"--nt-accent",t.tokens.accent),St(n,"--nt-accent-soft",t.tokens.accentSoft),St(n,"--nt-accent-glow",t.tokens.accentGlow),St(n,"--nt-on-accent",t.tokens.onAccent),St(n,"--nt-ok",t.tokens.ok),St(n,"--nt-working",t.tokens.working),St(n,"--nt-unread",t.tokens.unread),St(n,"--nt-on-unread",t.tokens.onUnread),St(n,"--nt-danger",t.tokens.danger),St(n,"--nt-on-danger",t.tokens.onDanger),St(n,"--nt-danger-soft",t.tokens.dangerSoft),St(n,"--nt-danger-line",t.tokens.dangerLine),St(n,"--nt-warning",t.tokens.warning),St(n,"--nt-warn",t.tokens.warning),St(n,"--nt-warning-soft",t.tokens.warningSoft),St(n,"--nt-warning-glow",t.tokens.warningGlow),St(n,"--nt-scrim",t.tokens.scrim),St(n,"--nt-scrim-soft",t.tokens.scrimSoft),St(n,"--nt-shadow",t.tokens.shadow),St(n,"--nt-shadow-strong",t.tokens.shadowStrong),St(n,"--nt-floating-bg",t.tokens.floatingBg),St(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),St(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),St(n,"--nt-subtle-fill",t.tokens.subtleFill),St(n,"--nt-hover-fill",t.tokens.hoverFill),St(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),St(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),St(n,"--nt-transcript-user",t.tokens.transcriptUser),St(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),St(n,"--nt-transcript-tool",t.tokens.transcriptTool),St(n,"--nt-transcript-command",t.tokens.transcriptCommand),St(n,"--nt-transcript-code",t.tokens.transcriptCode),St(n,"--nt-transcript-search",t.tokens.transcriptSearch),St(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),St(n,"--nt-qr-bg",t.tokens.qrBg)}function DN(e=Mo()){return Gb(Pp(e)).xterm}function Zb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Yb||n.key===GC)&&(Xb(Mo()),e())};return window.addEventListener(Kv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Kv,e),window.removeEventListener("storage",t)}}function St(e,t,n){e.style.setProperty(t,n)}function l1(e){const t=MN(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 MN(e){const t=[];for(let n=16;n<=e;n+=1)t.push(AN(n));return t}function AN(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 c1(s,o,l)}if(e>=232&&e<=255){const t=8+(e-232)*10;return c1(t,t,t)}return"#000000"}function c1(e,t,n){return`#${qg(e)}${qg(t)}${qg(n)}`}function qg(e){return e.toString(16).padStart(2,"0")}function LN(e){return e==="signal-red"?"signal-red":Yc}function XC(){const e=v.useSyncExternalStore(Zb,Mo,()=>Yc);return Gb(e).mode==="light"?"-light":""}function ZC({size:e=22}){const t=XC();return u.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function QC({height:e=18}){const t=XC(),n=Math.round(243/34*e);return u.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var md=qC();function jN(){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 zp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function tu(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Qb(e){return"nodeType"in e}function Vi(e){var t,n;return e?tu(e)?e:Qb(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Jb(e){const{Document:t}=Vi(e);return e instanceof t}function lh(e){return tu(e)?!1:e instanceof Vi(e).HTMLElement}function JC(e){return e instanceof Vi(e).SVGElement}function nu(e){return e?tu(e)?e.document:Qb(e)?Jb(e)?e:lh(e)||JC(e)?e.ownerDocument:document:document:document}const hs=zp?v.useLayoutEffect:v.useEffect;function Hp(e){const t=v.useRef(e);return hs(()=>{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 ON(){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 Hd(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return hs(()=>{n.current!==e&&(n.current=e)},t),n}function ch(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function np(e){const t=Hp(e),n=v.useRef(null),s=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,s]}function ip(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Vg={};function uh(e,t){return v.useMemo(()=>{if(t)return t;const n=Vg[e]==null?0:Vg[e]+1;return Vg[e]=n,e+"-"+n},[e,t])}function ek(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,d)=>{const f=Object.entries(d);for(const[m,p]of f){const b=l[m];b!=null&&(l[m]=b+e*p)}return l},{...t})}}const Wc=ek(1),rp=ek(-1);function BN(e){return"clientX"in e&&"clientY"in e}function Up(e){if(!e)return!1;const{KeyboardEvent:t}=Vi(e.target);return t&&e instanceof t}function IN(e){if(!e)return!1;const{TouchEvent:t}=Vi(e.target);return t&&e instanceof t}function sp(e){if(IN(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 BN(e)?{x:e.clientX,y:e.clientY}:null}const Ea=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[Ea.Translate.toString(e),Ea.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),u1="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function PN(e){return e.matches(u1)?e:e.querySelector(u1)}const zN={display:"none"};function HN(e){let{id:t,value:n}=e;return zt.createElement("div",{id:t,style:zN},n)}function UN(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 $N(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const tk=v.createContext(null);function FN(e){const t=v.useContext(tk);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function WN(){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(d=>{var f;return(f=d[o])==null?void 0:f.call(d,l)})},[e]),t]}const KN={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
|
-
`},qN={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 VN(e){let{announcements:t=qN,container:n,hiddenTextDescribedById:s,screenReaderInstructions:o=KN}=e;const{announce:l,announcement:d}=$N(),f=uh("DndLiveRegion"),[m,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),FN(v.useMemo(()=>({onDragStart(_){let{active:S}=_;l(t.onDragStart({active:S}))},onDragMove(_){let{active:S,over:w}=_;t.onDragMove&&l(t.onDragMove({active:S,over:w}))},onDragOver(_){let{active:S,over:w}=_;l(t.onDragOver({active:S,over:w}))},onDragEnd(_){let{active:S,over:w}=_;l(t.onDragEnd({active:S,over:w}))},onDragCancel(_){let{active:S,over:w}=_;l(t.onDragCancel({active:S,over:w}))}}),[l,t])),!m)return null;const b=zt.createElement(zt.Fragment,null,zt.createElement(HN,{id:s,value:o.draggable}),zt.createElement(UN,{id:f,announcement:d}));return n?md.createPortal(b,n):b}var fi;(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"})(fi||(fi={}));function ap(){}function op(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function nk(){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 fs=Object.freeze({x:0,y:0});function YN(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function GN(e,t){const n=sp(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 XN(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return n-s}function ZN(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function QN(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function d1(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 JN=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=d1(t,t.left,t.top),l=[];for(const d of s){const{id:f}=d,m=n.get(f);if(m){const p=YN(d1(m),o);l.push({id:f,data:{droppableContainer:d,value:p}})}}return l.sort(XN)};function eD(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),d=o-s,f=l-n;if(s<o&&n<l){const m=t.width*t.height,p=e.width*e.height,b=d*f,_=b/(m+p-b);return Number(_.toFixed(4))}return 0}const tD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=[];for(const l of s){const{id:d}=l,f=n.get(d);if(f){const m=eD(f,t);m>0&&o.push({id:d,data:{droppableContainer:l,value:m}})}}return o.sort(ZN)};function nD(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function ik(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:fs}function iD(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((d,f)=>({...d,top:d.top+e*f.y,bottom:d.bottom+e*f.y,left:d.left+e*f.x,right:d.right+e*f.x}),{...n})}}const rD=iD(1);function rk(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 sD(e,t,n){const s=rk(t);if(!s)return e;const{scaleX:o,scaleY:l,x:d,y:f}=s,m=e.left-d-(1-o)*parseFloat(n),p=e.top-f-(1-l)*parseFloat(n.slice(n.indexOf(" ")+1)),b=o?e.width/o:e.width,_=l?e.height/l:e.height;return{width:b,height:_,top:p,right:m+b,bottom:p+_,left:m}}const aD={ignoreTransform:!1};function iu(e,t){t===void 0&&(t=aD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:b}=Vi(e).getComputedStyle(e);p&&(n=sD(n,p,b))}const{top:s,left:o,width:l,height:d,bottom:f,right:m}=n;return{top:s,left:o,width:l,height:d,bottom:f,right:m}}function h1(e){return iu(e,{ignoreTransform:!0})}function oD(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function lD(e,t){return t===void 0&&(t=Vi(e).getComputedStyle(e)),t.position==="fixed"}function cD(e,t){t===void 0&&(t=Vi(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 ey(e,t){const n=[];function s(o){if(t!=null&&n.length>=t||!o)return n;if(Jb(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!lh(o)||JC(o)||n.includes(o))return n;const l=Vi(e).getComputedStyle(o);return o!==e&&cD(o,l)&&n.push(o),lD(o,l)?n:s(o.parentNode)}return e?s(e):n}function sk(e){const[t]=ey(e,1);return t??null}function Yg(e){return!zp||!e?null:tu(e)?e:Qb(e)?Jb(e)||e===nu(e).scrollingElement?window:lh(e)?e:null:null}function ak(e){return tu(e)?e.scrollX:e.scrollLeft}function ok(e){return tu(e)?e.scrollY:e.scrollTop}function qv(e){return{x:ak(e),y:ok(e)}}var bi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(bi||(bi={}));function lk(e){return!zp||!e?!1:e===document.scrollingElement}function ck(e){const t={x:0,y:0},n=lk(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,d=e.scrollTop>=s.y,f=e.scrollLeft>=s.x;return{isTop:o,isLeft:l,isBottom:d,isRight:f,maxScroll:s,minScroll:t}}const uD={x:.2,y:.2};function dD(e,t,n,s,o){let{top:l,left:d,right:f,bottom:m}=n;s===void 0&&(s=10),o===void 0&&(o=uD);const{isTop:p,isBottom:b,isLeft:_,isRight:S}=ck(e),w={x:0,y:0},x={x:0,y:0},R={height:t.height*o.y,width:t.width*o.x};return!p&&l<=t.top+R.height?(w.y=bi.Backward,x.y=s*Math.abs((t.top+R.height-l)/R.height)):!b&&m>=t.bottom-R.height&&(w.y=bi.Forward,x.y=s*Math.abs((t.bottom-R.height-m)/R.height)),!S&&f>=t.right-R.width?(w.x=bi.Forward,x.x=s*Math.abs((t.right-R.width-f)/R.width)):!_&&d<=t.left+R.width&&(w.x=bi.Backward,x.x=s*Math.abs((t.left+R.width-d)/R.width)),{direction:w,speed:x}}function hD(e){if(e===document.scrollingElement){const{innerWidth:l,innerHeight:d}=window;return{top:0,left:0,right:l,bottom:d,width:l,height:d}}const{top:t,left:n,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function uk(e){return e.reduce((t,n)=>Wc(t,qv(n)),fs)}function fD(e){return e.reduce((t,n)=>t+ak(n),0)}function pD(e){return e.reduce((t,n)=>t+ok(n),0)}function dk(e,t){if(t===void 0&&(t=iu),!e)return;const{top:n,left:s,bottom:o,right:l}=t(e);sk(e)&&(o<=0||l<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const mD=[["x",["left","right"],fD],["y",["top","bottom"],pD]];class ty{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=ey(n),o=uk(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,d,f]of mD)for(const m of d)Object.defineProperty(this,m,{get:()=>{const p=f(s),b=o[l]-p;return this.rect[m]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Nd{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}=Vi(e);return e instanceof t?e:nu(e)}function Gg(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 Yr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Yr||(Yr={}));function f1(e){e.preventDefault()}function vD(e){e.stopPropagation()}var Gt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Gt||(Gt={}));const hk={start:[Gt.Space,Gt.Enter],cancel:[Gt.Esc],end:[Gt.Space,Gt.Enter,Gt.Tab]},_D=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Gt.Right:return{...n,x:n.x+25};case Gt.Left:return{...n,x:n.x-25};case Gt.Down:return{...n,y:n.y+25};case Gt.Up:return{...n,y:n.y-25}}};class fk{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 Nd(nu(n)),this.windowListeners=new Nd(Vi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Yr.Resize,this.handleCancel),this.windowListeners.add(Yr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Yr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&dk(s),n(fs)}handleKeyDown(t){if(Up(t)){const{active:n,context:s,options:o}=this.props,{keyboardCodes:l=hk,coordinateGetter:d=_D,scrollBehavior:f="smooth"}=o,{code:m}=t;if(l.end.includes(m)){this.handleEnd(t);return}if(l.cancel.includes(m)){this.handleCancel(t);return}const{collisionRect:p}=s.current,b=p?{x:p.left,y:p.top}:fs;this.referenceCoordinates||(this.referenceCoordinates=b);const _=d(t,{active:n,context:s.current,currentCoordinates:b});if(_){const S=rp(_,b),w={x:0,y:0},{scrollableAncestors:x}=s.current;for(const R of x){const L=t.code,{isTop:A,isRight:W,isLeft:z,isBottom:H,maxScroll:q,minScroll:Y}=ck(R),I=hD(R),$={x:Math.min(L===Gt.Right?I.right-I.width/2:I.right,Math.max(L===Gt.Right?I.left:I.left+I.width/2,_.x)),y:Math.min(L===Gt.Down?I.bottom-I.height/2:I.bottom,Math.max(L===Gt.Down?I.top:I.top+I.height/2,_.y))},de=L===Gt.Right&&!W||L===Gt.Left&&!z,me=L===Gt.Down&&!H||L===Gt.Up&&!A;if(de&&$.x!==_.x){const K=R.scrollLeft+S.x,ne=L===Gt.Right&&K<=q.x||L===Gt.Left&&K>=Y.x;if(ne&&!S.y){R.scrollTo({left:K,behavior:f});return}ne?w.x=R.scrollLeft-K:w.x=L===Gt.Right?R.scrollLeft-q.x:R.scrollLeft-Y.x,w.x&&R.scrollBy({left:-w.x,behavior:f});break}else if(me&&$.y!==_.y){const K=R.scrollTop+S.y,ne=L===Gt.Down&&K<=q.y||L===Gt.Up&&K>=Y.y;if(ne&&!S.x){R.scrollTo({top:K,behavior:f});return}ne?w.y=R.scrollTop-K:w.y=L===Gt.Down?R.scrollTop-q.y:R.scrollTop-Y.y,w.y&&R.scrollBy({top:-w.y,behavior:f});break}}this.handleMove(t,Wc(rp(_,this.referenceCoordinates),w))}}}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()}}fk.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=hk,onActivation:o}=t,{active:l}=n;const{code:d}=e.nativeEvent;if(s.start.includes(d)){const f=l.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function p1(e){return!!(e&&"distance"in e)}function m1(e){return!!(e&&"delay"in e)}class ny{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:d}=l;this.props=t,this.events=n,this.document=nu(d),this.documentListeners=new Nd(this.document),this.listeners=new Nd(s),this.windowListeners=new Nd(Vi(d)),this.initialCoordinates=(o=sp(l))!=null?o:fs,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(Yr.Resize,this.handleCancel),this.windowListeners.add(Yr.DragStart,f1),this.windowListeners.add(Yr.VisibilityChange,this.handleCancel),this.windowListeners.add(Yr.ContextMenu,f1),this.documentListeners.add(Yr.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(m1(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(p1(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(Yr.Click,vD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Yr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:o,props:l}=this,{onMove:d,options:{activationConstraint:f}}=l;if(!o)return;const m=(n=sp(t))!=null?n:fs,p=rp(o,m);if(!s&&f){if(p1(f)){if(f.tolerance!=null&&Gg(p,f.tolerance))return this.handleCancel();if(Gg(p,f.distance))return this.handleStart()}if(m1(f)&&Gg(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),d(m)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Gt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const bD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class pk extends ny{constructor(t){const{event:n}=t,s=nu(n.target);super(t,bD,s)}}pk.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 yD={move:{name:"mousemove"},end:{name:"mouseup"}};var Vv;(function(e){e[e.RightClick=2]="RightClick"})(Vv||(Vv={}));class iy extends ny{constructor(t){super(t,yD,nu(t.event.target))}}iy.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===Vv.RightClick?!1:(s?.({event:n}),!0)}}];const Xg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ry extends ny{constructor(t){super(t,Xg)}static setup(){return window.addEventListener(Xg.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Xg.move.name,t)};function t(){}}}ry.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 Dd;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Dd||(Dd={}));var lp;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(lp||(lp={}));function SD(e){let{acceleration:t,activator:n=Dd.Pointer,canScroll:s,draggingRect:o,enabled:l,interval:d=5,order:f=lp.TreeOrder,pointerCoordinates:m,scrollableAncestors:p,scrollableAncestorRects:b,delta:_,threshold:S}=e;const w=xD({delta:_,disabled:!l}),[x,R]=ON(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),W=v.useMemo(()=>{switch(n){case Dd.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case Dd.DraggableRect:return o}},[n,o,m]),z=v.useRef(null),H=v.useCallback(()=>{const Y=z.current;if(!Y)return;const I=L.current.x*A.current.x,$=L.current.y*A.current.y;Y.scrollBy(I,$)},[]),q=v.useMemo(()=>f===lp.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!l||!p.length||!W){R();return}for(const Y of q){if(s?.(Y)===!1)continue;const I=p.indexOf(Y),$=b[I];if(!$)continue;const{direction:de,speed:me}=dD(Y,$,W,t,S);for(const K of["x","y"])w[K][de[K]]||(me[K]=0,de[K]=0);if(me.x>0||me.y>0){R(),z.current=Y,x(H,d),L.current=me,A.current=de;return}}L.current={x:0,y:0},A.current={x:0,y:0},R()},[t,H,s,R,l,d,JSON.stringify(W),JSON.stringify(w),x,p,q,b,JSON.stringify(S)])}const wD={x:{[bi.Backward]:!1,[bi.Forward]:!1},y:{[bi.Backward]:!1,[bi.Forward]:!1}};function xD(e){let{delta:t,disabled:n}=e;const s=ip(t);return ch(o=>{if(n||!s||!o)return wD;const l={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[bi.Backward]:o.x[bi.Backward]||l.x===-1,[bi.Forward]:o.x[bi.Forward]||l.x===1},y:{[bi.Backward]:o.y[bi.Backward]||l.y===-1,[bi.Forward]:o.y[bi.Forward]||l.y===1}}},[n,t,s])}function CD(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return ch(o=>{var l;return t==null?null:(l=s??o)!=null?l:null},[s,t])}function kD(e,t){return v.useMemo(()=>e.reduce((n,s)=>{const{sensor:o}=s,l=o.activators.map(d=>({eventName:d.eventName,handler:t(d.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 Yv;(function(e){e.Optimized="optimized"})(Yv||(Yv={}));const g1=new Map;function TD(e,t){let{dragging:n,dependencies:s,config:o}=t;const[l,d]=v.useState(null),{frequency:f,measure:m,strategy:p}=o,b=v.useRef(e),_=L(),S=Hd(_),w=v.useCallback(function(A){A===void 0&&(A=[]),!S.current&&d(W=>W===null?A:W.concat(A.filter(z=>!W.includes(z))))},[S]),x=v.useRef(null),R=ch(A=>{if(_&&!n)return g1;if(!A||A===g1||b.current!==e||l!=null){const W=new Map;for(let z of e){if(!z)continue;if(l&&l.length>0&&!l.includes(z.id)&&z.rect.current){W.set(z.id,z.rect.current);continue}const H=z.node.current,q=H?new ty(m(H),H):null;z.rect.current=q,q&&W.set(z.id,q)}return W}return A},[e,l,n,_,m]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{_||w()},[n,_]),v.useEffect(()=>{l&&l.length>0&&d(null)},[JSON.stringify(l)]),v.useEffect(()=>{_||typeof f!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},f))},[f,_,w,...s]),{droppableRects:R,measureDroppableContainers:w,measuringScheduled:l!=null};function L(){switch(p){case Ud.Always:return!1;case Ud.BeforeDragging:return n;default:return!n}}}function sy(e,t){return ch(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ED(e,t){return sy(e,t)}function RD(e){let{callback:t,disabled:n}=e;const s=Hp(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 $p(e){let{callback:t,disabled:n}=e;const s=Hp(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 ND(e){return new ty(iu(e),e)}function v1(e,t,n){t===void 0&&(t=ND);const[s,o]=v.useState(null);function l(){o(m=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=m??n)!=null?p:null}const b=t(e);return JSON.stringify(m)===JSON.stringify(b)?m:b})}const d=RD({callback(m){if(e)for(const p of m){const{type:b,target:_}=p;if(b==="childList"&&_ instanceof HTMLElement&&_.contains(e)){l();break}}}}),f=$p({callback:l});return hs(()=>{l(),e?(f?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),d?.disconnect())},[e]),s}function DD(e){const t=sy(e);return ik(e,t)}const _1=[];function MD(e){const t=v.useRef(e),n=ch(s=>e?s&&s!==_1&&e&&t.current&&e.parentNode===t.current.parentNode?s:ey(e):_1,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function AD(e){const[t,n]=v.useState(null),s=v.useRef(e),o=v.useCallback(l=>{const d=Yg(l.target);d&&n(f=>f?(f.set(d,qv(d)),new Map(f)):null)},[]);return v.useEffect(()=>{const l=s.current;if(e!==l){d(l);const f=e.map(m=>{const p=Yg(m);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,qv(p)]):null}).filter(m=>m!=null);n(f.length?new Map(f):null),s.current=e}return()=>{d(e),d(l)};function d(f){f.forEach(m=>{const p=Yg(m);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,d)=>Wc(l,d),fs):uk(e):fs,[e,t])}function b1(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==fs;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?rp(e,n.current):fs}function LD(e){v.useEffect(()=>{if(!zp)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 jD(e,t){return v.useMemo(()=>e.reduce((n,s)=>{let{eventName:o,handler:l}=s;return n[o]=d=>{l(d,t)},n},{}),[e,t])}function mk(e){return v.useMemo(()=>e?oD(e):null,[e])}const y1=[];function OD(e,t){t===void 0&&(t=iu);const[n]=e,s=mk(n?Vi(n):null),[o,l]=v.useState(y1);function d(){l(()=>e.length?e.map(m=>lk(m)?s:new ty(t(m),m)):y1)}const f=$p({callback:d});return hs(()=>{f?.disconnect(),d(),e.forEach(m=>f?.observe(m))},[e]),o}function gk(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return lh(t)?t:e}function BD(e){let{measure:t}=e;const[n,s]=v.useState(null),o=v.useCallback(p=>{for(const{target:b}of p)if(lh(b)){s(_=>{const S=t(b);return _?{..._,width:S.width,height:S.height}:S});break}},[t]),l=$p({callback:o}),d=v.useCallback(p=>{const b=gk(p);l?.disconnect(),b&&l?.observe(b),s(b?t(b):null)},[t,l]),[f,m]=np(d);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:m}),[n,f,m])}const ID=[{sensor:pk,options:{}},{sensor:fk,options:{}}],PD={current:{}},If={draggable:{measure:h1},droppable:{measure:h1,strategy:Ud.WhileDragging,frequency:Yv.Optimized},dragOverlay:{measure:iu}};class Md 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 zD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Md,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ap},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:If,measureDroppableContainers:ap,windowRect:null,measuringScheduled:!1},vk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ap,draggableNodes:new Map,over:null,measureDroppableContainers:ap},dh=v.createContext(vk),_k=v.createContext(zD);function HD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Md}}}function UD(e,t){switch(t.type){case fi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case fi.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 fi.DragEnd:case fi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case fi.RegisterDroppable:{const{element:n}=t,{id:s}=n,o=new Md(e.droppable.containers);return o.set(s,n),{...e,droppable:{...e.droppable,containers:o}}}case fi.SetDroppableDisabled:{const{id:n,key:s,disabled:o}=t,l=e.droppable.containers.get(n);if(!l||s!==l.key)return e;const d=new Md(e.droppable.containers);return d.set(n,{...l,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case fi.UnregisterDroppable:{const{id:n,key:s}=t,o=e.droppable.containers.get(n);if(!o||s!==o.key)return e;const l=new Md(e.droppable.containers);return l.delete(n),{...e,droppable:{...e.droppable,containers:l}}}default:return e}}function $D(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:o}=v.useContext(dh),l=ip(s),d=ip(n?.id);return v.useEffect(()=>{if(!t&&!s&&l&&d!=null){if(!Up(l)||document.activeElement===l.target)return;const f=o.get(d);if(!f)return;const{activatorNode:m,node:p}=f;if(!m.current&&!p.current)return;requestAnimationFrame(()=>{for(const b of[m.current,p.current]){if(!b)continue;const _=PN(b);if(_){_.focus();break}}})}},[s,t,o,d,l]),null}function bk(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((o,l)=>l({transform:o,...s}),n):n}function FD(e){return v.useMemo(()=>({draggable:{...If.draggable,...e?.draggable},droppable:{...If.droppable,...e?.droppable},dragOverlay:{...If.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function WD(e){let{activeNode:t,measure:n,initialRect:s,config:o=!0}=e;const l=v.useRef(!1),{x:d,y:f}=typeof o=="boolean"?{x:o,y:o}:o;hs(()=>{if(!d&&!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),_=ik(b,s);if(d||(_.x=0),f||(_.y=0),l.current=!0,Math.abs(_.x)>0||Math.abs(_.y)>0){const S=sk(p);S&&S.scrollBy({top:_.y,left:_.x})}},[t,d,f,s,n])}const Fp=v.createContext({...fs,scaleX:1,scaleY:1});var yo;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(yo||(yo={}));const yk=v.memo(function(t){var n,s,o,l;let{id:d,accessibility:f,autoScroll:m=!0,children:p,sensors:b=ID,collisionDetection:_=tD,measuring:S,modifiers:w,...x}=t;const R=v.useReducer(UD,void 0,HD),[L,A]=R,[W,z]=WN(),[H,q]=v.useState(yo.Uninitialized),Y=H===yo.Initialized,{draggable:{active:I,nodes:$,translate:de},droppable:{containers:me}}=L,K=I!=null?$.get(I):null,ne=v.useRef({initial:null,translated:null}),ee=v.useMemo(()=>{var Ke;return I!=null?{id:I,data:(Ke=K?.data)!=null?Ke:PD,rect:ne}:null},[I,K]),Z=v.useRef(null),[X,M]=v.useState(null),[T,O]=v.useState(null),re=Hd(x,Object.values(x)),he=uh("DndDescribedBy",d),N=v.useMemo(()=>me.getEnabled(),[me]),V=FD(S),{droppableRects:se,measureDroppableContainers:J,measuringScheduled:xe}=TD(N,{dragging:Y,dependencies:[de.x,de.y],config:V.droppable}),ye=CD($,I),Pe=v.useMemo(()=>T?sp(T):null,[T]),Fe=te(),ze=ED(ye,V.draggable.measure);WD({activeNode:I!=null?$.get(I):null,config:Fe.layoutShiftCompensation,initialRect:ze,measure:V.draggable.measure});const ve=v1(ye,V.draggable.measure,ze),We=v1(ye?ye.parentElement:null),Oe=v.useRef({activatorEvent:null,active:null,activeNode:ye,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:me,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),j=me.getNodeFor((n=Oe.current.over)==null?void 0:n.id),ge=BD({measure:V.dragOverlay.measure}),Me=(s=ge.nodeRef.current)!=null?s:ye,Le=Y?(o=ge.rect)!=null?o:ve:null,F=!!(ge.nodeRef.current&&ge.rect),pe=DD(F?null:ve),Ce=mk(Me?Vi(Me):null),Re=MD(Y?j??ye:null),je=OD(Re),be=bk(w,{transform:{x:de.x-pe.x,y:de.y-pe.y,scaleX:1,scaleY:1},activatorEvent:T,active:ee,activeNodeRect:ve,containerNodeRect:We,draggingNodeRect:Le,over:Oe.current.over,overlayNodeRect:ge.rect,scrollableAncestors:Re,scrollableAncestorRects:je,windowRect:Ce}),Ue=Pe?Wc(Pe,de):null,$e=AD(Re),Be=b1($e),ot=b1($e,[ve]),ct=Wc(be,Be),ht=Le?rD(Le,be):null,jt=ee&&ht?_({active:ee,collisionRect:ht,droppableRects:se,droppableContainers:N,pointerCoordinates:Ue}):null,Qt=QN(jt,"id"),[rt,Yn]=v.useState(null),_n=F?be:Wc(be,ot),pt=nD(_n,(l=rt?.rect)!=null?l:null,ve),Et=v.useRef(null),Nt=v.useCallback((Ke,et)=>{let{sensor:bt,options:Pt}=et;if(Z.current==null)return;const bn=$.get(Z.current);if(!bn)return;const Ft=Ke.nativeEvent,pn=new bt({active:Z.current,activeNode:bn,event:Ft,options:Pt,context:Oe,onAbort(Dt){if(!$.get(Dt))return;const{onDragAbort:Sn}=re.current,Dn={id:Dt};Sn?.(Dn),W({type:"onDragAbort",event:Dn})},onPending(Dt,yn,Sn,Dn){if(!$.get(Dt))return;const{onDragPending:ft}=re.current,wt={id:Dt,constraint:yn,initialCoordinates:Sn,offset:Dn};ft?.(wt),W({type:"onDragPending",event:wt})},onStart(Dt){const yn=Z.current;if(yn==null)return;const Sn=$.get(yn);if(!Sn)return;const{onDragStart:Dn}=re.current,rn={activatorEvent:Ft,active:{id:yn,data:Sn.data,rect:ne}};md.unstable_batchedUpdates(()=>{Dn?.(rn),q(yo.Initializing),A({type:fi.DragStart,initialCoordinates:Dt,active:yn}),W({type:"onDragStart",event:rn}),M(Et.current),O(Ft)})},onMove(Dt){A({type:fi.DragMove,coordinates:Dt})},onEnd:Jt(fi.DragEnd),onCancel:Jt(fi.DragCancel)});Et.current=pn;function Jt(Dt){return async function(){const{active:Sn,collisions:Dn,over:rn,scrollAdjustedTranslate:ft}=Oe.current;let wt=null;if(Sn&&ft){const{cancelDrop:wn}=re.current;wt={activatorEvent:Ft,active:Sn,collisions:Dn,delta:ft,over:rn},Dt===fi.DragEnd&&typeof wn=="function"&&await Promise.resolve(wn(wt))&&(Dt=fi.DragCancel)}Z.current=null,md.unstable_batchedUpdates(()=>{A({type:Dt}),q(yo.Uninitialized),Yn(null),M(null),O(null),Et.current=null;const wn=Dt===fi.DragEnd?"onDragEnd":"onDragCancel";if(wt){const oe=re.current[wn];oe?.(wt),W({type:wn,event:wt})}})}}},[$]),Di=v.useCallback((Ke,et)=>(bt,Pt)=>{const bn=bt.nativeEvent,Ft=$.get(Pt);if(Z.current!==null||!Ft||bn.dndKit||bn.defaultPrevented)return;const pn={active:Ft};Ke(bt,et.options,pn)===!0&&(bn.dndKit={capturedBy:et.sensor},Z.current=Pt,Nt(bt,et))},[$,Nt]),Gn=kD(b,Di);LD(b),hs(()=>{ve&&H===yo.Initializing&&q(yo.Initialized)},[ve,H]),v.useEffect(()=>{const{onDragMove:Ke}=re.current,{active:et,activatorEvent:bt,collisions:Pt,over:bn}=Oe.current;if(!et||!bt)return;const Ft={active:et,activatorEvent:bt,collisions:Pt,delta:{x:ct.x,y:ct.y},over:bn};md.unstable_batchedUpdates(()=>{Ke?.(Ft),W({type:"onDragMove",event:Ft})})},[ct.x,ct.y]),v.useEffect(()=>{const{active:Ke,activatorEvent:et,collisions:bt,droppableContainers:Pt,scrollAdjustedTranslate:bn}=Oe.current;if(!Ke||Z.current==null||!et||!bn)return;const{onDragOver:Ft}=re.current,pn=Pt.get(Qt),Jt=pn&&pn.rect.current?{id:pn.id,rect:pn.rect.current,data:pn.data,disabled:pn.disabled}:null,Dt={active:Ke,activatorEvent:et,collisions:bt,delta:{x:bn.x,y:bn.y},over:Jt};md.unstable_batchedUpdates(()=>{Yn(Jt),Ft?.(Dt),W({type:"onDragOver",event:Dt})})},[Qt]),hs(()=>{Oe.current={activatorEvent:T,active:ee,activeNode:ye,collisionRect:ht,collisions:jt,droppableRects:se,draggableNodes:$,draggingNode:Me,draggingNodeRect:Le,droppableContainers:me,over:rt,scrollableAncestors:Re,scrollAdjustedTranslate:ct},ne.current={initial:Le,translated:ht}},[ee,ye,jt,ht,$,Me,Le,se,me,rt,Re,ct]),SD({...Fe,delta:de,draggingRect:ht,pointerCoordinates:Ue,scrollableAncestors:Re,scrollableAncestorRects:je});const nn=v.useMemo(()=>({active:ee,activeNode:ye,activeNodeRect:ve,activatorEvent:T,collisions:jt,containerNodeRect:We,dragOverlay:ge,draggableNodes:$,droppableContainers:me,droppableRects:se,over:rt,measureDroppableContainers:J,scrollableAncestors:Re,scrollableAncestorRects:je,measuringConfiguration:V,measuringScheduled:xe,windowRect:Ce}),[ee,ye,ve,T,jt,We,ge,$,me,se,rt,J,Re,je,V,xe,Ce]),fn=v.useMemo(()=>({activatorEvent:T,activators:Gn,active:ee,activeNodeRect:ve,ariaDescribedById:{draggable:he},dispatch:A,draggableNodes:$,over:rt,measureDroppableContainers:J}),[T,Gn,ee,ve,A,he,$,rt,J]);return zt.createElement(tk.Provider,{value:z},zt.createElement(dh.Provider,{value:fn},zt.createElement(_k.Provider,{value:nn},zt.createElement(Fp.Provider,{value:pt},p)),zt.createElement($D,{disabled:f?.restoreFocus===!1})),zt.createElement(VN,{...f,hiddenTextDescribedById:he}));function te(){const Ke=X?.autoScrollEnabled===!1,et=typeof m=="object"?m.enabled===!1:m===!1,bt=Y&&!Ke&&!et;return typeof m=="object"?{...m,enabled:bt}:{enabled:bt}}}),KD=v.createContext(null),S1="button",qD="Draggable";function ay(e){let{id:t,data:n,disabled:s=!1,attributes:o}=e;const l=uh(qD),{activators:d,activatorEvent:f,active:m,activeNodeRect:p,ariaDescribedById:b,draggableNodes:_,over:S}=v.useContext(dh),{role:w=S1,roleDescription:x="draggable",tabIndex:R=0}=o??{},L=m?.id===t,A=v.useContext(L?Fp:KD),[W,z]=np(),[H,q]=np(),Y=jD(d,t),I=Hd(n);hs(()=>(_.set(t,{id:t,key:l,node:W,activatorNode:H,data:I}),()=>{const de=_.get(t);de&&de.key===l&&_.delete(t)}),[_,t]);const $=v.useMemo(()=>({role:w,tabIndex:R,"aria-disabled":s,"aria-pressed":L&&w===S1?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[s,w,R,L,x,b.draggable]);return{active:m,activatorEvent:f,activeNodeRect:p,attributes:$,isDragging:L,listeners:s?void 0:Y,node:W,over:S,setNodeRef:z,setActivatorNodeRef:q,transform:A}}function Sk(){return v.useContext(_k)}const VD="Droppable",YD={timeout:25};function Wp(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:o}=e;const l=uh(VD),{active:d,dispatch:f,over:m,measureDroppableContainers:p}=v.useContext(dh),b=v.useRef({disabled:n}),_=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:R,timeout:L}={...YD,...o},A=Hd(R??s),W=v.useCallback(()=>{if(!_.current){_.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),w.current=null},L)},[L]),z=$p({callback:W,disabled:x||!d}),H=v.useCallback(($,de)=>{z&&(de&&(z.unobserve(de),_.current=!1),$&&z.observe($))},[z]),[q,Y]=np(H),I=Hd(t);return v.useEffect(()=>{!z||!q.current||(z.disconnect(),_.current=!1,z.observe(q.current))},[q,z]),v.useEffect(()=>(f({type:fi.RegisterDroppable,element:{id:s,key:l,disabled:n,node:q,rect:S,data:I}}),()=>f({type:fi.UnregisterDroppable,key:l,id:s})),[s]),v.useEffect(()=>{n!==b.current.disabled&&(f({type:fi.SetDroppableDisabled,id:s,key:l,disabled:n}),b.current.disabled=n)},[s,l,n,f]),{active:d,rect:S,isOver:m?.id===s,node:q,over:m,setNodeRef:Y}}function GD(e){let{animation:t,children:n}=e;const[s,o]=v.useState(null),[l,d]=v.useState(null),f=ip(n);return!n&&!s&&f&&o(f),hs(()=>{if(!l)return;const m=s?.key,p=s?.props.id;if(m==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:d}):null)}const XD={x:0,y:0,scaleX:1,scaleY:1};function ZD(e){let{children:t}=e;return zt.createElement(dh.Provider,{value:vk},zt.createElement(Fp.Provider,{value:XD},t))}const QD={position:"fixed",touchAction:"none"},JD=e=>Up(e)?"transform 250ms ease":void 0,eM=v.forwardRef((e,t)=>{let{as:n,activatorEvent:s,adjustScale:o,children:l,className:d,rect:f,style:m,transform:p,transition:b=JD}=e;if(!f)return null;const _=o?p:{...p,scaleX:1,scaleY:1},S={...QD,width:f.width,height:f.height,top:f.top,left:f.left,transform:Ea.Transform.toString(_),transformOrigin:o&&s?GN(s,f):void 0,transition:typeof b=="function"?b(s):b,...m};return zt.createElement(n,{className:d,style:S,ref:t},l)}),tM=e=>t=>{let{active:n,dragOverlay:s}=t;const o={},{styles:l,className:d}=e;if(l!=null&&l.active)for(const[f,m]of Object.entries(l.active))m!==void 0&&(o[f]=n.node.style.getPropertyValue(f),n.node.style.setProperty(f,m));if(l!=null&&l.dragOverlay)for(const[f,m]of Object.entries(l.dragOverlay))m!==void 0&&s.node.style.setProperty(f,m);return d!=null&&d.active&&n.node.classList.add(d.active),d!=null&&d.dragOverlay&&s.node.classList.add(d.dragOverlay),function(){for(const[m,p]of Object.entries(o))n.node.style.setProperty(m,p);d!=null&&d.active&&n.node.classList.remove(d.active)}},nM=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ea.Transform.toString(t)},{transform:Ea.Transform.toString(n)}]},iM={duration:250,easing:"ease",keyframes:nM,sideEffects:tM({styles:{active:{opacity:"0"}}})};function rM(e){let{config:t,draggableNodes:n,droppableContainers:s,measuringConfiguration:o}=e;return Hp((l,d)=>{if(t===null)return;const f=n.get(l);if(!f)return;const m=f.node.current;if(!m)return;const p=gk(d);if(!p)return;const{transform:b}=Vi(d).getComputedStyle(d),_=rk(b);if(!_)return;const S=typeof t=="function"?t:sM(t);return dk(m,o.draggable.measure),S({active:{id:l,data:f.data,node:m,rect:o.draggable.measure(m)},draggableNodes:n,dragOverlay:{node:d,rect:o.dragOverlay.measure(p)},droppableContainers:s,measuringConfiguration:o,transform:_})})}function sM(e){const{duration:t,easing:n,sideEffects:s,keyframes:o}={...iM,...e};return l=>{let{active:d,dragOverlay:f,transform:m,...p}=l;if(!t)return;const b={x:f.rect.left-d.rect.left,y:f.rect.top-d.rect.top},_={scaleX:m.scaleX!==1?d.rect.width*m.scaleX/f.rect.width:1,scaleY:m.scaleY!==1?d.rect.height*m.scaleY/f.rect.height:1},S={x:m.x-b.x,y:m.y-b.y,..._},w=o({...p,active:d,dragOverlay:f,transform:{initial:m,final:S}}),[x]=w,R=w[w.length-1];if(JSON.stringify(x)===JSON.stringify(R))return;const L=s?.({active:d,dragOverlay:f,...p}),A=f.node.animate(w,{duration:t,easing:n,fill:"forwards"});return new Promise(W=>{A.onfinish=()=>{L?.(),W()}})}}let w1=0;function aM(e){return v.useMemo(()=>{if(e!=null)return w1++,w1},[e])}const oM=zt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:s,style:o,transition:l,modifiers:d,wrapperElement:f="div",className:m,zIndex:p=999}=e;const{activatorEvent:b,active:_,activeNodeRect:S,containerNodeRect:w,draggableNodes:x,droppableContainers:R,dragOverlay:L,over:A,measuringConfiguration:W,scrollableAncestors:z,scrollableAncestorRects:H,windowRect:q}=Sk(),Y=v.useContext(Fp),I=aM(_?.id),$=bk(d,{activatorEvent:b,active:_,activeNodeRect:S,containerNodeRect:w,draggingNodeRect:L.rect,over:A,overlayNodeRect:L.rect,scrollableAncestors:z,scrollableAncestorRects:H,transform:Y,windowRect:q}),de=sy(S),me=rM({config:s,draggableNodes:x,droppableContainers:R,measuringConfiguration:W}),K=de?L.setRef:void 0;return zt.createElement(ZD,null,zt.createElement(GD,{animation:me},_&&I?zt.createElement(eM,{key:I,id:_.id,ref:K,as:f,activatorEvent:b,adjustScale:t,className:m,transition:l,rect:de,style:{zIndex:p,...o},transform:$},n):null))}),lM=128,cM=512,Ao=100,uM="too_many_detached_terminals",dM=64,hM=4096;function Kp(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>lM)return null;const n=t.workspaces.map(fM);if(n.some(d=>d===null))return null;const s=n,o=new Set,l=new Set;for(const d of s){if(o.has(d.id))return null;o.add(d.id);for(const f of d.tabs){if(l.has(f.id))return null;l.add(f.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}function wk(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>Ao}):!1}function fM(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>cM)return null;const n=t.tabs.map(pM);if(n.some(o=>o===null))return null;const s=_M(t.detachedTerminalIds,Ao);return s===null?null:{id:t.id,title:t.title,defaultCwd:vM(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function pM(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=mM(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function mM(e){if(!e||typeof e!="object")return null;let t=0;return Gv(e,1,()=>(t+=1,t<=hM))}function Gv(e,t,n){if(!e||typeof e!="object"||t>dM||!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=Gv(s.first,t+1,n),l=Gv(s.second,t+1,n);return!o||!l?null:{type:"split",direction:s.direction,ratio:gM(s.ratio),first:o,second:l}}function gM(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function vM(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function _M(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 xk=[{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"}],bM="nterminal-focus",yM=/^[A-Za-z0-9_.:-]{1,128}$/;function SM(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(bM)!=="terminal"?null:qp({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function qp(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!x1(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!x1(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function x1(e){return typeof e=="string"&&yM.test(e)}const Zt="__main__",Ck=128,wM=600*1e3,kk="nterminal.clientDiagnostics.v1",Tk="nterminal.terminalDiagnosticsCursor.v1",Vp=150,xM=24,CM=160,kM=48*1024,TM="terminal-connection-recovery";let C1=!1,sd=null,ad=null,Zg=0;function EM(){C1||typeof window>"u"||(C1=!0,Pi("page.load",{navigation:WM(),visibility:document.visibilityState,online:navigator.onLine,viewport:Mk(),standalone:FM()}),document.addEventListener("visibilitychange",()=>{Pi("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Pi("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Pi("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Pi("network.online")),window.addEventListener("offline",()=>Pi("network.offline")),window.addEventListener("focus",()=>Pi("window.focus")),window.addEventListener("blur",()=>Pi("window.blur")),window.addEventListener("error",e=>{Pi("runtime.error",{message:e.message,source:KM(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Pi("runtime.unhandledrejection",{reason:qM(e.reason)})}))}function Pi(e,t={}){const n={id:BM(),at:new Date().toISOString(),event:$d(e,80),data:Dk({...t,visibility:t.visibility??UM(),online:t.online??$M(),viewport:t.viewport??Mk()})},s=oy();return s.push(n),jM(s.slice(-Vp)),n}function oy(){try{const e=window.localStorage.getItem(kk);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(OM).filter(n=>n!==null).slice(-Vp):[]}catch{return[]}}async function ly(e,t=fetch){if(sd)return sd;const n=oy(),s={reason:$d(e,80),events:n},o=JSON.stringify(s);sd=(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 sd}finally{sd=null}}function Yp(){return Ek().events.length>0}async function RM(e=fetch){if(ad)return ad;ad=NM(e);try{return await ad}finally{ad=null}}async function NM(e){const t=Ek();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?(LM(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function Ek(){const e=Rk(),t=oy().filter(o=>DM(o)&&AM(o,e)),n=[];let s=k1([]);for(const o of t){const l=[...n,o],d=k1(l);if(MM(d)>kM)break;n.push(o),s=d}return{events:n,body:s,hasMore:n.length<t.length}}function k1(e){return JSON.stringify({reason:TM,events:e})}function DM(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function MM(e){return new TextEncoder().encode(e).byteLength}function AM(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(Nk(e))}function Rk(){try{const e=window.localStorage.getItem(Tk);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(-Vp):[]}}catch{return null}}function LM(e){const t=e.at(-1);if(!t)return;const n=Rk(),s=new Set(n?.at===t.at?n.boundaryIds:[]);for(const l of e)l.at===t.at&&s.add(Nk(l));const o={at:t.at.slice(0,40),boundaryIds:Array.from(s).slice(-Vp)};try{window.localStorage.setItem(Tk,JSON.stringify(o))}catch{}}function jM(e){try{window.localStorage.setItem(kk,JSON.stringify(e))}catch{}}function OM(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:$d(t.id,128)}:{},at:t.at.slice(0,40),event:$d(t.event,80),...t.data&&typeof t.data=="object"?{data:Dk(t.data)}:{}}}function BM(){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 Nk(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 Dk(e){const t={};for(const[n,s]of Object.entries(e).slice(0,xM)){const o=$d(n,64);if(!o||IM(o))continue;const l=PM(s);l!==void 0&&(t[o]=l)}return t}function IM(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function PM(e){if(typeof e=="string")return zM(e,CM);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function $d(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function zM(e,t){return HM(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function HM(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 UM(){return typeof document>"u"?void 0:document.visibilityState}function $M(){return typeof navigator>"u"?void 0:navigator.onLine}function Mk(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function FM(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function WM(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function KM(e){if(!e)return null;try{const t=new URL(e);return t.pathname.split("/").pop()||t.pathname}catch{return e.split("/").pop()??e}}function qM(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const Ak="nterminal.notifications.completionEnabled",cy="nterminal.notifications.completionToastEnabled",uy="nterminal.notifications.completionToastDurationSeconds",dy="nterminal.notifications.completionToastPersistent",Xv="nterminal:completion-toast-display",Zv="nterminal:notification-focus",Ad=6.5,Qv=2,Jv=60;function Gp(){return typeof window<"u"&&"Notification"in window}function hy(){try{return window.localStorage.getItem(Ak)==="true"}catch{return!1}}function T1(e){try{window.localStorage.setItem(Ak,e?"true":"false")}catch{}}function Al(){return{enabled:XM(),durationSeconds:GM(),persistUntilDismissed:ZM()}}function VM(e){if(typeof window<"u"){try{window.localStorage.setItem(cy,e?"true":"false")}catch{}fy()}return Al()}function E1(e){const t=jk(e);if(typeof window<"u"){try{window.localStorage.setItem(uy,String(t))}catch{}fy()}return Al()}function YM(e){if(typeof window<"u"){try{window.localStorage.setItem(dy,e?"true":"false")}catch{}fy()}return Al()}function Lk(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===cy||n.key===uy||n.key===dy)&&e()};return window.addEventListener(Xv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Xv,e),window.removeEventListener("storage",t)}}function ru(){return Gp()?window.Notification.permission:"unsupported"}function GM(){if(typeof window>"u")return Ad;try{const e=window.localStorage.getItem(uy);return e===null?Ad:jk(Number(e))}catch{return Ad}}function XM(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(cy)!=="false"}catch{return!0}}function ZM(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(dy)==="true"}catch{return!1}}function jk(e){if(!Number.isFinite(e))return Ad;const t=Math.round(e*2)/2;return Math.max(Qv,Math.min(Jv,t))}function fy(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Xv))}async function Ok(){if(!Gp())return"unsupported";try{return await window.Notification.requestPermission()}catch{return ru()}}function QM(e){if(!Gp()||ru()!=="granted"||!hy()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,s=qp({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(),JM(s)})}catch{}}function JM(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Zv,{detail:e}))}const R1="nterminal.push.clientId",eA=2e4,N1=[5e3,3e4,12e4];function wa(){try{const e=window.localStorage.getItem(R1);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${t_()}`;return window.localStorage.setItem(R1,t),t}catch{return`client-${t_()}`}}function tA(){return`page-${t_()}`}function Xp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=lA(),n=cA(),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 nA(e,t){const n=Xp();if(!n.supported)throw new Error(n.reason);if((ru()==="granted"?"granted":await Ok())!=="granted")throw new Error("permission_denied");const o=wa(),l=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(o),m=await dA(l,d.publicKey)??await l.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Pk(d.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:Ik(m),deviceKind:n.deviceKind,displayMode:n.displayMode,label:Bk(n.deviceKind),alwaysNotify:t})}async function iA(e){const t=Xp();if(!t.supported||ru()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),s=await n?.pushManager.getSubscription();if(!n||!s)return!1;const o=wa(),l=await hA(s.endpoint),d=await e.getPushNotificationStatus(o,l);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&e_(s,d.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),m=d.endpointRegistered===!0&&e_(s,f.publicKey);m||await s.unsubscribe();const p=m?s:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Pk(f.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:Ik(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:Bk(t.deviceKind),alwaysNotify:!1}),!0}function rA(e){let t=!1,n=!1,s=0,o=null;const l=()=>{o!==null&&(window.clearTimeout(o),o=null)},d=b=>{t||n||(n=!0,iA(e).then(_=>{s=0,_&&Pi("push.subscription.reconciled",{trigger:b})}).catch(_=>{if(Pi("push.subscription.reconcile_failed",{trigger:b,reason:_ instanceof Error?_.message:String(_)}),!t&&s<N1.length){const S=N1[s++];o=window.setTimeout(()=>{o=null,d("retry")},S)}}).finally(()=>{n=!1}))},f=b=>{l(),s=0,d(b)},m=()=>f("online"),p=()=>f("pageshow");return window.addEventListener("online",m),window.addEventListener("pageshow",p),d("startup"),()=>{t=!0,l(),window.removeEventListener("online",m),window.removeEventListener("pageshow",p)}}async function sA(e){const t=wa();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 aA(e,t){await e.updatePushNotificationDevice({clientId:wa(),alwaysNotify:t})}function oA(e){if(typeof window>"u")return()=>{};const t=wa(),n=tA();let s=null,o=!1;const l=(p=!0)=>{const b=Xp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:uA(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:hy()&&ru()==="granted",active:p}).catch(()=>{})},d=()=>{o||s!==null||(s=window.setInterval(()=>l(!0),eA))},f=()=>l(!0),m=()=>l(!1);return window.addEventListener("focus",f),window.addEventListener("blur",f),document.addEventListener("visibilitychange",f),window.addEventListener("pagehide",m),l(!0),d(),()=>{o=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",f),window.removeEventListener("blur",f),document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",m),l(!1)}}function lA(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function cA(){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 Bk(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function uA(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function Ik(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 dA(e,t){const n=await e.pushManager.getSubscription();return n?e_(n,t)?n:(await n.unsubscribe(),null):null}function e_(e,t){const n=e.options.applicationServerKey;return n?zk(n)===t:!0}async function hA(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return zk(t)}function Pk(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 d=0;d<s.length;d+=1)l[d]=s.charCodeAt(d);return o}function zk(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 t_(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const fA=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function pA(e,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:fA(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}const mA=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 gA=e=>{const t=mA(e);return t.charAt(0).toUpperCase()+t.slice(1)};const n_=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const _l={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 Qg(e){return e!=null}function vA(e,t={}){const n=t.attributeNames??{},s=S=>n[S]??S,o=e.size??e.width??_l.width,l=e.size??e.height??_l.height,d=e.aliases?.filter(S=>typeof S=="string"&&S.trim()!=="").map(S=>`lucide-${S}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...d],m=t.className?.split(" ").filter(Boolean)??[],p=t.includeDefaultClasses===!1?n_(...m):n_("lucide",...f,...m),b=t.absoluteStrokeWidth?Number(t.strokeWidth??_l["stroke-width"])*Number(e.size??e.width??_l.width)/Number(t.size??t.width??_l.width):t.strokeWidth??_l["stroke-width"];return["svg",{...Object.entries(_l).reduce((S,[w,x])=>(S[s(w)]=x,S),{}),..."color"in t&&t.color&&{[s("stroke")]:t.color},..."size"in t&&Qg(t.size)&&{[s("width")]:t.size,[s("height")]:t.size},..."width"in t&&Qg(t.width)&&{[s("width")]:t.width},..."height"in t&&Qg(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(S=>{const[w,x,R]=S,L=t.nonScalingStroke?{[s("vector-effect")]:"non-scaling-stroke",...x}:x;return R?[w,L,R]:[w,L]})]}function _A(e,t={}){return vA(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const bA=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},yA=v.createContext({}),SA=()=>v.useContext(yA),wA=v.forwardRef(({color:e,size:t,width:n,height:s,strokeWidth:o,absoluteStrokeWidth:l,nonScalingStroke:d,className:f="",children:m,iconNode:p=[],icon:b={node:p,aliases:[],size:24},..._},S)=>{const{size:w=24,strokeWidth:x=2,absoluteStrokeWidth:R=!1,nonScalingStroke:L=!1,color:A="currentColor",className:W=""}=SA()??{},z=!!m||bA(_),[H,q,Y=[]]=_A(b,{color:e??A,width:n??t??w,height:s??t??w,strokeWidth:o??x,absoluteStrokeWidth:l??R,nonScalingStroke:d??L,className:n_(W,f),hasA11yProp:z,attributes:_});return v.createElement(H,{ref:S,...q},[...Y.map(([I,$])=>v.createElement(I,$)),...Array.isArray(m)?m:[m]])});function Nn(e,t=[],n=[]){const s=typeof e=="string"?pA(e,t,n):e,o=v.forwardRef(({className:l,...d},f)=>v.createElement(wA,{ref:f,icon:s,className:l,...d}));return s.name&&(o.displayName=gA(s.name)),o}const Hk={name:"arrow-big-up",size:24,node:[["path",{d:"M9 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-6a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-7.086-7.086a1 1 0 0 0-1.414 0l-7.086 7.086a.707.707 0 0 0 .5 1.207H8a1 1 0 0 1 1 1z",key:"106j91"}]]};Hk.node;const xA=Nn(Hk);const Uk={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Uk.node;const CA=Nn(Uk);const $k={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};$k.node;const kA=Nn($k);const Fk={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Fk.node;const TA=Nn(Fk);const Wk={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Wk.node;const EA=Nn(Wk);const Kk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Kk.node;const qk=Nn(Kk);const Vk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Vk.node;const RA=Nn(Vk);const Yk={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Yk.node;const Gk=Nn(Yk);const Xk={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"}]]};Xk.node;const cp=Nn(Xk);const Zk={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};Zk.node;const NA=Nn(Zk);const Qk={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"}]]};Qk.node;const DA=Nn(Qk);const Jk={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"}]]};Jk.node;const MA=Nn(Jk);const eT={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"}]]};eT.node;const AA=Nn(eT);const tT={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"}]]};tT.node;const LA=Nn(tT);const nT={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};nT.node;const D1=Nn(nT);const iT={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]};iT.node;const jA=Nn(iT);const rT={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"}]]};rT.node;const sT=Nn(rT);const aT={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"}]]};aT.node;const Jg=Nn(aT);const oT={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};oT.node;const OA=Nn(oT);const lT={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"}]]};lT.node;const Ll=Nn(lT);const cT={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"}]]};cT.node;const M1=Nn(cT);const uT={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"]};uT.node;const BA=Nn(uT);const dT={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"}]]};dT.node;const A1=Nn(dT);const hT={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};hT.node;const up=Nn(hT);function ya(e,t){const n=[Zt,...t.map(d=>d.id)],s=new Set(n),o=new Set,l=[];for(const d of e??[])!s.has(d)||o.has(d)||(o.add(d),l.push(d));for(const d of n)o.has(d)||l.push(d);return l}function IA(e,t){return ya(e,t).map(n=>n===Zt?null:n)}function PA(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function zA(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const L1="Local",HA=3e4,UA=2,$A=6,fT="nterminal.serverList.viewMode.v1";function FA(){try{return window.localStorage.getItem(fT)==="list"?"list":"stats"}catch{return"stats"}}function WA(e){try{window.localStorage.setItem(fT,e)}catch{}}function KA(e,t){const n=new Map(e.map(s=>[s.id,s]));return ya(t,e).flatMap(s=>{if(s===Zt)return[{kind:"main",id:Zt}];const o=n.get(s);return o?[{kind:"agent",id:s,agent:o}]:[]})}function j1(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function pT(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Xr(e.value.cpuPercent)} ${py(e.value)}`,`MEM ${Xr(e.value.memoryPercent)} ${Ta(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Xr(e.value.diskPercent)} ${Ta(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Xr(e.value.swapPercent)} ${Ta(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function O1(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Xr(e.value.cpuPercent)} (${py(e.value)})`,`RAM ${Xr(e.value.memoryPercent)} (${Ta(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Xr(e.value.diskPercent)} (${Ta(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Xr(e.value.swapPercent)} (${Ta(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function qA(e,t){const n=pT(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function Xr(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function py(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`:`${i_(e.cpuPercent/100*t)}/${t} cores`}function Ta(e,t){return!B1(e)||!B1(t)?"–/–":VA(e,t)}function VA(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${i_(e/s)}/${i_(t/s)} ${n}`}function i_(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function B1(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function bf(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function YA(e){return[{label:"CPU",percent:Xr(e.cpuPercent),detail:py(e),tone:bf(e.cpuPercent)},{label:"MEM",percent:Xr(e.memoryPercent),detail:Ta(e.memoryUsedBytes,e.memoryTotalBytes),tone:bf(e.memoryPercent)},{label:"DISK",percent:Xr(e.diskPercent),detail:Ta(e.diskUsedBytes,e.diskTotalBytes),tone:bf(e.diskPercent)},{label:"SWAP",percent:Xr(e.swapPercent),detail:Ta(e.swapUsedBytes,e.swapTotalBytes),tone:bf(e.swapPercent)}]}function GA({entry:e}){return e?.status==="offline"?u.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?u.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>u.jsxs("span",{className:"server-list-stat-cell",children:[u.jsxs("span",{className:"server-list-stat-head",children:[u.jsx("span",{className:"server-list-stat-label",children:t}),u.jsx("span",{className:"server-list-stat-value",children:"–"})]}),u.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):u.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:O1(e),"aria-label":O1(e),children:YA(e.value).map(t=>u.jsxs("span",{className:"server-list-stat-cell",children:[u.jsxs("span",{className:"server-list-stat-head",children:[u.jsx("span",{className:"server-list-stat-label",children:t.label}),u.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),u.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function I1({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:o=0,onServerLabelsChange:l,onManageAccounts:d,onServerInfo:f,renderServerChildren:m,compact:p=!1}){const[b,_]=v.useState([]),[S,w]=v.useState([Zt]),[x,R]=v.useState(null),[L,A]=v.useState(!1),[W,z]=v.useState(!1),[H,q]=v.useState(null),[Y,I]=v.useState(""),$=v.useRef(null),[de,me]=v.useState(()=>FA()),[K,ne]=v.useState(null),[ee,Z]=v.useState(null),[X,M]=v.useState({}),T=v.useRef({}),O=v.useRef(0),re=v.useRef([]),he=v.useRef([Zt]),N=v.useRef(null);v.useEffect(()=>{re.current=b},[b]),v.useEffect(()=>{const F=ya(S,b);he.current=F,j1(F,S)||w(F)},[b,S]),v.useEffect(()=>{let F=!1;return e.listAgents().then(pe=>{F||(_(pe.agents),z(!0),w(ya(pe.serverOrder,pe.agents)))}).catch(()=>{}),e.getMainInfo().then(pe=>{F||(R(pe.name),A(!0))}).catch(()=>{}),()=>{F=!0}},[e,o]),v.useEffect(()=>{H&&($.current?.focus(),$.current?.select())},[H]),v.useEffect(()=>{let F=!1;function pe(){const Re=[{key:Zt,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...b.map(be=>({key:be.id,load:()=>e.getAgentStats(be.id),probe:async()=>(await e.pingAgent(be.id)).ok}))],je=new Set(Re.map(be=>be.key));for(const be of Object.keys(T.current))je.has(be)||delete T.current[be];M(be=>{const Ue={};for(const $e of je)$e in be&&(Ue[$e]=be[$e]);return Ue});for(const be of Re)be.load().then(Ue=>{F||(T.current[be.key]=0,M($e=>je.has(be.key)?{...$e,[be.key]:{status:"online",value:Ue,stale:!1}}:$e))}).catch(async Ue=>{if(F)return;if(Ue instanceof Vn&&Ue.status===401&&be.key===Zt){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(be.key===Zt&&Ue instanceof Vn){T.current[be.key]=0,M(Be=>{if(!je.has(be.key))return Be;const ot=Be[be.key];return{...Be,[be.key]:{status:"online",value:ot?.value??null,stale:!0}}});return}if(be.probe)try{if(await be.probe()){if(F)return;T.current[be.key]=0,M(Be=>{if(!je.has(be.key))return Be;const ot=Be[be.key];return{...Be,[be.key]:{status:"online",value:ot?.value??null,stale:!0}}});return}}catch(Be){if(F)return;if(Be instanceof Vn&&Be.status===401){s?.({source:be.key===Zt?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const $e=(T.current[be.key]??0)+1;T.current[be.key]=$e,$e>=UA&&M(Be=>je.has(be.key)?{...Be,[be.key]:{status:"offline",value:Be[be.key]?.value??null,stale:!0}}:Be)})}pe();const Ce=window.setInterval(pe,HA);return()=>{F=!0,window.clearInterval(Ce)}},[e,b,s]);function V(F){F==="main"?(I(x??""),q({kind:"main"})):(I(F.name),q({kind:"agent",id:F.id}))}async function se(){if(!H)return;const F=Y.trim(),pe=H;if(q(null),pe.kind==="main"){const Ce=F||"";try{const Re=await e.renameMain(Ce);R(Re.name)}catch{}}else{if(!F)return;const Ce=b.find(Re=>Re.id===pe.id)?.name;_(Re=>Re.map(je=>je.id===pe.id?{...je,name:F}:je));try{await e.renameAgent(pe.id,F)}catch{Ce!==void 0&&_(Re=>Re.map(je=>je.id===pe.id?{...je,name:Ce}:je))}}}function J(){q(null)}function xe(F){me(F),WA(F)}function ye(F,pe,Ce){if(F===pe)return;const Re=ya(he.current,re.current),je=Re.findIndex(ht=>ht===F),be=Re.findIndex(ht=>ht===pe);if(je<0||be<0)return;const Ue=[...Re],[$e]=Ue.splice(je,1);if(!$e)return;const Be=Ue.findIndex(ht=>ht===pe);if(Be<0)return;const ot=Ce==="before"?Be:Be+1;if(Ue.splice(ot,0,$e),j1(Ue,Re))return;const ct=O.current+1;O.current=ct,he.current=Ue,w(Ue),e.reorderAgents(Ue).then(ht=>{if(O.current===ct){re.current=ht.agents;const jt=ya(ht.serverOrder,ht.agents);he.current=jt,_(ht.agents),w(jt)}}).catch(async()=>{if(O.current===ct)try{const ht=await e.listAgents();if(O.current===ct){re.current=ht.agents;const jt=ya(ht.serverOrder,ht.agents);he.current=jt,_(ht.agents),w(jt)}}catch{O.current===ct&&(he.current=Re,w(Re))}})}function Pe(F,pe){const Ce=ya(he.current,re.current),Re=Ce.findIndex(be=>be===F),je=Ce[Re+pe];Re<0||!je||ye(F,je,pe<0?"before":"after")}function Fe(F,pe){pe.pointerType==="mouse"&&pe.button!==0||(pe.stopPropagation(),N.current={sourceId:F,pointerId:pe.pointerId,startX:pe.clientX,startY:pe.clientY,active:!1,targetId:null,placement:"after"},pe.currentTarget.setPointerCapture?.(pe.pointerId))}function ze(F){const pe=N.current;if(!pe||pe.pointerId!==F.pointerId)return;const Ce=Math.hypot(F.clientX-pe.startX,F.clientY-pe.startY);if(!pe.active){if(Ce<$A)return;pe.active=!0,ne(pe.sourceId)}const je=document.elementFromPoint(F.clientX,F.clientY)?.closest("[data-server-id]"),be=je?.dataset.serverId??null;if(!je||!be||be===pe.sourceId){pe.targetId=null,Z(null);return}const Ue=je.getBoundingClientRect(),$e=F.clientY<Ue.top+Ue.height/2?"before":"after";pe.targetId=be,pe.placement=$e,Z({serverId:be,placement:$e})}function ve(F){const pe=N.current;!pe||pe.pointerId!==F.pointerId||(F.stopPropagation(),F.currentTarget.releasePointerCapture?.(F.pointerId),N.current=null,ne(null),Z(null),pe.active&&pe.targetId&&ye(pe.sourceId,pe.targetId,pe.placement))}function We(F){const pe=N.current;pe&&pe.pointerId===F.pointerId&&F.currentTarget.releasePointerCapture?.(F.pointerId),N.current=null,ne(null),Z(null)}const Oe=x?.trim()||L1,j=H?.kind==="main",ge=de==="stats",Me=KA(b,S),Le=Me.length>1;return v.useEffect(()=>{l?.([...L?[{agentId:null,label:Oe}]:[],...W?b.map(F=>({agentId:F.id,label:F.name})):[]])},[b,W,Oe,L,l]),p?u.jsx("div",{className:"server-list server-list--compact",children:Me.map(F=>{const pe=F.kind==="main",Ce=pe?Oe:F.agent.name,Re=pe?Zt:F.id,je=X[Re],be=pT(je);return u.jsxs("button",{type:"button",className:`server-list-chip${(pe?t===null:t===F.id)?" server-list-chip--active":""}`,onClick:()=>n(pe?null:F.id),"aria-label":`${Ce}${be?` — ${be}`:""}`,title:`${Ce}${be?` — ${be}`:""}`,children:[u.jsx("span",{className:"server-list-chip-initial",children:zA(Ce)}),u.jsx("span",{className:"server-list-chip-pip","data-status":PA(je)})]},F.id)})}):u.jsxs("div",{className:`server-list server-list--${de}`,children:[u.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[u.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":de==="list",onClick:()=>xe("list"),title:"Show server names only",children:"List"}),u.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":de==="stats",onClick:()=>xe("stats"),title:"Show resource usage",children:"Stats"})]}),Me.map(F=>{const pe=F.kind==="main",Ce=pe?Oe:F.agent.name,Re=pe?Zt:F.id,je=pe?t===null:t===F.id,be=pe?j:H?.kind==="agent"&&H.id===F.id,Ue=m?.({agentId:pe?null:F.id,serverId:F.id,label:Ce,active:je}),$e=ee?.serverId===F.id&&K!==F.id?` server-list-section--drop-target server-list-section--drop-${ee.placement}`:"";return u.jsxs("section",{className:`server-list-section${$e}`,"aria-label":`${Ce} server`,children:[u.jsx("div",{className:["server-list-row",K===F.id?"server-list-row--dragging":"",ee?.serverId===F.id&&K!==F.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":F.id,children:be?u.jsxs(u.Fragment,{children:[Le?u.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,u.jsx("form",{className:"server-list-editor",onSubmit:Be=>{Be.preventDefault(),se()},children:u.jsx("input",{ref:$,"aria-label":pe?"Rename main server":`Rename ${Ce}`,value:Y,onChange:Be=>I(Be.target.value),onBlur:()=>{se()},onKeyDown:Be=>{Be.key==="Escape"&&(Be.preventDefault(),J())},placeholder:pe?L1:void 0})})]}):u.jsxs(u.Fragment,{children:[Le?u.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":F.id,title:"Drag to reorder","aria-label":`Reorder ${Ce}`,"aria-grabbed":K===F.id,onPointerDown:Be=>Fe(F.id,Be),onPointerMove:ze,onPointerUp:ve,onPointerCancel:We,onKeyDown:Be=>{(Be.key==="ArrowUp"||Be.key==="ArrowDown")&&(Be.preventDefault(),Be.stopPropagation(),Pe(F.id,Be.key==="ArrowUp"?-1:1))},onClick:Be=>Be.stopPropagation(),children:"::"}):null,u.jsxs("div",{className:`server-list-item${je?" server-list-item--active":""}`,title:qA(Ce,X[Re]),children:[u.jsxs("div",{className:"server-list-item-header",children:[u.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(pe?null:F.id),onDoubleClick:Be=>{Be.preventDefault(),V(pe?"main":{id:F.id,name:Ce})},children:[u.jsx("span",{className:"server-list-dot"}),u.jsx("span",{className:"server-list-name",title:pe?void 0:F.agent.url??"Outbound connection to main",children:Ce})]}),d?u.jsx("span",{className:"server-list-provider-actions","aria-label":`${Ce} account management`,children:["codex","claude"].map(Be=>{const ot=Be==="codex"?"Codex":"Claude",ct=X[Re]?.value?.accountsReloginRequired?.includes(Be)===!0;return u.jsxs("button",{type:"button",className:`server-list-provider-button${ct?" server-list-provider-button--attention":""}`,title:ct?`Manage ${ot} accounts: a saved account needs re-login`:`Manage ${ot} accounts`,"aria-label":`Manage ${ot} accounts on ${Ce}${ct?" (re-login required)":""}`,onClick:()=>d({agentId:pe?null:F.id,label:Ce},Be),children:[u.jsx("img",{src:`/brand/${Be}.webp`,alt:""}),ct?u.jsx("span",{className:"server-list-provider-attention","aria-hidden":"true"}):null]},Be)})}):null,f&&u.jsx("button",{type:"button",className:"server-list-provider-button",title:"Server information","aria-label":`Server information: ${Ce}`,onClick:()=>f({agentId:pe?null:F.id,label:Ce}),children:u.jsx(MA,{size:17})})]}),ge?u.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(pe?null:F.id),children:u.jsx(GA,{entry:X[Re]})}):null]})]})}),Ue?u.jsx("div",{className:"server-list-children",children:Ue}):null]},F.id)})]})}function XA(e,t){if(e.refresh?.state==="reauth_required")return e.refresh.code??"reauth_required";const n=e.refreshTokenExpiresAt?Date.parse(e.refreshTokenExpiresAt):NaN;return Number.isFinite(n)&&n<=t?"refresh_token_expired":null}function ZA(e){return["refresh_token_invalidated","refresh_token_revoked","refresh_token_reused","invalid_grant"].includes(e)?"The provider revoked this login.":["refresh_token_expired","token_expired"].includes(e)?"Login expired.":e==="refresh_token_unavailable"?"No renewable login is stored for this account.":"The provider no longer accepts this login."}function QA(e,t){if(e.status!=="available")return e;let n=!1;const s=e.windows.map(o=>{const l=Date.parse(o.resetsAt??"");return!Number.isFinite(l)||l>t||o.estimatedReset?o:(n=!0,{...o,usedPercent:0,estimatedReset:!0})});return n?{...e,cached:!0,windows:s}:e}const JA={codex:[{host:"auth.openai.com",path:"/codex/device"}],claude:[{host:"claude.com",path:"/cai/oauth/authorize"},{host:"platform.claude.com",path:"/oauth/authorize"}]},eL=2048,tL=/^[A-Za-z0-9._~-]{8,512}#[A-Za-z0-9._~-]{8,512}$/,P1=1024;function nL(e,t){if(typeof t!="string"||t.length>eL)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password||n.port)return null;const s=n.hostname.toLowerCase();return JA[e].some(o=>o.host===s&&o.path===n.pathname)?n.toString():null}function iL(e,t){if(typeof t!="string"||t.length>P1+64)return null;const n=t.trim();return n.length>P1||!tL.test(n)?null:n}function rL({provider:e,serverLabel:t,api:n,disabled:s=!1,onBusyChange:o}){const[l,d]=v.useState(null),[f,m]=v.useState(!0),[p,b]=v.useState(!1),[_,S]=v.useState(null),[w,x]=v.useState(null),[R,L]=v.useState(null),A=v.useRef(null),W=v.useRef(null),z=v.useRef(null),H=v.useRef(null),q=v.useRef(null),Y=v.useRef(!1),I=v.useId(),$=v.useId(),de=e==="codex"?"Codex":"Claude",me=s||l?.reason==="preview_mode",K=z1(l),ne=e==="codex"&&!!l?.installed&&!K&&l?.reason!=="hooks_disabled",ee=v.useCallback(async()=>{const X=A.current;if(!X?.active||X.busy)return;const M=++X.generation;m(!0),x(null),L(null);let T=null;try{T=await n.getProviderHooks(e),X.active&&M===X.generation&&d(T)}catch(O){X.active&&M===X.generation&&x($1(O))}finally{X.active&&M===X.generation&&m(!1)}if(!(e!=="codex"||!T?.installed||T.trust||T.reason==="preview_mode"||T.reason==="hooks_disabled"))try{const O=await n.checkProviderHookTrust(e);X.active&&M===X.generation&&!X.busy&&O.trust&&!O.trust.reason&&d(O)}catch{}},[n,e]);v.useEffect(()=>{const X={active:!0,busy:!1,generation:0};return A.current=X,d(null),S(null),b(!1),L(null),q.current=null,ee(),()=>{X.active=!1}},[ee]),v.useEffect(()=>{_&&!p?W.current?.focus():!p&&Y.current&&(q.current==="trust"&&H.current?H:z).current?.focus(),Y.current=!!_||p;const X=M=>{M.key!=="Escape"||!_&&!p||(M.preventDefault(),M.stopImmediatePropagation(),p||S(null))};return window.addEventListener("keydown",X,!0),()=>window.removeEventListener("keydown",X,!0)},[_,p]);async function Z(){const X=A.current;if(!(!X?.active||X.busy||me||!_)){X.busy=!0,X.generation++,b(!0),m(!1),x(null),L(null),o(!0),q.current=_;try{let M=await(_==="install"?n.installProviderHooks(e):_==="remove"?n.removeProviderHooks(e):n.trustProviderHooks(e));if(!X.active)return;d(M);let T=_==="trust";_==="install"&&e==="codex"&&M.installed&&(!M.reason||M.reason==="approval_unknown"||M.reason==="approval_required")&&(S(null),M=await n.trustProviderHooks(e),T=!0),X.active&&(d(M),S(null),T?M.trust?M.trust.reason?x(U1(M.trust.reason)):z1(M)?L(lL(M.trust)):x(U1("verification_failed")):x("Codex did not report a trust result. Use /hooks in Codex instead."):M.installed!==(_==="install")&&x(M.reason?r_(M.reason):"The requested hook change was not applied."))}catch(M){X.active&&x($1(M))}finally{X.busy=!1,X.active&&(b(!1),o(!1))}}}return u.jsxs("section",{className:"provider-hooks","aria-labelledby":I,"aria-busy":f||p,children:[u.jsxs("div",{className:"provider-hooks-heading",children:[u.jsxs("div",{children:[u.jsxs("h3",{id:I,children:[u.jsx(Jg,{size:14,"aria-hidden":"true"}),"Provider hooks"]}),u.jsx("span",{className:"provider-hooks-status",role:"status",children:f?"Checking...":l?aL(l):"Status unavailable"})]}),u.jsxs("div",{className:"provider-hooks-actions",children:[u.jsx("button",{type:"button",className:"account-icon-button",title:"Refresh hook status","aria-label":"Refresh hook status",disabled:s||f||p||!!_,onClick:()=>{ee()},children:u.jsx(Ll,{size:14,"aria-hidden":"true"})}),u.jsxs("button",{ref:z,type:"button",disabled:me||f||p||!l||!!_,onClick:()=>S(l?.installed?"remove":"install"),children:[l?.installed?u.jsx(A1,{size:14,"aria-hidden":"true"}):u.jsx(Jg,{size:14,"aria-hidden":"true"}),l?.installed?"Remove hooks":"Install hooks"]})]})]}),l?.configPath?u.jsx("code",{className:"provider-hooks-path",children:l.configPath}):null,l?.notifyConfigPath?u.jsx("code",{className:"provider-hooks-path",children:l.notifyConfigPath}):null,l?.reason&&l.reason!=="approval_unknown"&&l.reason!=="approval_required"?u.jsxs("p",{className:"provider-hooks-reason",children:[r_(l.reason),l.reason==="unsafe_path"&&l.unsafePath?u.jsxs(u.Fragment,{children:[" ",u.jsx("code",{children:l.unsafePath})]}):null]}):null,l?.warnings?.length?u.jsx("ul",{className:"provider-hooks-warnings",children:l.warnings.map(X=>u.jsx("li",{children:cL(X)},X))}):null,e==="codex"&&K?u.jsxs("p",{className:"provider-hooks-trusted",children:["Codex reports ",oL(l?.trust?.total??l?.hookCount)," as trusted."]}):e==="codex"&&(l?.installed||l?.approvalRequired||l?.activity?.observed)&&!p?u.jsxs("p",{className:"provider-hooks-trust",children:["In Codex, open ",u.jsx("code",{children:"/hooks"})," and trust the NTerminal hooks.",l?.activity?.observed?" Events received from at least one hook; other hooks may still need approval.":null,l?.trust&&!l.trust.reason&&l.trust.pending>0?` Codex reports ${l.trust.pending} of ${l.trust.total} still need approval.`:null]}):null,ne&&!p?u.jsx("div",{className:"provider-hooks-actions",children:u.jsxs("button",{ref:H,type:"button",disabled:me||f||p||!!_,onClick:()=>S("trust"),children:[u.jsx(M1,{size:14,"aria-hidden":"true"}),"Trust NTerminal hooks in Codex"]})}):null,e==="codex"&&l?.installed&&l.activity?.unboundPanes?.length?u.jsx(sL,{panes:l.activity.unboundPanes}):null,_?u.jsxs("div",{className:"provider-hooks-confirm",role:"group","aria-labelledby":$,children:[_==="trust"?u.jsxs(u.Fragment,{children:[u.jsxs("p",{id:$,children:["Trust ",H1(l?.hookCount)," Codex hooks on ",t,"?"]}),u.jsxs("p",{children:["This marks only ",H1(l?.hookCount)," Codex hooks as trusted in Codex's ",u.jsx("code",{children:"config.toml"}),", the same as pressing Trust in ",u.jsx("code",{children:"/hooks"}),". Codex performs the change; other hooks stay as they are."]}),u.jsxs("p",{children:["Trusted hooks run outside the Codex sandbox. The command it trusts is the NTerminal hook helper",l?.hookCommand?":":"."]}),l?.hookCommand?u.jsx("code",{className:"provider-hooks-path",children:l.hookCommand}):null]}):u.jsxs(u.Fragment,{children:[u.jsxs("p",{id:$,children:[_==="install"?"Install":"Remove"," ",de," hooks on ",t,"?"]}),u.jsx("p",{children:_==="install"?e==="codex"?"Install and trust only NTerminal hooks in Codex. Trusted hooks run outside the Codex sandbox; other hooks stay unchanged.":"Add NTerminal hooks to this provider's configuration?":"Remove NTerminal hooks from this provider's configuration?"})]}),u.jsxs("div",{className:"provider-hooks-actions",children:[u.jsx("button",{ref:W,type:"button",disabled:p,onClick:()=>S(null),children:"Cancel"}),u.jsxs("button",{type:"button",className:_==="remove"?"danger-button":"primary-button",disabled:me||p,onClick:()=>{Z()},children:[p?u.jsx(D1,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"}):_==="install"?u.jsx(Jg,{size:14,"aria-hidden":"true"}):_==="trust"?u.jsx(M1,{size:14,"aria-hidden":"true"}):u.jsx(A1,{size:14,"aria-hidden":"true"}),p?"Applying...":_==="install"?"Confirm installation":_==="trust"?"Confirm trust":"Confirm removal"]})]})]}):null,p&&!_?u.jsxs("p",{className:"provider-hooks-notice",role:"status",children:[u.jsx(D1,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"})," Trusting NTerminal hooks in Codex..."]}):null,R?u.jsx("p",{className:"provider-hooks-notice",role:"status",children:R}):null,w?u.jsx("p",{className:"provider-hooks-error",role:"alert",children:w}):null]})}function sL({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 u.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 ",u.jsx("code",{children:"--no-daemon"}),"."]})}function aL(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 z1(e){return!!(e?.installed&&e.trust&&!e.trust.reason&&e.trust.pending===0&&e.trust.total>0)}function oL(e){return e===void 0?"all NTerminal hooks":e===1?"the NTerminal hook":`all ${e} NTerminal hooks`}function H1(e){return e===void 0?"NTerminal's":`NTerminal's ${e}`}function lL(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 U1(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]??r_(e)}function $1(e){if(e instanceof Vn){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 r_(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 cL(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 uL(e){const[t,n]=v.useState({api:e.api,provider:e.provider,revision:0});return t.api!==e.api||t.provider!==e.provider?(n({api:e.api,provider:e.provider,revision:t.revision+1}),null):u.jsx(dL,{...e},t.revision)}function dL({provider:e,serverLabel:t,api:n,onClose:s}){const[o,l]=v.useState(null),[d,f]=v.useState(!0),[m,p]=v.useState(null),[b,_]=v.useState(!1),[S,w]=v.useState(null),[x,R]=v.useState(""),[L,A]=v.useState(null),[W,z]=v.useState(!1),[H,q]=v.useState(()=>Date.now()),[Y,I]=v.useState({}),[$,de]=v.useState(!0),[me,K]=v.useState(!1),[ne,ee]=v.useState(!1),Z=v.useRef(null),X=v.useCallback(async(N=!1)=>{const V=Z.current;if(!V?.active||V.actionPending||N&&V.statusPending)return;const se=++V.statusGeneration;V.statusPending=!0,N||(f(!0),w(null));try{const J=await n.getAccounts();V.active&&se===V.statusGeneration&&l(J)}catch(J){V.active&&se===V.statusGeneration&&!N&&w(W1(J))}finally{V.active&&se===V.statusGeneration&&(V.statusPending=!1,N||f(!1))}},[n]),M=v.useCallback(async()=>{const N=Z.current;if(!(!N?.active||N.actionPending)&&(N.usageGeneration+=1,N.usageQueued=!0,!N.usagePending)){N.usagePending=!0,de(!0);do{N.usageQueued=!1;const V=N.usageGeneration;try{const se=await n.getAccountUsage(e);if(se.provider!==e)throw new Error("Unexpected account usage provider");N.active&&V===N.usageGeneration&&(I(Object.fromEntries(se.profiles.map(J=>[J.profileId,J.usage]))),K(!1),ee(!1),q(Date.now()))}catch{N.active&&V===N.usageGeneration&&(K(!0),ee(!0))}}while(N.active&&N.usageQueued&&!N.actionPending);N.usagePending=!1,N.active&&de(!1)}},[n,e]),T=v.useMemo(()=>o?.providers.find(N=>N.provider===e)??null,[e,o]);v.useEffect(()=>{const N={active:!0,actionPending:!1,statusGeneration:0,statusPending:!1,usageGeneration:0,usagePending:!1,usageQueued:!1};return Z.current=N,X(),M(),()=>{N.active=!1}},[X,M]),v.useEffect(()=>{const N=V=>{V.key==="Escape"&&!V.defaultPrevented&&!m&&!b&&(W?z(!1):s())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[s,m,b,W]),v.useEffect(()=>{const N=window.setInterval(()=>q(Date.now()),6e4);return()=>window.clearInterval(N)},[]),v.useEffect(()=>{if(!T?.pendingLogin||m)return;const V=window.setInterval(()=>{X(!0)},1500);return()=>window.clearInterval(V)},[m,T?.pendingLogin,X]),v.useEffect(()=>{if(!T?.pendingLogin)return;const N=window.setInterval(()=>q(Date.now()),15e3);return()=>window.clearInterval(N)},[T?.pendingLogin]);async function O(N,V){const se=Z.current;if(!se?.active||se.actionPending||b)return!1;se.actionPending=!0,se.statusGeneration+=1,se.statusPending=!1,se.usageGeneration+=1,K(!0),f(!1),p(N),w(null);try{const J=await V();return se.active&&l(J),!0}catch(J){return se.active&&w(W1(J)),!1}finally{se.actionPending=!1,se.active&&(p(null),X(!0),M())}}async function re(N=null){A(N?.label??null),R(""),await O("login",()=>n.beginAccountLogin(e))}const he=e==="codex"?"Codex":"Claude";return u.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&!m&&!b&&s()},children:[u.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${he} accounts on ${t}`,children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"account-dialog-title",children:[u.jsx(xL,{provider:e}),u.jsxs("div",{children:[u.jsxs("h2",{children:[he," accounts"]}),u.jsx("p",{children:t})]})]}),u.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",title:"Close accounts",onClick:s,disabled:!!m||b,children:u.jsx(up,{size:16,"aria-hidden":"true"})})]}),u.jsxs("div",{className:"account-dialog-scroll",children:[d&&!T?u.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,T?u.jsx(hL,{provider:e,status:T,pendingAction:m??(b?"hooks":null),clock:H,usage:Y,usageLoading:$,usageStale:me,label:x,onLabelChange:R,onSelect:N=>{O(`select:${N}`,()=>n.selectAccount(e,N))},onRename:(N,V)=>O(`rename:${N}`,()=>n.renameAccount(e,N,V)),onDelete:N=>{O(`delete:${N}`,()=>n.removeAccount(e,N))},onRefresh:N=>{O(`refresh:${N}`,()=>n.refreshAccount(e,N))},onBeginLogin:()=>{re()},onRelogin:N=>{re(N)},reloginFor:L,onCompleteLogin:()=>{O("complete",()=>n.completeAccountLogin(e,x))},onCancelLogin:()=>{O("cancel",()=>n.cancelAccountLogin(e))},onSubmitCode:async N=>{await O("code",()=>n.submitAccountLoginCode(e,N))},onRequestTerminate:()=>z(!0)}):null,ne?u.jsx("p",{className:"account-dialog-muted account-usage-error",role:"status",children:"Usage could not be updated. Previous readings, if any, are stale."}):null,S?u.jsx("p",{className:"account-dialog-error",role:"alert",children:S}):null,u.jsx(rL,{provider:e,serverLabel:t,api:n,disabled:!!m||W,onBusyChange:_})]}),u.jsxs("footer",{className:"account-dialog-footer",children:[u.jsxs("button",{type:"button",title:"Reload account metadata and usage; does not refresh OAuth credentials",onClick:()=>{X(),M()},disabled:d||!!m||b,children:[u.jsx(Ll,{size:14,"aria-hidden":"true"}),"Refresh"]}),u.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:!!m||b,children:"Close"})]})]}),W?u.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&!m&&z(!1)},children:u.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${he} sessions`,children:[u.jsxs("h3",{children:["Exit all ",he," sessions?"]}),u.jsxs("p",{children:["This stops detected ",he," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),e==="codex"?u.jsx("p",{children:"The shared Codex daemon will also stop. All Codex work using that daemon is affected."}):null,u.jsxs("div",{children:[u.jsx("button",{type:"button",onClick:()=>z(!1),disabled:!!m,children:"Cancel"}),u.jsx("button",{type:"button",className:"danger-button",disabled:!!m,onClick:()=>{z(!1),O("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function hL({provider:e,status:t,pendingAction:n,clock:s,usage:o,usageLoading:l,usageStale:d,label:f,onLabelChange:m,onSelect:p,onRename:b,onDelete:_,onRefresh:S,onBeginLogin:w,onRelogin:x,reloginFor:R,onCompleteLogin:L,onCancelLogin:A,onSubmitCode:W,onRequestTerminate:z}){const H=t.runningProcesses??[],q=t.runningPanes.length>0||H.length>0||t.processCheckUnavailable===!0,Y=e==="codex"?"Codex":"Claude",I=t.application?.profileId===t.activeProfileId&&t.application.state==="pending",$=I?t.application?.reason??null:null,de=e==="codex"&&t.runningPanes.length===0&&H.length>0&&H.every(T=>T.role==="daemon")&&t.processCheckUnavailable!==!0,me=$==="daemon_in_use"||$==="daemon_busy"||$==="daemon_unverified"||$==="sessions_running",K=q?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsx("strong",{children:de?"Only the shared Codex background server is running. Apply restarts it automatically when no Codex session is using it.":`${Y} is running. Changing accounts here does not stop these sessions; they keep their current account until restarted.`}),e==="codex"&&!de?u.jsx("small",{children:"New Codex sessions started through the shared background server may also use the previous account until that server restarts."}):null,t.runningPanes.map(T=>u.jsxs("span",{children:[u.jsx("b",{children:T.title}),u.jsx("small",{children:T.cwd})]},T.terminalId)),H.map(T=>u.jsxs("span",{children:[u.jsxs("b",{children:[T.command," ",u.jsxs("em",{children:["PID ",T.pid]})]}),u.jsx("small",{children:T.role==="daemon"?"Shared Codex daemon / manager":"Provider process on this server"})]},T.pid)),t.processCheckUnavailable?u.jsxs("span",{children:[u.jsx("b",{children:"Process check unavailable"}),u.jsx("small",{children:"Running sessions could not be listed. Refreshing the active account's credentials is paused until they can."})]}):null,!t.processCheckUnavailable&&(!de||me)?u.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:z,children:["Exit all ",Y," sessions"]}):null]}):null;if(t.pendingLogin){const T=t.pendingLogin,O=T.ready&&(T.login?.phase??"done")==="done";return u.jsxs(u.Fragment,{children:[K,u.jsxs("div",{className:"account-dialog-section account-login",children:[R?u.jsxs("p",{className:"account-dialog-muted",children:["Signing in again to ",u.jsx("b",{children:R}),". Use the same account: its saved name is kept, and it becomes the active account when saved."]}):null,O?u.jsxs(u.Fragment,{children:[u.jsx("p",{children:"Sign-in completed. Name this account to save it in the server vault."}),u.jsxs("label",{className:"account-dialog-label",children:["Account name",u.jsx("input",{value:f,onChange:re=>m(re.target.value),placeholder:T.suggestedLabel??(R?"Leave blank to keep the saved name":`${Y} account`),maxLength:80,autoFocus:!0})]}),T.suggestedLabel?u.jsxs("p",{className:"account-dialog-muted account-login-suggested",children:["Leave blank to save it as ",u.jsx("b",{children:T.suggestedLabel}),". You can rename it later by clicking its name."]}):null]}):u.jsx(vL,{provider:e,pending:T,clock:s,busy:!!n,onSubmitCode:W}),u.jsxs("div",{className:"account-dialog-inline-actions",children:[O?u.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:L,children:"Save account"}):null,u.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:A,children:"Cancel and restore previous"})]})]})]})}const ne=t.lastExternalSwitch??null,ee=ne?t.profiles.find(T=>T.id===ne.fromProfileId&&T.id!==t.activeProfileId):void 0,Z=ne?.toProfileId?t.profiles.find(T=>T.id===ne.toProfileId):void 0,X=ee?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsx("strong",{children:Z?`${Y} on this server was switched to ${Z.label} outside NTerminal, for example by a running session that still used it.`:`The ${Y} login on this server was removed outside NTerminal.`}),u.jsxs("span",{children:[ee.label," is still saved. Restart old ",Y," sessions, then press Use on ",ee.label,"."]})]}):null,M=t.loginNotice?.code==="login_timed_out"?u.jsx("p",{className:"account-dialog-error",role:"status",children:"The sign-in timed out and was stopped. The previous account was restored."}):null;return u.jsxs(u.Fragment,{children:[K,X,M,I?u.jsxs("p",{className:"account-dialog-error",role:"status",children:["Account saved; CLI setup is pending. ",fL($,Y)]}):null,u.jsxs("div",{className:"account-dialog-section",children:[u.jsxs("div",{className:"account-dialog-section-heading",children:[u.jsx("span",{children:"Saved accounts"}),u.jsxs("button",{type:"button",className:"primary-button",disabled:!!n,onClick:w,children:[u.jsx(OA,{size:14,"aria-hidden":"true"}),"Add account"]})]}),t.profiles.length===0?u.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map(T=>{const O=T.id===t.activeProfileId,re=XA(T,s);return u.jsxs("article",{className:`account-profile${O?" account-profile--active":""}${re?" account-profile--relogin":""}`,children:[u.jsxs("div",{children:[u.jsx(pL,{profile:T,pending:n===`rename:${T.id}`,disabled:!!n,onRename:he=>b(T.id,he)}),T.email&&T.email!==T.label?u.jsx("small",{className:"account-profile-email",title:T.email,children:T.email}):null,u.jsxs("small",{title:kL(T.expiresAt),children:[O?I?"Selected (setup pending)":"Active":"Saved"," · ",CL(T.expiresAt,s)," · ",TL(T.updatedAt,s)]}),u.jsx(wL,{refresh:T.refresh,clock:s}),re?u.jsxs("div",{className:"account-relogin",role:"status","aria-label":`${T.label}: re-login required`,children:[u.jsx("span",{className:"account-relogin-badge",children:"Re-login required"}),u.jsx("span",{className:"account-relogin-reason",children:ZA(re)}),u.jsxs("button",{type:"button",className:"primary-button",title:`Sign in to ${T.label} again; its saved name is kept`,disabled:!!n,onClick:()=>x(T),children:[u.jsx(jA,{size:14,"aria-hidden":"true"}),"Sign in again"]})]}):null]}),u.jsxs("div",{className:"account-profile-actions",children:[u.jsxs("button",{type:"button",title:O?`Apply ${T.label} to new CLI sessions`:`Use ${T.label}`,disabled:!!n||O&&t.application?.state==="ready",onClick:()=>p(T.id),children:[u.jsx(kA,{size:14,"aria-hidden":"true"}),O?"Apply":"Use"]}),u.jsxs("button",{type:"button",title:O&&q?t.processCheckUnavailable?"Credential refresh deferred: process check unavailable":"Managed by running CLI":"Refresh OAuth credentials (rotates tokens); does not reset usage limits",disabled:O&&q||!!n,onClick:()=>S(T.id),children:[u.jsx(AA,{size:14,"aria-hidden":"true"}),"Refresh credentials"]}),u.jsx("button",{type:"button",className:"danger-button account-icon-button","aria-label":`Remove ${T.label}`,title:`Remove ${T.label}`,disabled:!!n||O,onClick:()=>_(T.id),children:u.jsx(BA,{size:14,"aria-hidden":"true"})})]}),u.jsx(SL,{usage:o[T.id],loading:l,stale:d,clock:s})]},T.id)})]})]})}function fL(e,t){switch(e){case"sessions_running":return`Exit existing ${t} sessions, then press Apply again.`;case"daemon_in_use":return"A Codex session is still connected to the shared Codex background server or is still running a turn. Exit it, then press Apply again.";case"daemon_busy":return"The shared Codex background server is still running commands started by Codex. Wait for them to finish, or exit all Codex sessions, then press Apply again.";case"daemon_unverified":return"The shared Codex background server could not be verified for a safe restart. Exit all Codex sessions, then press Apply again.";default:return"CLI setup could not be verified. Your credentials are saved. Press Apply to retry."}}function pL({profile:e,pending:t,disabled:n,onRename:s}){const[o,l]=v.useState(null),d=v.useRef(!1),f=v.useRef(!1),m=v.useRef(null),p=v.useRef(null),b=v.useRef(!1);v.useEffect(()=>{o===null&&b.current&&(b.current=!1,m.current?.focus())},[o]);function _(){d.current=!1,b.current=!0,l(null)}async function S(){if(o===null||!d.current||f.current)return;if(o.trim()===e.label){_();return}f.current=!0;const w=await s(o);f.current=!1,d.current&&(w?_():window.setTimeout(()=>p.current?.focus(),0))}return o===null?u.jsx("span",{className:"account-profile-name",children:u.jsxs("button",{type:"button",ref:m,className:"account-profile-name-button","aria-label":`Rename ${e.label}`,title:"Click to rename",disabled:n,onClick:()=>{d.current=!0,l(e.label)},children:[u.jsx("strong",{children:e.label}),u.jsx(sT,{size:11,"aria-hidden":"true"})]})}):u.jsxs("span",{className:"account-profile-name account-profile-name--editing",children:[u.jsx("input",{ref:p,className:"account-profile-name-input","aria-label":`Account name for ${e.label}`,value:o,maxLength:80,autoFocus:!0,disabled:t,"aria-busy":t||void 0,placeholder:e.email??"Account name",onFocus:w=>w.currentTarget.select(),onChange:w=>l(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),S()):w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),_())},onBlur:()=>{S()}}),t?u.jsx("small",{role:"status",children:"Saving..."}):null]})}const mL=2*6e4,gL=2e4;function vL({provider:e,pending:t,clock:n,busy:s,onSubmitCode:o}){const[l,d]=v.useState(""),[f,m]=v.useState(null),p=t.login??{phase:"starting"},b=e==="codex"?"Codex":"Claude",_=nL(e,p.verificationUrl),S=e==="codex"&&p.userCode&&/^[A-Z0-9-]{3,40}$/.test(p.userCode)?p.userCode:null,w=p.expiresAt?my(p.expiresAt,n):null,x=p.phase==="starting"&&n-Date.parse(t.startedAt)>gL,R=p.recentOutput??[];async function L(A){A.preventDefault();const W=iL("claude",l);if(!W){m("Paste the complete code shown after approval, including the part after #.");return}m(null),await o(W),d("")}return p.phase==="failed"?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"account-dialog-error account-login-failed",role:"alert",children:p.message??`The ${b} sign-in failed.`}),u.jsx("p",{className:"account-dialog-muted",children:"Cancel to restore the previous account, then start the sign-in again."}),u.jsx(F1,{lines:R,open:!0})]}):p.phase==="starting"||!_?u.jsxs(u.Fragment,{children:[u.jsxs("p",{role:"status",children:["Starting the ",b," sign-in on the server..."]}),x?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"account-dialog-muted",children:"This is taking longer than expected. The login command may be waiting for something else."}),u.jsx(F1,{lines:R})]}):null]}):u.jsxs(u.Fragment,{children:[u.jsxs("ol",{className:"account-login-steps",children:[u.jsxs("li",{children:[u.jsx("span",{children:e==="codex"?"Open this page in any browser and sign in:":"Open this page in any browser and approve access:"}),u.jsx(_L,{url:_})]}),e==="codex"?u.jsxs("li",{children:[u.jsxs("span",{children:["Enter this one-time code",w?u.jsxs("small",{children:[" (expires ",w,")"]}):null,":"]}),S?u.jsx(bL,{code:S}):u.jsx("small",{className:"account-dialog-muted",children:"Waiting for the code..."})]}):u.jsxs("li",{children:[u.jsx("span",{children:"After approving, copy the code the page shows and paste it here:"}),u.jsxs("form",{className:"account-login-code-form",onSubmit:A=>{L(A)},children:[u.jsxs("label",{className:"account-dialog-label",children:["Authorization code",u.jsx("input",{value:l,onChange:A=>{d(A.target.value),m(null)},autoComplete:"off",autoCapitalize:"off",spellCheck:!1,maxLength:1100,disabled:s||p.phase==="completing","aria-invalid":f?!0:void 0,placeholder:"code#state"})]}),u.jsx("button",{type:"submit",className:"primary-button",disabled:s||p.phase==="completing"||!l.trim(),children:"Submit"})]})]})]}),f?u.jsx("p",{className:"account-dialog-error",role:"alert",children:f}):null,p.message&&p.phase!=="completing"?u.jsx("p",{className:"account-dialog-error",role:"alert",children:p.message}):null,u.jsx("p",{className:"account-login-waiting",role:"status",children:p.phase==="completing"?"Completing...":e==="codex"?"Waiting for approval...":"Waiting for the code..."}),u.jsxs("p",{className:"account-dialog-muted",children:["Only continue if you started this sign-in. The link and code come from the official ",b," CLI running on this server."]})]})}function F1({lines:e,open:t=!1}){return e.length===0?null:u.jsxs("details",{className:"account-login-output",open:t,children:[u.jsx("summary",{children:"Recent login output"}),u.jsx("pre",{children:e.join(`
|
|
15
|
-
`)})]})}function _L({url:e}){const t=v.useRef(null),[n,s]=mT();return u.jsxs("div",{className:"account-login-url",children:[u.jsx("code",{ref:t,children:e}),u.jsxs("div",{className:"account-dialog-inline-actions",children:[u.jsxs("a",{className:"account-login-open",href:e,target:"_blank",rel:"noopener noreferrer",children:[u.jsx(NA,{size:14,"aria-hidden":"true"}),"Open"]}),u.jsxs("button",{type:"button",onClick:()=>{s(e,t.current)},children:[u.jsx(cp,{size:14,"aria-hidden":"true"}),"Copy link"]}),n?u.jsx("small",{className:"account-login-copied",role:"status",children:n}):null]})]})}function bL({code:e}){const t=v.useRef(null),[n,s]=mT();return u.jsxs("div",{className:"account-login-user-code",children:[u.jsx("code",{ref:t,"aria-label":"One-time code",children:e}),u.jsxs("button",{type:"button",onClick:()=>{s(e,t.current)},children:[u.jsx(cp,{size:14,"aria-hidden":"true"}),"Copy code"]}),n?u.jsx("small",{className:"account-login-copied",role:"status",children:n}):null]})}function mT(){const[e,t]=v.useState(null),n=v.useRef(null);v.useEffect(()=>()=>{n.current!==null&&window.clearTimeout(n.current)},[]);const s=v.useCallback(async(o,l)=>{const d=await yL(o,l);t(d==="copied"?"Copied":d==="selected"?"Selected: press Ctrl+C (Cmd+C) to copy":"Copy failed: select the text manually"),n.current!==null&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(null),d==="copied"?2e3:6e3)},[]);return[e,s]}async function yL(e,t){try{if(window.isSecureContext&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),"copied"}catch{}const n=document.activeElement instanceof HTMLElement?document.activeElement:null,s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.opacity="0",document.body.appendChild(s);try{if(s.select(),typeof document.execCommand=="function"&&document.execCommand("copy"))return"copied"}catch{}finally{s.remove(),n?.focus()}if(t){const o=window.getSelection(),l=document.createRange();return l.selectNodeContents(t),o?.removeAllRanges(),o?.addRange(l),"selected"}return"failed"}function SL({usage:e,loading:t,stale:n,clock:s}){e&&(e=QA(e,s));const o=e?.status==="available"?e.windows.filter(m=>Number.isFinite(m.usedPercent)&&m.usedPercent>=0&&m.usedPercent<=100):[],l=e?Date.parse(e.checkedAt):NaN,d=!!e&&(n||!Number.isFinite(l)||s-l>=mL||o.some(m=>m.resetsAt&&Date.parse(m.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==="access_token_expired"?"Weekly usage unavailable: no saved reading":e?.code==="usage_authentication_required"?"Weekly usage unavailable: access token not accepted":"Weekly usage unavailable";return u.jsxs("div",{className:"account-quota","aria-label":"Account usage","aria-busy":t,title:"Read-only usage check; does not rotate credentials",children:[o.some(m=>m.kind==="weekly")?null:u.jsx("span",{className:"account-quota-unavailable",children:f}),["weekly","session"].map(m=>{const p=o.find(_=>_.kind===m);if(!p)return null;const b=Math.round((100-p.usedPercent)*10)/10;return u.jsxs("div",{className:"account-quota-window",children:[u.jsxs("span",{children:[m==="weekly"?"Weekly":"Session"," ",u.jsxs("b",{className:b<=10?"account-quota-critical":b<=25?"account-quota-warning":void 0,children:[b,"% remaining"]})]}),u.jsx("small",{title:p.estimatedReset?`Estimated from the previous reset time: ${Ld(p.resetsAt)}. Usage since then has not been checked.`:Ld(p.resetsAt),children:p.estimatedReset?"Reset (estimated)":p.resetsAt&&Number.isFinite(Date.parse(p.resetsAt))?`Resets ${my(p.resetsAt,s)}`:"Reset time unavailable"})]},m)}),u.jsxs("small",{className:"account-quota-check",children:[e?u.jsxs(u.Fragment,{children:["Last checked ",u.jsx("time",{dateTime:e.checkedAt,children:Ld(e.checkedAt)})]}):"Not yet checked",e?.cached?u.jsx("span",{children:"Cached"}):d?u.jsx("span",{className:"account-quota-warning",children:"Stale"}):null,t&&e?u.jsx("span",{children:"Updating..."}):null]}),e?.code&&e.code!=="access_token_expired"?u.jsx("small",{className:"account-diagnostic-code",children:e.code}):null]})}function wL({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 u.jsxs("div",{className:`account-refresh-status account-refresh-status--${e.state}`,children:[u.jsxs("span",{children:[s,e.nextRetryAt?` · Next retry ${my(e.nextRetryAt,t)}`:""]}),e.lastAttemptAt?u.jsxs("small",{children:["Last attempt ",Ld(e.lastAttemptAt)]}):null,e.lastSuccessAt?u.jsxs("small",{children:["Last success ",Ld(e.lastSuccessAt)]}):null,e.code||e.httpStatus!==null?u.jsx("small",{className:"account-diagnostic-code",children:[e.code,e.httpStatus!==null?`HTTP ${e.httpStatus}`:null].filter(Boolean).join(" · ")}):null]})}function Ld(e){return e&&Number.isFinite(Date.parse(e))?new Date(e).toLocaleString():"Timestamp unavailable"}function my(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 xL({provider:e}){return u.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function CL(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 kL(e){return!e||!Number.isFinite(Date.parse(e))?"Access token expiry timestamp unavailable":`Access token expires ${new Date(e).toLocaleString()}`}function TL(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 W1(e){return e instanceof Vn?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",codex_daemon_stop_failed:"Could not stop the shared Codex daemon. No account was switched. Stop the daemon and try again.",account_operation_busy:"Another account operation is in progress. Try again shortly.",account_process_check_unavailable:"Could not verify running CLI processes. Refreshing the active account is paused.",active_cli_refresh_deferred:"Credentials are managed by the running CLI. Refresh is deferred.",account_credential_changed:"Credentials changed during refresh. Refresh the account list before trying again.",account_login_already_pending:"Finish or cancel the current sign-in first.",account_login_not_complete:"The provider login has not finished yet.",account_login_not_pending:"No sign-in is in progress. Start it again.",account_login_code_invalid:"Paste the complete code shown after approval, including the part after #.",account_login_code_not_expected:"The login command is not waiting for a code right now.",account_login_code_attempts_exceeded:"Too many codes were submitted. Cancel and start the sign-in again.",account_login_process_unavailable:"The login command is not running on the server. Cancel and try again.",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.",account_not_found:"That account is no longer saved on this server. Refresh the list.",account_label_required:"Enter a name for this account.",account_label_invalid:"Account names can be at most 80 characters.",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 EL(e){const t=new Map(e.map(l=>[l.pid,{process:l,children:[],count:1,cpuPercent:l.cpuPercent,memoryBytes:l.memoryBytes}])),n=[];for(const l of t.values()){const d=t.get(l.process.ppid);d&&d!==l?d.children.push(l):n.push(l)}const s=[...n],o=new Set;for(let l=0;l<s.length;l++){const d=s[l];o.add(d.process.pid);for(const f of d.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 d=s[l];for(const f of d.children)d.count+=f.count,d.cpuPercent+=f.cpuPercent,d.memoryBytes+=f.memoryBytes}return n}const s_=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function RL({api:e,label:t,main:n,favorites:s,targets:o,onClose:l,onFavorite:d,onTarget:f,getRuntimeStatus:m,targetStatus:p}){const[b,_]=v.useState(null),[S,w]=v.useState(null),[x,R]=v.useState(!0),[L,A]=v.useState(!0),[W,z]=v.useState(null),[H,q]=v.useState(!1),[Y,I]=v.useState(null),[$,de]=v.useState(""),[me,K]=v.useState(!1),[ne,ee]=v.useState(null),Z=v.useRef(null),X=v.useRef(l);X.current=l;const M=v.useRef(!0);async function T(J=!1){R(!0);try{const xe=await e.getServerExternalIp(J);M.current&&_(xe)}catch{M.current&&_(xe=>({address:xe?.address??null,checkedAt:xe?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{M.current&&R(!1)}}async function O(){A(!0),z(null);try{const J=await e.getServerProcesses();M.current&&w(J)}catch{M.current&&z("Could not retrieve processes. The server may be offline or need an update.")}finally{M.current&&A(!1)}}v.useEffect(()=>(M.current=!0,T(),O(),()=>{M.current=!1}),[e]),v.useEffect(()=>{const J=document.activeElement;Z.current?.focus();const xe=ye=>{if(ye.key==="Escape"){ye.preventDefault(),ye.stopImmediatePropagation(),X.current();return}if(ye.key==="Tab"){const Pe=[...Z.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(ze=>ze.getClientRects().length>0),Fe=Pe.indexOf(document.activeElement);Pe.length&&(Fe<0||(ye.shiftKey?Fe===0:Fe===Pe.length-1))&&(ye.preventDefault(),Pe[ye.shiftKey?Pe.length-1:0]?.focus()),ye.stopPropagation();return}Z.current?.contains(ye.target)||(ye.preventDefault(),ye.stopImmediatePropagation())};return window.addEventListener("keydown",xe,!0),()=>{window.removeEventListener("keydown",xe,!0),J instanceof HTMLButtonElement&&J.isConnected&&J.focus({preventScroll:!0})}},[]);async function re(J){try{await navigator.clipboard.writeText(J),q(!1)}catch{q(!0)}}async function he(J){if(!(me||!$.trim())){K(!0),ee(null);try{const xe=await e.renameServerProject(J,$.trim());if(!M.current)return;w(ye=>ye&&{...ye,projects:ye.projects.map(Pe=>Pe.path===J?{...Pe,name:xe.name}:Pe)}),I(null)}catch{M.current&&ee("Could not save project name.")}finally{M.current&&K(!1)}}}const N=v.useMemo(()=>S?.projects.filter(J=>J.category!=="services")??[],[S]),V=v.useMemo(()=>{const J=S?.projects.filter(xe=>xe.category==="services")??[];return N.length?[...J,{name:"Development tools",path:"",category:"tools",cpuPercent:N.reduce((xe,ye)=>xe+ye.cpuPercent,0),memoryBytes:N.reduce((xe,ye)=>xe+ye.memoryBytes,0),processes:N.flatMap(xe=>xe.processes)}]:J},[S,N]);function se(J){const xe=J.path?o.filter(ye=>ye.cwd===J.path||ye.cwd.startsWith(J.path.replace(/\/$/,"")+"/")):[];return u.jsxs(u.Fragment,{children:[J.category!=="services"&&u.jsxs("div",{className:"server-info-tool-name",children:[u.jsx(DA,{size:15,"aria-hidden":"true"}),u.jsx("strong",{children:J.path?J.name:"Shared tools"})]}),u.jsxs("div",{className:"server-info-path",children:[u.jsx("code",{children:J.path||"Shared across projects"}),J.path&&u.jsxs(u.Fragment,{children:[u.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{re(J.path)},children:u.jsx(cp,{size:14})}),u.jsx("button",{disabled:L||me,title:"Rename project","aria-label":`Rename ${J.name}`,onClick:()=>{I(`${J.category}:${J.path}`),de(J.name),ee(null)},children:u.jsx(sT,{size:14})})]})]}),Y===`${J.category}:${J.path}`&&u.jsxs("form",{className:"server-info-rename",onSubmit:ye=>{ye.preventDefault(),he(J.path)},children:[u.jsx("input",{"aria-label":"Project display name",maxLength:80,value:$,disabled:me,onChange:ye=>de(ye.target.value)}),u.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:me||!$.trim(),children:u.jsx(qk,{size:16})}),u.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:me,onClick:()=>I(null),children:u.jsx(up,{size:16})}),ne&&u.jsx("small",{role:"alert",className:"server-info-error",children:ne})]}),J.path&&u.jsx("div",{className:"server-info-targets",children:xe.length?xe.map(ye=>u.jsxs("button",{onClick:()=>f(ye),title:`Open ${ye.label}`,children:[u.jsx(TA,{size:14}),ye.label]},ye.terminalId)):u.jsx("button",{disabled:!0,children:p??"No open tab"})}),u.jsx(NL,{processes:J.processes})]})}return u.jsx("div",{className:"server-info-backdrop",onMouseDown:J=>{J.target===J.currentTarget&&l()},children:u.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:Z,onKeyDown:J=>J.stopPropagation(),children:[u.jsxs("header",{children:[u.jsxs("div",{children:[u.jsx("h2",{children:t}),u.jsx("small",{children:n?"Main":"Secondary"})]}),u.jsx("button",{title:"Close","aria-label":"Close server information",onClick:l,children:u.jsx(up,{size:18})})]}),u.jsxs("div",{className:"server-info-body",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"server-info-ip",children:[u.jsx("h3",{title:"External IPv4",children:"IPv4"}),u.jsx("code",{title:b?.checkedAt?`Checked ${new Date(b.checkedAt).toLocaleString()}`:void 0,children:b?.address??(x?"Loading...":"Unavailable")}),u.jsxs("span",{className:"server-info-ip-actions",children:[b?.address&&u.jsx("button",{title:"Copy IPv4","aria-label":"Copy IPv4",onClick:()=>{re(b.address)},children:u.jsx(cp,{size:16})}),u.jsx("button",{disabled:x,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{T(!0)},children:u.jsx(Ll,{size:16})})]})]}),b?.error&&u.jsx("p",{role:"status",className:"server-info-error",children:b.error})]}),u.jsxs("section",{children:[u.jsx("h3",{children:"Favorites"}),u.jsx("div",{className:"server-info-favorites",children:s.map(J=>u.jsxs("button",{onClick:()=>d(J),children:[u.jsx("strong",{children:J.tabName}),u.jsxs("small",{children:[J.workspaceName," · ",m?.(J)?.state??"Not loaded"]}),u.jsx("span",{children:J.providers.map(xe=>u.jsx("img",{alt:xe,src:`/brand/${xe}.webp`},xe))})]},`${J.workspaceId}:${J.tabId}`))}),!s.length&&u.jsx("small",{children:"No favorite tabs on this server."})]}),u.jsxs("section",{children:[u.jsxs("div",{className:"server-info-heading",children:[u.jsx("h3",{children:"Projects"}),u.jsx("button",{disabled:L||me,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{O()},children:u.jsx(Ll,{size:16})})]}),L&&u.jsx("p",{role:"status",children:"Sampling processes..."}),W&&u.jsx("p",{role:"alert",className:"server-info-error",children:W}),S&&u.jsxs("small",{children:["Sampled ",new Date(S.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),V.map(J=>u.jsxs(vT,{className:"server-info-project",children:[u.jsxs("summary",{children:[u.jsxs("span",{className:"server-info-project-label",children:[u.jsx(Gk,{className:"server-info-chevron",size:16,"aria-hidden":"true"}),u.jsx("strong",{title:J.name,children:J.name}),u.jsx("small",{className:"server-info-project-location",title:J.path,children:J.path}),u.jsx("small",{className:"server-info-project-count",title:`${J.processes.length} processes`,children:J.processes.length})]}),u.jsxs("span",{className:"server-info-metrics",children:[u.jsxs("span",{children:[J.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:s_(J.memoryBytes)})]})]}),u.jsx("div",{className:"server-info-project-body",children:J.category==="services"?se(J):N.map(xe=>u.jsx("div",{className:"server-info-tool-project",children:se(xe)},`${xe.category}:${xe.path}`))})]},`${J.category}:${J.path}`)),S&&!S.projects.length&&u.jsx("p",{children:"No processes found for the runtime user."})]}),H&&u.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function NL({processes:e}){const t=v.useMemo(()=>EL(e),[e]);return u.jsx("div",{className:"server-info-process-list",children:t.map(n=>u.jsx("div",{className:"server-info-process-root",children:u.jsx(gT,{node:n})},n.process.pid))})}function gT({node:e}){const t=e.process,n=u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"server-info-process-label",children:[e.children.length?u.jsx(Gk,{className:"server-info-chevron",size:14,"aria-hidden":"true"}):u.jsx("span",{className:"server-info-process-dot","aria-hidden":"true"}),u.jsxs("span",{children:[u.jsx("strong",{children:t.name}),u.jsxs("small",{children:["PID ",t.pid," · ",t.manager??"Unmanaged",e.count>1?` · ${e.count} processes · Total`:""]})]})]}),u.jsxs("span",{className:"server-info-metrics",title:e.count>1?"Total for this process and its descendants":"Process usage",children:[u.jsxs("span",{children:[e.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:s_(e.memoryBytes)})]})]});return e.children.length?u.jsxs(vT,{className:"server-info-process-group",children:[u.jsx("summary",{className:"server-info-process",children:n}),u.jsxs("div",{className:"server-info-process-children",children:[u.jsxs("div",{className:"server-info-process",children:[u.jsxs("span",{children:[u.jsx("strong",{children:t.name}),u.jsxs("small",{children:["PID ",t.pid," · Parent"]})]}),u.jsxs("span",{className:"server-info-metrics",children:[u.jsxs("span",{children:[t.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:s_(t.memoryBytes)})]})]}),e.children.map(s=>u.jsx(gT,{node:s},s.process.pid))]})]}):u.jsx("div",{className:"server-info-process",children:n})}function vT({children:e,className:t}){const[n,s]=v.useState(!1),[o,...l]=zt.Children.toArray(e);return u.jsxs("details",{className:t,onToggle:d=>{d.target===d.currentTarget&&s(d.currentTarget.open)},children:[o,n?l:null]})}function DL({api:e}){const[t,n]=v.useState([]),[s,o]=v.useState([]),[l,d]=v.useState(!1),[f,m]=v.useState(null),[p,b]=v.useState(""),[_,S]=v.useState("");async function w(){try{const[A,W,z]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(W.networks),d(z.totpEnabled),m(null)}catch(A){m(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(A){await e.revokeDevice(A),await w()}async function R(A){await e.removeNetwork(A),await w()}async function L(A){A.preventDefault(),m(null);try{await e.addNetwork({value:p.trim(),label:_.trim()}),b(""),S(""),await w()}catch(W){m(W instanceof Error?W.message:"Failed to add network")}}return u.jsxs(u.Fragment,{children:[f?u.jsx("p",{className:"form-error",children:f}):null,u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Trusted devices"}),u.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?u.jsx("p",{className:"muted",children:"No trusted devices."}):u.jsx("ul",{className:"security-list",children:t.map(A=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsxs("span",{className:"security-item-label",children:[A.label,A.current?u.jsx("span",{className:"security-badge",children:"this device"}):null]}),u.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),u.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(A.id)},children:"revoke"})]},A.id))})]}),u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Trusted networks"}),u.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?u.jsx("p",{className:"muted",children:"No trusted networks."}):u.jsx("ul",{className:"security-list",children:s.map(A=>u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?u.jsx("span",{className:"security-item-meta",children:A.label}):null]}),u.jsx("button",{type:"button",className:"security-remove",onClick:()=>{R(A.id)},children:"remove"})]},A.id))}),u.jsxs("form",{className:"security-add-form",onSubmit:L,children:[u.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:A=>b(A.currentTarget.value),required:!0}),u.jsx("input",{type:"text",placeholder:"Label (optional)",value:_,onChange:A=>S(A.currentTarget.value)}),u.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),l?u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Two-factor authentication"}),u.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),u.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const ML=1500,gy="nterminal.terminal.fontSize",vy="nterminal.terminal.fontFamily",a_="nterminal:terminal-font-size",o_="nterminal:terminal-font-family",l_=11,c_=20,El=14,dp=[{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:[]}],Gc="meslo";u_(Gc);async function ev(e=El,t=Gc){if(typeof document>"u"||!document.fonts)return;const n=yT(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,ML)})])}function _T(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return El;const n=Math.round(t);return Math.max(l_,Math.min(c_,n))}function bT(e){return dp.some(t=>t.id===e)?e:Gc}function u_(e){return yT(e).cssFamily}function yT(e){return dp.find(t=>t.id===e)??dp[0]}function d_(){if(typeof window>"u")return El;try{const e=window.localStorage.getItem(gy);return e?_T(e):El}catch{return El}}function h_(){if(typeof window>"u")return Gc;try{return bT(window.localStorage.getItem(vy))}catch{return Gc}}function yf(e){const t=_T(e);if(typeof window>"u")return t;try{window.localStorage.setItem(gy,String(t))}catch{}return window.dispatchEvent(new CustomEvent(a_,{detail:t})),t}function AL(e){const t=bT(e);if(typeof window>"u")return t;try{window.localStorage.setItem(vy,t)}catch{}return window.dispatchEvent(new CustomEvent(o_,{detail:t})),t}function ST(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===gy&&e()};return window.addEventListener(a_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(a_,e),window.removeEventListener("storage",t)}}function wT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===vy&&e()};return window.addEventListener(o_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(o_,e),window.removeEventListener("storage",t)}}const Fd=3,xT=1,CT=5,kT=30;function _y(e){return Number.isFinite(e)?Math.max(xT,Math.min(CT,Math.round(e))):Fd}function LL(e,t){const n=Number.isFinite(t)?Math.max(1,Math.min(kT,Math.trunc(t))):1;return n===1?e:e.replace(/\x1b\[<(\d+);\d+;\d+M/g,(s,o)=>{const l=Number(o)&-29;return l===64||l===65?s.repeat(n):s})}class jL{remainder=0;direction=0;scale=0;reset(){this.remainder=0,this.direction=0,this.scale=0}consume(t,n,s){if(!Number.isFinite(t)||!Number.isFinite(n)||n<=0)return this.reset(),0;if(t===0)return 0;const o=_y(s)/(n*3),l=Math.sign(t);(l!==this.direction||o!==this.scale)&&(this.remainder=0),this.direction=l,this.scale=o;const d=this.remainder+Math.abs(t)*o,f=Math.floor(d+1e-9);return this.remainder=Math.max(0,d-f),l*Math.min(kT,f)}}const by="nterminal.terminal.showScrollProgress",f_="nterminal:terminal-scroll-progress",yy="nterminal.terminal.tmuxScrollback.shell",Sy="nterminal.terminal.tmuxScrollback.agent",wy="nterminal.terminal.tmuxScrollback.overrides",Xc="nterminal:terminal-tmux-scrollback",OL=200,hp="nterminal.terminal.codexScrollSpeed";let p_=Fd,fp=!1;function m_(){if(typeof window>"u")return Fd;if(fp)return p_;try{const e=window.localStorage.getItem(hp);return e===null||e.trim()===""?Fd:_y(Number(e))}catch{return p_}}function BL(e){const t=_y(e);if(p_=t,typeof window<"u"){try{window.localStorage.setItem(hp,String(t)),fp=!1}catch{fp=!0}window.dispatchEvent(new CustomEvent(Xc))}return t}function g_(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(by)!=="false"}catch{return!0}}function IL(e){if(typeof window<"u"){try{window.localStorage.setItem(by,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(f_,{detail:e}))}return e}function TT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===by&&e()};return window.addEventListener(f_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(f_,e),window.removeEventListener("storage",t)}}function v_(){return ET(yy,!0)}function PL(e){return RT(yy,e,Xc)}function __(){return ET(Sy,!0)}function zL(e){return RT(Sy,e,Xc)}function gd(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===hp||n.key===null)&&(fp=!1),(n.key===yy||n.key===Sy||n.key===hp||n.key===null||n.key===wy)&&e()};return window.addEventListener(Xc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Xc,e),window.removeEventListener("storage",t)}}function tv(e){const n=NT()[e];return typeof n=="boolean"?n:null}function HL(e,t){if(typeof window<"u"){try{const n=NT(),s=Object.entries(n).filter(([l])=>l!==e);s.push([e,t]);const o=s.slice(-OL);window.localStorage.setItem(wy,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Xc,{detail:{terminalId:e,enabled:t}}))}return t}function ET(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 RT(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 NT(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(wy);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 xy="nterminal.shortcuts.workspace.v1",b_="nterminal:workspace-shortcuts",Wd=[{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}],Zp={"server.previous":En("ArrowUp",{ctrlKey:!0}),"server.next":En("ArrowDown",{ctrlKey:!0}),"tab.previous":En("ArrowLeft",{ctrlKey:!0}),"tab.next":En("ArrowRight",{ctrlKey:!0}),"tab.index":En("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":En("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":En("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":En("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":En("KeyH",{altKey:!0}),"subagents.toggle":En("KeyA",{altKey:!0}),"scrollback.toggle":En("KeyS",{altKey:!0}),"favorites.toggle":En("KeyF",{ctrlKey:!0,altKey:!0})},UL={"server.previous":En("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":En("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":En("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":En("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":En("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":En("Digit",{ctrlKey:!0,altKey:!0}),"split.right":En("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":En("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":En("KeyH",{altKey:!0}),"subagents.toggle":En("KeyA",{altKey:!0}),"scrollback.toggle":En("KeyS",{altKey:!0}),"favorites.toggle":En("KeyF",{ctrlKey:!0,altKey:!0})};function jl(){const e=AT(Zp);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(xy);if(!t)return e;const n=JSON.parse(t);for(const s of Wd){const o=n[s.id];if(GL(o)){const l=LT(o,s);YL(l,UL[s.id])||(e[s.id]=l)}}}catch{return e}return e}function K1(){return JSON.stringify(jl())}function $L(e,t){const n=jl(),s=Wd.find(o=>o.id===e);return s&&(n[e]=LT(t,s),Cy(n)),n}function FL(e){const t=jl();return t[e]={...Zp[e]},Cy(t),t}function WL(){const e=AT(Zp);return Cy(e),e}function jd(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===xy&&e()};return window.addEventListener(b_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(b_,e),window.removeEventListener("storage",t)}}function KL(e,t){const n=BT(e);return!n||ZL(n)||t.indexed&&OT(e)===null||t.requiresPrimaryModifier&&!jT(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function DT(e){const t=jl();for(const n of Wd){const s=t[n.id];if(!(!s||!XL(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const o=OT(e);if(o!==null)return{id:n.id,index:o};continue}if(BT(e)===s.code)return{id:n.id,index:null}}}return null}function Od(e){return MT(jl()[e])}function MT(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(QL(e.code)),t.join("+")}const qL=()=>Od("split.right"),VL=()=>Od("split.down");function En(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function AT(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function YL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Cy(e){if(!(typeof window>"u")){try{window.localStorage.setItem(xy,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(b_))}}function LT(e,t){return t.requiresPrimaryModifier&&!jT(e)?{...Zp[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function jT(e){return e.ctrlKey||e.altKey||e.metaKey}function GL(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 XL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function OT(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 BT(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 ZL(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function QL(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 JL="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 ej(e="nterminal",t=new Date){return{reason:"permission",message:JL,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function tj(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 IT=3600*1e3,nj="local",y_=new Set,ko=new Map;let Lo={checking:!1,hasUpdates:!1,lastCheckedAt:null},ky=null,Bd=null,pp=0,bo=null;function ij(e){return y_.add(e),()=>{y_.delete(e)}}function q1(){return Lo}function rj(e){const t=cj();ky=e,Ty(),S_(e,t);const n=()=>{if(document.visibilityState!=="visible"||!jo(e,t))return;const s=Lo.lastCheckedAt;(s===null||Date.now()-s>=IT)&&S_(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),jo(e,t)&&lj()}}function sj(e,t){ko.set(e,PT(t)),Zc({...Lo,hasUpdates:Ey(),lastCheckedAt:Date.now()})}function nv(e){e===void 0?ko.clear():ko.set(e,!1),Zc({...Lo,hasUpdates:Ey()})}async function S_(e,t){if(!jo(e,t))return;if(bo&&bo.api===e&&bo.runId===t)return bo.promise;Zc({...Lo,checking:!0});const n=aj(e,t).finally(()=>{bo?.promise===n&&(bo=null),jo(e,t)&&(Zc({...Lo,checking:!1,lastCheckedAt:Date.now()}),oj(e,t))});return bo={api:e,runId:t,promise:n},n}async function aj(e,t){try{const n=await e.listAgents();if(!jo(e,t))return;const s=[{key:nj,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 d=await l.check();o.set(l.key,PT(d))}catch{o.set(l.key,ko.get(l.key)??!1)}})),!jo(e,t))return;ko.clear();for(const[l,d]of o)ko.set(l,d);Zc({...Lo,hasUpdates:Ey()})}catch{}}function oj(e,t){jo(e,t)&&(Ty(),Bd=window.setTimeout(()=>{Bd=null,jo(e,t)&&S_(e,t)},IT))}function lj(){pp+=1,Ty(),ky=null,bo=null,ko.clear(),Zc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Ty(){Bd!==null&&(window.clearTimeout(Bd),Bd=null)}function cj(){return pp+=1,pp}function jo(e,t){return ky===e&&pp===t}function PT(e){return e.updateAvailable===!0}function Ey(){return Array.from(ko.values()).some(Boolean)}function Zc(e){Lo=e;for(const t of Array.from(y_))t()}const uj=e=>new Promise(t=>setTimeout(t,e));function dj({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local"}]),[o,l]=v.useState({}),[d,f]=v.useState(!1),[m,p]=v.useState(null),[b,_]=v.useState(!1),[S,w]=v.useState({});function x(T,O){l(re=>({...re,[T]:{...re[T],...O}}))}function R(T,O){w(re=>({...re,[T]:{status:re[T]?.status??null,busy:re[T]?.busy??!1,error:re[T]?.error??null,...O}}))}const L=T=>T.id===null?e.getVersion():e.getAgentVersion(T.id),A=T=>T.id===null?e.checkUpdate():e.checkAgentUpdate(T.id),W=T=>T.id===null?e.runUpdate():e.runAgentUpdate(T.id),z=T=>T.id===null?e:Rs(T.id);v.useEffect(()=>{let T=!1;return e.listAgents().then(async O=>{if(T)return;let re="Local";try{re=(await e.getMainInfo()).name?.trim()||re}catch{}if(T)return;const he=new Map(O.agents.map(V=>[V.id,V])),N=ya(O.serverOrder,O.agents).flatMap(V=>{if(V===Zt)return[{key:"local",id:null,name:re}];const se=he.get(V);return se?[{key:se.id,id:se.id,name:se.name}]:[]});s(N);for(const V of N)L(V).then(se=>x(V.key,{version:se,manualUpdate:se.manualUpdate??null})).catch(se=>x(V.key,{error:se instanceof Error?se.message:"unreachable"})),Z(V)}).catch(()=>{}),()=>{T=!0}},[]);async function H(T){x(T.key,{busy:!0,status:"checking…",error:void 0});try{const O=await A(T);sj(T.key,O),x(T.key,{latestVersion:O.latestVersion,updateAvailable:O.updateAvailable,status:K(O),...O.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(O){x(T.key,{busy:!1,error:O instanceof Error?O.message:"check failed"})}}async function q(){f(!0),await Promise.all(n.map(T=>H(T))),f(!1)}async function Y(T,O){const re=Date.now()+18e4;for(;Date.now()<re;){await uj(3e3);try{const he=await L(T);if(O&&he.runningVersion!==O.runningVersion)return he}catch{}}return null}async function I(T){let O=o[T.key]?.version;if(!O)try{O=await L(T),x(T.key,{version:O,manualUpdate:O.manualUpdate??null})}catch(N){return x(T.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}x(T.key,{busy:!0,status:"updating…",error:void 0});let re;try{re=await W(T)}catch(N){return x(T.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!re.ok){const N=re.manualUpdate??(tj(re.message)?ej():null);return N?(x(T.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(x(T.key,{busy:!1,status:void 0,error:re.message}),"failed")}if(!re.changed)return x(T.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),nv(T.key),"unchanged";x(T.key,{status:"restarting…"});const he=await Y(T,O);return he?(x(T.key,{busy:!1,version:he,updateAvailable:!1,status:"updated",manualUpdate:he.manualUpdate??null}),nv(T.key),T.id===null&&(_(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(x(T.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function $(T){if(!(T.id===null||!window.confirm([`Delete secondary server "${T.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(`
|
|
16
|
-
`)))){x(T.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const re=await e.uninstallAgent(T.id);s(he=>he.filter(N=>N.key!==T.key)),l(he=>{const N={...he};return delete N[T.key],N}),nv(T.key),t?.(T.id),p(re.message)}catch(re){x(T.key,{busy:!1,status:void 0,error:re instanceof Error?re.message:"delete failed"})}}}async function de(){f(!0),p(null);const T=n.filter(se=>se.id!==null),O=n.find(se=>se.id===null),re=await Promise.all(T.map(se=>I(se))),he=re.filter(se=>se==="failed").length;let N=re.filter(se=>se==="manual").length,V=null;if(O&&(V=await I(O),V==="manual"&&(N+=1),V==="updated")){he>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}he>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):he>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 me(T){return T?T.error?T.error:T.status?T.status:T.manualUpdate?"manual update required":T.version?`v${T.version.version}`:"…":"…"}function K(T){return T.error?T.error:typeof T.updateAvailable=="boolean"?T.updateAvailable?`latest v${T.latestVersion??"available"}`:"up to date":"unknown"}function ne(T){const O=T?.version;return O?`npm package v${O.runningVersion}`:""}async function ee(T,O){try{await fj(O),x(T,{copiedCommand:!0}),window.setTimeout(()=>x(T,{copiedCommand:!1}),1800)}catch(re){x(T,{error:re instanceof Error?re.message:"copy failed"})}}async function Z(T,O=!1){try{const re=await z(T).getCodeServerStatus(O?{checkLatest:!0}:void 0);R(T.key,{status:re,error:null})}catch(re){R(T.key,{error:re instanceof Error?re.message:"code-server status failed"})}}async function X(T,O){if(O==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${T.name} and stop its running VS Code sessions?`))return;const re=z(T);R(T.key,{busy:!0,error:null});try{if(O==="install"){const he=await re.installCodeServer();R(T.key,{status:he.status})}else if(O==="update"){const he=await re.updateCodeServer();R(T.key,{status:he.status})}else{const he=await re.uninstallCodeServer();R(T.key,{status:he.status})}}catch(he){R(T.key,{error:he instanceof Error?he.message:"code-server action failed"})}finally{R(T.key,{busy:!1})}}const M=n.filter(T=>S[T.key]?.status?.job?.status==="running").map(T=>T.key).join("|");return v.useEffect(()=>{const T=n.filter(re=>S[re.key]?.status?.job?.status==="running");if(T.length===0)return;const O=window.setInterval(()=>{for(const re of T)Z(re)},1e3);return()=>window.clearInterval(O)},[M]),u.jsxs("section",{className:"security-section",children:[u.jsx("h3",{children:"Servers"}),u.jsxs("div",{className:"update-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{q()},disabled:d,children:"Check for updates"}),u.jsx("button",{type:"button",onClick:()=>{de()},disabled:d,children:"Update all"})]}),m?u.jsx("p",{className:"settings-status",children:m}):null,b?u.jsxs("div",{className:"server-reload-required",role:"status",children:[u.jsx("span",{children:"Main server update is ready."}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,u.jsx("ul",{className:"security-list",children:n.map(T=>{const O=o[T.key],re=ne(O),he=O?.manualUpdate??null,N=S[T.key]??{status:null,busy:!1,error:null},V=O?.version!==void 0&&O?.updateAvailable!==!1&&!O?.busy&&!d,se=T.id!==null&&!O?.busy&&!d;return u.jsxs("li",{children:[u.jsxs("div",{className:"server-row-main",children:[u.jsxs("div",{children:[u.jsxs("span",{className:"security-item-label",children:[T.name,T.id===null?u.jsx("span",{className:"security-badge",children:"Main"}):null]}),u.jsxs("span",{className:"security-item-meta",children:[re?`${re} — `:"",me(O)]})]}),he?u.jsxs("div",{className:"server-manual-update",children:[u.jsx("span",{children:he.message}),u.jsxs("div",{className:"server-manual-command",children:[u.jsx("code",{children:he.command}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ee(T.key,he.command)},children:O?.copiedCommand?"Copied":"Copy"})]})]}):null,u.jsx(hj,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{Z(T,!0)},onInstall:()=>{X(T,"install")},onUpdate:()=>{X(T,"update")},onUninstall:()=>{X(T,"uninstall")}})]}),u.jsxs("div",{className:"server-row-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{I(T)},disabled:!V,children:O?.busy?"…":"Update"}),T.id!==null?u.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{$(T)},disabled:!se,children:"Delete"}):null]})]},T.key)})})]})}function hj({status:e,busy:t,error:n,onCheck:s,onInstall:o,onUpdate:l,onUninstall:d}){const f=e?.job??null,m=f?.status==="running",p=e!==null,b=e?.installed===!0,_=e?.supported!==!1,S=e===null&&!n;return u.jsxs("div",{className:"server-code-addon-inline",children:[u.jsxs("div",{className:"server-code-addon-summary",children:[u.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),u.jsxs("span",{className:"security-item-meta",children:[_?S?"checking...":b?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?u.jsx("p",{className:"settings-error",children:n}):null,f?u.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,u.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[u.jsx("a",{className:"server-code-addon-icon-button",href:"https://github.com/coder/code-server",target:"_blank",rel:"noreferrer",title:"Open code-server on GitHub","aria-label":"Open code-server on GitHub",children:"↗"}),b?u.jsxs(u.Fragment,{children:[e?.updateAvailable?u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:l,disabled:t||m||!_,title:"Update code-server","aria-label":"Update code-server",children:"↑"}):u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:s,disabled:t||m||!_,title:"Check code-server updates","aria-label":"Check code-server updates",children:"↻"}),u.jsx("button",{type:"button",className:"server-code-addon-icon-button server-code-addon-icon-button--delete",onClick:d,disabled:t||m,title:"Uninstall code-server","aria-label":"Uninstall code-server",children:"×"})]}):u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:o,disabled:!p||S||t||m||!_,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function fj(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 Sf=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function pj({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:o}){const l=v.useMemo(()=>t??Ip(),[t]),[d,f]=v.useState(()=>d_()),[m,p]=v.useState(()=>h_()),[b,_]=v.useState(()=>g_()),[S,w]=v.useState(()=>v_()),[x,R]=v.useState(()=>__()),[L,A]=v.useState(()=>m_()),[W,z]=v.useState(()=>Mo()),[H,q]=v.useState(()=>jl()),[Y,I]=v.useState(null),[$,de]=v.useState(null),[me,K]=v.useState("appearance"),[ne,ee]=v.useState(()=>hy()),[Z,X]=v.useState(()=>Al()),[M,T]=v.useState(()=>ru()),[O,re]=v.useState([]),[he,N]=v.useState([]),[V,se]=v.useState([]),[J,xe]=v.useState(5*1024*1024),[ye,Pe]=v.useState(!1),[Fe,ze]=v.useState(null),[ve,We]=v.useState(null),[Oe,j]=v.useState(!1),[ge,Me]=v.useState(null),[Le,F]=v.useState(null),pe=v.useRef(null),Ce=v.useRef(null),Re=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),je=v.useMemo(()=>new Set(he),[he]),be=!gj(he,V),Ue=v.useMemo(()=>Xp(),[]),$e=ve?.displayMode==="standalone"&&(ve.deviceKind==="mobile"||ve.deviceKind==="tablet");v.useEffect(()=>ST(()=>f(d_())),[]),v.useEffect(()=>wT(()=>p(h_())),[]),v.useEffect(()=>TT(()=>_(g_())),[]),v.useEffect(()=>gd(()=>{w(v_()),R(__()),A(m_())}),[]),v.useEffect(()=>Zb(()=>z(Mo())),[]),v.useEffect(()=>jd(()=>q(jl())),[]),v.useEffect(()=>Lk(()=>X(Al())),[]),v.useEffect(()=>{if(!Y)return;const te=Wd.find(et=>et.id===Y);if(!te)return;const Ke=et=>{if(et.preventDefault(),et.stopPropagation(),et.key==="Escape"){I(null),de(null);return}const bt=KL(et,te);if(!bt){de(mj(te));return}q($L(Y,bt)),I(null),de(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[Y]),v.useEffect(()=>{let te=!1;return l.listNotificationAssets().then(Ke=>{te||rt(Ke)}).catch(Ke=>{te||ze(Lc(Ke))}),()=>{te=!0}},[l]),v.useEffect(()=>{let te=!1;return l.getPushNotificationStatus(wa()).then(Ke=>{te||(We(Ke.currentDevice),Me(null))}).catch(Ke=>{te||Me(Lc(Ke))}),()=>{te=!0}},[l]);function Be(te){f(yf(Number(te)))}function ot(te){X(E1(Number(te)))}function ct(te){K(te);const Ke=Ce.current,et=Re.current[te];if(!Ke||!et)return;const bt=Math.max(0,V1(et,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:bt,behavior:"smooth"}):Ke.scrollTop=bt}function ht(){const te=Ce.current;if(!te)return;if(te.scrollTop+te.clientHeight>=te.scrollHeight-2){K(Sf[Sf.length-1].id);return}let Ke="appearance";const et=te.scrollTop+Math.min(180,Math.max(48,te.clientHeight*.28));for(const bt of Sf){const Pt=Re.current[bt.id];Pt&&V1(Pt,te)<=et&&(Ke=bt.id)}K(Ke)}function jt(te){q(FL(te)),I(null),de(null)}function Qt(){q(WL()),I(null),de(null)}function rt(te){const Ke=te.assets.filter(et=>et.enabled).map(et=>et.id);re(te.assets),N(Ke),se(Ke),xe(te.maxFileBytes),ze(null)}async function Yn(){if(ne){T1(!1),ee(!1);return}let te=M;te==="default"&&(te=await Ok(),T(te)),te==="granted"&&(T1(!0),ee(!0))}async function _n(){j(!0),Me(null),F(null);try{if(ve)await sA(l),We(null);else{await nA(l,!1);const te=await l.getPushNotificationStatus(wa());We(te.currentDevice)}}catch(te){Me(rv(te))}finally{j(!1)}}async function pt(te){j(!0),Me(null),F(null);try{await aA(l,te);const Ke=await l.getPushNotificationStatus(wa());We(Ke.currentDevice)}catch(Ke){Me(rv(Ke))}finally{j(!1)}}async function Et(){j(!0),Me(null),F(null);try{await l.testPushNotification({clientId:wa()}),F("Test notification accepted by the push service.")}catch(te){Me(rv(te))}finally{j(!1)}}async function Nt(te){const Ke=te?.[0];if(Ke){if(Ke.size>J){ze(`File must be ${iv(J)} or smaller.`),Gn();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){ze("Upload an MP4 or WebM video."),Gn();return}Pe(!0),ze(null);try{await l.uploadNotificationAsset(Ke),rt(await l.listNotificationAssets()),s?.()}catch(et){ze(Lc(et))}finally{Pe(!1),Gn()}}}async function Di(te){Pe(!0),ze(null);try{await l.deleteNotificationAsset(te),rt(await l.listNotificationAssets()),s?.()}catch(Ke){ze(Lc(Ke))}finally{Pe(!1)}}function Gn(){pe.current&&(pe.current.value="")}function nn(te,Ke){const et=new Set(he);if(Ke?et.add(te):et.delete(te),et.size===0){ze("Keep at least one toast video selected.");return}ze(null),N(Array.from(et))}async function fn(){if(he.length===0){ze("Keep at least one toast video selected.");return}Pe(!0),ze(null);try{const te=await l.updateNotificationAssetSelection({enabledAssetIds:he});rt(te),s?.()}catch(te){ze(Lc(te))}finally{Pe(!1)}}return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:u.jsxs("div",{className:"security-panel settings-panel",onClick:te=>te.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{children:"Settings"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),u.jsxs("div",{className:"settings-layout",children:[u.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Sf.map(te=>u.jsxs("button",{type:"button","data-active":me===te.id?"true":"false","aria-current":me===te.id?"true":void 0,onClick:()=>ct(te.id),children:[te.label,te.id==="servers"&&n?u.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},te.id))}),u.jsxs("div",{ref:Ce,className:"settings-content",onScroll:ht,children:[u.jsxs("section",{id:"settings-appearance",ref:te=>{Re.current.appearance=te},className:"security-section settings-section",children:[u.jsx("h3",{children:"Appearance"}),u.jsx("div",{className:"settings-section-heading",children:u.jsxs("div",{children:[u.jsx("span",{className:"settings-control-title",children:"Theme"}),u.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),u.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:tp.map(te=>u.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":W===te.id,"data-active":W===te.id?"true":"false",onClick:()=>z(NN(te.id)),style:{"--settings-theme-bg":te.tokens.bg,"--settings-theme-bg-2":te.tokens.bg2,"--settings-theme-sidebar":te.tokens.bgSidebar,"--settings-theme-line":te.tokens.line,"--settings-theme-fg":te.tokens.fg,"--settings-theme-fg-2":te.tokens.fg2,"--settings-theme-accent":te.tokens.accent,"--settings-theme-xterm-bg":te.xterm.background,"--settings-theme-xterm-fg":te.xterm.foreground,"--settings-theme-xterm-selection":te.xterm.selectionBackground},children:[u.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[u.jsxs("span",{className:"settings-theme-preview-sidebar",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]}),u.jsxs("span",{className:"settings-theme-preview-main",children:[u.jsxs("span",{className:"settings-theme-preview-tabs",children:[u.jsx("span",{}),u.jsx("span",{})]}),u.jsxs("span",{className:"settings-theme-preview-terminal",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]})]})]}),u.jsxs("span",{className:"settings-theme-card-copy",children:[u.jsx("strong",{children:te.label}),u.jsx("small",{children:te.description})]})]},te.id))}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Font size"}),u.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),u.jsx("input",{type:"range",min:l_,max:c_,step:1,value:d,"aria-label":"Terminal font size",onChange:te=>Be(te.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row",children:[u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(yf(d-1)),children:"-"}),u.jsx("input",{type:"number",min:l_,max:c_,step:1,value:d,"aria-label":"Terminal font size value",onChange:te=>Be(te.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(yf(d+1)),children:"+"}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(yf(El)),children:"Reset"})]}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Font family"}),u.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:te=>p(AL(te.currentTarget.value)),children:dp.map(te=>u.jsx("option",{value:te.id,children:te.label},te.id))})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:b,onChange:te=>_(IL(te.currentTarget.checked))}),"Show scroll progress"]}),u.jsx("div",{className:"settings-section-heading",children:u.jsxs("div",{children:[u.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),u.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:S,onChange:te=>w(PL(te.currentTarget.checked))}),"Shell panes"]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:x,onChange:te=>R(zL(te.currentTarget.checked))}),"Codex/Claude panes"]}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Codex scroll speed"}),u.jsxs("span",{className:"settings-control-value",children:[L,"x"]}),u.jsx("input",{type:"range",min:xT,max:CT,step:1,value:L,"aria-label":"Codex scroll speed","aria-valuetext":`${L}x`,onChange:te=>A(BL(Number(te.currentTarget.value)))})]})]}),u.jsxs("section",{id:"settings-shortcuts",ref:te=>{Re.current.shortcuts=te},className:"security-section settings-section",children:[u.jsxs("div",{className:"settings-section-heading",children:[u.jsx("h3",{children:"Shortcuts"}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:Qt,children:"Reset all"})]}),u.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),$?u.jsx("p",{className:"settings-error",children:$}):null,u.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Wd.map(te=>{const Ke=Y===te.id;return u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("span",{className:"settings-shortcut-label",children:te.label}),u.jsx("span",{className:"settings-shortcut-group",children:te.group})]}),u.jsxs("div",{className:"settings-shortcut-actions",children:[u.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{I(te.id),de(null)},children:Ke?"Press keys…":MT(H[te.id])}),u.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>jt(te.id),children:"Reset"})]})]},te.id)})})]}),u.jsxs("section",{id:"settings-notifications",ref:te=>{Re.current.notifications=te},className:"security-section settings-section",children:[u.jsx("h3",{children:"Notifications"}),Gp()?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:ne&&M==="granted",onChange:()=>{Yn()},disabled:M==="denied"}),"System notification when page is hidden"]}),M==="denied"?u.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):u.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):u.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),u.jsxs("div",{className:"settings-subsection",children:[u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:!!ve,onChange:()=>{_n()},disabled:Oe||!Ue.supported}),"Installed app push notifications"]}),u.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ue.supported?null:u.jsx("p",{className:"muted",children:Pf(Ue.reason)}),ve?u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"muted",children:["Registered as ",ve.label,". Last active ",new Date(ve.lastActiveAt).toLocaleString(),"."]}),u.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{Et()},disabled:Oe,children:"Send test notification"})]}):null,$e?u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:ve?.alwaysNotify===!0,onChange:te=>{pt(te.currentTarget.checked)},disabled:Oe||!ve}),"Always notify this mobile device"]}):null,ge?u.jsx("p",{className:"form-error",children:ge}):null,Le?u.jsx("p",{className:"muted",role:"status",children:Le}):null]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:Z.enabled,onChange:te=>X(VM(te.currentTarget.checked))}),"Show animated completion toast"]}),u.jsxs("label",{className:"settings-control",children:[u.jsx("span",{children:"Toast duration"}),u.jsx("span",{className:"settings-control-value",children:Z.persistUntilDismissed?"Until closed":`${Z.durationSeconds}s`}),u.jsx("input",{type:"range",min:Qv,max:Jv,step:.5,value:Z.durationSeconds,disabled:!Z.enabled||Z.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:te=>ot(te.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[u.jsx("input",{type:"number",min:Qv,max:Jv,step:.5,value:Z.durationSeconds,disabled:!Z.enabled||Z.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:te=>ot(te.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!Z.enabled||Z.persistUntilDismissed,onClick:()=>X(E1(Ad)),children:"Reset"})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:Z.persistUntilDismissed,disabled:!Z.enabled,onChange:te=>X(YM(te.currentTarget.checked))}),"Keep toast until dismissed"]}),u.jsxs("div",{className:"settings-assets-header",children:[u.jsx("span",{children:"Toast videos"}),u.jsxs("span",{children:[iv(J)," max"]})]}),u.jsx("input",{ref:pe,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:te=>{Nt(te.currentTarget.files)}}),u.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ye,onClick:()=>pe.current?.click(),children:"Upload video"}),Fe?u.jsx("p",{className:"settings-error",children:Fe}):null,O.length>0?u.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(te=>u.jsxs("li",{"data-enabled":je.has(te.id)?"true":"false",children:[u.jsxs("label",{className:"settings-asset-choice",children:[u.jsx("input",{type:"checkbox",checked:je.has(te.id),disabled:ye,"aria-label":`Use ${te.filename}`,onChange:Ke=>nn(te.id,Ke.currentTarget.checked)}),u.jsx("video",{src:te.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),u.jsxs("span",{className:"settings-asset-copy",children:[u.jsx("span",{children:te.filename}),u.jsx("small",{children:te.source==="built-in"?"Built-in":iv(te.size)})]})]}),te.source==="uploaded"?u.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ye,"aria-label":`Delete ${te.filename}`,onClick:()=>{Di(te.id)},children:"x"}):null]},te.id))}):u.jsx("p",{className:"muted",children:"Built-in videos will be used."}),u.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ye||O.length===0||!be,onClick:()=>{fn()},children:"Save selected videos"})]}),u.jsx("div",{id:"settings-security",ref:te=>{Re.current.security=te},className:"settings-section-group",children:u.jsx(DL,{api:l})}),u.jsx("div",{id:"settings-servers",ref:te=>{Re.current.servers=te},className:"settings-section-group",children:u.jsx(dj,{api:l,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function V1(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function iv(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 Lc(e){return e instanceof Error?e.message:"Request failed."}function Pf(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 rv(e){const t=Lc(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Pf("not_standalone"):t==="insecure"?Pf("insecure"):t==="not_mobile"?Pf("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 mj(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 gj(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}const vj="modulepreload",_j=function(e){return"/"+e},Y1={},Ry=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let m=function(p){return Promise.all(p.map(b=>Promise.resolve(b).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=d?.nonce||d?.getAttribute("nonce");o=m(n.map(p=>{if(p=_j(p),p in Y1)return;Y1[p]=!0;const b=p.endsWith(".css"),_=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${_}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":vj,b||(S.as="script"),S.crossOrigin="",S.href=p,f&&S.setAttribute("nonce",f),document.head.appendChild(S),b)return new Promise((w,x)=>{S.addEventListener("load",w),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&l(f.reason);return t().catch(l)})},bj=v.lazy(()=>Ry(()=>import("./MarkdownPreview--8XdSXg9.js"),__vite__mapDeps([0,1])));function yj({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:o}){const[l,d]=v.useState(null),[f,m]=v.useState(""),[p,b]=v.useState({}),[_,S]=v.useState(()=>new Set),[w,x]=v.useState(null),[R,L]=v.useState({type:"empty"}),[A,W]=v.useState("idle"),[z,H]=v.useState(null),q=v.useRef(null),Y=v.useRef(null),I=v.useRef(!1),$=v.useRef(0),de=v.useRef(null);de.current===null&&t&&(de.current=t);const me=de.current,K=s?wj(s):t?G1(t,n):null,ne=l?[l.rootPath,f].filter(Boolean).join("/"):"",ee=w?.path??null;v.useEffect(()=>(I.current=!0,()=>{I.current=!1,$.current+=1,We()}),[]),v.useEffect(()=>{de.current=t,Y.current=null,Z(K)},[e]),v.useEffect(()=>{s&&K!==Y.current&&X(s,K)},[s,K]),v.useEffect(()=>{if(s||!me||t!==me)return;const F=G1(me,n);F!==Y.current&&M(me,F)},[me,t,n,s]);async function Z(F=K){if(s){await X(s,F);return}await M(t,F)}async function X(F,pe=K){const Ce=Oe();if(Y.current=pe,We(),d(null),m(""),b({}),S(new Set),x(null),L({type:"empty"}),H(null),!F){W("idle");return}W("loading");try{const Re=await e.createFileRoot({path:F});if(!j(Ce))return;d({rootToken:Re.rootToken,rootPath:Re.rootPath});const je=await e.listFiles({rootToken:Re.rootToken,path:""});if(!j(Ce))return;re(je),W("idle")}catch(Re){j(Ce)&&(H(ma(Re)),W("idle"))}}async function M(F,pe=K){const Ce=Oe();if(Y.current=pe,We(),d(null),m(""),b({}),S(new Set),x(null),L({type:"empty"}),H(null),!F){W("idle");return}W("loading");try{const Re=await e.createFileRoot({terminalId:F});if(!j(Ce))return;d({rootToken:Re.rootToken,rootPath:Re.rootPath});const je=await e.listFiles({rootToken:Re.rootToken,path:""});if(!j(Ce))return;re(je),W("idle")}catch(Re){if(await ge(Re,Ce))return;j(Ce)&&(H(ma(Re)),W("idle"))}}async function T(F=f,pe=l){if(!pe)return;const Ce=Oe();W("loading"),H(null);try{const Re=await e.listFiles({rootToken:pe.rootToken,path:F});if(!j(Ce))return;re(Re),W("idle")}catch(Re){if(await ge(Re,Ce))return;j(Ce)&&(H(ma(Re)),W("idle"))}}async function O(){if(s){await X(s,K);return}de.current=t,await M(t,K)}function re(F){b(pe=>({...pe,[F.path]:xj(F.entries)}))}async function he(F){if(!(!sv(F)||!l)){if(x(F),H(null),F.kind==="directory"){m(F.path),ve(),await V(F);return}if(m(bl(F.path)),F.editable){await J(F);return}F.previewKind!=="none"&&await ye(F,F.previewKind)}}async function N(F){if(!(!sv(F)||!l)){if(x(F),H(null),F.kind==="directory"){m(F.path),ve(),await V(F);return}if(m(bl(F.path)),F.editable){await xe(F);return}F.previewKind!=="none"&&await ye(F,F.previewKind)}}async function V(F){if(_.has(F.path)){S(pe=>{const Ce=new Set(pe);return Ce.delete(F.path),Ce});return}S(pe=>new Set(pe).add(F.path)),await T(F.path)}function se(F,pe){F.key==="Enter"&&(F.preventDefault(),N(pe))}async function J(F){if(!l)return;const pe=Oe();W("loading"),We();try{const Ce=await e.readFile({rootToken:l.rootToken,path:F.path});if(!j(pe))return;L({type:"text-preview",file:F,read:Ce}),W("idle")}catch(Ce){if(await ge(Ce,pe))return;j(pe)&&(H(ma(Ce)),W("idle"))}}async function xe(F){if(!l)return;const pe=Oe();W("loading");try{await o({rootToken:l.rootToken,path:F.path,...t?{terminalId:t}:{}}),j(pe)&&W("idle")}catch(Ce){if(await ge(Ce,pe))return;j(pe)&&(H(ma(Ce)),W("idle"))}}async function ye(F,pe){if(!l)return;const Ce=Oe();W("loading"),We();try{const Re=await e.previewFile({rootToken:l.rootToken,path:F.path});if(!j(Ce))return;const je=URL.createObjectURL(Re);if(!j(Ce)){URL.revokeObjectURL(je);return}q.current=je,L({type:"preview",file:F,previewKind:pe,url:je}),W("idle")}catch(Re){if(await ge(Re,Ce))return;j(Ce)&&(H(ma(Re)),W("idle"))}}async function Pe(F){if(!l)return;const pe=F==="file"?"New file":"New folder",Ce=window.prompt(pe,""),Re=w?w.kind==="directory"?w.path:bl(w.path):f,je=X1(Ce,Re);if(je){H(null);try{const be=await e.createFileEntry({rootToken:l.rootToken,path:je,kind:F});x(be.entry),await T(Re)}catch(be){if(await ge(be))return;H(ma(be))}}}async function Fe(){if(!l||!w)return;const F=window.prompt("Move selected entry",w.path),pe=X1(F,"");if(!pe||pe===w.path)return;const Ce=bl(w.path),Re=bl(pe);H(null);try{const je=await e.moveFileEntry({rootToken:l.rootToken,sourcePath:w.path,destinationPath:pe});x(je.entry),m(je.entry.kind==="directory"?je.entry.path:bl(je.entry.path)),ve(),await T(Ce),Re!==Ce&&await T(Re)}catch(je){if(await ge(je))return;H(ma(je))}}async function ze(){if(!l||!w)return;const F=w.path,pe=bl(F);H(null);try{const Ce=await e.previewDeleteFileEntry({rootToken:l.rootToken,path:w.path}),Re=Ce.descendantCount>0?` and ${Ce.descendantCount} nested item${Ce.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Ce.path}${Re}?`))return;await e.deleteFileEntry({rootToken:l.rootToken,path:w.path,previewToken:Ce.previewToken}),x(null),m(pe),S(je=>{const be=new Set(je);for(const Ue of je)(Ue===F||Ue.startsWith(`${F}/`))&&be.delete(Ue);return be}),ve(),await T(pe)}catch(Ce){if(await ge(Ce))return;H(ma(Ce))}}function ve(){$.current+=1,We(),L({type:"empty"})}function We(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function Oe(){return $.current+=1,$.current}function j(F){return I.current&&F===$.current}async function ge(F,pe){return Cj(F)?(pe!==void 0&&!j(pe)||await Z(K),!0):!1}function Me(F,pe){const Ce=sv(F),Re=F.kind==="directory"&&_.has(F.path),je=p[F.path]??[],be={"--file-tree-depth":pe};return u.jsxs(zt.Fragment,{children:[u.jsxs("button",{type:"button",className:"file-entry-button","data-kind":F.kind,"data-expanded":Re,"data-active":ee===F.path,disabled:!Ce,style:be,"aria-expanded":F.kind==="directory"?Re:void 0,"aria-label":`${F.kind==="directory"?"Open folder":"Open file"} ${F.name}`,title:F.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{he(F)},onDoubleClick:()=>{N(F)},onKeyDown:Ue=>se(Ue,F),children:[u.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:F.kind==="directory"?Re?"▾":"▸":""}),u.jsx("span",{className:"file-entry-name",children:F.name}),u.jsx("small",{children:Sj(F)})]}),Re?u.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Ue=>Me(Ue,pe+1))}):null]},F.path)}const Le=p[""]??[];return u.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[u.jsxs("header",{className:"file-explorer-header",children:[u.jsx("div",{className:"file-explorer-path",title:ne,children:ne||"No active pane"}),u.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[u.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{O()},children:"↻"}),u.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!l,onClick:()=>{Pe("file")},children:"+"}),u.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!l,onClick:()=>{Pe("directory")},children:"▣"})]})]}),z?u.jsx("div",{className:"file-explorer-alert",role:"alert",children:z}):null,u.jsxs("div",{className:"file-explorer-layout",children:[u.jsx("div",{className:"file-tree","aria-label":ne?`Files in ${ne}`:"Files",children:Le.map(F=>Me(F,0))}),u.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[u.jsxs("div",{className:"file-detail-header",children:[u.jsx("strong",{children:w?.name??"detail"}),u.jsxs("div",{className:"file-detail-actions",children:[u.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Fe()},children:"Move"}),u.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{ze()},children:"Delete"})]})]}),A==="loading"?u.jsx("div",{className:"file-detail-empty",children:"loading"}):null,R.type==="empty"&&A!=="loading"?u.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,R.type==="preview"?u.jsxs("div",{className:"file-preview-frame",children:[R.previewKind==="image"?u.jsx("img",{src:R.url,alt:R.file.name}):null,R.previewKind==="pdf"?u.jsx("iframe",{src:R.url,title:R.file.name}):null]}):null,R.type==="text-preview"&&R.read.language==="markdown"?u.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${R.file.name}`,children:u.jsx(v.Suspense,{fallback:u.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:u.jsx(bj,{content:R.read.content})})}):null,R.type==="text-preview"&&R.read.language==="text"?u.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${R.file.name}`,children:R.read.content}):null]})]})]})}function sv(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function Sj(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function G1(e,t){return`${e}\0${t??""}`}function wj(e){return`workspace\0${e}`}function xj(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 bl(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function X1(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 ma(e){return e instanceof Error?e.message:"Request failed"}function Cj(e){return e instanceof Vn&&e.status===409&&e.message==="terminal_cwd_changed"}const kj=v.lazy(()=>Ry(()=>import("./MarkdownPreview--8XdSXg9.js"),__vite__mapDeps([0,1])));function Z1({api:e,editor:t,canClose:n,onClose:s}){const[o,l]=v.useState(t.read),[d,f]=v.useState(t.read.content),[m,p]=v.useState("idle"),[b,_]=v.useState(null),[S,w]=v.useState(!1),[x,R]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),W=v.useRef(t.read.content),z=v.useRef(!1),H=v.useRef(!1),q=v.useRef(0),Y=d!==o.content&&m!=="saving"&&!S;v.useEffect(()=>(H.current=!0,()=>{H.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,z.current=!1,L.current=t,A.current=t.read,W.current=t.read.content,l(t.read),f(t.read.content),p("idle"),_(null),w(!1),R("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{W.current=d},[d]),v.useEffect(()=>{if(d===o.content||S)return;const K=window.setInterval(()=>{!z.current&&W.current!==A.current.content&&I()},1e3);return()=>window.clearInterval(K)},[d===o.content,S,t.id]);async function I(){if(z.current)return;const K=W.current,ne=A.current;if(K===ne.content)return;const ee=L.current,Z=q.current;z.current=!0,p("saving"),_(null),w(!1);try{const X=await e.writeFile({rootToken:ee.rootToken,path:ee.path,content:K,expectedVersion:ne.version});if(!H.current||Z!==q.current)return;const M={...ne,content:K,version:X.version};A.current=M,l(M),p(W.current===K?"saved":"idle")}catch(X){if(!H.current||Z!==q.current)return;if(X instanceof Vn&&X.status===409){w(!0),p("idle");return}_(Tj(X)),p("idle")}finally{Z===q.current&&(z.current=!1)}}const $=m==="saving"?"saving":m==="saved"?"saved":o.language,de=o.language==="markdown",me=de&&x==="preview";return u.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[u.jsxs("header",{className:"editor-pane-header",children:[u.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),u.jsx("strong",{children:t.title}),u.jsx("span",{className:"terminal-pane-spacer"}),u.jsx("span",{className:"terminal-pane-state",children:$}),u.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!Y,onClick:()=>{I()},children:"Save"}),de?u.jsx("button",{type:"button","aria-label":`${me?"Edit":"Preview"} ${t.title}`,onClick:()=>R(K=>K==="preview"?"edit":"preview"),children:me?"Edit":"Preview"}):null,n?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,me?u.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:u.jsx(v.Suspense,{fallback:u.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:u.jsx(kj,{content:d})})}):u.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:K=>{const ne=K.target.value;W.current=ne,f(ne),p("idle"),_(null),w(!1)}})]})}function Tj(e){return e instanceof Error?e.message:"Request failed"}var Ej=2,Rj=1,Nj=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),d={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=d.top+d.bottom,m=d.right+d.left,p=s-f,b=o-m-t;return{cols:Math.max(Ej,Math.floor(b/e.css.cell.width)),rows:Math.max(Rj,Math.floor(p/e.css.cell.height))}}};var zT=Object.defineProperty,Dj=Object.getOwnPropertyDescriptor,Mj=(e,t)=>{for(var n in t)zT(e,n,{get:t[n],enumerable:!0})},Un=(e,t,n,s)=>{for(var o=s>1?void 0:s?Dj(t,n):t,l=e.length-1,d;l>=0;l--)(d=e[l])&&(o=(s?d(t,n,o):d(o))||o);return s&&o&&zT(t,n,o),o},Ye=(e,t)=>(n,s)=>t(n,s,e),Q1="Terminal input",w_={get:()=>Q1,set:e=>Q1=e},J1="Too much output to announce, navigate to rows manually to read",x_={get:()=>J1,set:e=>J1=e};function Aj(e){return e.replace(/\r?\n/g,"\r")}function Lj(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function jj(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Oj(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");HT(o,t,n,s)}}function HT(e,t,n,s){e=Aj(e),e=Lj(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function UT(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 ex(e,t,n,s,o){UT(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function So(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Qp(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 Bj=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 d=e.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=n)return this._interim=d,s;let f=e.charCodeAt(l);56320<=f&&f<=57343?t[s++]=(d-55296)*1024+f-56320+65536:(t[s++]=d,t[s++]=f);continue}d!==65279&&(t[s++]=d)}return s}},Ij=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,l,d,f,m=0,p=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,R;for(;(R=this.interim[++x]&63)&&x<4;)w<<=6,w|=R;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-x;for(;p<A;){if(p>=n)return 0;if(R=e[p++],(R&192)!==128){p--,S=!0;break}else this.interim[x++]=R,w<<=6,w|=R&63}S||(L===2?w<128?p--:t[s++]=w:L===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let b=n-4,_=p;for(;_<n;){for(;_<b&&!((o=e[_])&128)&&!((l=e[_+1])&128)&&!((d=e[_+2])&128)&&!((f=e[_+3])&128);)t[s++]=o,t[s++]=l,t[s++]=d,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(m=(o&31)<<6|l&63,m<128){_--;continue}t[s++]=m}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(d=e[_++],(d&192)!==128){_--;continue}if(m=(o&15)<<12|(l&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}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(d=e[_++],(d&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=d,s;if(f=e[_++],(f&192)!==128){_--;continue}if(m=(o&7)<<18|(l&63)<<12|(d&63)<<6|f&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},$T="",Co=" ",hh=class FT{constructor(){this.fg=0,this.bg=0,this.extended=new mp}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 FT;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}},mp=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}},Zr=class KT extends hh{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new mp,this.combinedData=""}static fromCharData(t){let n=new KT;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?So(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()]}},tx="di$target",C_="di$dependencies",av=new Map;function Pj(e){return e[C_]||[]}function xi(e){if(av.has(e))return av.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");zj(t,n,o)};return t._id=e,av.set(e,t),t}function zj(e,t,n){t[tx]===t?t[C_].push({id:e,index:n}):(t[C_]=[{id:e,index:n}],t[tx]=t)}var Yi=xi("BufferService"),qT=xi("CoreMouseService"),Pl=xi("CoreService"),Hj=xi("CharsetService"),Ny=xi("InstantiationService"),VT=xi("LogService"),Gi=xi("OptionsService"),YT=xi("OscLinkService"),Uj=xi("UnicodeService"),fh=xi("DecorationService"),k_=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 Zr,d=n.getTrimmedLength(),f=-1,m=-1,p=!1;for(let b=0;b<d;b++)if(!(m===-1&&!n.hasContent(b))){if(n.loadCell(b,l),l.hasExtendedAttrs()&&l.extended.urlId)if(m===-1){m=b,f=l.extended.urlId;continue}else p=l.extended.urlId!==f;else m!==-1&&(p=!0);if(p||m!==-1&&b===d-1){let _=this._oscLinkService.getLinkData(f)?.uri;if(_){let S={start:{x:m+1,y:e},end:{x:b+(!p&&b===d-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:_,range:S,activate:(x,R)=>o?o.activate(x,R,S):$j(x,R),hover:(x,R)=>o?.hover?.(x,R,S),leave:(x,R)=>o?.leave?.(x,R,S)})}p=!1,l.hasExtendedAttrs()&&l.extended.urlId?(m=b,f=l.extended.urlId):(m=-1,f=-1)}}t(s)}};k_=Un([Ye(0,Yi),Ye(1,Gi),Ye(2,YT)],k_);function $j(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
17
|
-
|
|
18
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Jp=xi("CharSizeService"),Da=xi("CoreBrowserService"),Dy=xi("MouseService"),Ma=xi("RenderService"),Fj=xi("SelectionService"),GT=xi("CharacterJoinerService"),su=xi("ThemeService"),XT=xi("LinkProviderService"),Wj=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?nx.isErrorNoTelemetry(e)?new nx(e.message+`
|
|
19
|
-
|
|
20
|
-
`+e.stack):new Error(e.message+`
|
|
21
|
-
|
|
22
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Kj=new Wj;function zf(e){qj(e)||Kj.onUnexpectedError(e)}var T_="Canceled";function qj(e){return e instanceof Vj?!0:e instanceof Error&&e.name===T_&&e.message===T_}var Vj=class extends Error{constructor(){super(T_),this.name=this.message}};function Yj(e){return new Error(`Illegal argument: ${e}`)}var nx=class E_ extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof E_)return t;let n=new E_;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},R_=class ZT extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,ZT.prototype)}};function Cr(e,t=0){return e[e.length-(1+t)]}var Gj;(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})(Gj||={});function Xj(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var QT;(e=>{function t(H){return H&&typeof H=="object"&&typeof H[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(H){yield H}e.single=o;function l(H){return t(H)?H:o(H)}e.wrap=l;function d(H){return H||n}e.from=d;function*f(H){for(let q=H.length-1;q>=0;q--)yield H[q]}e.reverse=f;function m(H){return!H||H[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(H){return H[Symbol.iterator]().next().value}e.first=p;function b(H,q){let Y=0;for(let I of H)if(q(I,Y++))return!0;return!1}e.some=b;function _(H,q){for(let Y of H)if(q(Y))return Y}e.find=_;function*S(H,q){for(let Y of H)q(Y)&&(yield Y)}e.filter=S;function*w(H,q){let Y=0;for(let I of H)yield q(I,Y++)}e.map=w;function*x(H,q){let Y=0;for(let I of H)yield*q(I,Y++)}e.flatMap=x;function*R(...H){for(let q of H)yield*q}e.concat=R;function L(H,q,Y){let I=Y;for(let $ of H)I=q(I,$);return I}e.reduce=L;function*A(H,q,Y=H.length){for(q<0&&(q+=H.length),Y<0?Y+=H.length:Y>H.length&&(Y=H.length);q<Y;q++)yield H[q]}e.slice=A;function W(H,q=Number.POSITIVE_INFINITY){let Y=[];if(q===0)return[Y,H];let I=H[Symbol.iterator]();for(let $=0;$<q;$++){let de=I.next();if(de.done)return[Y,e.empty()];Y.push(de.value)}return[Y,{[Symbol.iterator](){return I}}]}e.consume=W;async function z(H){let q=[];for await(let Y of H)q.push(Y);return Promise.resolve(q)}e.asyncToArray=z})(QT||={});function Ol(e){if(QT.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 Zj(...e){return Rn(()=>Ol(e))}function Rn(e){return{dispose:Xj(()=>{e()})}}var JT=class eE{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{Ol(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?eE.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)}};JT.DISABLE_DISPOSED_WARNING=!1;var To=JT,Tt=class{constructor(){this._store=new To,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)}};Tt.None=Object.freeze({dispose(){}});var Qc=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}},xa=typeof window=="object"?window:globalThis,N_=class D_{constructor(t){this.element=t,this.next=D_.Undefined,this.prev=D_.Undefined}};N_.Undefined=new N_(void 0);var An=N_,ix=class{constructor(){this._first=An.Undefined,this._last=An.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===An.Undefined}clear(){let e=this._first;for(;e!==An.Undefined;){let t=e.next;e.prev=An.Undefined,e.next=An.Undefined,e=t}this._first=An.Undefined,this._last=An.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new An(e);if(this._first===An.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!==An.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==An.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==An.Undefined&&e.next!==An.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===An.Undefined&&e.next===An.Undefined?(this._first=An.Undefined,this._last=An.Undefined):e.next===An.Undefined?(this._last=this._last.prev,this._last.next=An.Undefined):e.prev===An.Undefined&&(this._first=this._first.next,this._first.prev=An.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==An.Undefined;)yield e.element,e=e.next}},Qj=globalThis.performance&&typeof globalThis.performance.now=="function",Jj=class tE{static create(t){return new tE(t)}constructor(t){this._now=Qj&&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}},Ni;(e=>{e.None=()=>Tt.None;function t(ne,ee){return _(ne,()=>{},0,void 0,!0,void 0,ee)}e.defer=t;function n(ne){return(ee,Z=null,X)=>{let M=!1,T;return T=ne(O=>{if(!M)return T?T.dispose():M=!0,ee.call(Z,O)},null,X),M&&T.dispose(),T}}e.once=n;function s(ne,ee,Z){return p((X,M=null,T)=>ne(O=>X.call(M,ee(O)),null,T),Z)}e.map=s;function o(ne,ee,Z){return p((X,M=null,T)=>ne(O=>{ee(O),X.call(M,O)},null,T),Z)}e.forEach=o;function l(ne,ee,Z){return p((X,M=null,T)=>ne(O=>ee(O)&&X.call(M,O),null,T),Z)}e.filter=l;function d(ne){return ne}e.signal=d;function f(...ne){return(ee,Z=null,X)=>{let M=Zj(...ne.map(T=>T(O=>ee.call(Z,O))));return b(M,X)}}e.any=f;function m(ne,ee,Z,X){let M=Z;return s(ne,T=>(M=ee(M,T),M),X)}e.reduce=m;function p(ne,ee){let Z,X={onWillAddFirstListener(){Z=ne(M.fire,M)},onDidRemoveLastListener(){Z?.dispose()}},M=new He(X);return ee?.add(M),M.event}function b(ne,ee){return ee instanceof Array?ee.push(ne):ee&&ee.add(ne),ne}function _(ne,ee,Z=100,X=!1,M=!1,T,O){let re,he,N,V=0,se,J={leakWarningThreshold:T,onWillAddFirstListener(){re=ne(ye=>{V++,he=ee(he,ye),X&&!N&&(xe.fire(he),he=void 0),se=()=>{let Pe=he;he=void 0,N=void 0,(!X||V>1)&&xe.fire(Pe),V=0},typeof Z=="number"?(clearTimeout(N),N=setTimeout(se,Z)):N===void 0&&(N=0,queueMicrotask(se))})},onWillRemoveListener(){M&&V>0&&se?.()},onDidRemoveLastListener(){se=void 0,re.dispose()}},xe=new He(J);return O?.add(xe),xe.event}e.debounce=_;function S(ne,ee=0,Z){return e.debounce(ne,(X,M)=>X?(X.push(M),X):[M],ee,void 0,!0,void 0,Z)}e.accumulate=S;function w(ne,ee=(X,M)=>X===M,Z){let X=!0,M;return l(ne,T=>{let O=X||!ee(T,M);return X=!1,M=T,O},Z)}e.latch=w;function x(ne,ee,Z){return[e.filter(ne,ee,Z),e.filter(ne,X=>!ee(X),Z)]}e.split=x;function R(ne,ee=!1,Z=[],X){let M=Z.slice(),T=ne(he=>{M?M.push(he):re.fire(he)});X&&X.add(T);let O=()=>{M?.forEach(he=>re.fire(he)),M=null},re=new He({onWillAddFirstListener(){T||(T=ne(he=>re.fire(he)),X&&X.add(T))},onDidAddFirstListener(){M&&(ee?setTimeout(O):O())},onDidRemoveLastListener(){T&&T.dispose(),T=null}});return X&&X.add(re),re.event}e.buffer=R;function L(ne,ee){return(Z,X,M)=>{let T=ee(new W);return ne(function(O){let re=T.evaluate(O);re!==A&&Z.call(X,re)},void 0,M)}}e.chain=L;let A=Symbol("HaltChainable");class W{constructor(){this.steps=[]}map(ee){return this.steps.push(ee),this}forEach(ee){return this.steps.push(Z=>(ee(Z),Z)),this}filter(ee){return this.steps.push(Z=>ee(Z)?Z:A),this}reduce(ee,Z){let X=Z;return this.steps.push(M=>(X=ee(X,M),X)),this}latch(ee=(Z,X)=>Z===X){let Z=!0,X;return this.steps.push(M=>{let T=Z||!ee(M,X);return Z=!1,X=M,T?M:A}),this}evaluate(ee){for(let Z of this.steps)if(ee=Z(ee),ee===A)break;return ee}}function z(ne,ee,Z=X=>X){let X=(...re)=>O.fire(Z(...re)),M=()=>ne.on(ee,X),T=()=>ne.removeListener(ee,X),O=new He({onWillAddFirstListener:M,onDidRemoveLastListener:T});return O.event}e.fromNodeEventEmitter=z;function H(ne,ee,Z=X=>X){let X=(...re)=>O.fire(Z(...re)),M=()=>ne.addEventListener(ee,X),T=()=>ne.removeEventListener(ee,X),O=new He({onWillAddFirstListener:M,onDidRemoveLastListener:T});return O.event}e.fromDOMEventEmitter=H;function q(ne){return new Promise(ee=>n(ne)(ee))}e.toPromise=q;function Y(ne){let ee=new He;return ne.then(Z=>{ee.fire(Z)},()=>{ee.fire(void 0)}).finally(()=>{ee.dispose()}),ee.event}e.fromPromise=Y;function I(ne,ee){return ne(Z=>ee.fire(Z))}e.forward=I;function $(ne,ee,Z){return ee(Z),ne(X=>ee(X))}e.runAndSubscribe=$;class de{constructor(ee,Z){this._observable=ee,this._counter=0,this._hasChanged=!1;let X={onWillAddFirstListener:()=>{ee.addObserver(this)},onDidRemoveLastListener:()=>{ee.removeObserver(this)}};this.emitter=new He(X),Z&&Z.add(this.emitter)}beginUpdate(ee){this._counter++}handlePossibleChange(ee){}handleChange(ee,Z){this._hasChanged=!0}endUpdate(ee){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function me(ne,ee){return new de(ne,ee).emitter.event}e.fromObservable=me;function K(ne){return(ee,Z,X)=>{let M=0,T=!1,O={beginUpdate(){M++},endUpdate(){M--,M===0&&(ne.reportChanges(),T&&(T=!1,ee.call(Z)))},handlePossibleChange(){},handleChange(){T=!0}};ne.addObserver(O),ne.reportChanges();let re={dispose(){ne.removeObserver(O)}};return X instanceof To?X.add(re):Array.isArray(X)&&X.push(re),re}}e.fromObservableLight=K})(Ni||={});var M_=class A_{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${A_._idPool++}`,A_.all.add(this)}start(t){this._stopWatch=new Jj,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}}};M_.all=new Set,M_._idPool=0;var e3=M_,t3=-1,nE=class iE{constructor(t,n,s=(iE._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,d]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(f),console.warn(l);let m=new r3(f,l);this._errorHandler(m)}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}};nE._idPool=1;var n3=nE,i3=class rE{constructor(t){this.value=t}static create(){let t=new Error;return new rE(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
-
`).slice(2).join(`
|
|
24
|
-
`))}},r3=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}},a3=0,ov=class{constructor(e){this.value=e,this.id=a3++}},o3=2,l3,He=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new n3(e?.onListenerError??zf,this._options?.leakWarningThreshold??t3):void 0,this._perfMon=this._options?._profName?new e3(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new s3(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||zf)(m),Tt.None}if(this._disposed)return Tt.None;t&&(e=e.bind(t));let s=new ov(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=i3.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof ov?(this._deliveryQueue??=new c3,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let l=Rn(()=>{o?.(),this._removeListener(s)});return n instanceof To?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*o3<=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||zf;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 ov)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}},c3=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}},L_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new He,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new He,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}};L_.INSTANCE=new L_;var My=L_;function u3(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}My.INSTANCE.onDidChangeZoomLevel;function d3(e){return My.INSTANCE.getZoomFactor(e)}My.INSTANCE.onDidChangeFullscreen;var au=typeof navigator=="object"?navigator.userAgent:"",j_=au.indexOf("Firefox")>=0,h3=au.indexOf("AppleWebKit")>=0,Ay=au.indexOf("Chrome")>=0,f3=!Ay&&au.indexOf("Safari")>=0;au.indexOf("Electron/")>=0;au.indexOf("Android")>=0;var lv=!1;if(typeof xa.matchMedia=="function"){let e=xa.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=xa.matchMedia("(display-mode: fullscreen)");lv=e.matches,u3(xa,e,({matches:n})=>{lv&&t.matches||(lv=n)})}var Pc="en",O_=!1,B_=!1,Hf=!1,sE=!1,wf,Uf=Pc,rx=Pc,p3,_a,Rl=globalThis,Tr;typeof Rl.vscode<"u"&&typeof Rl.vscode.process<"u"?Tr=Rl.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Tr=process);var m3=typeof Tr?.versions?.electron=="string",g3=m3&&Tr?.type==="renderer";if(typeof Tr=="object"){O_=Tr.platform==="win32",B_=Tr.platform==="darwin",Hf=Tr.platform==="linux",Hf&&Tr.env.SNAP&&Tr.env.SNAP_REVISION,Tr.env.CI||Tr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,wf=Pc,Uf=Pc;let e=Tr.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);wf=t.userLocale,rx=t.osLocale,Uf=t.resolvedLanguage||Pc,p3=t.languagePack?.translationsConfigFile}catch{}sE=!0}else typeof navigator=="object"&&!g3?(_a=navigator.userAgent,O_=_a.indexOf("Windows")>=0,B_=_a.indexOf("Macintosh")>=0,(_a.indexOf("Macintosh")>=0||_a.indexOf("iPad")>=0||_a.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Hf=_a.indexOf("Linux")>=0,_a?.indexOf("Mobi")>=0,Uf=globalThis._VSCODE_NLS_LANGUAGE||Pc,wf=navigator.language.toLowerCase(),rx=wf):console.error("Unable to resolve platform.");var aE=O_,Ms=B_,v3=Hf,sx=sE,js=_a,po=Uf,_3;(e=>{function t(){return po}e.value=t;function n(){return po.length===2?po==="en":po.length>=3?po[0]==="e"&&po[1]==="n"&&po[2]==="-":!1}e.isDefaultVariant=n;function s(){return po==="en"}e.isDefault=s})(_3||={});var b3=typeof Rl.postMessage=="function"&&!Rl.importScripts;(()=>{if(b3){let e=[];Rl.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}),Rl.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var y3=!!(js&&js.indexOf("Chrome")>=0);js&&js.indexOf("Firefox")>=0;!y3&&js&&js.indexOf("Safari")>=0;js&&js.indexOf("Edg/")>=0;js&&js.indexOf("Android")>=0;var Nc=typeof navigator=="object"?navigator:{};sx||document.queryCommandSupported&&document.queryCommandSupported("copy")||Nc&&Nc.clipboard&&Nc.clipboard.writeText,sx||Nc&&Nc.clipboard&&Nc.clipboard.readText;var Ly=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}},cv=new Ly,ax=new Ly,ox=new Ly,S3=new Array(230),oE;(e=>{function t(f){return cv.keyCodeToStr(f)}e.toString=t;function n(f){return cv.strToKeyCode(f)}e.fromString=n;function s(f){return ax.keyCodeToStr(f)}e.toUserSettingsUS=s;function o(f){return ox.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function l(f){return ax.strToKeyCode(f)||ox.strToKeyCode(f)}e.fromUserSettings=l;function d(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return cv.keyCodeToStr(f)}e.toElectronAccelerator=d})(oE||={});var w3=class lE{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 lE&&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 x3([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},x3=class{constructor(e){if(e.length===0)throw Yj("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 C3(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return oE.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(j_)switch(t){case 59:return 85;case 60:if(v3)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ms)return 57;break}else if(h3&&(Ms&&t===93||!Ms&&t===92))return 57;return S3[t]||0}var k3=Ms?256:2048,T3=512,E3=1024,R3=Ms?2048:256,lx=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=C3(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|=k3),this.altKey&&(t|=T3),this.shiftKey&&(t|=E3),this.metaKey&&(t|=R3),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new w3(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},cx=new WeakMap;function N3(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 D3=class{static getSameOriginWindowChain(e){let t=cx.get(e);if(!t){t=[],cx.set(e,t);let n=e,s;do s=N3(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 d=l.window.deref();if(n+=d?.scrollY??0,s+=d?.scrollX??0,d===t||!l.iframeElement)break;let f=l.iframeElement.getBoundingClientRect();n+=f.top,s+=f.left}return{top:n,left:s}}},xf=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=D3.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ux=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(Ay){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,d=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*d):this.deltaY=o.wheelDeltaY/120;else if(typeof 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?j_&&!Ms?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")f3&&aE?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*d):this.deltaX=o.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?j_&&!Ms?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},cE=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),M3;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof A3?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ni.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:cE})})(M3||={});var A3=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?cE:(this._emitter||(this._emitter=new He),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},jy=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 R_("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new R_("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},L3=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 R_("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Rn(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},j3;(e=>{async function t(s){let o,l=await Promise.all(s.map(d=>d.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(d){l(d)}})}e.withAsyncBody=n})(j3||={});var dx=class Kr{static fromArray(t){return new Kr(n=>{n.emitMany(t)})}static fromPromise(t){return new Kr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Kr(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Kr(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 He,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 Ni.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new Kr(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Kr.map(this,t)}static filter(t,n){return new Kr(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Kr.filter(this,t)}static coalesce(t){return Kr.filter(t,n=>!!n)}coalesce(){return Kr.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Kr.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())}};dx.EMPTY=dx.fromArray([]);var{getWindow:Ds,getWindowId:O3,onDidRegisterWindow:B3}=(function(){let e=new Map,t={window:xa,disposables:new To};e.set(xa.vscodeWindowId,t);let n=new He,s=new He,o=new He;function l(d,f){return(typeof d=="number"?e.get(d):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(d){if(e.has(d.vscodeWindowId))return Tt.None;let f=new To,m={window:d,disposables:f.add(new To)};return e.set(d.vscodeWindowId,m),f.add(Rn(()=>{e.delete(d.vscodeWindowId),s.fire(d)})),f.add(vt(d,_i.BEFORE_UNLOAD,()=>{o.fire(d)})),n.fire(m),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:l,getWindow(d){let f=d;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let m=d;return m?.view?m.view.window:xa},getDocument(d){return Ds(d).document}}})(),I3=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 vt(e,t,n,s){return new I3(e,t,n,s)}var hx=function(e,t,n,s){return vt(e,t,n,s)},Oy,P3=class extends L3{constructor(e){super(),this.defaultTarget=e&&Ds(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},fx=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){zf(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 d=e.get(l)??[];for(t.set(l,d),e.set(l,[]),s.set(l,!0);d.length>0;)d.sort(fx.sort),d.shift().execute();s.set(l,!1)};Oy=(l,d,f=0)=>{let m=O3(l),p=new fx(d,f),b=e.get(m);return b||(b=[],e.set(m,b)),b.push(p),n.get(m)||(n.set(m,!0),l.requestAnimationFrame(()=>o(m))),p}})();function z3(e){let t=e.getBoundingClientRect(),n=Ds(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var _i={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},H3=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=cr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=cr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=cr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=cr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=cr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=cr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=cr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=cr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=cr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=cr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=cr(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=cr(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=cr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=cr(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 cr(e){return typeof e=="number"?`${e}px`:e}function Id(e){return new H3(e)}var uE=class{constructor(){this._hooks=new To,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(Rn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Ds(e)}this._hooks.add(vt(l,_i.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(vt(l,_i.POINTER_UP,d=>this.stopMonitoring(!0)))}};function U3(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(...d){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,d)}),this[l]}}var Es;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Es||={});var vd=class Ii extends Tt{constructor(){super(),this.dispatched=!1,this.targets=new ix,this.ignoreTargets=new ix,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ni.runAndSubscribe(B3,({window:t,disposables:n})=>{n.add(vt(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(vt(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(vt(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:xa,disposables:this._store}))}static addTarget(t){if(!Ii.isTouchDevice())return Tt.None;Ii.INSTANCE||(Ii.INSTANCE=new Ii);let n=Ii.INSTANCE.targets.push(t);return Rn(n)}static ignoreTarget(t){if(!Ii.isTouchDevice())return Tt.None;Ii.INSTANCE||(Ii.INSTANCE=new Ii);let n=Ii.INSTANCE.ignoreTargets.push(t);return Rn(n)}static isTouchDevice(){return"ontouchstart"in xa||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 d=this.newGestureEvent(Es.Start,l.target);d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,d=n.changedTouches.length;l<d;l++){let f=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let m=this.activeTouches[f.identifier],p=Date.now()-m.initialTimeStamp;if(p<Ii.HOLD_DELAY&&Math.abs(m.initialPageX-Cr(m.rollingPageX))<30&&Math.abs(m.initialPageY-Cr(m.rollingPageY))<30){let b=this.newGestureEvent(Es.Tap,m.initialTarget);b.pageX=Cr(m.rollingPageX),b.pageY=Cr(m.rollingPageY),this.dispatchEvent(b)}else if(p>=Ii.HOLD_DELAY&&Math.abs(m.initialPageX-Cr(m.rollingPageX))<30&&Math.abs(m.initialPageY-Cr(m.rollingPageY))<30){let b=this.newGestureEvent(Es.Contextmenu,m.initialTarget);b.pageX=Cr(m.rollingPageX),b.pageY=Cr(m.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=Cr(m.rollingPageX),_=Cr(m.rollingPageY),S=Cr(m.rollingTimestamps)-m.rollingTimestamps[0],w=b-m.rollingPageX[0],x=_-m.rollingPageY[0],R=[...this.targets].filter(L=>m.initialTarget instanceof Node&&L.contains(m.initialTarget));this.inertia(t,R,s,Math.abs(w)/S,w>0?1:-1,b,Math.abs(x)/S,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(Es.End,m.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===Es.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Ii.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Es.Change||t.type===Es.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,d,f,m,p){this.handle=Oy(t,()=>{let b=Date.now(),_=b-s,S=0,w=0,x=!0;o+=Ii.SCROLL_FRICTION*_,f+=Ii.SCROLL_FRICTION*_,o>0&&(x=!1,S=l*o*_),f>0&&(x=!1,w=m*f*_);let R=this.newGestureEvent(Es.Change);R.translationX=S,R.translationY=w,n.forEach(L=>L.dispatchEvent(R)),x||this.inertia(t,n,b,o,l,d+S,f,m,p+w)})}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 d=this.activeTouches[l.identifier],f=this.newGestureEvent(Es.Change,d.initialTarget);f.translationX=l.pageX-Cr(d.rollingPageX),f.translationY=l.pageY-Cr(d.rollingPageY),f.pageX=l.pageX,f.pageY=l.pageY,this.dispatchEvent(f),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(l.pageX),d.rollingPageY.push(l.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};vd.SCROLL_FRICTION=-.005,vd.HOLD_DELAY=700,vd.CLEAR_TAP_COUNT_TIME=400,Un([U3],vd,"isTouchDevice",1);var $3=vd,By=class extends Tt{onclick(e,t){this._register(vt(e,_i.CLICK,n=>t(new xf(Ds(e),n))))}onmousedown(e,t){this._register(vt(e,_i.MOUSE_DOWN,n=>t(new xf(Ds(e),n))))}onmouseover(e,t){this._register(vt(e,_i.MOUSE_OVER,n=>t(new xf(Ds(e),n))))}onmouseleave(e,t){this._register(vt(e,_i.MOUSE_LEAVE,n=>t(new xf(Ds(e),n))))}onkeydown(e,t){this._register(vt(e,_i.KEY_DOWN,n=>t(new lx(n))))}onkeyup(e,t){this._register(vt(e,_i.KEY_UP,n=>t(new lx(n))))}oninput(e,t){this._register(vt(e,_i.INPUT,t))}onblur(e,t){this._register(vt(e,_i.BLUR,t))}onfocus(e,t){this._register(vt(e,_i.FOCUS,t))}onchange(e,t){this._register(vt(e,_i.CHANGE,t))}ignoreGesture(e){return $3.ignoreTarget(e)}},px=11,F3=class extends By{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=px+"px",this.domNode.style.height=px+"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 uE),this._register(hx(this.bgDomNode,_i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(hx(this.domNode,_i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new P3),this._pointerdownScheduleRepeatTimer=this._register(new jy)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ds(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()}},W3=class I_{constructor(t,n,s,o,l,d,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,l=l|0,d=d|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),l<0&&(l=0),f+l>d&&(f=d-l),f<0&&(f=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=d,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new I_(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 I_(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,d=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,m=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:d,scrollHeightChanged:f,scrollTopChanged:m}}},K3=class extends Tt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new He),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new W3(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 gx(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=gx.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)))}},mx=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function uv(e,t){let n=t-e;return function(s){return e+n*Y3(s)}}function q3(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var gx=class P_{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),q3(uv(t,o),uv(l,n),.33)}return uv(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 mx(s,o,!1)}return new mx(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return P_.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new P_(t,n,o,s)}};function V3(e){return Math.pow(e,3)}function Y3(e){return 1-V3(1-e)}var G3=class extends Tt{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 jy)}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":"")))}},X3=140,dE=class extends By{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 G3(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new uE),this._shouldRender=!0,this.domNode=Id(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(vt(this.domNode.domNode,_i.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new F3(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Id(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(vt(this.slider.domNode,_i.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=z3(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),d=Math.abs(l-n);if(aE&&d>X3){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()}},hE=class z_{constructor(t,n,s,o,l,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new z_(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 d=Math.max(0,s-t),f=Math.max(0,d-2*n),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(d),computedIsNeeded:m,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(d),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:b,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=z_._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)}},Z3=class extends dE{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new hE(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}},Q3=class extends dE{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new hE(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}},J3=500,vx=50,eO=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},H_=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(Ay){let n=Ds(t.browserEvent),s=d3(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 eO(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),d=Math.abs(n.deltaX),f=Math.abs(n.deltaY),m=Math.max(Math.min(o,d),1),p=Math.max(Math.min(l,f),1),b=Math.max(o,d),_=Math.max(l,f);b%m===0&&_%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};H_.INSTANCE=new H_;var tO=H_,nO=class extends By{constructor(e,t,n){super(),this._onScroll=this._register(new He),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new He),this.onWillScroll=this._onWillScroll.event,this._options=rO(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 Q3(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Z3(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=Id(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Id(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Id(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 jy),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ol(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,Ms&&(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 ux(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ol(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new ux(n))};this._mouseWheelToDispose.push(vt(this._listenOnDomNode,_i.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=tO.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,l=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&l+o===0?l=o=0:Math.abs(o)>=Math.abs(l)?l=0:o=0),this._options.flipAxes&&([o,l]=[l,o]);let d=!Ms&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!l&&(l=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(l=l*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),m={};if(o){let p=vx*o,b=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(m,b)}if(l){let p=vx*l,b=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(m,b)}m=this._scrollable.validateScrollPosition(m),(f.scrollLeft!==m.scrollLeft||f.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),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(),J3)}},iO=class extends nO{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 rO(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,Ms&&(t.className+=" mac"),t}var U_=class extends Tt{constructor(e,t,n,s,o,l,d,f){super(),this._bufferService=n,this._optionsService=d,this._renderService=f,this._onRequestScrollLines=this._register(new He),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new K3({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Oy(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new iO(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),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(Ni.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Rn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Rn(()=>this._styleElement.remove())),this._register(Ni.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(`
|
|
25
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};U_=Un([Ye(2,Yi),Ye(3,Da),Ye(4,qT),Ye(5,su),Ye(6,Gi),Ye(7,Ma)],U_);var $_=class extends Tt{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(Rn(()=>{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()}};$_=Un([Ye(1,Yi),Ye(2,Da),Ye(3,fh),Ye(4,Ma)],$_);var sO=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)}},ks={full:0,left:0,center:0,right:0},mo={full:0,left:0,center:0,right:0},od={full:0,left:0,center:0,right:0},gp=class extends Tt{constructor(e,t,n,s,o,l,d,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=d,this._coreBrowserService=f,this._colorZoneStore=new sO,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(Rn(()=>this._canvas?.remove()));let m=this._canvas.getContext("2d");if(m)this._ctx=m;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);mo.full=this._canvas.width,mo.left=e,mo.center=t,mo.right=e,this._refreshDrawHeightConstants(),od.full=1,od.left=1,od.center=1+mo.left,od.right=1+mo.left+mo.center}_refreshDrawHeightConstants(){ks.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);ks.left=t,ks.center=t,ks.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ks.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ks.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ks.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ks.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(od[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ks[e.position||"full"]/2),mo[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ks[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}))}};gp=Un([Ye(2,Yi),Ye(3,fh),Ye(4,Ma),Ye(5,Gi),Ye(6,su),Ye(7,Da)],gp);var Ne;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
26
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(Ne||={});var $f;(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=""))($f||={});var fE;(e=>e.ST=`${Ne.ESC}\\`)(fE||={});var F_=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(`${Ne.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,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)}}};F_=Un([Ye(2,Yi),Ye(3,Gi),Ye(4,Pl),Ye(5,Ma)],F_);var yi=0,Si=0,wi=0,Hn=0,_x={css:"#00000000",rgba:0},ii;(e=>{function t(o,l,d,f){return f!==void 0?`#${yl(o)}${yl(l)}${yl(d)}${yl(f)}`:`#${yl(o)}${yl(l)}${yl(d)}`}e.toCss=t;function n(o,l,d,f=255){return(o<<24|l<<16|d<<8|f)>>>0}e.toRgba=n;function s(o,l,d,f){return{css:e.toCss(o,l,d,f),rgba:e.toRgba(o,l,d,f)}}e.toColor=s})(ii||={});var vn;(e=>{function t(m,p){if(Hn=(p.rgba&255)/255,Hn===1)return{css:p.css,rgba:p.rgba};let b=p.rgba>>24&255,_=p.rgba>>16&255,S=p.rgba>>8&255,w=m.rgba>>24&255,x=m.rgba>>16&255,R=m.rgba>>8&255;yi=w+Math.round((b-w)*Hn),Si=x+Math.round((_-x)*Hn),wi=R+Math.round((S-R)*Hn);let L=ii.toCss(yi,Si,wi),A=ii.toRgba(yi,Si,wi);return{css:L,rgba:A}}e.blend=t;function n(m){return(m.rgba&255)===255}e.isOpaque=n;function s(m,p,b){let _=Ff.ensureContrastRatio(m.rgba,p.rgba,b);if(_)return ii.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[yi,Si,wi]=Ff.toChannels(p),{css:ii.toCss(yi,Si,wi),rgba:p}}e.opaque=o;function l(m,p){return Hn=Math.round(p*255),[yi,Si,wi]=Ff.toChannels(m.rgba),{css:ii.toCss(yi,Si,wi,Hn),rgba:ii.toRgba(yi,Si,wi,Hn)}}e.opacity=l;function d(m,p){return Hn=m.rgba&255,l(m,Hn*p/255)}e.multiplyOpacity=d;function f(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=f})(vn||={});var Ln;(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 yi=parseInt(o.slice(1,2).repeat(2),16),Si=parseInt(o.slice(2,3).repeat(2),16),wi=parseInt(o.slice(3,4).repeat(2),16),ii.toColor(yi,Si,wi);case 5:return yi=parseInt(o.slice(1,2).repeat(2),16),Si=parseInt(o.slice(2,3).repeat(2),16),wi=parseInt(o.slice(3,4).repeat(2),16),Hn=parseInt(o.slice(4,5).repeat(2),16),ii.toColor(yi,Si,wi,Hn);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 yi=parseInt(l[1]),Si=parseInt(l[2]),wi=parseInt(l[3]),Hn=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),ii.toColor(yi,Si,wi,Hn);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),[yi,Si,wi,Hn]=t.getImageData(0,0,1,1).data,Hn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ii.toRgba(yi,Si,wi,Hn),css:o}}e.toColor=s})(Ln||={});var qi;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,l){let d=s/255,f=o/255,m=l/255,p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),b=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),_=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+b*.7152+_*.0722}e.relativeLuminance2=n})(qi||={});var Ff;(e=>{function t(d,f){if(Hn=(f&255)/255,Hn===1)return f;let m=f>>24&255,p=f>>16&255,b=f>>8&255,_=d>>24&255,S=d>>16&255,w=d>>8&255;return yi=_+Math.round((m-_)*Hn),Si=S+Math.round((p-S)*Hn),wi=w+Math.round((b-w)*Hn),ii.toRgba(yi,Si,wi)}e.blend=t;function n(d,f,m){let p=qi.relativeLuminance(d>>8),b=qi.relativeLuminance(f>>8);if(ga(p,b)<m){if(b<p){let w=s(d,f,m),x=ga(p,qi.relativeLuminance(w>>8));if(x<m){let R=o(d,f,m),L=ga(p,qi.relativeLuminance(R>>8));return x>L?w:R}return w}let _=o(d,f,m),S=ga(p,qi.relativeLuminance(_>>8));if(S<m){let w=s(d,f,m),x=ga(p,qi.relativeLuminance(w>>8));return S>x?_:w}return _}}e.ensureContrastRatio=n;function s(d,f,m){let p=d>>24&255,b=d>>16&255,_=d>>8&255,S=f>>24&255,w=f>>16&255,x=f>>8&255,R=ga(qi.relativeLuminance2(S,w,x),qi.relativeLuminance2(p,b,_));for(;R<m&&(S>0||w>0||x>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),R=ga(qi.relativeLuminance2(S,w,x),qi.relativeLuminance2(p,b,_));return(S<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=s;function o(d,f,m){let p=d>>24&255,b=d>>16&255,_=d>>8&255,S=f>>24&255,w=f>>16&255,x=f>>8&255,R=ga(qi.relativeLuminance2(S,w,x),qi.relativeLuminance2(p,b,_));for(;R<m&&(S<255||w<255||x<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),R=ga(qi.relativeLuminance2(S,w,x),qi.relativeLuminance2(p,b,_));return(S<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=o;function l(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=l})(Ff||={});function yl(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ga(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var aO=class extends hh{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()]}},vp=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Zr}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,d=0,f=t.getFg(0),m=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!==m){if(p-o>1){let b=this._getJoinedRanges(s,d,l,t,o);for(let _=0;_<b.length;_++)n.push(b[_])}o=p,d=l,f=this._workCell.fg,m=this._workCell.bg}l+=this._workCell.getChars().length||Co.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,d,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),d=[];try{d=this._characterJoiners[0].handler(l)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let m=this._characterJoiners[f].handler(l);for(let p=0;p<m.length;p++)vp._mergeRanges(d,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(d,s,o),d}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,l=0,d=e[s];if(d){for(let f=n;f<this._bufferService.cols;f++){let m=t.getWidth(f),p=t.getString(f).length||Co.length;if(m!==0){if(!o&&d[0]<=l&&(d[0]=f,o=!0),d[1]<=l){if(d[1]=f,d=e[++s],!d)break;d[0]<=l?(d[0]=f,o=!0):o=!1}l+=p}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let 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}};vp=Un([Ye(0,Yi)],vp);function oO(e){return 57508<=e&&e<=57558}function lO(e){return 9472<=e&&e<=9631}function cO(e){return oO(e)||lO(e)}function uO(){return{css:{canvas:Cf(),cell:Cf()},device:{canvas:Cf(),cell:Cf(),char:{width:0,height:0,left:0,top:0}}}}function Cf(){return{width:0,height:0}}var W_=class{constructor(e,t,n,s,o,l,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=d,this._workCell=new Zr,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,d,f,m,p,b){let _=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<l+1&&(x=l+1);let R,L=0,A="",W=0,z=0,H=0,q=0,Y=!1,I=0,$=!1,de=0,me=0,K=[],ne=p!==-1&&b!==-1;for(let ee=0;ee<x;ee++){e.loadCell(ee,this._workCell);let Z=this._workCell.getWidth();if(Z===0)continue;let X=!1,M=ee>=me,T=ee,O=this._workCell;if(S.length>0&&ee===S[0][0]&&M){let j=S.shift(),ge=this._isCellInSelection(j[0],t);for(W=j[0]+1;W<j[1];W++)M&&=ge===this._isCellInSelection(W,t);M&&=!n||l<j[0]||l>=j[1],M?(X=!0,O=new aO(this._workCell,e.translateToString(!0,j[0],j[1]),j[1]-j[0]),T=j[1]-1,Z=O.getWidth()):me=j[1]}let re=this._isCellInSelection(ee,t),he=n&&ee===l,N=ne&&ee>=p&&ee<=b,V=!1;this._decorationService.forEachDecorationAtCell(ee,t,void 0,j=>{V=!0});let se=O.getChars()||Co;if(se===" "&&(O.isUnderline()||O.isOverline())&&(se=" "),de=Z*f-m.get(se,O.isBold(),O.isItalic()),!R)R=this._document.createElement("span");else if(L&&(re&&$||!re&&!$&&O.bg===z)&&(re&&$&&w.selectionForeground||O.fg===H)&&O.extended.ext===q&&N===Y&&de===I&&!he&&!X&&!V&&M){O.isInvisible()?A+=Co:A+=se,L++;continue}else L&&(R.textContent=A),R=this._document.createElement("span"),L=0,A="";if(z=O.bg,H=O.fg,q=O.extended.ext,Y=N,I=de,$=re,X&&l>=ee&&l<=T&&(l=ee),!this._coreService.isCursorHidden&&he&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(O.isBold()&&K.push("xterm-bold"),O.isItalic()&&K.push("xterm-italic"),O.isDim()&&K.push("xterm-dim"),O.isInvisible()?A=Co:A=O.getChars()||Co,O.isUnderline()&&(K.push(`xterm-underline-${O.extended.underlineStyle}`),A===" "&&(A=" "),!O.isUnderlineColorDefault()))if(O.isUnderlineColorRGB())R.style.textDecorationColor=`rgb(${hh.toColorRGB(O.getUnderlineColor()).join(",")})`;else{let j=O.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&O.isBold()&&j<8&&(j+=8),R.style.textDecorationColor=w.ansi[j].css}O.isOverline()&&(K.push("xterm-overline"),A===" "&&(A=" ")),O.isStrikethrough()&&K.push("xterm-strikethrough"),N&&(R.style.textDecoration="underline");let J=O.getFgColor(),xe=O.getFgColorMode(),ye=O.getBgColor(),Pe=O.getBgColorMode(),Fe=!!O.isInverse();if(Fe){let j=J;J=ye,ye=j;let ge=xe;xe=Pe,Pe=ge}let ze,ve,We=!1;this._decorationService.forEachDecorationAtCell(ee,t,void 0,j=>{j.options.layer!=="top"&&We||(j.backgroundColorRGB&&(Pe=50331648,ye=j.backgroundColorRGB.rgba>>8&16777215,ze=j.backgroundColorRGB),j.foregroundColorRGB&&(xe=50331648,J=j.foregroundColorRGB.rgba>>8&16777215,ve=j.foregroundColorRGB),We=j.options.layer==="top")}),!We&&re&&(ze=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,ye=ze.rgba>>8&16777215,Pe=50331648,We=!0,w.selectionForeground&&(xe=50331648,J=w.selectionForeground.rgba>>8&16777215,ve=w.selectionForeground)),We&&K.push("xterm-decoration-top");let Oe;switch(Pe){case 16777216:case 33554432:Oe=w.ansi[ye],K.push(`xterm-bg-${ye}`);break;case 50331648:Oe=ii.toColor(ye>>16,ye>>8&255,ye&255),this._addStyle(R,`background-color:#${bx((ye>>>0).toString(16),"0",6)}`);break;default:Fe?(Oe=w.foreground,K.push("xterm-bg-257")):Oe=w.background}switch(ze||O.isDim()&&(ze=vn.multiplyOpacity(Oe,.5)),xe){case 16777216:case 33554432:O.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(R,Oe,w.ansi[J],O,ze,void 0)||K.push(`xterm-fg-${J}`);break;case 50331648:let j=ii.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(R,Oe,j,O,ze,ve)||this._addStyle(R,`color:#${bx(J.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(R,Oe,w.foreground,O,ze,ve)||Fe&&K.push("xterm-fg-257")}K.length&&(R.className=K.join(" "),K.length=0),!he&&!X&&!V&&M?L++:R.textContent=A,de!==this.defaultSpacing&&(R.style.letterSpacing=`${de}px`),_.push(R),ee=T}return R&&L&&(R.textContent=A),_}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||cO(s.getCode()))return!1;let d=this._getContrastCache(s),f;if(!o&&!l&&(f=d.getColor(t.rgba,n.rgba)),f===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);f=vn.ensureContrastRatio(o||t,l||n,m),d.setColor((o||t).rgba,(l||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,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]}};W_=Un([Ye(1,GT),Ye(2,Gi),Ye(3,Da),Ye(4,Pl),Ye(5,fh),Ye(6,su)],W_);function bx(e,t,n){for(;e.length<n;)e=t+e;return e}var dO=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 d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let o=e;t&&(o+="B"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let d=0;t&&(d|=1),n&&(d|=2),l=this._measure(e,d),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},hO=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,d=n[1]-o,f=Math.max(l,0),m=Math.min(d,e.rows-1);if(f>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=f,this.viewportCappedEndRow=m,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 fO(){return new hO}var dv="xterm-dom-renderer-owner-",Wr="xterm-rows",kf="xterm-fg-",yx="xterm-bg-",ld="xterm-focus",Tf="xterm-selection",pO=1,K_=class extends Tt{constructor(e,t,n,s,o,l,d,f,m,p,b,_,S,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=d,this._charSizeService=m,this._optionsService=p,this._bufferService=b,this._coreService=_,this._coreBrowserService=S,this._themeService=w,this._terminalClass=pO++,this._rowElements=[],this._selectionRenderModel=fO(),this.onRequestRedraw=this._register(new He).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Wr),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(Tf),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=uO(),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(W_,document),this._element.classList.add(dv+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(Rn(()=>{this._element.classList.remove(dv+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new dO(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} .${Wr} 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} .${Wr} { 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} .${Wr} .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} .${Wr}.${ld} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Wr}.${ld} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Wr}.${ld} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Wr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Wr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Wr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Wr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Wr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Tf} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Tf} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Tf} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,d]of e.ansi.entries())t+=`${this._terminalSelector} .${kf}${l} { color: ${d.css}; }${this._terminalSelector} .${kf}${l}.xterm-dim { color: ${vn.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${yx}${l} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${kf}257 { color: ${vn.opaque(e.background).css}; }${this._terminalSelector} .${kf}257.xterm-dim { color: ${vn.multiplyOpacity(vn.opaque(e.background),.5).css}; }${this._terminalSelector} .${yx}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(ld),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ld),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,d=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let m=e[0]>t[0];f.appendChild(this._createSelectionElement(l,m?t[0]:e[0],m?e[0]:t[0],d-l+1))}else{let m=s===l?e[0]:0,p=l===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(l,m,p));let b=d-l-1;if(f.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,b)),l!==d){let _=o===d?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(d,0,_))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return l+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-l),o.style.height=`${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=`${d}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+n.ydisp,b=this._rowElements[m],_=n.lines.get(p);if(!b||!_)break;b.replaceChildren(...this._rowFactory.createRow(_,p,p===s,d,f,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${dv}${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 d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),s=Math.max(Math.min(s,d),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,m=f.ybase+f.y,p=Math.min(f.x,o-1),b=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=s;++w){let x=w+f.ydisp,R=this._rowElements[w],L=f.lines.get(x);if(!R||!L)break;R.replaceChildren(...this._rowFactory.createRow(L,x,x===m,_,S,p,b,this.dimensions.css.cell.width,this._widthCache,l?w===n?e:0:-1,l?(w===s?t:o)-1:-1))}}};K_=Un([Ye(7,Ny),Ye(8,Jp),Ye(9,Gi),Ye(10,Yi),Ye(11,Pl),Ye(12,Da),Ye(13,su)],K_);var q_=class extends Tt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new He),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new gO(this._optionsService))}catch{this._measureStrategy=this._register(new mO(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())}};q_=Un([Ye(2,Gi)],q_);var pE=class extends Tt{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)}},mO=class extends pE{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}},gO=class extends pE{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}},vO=class extends Tt{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 _O(this._window)),this._onDprChange=this._register(new He),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new He),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ni.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(vt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(vt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},_O=class extends Tt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Qc),this._onDprChange=this._register(new He),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Rn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=vt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},bO=class extends Tt{constructor(){super(),this.linkProviders=[],this._register(Rn(()=>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 Iy(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),d=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-d]}function yO(e,t,n,s,o,l,d,f,m){if(!l)return;let p=Iy(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(m?d/2:0))/d),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),s+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var V_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return yO(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=Iy(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])}}};V_=Un([Ye(0,Ma),Ye(1,Jp)],V_);var SO=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=[]}},mE={};Mj(mE,{getSafariVersion:()=>xO,isChromeOS:()=>bE,isFirefox:()=>gE,isIpad:()=>CO,isIphone:()=>kO,isLegacyEdge:()=>wO,isLinux:()=>Py,isMac:()=>_p,isNode:()=>em,isSafari:()=>vE,isWindows:()=>_E});var em=typeof process<"u"&&"title"in process,ph=em?"node":navigator.userAgent,mh=em?"node":navigator.platform,gE=ph.includes("Firefox"),wO=ph.includes("Edge"),vE=/^((?!chrome|android).)*safari/i.test(ph);function xO(){if(!vE)return 0;let e=ph.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _p=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mh),CO=mh==="iPad",kO=mh==="iPhone",_E=["Windows","Win16","Win32","WinCE"].includes(mh),Py=mh.indexOf("Linux")>=0,bE=/\bCrOS\b/.test(ph),yE=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()}},TO=class extends yE{_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())}}},EO=class extends yE{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},bp=!em&&"requestIdleCallback"in window?EO:TO,RO=class{constructor(){this._queue=new bp}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Y_=class extends Tt{constructor(e,t,n,s,o,l,d,f,m){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Qc),this._pausedResizeTask=new RO,this._observerDisposable=this._register(new Qc),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 He),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new He),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new He),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new He),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new SO((p,b)=>this._renderRows(p,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new NO(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Rn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(m.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=Rn(()=>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()}};Y_=Un([Ye(2,Gi),Ye(3,Jp),Ye(4,Pl),Ye(5,fh),Ye(6,Yi),Ye(7,Da),Ye(8,su)],Y_);var NO=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 DO(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return LO(o,l,e,t,n,s)+tm(l,t,n,s)+jO(o,l,e,t,n,s);let d;if(l===t)return d=o>e?"D":"C",qd(Math.abs(o-e),Kd(d,s));d=l>t?"D":"C";let f=Math.abs(l-t),m=AO(l>t?e:o,n)+(f-1)*n.cols+1+MO(l>t?o:e);return qd(m,Kd(d,s))}function MO(e,t){return e-1}function AO(e,t){return t.cols-e}function LO(e,t,n,s,o,l){return tm(t,s,o,l).length===0?"":qd(wE(e,t,e,t-Bl(t,o),!1,o).length,Kd("D",l))}function tm(e,t,n,s){let o=e-Bl(e,n),l=t-Bl(t,n),d=Math.abs(o-l)-OO(e,t,n);return qd(d,Kd(SE(e,t),s))}function jO(e,t,n,s,o,l){let d;tm(t,s,o,l).length>0?d=s-Bl(s,o):d=t;let f=s,m=BO(e,t,n,s,o,l);return qd(wE(e,d,n,f,m==="C",o).length,Kd(m,l))}function OO(e,t,n){let s=0,o=e-Bl(e,n),l=t-Bl(t,n);for(let d=0;d<Math.abs(o-l);d++){let f=SE(e,t)==="A"?-1:1;n.buffer.lines.get(o+f*d)?.isWrapped&&s++}return s}function Bl(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 BO(e,t,n,s,o,l){let d;return tm(n,s,o,l).length>0?d=s-Bl(s,o):d=t,e<n&&d<=s||e>=n&&d<s?"C":"D"}function SE(e,t){return e>t?"A":"B"}function wE(e,t,n,s,o,l){let d=e,f=t,m="";for(;(d!==n||f!==s)&&f>=0&&f<l.buffer.lines.length;)d+=o?1:-1,o&&d>l.cols-1?(m+=l.buffer.translateBufferLineToString(f,!1,e,d),d=0,e=0,f++):!o&&d<0&&(m+=l.buffer.translateBufferLineToString(f,!1,0,e+1),d=l.cols-1,e=d,f--);return m+l.buffer.translateBufferLineToString(f,!1,e,d)}function Kd(e,t){let n=t?"O":"[";return Ne.ESC+n+e}function qd(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var IO=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Sx(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 hv=50,PO=15,zO=50,HO=500,UO=" ",$O=new RegExp(UO,"g"),G_=class extends Tt{constructor(e,t,n,s,o,l,d,f,m){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=d,this._renderService=f,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Zr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new He),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new He),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new He),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new He),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new IO(this._bufferService),this._activeSelectionMode=0,this._register(Rn(()=>{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 d=e[1];d<=t[1];d++){let f=n.translateBufferLineToString(d,!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 d=n.lines.get(l),f=n.translateBufferLineToString(l,!0);d?.isWrapped?s[s.length-1]+=f:s.push(f)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(o=>o.replace($O," ")).join(_E?`\r
|
|
27
|
-
`:`
|
|
28
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Py&&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=Sx(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=Iy(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,-hv),hv),t/=hv,t/Math.abs(t)+Math.round(t*(PO-1)))}shouldForceSelection(e){return _p?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(),zO)}_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&&!(_p&&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<HO&&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=DO(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 d=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(l,e[0]),m=f,p=e[0]-f,b=0,_=0,S=0,w=0;if(d.charAt(f)===" "){for(;f>0&&d.charAt(f-1)===" ";)f--;for(;m<d.length&&d.charAt(m+1)===" ";)m++}else{let L=e[0],A=e[0];l.getWidth(L)===0&&(b++,L--),l.getWidth(A)===2&&(_++,A++);let W=l.getString(A).length;for(W>1&&(w+=W-1,m+=W-1);L>0&&f>0&&!this._isCharWordSeparator(l.loadCell(L-1,this._workCell));){l.loadCell(L-1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,L--):z>1&&(S+=z-1,f-=z-1),f--,L--}for(;A<l.length&&m+1<d.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&&(w+=z-1,m+=z-1),m++,A++}}m++;let x=f+p-b+S,R=Math.min(this._bufferService.cols,m-f+b+_-S-w);if(!(!t&&d.slice(f,m).trim()==="")){if(n&&x===0&&l.getCodePoint(0)!==32){let L=o.lines.get(e[1]-1);if(L&&l.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let W=this._bufferService.cols-A.start;x-=W,R+=W}}}if(s&&x+R===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let L=o.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(R+=A.length)}}return{start:x,length:R}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Sx(n,this._bufferService.cols)}};G_=Un([Ye(3,Yi),Ye(4,Pl),Ye(5,Dy),Ye(6,Gi),Ye(7,Ma),Ye(8,Da)],G_);var wx=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={}}},xx=class{constructor(){this._color=new wx,this._css=new wx}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()}},ui=Object.freeze((()=>{let e=[Ln.toColor("#2e3436"),Ln.toColor("#cc0000"),Ln.toColor("#4e9a06"),Ln.toColor("#c4a000"),Ln.toColor("#3465a4"),Ln.toColor("#75507b"),Ln.toColor("#06989a"),Ln.toColor("#d3d7cf"),Ln.toColor("#555753"),Ln.toColor("#ef2929"),Ln.toColor("#8ae234"),Ln.toColor("#fce94f"),Ln.toColor("#729fcf"),Ln.toColor("#ad7fa8"),Ln.toColor("#34e2e2"),Ln.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:ii.toCss(s,o,l),rgba:ii.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:ii.toCss(s,s,s),rgba:ii.toRgba(s,s,s)})}return e})()),Sl=Ln.toColor("#ffffff"),_d=Ln.toColor("#000000"),Cx=Ln.toColor("#ffffff"),kx=_d,cd={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},FO=Sl,X_=class extends Tt{constructor(e){super(),this._optionsService=e,this._contrastCache=new xx,this._halfContrastCache=new xx,this._onChangeColors=this._register(new He),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Sl,background:_d,cursor:Cx,cursorAccent:kx,selectionForeground:void 0,selectionBackgroundTransparent:cd,selectionBackgroundOpaque:vn.blend(_d,cd),selectionInactiveBackgroundTransparent:cd,selectionInactiveBackgroundOpaque:vn.blend(_d,cd),scrollbarSliderBackground:vn.opacity(Sl,.2),scrollbarSliderHoverBackground:vn.opacity(Sl,.4),scrollbarSliderActiveBackground:vn.opacity(Sl,.5),overviewRulerBorder:Sl,ansi:ui.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=dn(e.foreground,Sl),t.background=dn(e.background,_d),t.cursor=vn.blend(t.background,dn(e.cursor,Cx)),t.cursorAccent=vn.blend(t.background,dn(e.cursorAccent,kx)),t.selectionBackgroundTransparent=dn(e.selectionBackground,cd),t.selectionBackgroundOpaque=vn.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=dn(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vn.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?dn(e.selectionForeground,_x):void 0,t.selectionForeground===_x&&(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=dn(e.scrollbarSliderBackground,vn.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=dn(e.scrollbarSliderHoverBackground,vn.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=dn(e.scrollbarSliderActiveBackground,vn.opacity(t.foreground,.5)),t.overviewRulerBorder=dn(e.overviewRulerBorder,FO),t.ansi=ui.slice(),t.ansi[0]=dn(e.black,ui[0]),t.ansi[1]=dn(e.red,ui[1]),t.ansi[2]=dn(e.green,ui[2]),t.ansi[3]=dn(e.yellow,ui[3]),t.ansi[4]=dn(e.blue,ui[4]),t.ansi[5]=dn(e.magenta,ui[5]),t.ansi[6]=dn(e.cyan,ui[6]),t.ansi[7]=dn(e.white,ui[7]),t.ansi[8]=dn(e.brightBlack,ui[8]),t.ansi[9]=dn(e.brightRed,ui[9]),t.ansi[10]=dn(e.brightGreen,ui[10]),t.ansi[11]=dn(e.brightYellow,ui[11]),t.ansi[12]=dn(e.brightBlue,ui[12]),t.ansi[13]=dn(e.brightMagenta,ui[13]),t.ansi[14]=dn(e.brightCyan,ui[14]),t.ansi[15]=dn(e.brightWhite,ui[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]=dn(e.extendedAnsi[s],ui[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()}}};X_=Un([Ye(0,Gi)],X_);function dn(e,t){if(e!==void 0)try{return Ln.toColor(e)}catch{}return t}var WO=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)}},KO=class{constructor(){this._services=new WO,this._services.set(Ny,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Pj(e).sort((l,d)=>l.index-d.index),s=[];for(let l of n){let d=this._services.get(l.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(d)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},qO={trace:0,debug:1,info:2,warn:3,error:4,off:5},VO="xterm.js: ",Z_=class extends Tt{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=qO[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?"":VO)+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)}};Z_=Un([Ye(0,Gi)],Z_);var Tx=class extends Tt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new He),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new He),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new He),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}},kt=3,ni=Object.freeze(new hh),Ef=0,fv=2,bd=class xE{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*kt);let o=n||Zr.fromCharData([0,$T,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*kt+0],s=n&2097151;return[this._data[t*kt+1],n&2097152?this._combined[t]:s?So(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*kt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*kt+0]=t|2097152|n[2]<<22):this._data[t*kt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*kt+0]>>22}hasWidth(t){return this._data[t*kt+0]&12582912}getFg(t){return this._data[t*kt+1]}getBg(t){return this._data[t*kt+2]}hasContent(t){return this._data[t*kt+0]&4194303}getCodePoint(t){let n=this._data[t*kt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*kt+0]&2097152}getString(t){let n=this._data[t*kt+0];return n&2097152?this._combined[t]:n&2097151?So(n&2097151):""}isProtected(t){return this._data[t*kt+2]&536870912}loadCell(t,n){return Ef=t*kt,n.content=this._data[Ef+0],n.fg=this._data[Ef+1],n.bg=this._data[Ef+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*kt+0]=n.content,this._data[t*kt+1]=n.fg,this._data[t*kt+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*kt+0]=n|s<<22,this._data[t*kt+1]=o.fg,this._data[t*kt+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*kt+0];o&2097152?this._combined[t]+=So(n):o&2097151?(this._combined[t]=So(o&2097151)+So(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*kt+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 Zr;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 Zr;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*fv<this._data.buffer.byteLength;let s=t*kt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let d=0;d<o.length;d++){let f=parseInt(o[d],10);f>=t&&delete this._combined[f]}let l=Object.keys(this._extendedAttrs);for(let d=0;d<l.length;d++){let f=parseInt(l[d],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,s*4*fv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*fv<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 xE(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*kt+0]&4194303)return t+(this._data[t*kt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*kt+0]&4194303||this._data[t*kt+2]&50331648)return t+(this._data[t*kt+0]>>22);return 0}copyCellsFrom(t,n,s,o,l){let d=t._data;if(l)for(let m=o-1;m>=0;m--){for(let p=0;p<kt;p++)this._data[(s+m)*kt+p]=d[(n+m)*kt+p];d[(n+m)*kt+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[n+m])}else for(let m=0;m<o;m++){for(let p=0;p<kt;p++)this._data[(s+m)*kt+p]=d[(n+m)*kt+p];d[(n+m)*kt+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[n+m])}let f=Object.keys(t._combined);for(let m=0;m<f.length;m++){let p=parseInt(f[m],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 d=this._data[n*kt+0],f=d&2097151,m=d&2097152?this._combined[n]:f?So(f):Co;if(l+=m,o)for(let p=0;p<m.length;++p)o.push(n);n+=d>>22||1}return o&&o.push(n),l}};function YO(e,t,n,s,o,l){let d=[];for(let f=0;f<e.length-1;f++){let m=f,p=e.get(++m);if(!p.isWrapped)continue;let b=[e.get(f)];for(;m<e.length&&p.isWrapped;)b.push(p),p=e.get(++m);if(!l&&s>=f&&s<m){f+=b.length-1;continue}let _=0,S=Vd(b,_,t),w=1,x=0;for(;w<b.length;){let L=Vd(b,w,t),A=L-x,W=n-S,z=Math.min(A,W);b[_].copyCellsFrom(b[w],x,S,z,!1),S+=z,S===n&&(_++,S=0),x+=z,x===L&&(w++,x=0),S===0&&_!==0&&b[_-1].getWidth(n-1)===2&&(b[_].copyCellsFrom(b[_-1],n-1,S++,1,!1),b[_-1].setCell(n-1,o))}b[_].replaceCells(S,n,o);let R=0;for(let L=b.length-1;L>0&&(L>_||b[L].getTrimmedLength()===0);L--)R++;R>0&&(d.push(f+b.length-R),d.push(R)),f+=b.length-1}return d}function GO(e,t){let n=[],s=0,o=t[s],l=0;for(let d=0;d<e.length;d++)if(o===d){let f=t[++s];e.onDeleteEmitter.fire({index:d-l,amount:f}),d+=f-1,l+=f,o=t[++s]}else n.push(d);return{layout:n,countRemoved:l}}function XO(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 ZO(e,t,n){let s=[],o=e.map((m,p)=>Vd(e,p,t)).reduce((m,p)=>m+p),l=0,d=0,f=0;for(;f<o;){if(o-f<n){s.push(o-f);break}l+=n;let m=Vd(e,d,t);l>m&&(l-=m,d++);let p=e[d].getWidth(l-1)===2;p&&l--;let b=p?n-1:n;s.push(b),f+=b}return s}function Vd(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 CE=class kE{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=kE._nextId++,this._onDispose=this.register(new He),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ol(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};CE._nextId=1;var QO=CE,pi={},wl=pi.B;pi[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};pi.A={"#":"£"};pi.B=void 0;pi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};pi.C=pi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};pi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};pi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};pi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};pi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};pi.E=pi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};pi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};pi.H=pi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};pi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ex=4294967295,Rx=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=ni.clone(),this.savedCharset=wl,this.markers=[],this._nullCell=Zr.fromCharData([0,$T,1,0]),this._whitespaceCell=Zr.fromCharData([0,Co,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new bp,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Tx(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 mp),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 mp),this._whitespaceCell}getBlankLine(e,t){return new bd(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>Ex?Ex:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ni);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 Tx(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(ni),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)s+=+this.lines.get(d).resize(e,n);let l=0;if(this._rows<t)for(let d=this._rows;d<t;d++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new bd(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 bd(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let d=this.lines.length-o;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let l=0;l<this.lines.length;l++)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=YO(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ni),n);if(s.length>0){let o=GO(this.lines,s);XO(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(ni),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new bd(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(ni),o=[],l=0;for(let d=this.lines.length-1;d>=0;d--){let f=this.lines.get(d);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let m=[f];for(;f.isWrapped&&d>0;)f=this.lines.get(--d),m.unshift(f);if(!n){let z=this.ybase+this.y;if(z>=d&&z<d+m.length)continue}let p=m[m.length-1].getTrimmedLength(),b=ZO(m,this._cols,e),_=b.length-m.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+_):S=Math.max(0,this.lines.length-this.lines.maxLength+_);let w=[];for(let z=0;z<_;z++){let H=this.getBlankLine(ni,!0);w.push(H)}w.length>0&&(o.push({start:d+m.length+l,newLines:w}),l+=w.length),m.push(...w);let x=b.length-1,R=b[x];R===0&&(x--,R=b[x]);let L=m.length-_-1,A=p;for(;L>=0;){let z=Math.min(A,R);if(m[x]===void 0)break;if(m[x].copyCellsFrom(m[L],A-z,R-z,z,!0),R-=z,R===0&&(x--,R=b[x]),A-=z,A===0){L--;let H=Math.max(L,0);A=Vd(m,H,this._cols)}}for(let z=0;z<m.length;z++)b[z]<e&&m[z].setCell(b[z],s);let W=_-S;for(;W-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}if(o.length>0){let d=[],f=[];for(let R=0;R<this.lines.length;R++)f.push(this.lines.get(R));let m=this.lines.length,p=m-1,b=0,_=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let S=0;for(let R=Math.min(this.lines.maxLength-1,m+l-1);R>=0;R--)if(_&&_.start>p+S){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(R--,_.newLines[L]);R++,d.push({index:p+1,amount:_.newLines.length}),S+=_.newLines.length,_=o[++b]}else this.lines.set(R,f[p--]);let w=0;for(let R=d.length-1;R>=0;R--)d[R].index+=w,this.lines.onInsertEmitter.fire(d[R]),w+=d[R].amount;let x=Math.max(0,m+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 QO(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)}},JO=class extends Tt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new He),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 Rx(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Rx(!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)}},TE=2,EE=1,Q_=class extends Tt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new He),this.onResize=this._onResize.event,this._onScroll=this._register(new He),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,TE),this.rows=Math.max(e.rawOptions.rows||0,EE),this.buffers=this._register(new JO(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 d=n.lines.isFull;l===n.lines.length-1?d?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=l-o+1;n.lines.shiftElements(o+1,d-1,-1),n.lines.set(l,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))}};Q_=Un([Ye(0,Gi)],Q_);var Dc={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:_p,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},eB=["normal","bold","100","200","300","400","500","600","700","800","900"],tB=class extends Tt{constructor(e){super(),this._onOptionChange=this._register(new He),this.onOptionChange=this._onOptionChange.event;let t={...Dc};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(Rn(()=>{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 Dc))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Dc))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=Dc[e]),!nB(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Dc[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=eB.includes(t)?t:Dc[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 nB(e){return e==="block"||e==="underline"||e==="bar"}function yd(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]&&yd(e[s],t-1);return n}var Nx=Object.freeze({insertMode:!1}),Dx=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),J_=class extends Tt{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 He),this.onData=this._onData.event,this._onUserInput=this._register(new He),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new He),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new He),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=yd(Nx),this.decPrivateModes=yd(Dx)}reset(){this.modes=yd(Nx),this.decPrivateModes=yd(Dx)}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))}};J_=Un([Ye(0,Yi),Ye(1,VT),Ye(2,Gi)],J_);var Mx={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 pv(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 mv=String.fromCharCode,Ax={DEFAULT:e=>{let t=[pv(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${mv(t[0])}${mv(t[1])}${mv(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${pv(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${pv(e,!0)};${e.x};${e.y}${t}`}},eb=class extends Tt{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 He),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Mx))this.addProtocol(s,Mx[s]);for(let s of Object.keys(Ax))this.addEncoding(s,Ax[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)}};eb=Un([Ye(0,Yi),Ye(1,Pl),Ye(2,Gi)],eb);var gv=[[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]],iB=[[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]],di;function rB(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 sB=class{constructor(){if(this.version="6",!di){di=new Uint8Array(65536),di.fill(1),di[0]=0,di.fill(0,1,32),di.fill(0,127,160),di.fill(2,4352,4448),di[9001]=2,di[9002]=2,di.fill(2,11904,42192),di[12351]=1,di.fill(2,44032,55204),di.fill(2,63744,64256),di.fill(2,65040,65050),di.fill(2,65072,65136),di.fill(2,65280,65377),di.fill(2,65504,65511);for(let e=0;e<gv.length;++e)di.fill(0,gv[e][0],gv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?di[e]:rB(e,iB)?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=kl.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return kl.createPropertyValue(0,n,s)}},kl=class Wf{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new He,this.onChange=this._onChange.event;let t=new sB;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 d=t.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=o)return n+this.wcwidth(d);let p=t.charCodeAt(l);56320<=p&&p<=57343?d=(d-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let f=this.charProperties(d,s),m=Wf.extractWidth(f);Wf.extractShouldJoin(f)&&(m-=Wf.extractWidth(s)),n+=m,s=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},aB=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 Lx(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 ud=2147483647,oB=256,RE=class tb{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>oB)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 tb;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 tb(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>ud?ud: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>ud?ud: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,ud):t}},dd=[],lB=class{constructor(){this._state=0,this._active=dd,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=dd}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=dd,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||dd,!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",Qp(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=dd,this._id=-1,this._state=0}}},kr=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+=Qp(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}},hd=[],cB=class{constructor(){this._handlers=Object.create(null),this._active=hd,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=hd}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=hd,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||hd,!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",Qp(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=hd,this._ident=0}},Sd=new RE;Sd.addParam(0);var jx=class{constructor(e){this._handler=e,this._data="",this._params=Sd,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Sd,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Qp(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=Sd,this._data="",this._hitLimit=!1,n));return this._params=Sd,this._data="",this._hitLimit=!1,t}},uB=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}},Gr=160,dB=(function(){let e=new uB(4095),t=Array.apply(null,Array(256)).map((f,m)=>m),n=(f,m)=>t.slice(f,m),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),d;e.setDefault(1,0),e.addMany(s,0,2,0);for(d in l)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(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(Gr,0,2,0),e.add(Gr,8,5,8),e.add(Gr,6,0,6),e.add(Gr,11,0,11),e.add(Gr,13,13,13),e})(),hB=class extends Tt{constructor(e=dB){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 RE,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(Rn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new lB),this._dcsParser=this._register(new cB),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,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&m>-1){for(;m>=0&&(d=f[m](this._params),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&m>-1){for(;m>=0&&(d=f[m](),d!==!0);m--)if(d instanceof Promise)return this._parseStack.handlerPos=m,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],d=this._oscParser.end(s!==24&&s!==26,n),d)return d;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,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:Gr)],o>>4){case 2:for(let S=f+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Gr){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gr){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gr){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gr){this._printHandler(e,f,S),f=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(d=m[p](this._params),d!==!0);p--)if(d instanceof Promise)return this._preserveStack(3,m,p,o,f),d;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&&(d=b[_](),d!==!0);_--)if(d instanceof Promise)return this._preserveStack(4,b,_,o,f),d;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let S=f+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Gr){this._dcsParser.put(e,f,S),f=S-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,o,f),d;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let S=f+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Gr){this._oscParser.put(e,f,S),f=S-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,o,f),d;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},fB=/^([\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})$/,pB=/^[\da-f]+$/;function Ox(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=fB.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),pB.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 vv(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 mB(e,t=16){let[n,s,o]=e;return`rgb:${vv(n,t)}/${vv(s,t)}/${vv(o,t)}`}var gB={"(":0,")":1,"*":2,"+":3,"-":1,".":2},go=131072,Bx=10;function Ix(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 Px=5e3,zx=0,vB=class extends Tt{constructor(e,t,n,s,o,l,d,f,m=new hB){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=d,this._unicodeService=f,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Bj,this._utf8Decoder=new Ij,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ni.clone(),this._eraseAttrDataInternal=ni.clone(),this._onRequestBell=this._register(new He),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new He),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new He),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new He),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new He),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new He),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new He),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new He),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new He),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new He),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new He),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new He),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new He),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 nb(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:b.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,b,_)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:b,data:_})}),this._parser.setDcsHandlerFallback((p,b,_)=>{b==="HOOK"&&(_=_.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:b,payload:_})}),this._parser.setPrintHandler((p,b,_)=>this.print(p,b,_)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(Ne.BEL,()=>this.bell()),this._parser.setExecuteHandler(Ne.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ne.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Ne.BS,()=>this.backspace()),this._parser.setExecuteHandler(Ne.HT,()=>this.tab()),this._parser.setExecuteHandler(Ne.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Ne.SI,()=>this.shiftIn()),this._parser.setExecuteHandler($f.IND,()=>this.index()),this._parser.setExecuteHandler($f.NEL,()=>this.nextLine()),this._parser.setExecuteHandler($f.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new kr(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new kr(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new kr(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new kr(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new kr(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new kr(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new kr(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new kr(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new kr(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new kr(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new kr(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new kr(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in pi)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new jx((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"),Px))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Px} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>go&&(l=this._parseStack.position+go)}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<go&&(this._parseBuffer=new Uint32Array(Math.min(e.length,go))),d||this._dirtyRowTracker.clearRange(),e.length>go)for(let p=l;p<e.length;p+=go){let b=p+go<e.length?p+go: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(!d){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(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),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(f,this._bufferService.rows-1)})}print(e,t,n){let s,o,l=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,m=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 S=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(s=e[w],s<127&&l){let A=l[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let x=this._unicodeService.charProperties(s,S);o=kl.extractWidth(x);let R=kl.extractShouldJoin(x),L=R?kl.extractWidth(S):0;if(S=x,d&&this._onA11yChar.fire(So(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-L>f){if(m){let A=_,W=this._activeBuffer.x-L;for(this._activeBuffer.x=L,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),L>0&&_ instanceof bd&&_.copyCellsFrom(A,W,0,L,!1);W<f;)A.setCellFromCodepoint(W++,0,1,b)}else if(this._activeBuffer.x=f-1,o===2)continue}if(R&&this._activeBuffer.x){let A=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-A,s,o);for(let W=o-L;--W>=0;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(p&&(_.insertCells(this._activeBuffer.x,o-L,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=S,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=>Ix(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new jx(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new kr(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(ni));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=kl.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),d=new Uint32Array(l.length*n),f=0;for(let p=0;p<l.length;){let b=l.codePointAt(p)||0;d[f++]=b,p+=b>65535?2:1}let m=f;for(let p=1;p<n;++p)d.copyWithin(m,0,f),m+=f;return this.print(d,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Ne.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Ne.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Ne.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Ne.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Ne.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,wl),this._charsetService.setgCharset(1,wl),this._charsetService.setgCharset(2,wl),this._charsetService.setgCharset(3,wl);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(R=>(R[R.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",R[R.SET=1]="SET",R[R.RESET=2]="RESET",R[R.PERMANENTLY_SET=3]="PERMANENTLY_SET",R[R.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,d=this._coreService,{buffers:f,cols:m}=this._bufferService,{active:p,alt:b}=f,_=this._optionsService.rawOptions,S=(R,L)=>(d.triggerDataEvent(`${Ne.ESC}[${t?"":"?"}${R};${L}$y`),!0),w=R=>R?1:2,x=e.params[0];return t?x===2?S(x,4):x===4?S(x,w(d.modes.insertMode)):x===12?S(x,3):x===20?S(x,w(_.convertEol)):S(x,0):x===1?S(x,w(s.applicationCursorKeys)):x===3?S(x,_.windowOptions.setWinLines?m===80?2:m===132?1:0:0):x===6?S(x,w(s.origin)):x===7?S(x,w(s.wraparound)):x===8?S(x,3):x===9?S(x,w(o==="X10")):x===12?S(x,w(_.cursorBlink)):x===25?S(x,w(!d.isCursorHidden)):x===45?S(x,w(s.reverseWraparound)):x===66?S(x,w(s.applicationKeypad)):x===67?S(x,4):x===1e3?S(x,w(o==="VT200")):x===1002?S(x,w(o==="DRAG")):x===1003?S(x,w(o==="ANY")):x===1004?S(x,w(s.sendFocus)):x===1005?S(x,4):x===1006?S(x,w(l==="SGR")):x===1015?S(x,4):x===1016?S(x,w(l==="SGR_PIXELS")):x===1048?S(x,1):x===47||x===1047||x===1049?S(x,w(p===b)):x===2004?S(x,w(s.bracketedPasteMode)):x===2026?S(x,w(s.synchronizedOutput)):S(x,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=hh.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 d=e.getSubParams(t+l),f=0;do s[1]===5&&(o=1),s[l+f+1+o]=d[f];while(++f<d.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 d=2;d<s.length;++d)s[d]===-1&&(s[d]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return 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=ni.fg,e.bg=ni.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|=ni.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=ni.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|=ni.fg&16777215,s.bg&=-67108864,s.bg|=ni.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Ne.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ne.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ne.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ni.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(!Ix(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Ne.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Bx&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Bx&&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(Hx(l))if(o==="?")t.push({type:0,index:l});else{let d=Ox(o);d&&t.push({type:1,index:l,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),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=Ox(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]);Hx(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,wl),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(gB[e[0]],pi[e[1]]||wl),!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=ni.clone(),this._eraseAttrDataInternal=ni.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 Zr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${Ne.ESC}${d}${Ne.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)}},nb=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&&(zx=e,e=t,t=zx),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};nb=Un([Ye(0,Yi)],nb);function Hx(e){return 0<=e&&e<256}var _B=5e7,Ux=12,bB=50,yB=class extends Tt{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 He),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>_B)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let d=f=>performance.now()-n>=Ux?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(d);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Ux)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>bB&&(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()}},ib=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),m={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(m,f)),this._dataByLinkId.set(m.id,m),m.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),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(d,l)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(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)))}};ib=Un([Ye(0,Yi)],ib);var $x=!1,SB=class extends Tt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Qc),this._onBinary=this._register(new He),this.onBinary=this._onBinary.event,this._onData=this._register(new He),this.onData=this._onData.event,this._onLineFeed=this._register(new He),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new He),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new He),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new He),this._instantiationService=new KO,this.optionsService=this._register(new tB(e)),this._instantiationService.setService(Gi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Q_)),this._instantiationService.setService(Yi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Z_)),this._instantiationService.setService(VT,this._logService),this.coreService=this._register(this._instantiationService.createInstance(J_)),this._instantiationService.setService(Pl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eb)),this._instantiationService.setService(qT,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(kl)),this._instantiationService.setService(Uj,this.unicodeService),this._charsetService=this._instantiationService.createInstance(aB),this._instantiationService.setService(Hj,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ib),this._instantiationService.setService(YT,this._oscLinkService),this._inputHandler=this._register(new vB(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ni.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ni.forward(this._bufferService.onResize,this._onResize)),this._register(Ni.forward(this.coreService.onData,this._onData)),this._register(Ni.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 yB((t,n)=>this._inputHandler.parse(t,n))),this._register(Ni.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new He),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&&!$x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),$x=!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,TE),t=Math.max(t,EE),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(Lx.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Lx(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Rn(()=>{for(let t of e)t.dispose()})}}},wB={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 xB(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=Ne.ESC+"OA":o.key=Ne.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=Ne.ESC+"OD":o.key=Ne.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=Ne.ESC+"OC":o.key=Ne.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=Ne.ESC+"OB":o.key=Ne.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":Ne.DEL,e.altKey&&(o.key=Ne.ESC+o.key);break;case 9:if(e.shiftKey){o.key=Ne.ESC+"[Z";break}o.key=Ne.HT,o.cancel=!0;break;case 13:o.key=e.altKey?Ne.ESC+Ne.CR:Ne.CR,o.cancel=!0;break;case 27:o.key=Ne.ESC,e.altKey&&(o.key=Ne.ESC+Ne.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"D":t?o.key=Ne.ESC+"OD":o.key=Ne.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"C":t?o.key=Ne.ESC+"OC":o.key=Ne.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"A":t?o.key=Ne.ESC+"OA":o.key=Ne.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=Ne.ESC+"[1;"+(l+1)+"B":t?o.key=Ne.ESC+"OB":o.key=Ne.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=Ne.ESC+"[2~");break;case 46:l?o.key=Ne.ESC+"[3;"+(l+1)+"~":o.key=Ne.ESC+"[3~";break;case 36:l?o.key=Ne.ESC+"[1;"+(l+1)+"H":t?o.key=Ne.ESC+"OH":o.key=Ne.ESC+"[H";break;case 35:l?o.key=Ne.ESC+"[1;"+(l+1)+"F":t?o.key=Ne.ESC+"OF":o.key=Ne.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=Ne.ESC+"[5;"+(l+1)+"~":o.key=Ne.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=Ne.ESC+"[6;"+(l+1)+"~":o.key=Ne.ESC+"[6~";break;case 112:l?o.key=Ne.ESC+"[1;"+(l+1)+"P":o.key=Ne.ESC+"OP";break;case 113:l?o.key=Ne.ESC+"[1;"+(l+1)+"Q":o.key=Ne.ESC+"OQ";break;case 114:l?o.key=Ne.ESC+"[1;"+(l+1)+"R":o.key=Ne.ESC+"OR";break;case 115:l?o.key=Ne.ESC+"[1;"+(l+1)+"S":o.key=Ne.ESC+"OS";break;case 116:l?o.key=Ne.ESC+"[15;"+(l+1)+"~":o.key=Ne.ESC+"[15~";break;case 117:l?o.key=Ne.ESC+"[17;"+(l+1)+"~":o.key=Ne.ESC+"[17~";break;case 118:l?o.key=Ne.ESC+"[18;"+(l+1)+"~":o.key=Ne.ESC+"[18~";break;case 119:l?o.key=Ne.ESC+"[19;"+(l+1)+"~":o.key=Ne.ESC+"[19~";break;case 120:l?o.key=Ne.ESC+"[20;"+(l+1)+"~":o.key=Ne.ESC+"[20~";break;case 121:l?o.key=Ne.ESC+"[21;"+(l+1)+"~":o.key=Ne.ESC+"[21~";break;case 122:l?o.key=Ne.ESC+"[23;"+(l+1)+"~":o.key=Ne.ESC+"[23~";break;case 123:l?o.key=Ne.ESC+"[24;"+(l+1)+"~":o.key=Ne.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=Ne.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=Ne.DEL:e.keyCode===219?o.key=Ne.ESC:e.keyCode===220?o.key=Ne.FS:e.keyCode===221&&(o.key=Ne.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=wB[e.keyCode]?.[e.shiftKey?1:0];if(d)o.key=Ne.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(f);e.shiftKey&&(m=m.toUpperCase()),o.key=Ne.ESC+m}else if(e.keyCode===32)o.key=Ne.ESC+(e.ctrlKey?Ne.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=Ne.ESC+f,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=Ne.US),e.key==="@"&&(o.key=Ne.NUL));break}return o}var qn=0,CB=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new bp,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new bp,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||(qn=this._search(t),qn===-1)||this._getKey(this._array[qn])!==t)return!1;do if(this._array[qn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(qn),!0;while(++qn<this._array.length&&this._getKey(this._array[qn])===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&&(qn=this._search(e),!(qn<0||qn>=this._array.length)&&this._getKey(this._array[qn])===e))do yield this._array[qn];while(++qn<this._array.length&&this._getKey(this._array[qn])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(qn=this._search(e),!(qn<0||qn>=this._array.length)&&this._getKey(this._array[qn])===e))do t(this._array[qn]);while(++qn<this._array.length&&this._getKey(this._array[qn])===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}},_v=0,Fx=0,kB=class extends Tt{constructor(){super(),this._decorations=new CB(e=>e?.marker.line),this._onDecorationRegistered=this._register(new He),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new He),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Rn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new TB(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=>{_v=o.options.x??0,Fx=_v+(o.options.width??1),e>=_v&&e<Fx&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},TB=class extends To{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new He),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new He),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=Ln.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ln.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},EB=1e3,RB=class{constructor(e,t=EB){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)}},Wx=20,yp=class extends Tt{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 RB(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(`
|
|
29
|
-
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(vt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Rn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Wx+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Wx+1&&(this._liveRegion.textContent+=x_.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),d=[],f=l?.translateToString(!0,void 0,void 0,d)||"",m=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,d)),p.setAttribute("aria-posinset",m),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 d,f;if(t===0?(d=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(d=this._rowElements.shift(),f=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}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:m})=>{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 S=m<_.length?_[m]:_.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},l=o(t),d=o(n);if(!(!l||!d)){if(l.row>d.row||l.row===d.row&&l.column>=d.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(d.row-l.row)*this._terminal.cols-l.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};yp=Un([Ye(1,Ny),Ye(2,Da),Ye(3,Ma)],yp);var rb=class extends Tt{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 He),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new He),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Rn(()=>{Ol(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(vt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(vt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(vt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(vt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let 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 d=l?.map(f=>({link:f}));this._activeProviderReplies?.set(s,d),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let d=o[l],f=d.link.range.start.y<e?0:d.link.range.start.x,m=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let p=f;p<=m;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(d=>this._linkAtPosition(d.link,t));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=this._activeProviderReplies.get(l)?.find(f=>this._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&NB(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,Ol(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}}};rb=Un([Ye(1,Dy),Ye(2,Ma),Ye(3,Yi),Ye(4,XT)],rb);function NB(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 DB=class extends SB{constructor(e={}){super(e),this._linkifier=this._register(new Qc),this.browser=mE,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Qc),this._onCursorMove=this._register(new He),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new He),this.onKey=this._onKey.event,this._onRender=this._register(new He),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new He),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new He),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new He),this.onBell=this._onBell.event,this._onFocus=this._register(new He),this._onBlur=this._register(new He),this._onA11yCharEmitter=this._register(new He),this._onA11yTabEmitter=this._register(new He),this._onWillOpen=this._register(new He),this._setup(),this._decorationService=this._instantiationService.createInstance(kB),this._instantiationService.setService(fh,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(bO),this._instantiationService.setService(XT,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(k_)),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(Ni.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ni.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ni.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ni.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Rn(()=>{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(`${Ne.ESC}]${s};${mB(o)}${fE.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=ii.toColor(...t.color));else{let l=n;this._themeService.modifyColors(d=>d[l]=ii.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(yp,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ne.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ne.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=d+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(vt(this.element,"copy",t=>{this.hasSelection()&&jj(t,this._selectionService)}));let e=t=>Oj(t,this.textarea,this.coreService,this.optionsService);this._register(vt(this.textarea,"paste",e)),this._register(vt(this.element,"paste",e)),gE?this._register(vt(this.element,"mousedown",t=>{t.button===2&&ex(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(vt(this.element,"contextmenu",t=>{ex(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Py&&this._register(vt(this.element,"auxclick",t=>{t.button===1&&UT(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(vt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(vt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(vt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(vt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(vt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(vt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(vt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(vt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",w_.get()),bE||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(vO,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Da,this._coreBrowserService),this._register(vt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(vt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(q_,this._document,this._helperContainer),this._instantiationService.setService(Jp,this._charSizeService),this._themeService=this._instantiationService.createInstance(X_),this._instantiationService.setService(su,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(vp),this._instantiationService.setService(GT,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Y_,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(F_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(V_),this._instantiationService.setService(Dy,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(rb,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(U_,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(G_,this.element,this.screenElement,s)),this._instantiationService.setService(Fj,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(Ni.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance($_,this.screenElement)),this._register(vt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(yp,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gp,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gp,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(K_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){let d=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!d)return!1;let f,m;switch(l.overrideType||l.type){case"mousemove":m=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":m=0,f=l.button<3?l.button:3;break;case"mousedown":m=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;m=p<0?0:1,f=4;break;default:return!1}return m===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:f,action:m,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(vt(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(vt(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 d=Ne.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){HT(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=xB(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===Ne.ETX||n.key===Ne.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(MB(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(ni));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(Ne.ESC+"[I"):this.coreService.triggerDataEvent(Ne.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Ne.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function MB(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var AB=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)}},LB=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 Zr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Kx=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 LB(t)}getNullCell(){return new Zr}},jB=class extends Tt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new He),this.onBufferChange=this._onBufferChange.event,this._normal=new Kx(this._core.buffers.normal,"normal"),this._alternate=new Kx(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)}},OB=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)}},BB=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}},IB=["cols","rows"],Ts=0,PB=class extends Tt{constructor(e){super(),this._core=this._register(new DB(e)),this._addonManager=this._register(new AB),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(IB.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 OB(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new BB(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 jB(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
31
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return w_.get()},set promptLabel(e){w_.set(e)},get tooMuchOutput(){return x_.get()},set tooMuchOutput(e){x_.set(e)}}}_verifyIntegers(...e){for(Ts of e)if(Ts===1/0||isNaN(Ts)||Ts%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ts of e)if(Ts&&(Ts===1/0||isNaN(Ts)||Ts%1!==0||Ts<0))throw new Error("This API only accepts positive integers")}};function nm(e){return e.normalize("NFC").trim().toLowerCase()}function zB(e){const t=nm(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 HB=zt.lazy(()=>Ry(()=>import("./TranscriptMarkdownBody-D_cxr-gq.js"),__vite__mapDeps([2,1])));function NE({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:o,fontSize:l}){const d=v.useRef(new Map),f=v.useMemo(()=>{const p=new Map,b=new Array(e.length);for(let _=e.length-1;_>=0;_--){const S=e[_],w=`${S.kind}\0${S.header??""}\0${S.body}`;let x=2166136261,R=5381;for(let W=0;W<w.length;W++)x=Math.imul(x^w.charCodeAt(W),16777619),R=Math.imul(R,33)^w.charCodeAt(W);const L=`${w.length}:${x>>>0}:${R>>>0}`,A=p.get(L)??0;p.set(L,A+1),b[_]=`${L}:${A}`}return b},[e]);v.useEffect(()=>{if(n===null)return;const p=d.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 m=-1;return u.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:l},children:e.map((p,b)=>{const _=p.kind==="user"?++m:null,S=n===b?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return u.jsxs("section",{ref:w=>{w?d.current.set(b,w):d.current.delete(b)},className:`transcript-entry transcript-entry-${p.kind}${S}`,"data-transcript-kind":p.kind,"data-transcript-entry-key":f[b],"data-transcript-entry-index":b,..._!==null?{"data-transcript-prompt-position":_}:{},children:[p.header?u.jsx("div",{className:"transcript-entry-header",children:DE(p.header,t)}):null,p.body?u.jsx("div",{className:"transcript-entry-body",children:p.kind==="tool"?u.jsx(qx,{text:p.body,searchQuery:t}):u.jsx(zt.Suspense,{fallback:u.jsx(qx,{text:p.body,searchQuery:t}),children:u.jsx(HB,{text:p.body,searchQuery:t})})}):null]},f[b])})})}function qx({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
32
|
-
`)?e.slice(0,-1).split(`
|
|
33
|
-
`):e.split(`
|
|
34
|
-
`);return u.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,o)=>u.jsx("span",{className:`transcript-line transcript-line-${KB(s,o===0||n[o-1]?.trim()==="")}`,children:DE(s,t)},o))})}function DE(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),o=n.toLowerCase(),l=[];let d=0,f=s.indexOf(o);for(;f!==-1;){f>d&&l.push(e.slice(d,f));const m=f+n.length;l.push(u.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,m)},`${f}-${m}`)),d=m,f=s.indexOf(o,d)}return d<e.length&&l.push(e.slice(d)),l.length>0?l:e||" "}function UB(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 sb(e){const t=e.endsWith(`
|
|
35
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,o="plain",l=[];function d(){const f=$B(l).join(`
|
|
36
|
-
`);(s||f)&&n.push({header:s,body:f,kind:o}),s=null,o="plain",l=[]}for(const f of t.split(`
|
|
37
|
-
`)){const m=FB(f);m?(d(),s=f,o=m):l.push(f)}return d(),n}function $B(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function FB(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 WB(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}
|
|
38
|
-
${o.body}`:o.body,d=UB(l,t);for(let f=0;f<d;f+=1)n.push({entryIndex:s,matchIndexInEntry:f})}return n}function KB(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)||AE(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 Eo(e){return e==="codex"?"Codex":"Claude"}function jc(e,t,n={}){const s=`[nterminal] ${Eo(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
-
`).replace(/\r/g,`
|
|
40
|
-
`).replace(s,"").replace(/\n{3,}/g,`
|
|
41
|
-
|
|
42
|
-
`).trimEnd(),l=zy(o),d=n.includeTools?l:ME(l);return d?`${d}
|
|
43
|
-
`:""}function zy(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=qB(n);return s?`[${s}]`:t})}function qB(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=fd(t.getMonth()+1),o=fd(t.getDate()),l=fd(t.getHours()),d=fd(t.getMinutes()),f=fd(t.getSeconds());return`${n}-${s}-${o} ${l}:${d}:${f}`}function fd(e){return e.toString().padStart(2,"0")}function Sp(e,t){return e.map(n=>t?n:ME(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
44
|
-
`)?n:`${n}
|
|
45
|
-
`).join("")}function ME(e){if(!e)return"";const t=e.split(`
|
|
46
|
-
`),n=[];let s=!1,o=!1,l=!0;for(const d of t){const f=d.trim()==="",m=l?VB(d):null;if(m&&(s=m==="tool",o=!1),AE(d)){o=!0,l=!1;continue}if(o){f?(o=!1,s||n.push(d),l=!0):l=!1;continue}s||n.push(d),l=f}return n.join(`
|
|
47
|
-
`).replace(/\n{3,}/g,`
|
|
48
|
-
|
|
49
|
-
`).trimEnd()}function VB(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function AE(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Ca(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Vx(e,t){return e===null?t===null:t!==null&&Ca(e,t)}const YB=5e3,GB=200,XB=1200,ZB=4,QB=zt.memo(function({terminalId:t,serverApi:n,source:s,fontSize:o,onClose:l}){const d=v.useRef(null),f=v.useRef(0),m=v.useRef(!1),p=v.useRef(!1),b=v.useRef(null),_=v.useRef(!1),[S,w]=v.useState(null),[x,R]=v.useState(null),[L,A]=v.useState(null),[W,z]=v.useState(()=>new Set),[H,q]=v.useState(!1),[Y,I]=v.useState(!1),[$,de]=v.useState([]),[me,K]=v.useState(null),[ne,ee]=v.useState(!1),[Z,X]=v.useState(!1),[M,T]=v.useState(!1),[O,re]=v.useState(null),he=S?.find(j=>j.id===L)??null;v.useEffect(()=>{function j(ge){ge.key==="Escape"&&(ge.preventDefault(),ge.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(R(null),w(ge=>ge&&i5(ge,j.subagents)?ge:j.subagents),!_.current){const ge=j.subagents.find(Me=>Me.hasTranscript);ge&&(_.current=!0,A(Me=>Me??ge.id))}}catch(j){R(j instanceof Error?j.message:"Failed to load subagents."),w(ge=>ge??[])}},[n,t]);v.useEffect(()=>{N();const j=window.setInterval(()=>{document.hidden||N()},YB);function ge(){document.hidden||N()}return document.addEventListener("visibilitychange",ge),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",ge)}},[N]),v.useEffect(()=>{f.current+=1;const j=f.current;return m.current=!1,p.current=!0,b.current=null,de([]),K(null),ee(!1),re(null),L&&V(null,"initial",j),()=>{f.current===j&&(f.current+=1)}},[n,t,L,Y]),v.useLayoutEffect(()=>{const j=d.current;if(!j)return;if(p.current){if(Z||$.length===0)return;p.current=!1;const Me=()=>{j.scrollTop=j.scrollHeight};Me(),window.requestAnimationFrame?.(Me);return}const ge=b.current;ge!==null&&(b.current=null,j.scrollTop+=j.scrollHeight-ge)},[$,Z,Y]);async function V(j,ge,Me=f.current){const Le=L;if(!(!Le||m.current)){m.current=!0,ge==="initial"?X(!0):(T(!0),b.current=d.current?.scrollHeight??null),re(null);try{let F=j,pe=0,Ce=0,Re=[];for(;f.current===Me;){const je=await n.getTerminalSubagentTranscriptHistory(t,Le,{...F?{cursor:F}:{},limit:GB,maxLines:XB,includeTools:Y});if(f.current!==Me)return;if(!je.source){if(Ce<1){Ce+=1,await new Promise(Ue=>setTimeout(Ue,600));continue}re("Subagent transcript is unavailable.");return}const be=jc(je.output,je.source.provider,{includeTools:Y});if(K(je.cursor),ee(!!(je.hasMore&&je.cursor)),be&&(Re=[be,...Re],Sp(Re,Y))){de(Ue=>ge==="older"?[...Re,...Ue]:Re);return}if(!je.hasMore||!je.cursor||pe>=ZB){Re.length>0&&de(Ue=>ge==="older"?[...Re,...Ue]:Re);return}F=je.cursor,pe+=1}}catch(F){if(f.current!==Me)return;re(F instanceof Error?F.message:"Failed to load subagent transcript.")}finally{f.current===Me&&(m.current=!1,X(!1),T(!1))}}}function se(){const j=d.current;j&&(j.scrollTop>72||!ne||!me||m.current||V(me,"older"))}function J(j){z(ge=>{const Me=new Set(ge);return Me.delete(j)||Me.add(j),Me})}function xe(j){_.current=!0,q(!0),j.id!==L&&A(j.id),ye(j.id)}function ye(j){const ge=t5(S??[],j);ge.length!==0&&z(Me=>{if(ge.every(F=>Me.has(F)))return Me;const Le=new Set(Me);for(const F of ge)Le.add(F);return Le})}function Pe(){f.current+=1;const j=f.current;m.current=!1,p.current=!0,b.current=null,de([]),K(null),ee(!1),re(null),V(null,"initial",j)}const Fe=v.useMemo(()=>Sp($,Y),[$,Y]),ze=v.useMemo(()=>sb(Fe),[Fe]),ve=S===null;v.useEffect(()=>{if(Z||M||!ne||!me||m.current)return;const j=d.current;!j||$.length===0||j.scrollHeight<=j.clientHeight+4&&V(me,"older")},[$,ne,me,Z,M]);const We=S?.filter(j=>j.state==="working").length??0,Oe=v.useMemo(()=>OE(JB(S??[]),W),[S,W]);return u.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:u.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":H?"transcript":"list",onPointerDown:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),onClick:j=>j.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"transcript-dialog-title",children:[u.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",S&&S.length>0?u.jsx("span",{className:"subagents-count",children:We>0?`${We} working · ${S.length} total`:`${S.length} total`}):null]}),u.jsxs("span",{title:s.sessionId,children:[Eo(s.provider)," session ",s.sessionId]})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:l,children:"×"})]}),u.jsxs("div",{className:"subagents-body",children:[u.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[ve?u.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!ve&&x?u.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!ve&&!x&&S!==null&&S.length===0?u.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Oe.map(j=>{const ge=j.subagent,Me=W.has(ge.id);return u.jsxs("div",{className:"subagent-row-wrap",style:j.level>0?{paddingLeft:`${Math.min(j.level,4)*14}px`}:void 0,children:[j.nestedCount>0?u.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":Me,"aria-label":`${Me?"Collapse":"Expand"} ${j.nestedCount} nested subagents of ${ge.name}`,title:j.nestedWorkingCount>0?`${j.nestedCount} nested · ${j.nestedWorkingCount} working`:`${j.nestedCount} nested`,onClick:()=>J(ge.id),children:[u.jsx("span",{"aria-hidden":"true",children:Me?"▾":"▸"}),u.jsx("span",{className:"subagent-expander-count","data-working":j.nestedWorkingCount>0?"true":"false",children:j.nestedCount})]}):u.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),u.jsxs("button",{type:"button",className:"subagent-row","data-selected":ge.id===L?"true":"false","data-state":ge.state,disabled:!ge.hasTranscript,title:ge.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>xe(ge),children:[u.jsx("span",{className:"subagent-row-dot","data-state":ge.state,"aria-hidden":"true"}),u.jsxs("span",{className:"subagent-row-main",children:[u.jsxs("span",{className:"subagent-row-title",children:[u.jsx("strong",{children:ge.name}),u.jsx("span",{className:"subagent-row-badge","data-kind":ge.kind,children:ge.kind==="cross"?Eo(ge.provider):ge.provider})]}),ge.description?u.jsx("span",{className:"subagent-row-description",children:ge.description}):null,u.jsxs("span",{className:"subagent-row-meta",children:[r5(ge.state),ge.model?` · ${ge.model}`:"",ge.updatedAt?` · ${s5(ge.updatedAt)}`:"",j.nestedCount>0&&!Me?` · ${j.nestedCount} nested${j.nestedWorkingCount>0?` (${j.nestedWorkingCount} working)`:""}`:""]})]})]})]},ge.id)})]}),u.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[u.jsxs("div",{className:"subagents-transcript-controls",children:[u.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>q(!1),children:"‹ List"}),u.jsx("span",{className:"subagents-transcript-name",children:he?he.name:"Select a subagent"}),u.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[u.jsx("input",{type:"checkbox",checked:Y,onChange:j=>I(j.currentTarget.checked)}),"Show tool output"]}),u.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!he,onClick:Pe,children:"↻"})]}),he?u.jsx("div",{className:"subagents-transcript-hint",children:n5(he)}):null,u.jsxs("div",{ref:d,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:se,children:[M?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!Z&&ne?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Fe?u.jsx(NE,{entries:ze,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,Z?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Z&&he&&!Fe&&!O?ne&&me?u.jsxs("div",{className:"transcript-dialog-status",children:[Y?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",u.jsx("button",{type:"button",onClick:()=>{V(me,"older")},disabled:M,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!he&&!ve&&!Fe?u.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,O?u.jsx("div",{className:"transcript-dialog-error",children:O}):null]})]})]})]})})});function JB(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=e5(s,t);o?o.children.push(s):n.push(s)}for(const s of n)LE(s);return jE(n),n}function e5(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 d=l.subagent.parentId;l=d?t.get(d):void 0}return s}function LE(e){let t=0,n=0;for(const s of e.children)LE(s),t+=1+s.nestedCount,n+=(s.subagent.state==="working"?1:0)+s.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,jE(e.children)}function jE(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 OE(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(...OE(o.children,t,n+1));return s}function t5(e,t){const n=new Map(e.map(d=>[d.id,d])),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 n5(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 i5(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 r5(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function s5(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 a5({options:e,value:t,onSelect:n}){const[s,o]=v.useState(!1),l=v.useRef(null),d=v.useRef(null),f=e.find(m=>m.id===t);return v.useEffect(()=>{if(!s)return;const m=()=>Array.from(l.current?.querySelectorAll('[role="menuitemradio"]')??[]),p=m();(p.find(S=>S.getAttribute("aria-checked")==="true")??p[0])?.focus();function b(S){l.current?.contains(S.target)||o(!1)}function _(S){if(S.key==="Escape")S.preventDefault(),S.stopPropagation(),o(!1),d.current?.focus();else if(["ArrowDown","ArrowUp","Home","End"].includes(S.key)){S.preventDefault(),S.stopPropagation();const w=m(),x=w.findIndex(L=>L===document.activeElement),R=S.key==="Home"?0:S.key==="End"?w.length-1:(x+(S.key==="ArrowDown"?1:-1)+w.length)%w.length;w[R]?.focus()}else S.key==="Tab"&&o(!1)}return document.addEventListener("pointerdown",b,!0),window.addEventListener("keydown",_,!0),()=>{document.removeEventListener("pointerdown",b,!0),window.removeEventListener("keydown",_,!0)}},[s]),u.jsxs("div",{className:"transcript-session-menu",ref:l,children:[u.jsxs("button",{ref:d,type:"button",className:"transcript-session-trigger","aria-label":"Transcript session","aria-haspopup":"menu","aria-expanded":s,onClick:()=>o(!s),children:[u.jsx("span",{children:f?.title??"Choose a session"}),u.jsx(RA,{size:16,"aria-hidden":"true"})]}),s?u.jsx("div",{className:"transcript-session-options",role:"menu","aria-label":"Transcript sessions",children:e.map(m=>u.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t===m.id,tabIndex:-1,onClick:()=>{o(!1),d.current?.focus(),n(m.id)},children:[u.jsx("span",{className:"transcript-session-check",children:t===m.id?u.jsx(qk,{size:16}):null}),u.jsxs("span",{className:"transcript-session-copy",children:[u.jsx("strong",{children:m.title}),u.jsx("small",{children:m.detail})]})]},m.id))}):null]})}function Hy(e){const t=new Set;return e.filter(n=>t.has(n.id)?!1:(t.add(n.id),!0))}function ab(e){return!e.page||e.page.unchanged?null:{page:{...e.page,records:Hy(e.page.records)},cursor:e.cursor,hasMore:e.hasMore,scrollTop:0,atBottom:!0}}function Yx(e,t){const n=ab(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:Hy([...n.page.records,...e.page.records])},cursor:n.cursor,hasMore:n.hasMore}}function BE(e,t){return e.identity===t.identity&&(t.snapshotSize>e.snapshotSize||t.snapshotSize===e.snapshotSize&&t.snapshotMtime===e.snapshotMtime)}function IE(e,t){return!BE(e.page,t.page)||t.page.startOffset<=e.page.stableBefore||t.page.startOffset<=e.page.startOffset}function o5(e,t){if(!BE(e.page,t.page)||!IE(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:Hy([...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 l5=64*1024*1024,c5=1800*1e3;let ob=0,lb=new WeakMap;const Yd=new Map,Gd=new Set;function u5(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 cb(e){e.owner.delete(e.key),Gd.delete(e),e.snapshot=null,e.bytes=0}function bv(e){for(const s of Gd)!s.leases&&e-s.closedAt>=c5&&cb(s);let t=0;const n=[];for(const s of Gd)t+=s.bytes,s.leases||n.push(s);n.sort((s,o)=>s.closedAt-o.closedAt);for(const s of n){if(t<=l5)break;t-=s.bytes,cb(s)}for(const[s,o]of Yd)o.size||Yd.delete(s)}function yv(){ob+=1;for(const e of Gd)cb(e);Yd.clear(),lb=new WeakMap}function d5(e,t,n,s){bv(Date.now());const o=e.transcriptCacheScope;let l=o===void 0?lb.get(e):Yd.get(o);l||(l=new Map,o===void 0?lb.set(e,l):Yd.set(o,l));const d=JSON.stringify([t,n.provider,n.sessionId,s]);let f=l.get(d);f||(f={snapshot:null,bytes:0,leases:0,closedAt:0,owner:l,key:d},l.set(d,f),Gd.add(f));const m=ob,p=f;p.leases+=1;let b=!1;const _=()=>!b&&m===ob;return{get snapshot(){return _()?p.snapshot:null},current:_,write(S){_()&&(p.snapshot=S,p.bytes=u5(S),bv(Date.now()))},invalidate(){_()&&(p.snapshot=null,p.bytes=0)},release(){b||(b=!0,p.leases-=1,p.leases||(p.closedAt=Date.now()),bv(Date.now()))}}}function h5(e,t,n){if(!e.length)return null;const s=t.timestamp?zy(`[${t.timestamp}] ${t.role}`):null;let o=e.length-1;if(s){for(let d=e.length-1;d>=0;d-=1)if(e[d]?.header===s){o=d;break}}const l=WB(e,nm(n)).filter(d=>d.entryIndex===o);return(s&&e[o]?.header===s?l[0]:l.at(-1))??{entryIndex:o,matchIndexInEntry:0}}function f5(e,t,n,s,o,l){const[d,f]=v.useState(null),[m,p]=v.useState(!1),[b,_]=v.useState(null),S=v.useRef(null),w=v.useRef(0);function x(){w.current+=1,S.current?.abort(),S.current=null}function R(){x(),p(!1)}v.useEffect(()=>(x(),f(null),p(!1),_(null),x),[e,t,n.provider,n.sessionId,s,o,l]);async function L(A=!1){const W=zB(l);if(W){_(W);return}x();const z=w.current,H=new AbortController;S.current=H,p(!0),_(null);let q=A?d:null;A||f(null);try{for(let Y=0;Y<4;Y+=1){const I=await e.searchTerminalTranscript(t,{query:nm(l),...q?.cursor?{cursor:q.cursor}:{},...s?{candidateId:s}:{},expectedSessionId:n.sessionId,includeTools:o},H.signal);if(H.signal.aborted||z!==w.current)return;if(!I.source||I.source.provider!==n.provider||I.source.sessionId!==n.sessionId)throw new Error("Transcript source changed or is unavailable. Choose a session again.");const $=new Set(q?.hits.map(K=>K.id)),de=[...q?.hits??[],...I.hits.filter(K=>!$.has(K.id))],me=q?.cursor;if(q={...I,hits:de.slice(-200)},f(q),I.complete||!I.cursor||I.cursor===me||I.hits.length)break}}catch(Y){!H.signal.aborted&&z===w.current&&_(Y instanceof Error?Y.message:"Search failed.")}finally{z===w.current&&p(!1)}}return{result:d,busy:m,error:b,search:L,cancel:R}}class p5{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():UE.has(t)?this.acceptConsonant(t):$E.has(t)?this.acceptVowel(t):_5(t)&&this.canReplacePendingWith(t)?(this.pending=Xx(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(FE.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=v5.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=g5.get(`${this.pending.vowel}${t}`);return l?(this.pending.vowel=l,""):this.flushPending()+t}const n=Gx.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=Gx.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=Xx(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 wp=44032,xp=21,zc=28,m5=19*xp*zc,PE=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],zE=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],HE=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],UE=Uy(PE),$E=Uy(zE),FE=Uy(HE),g5=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),WE=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],v5=new Map(WE),Gx=new Map(WE.map(([e,t])=>[t,[e[0],e[1]]]));function Uy(e){return new Map(e.map((t,n)=>[t,n]))}function _5(e){const t=e.codePointAt(0);return t!==void 0&&t>=wp&&t<wp+m5}function Xx(e){const t=e.codePointAt(0)-wp,n=Math.floor(t/(xp*zc)),s=Math.floor(t%(xp*zc)/zc),o=t%zc,l={initial:PE[n],vowel:zE[s]};return o===0?l:{...l,final:HE[o]}}function Zx(e){if(!e.vowel)return e.initial;const t=UE.get(e.initial),n=$E.get(e.vowel),s=e.final?FE.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(wp+(t*xp+n)*zc+s)}class Qx{constructor(t=!0){this.mouseEnabled=t}mouseEnabled;state="text";pending="";stringIsOsc=!1;oversizedCsi=!1;mouseProtocol=null;mouseEncodings=new Set;setMouseEnabled(t){if(this.mouseEnabled===t)return"";if(this.mouseEnabled=t,!t)return"\x1B[?9;1000;1002;1003;1005;1006;1015;1016l";const n=[...this.mouseEncodings,...this.mouseProtocol===null?[]:[this.mouseProtocol]];return n.length?`\x1B[?${n.join(";")}h`:""}write(t){if(this.state==="text"&&!/[\x1b\x90\x98\x9b\x9d\x9e\x9f]/.test(t))return t;let n="";for(const s of t){if(this.state==="string-escape"){if(s==="\\"){n+="\x1B\\",this.state="text";continue}n+="",this.pending="\x1B",this.state="escape"}if(this.state==="string"){if(s==="\x1B"){this.state="string-escape";continue}n+=s,(s===""||s===""||s===""||this.stringIsOsc&&s==="\x07")&&(this.state="text");continue}if(s==="\x1B"){n+=this.pending,this.pending=s,this.state="escape",this.oversizedCsi=!1;continue}if(this.state==="escape"){const o=s.charCodeAt(0);if(o===127)continue;if(o<32&&s!==""&&s!==""){n+=s;continue}this.pending+=s,s==="["?this.state="csi":(n+=this.pending,this.pending="",this.stringIsOsc=s==="]",this.state="]PX^_".includes(s)?"string":"text");continue}if(this.state==="csi"){const o=s.charCodeAt(0);if(o===127)continue;if(o<32&&s!==""&&s!==""){n+=s;continue}this.oversizedCsi||(this.pending+=s),o>=64&&o<=126?(this.oversizedCsi||(n+=this.filterModes(this.pending)),this.pending="",this.state="text"):s===""||s===""?(n+=this.pending,this.pending="",this.state="text"):this.pending.length>4096&&(this.pending="",this.oversizedCsi=!0);continue}s===""?(this.pending=s,this.state="csi",this.oversizedCsi=!1):(n+=s,"".includes(s)&&(this.stringIsOsc=s==="",this.state="string"))}return n}filterModes(t){const n=/^(\x1b\[|\x9b)\?([0-9;:]*)([hl])$/.exec(t);if(!n)return t;const s=n[3]==="h",o=n[2].split(";").filter(Boolean).filter(l=>{const d=Number(l.split(":")[0]);return[47,1047,1049].includes(d)?!1:[9,1e3,1002,1003].includes(d)?(this.mouseProtocol=s?d:null,this.mouseEnabled||!s):[1005,1006,1015,1016].includes(d)?(s?this.mouseEncodings.add(d):this.mouseEncodings.delete(d),this.mouseEnabled||!s):!0});return o.length>0?`${n[1]}?${o.join(";")}${n[3]}`:""}}function b5(e){return/^(?:\x1b\[<\d+;\d+;\d+[Mm])+$/.test(e)}const KE={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"},y5={...KE,tab:"\x1B[Z",arrowUp:"\x1B[1;2A",arrowDown:"\x1B[1;2B",arrowRight:"\x1B[1;2C",arrowLeft:"\x1B[1;2D"};function ub(e,t=!1){return(t?y5:KE)[e]}function S5(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const w5=[{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 x5({ctrlActive:e,shiftActive:t,onCtrl:n,onShift:s,onStandaloneKey:o,onPreserveFocus:l,onHide:d}){const f=v.useRef(null);function m(p){p.preventDefault(),p.stopPropagation(),l()}return u.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:m,onPointerDown:m,children:[u.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:n,children:"Ctrl"}),u.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-shift","aria-label":"Toggle Shift modifier",title:"Shift","aria-pressed":t,"data-active":t,onPointerDown:()=>{f.current=!t},onPointerCancel:()=>{f.current=null},onKeyDown:()=>{f.current=null},onClick:()=>{const p=f.current??!t;f.current=null,s(p)},children:u.jsx(xA,{size:16,"aria-hidden":"true"})}),w5.map(p=>{const _=t&&ub(p.key,!0)!==ub(p.key)?p.ariaLabel.replace("Send ","Send Shift + "):p.ariaLabel;return u.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":_,title:_,onClick:()=>o(p.key),children:p.label},p.key)}),u.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:d,children:"×"})]})}const qE="--nterminal-viewport-height",VE="--nterminal-keyboard-inset-bottom",YE="data-nterminal-keyboard-visible",im="data-nterminal-compose-open",Cp="nterminal:viewport-refresh",C5=120;function k5(e=window){const t=e.document.documentElement,n=e.visualViewport,s=M5(e);function o(){$y(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),s?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(Cp,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(Cp,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(qE),t.style.removeProperty(VE),t.removeAttribute(YE)}}function $y(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=db(e),o=T5(e,s);return o!==null&&Jx(t,qE,`${o}px`),Jx(t,VE,`${n}px`),E5(t,YE,String(s)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:s}}function db(e=window){const t=R5(e);return{keyboardInsetBottom:t,keyboardVisible:t>C5}}function T5(e,t){if((e.document.documentElement.hasAttribute(im)||t)&&Nl(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Nl(n)?n:Nl(e.innerHeight)?e.innerHeight:null}function Nl(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Jx(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function E5(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function R5(e){return Math.max(N5(e),D5(e))}function N5(e){const t=e.visualViewport?.height;if(!Nl(t)||!Nl(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 D5(e){if(!Nl(e.innerHeight))return 0;const n=GE(e)?.boundingRect?.height;return!Nl(n)||n>=e.innerHeight*.8?0:Math.round(n)}function GE(e){return e.navigator.virtualKeyboard}function M5(e){const t=GE(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const gh=new Map,Xd=new Map,A5=Object.freeze({open:!1,text:""});function L5(e){let t=Xd.get(e);return t||(t=new Set,Xd.set(e,t)),t}function XE(e){const t=Xd.get(e);if(t)for(const n of Array.from(t))n()}function Kc(e){return gh.get(e)??A5}function j5(e,t){const n=L5(e);return n.add(t),()=>{n.delete(t)}}function O5(e,t){const n=Kc(e);n.open!==t&&(gh.set(e,{...n,open:t}),XE(e))}function B5(e,t){const n=Kc(e);n.text!==t&&(gh.set(e,{...n,text:t}),XE(e))}function Rf(e){gh.delete(e),Xd.delete(e)}function eC(){gh.clear(),Xd.clear()}const Oo=new Map,Zd=new Map,kp=new Map,I5=Object.freeze([]);function Qd(e){return Oo.get(e)??I5}function P5(e,t){let n=Zd.get(e);return n||(n=new Set,Zd.set(e,n)),n.add(t),()=>n?.delete(t)}function Sv(e,t){t.length!==0&&(Oo.set(e,[...Qd(e),...t]),rm(e))}function wv(e){const t=kp.get(e)??1;return kp.set(e,t+1),`attach${t}`}function hb(e){kp.delete(e)}function pd(e,t,n){const s=Qd(e);s.length!==0&&(Oo.set(e,s.map(o=>t.has(o.id)?n(o):o)),rm(e))}function Nf(e,t){const n=Qd(e);n.find(l=>l.id===t)?.cancel?.();const o=n.filter(l=>l.id!==t);o.length!==n.length&&(o.length===0?Oo.delete(e):Oo.set(e,o),rm(e))}function ZE(e){const t=Oo.get(e);if(t){for(const n of t)n.cancel?.();Oo.delete(e),rm(e)}}function wd(e){ZE(e),hb(e),Zd.delete(e)}function tC(){for(const e of Array.from(Oo.keys()))wd(e);Zd.clear(),kp.clear()}function rm(e){for(const t of Array.from(Zd.get(e)??[]))t()}class z5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Hc(e){return e?Array.from(e.types??[]).includes("Files")||Wy(e.items).some(n=>n.kind==="file")?!0:i2(e.files).length>0:!1}async function QE(e){const t=Wy(e.items).filter(n=>n.kind==="file");return t.length>0?H5(t):e2(e.files)}function JE(e){const t=Wy(e.items).filter(o=>o.kind==="file").flatMap(o=>{const l=o.getAsFile();return l?[{relativePath:Fy(l),file:l}]:[]}),n=e2(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=>W5(l.file,o.file))||s.push(o);return s}async function H5(e){const t=[];for(const n of e){const s=K5(n);if(s){await t2(s,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Fy(o),file:o});continue}throw new z5("Folder upload is not supported by this browser.")}return t}function e2(e){return i2(e).map(t=>({relativePath:Fy(t),file:t}))}async function t2(e,t,n){const s=V5(t,e.name);if(e.isFile){const d=await U5(e);n.push({relativePath:s,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),l=await $5(o);for(const d of l)await t2(d,s,n)}function U5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function $5(e){const t=[];for(;;){const n=await F5(e);if(n.length===0)return t;t.push(...n)}}function F5(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function Fy(e){const t=e.webkitRelativePath;return n2(typeof t=="string"&&t?t:e.name)}function W5(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type}function K5(e){const t=e.webkitGetAsEntry?.();return q5(t)?t:null}function q5(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 V5(e,t){return n2(e?`${e}/${t}`:t)}function n2(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Wy(e){return e?Array.from(e):[]}function i2(e){return e?Array.from(e):[]}const Y5=120,G5="\x1B[200~",X5="\x1B[201~";function Kf(e,t){const n=t.stripTrailingLineBreaks===!1?e:r2(e),s=Q5(n);return s?t.bracketedPasteMode?`${G5}${s}${X5}`:s:""}function Z5(e){return e==="queue"?" ":"\r"}function r2(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function Q5(e){return e.replace(/\r\n/g,`
|
|
50
|
-
`).replace(/\r/g,`
|
|
51
|
-
`).replace(/\n/g,"\r")}const J5=420,e4=3e3,nC=650,t4=80,n4=3,i4=10,r4=50*1024*1024,s4=100*1024*1024,a4=2,o4={maxFiles:i4,maxFileBytes:r4,maxBatchBytes:s4},qf=new Set;let qc=null;function l4({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1,onUploadAttachments:o,onGetAttachmentLimits:l,onDeleteAttachments:d}){const f=v.useMemo(()=>j=>j5(e,j),[e]),m=v.useMemo(()=>()=>Kc(e),[e]),p=v.useSyncExternalStore(f,m,m),{open:b,text:_}=p,S=v.useMemo(()=>j=>P5(e,j),[e]),w=v.useMemo(()=>()=>Qd(e),[e]),x=v.useSyncExternalStore(S,w,w),[R,L]=v.useState(o4),[A,W]=v.useState(!1),z=v.useRef(null),H=v.useRef(null),q=v.useRef(null),Y=v.useRef(null),I=v.useRef(new Map),$=v.useRef(l),de=v.useRef(d),me=v.useRef(null),K=v.useRef({start:0,end:0});$.current=l,de.current=d,v.useEffect(()=>()=>{me.current?.(),me.current=null},[]),v.useEffect(()=>{if(!b||!$.current)return;let j=!0;return $.current().then(ge=>{j&&L(ge)}).catch(()=>{}),()=>{j=!1}},[b,e]),v.useLayoutEffect(()=>{if(!(!b||!Vf()))return g4(e),()=>v4(e)},[b,e]),v.useLayoutEffect(()=>{const j=z.current?.closest(".terminal-pane");if(!j)return;function ge(){j?.removeAttribute("data-compose-open"),j?.style.removeProperty("--compose-drawer-panel-height")}if(!b){ge();return}const Me=H.current;j.setAttribute("data-compose-open","true");function Le(){const Re=Me?.getBoundingClientRect().height??0;Re>0&&j?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Re)}px`)}Le();const F=[window.setTimeout(Le,0),window.setTimeout(Le,180),window.setTimeout(Le,260)],pe=window.requestAnimationFrame?.(Le)??null,Ce=typeof ResizeObserver=="function"&&Me?new ResizeObserver(Le):null;return Ce&&Me&&Ce.observe(Me),()=>{for(const Re of F)window.clearTimeout(Re);pe!==null&&window.cancelAnimationFrame?.(pe),Ce?.disconnect(),ge()}},[b]),v.useEffect(()=>{if(!b){me.current?.(),me.current=null;return}Tv(q.current),ve()},[b]);function ne(j){O5(e,j)}function ee(j){B5(e,j)}function Z(){m4(z.current),ne(!1),sC()}function X(j="send"){const ge=x.filter(Le=>Le.status==="uploaded"&&Le.path);if(s||x.some(Le=>Le.status==="uploading"||Le.status==="failed")||!_&&ge.length===0)return;const Me=d4(_,x);if(Me.parts.some(Le=>Le.kind==="image"||Le.value.trim())&&t(Me,j)){if(ee(""),ZE(e),hb(e),Vf()){q.current?.blur(),sC();return}window.setTimeout(()=>q.current?.focus(),Y5+20)}}async function M(j){if(s||j.length===0)return;const ge=Qd(e).filter(be=>be.status!=="failed"),Me=ge.reduce((be,Ue)=>be+Ue.file.size,0);let Le=0,F=ge.length;const pe=[],Ce=j.filter((be,Ue)=>{const $e=Me+Le+be.file.size,Be=be.file.size>R.maxFileBytes?`File exceeds the ${rC(R.maxFileBytes)} attachment limit.`:F>=R.maxFiles?`A compose message can include up to ${R.maxFiles} attachments.`:$e>R.maxBatchBytes?`Compose attachments cannot exceed ${rC(R.maxBatchBytes)} in total.`:null;return Be?(pe.push({id:Cv(Ue),reference:wv(e),file:be.file,relativePath:iC(be.relativePath,be.file.name),status:"failed",error:Be}),!1):(F+=1,Le+=be.file.size,!0)});if(pe.length>0&&Sv(e,pe),Ce.length===0)return;const Re=new Map,je=Ce.map((be,Ue)=>{const $e=Cv(Ue),Be=new AbortController;return Re.set($e,Be),{id:$e,reference:wv(e),file:be.file,relativePath:iC(be.relativePath,be.file.name),status:"uploading",loaded:0,total:be.file.size,cancel:()=>Be.abort()}});Sv(e,je),We(je.map(be=>be.reference));for(const be of je)I.current.set(be.id,Re.get(be.id));await p4(je,a4,async be=>{const Ue=Re.get(be.id),$e=new Set([be.id]);try{const ot=(await o([{relativePath:be.relativePath,file:be.file}],{signal:Ue.signal,onProgress:ct=>{pd(e,$e,ht=>({...ht,loaded:ct.loaded,total:ct.total}))}})).results[0];if(Ue.signal.aborted){const ct=de.current;ot?.status==="uploaded"&&ot.attachmentId&&ct&&ct([ot.attachmentId]).catch(()=>{});return}pd(e,$e,ct=>{const{error:ht,cancel:jt,...Qt}=ct;return ot?.status==="uploaded"&&ot.path?{...Qt,status:"uploaded",...ot.attachmentId?{attachmentId:ot.attachmentId}:{},path:ot.path,loaded:ot.size??ct.file.size,total:ot.size??ct.file.size}:{...Qt,status:"failed",error:ot?.error??"upload_failed"}})}catch(Be){const ot=Ue.signal.aborted?"Upload canceled.":kv(Be);pd(e,$e,ct=>{const{cancel:ht,...jt}=ct;return{...jt,status:"failed",error:ot}})}finally{I.current.get(be.id)===Ue&&I.current.delete(be.id)}})}function T(j){if(j.status!=="removing"){if(Oe(j.reference),j.status!=="uploaded"&&j.status!=="failed"||!j.attachmentId||!de.current){I.current.delete(j.id),Nf(e,j.id);return}re([j])}}function O(){ee(""),hb(e);const j=x.filter(ge=>!!(ge.path&&ge.attachmentId));for(const ge of x)j.includes(ge)||(I.current.delete(ge.id),Nf(e,ge.id));j.length>0&&re(j)}function re(j){const ge=j.flatMap(Le=>Le.attachmentId?[Le.attachmentId]:[]);if(ge.length===0||!de.current){for(const Le of j)Nf(e,Le.id);return}const Me=new Set(j.map(Le=>Le.id));pd(e,Me,Le=>{const{error:F,...pe}=Le;return{...pe,status:"removing"}}),de.current(ge).then(()=>{for(const Le of j)Nf(e,Le.id)}).catch(Le=>{pd(e,Me,F=>({...F,status:"failed",error:`Could not remove attachment: ${kv(Le)}`}))})}function he(j){const ge=Array.from(j.currentTarget.files??[]).map(Me=>({relativePath:Me.name,file:Me}));j.currentTarget.value="",M(ge)}function N(j){const ge=JE(j.clipboardData);ge.length!==0&&(j.preventDefault(),M(ge))}function V(j){s||!Hc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),j.dataTransfer.dropEffect="copy",W(!0))}function se(j){s||!Hc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),W(!0))}function J(j){if(!Hc(j.dataTransfer))return;const ge=j.relatedTarget;ge instanceof Node&&j.currentTarget.contains(ge)||W(!1)}function xe(j){Hc(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),W(!1),QE(j.dataTransfer).then(M).catch(ge=>{const Me={id:Cv(0),reference:wv(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:kv(ge)};Sv(e,[Me])}))}const ye=x.some(j=>j.status==="uploading"),Pe=x.some(j=>j.status==="failed"),Fe=x.filter(j=>j.status==="uploaded"&&j.path).length,ze=!s&&!ye&&!Pe&&(!!_||Fe>0);function ve(){Vf()&&(me.current?.(),me.current=_4())}function We(j){if(j.length===0)return;const ge=j.map(Be=>`@${Be}`).join(" "),Me=Kc(e).text,Le=Math.min(K.current.start,Me.length),F=Math.min(Math.max(Le,K.current.end),Me.length),pe=Me.slice(0,Le),Ce=Me.slice(F),Re=pe&&!/\s$/.test(pe)?" ":"",je=Ce&&!/^\s/.test(Ce)?" ":"",be=`${Re}${ge}${je}`,Ue=`${pe}${be}${Ce}`,$e=pe.length+be.length;K.current={start:$e,end:$e},ee(Ue),window.requestAnimationFrame(()=>{const Be=q.current;Be&&(Tv(Be),Be.setSelectionRange($e,$e))})}function Oe(j){const ge=Kc(e).text,Me=ge.replace(new RegExp(`@${f4(j)}(?![A-Za-z0-9_])`,"g"),"");Me!==ge&&ee(Me.replace(/[ \t]{2,}/g," "))}return u.jsxs("div",{ref:z,className:"compose-drawer","data-open":b?"true":"false",children:[u.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":b?"true":void 0,tabIndex:b?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>ne(!0),children:[u.jsx("span",{"aria-hidden":"true",children:"▴"}),u.jsx("span",{children:"compose"}),_||x.length>0?u.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),u.jsxs("div",{ref:H,className:"compose-drawer-panel","aria-hidden":b?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:se,onDragOver:V,onDragLeave:J,onDrop:xe,children:[A?u.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,u.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:b?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:Z,children:[u.jsx("span",{"aria-hidden":"true",children:"▾"}),u.jsx("span",{className:"compose-drawer-title",children:"compose"}),u.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),u.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),u.jsx("textarea",{ref:q,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:b?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:_,onChange:j=>{K.current={start:j.target.selectionStart,end:j.target.selectionEnd},ee(j.target.value)},onSelect:j=>{K.current={start:j.currentTarget.selectionStart,end:j.currentTarget.selectionEnd}},onPaste:N,onFocus:ve,onKeyDown:j=>{if(j.key==="Enter"&&(j.metaKey||j.ctrlKey)){if(j.preventDefault(),j.shiftKey){n&&X("queue");return}X("send");return}j.key==="Escape"&&(j.preventDefault(),Z())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),u.jsx("input",{ref:Y,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:he}),x.length>0?u.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:x.map(j=>u.jsx(c4,{attachment:j,onRemove:()=>T(j)},j.id))}):null,u.jsxs("div",{className:"compose-drawer-actions",children:[u.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:b?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>Y.current?.click(),disabled:s,children:"+"}),u.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:b?0:-1,onClick:()=>{O(),Tv(q.current),ve()},disabled:!_&&x.length===0,children:"Clear"}),n?u.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:b?0:-1,title:Pe?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>X("queue"),disabled:!ze,children:"Queue"}):null,u.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:b?0:-1,title:Pe?"Remove failed attachments before sending.":void 0,onClick:()=>X("send"),disabled:!ze,children:"Send"})]})]})]})}function c4({attachment:e,onRemove:t}){const n=u4(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 u.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[s&&n?u.jsx("img",{src:n,alt:""}):u.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),u.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),u.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),u.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),u.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function u4(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 d4(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,d;for(;(d=o.exec(e))!==null;){const f=n.get(d[1]);f&&(xv(s,e.slice(l,d.index)),f.status==="uploaded"&&f.path&&(h4(f)?s.push({kind:"image",path:f.path}):xv(s,f.path)),l=o.lastIndex)}return xv(s,e.slice(l)),{parts:s}}function xv(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 h4(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function f4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function iC(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Cv(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function kv(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function rC(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 p4(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 m4(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Tv(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Vf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function sC(){if(!Vf())return;const e=Uc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function g4(e){qc!==null&&(window.clearTimeout(qc),qc=null),qf.add(e),document.documentElement.setAttribute(im,"true"),Uc()}function v4(e){if(qf.delete(e),qf.size>0||qc!==null){Uc();return}qc=window.setTimeout(()=>{if(qc=null,qf.size>0){Uc();return}document.documentElement.removeAttribute(im),Uc()},J5),Uc()}function _4(){let e=!1,t=null,n=null,s=null,o=0;const l=Date.now(),d=window.visualViewport,f=b4();function m(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,m(),d?.removeEventListener("resize",_),d?.removeEventListener("scroll",_),f?.removeEventListener("geometrychange",_))}function b(S){if(!e){if(S<nC&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(_);return}t=window.setTimeout(_,t4)}}function _(){if(e)return;m();const S=$y(),w=Date.now()-l;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?o+=1:(o=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=e4||w>=nC&&o>=n4){p();return}b(w)}return d?.addEventListener("resize",_),d?.addEventListener("scroll",_),f?.addEventListener("geometrychange",_),_(),p}function Uc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,$y()}function b4(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function y4(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(x4(d))return d.preventDefault(),d.stopPropagation(),S4(e),!1;if(w4(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(C4(d)){const f=fb(e);return f?(d.preventDefault(),d.stopPropagation(),pb(f),!1):!0}return k4(d)?(d.stopPropagation(),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const f=fb(e);if(f){if(d.clipboardData){d.clipboardData.setData("text/plain",f),d.preventDefault();return}d.preventDefault(),pb(f)}},l=d=>{if(n.canPaste?.()===!1){d.preventDefault(),d.stopImmediatePropagation();return}if(n.onPasteFiles&&d.clipboardData){const p=JE(d.clipboardData).map(b=>b.file);if(p.length>0){d.preventDefault(),d.stopImmediatePropagation(),n.onPasteFiles(p);return}}const f=d.clipboardData?.getData("text/plain");if(!f)return;const m=r2(f);d.preventDefault(),d.stopImmediatePropagation(),T4(e,m,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 S4(e){const t=fb(e);t&&await pb(t)}function w4(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function x4(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 C4(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function k4(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}function T4(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function fb(e){return e.hasSelection()?e.getSelection():E4(e.element??null)}function E4(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 pb(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}R4(e)}function R4(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 N4=10,D4=100*1024*1024;class M4{constructor(t){this.options=t}options;jobs=[];job=null;limits=null;notice=null;percent=null;get pending(){return this.jobs.length>0}cancel(t,n=!1){for(const s of this.jobs)s.controller.abort(),s.timer!==null&&clearTimeout(s.timer),s.resolve();this.jobs=[],this.job=null,this.limits=null,this.notice=null,this.percent=null,this.options.onState(t?{uploading:!1,message:t,...n?{error:!0}:{}}:null)}allowInput(t,n=!1){return!this.pending||n?!0:t===""||t===""||t===""||t==="\x1B"?(this.cancel("Image paste canceled."),!0):!/[\r\n\t]/.test(t)}paste(t){if(t.length===0)return Promise.resolve();const n=this.options.getTarget();if(this.job&&this.job.target!==n&&this.cancel(),this.pending||(this.notice=null),!n?.supportsImages)return this.showNotice("Image paste requires an active Codex or Claude pane."),Promise.resolve();const s=t.map(A4);if(s.some(l=>l===null))return this.showNotice("Only image attachments are supported here."),Promise.resolve();const o=this.jobs.flatMap(l=>l.files);return o.length+t.length>N4||[...o,...t].reduce((l,d)=>l+d.size,0)>D4?(this.showNotice("New images were not queued: image paste is limited to 10 pending images and 100 MiB."),Promise.resolve()):new Promise(l=>{this.jobs.push({target:n,files:s,controller:new AbortController,timer:null,resolve:l}),this.publishState(),this.startNext()})}startNext(){if(this.job)return;const t=this.jobs[0];if(!t){this.limits=null,this.publishState();return}this.job=t,this.percent=null,this.publishState(),this.upload(t)}showNotice(t){this.notice=t,this.publishState()}publishState(){const t=this.jobs.reduce((s,o)=>s+o.files.length,0),n=t>0?`Uploading ${t} image${t===1?"":"s"}${this.percent===null?"...":` (${this.percent}%)`}`:"";this.options.onState(n||this.notice?{uploading:t>0,message:[n,this.notice].filter(Boolean).join(" "),...this.notice?{error:!0}:{}}:null)}async upload(t){const{target:n,files:s,controller:o}=t,l=()=>this.job===t&&!o.signal.aborted&&this.options.getTarget()===n,d=[];let f=!1;t.timer=setTimeout(()=>{this.job===t&&this.cancel("Image upload timed out. Pending image pastes were canceled.",!0)},12e4);try{if(!l())return;const m=this.limits??await n.api.getComposeAttachmentLimits(o.signal);if(!l())return;if(this.limits=m,s.length>m.maxFiles||s.some(_=>_.size>m.maxFileBytes)||s.reduce((_,S)=>_+S.size,0)>m.maxBatchBytes)throw new Error("Images exceed the server attachment limits.");const p=await n.api.uploadComposeAttachments({terminalId:n.terminalId,files:s.map(_=>({file:_,relativePath:_.name})),signal:o.signal,onProgress:_=>{l()&&(this.percent=_.percent,this.publishState())}});if(d.push(...p.results.filter(_=>_.status==="uploaded")),!l())return;if(p.results.length!==s.length||d.length!==s.length||d.some(_=>!_.path?.startsWith("/")||/[\x00-\x1f\x7f]/.test(_.path)))throw new Error("Image upload did not complete. No images were pasted.");const b=d.map(_=>Kf(_.path,{bracketedPasteMode:!0})).join("");if(f=this.options.send(b),!f)throw new Error("Images were not pasted because the terminal connection is unavailable.")}catch(m){l()&&this.cancel(`${m instanceof Error?m.message:"Image paste failed."} Pending image pastes were canceled.`,!0)}finally{if(t.timer!==null&&clearTimeout(t.timer),this.job===t&&(this.options.getTarget()!==n?this.cancel():(this.jobs.shift(),this.job=null,t.resolve(),this.startNext())),!f&&d.length>0){const m=d.flatMap(p=>p.attachmentId?[p.attachmentId]:[]);m.length>0&&n.api.deleteComposeAttachments({terminalId:n.terminalId,attachmentIds:m}).catch(()=>{})}}}}function A4(e){if(/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.name))return e;const t=/^image\/(avif|bmp|gif|jpeg|png|webp)$/.exec(e.type.toLowerCase())?.[1];if(!t)return null;const n=t==="jpeg"?"jpg":t;return new File([e],`${e.name||"clipboard"}.${n}`,{type:e.type})}const L4=[4,10,11,12];function j4(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>aC(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>aC(s)),e.parser.registerCsiHandler({final:"n"},s=>O4(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>B4(s)),e.parser.registerCsiHandler({final:"t"},s=>I4(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...L4.map(s=>e.parser.registerOscHandler(s,o=>P4(o)))];return{dispose(){for(const s of n)s.dispose()}}}function aC(e){return sm(e)===0}function O4(e){const t=sm(e);return t===5||t===6}function B4(e){return sm(e)===6}function I4(e){const t=sm(e);return t===14||t===16||t===18}function P4(e){return e.split(";").some(t=>t==="?")}function sm(e){const t=e[0];return typeof t=="number"?t:0}const Qr=new Map,Ev=2*1024*1024,z4=1500,oC=25e3,H4=2500,U4=2500,$4=1e3,F4=2e3,W4=3e4,K4=16*1024*1024,mb=256,s2=wM-3e4,q4=3e3,a2=1e4,V4=3e3,gb=16*1024*1024,am=4*1024*1024,Tp=25,Y4=1e3,G4=3e3,Rv=8,X4=100,o2=1e3,lC=[2e3,5e3,15e3,6e4];let Z4=0,Q4=0,Nv=0,Dv=null,Yf=!1,vb=0,Gf=0,Ro=!1,cC=!1,Pd=null,uC=!1,_b=0,Jd=document.visibilityState!=="hidden";const Ep=new Set;let Vc=null,zd=0;const J4=new TextEncoder,eI=xI();function tI(e,t){iI(),dI(),Yp()&&ka(0);let n=Qr.get(e);n||(n=aI(e),Qr.set(e,n),ou(n)),n.listeners.add(t);const s=Symbol(e);queueMicrotask(()=>qy(n));const o=(f,m)=>fI(n,f,m),l=f=>{f?(n.foregroundAttachments.add(s),Rp(),u2(n)):(n.foregroundAttachments.delete(s),bb())},d=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(s),bb()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:l,detach:d}}function xd(e){const t=Qr.get(e);t&&(wI(t),Qr.delete(e),bb())}function nI(e){const t=Qr.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Io(t),ds(t),Os(t),Po(t),As(t,"reconnecting"),zo(t);const n=t.socket;return t.socket=null,wo(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),ou(t),!0}function iI(){if(uC)return;uC=!0;const e=()=>{if(document.visibilityState==="hidden"){Jd=!1,_b+=1,d2(),c2(),rI();return}Ky(),zd=Date.now(),Rp()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),Rp()}function Rp(){Vc!==null||document.visibilityState==="hidden"||!l2()||typeof window.requestAnimationFrame!="function"||(Vc=window.requestAnimationFrame(()=>{if(Vc=null,document.visibilityState==="hidden")return;const e=Date.now(),t=zd>0?e-zd:0;if(zd=e,t>=F4){for(const n of Qr.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&Ra("terminal.connection.foreground_gap",n,{gapMs:t});Ky(void 0,{foregroundOnly:!0})}Rp()}))}function l2(){for(const e of Qr.values())if(e.foregroundAttachments.size>0)return!0;return!1}function bb(){l2()||(c2(),zd=0)}function c2(){Vc!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Vc),Vc=null}function u2(e){if(document.visibilityState!=="hidden"){if(!Jd||e?.heartbeatSuspended){Ky(e);return}e&&yb(e)}}function Ky(e,t={}){if(document.visibilityState==="hidden")return;Jd=!0;const n=++_b;d2();const s=Array.from(Qr.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=s.filter(f=>f===e||f.foregroundAttachments.size>0||mI(f)),l=new Set(o),d=s.filter(f=>!l.has(f));for(const f of o)yb(f);if(!t.foregroundOnly)for(let f=0;f<d.length;f+=Rv){const m=d.slice(f,f+Rv),p=Math.floor(f/Rv)*X4,b=window.setTimeout(()=>{if(Ep.delete(b),!(n!==_b||!Jd||document.visibilityState==="hidden"))for(const _ of m)yb(_)},p);Ep.add(b)}}function d2(){for(const e of Ep)window.clearTimeout(e);Ep.clear()}function yb(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,ou(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<$4)return Promise.resolve("alive");As(e,"reconnecting"),zo(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const s=`resume-${n.toString(36)}-${(++Z4).toString(36)}`;let o;const l=new Promise(f=>{o=f}),d={socket:t,nonce:s,timeout:0,promise:l,resolve:o};e.resumeProbe=d,Dl(e,{type:"resume"}),d.timeout=window.setTimeout(()=>{e.resumeProbe!==d||e.socket!==t||(Ra("terminal.connection.resume_timeout",e,{pendingInputs:No(e)}),As(e,"reconnecting"),Do(e))},H4);try{t.send(JSON.stringify({type:"ping",nonce:s}))}catch{As(e,"reconnecting"),Do(e)}return l}function rI(){Jd=!1;for(const e of Qr.values())e.heartbeatSuspended=!0,Io(e),ds(e),Os(e),Po(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,As(e,"skipped"),zo(e)}function sI(){Ro=!1,Yp()&&ka(0);for(const e of Qr.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Io(e),ds(e),Os(e),Po(e),As(e,"reconnecting"),zo(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,wo(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ou(e)}}function Mv(){for(const e of Array.from(Qr.keys()))xd(e)}function aI(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:Tp,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 ou(e){if(!e.reconnectEnabled)return;wo(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,ds(e),Os(e),Po(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,Io(e),ds(e),wo(e,"connected"),Bo(e,t),h2(e,t),e.isAlive=!0,dC(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(MI(l)){AI(e,t,l.instanceId,l.inputAck,l.inputReceipt===!0),Ro&&(Ro=!1,Yp()&&ka(0));return}if(e.inputProtocolMode==="unknown"&&m2(e,t),l.type==="pong"){e.isAlive=!0;const f=e.resumeProbe;f?.socket===t&&f.nonce===l.nonce&&(e.lastResumeProbeAt=Date.now(),No(e)>0&&Ra("terminal.connection.resume_alive",e,{pendingInputs:No(e)}),As(e,"alive"),Bo(e,t),dC(e),Il(e),Dl(e,{type:"resume"}));const m=e.inputAckProbe;m?.socket===t&&m.nonce===l.nonce&&(eh(e),Ra("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:No(e)}),Do(e));return}if(l.type==="input_ack"){EI(e,t,l);return}if(l.type==="input_received"){RI(e,t,l);return}if(l.type==="error"&&NI(e,l),l.type==="input_ack_confirmed"){jI(e,l);return}const d=lI(e,l);if(Dl(e,{type:"message",message:d}),l.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;qy(e)}}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Io(e),ds(e),Os(e),Po(e),As(e,"reconnecting"),zo(e),s.code===1008){e.reconnectEnabled=!1,wo(e,oI(s.reason)?"unauthorized":"closed");return}if(!n&&s.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=W4)&&(e.lastUpgradeAuthProbeAt=o,Dl(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){wo(e,"closed");return}wo(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,ou(e)},z4)}}),t.addEventListener("error",()=>{})}function dC(e){if(zo(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>oC*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)}))},oC)}function zo(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function oI(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function lI(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+Na(s),0),hC(e),e.exited&&Xf(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Na(t.data),hC(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Xf(e)),t):(t.type==="exit"&&(e.exited=!0,Xf(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function hC(e){for(;e.outputBytes>Ev&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Na(t)}e.outputBytes>Ev&&e.output.length===1&&(e.output[0]=BI(e.output[0],Ev),e.outputBytes=Na(e.output[0]))}function wo(e,t){e.status!==t&&(e.status=t,Dl(e,{type:"status",status:t}))}function Dl(e,t){for(const n of Array.from(e.listeners))n(t)}function No(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function cI(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 uI(e,t,n={}){const s=Qr.get(e);s&&Ra(`terminal.connection.render_${t}`,s,n)}function Ra(e,t,n={}){Pi(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:No(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??cI(t)}),vb+=1,Gf=0,ka(o2)}function dI(){if(cC)return;cC=!0;const e=()=>{document.visibilityState==="hidden"||Ro||Yp()&&ka(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function ka(e){if(Yf){Pd=Pd===null?e:Math.min(Pd,e);return}Dv!==null||Ro||document.visibilityState==="hidden"||navigator.onLine===!1||(Dv=window.setTimeout(()=>{Dv=null,hI()},e))}async function hI(){if(Yf||Ro||document.visibilityState==="hidden"||navigator.onLine===!1)return;Yf=!0;const e=vb;try{const t=await RM();if(t.outcome==="auth_blocked"){Ro=!0;return}if(t.outcome==="retryable"){const n=lC[Math.min(Gf,lC.length-1)];Gf+=1,ka(n);return}if(Gf=0,t.outcome==="sent"&&t.hasMore){ka(0);return}}finally{Yf=!1;const t=Pd;Pd=null,t!==null&&ka(t),vb!==e&&!Ro&&ka(o2)}}function fI(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const s=kI(e,t);if(!s)return"rejected";const o=JSON.stringify(s),l=Na(o);if(l>K4)return"rejected";const d=n.durability!=="live-only"&&s.type!=="restore_screen",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:d};if(!TI(e,f))return"rejected";const m=e.socket,p=m?.readyState===WebSocket.OPEN;s.type==="input"&&d&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(Ra("terminal.input.foreground_resume",e,{terminalId:s.terminalId,pendingInputs:No(e)}),u2(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||(m?.bufferedAmount??0)>am))return s.type==="redraw"||s.type==="restore_screen"||!d?"rejected":pI(e,s)?(p&&m&&Bo(e,m),"queued"):e.pendingOut.length>=mb||e.pendingOutBytes+l>gb?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=l,pC(e,f),p&&m&&Bo(e,m),"queued");if(p){pC(e,f);try{return m.send(o),p2(e,f),"sent"}catch{if(_&&d&&e.pendingOut.length<mb&&e.pendingOutBytes+l<=gb)return e.pendingOut.push(f),e.pendingOutBytes+=l,m.close(),"queued";zl(e,f),m.close()}}return"rejected"}function Bo(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){ds(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>am){OI(e,t),vI(e,t);return}const s=e.pendingOut[0];if(s.message.type==="input"&&e.inputProtocolMode==="unknown"){h2(e,t);return}try{t.send(s.encoded),p2(e,s)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-s.bytes),e.outboundFlushDelayMs=Tp,n=!0}e.outboundFlushDelayMs=Tp,ds(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&Dl(e,{type:"outbound_flushed"})})}function pI(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let s=null;if(t.type==="resize"&&n.message.type==="resize")s=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const d=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(d===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;s={...t,lines:d}}}if(!s)return!1;const o=JSON.stringify(s),l=Na(o);return e.pendingOutBytes+=l-n.bytes,n.message=s,n.encoded=o,n.bytes=l,!0}function Io(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=Tp}function ds(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function Np(e){return e.pendingOut.some(t=>t.message.type==="input")}function mI(e){return Np(e)||e.unackedInputs.size>0}function gI(e){if(!Np(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 vI(e,t){e.outboundStallWatchdog!==null||!Np(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!Np(e))return;const n=e.inputProtocolMode==="unknown",s=t.bufferedAmount>am;if(!n&&!s){Bo(e,t);return}gI(e),Do(e)},G4))}function Os(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function h2(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)&&Do(e)},V4))}function f2(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function eh(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function Po(e){f2(e),eh(e)}function Il(e){f2(e),Sb(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=fC(e),s=_I(e),o=yI(e);if(n===null&&s===null&&o===null){eh(e);return}if(e.inputAckProbe)return;const l=n===null?Number.POSITIVE_INFINITY:n+q4,d=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(Sb(e,{notifyImmediately:!0})){Il(e);return}if(bI(e),fC(e)===null){Il(e);return}SI(e,t)},d)}function _I(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const s=n.receivedAt+a2;t=t===null?s:Math.min(t,s)}return t}function bI(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<a2||(n.writeSlowReported=!0,Ra("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function fC(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 yI(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const s=n.firstSentAt+s2;t=t===null?s:Math.min(t,s)}return t}function SI(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>am){Do(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++Q4).toString(36)}`;Ra("terminal.input.delivery_probe_started",e,{pendingInputs:No(e)});const s={socket:t,nonce:n,timeout:0};e.inputAckProbe=s,s.timeout=window.setTimeout(()=>{e.inputAckProbe!==s||e.socket!==t||(Ra("terminal.input.delivery_probe_timeout",e,{pendingInputs:No(e)}),eh(e),Do(e))},U4);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{eh(e),Do(e)}}function As(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Do(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Io(e),ds(e),Os(e),Po(e),As(e,"reconnecting"),zo(e);const t=e.socket;e.socket=null,wo(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ou(e)}function wI(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Io(e),ds(e),Os(e),Po(e),As(e,"skipped"),zo(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Xf(e),e.listeners.clear()}function xI(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function CI(){return Nv=(Nv+1)%Number.MAX_SAFE_INTEGER,`${eI}-${Nv.toString(36)}`.slice(0,Ck)}function kI(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:s,...o}=t;return o}const n=CI();return n.length===0||n.length>Ck?null:{...t,messageId:n}}function TI(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<mb&&e.unackedInputBytes+t.bytes<=gb)}function pC(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function zl(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 EI(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&&wb(e,t,l);return}if(zl(e,s),Il(e),!Vy(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),wb(e,t,o)}function RI(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",Il(e))}function NI(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(zl(e,n),Il(e))}function p2(e,t){if(t.message.type!=="input"||!t.message.messageId||!Vy(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",Il(e)}function DI(e){if(Sb(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){zl(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 Sb(e,t={}){const n=Date.now(),s=new Set;let o=0;for(const[l,d]of e.unackedInputs)d.firstSentAt!==null&&n-d.firstSentAt>=s2&&(s.add(l),d.durable&&(o+=1));if(s.size===0)return!1;e.pendingOut=e.pendingOut.filter(l=>{const d=l.message.type==="input"?l.message.messageId:void 0;return!d||!s.has(d)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-l.bytes),!1)});for(const l of s){const d=e.unackedInputs.get(l);d&&zl(e,d)}return o>0&&(v2(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&&qy(e)),!0}function MI(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function AI(e,t,n,s,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!s){m2(e,t);return}Os(e);const l=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,l===n?(DI(e),LI(e,t)):l!==null&&(g2(e),_2(e)),Bo(e,t)}function m2(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",Os(e),e.serverInstanceId=null,g2(e),_2(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;zl(e,n);const{messageId:s,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const l=Na(n.encoded);e.pendingOutBytes+=l-n.bytes,n.bytes=l}Bo(e,t)}}function g2(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&&zl(e,o)}n>0&&v2(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 v2(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function qy(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)Dl(e,{type:"message",message:{type:"error",message:n.message}})}}function Xf(e){Io(e),ds(e),Os(e),Po(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function wb(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Vy(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Vy(e){return e==="ack"||e==="receipt-ack"}function LI(e,t){for(const n of e.pendingAckReceipts.values())if(wb(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function jI(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function _2(e){e.pendingAckReceipts.clear()}function OI(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(Y4,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Bo(e,t)},n)}function Na(e){return J4.encode(e).byteLength}function BI(e,t){if(Na(e)<=t)return e;let n=0,s=e.length;for(;n<s;){const o=Math.floor((n+s)/2);Na(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 II=[0,50,150,350],Av=[100,300,750],mC=800,PI=[150,500],zI=2,HI=[300,1200,2500],UI=1e3,$I=1e5,FI="",WI=400,Lv=9,KI=9,qI=32,VI=1.42,YI=2,GI=24,XI=720,ZI=60,QI=1260,JI=6,e6=2,gC=[500,1500,3e3,5e3,8e3],vC=15e3,t6=2,n6=1e3,_C="Do not take action. Wait for my next input.",Dp=6e4,i6=Dp+5*6e4,bC=Dp+6e4,r6=40,Df=240,s6=5e3,Mp=new Map,Oc=new Map;function yC({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:o,refreshCwdOnEnter:l=!1,tabId:d,codeServerContext:f,onSelect:m,onClose:p,onExit:b,onSnapshot:_,onAuthClose:S}){const w=v.useSyncExternalStore(ST,d_,()=>El),x=v.useSyncExternalStore(wT,h_,()=>Gc),R=v.useSyncExternalStore(TT,g_,()=>!0),L=v.useSyncExternalStore(gd,v_,()=>!0),A=v.useSyncExternalStore(gd,__,()=>!0),W=v.useSyncExternalStore(gd,m_,()=>Fd),z=v.useSyncExternalStore(Zb,Mo,()=>Yc),H=v.useSyncExternalStore(jd,()=>Od("history.toggle"),()=>"Alt+H"),q=v.useSyncExternalStore(jd,()=>Od("scrollback.toggle"),()=>"Alt+S"),Y=v.useSyncExternalStore(jd,()=>Od("subagents.toggle"),()=>"Alt+A"),I=v.useRef(null),$=v.useRef(null),de=v.useRef(null),me=v.useRef(null),K=v.useRef(null),ne=v.useRef(e.id),ee=v.useRef({onExit:b,onSnapshot:_}),Z=v.useRef(t.createWebSocketUrl),X=v.useRef(S),M=v.useRef(null),T=v.useRef(null),O=v.useRef(null),re=v.useRef(!1),he=v.useRef(new Map),N=v.useRef(new Map),V=v.useRef(new Set),se=v.useRef(null),J=v.useRef(!1),xe=v.useRef(null),ye=v.useRef(null),Pe=v.useRef(!1),Fe=v.useRef(null),ze=v.useRef(0),ve=v.useRef(0),We=v.useRef([]),Oe=v.useRef(!1),j=v.useRef(null),ge=v.useRef(0),Me=v.useRef(!1),Le=v.useRef(!1),F=v.useRef(e.scrollbackMode),pe=v.useRef({codex:!1,speed:W}),Ce=v.useRef(null),Re=v.useRef(new Qx),je=v.useRef(!1),be=v.useRef({terminalId:e.id,enabled:!1}),Ue=v.useRef([]),$e=v.useRef([]),Be=v.useRef(0),ot=v.useRef(!1),ct=v.useRef(null),ht=v.useRef(0),jt=v.useRef(0),Qt=v.useRef(null),rt=v.useRef(null),Yn=v.useRef(!1),_n=v.useRef(!1),pt=v.useRef(!1),Et=v.useRef(null),Nt=v.useRef(!1),Di=v.useRef(null),Gn=v.useRef(null),nn=v.useRef(!1),fn=v.useRef(!1),te=v.useRef(!1),Ke=v.useRef(!1),et=v.useRef(Number.NEGATIVE_INFINITY),bt=v.useRef(Number.NEGATIVE_INFINITY),Pt=v.useRef(!1),bn=v.useRef(!1),Ft=v.useRef(new Set),pn=v.useRef(new Set),Jt=v.useRef(!1),Dt=v.useRef(!1),yn=v.useRef(!1),Sn=v.useRef(!1),Dn=v.useRef(n),rn=v.useRef(s),ft=v.useRef(l),wt=v.useRef(w),wn=v.useRef(x),oe=v.useRef(!1),ke=v.useRef(!1),Xe=v.useRef(null),qe=v.useRef(null),nt=v.useRef(0),sn=v.useRef(0),On=v.useRef(e.id),dr=v.useRef(()=>{}),Xt=v.useRef(null),Xi=v.useRef(null),Mn=v.useRef(!1),Bn=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),hr=v.useRef(0),Ci=v.useRef(null),an=v.useRef(0),Zi=v.useRef(null),ms=v.useRef(!1),fr=v.useRef(null),Mi=v.useRef(0),Fl=v.useRef(!1),Aa=v.useRef(!1),Xn=v.useRef(null),Rr=v.useRef(null),[Bs,pr]=v.useState("connecting"),[ri,ki]=v.useState(null),Qi=v.useRef(null),Ho=v.useRef(null),La=v.useRef(()=>!1),zi=v.useRef(null);zi.current||(zi.current=new M4({getTarget:()=>Qi.current,send:k=>La.current(k),onState:ki}));const[ja,Is]=v.useState(!1),[mi,Ps]=v.useState(null),[Wl,Nr]=v.useState(!1),[Dr,Oa]=v.useState(null),[Uo,Jr]=v.useState(!1),[lu,$o]=v.useState(!1),[Kl,Ai]=v.useState(!1),[ql,zs]=v.useState(!1),[Hs,Li]=v.useState(!1),[on,Mr]=v.useState(null),[es,Ar]=v.useState([]),Us=v.useRef([]),si=e.agentCache&&on&&e.agentCache.source.provider===on.provider&&e.agentCache.source.sessionId===on.sessionId?e.agentCache:null,[Ba,$s]=v.useState(()=>Date.now()),[Ti,gs]=v.useState(!1),[Fs,Ji]=v.useState(null),[Ws,ts]=v.useState(!1),[Ia,Lr]=v.useState(!1),[ai,Ks]=v.useState(null),[xn,Hi]=v.useState(!1),[mt,er]=v.useState(!1),[Fo,mr]=v.useState(null),[qs,vs]=v.useState(null),[Pa,za]=v.useState(!1),jr=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[cu,Wo]=v.useState(()=>tv(e.id)),Ui=on?.provider??e.agentStatus?.provider??null,Vl=xl(e.currentCommand)||kC(e.currentCommand)&&Ui!==null,Ko=e.agentStatus?.sessionId??on?.sessionId??null,Yl=Ui!==null||xl(e.currentCommand),Vs=Ui==="claude"||kb(e.currentCommand),Gl=Ui!==null||xl(e.currentCommand),ji=e.capabilities?.tmuxScrollback===!0,oi=ji&&(cu??(Gl?A:L)),[Vo,Xl]=v.useState(!1);v.useLayoutEffect(()=>{La.current=k=>nr(k,{liveOnly:!0})==="sent"}),v.useLayoutEffect(()=>(Ho.current=null,Qi.current=n&&s&&e.status==="running"?{api:t,terminalId:e.id,supportsImages:Vl}:null,()=>{Qi.current=null,zi.current?.cancel()}),[t,e.id,e.pid,e.status,e.currentCommand,Vl,n,s,Bs]),v.useLayoutEffect(()=>{const k=Qi.current;if(!k||Ko===null)return;const P=Ho.current;Ho.current=Ko,P!==null&&P!==Ko&&(Qi.current={...k},zi.current?.pending&&zi.current.cancel("Image paste canceled because the active session changed."))}),v.useLayoutEffect(()=>{(!n||!s||!Vo||e.status!=="running")&&Wt(!1)},[n,s,Vo,e.status]),v.useLayoutEffect(()=>{Dn.current=n},[n]),v.useLayoutEffect(()=>{rn.current=s},[s]),v.useLayoutEffect(()=>{ft.current=l},[l]),v.useLayoutEffect(()=>{wt.current=w},[w]),v.useLayoutEffect(()=>{wn.current=x},[x]),v.useLayoutEffect(()=>{oe.current=Ws},[Ws]),v.useLayoutEffect(()=>{ke.current=Ia},[Ia]),v.useLayoutEffect(()=>{qe.current=on},[on]);const gr=v.useCallback((k,P={})=>{!k&&P.preserveOnNull||(Vx(qe.current,k)||(sn.current+=1),qe.current=k,Mr(Ae=>Ae&&k&&Ae.provider===k.provider&&Ae.sessionId===k.sessionId?Ae:k))},[]),Zl=v.useCallback(async()=>{const k=await t.getTerminalTranscriptSource(e.id);return On.current===e.id&&(Us.current=k.candidates??[],Ar(k.candidates??[])),k.source},[t,e.id]),Yo=v.useCallback(()=>{Lr(!1),ts(!0)},[]),Ha=v.useCallback(()=>{qe.current&&(ts(!1),Lr(!0))},[]),ns=v.useCallback(async(k={})=>{const P=await wC(jr,t,k);return Ks(P),P},[jr,t]),is=v.useCallback((k,P="info")=>{Zi.current!==null&&window.clearTimeout(Zi.current),vs({id:an.current++,message:k,tone:P}),Zi.current=window.setTimeout(()=>{vs(null),Zi.current=null},3200)},[]),Go=v.useCallback(()=>{if(ms.current)return;ms.current=!0;const k=jr,P=f?.serverName.trim()||"Local",Ae=f?.tabName.trim()||e.title||"Terminal",Je=fr.current,Ze=Je?.terminalId===e.id&&Je.requestedCwd===e.cwd?Je.instance:ai?.instances.find(dt=>dt.cwd===e.cwd),lt=Ze?xC(k,Ze.id):null,{handle:Ht,ownsPopup:Ot}=a6(lt);Ot&&d6(Ht);const st=()=>{Ot&&h6(Ht)};er(!0),mr(null),(async()=>{let dt=ai;if(dt?.installed||(dt=await ns({force:!0})),!dt?.installed||dt.supported===!1){st(),Hi(!0);return}return t.openCodeServer({terminalId:e.id,serverName:P,tabName:Ae})})().then(dt=>{if(!dt)return;fr.current={terminalId:e.id,requestedCwd:e.cwd,instance:dt.instance},xb(jr,dt.status),Ks(dt.status);const Ut=xC(k,dt.instance.id),$t=b2(Ut);if($t?.createdAt===dt.instance.createdAt&&l6($t.handle,dt.instance.url)){Gy($t.handle),Ht!==$t.handle&&st(),is("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}const $n=$t?.handle??(Ot||lt===Ut?Ht:null);if(u6($n,Ut,dt.url,dt.instance.createdAt))Ht!==$n&&st(),is("Opening VS Code...");else{const Hr=c6(Ut,dt.url,dt.instance.createdAt);Ht!==Hr&&st(),Hr?is("Opening VS Code..."):is("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}}).catch(async dt=>{st(),dt instanceof Vn&&dt.message==="code_server_not_installed"&&await ns({force:!0}).catch(()=>{}),Hi(!0),mr(Mf(dt))}).finally(()=>{ms.current=!1,er(!1)})},[f?.serverName,f?.tabName,jr,ai,ns,t,is,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return wC(jr,t).then(P=>{k||Ks(P)}).catch(()=>{}),()=>{k=!0}},[jr,t]),v.useEffect(()=>{if(ai?.job?.status!=="running")return;const k=window.setInterval(()=>{ns({force:!0}).catch(P=>mr(Mf(P)))},1e3);return()=>window.clearInterval(k)},[ai?.job?.status,ns]),v.useEffect(()=>()=>{Zi.current!==null&&window.clearTimeout(Zi.current)},[]),v.useLayoutEffect(()=>{dr.current=Yo},[Yo]),v.useLayoutEffect(()=>{Xi.current=si},[si]),v.useLayoutEffect(()=>{Mn.current=Ti},[Ti]),v.useLayoutEffect(()=>{Fl.current=Yl},[Yl]),v.useLayoutEffect(()=>{Aa.current=Vs},[Vs]),v.useLayoutEffect(()=>{const k=be.current;Le.current=oi,je.current=ji,be.current={terminalId:e.id,enabled:oi},TC(I.current,oi);const P=Re.current.setMouseEnabled(oi);P&&$.current?.write(P),k.terminalId===e.id&&k.enabled&&!oi&&as(),oi||Ai(!1)},[e.id,oi,ji]),v.useLayoutEffect(()=>{F.current=e.scrollbackMode,e.scrollbackMode&&Ai(e.scrollbackMode==="copy")},[e.id,e.scrollbackMode]),v.useLayoutEffect(()=>{pe.current={codex:!kb(e.currentCommand)&&(Ui==="codex"||Cb(e.currentCommand)),speed:W}},[Ui,e.currentCommand,W]),v.useEffect(()=>{Wo(tv(e.id)),ge.current=0,Me.current=!1,Ai(!1),al()},[e.id]),v.useEffect(()=>gd(()=>{Wo(tv(e.id))}),[e.id]),v.useEffect(()=>()=>{Cu()},[]),v.useEffect(()=>{K.current?.(s&&e.status==="running"),s&&e.status==="running"?E():Q()},[s,e.id,e.status]),v.useEffect(()=>{s&&n&&e.status==="running"&&_r("auto")},[n,s,e.status]),v.useEffect(()=>{ee.current={onExit:b,onSnapshot:_}},[b,_]),v.useLayoutEffect(()=>{Z.current=t.createWebSocketUrl,X.current=S},[t,S]),v.useLayoutEffect(()=>{ne.current=e.id,yn.current=!1,zs(!1),Wt(!1)},[e.id]),v.useEffect(()=>{let k=!1,P=null,Ae=0;const Je=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ze=Je||kC(e.currentCommand),lt=Je||xl(e.currentCommand);function Ht(){P!==null&&(window.clearTimeout(P),P=null)}function Ot(dt){if(k)return;let Ut;if(dt)Ut=vC;else if(Ae<gC.length){if(!Ze)return;Ut=gC[Ae++]}else{if(!lt)return;Ut=vC}P=window.setTimeout(()=>{P=null,st()},Ut)}async function st(){try{const dt=qe.current!==null,Ut=await Zl();if(k)return;if(Ut){nt.current=0,gr(Ut),Ot(!0);return}nt.current+=1;const $t=!!(dt&&Ze&&nt.current<t6);gr(null,{preserveOnNull:$t}),Ot($t)}catch(dt){if(k)return;Ov(dt)&&gr(null),Ot(!1)}}return On.current!==e.id&&(Us.current=[],Ar([]),On.current=e.id,sn.current+=1,qe.current=null,nt.current=0,Mr(null)),e.status!=="running"?(sn.current+=1,qe.current=null,nt.current=0,Mr(null),()=>{k=!0,Ht()}):(st(),()=>{k=!0,Ht()})},[gr,Zl,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=m6(e.id,on),P=Xt.current;P!==null&&k!==null&&P!==k&&(rt.current=null,Yn.current=!1,_n.current=!1,Lr(!1)),Xt.current=k},[e.id,on?.provider,on?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!on){gs(!1);return}const k=window.setInterval(()=>{$s(Date.now())},n6);return()=>{window.clearInterval(k)}},[e.status,on?.provider,on?.sessionId]),v.useEffect(()=>{const k=p6(si);Bn.current.key!==k&&(Bn.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[si?.expiresAt,si?.source?.provider,si?.source?.sessionId]),v.useEffect(()=>{if(!Ti||!si||si.status!=="ready")return;const k=S2(si,Ba);if(k===null||k<=0)return;const P=Bn.current;!P.warnedFiveMinutes&&k<=i6&&k>bC&&(P.warnedFiveMinutes=!0,Ir({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!P.warnedOneMinute&&k<=bC&&k>Dp&&(P.warnedOneMinute=!0,Ir({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!P.sent&&!P.skipped&&k<=Dp&&na()},[Ti,Ba,si,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(P){if(!Dn.current||!rn.current||P.isComposing||P.key==="Process"||_6(P.target))return;const Ae=DT(P);if(Ae?.id==="history.toggle"&&(qe.current||Us.current.length)){P.preventDefault(),P.stopPropagation(),oe.current?ts(!1):dr.current();return}if(Ae?.id==="subagents.toggle"&&qe.current){P.preventDefault(),P.stopPropagation(),ke.current?Lr(!1):Ha();return}if(Ae?.id==="scrollback.toggle"&&je.current){P.preventDefault(),P.stopPropagation(),ys();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=$.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&pr("closed")},[e.status]),v.useEffect(()=>{const k=$.current;k&&(k.options.fontSize=w,ev(w,wn.current).then(()=>{wt.current===w&&gi()}))},[w]),v.useEffect(()=>{const k=$.current;k&&(k.options.fontFamily=u_(x),ev(wt.current,x).then(()=>{wn.current===x&&gi()}))},[x]),v.useEffect(()=>{const k=$.current;k&&(k.options.theme=SC(z))},[z]),v.useEffect(()=>{const k=I.current;if(!k)return;let P=!1,Ae=null,Je=null,Ze=null,lt=null,Ht=null,Ot=null,st=null,dt=null,Ut=null,$t=null;M.current=null,et.current=Number.NEGATIVE_INFINITY,bt.current=Number.NEGATIVE_INFINITY,Pt.current=!1,ec(),Jt.current=!1,Dt.current=!1,Nt.current=!1,hu(),vh(),J.current=!1,Pe.current=!1,ze.current=0,ve.current=0,Ys(),Oe.current=!1;const $n=wt.current,Hr=wn.current,Fn=new PB({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:u_(Hr),fontSize:$n,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:$I,theme:{...SC(Mo())}}),ia=new Nj;return Fn.loadAddon(ia),Ht=j4(Fn),$.current=Fn,de.current=ia,ev($n,Hr).then(()=>{if(P)return;Fn.open(k),TC(k,Le.current),Jt.current=!0,lt=Fn.onRender(()=>{const mn=se.current;mn!==null&&(se.current=null,nl("painted",{elapsedMs:Date.now()-mn}))}),Ae=y4(Fn,{onPasteText:zr,onPasteFiles:mn=>{zi.current?.paste(mn)},canPaste:()=>Qi.current!==null,onInterrupt:Pr,shouldInterruptPlainCtrlC:()=>Aa.current}),rn.current&&Dn.current&&e.status==="running"&&_r("auto"),gi(),dt=P6(k,{markIntent:vu,markKeyboardIntent:Zs,setPointerScrollActive:mn=>{Pt.current=mn}}),Ot=K6(k,Fn,()=>wt.current*1.2,Ka,mn=>{rs(mn)},$i,Va,()=>Le.current,ac,Fi,Ss),st=$6(k,Fn,Ka,mn=>{rs(mn)},$i,Va,()=>Le.current,ac);const lc=new p5;Je=Fn.onData(mn=>{if(b5(mn)){ir(mn);return}if(yn.current){const ll=S5(mn);if(ll){In(!1),nr(ll);return}}const Zn=lc.accept(mn);Zn&&nr(Zn)}),Ze=Fn.onScroll(mn=>{if(fn.current||Ke.current||te.current){Vt();return}if(Le.current){if(!Jl()){bu(Fn);return}}else if(!Qs()){if(!nn.current||qr(Fn)){nn.current=!1,bu(Fn);return}Vt(),mn<=3&&rs();return}pu(),qr(Fn)&&Or({scrollToBottom:!0}),Ka(),!Le.current&&mn<=3&&rs()}),Ut=Fn.onResize(()=>{tc(_u(Fn))}),$t=new ResizeObserver(()=>{Ve()}),$t.observe(k),Dt.current&&($a(),Dt.current=!1,gi()),Jo()}),()=>{wu(me.current,{updateUi:!1}),P=!0,Jt.current=!1,Dt.current=!1,hu(),vh(),Q(),Fe.current!==null&&window.clearTimeout(Fe.current),Fe.current=null,Pe.current=!1,T.current=null,O.current=null,re.current=!1,_h(),Oe.current=!1,fu(),te.current=!1,ot.current=!1,ht.current+=1,jt.current+=1,ct.current=null,Xn.current=null,Rr.current=null,pt.current=!1,Et.current=null,Is(!1),Ot?.(),st?.(),dt?.(),Ut?.dispose(),ec(),Pt.current=!1,$t?.disconnect(),Ae?.dispose(),Je?.dispose(),Ze?.dispose(),lt?.dispose(),Ht?.dispose(),Fn.dispose(),$.current=null,de.current=null}},[e.id]),v.useEffect(()=>{const k=Z.current(e.id),P=tI(k,uu);return me.current=P.send,K.current=P.setForeground,P.setForeground(rn.current&&e.status==="running"),pr(P.status),P.status==="connected"&&gi(),P.snapshot&&(J.current=P.snapshot.capabilities?.screenRedraw===!0,ee.current.onSnapshot(P.snapshot,{notifyCompletion:!1}),$.current&&(gi(),Ua(P.output,P.history),gi())),()=>{wu(P.send,{updateUi:!1}),P.setForeground(!1),P.detach(),me.current=null,K.current=null}},[e.id,e.status]);function uu(k){if(k.type==="resume"){E();return}if(k.type==="status"){pr(k.status),k.status==="unauthorized"&&X.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(gi(),el());return}if(k.type==="upgrade_rejected"){X.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){Wa(),Oe.current&&(Oe.current=!1,ku());return}le(k.message)}function Ys(k=[],P=null){Ue.current=[],$e.current=k.filter(Boolean),Be.current=0,ot.current=!1,ct.current=null,te.current=!1,ht.current+=1,Qt.current=P,rt.current=null,Yn.current=!1,_n.current=!1,pt.current=!1,Et.current=null,Dt.current=!1,Xn.current=null,Rr.current=null,Di.current=null,nn.current=!1,Is(!1),Ps(null),Nr(!1),Oa(null),Jr(!1),$o(!1)}function Ua(k=[],P=null){if(te.current||ot.current){Rr.current={output:k,history:P,appendFromLiveOutputIndex:$e.current.length};return}Ys(k,P),vr()}function Xo(){if(te.current||ot.current)return!1;const k=Rr.current;if(!k)return!1;const P=$e.current.slice(k.appendFromLiveOutputIndex);return Rr.current=null,Ys([...k.output,...P],k.history),vr(),!0}function vr(){if(!$.current||!Jt.current){Dt.current=!0;return}Dt.current=!1,$a()}async function $a(){const k=$.current;if(!k)return;const P=Br(k),Ae=P?$e.current.length:Be.current,Je=await Zo(k,{liveOutputLimit:Ae,scrollToBottom:P});$.current===k&&(Vt(),Je&&(Pe.current=!0,ze.current=0,Wa(),el()))}function Zo(k,P={}){return new Promise(Ae=>{te.current=!0,ot.current=!1;const Je=ht.current+1;ht.current=Je;const Ze=Math.max(0,Math.min(P.liveOutputLimit??$e.current.length,$e.current.length)),lt=P.historyPages??Ue.current,Ht=()=>$.current===k&&ht.current===Je,Ot=()=>Ht()&&(P.isCurrent?.()??!0),st=()=>{Ht()&&(te.current=!1),Ae(!1)},dt=()=>{if(!Ot()){st();return}try{Be.current=Ze,P.scrollToBottom&&li(k)}finally{if(te.current=!1,Xo()){Ae(!1);return}const $t=Ql();$t?Or($t):P.applyDeferredSnapshot!==!1&&rl(),Ae(!0)}};(()=>{if(!Ot()){st();return}k.clear(),Re.current=new Qx(Le.current);const $t=[...lt,...$e.current.slice(0,Ze)].filter(Boolean);if($t.length===0){dt();return}for(let $n=0;$n<$t.length;$n+=1){const Hr=yu($t[$n]);$n===$t.length-1?k.write(Hr,dt):k.write(Hr)}})()})}async function rs(k=0){const P=$.current;if(pt.current||!P||P.buffer.active.type==="alternate")return;if(_s(P)){Vt();return}const Ae=Qt.current,Je=jt.current,Ze=Symbol("history-load"),lt=()=>$.current===P&&jt.current===Je;Et.current=Ze,pt.current=!0,Is(!0);const Ht=P.buffer.active.viewportY;try{let Ot=!!(Ae&&!Ae.hasMore);if(!Ot)try{const st=await t.getTerminalHistory(e.id,{beforeLine:Ae?.startLine??0,...Ae?.snapshotHistorySize!==void 0?{snapshotHistorySize:Ae.snapshotHistorySize}:{},...Ae?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ae.snapshotHistoryLimit}:{},...Ae?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ae.snapshotHistoryToken}:{},...Ae?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ae.snapshotPaneWidth}:{},limit:UI});if(!lt()||Qt.current!==Ae)return;const dt=()=>lt()&&Qt.current===Ae;if(st.invalidated){B();return}const Ut=st.hasMore&&st.snapshotHistorySize!==void 0&&st.snapshotPaneWidth!==void 0,$t={startLine:st.startLine,endLine:st.endLine,hasMore:Ut,...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 C(P,st.output,Ht,k)&&dt()&&(Qt.current=$t);return}if(!dt())return;Qt.current=$t,Ot=!Ut}catch(st){Ot=lt()&&Ov(st)}if(Ot){if(!lt()||_s(P)){Vt();return}await Gs(P,Ht,k,lt)}}catch{}finally{Et.current===Ze&&(Et.current=null,pt.current=!1,Is(!1))}}async function Gs(k,P,Ae,Je){if(!Je()||Yn.current||_n.current)return;const Ze=qe.current,lt=sn.current,Ht=rt.current,Ot=()=>Je()&&sn.current===lt&&Vx(Ze,qe.current)&&rt.current===Ht;try{const st=await t.getTerminalTranscriptHistory(e.id,{...Ht?{cursor:Ht}:{},limit:WI}),dt=st.output.map(zy);if(!st.source||st.terminalId!==e.id||!Ot())return;if(Ze&&!Ca(Ze,st.source)){rt.current=null,Yn.current=!1,_n.current=!1,gr(st.source);return}if(dt.length===0){gr(st.source),rt.current=st.cursor,_n.current=!st.hasMore||!st.cursor;return}await C(k,dt,P,Ae,Ot)&&Ot()&&(gr(st.source),rt.current=st.cursor,_n.current=!st.hasMore||!st.cursor)}catch(st){Ot()&&Ov(st)&&(Yn.current=!0)}}async function C(k,P,Ae,Je,Ze){if(_s(k)||Ze&&!Ze())return Vt(),!1;const lt=Ue.current,Ht=[...P,...lt],Ot=O6(P),st=ht.current+1,dt=await Zo(k,{liveOutputLimit:Be.current,scrollToBottom:!1,historyPages:Ht,applyDeferredSnapshot:!1,...Ze?{isCurrent:Ze}:{}}),Ut=Ze!==void 0&&!Ze();return!dt||Ut||$.current!==k?(Ut&&$.current===k&&ht.current===st&&await Zo(k,{liveOutputLimit:Be.current,scrollToBottom:!1,historyPages:lt,applyDeferredSnapshot:!1})&&$.current===k&&(Js(k,Ae),nn.current=!qr(k),Ka()),!1):(Ue.current=Ht,Js(k,Math.max(0,Ae+Ot+Math.min(0,Je))),nn.current=!qr(k),Ka(),!0)}v.useEffect(()=>{const k=window.visualViewport;function P(){document.visibilityState!=="hidden"?E():Q()}function Ae(){E()}function Je(){E()}function Ze(){Ve()}function lt(){_t()}return document.addEventListener("visibilitychange",P),document.addEventListener("resume",Ae),window.addEventListener("pageshow",Ae),window.addEventListener("focus",Ae),window.addEventListener("online",Je),window.addEventListener("resize",Ze),window.addEventListener(Cp,lt),k?.addEventListener("resize",Ze),k?.addEventListener("scroll",Ze),()=>{document.removeEventListener("visibilitychange",P),document.removeEventListener("resume",Ae),window.removeEventListener("pageshow",Ae),window.removeEventListener("focus",Ae),window.removeEventListener("online",Je),window.removeEventListener("resize",Ze),window.removeEventListener(Cp,lt),k?.removeEventListener("resize",Ze),k?.removeEventListener("scroll",Ze)}},[e.id]);function E(){if(document.visibilityState==="hidden"||!rn.current)return;el(),Ve();const k=$.current;k&&Jt.current&&tc(_u(k)),Wa()}function B(){if(xe.current)return;const k=Z.current(e.id);if(xe.current={requestId:crypto.randomUUID(),startedAt:Date.now(),snapshotReady:!1,sent:!1},za(!0),al(),ge.current=0,jt.current+=1,Nt.current=!0,Xn.current=null,pr("reconnecting"),gi(),!nI(k)){Q("Could not reconnect this pane. Try reloading again.");return}ye.current=window.setInterval(ae,100)}function Q(k){xe.current=null,ye.current!==null&&window.clearInterval(ye.current),ye.current=null,za(!1),k&&is(k,"error")}function ae(){const k=xe.current;if(!k)return;if(!rn.current||document.visibilityState==="hidden"){Q();return}if(Date.now()-k.startedAt>=15e3){Q("Pane recovery timed out. Check the connection and try again.");return}const P=$.current;k.sent||!k.snapshotReady||!P||!Jt.current||he.current.size>0||te.current||Xn.current||Rr.current||(k.sent=ss({type:"restore_screen",terminalId:e.id,requestId:k.requestId,cols:P.cols,rows:P.rows},{durability:"live-only"})==="sent")}function le(k){if(k.type==="snapshot"&&k.terminal.id===e.id){J.current=k.terminal.capabilities?.screenRedraw===!0;const Ae=xe.current;Ae&&(k.terminal.capabilities?.screenRestore===!0?(Ae.snapshotReady=!0,Ae.sent=!1):Q("This server does not support live-screen recovery. Update the server and try again.")),jt.current+=1,ee.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Je=Nt.current;Nt.current=!1;const Ze=$.current;if(!Ze)return;if(gi(),Je){Te(k.output,k.history??null);return}if(gu(Ze,k.terminal)){yh(k.output,k.history??null),Vt(),gi();return}Ua(k.output,k.history??null),gi();return}if(k.type==="restore_screen_result"&&k.terminalId===e.id){if(xe.current?.requestId!==k.requestId)return;k.ok&&(Me.current=!1,Ai(!1),nn.current=!1,Pe.current=!1,ve.current=Date.now(),Or({force:!0,scrollToBottom:!0}),el()),Q(k.ok?void 0:"Could not restore the live pane screen. Try reloading again.");return}if(k.type==="redraw_result"&&k.terminalId===e.id){nl("redraw_result",{ok:k.ok});return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){ee.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Ae=k.data;if(!Ae)return;$e.current.push(Ae),$.current&&Jt.current?Or({scrollToBottom:!0}):Dt.current=!0;return}const P=$.current;if(P){if(k.type==="exit"&&k.terminalId===e.id){ee.current.onExit(k.exitCode),pr("closed");return}k.type==="error"&&P.writeln(`\r
|
|
52
|
-
[nterminal] ${k.message}`)}}function Te(k,P){Ua(k,P),gi()}function Ie(k=25){if(document.visibilityState==="hidden"||!rn.current||he.current.has(k))return;const P=window.setTimeout(()=>{he.current.delete(k),!Ge()&&Sh()},k);he.current.set(k,P)}function Ve(){Ge()||Jo()}function Ge(){const k=kn();return k&&Cn(k)?(re.current=!0,O.current=k,!0):k&&Rt(k)?(re.current=!1,O.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(re.current=!1,O.current=null),!1)}function _t(){if(!re.current)return;const k=kn();k&&(k.composeOpen||k.keyboardVisible)||(re.current=!1,O.current=null)}function Cn(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const P=T.current;return P?Xs(k.windowWidth,P.windowWidth)&&Xs(k.visualViewportWidth,P.visualViewportWidth)&&Xs(k.containerWidth,P.containerWidth):!1}function Rt(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const P=O.current;return!P||!P.composeOpen&&!P.keyboardVisible?!1:Xs(k.windowWidth,P.windowWidth)&&Xs(k.visualViewportWidth,P.visualViewportWidth)&&Xs(k.containerWidth,P.containerWidth)}function kn(){const k=I.current;if(!k||k.isConnected===!1)return null;const P=k.getBoundingClientRect(),Ae=Qo(window.innerWidth)??0,Je=Qo(window.visualViewport?.width)??Ae,Ze=Qo(P.width)??Qo(k.clientWidth)??Ae;if(Ae<=0||Je<=0||Ze<=0)return null;const{keyboardVisible:lt}=db(),Ht=document.documentElement.hasAttribute(im),Ot=du()||lt;return{windowWidth:Ae,visualViewportWidth:Je,containerWidth:Ze,composeOpen:Ht,keyboardVisible:lt,mobileLike:Ot}}function du(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Fa(){return db().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Qo(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function Xs(k,P){return Math.abs(k-P)<=zI}function Jo(){for(const k of II)Ie(k)}function gi(){M.current=null,Jo()}function el(){if(se.current===null&&rn.current&&document.visibilityState!=="hidden"&&(se.current=Date.now(),nl("requested")),tl(),V.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{V.current.delete(k),tl();const P=window.requestAnimationFrame(()=>{V.current.delete(P),tl()});V.current.add(P)});V.current.add(k)}for(const k of Av){if(N.current.has(k))continue;const P=window.setTimeout(()=>{N.current.delete(k),tl(),k===Av[Av.length-1]&&se.current!==null&&(nl("timeout",{elapsedMs:Date.now()-se.current}),se.current=null)},k);N.current.set(k,P)}}function tl(){const k=$.current;if(!(!k||!Jt.current||document.visibilityState==="hidden"||!rn.current||I.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function hu(){for(const k of he.current.values())window.clearTimeout(k);he.current.clear()}function vh(){se.current=null;for(const k of N.current.values())window.clearTimeout(k);N.current.clear();for(const k of V.current)window.cancelAnimationFrame(k);V.current.clear()}function nl(k,P={}){const Ae=$.current;uI(Z.current(e.id),k,{visible:rn.current,cols:Ae?.cols??0,rows:Ae?.rows??0,viewportY:Ae?.buffer.active.viewportY??0,baseY:Ae?.buffer.active.baseY??0,pendingChunks:$e.current.length-Be.current,replaying:te.current,tmuxScrollback:Le.current,userScrolledAway:nn.current,...P})}function Wa(){if(xe.current)return;const k=$.current;if(!Pe.current||!J.current||!k||!Jt.current||!rn.current||document.visibilityState==="hidden"||te.current||ot.current||Xn.current||Rr.current||!Br(k))return;const P=1100-(Date.now()-ve.current);if(P>0){Fe.current===null&&(Fe.current=window.setTimeout(()=>{Fe.current=null,Wa()},P));return}ss({type:"redraw",terminalId:e.id},{durability:"live-only"})==="sent"?(Pe.current=!1,ve.current=Date.now(),nl("redraw_sent")):Fe.current===null&&ze.current<4&&(ze.current+=1,Fe.current=window.setTimeout(()=>{Fe.current=null,Wa()},250))}function _h(){for(const k of We.current)window.clearTimeout(k);We.current=[]}function Ka(){if(Vt(),!Di.current){Nr(!1);return}Nr(!0),fu(),Gn.current=window.setTimeout(()=>{Gn.current=null,Nr(!1)},1200)}function Vt(){const k=$.current,P=k?B6(k):null;if(Di.current=P,Ps(P),$o(!!(k&&P)),Jr(!!(k&&P&&!qr(k))),P||!k||!il()){Oa(null);return}Oa({alternate:k.buffer.active.type==="alternate"})}function il(){const k=Qt.current;return Ue.current.length>0||!!k?.hasMore}function fu(){Gn.current!==null&&(window.clearTimeout(Gn.current),Gn.current=null)}function pu(){const k=$.current;k&&(nn.current=!qr(k),Vt())}function mu(k){ct.current=Bv(ct.current,k)}function bh(k){const P=ct.current;return ct.current=null,Bv(P,k)}function Ql(){const k=ct.current;return ct.current=null,k}function Or(k={}){const P=$.current;if(!P||!Jt.current){Dt.current=!0;return}if(Xn.current&&!te.current&&!ot.current&&qa(P)){rl();return}if(te.current){mu(k);return}if(ot.current){mu(k);return}const Ae=bh(k);if(nc(P),!Ae.force&&!Br(P)){Vt();return}ot.current=!0;const Je=ht.current,Ze=()=>{if($.current!==P||ht.current!==Je)return;if(nc(P),!Ae.force&&!Br(P)){if(ot.current=!1,Xo())return;Vt();return}const lt=Be.current,Ht=$e.current[lt];if(Ht===void 0){if(ot.current=!1,Xo())return;Ae.scrollToBottom&&li(P),nc(P),Vt();const Ot=Ql();Ot?Or(Bv(Ae,Ot)):(rl(),Wa());return}P.write(yu(Ht),()=>{$.current!==P||ht.current!==Je||(Be.current=lt+1,Ze())})};Ze()}function _s(k){return Xn.current!==null||!qa(k)&&(ic()||ot.current||te.current)}function gu(k,P){return(P?.agentStatus?.provider==="codex"||P?.agentStatus?.provider==="claude"||Fl.current||xl(P?.currentCommand))&&!qa(k)}function Br(k){return Le.current||I6(k,nn.current)}function qa(k){return Le.current||qr(k)}function vu(){et.current=performance.now()}function Zs(){const k=performance.now();et.current=k,bt.current=k}function Qs(){return Pt.current||performance.now()-et.current<=mC}function Jl(){return Pt.current||performance.now()-bt.current<=mC}function _u(k){return Br(k)}function bs(k){li(k),nn.current=!1,Vt(),(ic()||Xn.current)&&Or({scrollToBottom:!0})}function bu(k){bn.current||(bn.current=!0,queueMicrotask(()=>{bn.current=!1,!($.current!==k||!Jt.current||te.current||Ke.current||fn.current)&&((Le.current?Jl():nn.current||Qs())||bs(k))}))}function ec(){for(const k of Ft.current)window.cancelAnimationFrame(k);Ft.current.clear();for(const k of pn.current)window.clearTimeout(k);pn.current.clear()}function tc(k){ec();const P=performance.now(),Ae=()=>dm(k,P);if(typeof window.requestAnimationFrame=="function"){const Je=Ft.current,Ze=window.requestAnimationFrame(()=>{Je.delete(Ze),Ae();const lt=window.requestAnimationFrame(()=>{Je.delete(lt),Ae()});Je.add(lt)});Je.add(Ze)}for(const Je of PI){const Ze=window.setTimeout(()=>{pn.current.delete(Ze),Ae()},Je);pn.current.add(Ze)}}function dm(k,P){const Ae=$.current;if(!(!Ae||!Jt.current||te.current||Ke.current)){if(Le.current){if(Pt.current||bt.current>=P)return}else if(!k||Pt.current||et.current>=P)return;qr(Ae)&&!nn.current&&!ic()&&!Xn.current||bs(Ae)}}function nc(k){Le.current&&(li(k),nn.current=!1)}function ic(){return Be.current<$e.current.length}function yu(k){return Re.current.write(k)}function yh(k,P){Xn.current={output:k,history:P,appendFromLiveOutputIndex:$e.current.length}}function rl(){const k=$.current,P=Xn.current;if(!k||!P||!qa(k)||ot.current||te.current)return;const Ae=P.output,Je=$e.current.slice(P.appendFromLiveOutputIndex);Xn.current=null,Ua([...Ae,...Je],P.history),gi()}function $i(){vu(),Ke.current=!0}function Va(){pu(),Ke.current=!1;const k=$.current;k&&qr(k)&&Or({scrollToBottom:!0})}function li(k){rc(()=>EC(k))&&(nn.current=!1)}function Js(k,P){rc(()=>(k.scrollToLine(P),!0))}function rc(k){fn.current=!0;try{return k()}finally{fn.current=!1}}function sc(){const k=$.current;if(!k)return;Le.current&&(ol(me.current),Ai(!1)),EC(k),nn.current=!1,Vt(),Or({force:!0,scrollToBottom:!0}),_r("scroll-action")}function sl(k){const P=$.current,Ae=I.current;if(!P||!Ae)return;const Je=Ae.getBoundingClientRect();if(Je.height<=0)return;const Ze=Math.max(0,Math.min(1,(k-Je.top)/Je.height)),lt=Math.round(P.buffer.active.baseY*Ze);$i();try{P.scrollToLine(lt)}finally{Va()}nn.current=!qr(P),Vt(),Ka(),lt<=3&&rs()}function Su(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),sl(k.clientY)}function ea(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),sl(k.clientY))}function Sh(){const k=$.current,P=de.current;if(!(!k||!P)&&!(document.visibilityState==="hidden"||!rn.current||I.current?.isConnected===!1))try{const Ae=Br(k),Je=kn();P.fit(),Je&&(T.current=Je),Ae&&li(k),Le.current&&!te.current&&!ot.current&&(nc(k),(ic()||Xn.current)&&Or({scrollToBottom:!0})),k.refresh(0,Math.max(0,k.rows-1)),Vt(),tc(Ae);const Ze={cols:k.cols,rows:k.rows},lt=M.current;if(lt&<.cols===Ze.cols&<.rows===Ze.rows)return;ta({type:"resize",terminalId:e.id,cols:Ze.cols,rows:Ze.rows})&&(M.current=Ze)}catch{}}function ss(k,P){const Ae=me.current;return Ae?Ae(k,P):"rejected"}function ta(k){return ss(k)!=="rejected"}function al(){j.current!==null&&(window.clearTimeout(j.current),j.current=null)}function Oi(){al();const k=Math.max(-Df,Math.min(Df,ge.current));if(ge.current=0,k===0)return!1;const P=ss({type:"scrollback_scroll",terminalId:e.id,lines:k},{durability:"live-only"})==="sent";return P&&(Me.current=!0,k<0&&Ai(!0)),P}function ac(k){if(!Le.current||k===0)return;const P=ge.current+k;ge.current=Math.max(-Df,Math.min(Df,P)),j.current===null&&(j.current=window.setTimeout(()=>{j.current=null,Oi()},r6))}function as(){ol(me.current)}function wu(k=me.current,P={}){const Ae=Me.current;al(),ge.current=0,Me.current=!1,P.updateUi!==!1&&Ai(!1),Ae&&k?.({type:"cancel_scrollback",terminalId:e.id})}function ol(k){al(),ge.current=0,Me.current=!1,Ai(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function ys(){if(!je.current)return;const k=!Le.current;Wo(HL(ne.current,k)),oc()}function xu(){const k=!Mn.current;Mn.current=k,gs(k),Ir({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Cu(){Ci.current!==null&&(window.clearTimeout(Ci.current),Ci.current=null)}function Ir(k,P={}){Cu();const Ae=hr.current+1;hr.current=Ae,Ji({...k,id:Ae}),!P.sticky&&(Ci.current=window.setTimeout(()=>{Ci.current=null,Ji(Je=>Je?.id===Ae?null:Je)},12e3))}function wh(){Bn.current.skipped=!0,Ir({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function tr(){Mn.current=!1,gs(!1),Ir({tone:"skipped",message:"Cache keep-alive off"})}async function na(){const k=Bn.current;if(k.sent||k.skipped)return;const P=Ya();if(k.sent=!0,P){Ir({tone:"skipped",message:"Skipped cache keep-alive",detail:P});return}if(nr(`${_C}\r`,{userInitiated:!1})==="rejected"){Ir({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Ir({tone:"success",message:"Cache keep-alive sent",detail:_C})}function Ya(){const k=Xi.current,P=qe.current;return Mn.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!P?"Transcript cache status is unavailable.":k.source.provider!==P.provider||k.source.sessionId!==P.sessionId?"The transcript session changed.":e.agentStatus&&["working","finishing","waiting"].includes(e.agentStatus.state)?`${Eo(P.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.":b6(I.current)?"Pane input is focused.":Date.now()-Mi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function oc(){const k=$.current;k&&(li(k),Vt())}function nr(k,P={}){if(zi.current?.allowInput(k,P.textPaste)===!1)return"rejected";Sn.current&&P.userInitiated!==!1&&!P.preserveMobileShift&&k&&k!=="\x1B[I"&&k!=="\x1B[O"&&Wt(!1),Oi();const Ae=Me.current;Or({force:!0,scrollToBottom:!0});const Je=ss({type:"input",terminalId:e.id,data:k,...Ae?{cancelScrollbackMode:!0}:{}},{durability:P.userInitiated===!1||P.liveOnly?"live-only":"durable"});return Je==="rejected"?(P.userInitiated!==!1&&is("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Je):(P.userInitiated!==!1&&(Mi.current=Date.now()),Ae&&(Me.current=!1,Ai(!1)),j6(k)&&(Je==="sent"?ku():Je==="queued"&&(Oe.current=!0)),Je)}function ir(k){if(!Le.current||!Dn.current||!rn.current)return;const P=LL(k,Ce.current??Fi()??1);ss({type:"input",terminalId:e.id,data:P},{durability:"live-only"})==="sent"&&/\x1b\[<(?:0|32|64|65);/.test(k)&&(Me.current=!0,(F.current==="tmux"||F.current==="copy")&&Ai(!0))}function Fi(){return F.current==="application"&&pe.current.codex?pe.current.speed:null}function Ss(k,P){const Ae=$.current;if(!(!Ae||P===0)){Ce.current=Math.abs(P);try{Ae.element?.dispatchEvent(w2(k,Math.sign(P),1))}finally{Ce.current=null}}}function Pr(){yn.current&&In(!1),nr(FI)}function zr(k){const P=Kf(k,{bracketedPasteMode:$.current?.modes.bracketedPasteMode===!0||zi.current?.pending===!0,stripTrailingLineBreaks:!0});P&&nr(P,{textPaste:!0})}function os(k,P){const Ae=$.current?.modes.bracketedPasteMode===!0,Je=Ui==="codex"||Ui==="claude"||xl(e.currentCommand),Ze=k.parts.map(lt=>lt.kind==="image"&&Je?Kf(lt.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Kf(lt.kind==="image"?lt.path:lt.value,{bracketedPasteMode:Ae,stripTrailingLineBreaks:!1})).join("");return Ze?nr(`${Ze}${Z5(P)}`)!=="rejected":!1}function ku(){!ft.current||!Dn.current||(_h(),We.current=HI.map(k=>{const P=window.setTimeout(()=>{We.current=We.current.filter(Ae=>Ae!==P),ft.current&&Dn.current&&ta({type:"refresh_cwd",terminalId:e.id})},k);return P}))}function _r(k="terminal-interaction"){oe.current||Fa()&&(k==="auto"||k==="scroll-action")||$.current?.focus()}const Tu=v.useCallback(()=>{ts(!1)},[]);function xh(){Wt(!1),zs(k=>{const P=!k;return yn.current=P,P}),_r("input-action")}function In(k){yn.current=k,zs(k)}function Wt(k){Sn.current=k,Li(k)}function Mt(k){In(!1),Wt(k),_r("input-action")}function ws(k){yn.current&&In(!1);const P=Sn.current&&k!=="interrupt"&&k!=="escape";nr(ub(k,P),{preserveMobileShift:P}),_r("input-action")}async function Wi(k="install"){er(!0),mr(null);try{const P=k==="update"?await t.updateCodeServer():await t.installCodeServer();xb(jr,P.status),Ks(P.status)}catch(P){mr(Mf(P))}finally{er(!1)}}return u.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":oi?"true":"false",onMouseDown:()=>{n||m()},children:[u.jsx(y6,{terminal:e,canClose:o,tabId:d,transcriptSource:on,hasTranscriptCandidates:es.length>0,transcriptShortcutLabel:H,subagentsShortcutLabel:Y,transcriptCacheStatus:si,transcriptCacheNow:Ba,cacheKeepAliveEnabled:Ti,codeServerAvailable:!0,codeServerInstallState:ai===null?"unknown":ai.installed?"installed":"missing",codeServerBusy:mt||ai?.job?.status==="running",codeServerSupported:ai?.supported!==!1,scrollbackShortcutLabel:q,tmuxScrollbackSupported:ji,tmuxScrollbackEnabled:oi,onToggleCacheKeepAlive:xu,onOpenCodeServer:Go,onToggleTmuxScrollback:ys,onOpenTranscript:Yo,onOpenSubagents:Ha,onReload:B,reloading:Pa,onClose:p}),u.jsx("div",{className:"xterm-container",ref:I}),ri?u.jsxs("div",{className:"terminal-image-paste-status","data-error":ri.error?"true":"false",role:"status","aria-live":"polite",children:[u.jsx("span",{children:ri.message}),u.jsx("button",{type:"button","aria-label":ri.uploading?"Cancel image paste":"Dismiss image paste message",title:ri.uploading?"Cancel image paste":"Dismiss",onMouseDown:k=>k.preventDefault(),onClick:()=>{zi.current?.cancel()},children:u.jsx(up,{size:16,"aria-hidden":"true"})})]}):null,ja?u.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:u.jsx("span",{"aria-hidden":"true"})}):null,R&&!oi&&mi?u.jsxs("div",{className:"terminal-scroll-progress","data-active":Wl,"aria-hidden":"true",children:[mi.current,"/",mi.total]}):R&&!oi&&Dr?u.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Dr.alternate?"alternate":"normal","aria-hidden":"true",children:[Dr.alternate?"alt ":"","0/?"]}):null,!oi&&Uo||oi&&Kl&&e.scrollbackMode!=="application"?u.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),sc()},children:"↓"}):null,lu&&!oi?u.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Su,onPointerMove:ea,children:u.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Vo?u.jsx(x5,{ctrlActive:ql,shiftActive:Hs,onCtrl:xh,onShift:Mt,onStandaloneKey:ws,onPreserveFocus:()=>_r("input-action"),onHide:()=>{Wt(!1),Xl(!1)}}):u.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Shift / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),_r("input-action")},onPointerDown:k=>{k.stopPropagation(),_r("input-action")},onClick:()=>Xl(!0),children:"⌨"}):null,u.jsx(l4,{terminalId:e.id,onSubmit:os,onUploadAttachments:(k,P)=>t.uploadComposeAttachments({terminalId:e.id,files:k,signal:P.signal,onProgress:P.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:k=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:k})}:{},queueAvailable:Ui==="codex"||Cb(e.currentCommand),disabled:e.status!=="running"}),u.jsx(C6,{toast:Fs,onSendNow:()=>{na()},onSkipOnce:wh,onTurnOff:tr,onDismiss:()=>Ji(null)}),Ws?u.jsx(k6,{terminalId:e.id,serverApi:t,source:on,candidates:es,rememberedSelection:Xe,fontSize:w,onClose:Tu},e.id):null,Ia&&on?u.jsx(QB,{terminalId:e.id,serverApi:t,source:on,fontSize:w,onClose:()=>Lr(!1)}):null,qs?u.jsx(w6,{notice:qs}):null,xn?u.jsx(S6,{status:ai,busy:mt,error:Fo,onInstall:()=>{Wi("install")},onUpdate:()=>{Wi("update")},onOpen:Go,onRefresh:()=>{ns({checkLatest:!0}).catch(k=>mr(Mf(k)))},onClose:()=>Hi(!1)}):null]})}function SC(e){return DN(e)}async function wC(e,t,n={}){const s=n.checkLatest===!0,o=n.force===!0||s,l=Date.now(),d=Oc.get(e);if(!o&&d?.status&&l-d.fetchedAt<=s6)return d.status;if(d?.inflight&&(!s||d.inflightCheckLatest))return d.inflight;let f;return f=t.getCodeServerStatus(s?{checkLatest:!0}:void 0).then(m=>(xb(e,m),m)).catch(m=>{const p=Oc.get(e);throw p?.inflight===f&&(p.status?Oc.set(e,{status:p.status,fetchedAt:p.fetchedAt}):Oc.delete(e)),m}),Oc.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:l},inflight:f,inflightCheckLatest:s}),f}function xb(e,t){Oc.set(e,{status:t,fetchedAt:Date.now()})}function xC(e,t){return`${e}:${t}`}function Yy(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function b2(e){const t=Mp.get(e);return t?y2(t.handle)?(Mp.delete(e),null):t:null}function a6(e){if(e){const t=b2(e);if(t)return{handle:t.handle,ownsPopup:!1}}try{const t=e?window.open("",Yy(e)):window.open("about:blank","_blank");return{handle:t,ownsPopup:o6(t)}}catch{return{handle:null,ownsPopup:!1}}}function o6(e){try{return!!(e&&!e.closed&&e.location.href==="about:blank")}catch{return!1}}function l6(e,t){try{const n=new URL(e.location.href,window.location.href),s=new URL(t,window.location.href);return n.origin===s.origin&&n.pathname===s.pathname}catch{return!1}}function Gy(e){try{e.focus()}catch{}}function c6(e,t,n){let s;try{s=window.open(t,Yy(e))}catch{return null}return s?(Mp.set(e,{handle:s,createdAt:n}),Gy(s),s):null}function u6(e,t,n,s){if(!e||y2(e))return!1;try{e.name=Yy(t),e.location.href=n,Mp.set(t,{handle:e,createdAt:s})}catch{return!1}return Gy(e),!0}function d6(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 y2(e){if(!e)return!0;try{return e.closed}catch{return!0}}function h6(e){if(e)try{e.closed||e.close()}catch{}}function jv(e,t,n){const s=f6(e,t),o=CC(s*Math.max(1,n),ZI,QI);return{limit:CC(Math.ceil(o/YI),GI,XI),maxLines:o}}function f6(e,t){const n=e?.clientHeight??0;if(n<=0)return qI;const s=Math.max(10,t*VI);return Math.max(1,Math.floor(n/s))}function CC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function p6(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function m6(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function S2(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 g6(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function v6(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),d=s%24;return d>0?`${l}d ${d}h`:`${l}d`}function _6(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Mf(e){return e instanceof Vn||e instanceof Error?e.message:"Something went wrong."}function b6(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function y6({terminal:e,canClose:t,tabId:n,transcriptSource:s,hasTranscriptCandidates:o,transcriptShortcutLabel:l,subagentsShortcutLabel:d,transcriptCacheStatus:f,transcriptCacheNow:m,cacheKeepAliveEnabled:p,codeServerAvailable:b,codeServerInstallState:_,codeServerBusy:S,codeServerSupported:w,scrollbackShortcutLabel:x,tmuxScrollbackSupported:R,tmuxScrollbackEnabled:L,onToggleCacheKeepAlive:A,onOpenCodeServer:W,onToggleTmuxScrollback:z,onOpenTranscript:H,onOpenSubagents:q,onReload:Y,reloading:I,onClose:$}){const de=ay({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),me={cursor:n?"grab":"default",opacity:de.isDragging?.5:void 0};return u.jsxs("header",{ref:de.setNodeRef,className:"terminal-pane-header",style:me,"data-dragging":de.isDragging,...de.attributes,...de.listeners,children:[u.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),u.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),u.jsx("span",{className:"terminal-pane-spacer"}),b?u.jsx("button",{type:"button",className:"terminal-pane-code","data-state":_,"data-busy":S?"true":"false",disabled:!w||S,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:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),W()},children:u.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,s||o?u.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s?.provider,title:"View transcript history","aria-label":"View transcript history",onPointerDown:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),H()},children:[u.jsx("span",{className:"pane-button-label-full",children:"View history"}),u.jsx("span",{className:"pane-button-label-short",children:"History"}),u.jsx("kbd",{children:l})]}):null,s?u.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:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),q()},children:[u.jsx("span",{className:"pane-button-label-full",children:"View agents"}),u.jsx("span",{className:"pane-button-label-short",children:"Agents"}),u.jsx("kbd",{children:d})]}):null,s?u.jsx(x6,{status:f,now:m,keepAliveEnabled:p,onToggle:A}):null,e.status==="exited"?u.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,R&&e.status==="running"?u.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":L?"true":"false","aria-pressed":L,"aria-label":`Toggle tmux scrollback (${x})`,title:L?`Native scrolling: application history or tmux scrollback (${x}). Shift-drag selects browser text.`:`Scroll input uses NTerminal scrollback (${x}).`,onPointerDown:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),z()},children:[L?u.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),u.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):u.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),u.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),u.jsx("kbd",{children:x})]}):null,e.status==="running"?u.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:I?"Restoring live pane output...":"Reload pane output and return to live screen",disabled:I,"aria-busy":I,onPointerDown:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),Y()},children:u.jsx(Ll,{size:12,"aria-hidden":"true"})}):null,t?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),$()},children:"x"}):null]})}function S6({status:e,busy:t,error:n,onInstall:s,onUpdate:o,onOpen:l,onRefresh:d,onClose:f}){const m=e?.job??null,p=m?.status==="running",b=e?.installed===!0,_=e?.supported!==!1,S=e===null&&t,w=e?.updateAvailable===!0,x=b?"VS Code add-on":"Install VS Code add-on";return u.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:f,children:u.jsxs("section",{className:"security-panel code-server-dialog",onClick:R=>R.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{children:[u.jsx("h2",{children:x}),u.jsx("p",{children:S?"Checking code-server status...":b?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),u.jsxs("div",{className:"code-server-dialog-scroll",children:[u.jsxs("div",{className:"code-server-dialog-body",children:[u.jsxs("p",{children:["NTerminal installs code-server under ",u.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),S?u.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),_?null:u.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?u.jsx("p",{className:"code-server-dialog-error",children:n}):null,m?u.jsxs("div",{className:"code-server-progress","data-status":m.status,children:[u.jsxs("div",{className:"code-server-progress-heading",children:[u.jsx("span",{children:m.action}),u.jsx("strong",{children:m.status})]}),u.jsx("pre",{children:m.logs.length>0?m.logs.join(`
|
|
53
|
-
`):"Preparing..."})]}):null]}),u.jsxs("div",{className:"code-server-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||p||!_,children:"Check"}),b?u.jsxs(u.Fragment,{children:[w?u.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!_,children:"Update"}):null,u.jsx("button",{type:"button",onClick:l,disabled:t||p,children:"Open"})]}):u.jsx("button",{type:"button",onClick:s,disabled:t||p||!_,children:p?"Installing...":"Install"})]})]})})}function w6({notice:e}){return u.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function x6({status:e,now:t,keepAliveEnabled:n,onToggle:s}){const o=S2(e,t),l=g6(e,o),d=o===null?"?":v6(o),f=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return u.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":l,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:f,onPointerDown:m=>m.stopPropagation(),onMouseDown:m=>m.stopPropagation(),onClick:m=>{m.stopPropagation(),s()},children:[u.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),u.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{children:d})]})}function C6({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:s,onDismiss:o}){if(!e)return null;const l=e.tone==="info"||e.tone==="warning";return u.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[u.jsxs("header",{children:[u.jsx("strong",{children:e.message}),u.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?u.jsx("p",{children:e.detail}):null,l?u.jsxs("div",{className:"cache-keepalive-toast-actions",children:[u.jsx("button",{type:"button",onClick:t,children:"Send now"}),u.jsx("button",{type:"button",onClick:n,children:"Skip once"}),u.jsx("button",{type:"button",onClick:s,children:"Turn off"})]}):null]})}function k6(e){const[t,n]=v.useState(null),[s,o]=v.useState(),[l,d]=v.useState(e.candidates),[f,m]=v.useState(e.source),[p,b]=v.useState(null),[_,S]=v.useState(!0),w=v.useRef(0);async function x(A=!1,W=!1){const z=++w.current;S(!0);try{const H=await e.serverApi.getTerminalTranscriptSource(e.terminalId);if(z!==w.current)return;if(d(H.candidates??[]),m(H.source),W&&!H.source&&e.source){m(e.source),n(e.source),b(null);return}const q=e.rememberedSelection?.current;let Y=!1;if((A||!t)&&q?.terminalId===e.terminalId){const I=H.candidates?.find($=>$.id===q.candidateId);I?(n({provider:I.provider,sessionId:I.sessionId}),o(I.id),Y=!0):e.rememberedSelection&&(e.rememberedSelection.current=null)}if((A||!t)&&H.source)n(H.source),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);else if((A||!t)&&!Y&&H.candidates?.length===1){const I=H.candidates[0];n({provider:I.provider,sessionId:I.sessionId}),o(I.id)}b(null)}catch(H){if(z!==w.current)return;if(W&&e.source){n(e.source);return}b(H instanceof Error?H.message:"Could not load sessions.")}finally{z===w.current&&S(!1)}}v.useEffect(()=>(x(!1,!0),()=>{w.current+=1}),[]),v.useEffect(()=>{if(t)return;function A(W){W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),e.onClose())}return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[t,e.onClose]);const R=[];t&&R.push({id:s??"__pinned",title:l.find(A=>A.id===s)?.title||`${Eo(t.provider)} · ${t.sessionId}`,detail:l.find(A=>A.id===s)?.cwd||t.sessionId}),f&&(!t||!Ca(f,t))&&R.push({id:"__current",title:`Current session · ${Eo(f.provider)}`,detail:f.sessionId});for(const A of l)t&&Ca(t,A)||f&&Ca(f,A)||R.push({id:A.id,title:A.title||A.sessionId,detail:`${Eo(A.provider)} · ${A.cwd}${A.updatedAt?` · ${new Date(A.updatedAt).toLocaleString()}`:""}`});const L=t&&R.length<=1?null:u.jsxs("div",{className:"transcript-session-picker",children:[R.length>1?u.jsx(a5,{options:R,value:s??(t?"__pinned":void 0),onSelect:A=>{if(w.current+=1,S(!1),A==="__current"&&f){n(f),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);return}const W=l.find(z=>z.id===A);W&&(n({provider:W.provider,sessionId:W.sessionId}),o(W.id),e.rememberedSelection&&(e.rememberedSelection.current={terminalId:e.terminalId,candidateId:W.id}))}}):null,u.jsx("button",{type:"button","aria-label":"Refresh sessions",title:"Refresh sessions",disabled:_,onClick:()=>{x()},children:u.jsx(Ll,{size:16})}),p?u.jsx("span",{role:"alert",children:p}):null,!t&&!f&&!_&&!l.length?u.jsx("span",{children:"No sessions available."}):null]});return t?v.createElement(T6,{...e,key:`${t.provider}:${t.sessionId}:${s??""}`,source:t,...s?{candidateId:s}:{},sessionPicker:L,liveSourceChanged:!!(e.source&&!Ca(e.source,t)),onReloadLatest:async()=>{e.rememberedSelection&&(e.rememberedSelection.current=null),n(null),o(void 0),await x(!0)}}):u.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-picker-title",onPointerDown:A=>A.stopPropagation(),onMouseDown:A=>A.stopPropagation(),onClick:A=>{A.stopPropagation(),e.onClose()},children:u.jsxs("div",{className:"security-panel transcript-dialog",onClick:A=>A.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"transcript-picker-title",children:"History"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e.onClose,children:"×"})]}),L,_?u.jsx("div",{className:"transcript-dialog-status",children:"Loading sessions..."}):null]})})}const T6=zt.memo(function({terminalId:t,serverApi:n,source:s,fontSize:o,onClose:l,onReloadLatest:d,candidateId:f,sessionPicker:m,liveSourceChanged:p}){const b=v.useRef(null),_=v.useRef(null),S=v.useRef(null),w=v.useRef(null),x=v.useRef(!0),R=v.useRef(null),[L,A]=v.useState(!1),W=v.useRef(!1),z=v.useRef(null),H=v.useRef(!1),q=v.useRef(()=>{});q.current=Dt;const Y=v.useRef(0),I=v.useRef(!1),$=v.useRef(!1),de=v.useRef(null),me=v.useRef(null),K=v.useRef(null),[ne,ee]=v.useState([]),[Z,X]=v.useState(!1),[M,T]=v.useState(""),[O,re]=v.useState(null),[he,N]=v.useState(null),[V,se]=v.useState(!1),[J,xe]=v.useState(!1),[ye,Pe]=v.useState(-1),[Fe,ze]=v.useState(null),[ve,We]=v.useState(null),[Oe,j]=v.useState(!1),[ge,Me]=v.useState(!0),[Le,F]=v.useState(!1),[pe,Ce]=v.useState(null),[Re,je]=v.useState(!1),be=f5(n,t,s,f,Z,M),Ue=v.useRef(0),$e=v.useRef(null),Be=v.useRef(null);function ot(){if(W.current)return!0;const oe=b.current,ke=window.getSelection();if(!oe||!ke||ke.isCollapsed)return!1;for(let Xe=0;Xe<ke.rangeCount;Xe++)if(ke.getRangeAt(Xe).intersectsNode(oe))return!0;return!1}v.useEffect(()=>{const oe=()=>{ot()||(z.current?z.current.resume():H.current&&(H.current=!1,q.current()))},ke=()=>{W.current=!1,oe()};return document.addEventListener("selectionchange",oe),document.addEventListener("pointerup",ke,!0),document.addEventListener("pointercancel",ke,!0),window.addEventListener("blur",ke),()=>{document.removeEventListener("selectionchange",oe),document.removeEventListener("pointerup",ke,!0),document.removeEventListener("pointercancel",ke,!0),window.removeEventListener("blur",ke),z.current?.cancel()}},[]);function ct(oe){return oe?.aborted?Promise.reject(new DOMException("Aborted","AbortError")):ot()?new Promise((ke,Xe)=>{const qe=()=>{oe?.removeEventListener("abort",nt),z.current?.cancel===nt&&(z.current=null)},nt=()=>{qe(),Xe(new DOMException("Aborted","AbortError"))};z.current={resume:()=>{qe(),ke()},cancel:nt},oe?.addEventListener("abort",nt,{once:!0})}):Promise.resolve()}v.useEffect(()=>{Sn(),re(null),N(null)},[M,Z]),v.useEffect(()=>()=>{Ue.current+=1,Be.current?.abort()},[]),v.useEffect(()=>{function oe(ke){ke.key==="Escape"&&(ke.preventDefault(),ke.stopPropagation(),l())}return document.addEventListener("keydown",oe,!0),()=>document.removeEventListener("keydown",oe,!0)},[l]),v.useLayoutEffect(()=>{Y.current+=1;const oe=Y.current;I.current=!1,$.current=!0,de.current=null,me.current=null,K.current=null;const ke=d5(n,t,s,Z);return _.current=ke,S.current=ke.snapshot,x.current=!0,R.current=null,A(!1),We(null),j(!1),Ce(null),je(!1),re(null),N(null),Pe(-1),ze(null),ke.snapshot?($.current=!1,R.current={top:ke.snapshot.scrollTop,atBottom:ke.snapshot.atBottom,...ke.snapshot.scrollAnchor},Pt(ke.snapshot),Me(!1),bn(ke.snapshot,oe)):(ee([]),Me(!0),Ft(null,"initial",oe)),()=>{bt(),ke.release(),_.current===ke&&(_.current=null),Y.current+=1,$e.current?.abort(),I.current=!1}},[n,Z,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const oe=b.current;if(!oe)return;const ke=R.current;if(ke&&!ge&&w.current===ne){R.current=null;const qe=ke.key?Array.from(oe.querySelectorAll("[data-transcript-entry-key]")).find(nt=>nt.dataset.transcriptEntryKey===ke.key):null;oe.scrollTop=ke.atBottom?oe.scrollHeight:qe?oe.scrollTop+qe.getBoundingClientRect().top-oe.getBoundingClientRect().top-(ke.offset??0):ke.top;return}if($.current){if(ge||ne.length===0)return;$.current=!1;const qe=()=>{oe.scrollTop=oe.scrollHeight};qe(),window.requestAnimationFrame?.(qe);return}const Xe=de.current;Xe!==null&&(de.current=null,oe.scrollTop+=oe.scrollHeight-Xe)},[ne,ge,Z]);const ht=Eo(s.provider),jt=zt.useMemo(()=>Sp(ne,Z),[ne,Z]),Qt=zt.useMemo(()=>sb(jt),[jt]),rt=zt.useMemo(()=>E6(Qt),[Qt]),Yn=rt.map(oe=>oe.key).join(""),_n=Fe?rt.find(oe=>oe.key===Fe)?.entryIndex??null:null,pt=M.trim().length>0,Et=be.result?.hits.length??0,Nt=be.result?.hits.findIndex(oe=>oe.id===O?.id)??-1,Di=he?.entryIndex??null,Gn=pt?Di:_n,nn=pt?Di===null?null:"search":_n===null?null:"prompt",fn=jt?jt.split(`
|
|
54
|
-
`).length-1:0,te=rt.length>0&&ye>=0&&ye<rt.length?ye:rt.length-1,Ke=Fe??(te>=0?rt[te]?.key??null:null),et=pt?Et>0?`${Nt+1}/${Et} ${Et===1?"match":"matches"} · ${fn} ${fn===1?"line":"lines"}`:`0 matches · ${fn} ${fn===1?"line":"lines"}`:rt.length>0?`${te+1}/${rt.length} prompts · ${fn} ${fn===1?"line":"lines"}`:`0 prompts · ${fn} ${fn===1?"line":"lines"}`;v.useEffect(()=>{if(pt){ze(null);return}Fe&&!rt.some(oe=>oe.key===Fe)&&ze(null),Pe(oe=>{if(rt.length===0)return K.current=null,-1;const ke=K.current?rt.findIndex(qe=>qe.key===K.current):-1,Xe=ke>=0?ke:oe>=0&&oe<rt.length?oe:rt.length-1;return K.current=rt[Xe]?.key??null,Xe})},[Fe,pt,Yn]),v.useEffect(()=>{const oe=me.current;if(!oe||rt.length===0)return;me.current=null;const ke=oe.anchorKey?rt.findIndex(qe=>qe.key===oe.anchorKey):-1,Xe=ke>0?ke-1:0;ft(Xe)},[Yn]);function bt(){const oe=S.current,ke=b.current;if(!oe||!ke||!x.current)return;const Xe=Array.from(ke.querySelectorAll("[data-transcript-entry-key]")).find(nt=>nt.getBoundingClientRect().bottom>ke.getBoundingClientRect().top),qe={...oe,scrollTop:ke.scrollTop,atBottom:ke.scrollHeight-ke.clientHeight-ke.scrollTop<=4,...Xe?{scrollAnchor:{key:Xe.dataset.transcriptEntryKey,offset:Xe.getBoundingClientRect().top-ke.getBoundingClientRect().top}}:{}};S.current=qe,_.current?.write(qe)}function Pt(oe){S.current=oe,_.current?.write(oe);const ke=jc([oe.page.records.map(qe=>qe.block).join(`
|
|
55
|
-
|
|
56
|
-
`)],s.provider,{includeTools:Z}),Xe=ke?[ke]:[];w.current=Xe,ee(Xe),We(oe.cursor),j(oe.hasMore)}async function bn(oe,ke){$e.current?.abort();const Xe=new AbortController;$e.current=Xe,I.current=!0,Me(!1),F(!1),A(!0),Ce(null);let qe=null;try{for(;;){const Xt=await n.getTerminalTranscriptHistory(t,{...jv(b.current,o,Lv),...qe?.cursor?{cursor:qe.cursor}:{ifSnapshot:oe.page.snapshot},includeTools:Z,expectedSessionId:s.sessionId,...f?{candidateId:f}:{}},Xe.signal);if(Y.current!==ke||!_.current?.current())return;if(!Xt.source)throw new Error("Transcript source is temporarily unavailable. Retry loading newest.");if(!Ca(s,Xt.source))throw je(!0),_.current?.invalidate(),new Error("Transcript session changed. Load newest to refresh.");if(je(!1),Xt.page?.unchanged)return;if(!Xt.page){if(await ct(Xe.signal),Y.current!==ke)return;S.current=null,_.current?.invalidate(),ee([jc(Xt.output,s.provider,{includeTools:Z})]),We(Xt.cursor),j(Xt.hasMore);return}if(qe=qe?Yx(qe,Xt):ab(Xt),!qe)throw new Error("Transcript changed while loading. Load newest to retry.");if(IE(oe,qe)||!qe.hasMore||!qe.cursor)break;await new Promise(Xi=>window.setTimeout(Xi,0))}if(await ct(Xe.signal),Y.current!==ke||!_.current?.current())return;bt();const nt=b.current,sn=S.current??oe,On=o5(sn,qe),dr=nt?Array.from(nt.querySelectorAll("[data-transcript-entry-key]")).find(Xt=>Xt.getBoundingClientRect().bottom>nt.getBoundingClientRect().top):void 0;R.current={top:On.scrollTop,atBottom:On.atBottom,...dr&&nt&&On.page.identity===oe.page.identity?{key:dr.dataset.transcriptEntryKey,offset:dr.getBoundingClientRect().top-nt.getBoundingClientRect().top}:{}},Pt(On)}catch(nt){Y.current===ke&&!Xe.signal.aborted&&(Ce(nt instanceof Error?nt.message:"Could not check the latest history."),nt instanceof Vn&&nt.status===409&&(_.current?.invalidate(),je(!0)))}finally{Y.current===ke&&(I.current=!1,A(!1))}}async function Ft(oe,ke,Xe=Y.current){if(!I.current){I.current=!0,$e.current?.abort(),$e.current=new AbortController,A(!1),Me(ke==="initial"),F(ke==="older"),ke==="older"&&(de.current=b.current?.scrollHeight??null),Ce(null);try{await pn(oe,ke,Xe)}catch(qe){if(Y.current!==Xe)return;Ce(qe instanceof Error?qe.message:"Failed to load transcript history."),qe instanceof Vn&&qe.status===409&&je(!0)}finally{Y.current===Xe&&(I.current=!1,Me(!1),F(!1))}}}async function pn(oe,ke,Xe){const qe=$e.current?.signal;let nt=oe,sn=0,On=[];const dr=ke==="initial"&&s.provider!=="claude"?e6:JI;for(;Y.current===Xe;){const Xt=await n.getTerminalTranscriptHistory(t,{...nt?{cursor:nt}:{},...jv(b.current,o,ke==="initial"?Lv:KI),includeTools:Z,expectedSessionId:s.sessionId,...f?{candidateId:f}:{}},qe);if(Y.current!==Xe||(ke==="older"&&await ct(qe),Y.current!==Xe))return;if(!Xt.source){Ce("Transcript source is temporarily unavailable.");return}if(!Ca(s,Xt.source)){_.current?.invalidate(),je(!0),j(!1);return}const Xi=jc(Xt.output,s.provider,{includeTools:Z}),Mn=Jt(Xt,ke,On,Xi);if(Xi&&(On=[Xi,...On],Mn))return;if(!Xt.hasMore||!Xt.cursor||sn>=dr){On.length>0&&ee(Bn=>ke==="older"?[...On,...Bn]:On);return}nt=Xt.cursor,sn+=1}}function Jt(oe,ke,Xe,qe=jc(oe.output,s.provider,{includeTools:Z})){if(x.current&&oe.page&&!oe.page.unchanged){const sn=S.current,On=ke==="older"&&sn?Yx(sn,oe):ab(oe);if(!On)throw new Error("Transcript changed while loading. Load newest to retry.");return ke==="older"&&(de.current=b.current?.scrollHeight??null),Pt(On),!!qe}if(We(oe.cursor),j(!!(oe.hasMore&&oe.cursor)),!qe)return!1;const nt=[qe,...Xe];return Sp(nt,Z)?(ee(sn=>ke==="older"?[...nt,...sn]:nt),!0):!1}function Dt(){const oe=b.current;if(oe){if(ot()){H.current=!0;return}H.current=!1,wn(),!(pt||oe.scrollTop>72||!Oe||!ve||I.current)&&Ft(ve,"older")}}function yn(oe){if(Et===0)return;const ke=Nt>=0?Nt:oe>0?-1:0;rn((ke+oe+Et)%Et)}function Sn(){Ue.current+=1,Be.current?.abort(),Be.current=null,se(!1)}function Dn(){const oe=S.current;x.current||(x.current=!0,$e.current?.abort(),Y.current+=1,I.current=!1,F(!1),de.current=null,oe?(R.current={top:oe.scrollTop,atBottom:oe.atBottom,...oe.scrollAnchor},Pt(oe),bn(oe,Y.current)):(ee([]),We(null),j(!1),$.current=!0,Ft(null,"initial")))}async function rn(oe){const ke=be.result?.hits[oe];if(!ke)return;bt(),x.current=!1,A(!1);const Xe=++Ue.current;Be.current?.abort(),$e.current?.abort();const qe=new AbortController;Be.current=qe,Y.current+=1,I.current=!1,$.current=!1,de.current=null,Me(!1),se(!0),F(!1),Ce(null),re(ke),N(null);try{const nt=await n.getTerminalTranscriptHistory(t,{around:ke.cursor,expectedSessionId:s.sessionId,...f?{candidateId:f}:{},includeTools:Z,...jv(b.current,o,Lv)},qe.signal);if(Xe!==Ue.current)return;if(!nt.source||!Ca(s,nt.source)){je(!0);return}const sn=jc(nt.output,s.provider,{includeTools:Z});ee([sn]),N(h5(sb(sn),ke,M)),We(nt.cursor),j(!!(nt.hasMore&&nt.cursor)),b.current&&(b.current.scrollTop=0)}catch(nt){Xe===Ue.current&&(Ce(nt instanceof Error?nt.message:"Could not load search result."),nt instanceof Vn&&nt.status===409&&je(!0))}finally{Xe===Ue.current&&se(!1)}}function ft(oe){const ke=rt[oe];ke&&(K.current=ke.key,Pe(oe),ze(ke.key))}async function wt(oe){if(rt.length===0){oe<0&&Oe&&ve&&!I.current&&(me.current={anchorKey:null},await Ft(ve,"older"));return}const Xe=(ye>=0&&ye<rt.length?ye:oe<0?rt.length-1:-1)+oe;if(Xe>=0&&Xe<rt.length){ft(Xe);return}oe<0&&Xe<0&&Oe&&ve&&!I.current&&(me.current={anchorKey:rt[0]?.key??null},await Ft(ve,"older"))}function wn(){if(pt)return;const oe=b.current;if(!oe)return;const Xe=oe.getBoundingClientRect().top+Math.min(140,Math.max(48,oe.clientHeight*.28));let qe=null;for(const nt of A6(oe)){const sn=L6(nt);if(sn!==null)if(nt.getBoundingClientRect().top<=Xe)qe=sn;else break}if(qe!==null){const nt=rt[qe]?.key??null;K.current=nt,Pe(qe),Fe&&Fe!==nt&&ze(null)}}return u.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:u.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:oe=>oe.stopPropagation(),onMouseDown:oe=>oe.stopPropagation(),onClick:oe=>oe.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"transcript-dialog-title",children:[u.jsxs("h2",{id:"transcript-dialog-title",children:[ht," JSONL"]}),u.jsx("span",{title:s.sessionId,children:s.sessionId})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:l,children:"×"})]}),m,p?u.jsx("div",{className:"transcript-dialog-status",children:"The live pane uses another session. History remains pinned to this session."}):null,u.jsxs("div",{className:"transcript-dialog-controls",children:[u.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[u.jsx("input",{type:"checkbox",checked:Z,onChange:oe=>X(oe.currentTarget.checked)}),"Show tool output"]}),u.jsx("label",{className:"transcript-search",children:u.jsx("input",{type:"search",value:M,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:oe=>{be.cancel(),Sn(),T(oe.currentTarget.value),oe.currentTarget.value.trim()||Dn()},onKeyDown:oe=>{oe.nativeEvent.isComposing||oe.key==="Enter"&&(oe.preventDefault(),pt?be.result?.query===nm(M)?Et>0?yn(oe.shiftKey?-1:1):!be.result.complete&&be.result.cursor&&!be.busy&&be.search(!0):be.busy||(Sn(),re(null),N(null),be.search()):wt(oe.shiftKey?-1:1))}})}),u.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":J,"aria-label":"Toggle prompt list",title:"Toggle prompt list",onClick:()=>xe(oe=>!oe),disabled:rt.length===0,children:u.jsx(LA,{size:16})}),u.jsxs("div",{className:"transcript-search-actions","aria-label":pt?"Search result navigation":"Prompt navigation",children:[u.jsx("button",{type:"button",onClick:()=>pt?yn(-1):void wt(-1),disabled:pt?Et===0:rt.length===0&&!Oe,"aria-label":pt?"Previous search match":"Previous user prompt",title:pt?"Previous search match":"Previous user prompt",children:u.jsx(EA,{size:16})}),u.jsx("button",{type:"button",onClick:()=>pt?yn(1):void wt(1),disabled:pt?Et===0:rt.length===0,"aria-label":pt?"Next search match":"Next user prompt",title:pt?"Next search match":"Next user prompt",children:u.jsx(CA,{size:16})})]}),u.jsx("span",{className:"transcript-result-count",children:et}),u.jsx("button",{type:"button",title:L?"Checking latest history...":"Load newest entries","aria-label":"Load newest entries","aria-busy":L,onClick:()=>{be.cancel(),Sn(),$e.current?.abort(),Y.current+=1,I.current=!1,F(!1),de.current=null,me.current=null,R.current=null,$.current=!0,re(null),N(null),x.current=!0;const oe=S.current;oe?($.current=!1,R.current={top:0,atBottom:!0},Pt({...oe,atBottom:!0}),bn(oe,Y.current)):Ft(null,"initial")},children:u.jsx(Ll,{size:16})})]}),pt?u.jsxs("div",{className:"transcript-search-results","aria-label":"Search results","aria-busy":be.busy,children:[u.jsxs("div",{className:"transcript-search-summary",role:"status",children:[be.busy?"Searching...":be.result?`${Et} ${Et>=200?"retained results":"results"}${be.result.complete?" · Complete":" · More to scan"} · ${be.result.scannedBytes.toLocaleString()} bytes scanned`:"Search history",be.result&&!be.result.complete&&be.result.cursor?u.jsx("button",{type:"button",disabled:be.busy,onClick:()=>{be.search(!0)},children:"Search more"}):null]}),O&&Nt<0&&be.result?u.jsx("div",{className:"transcript-dialog-status",children:"Selected result is outside the retained result window."}):null,be.error?u.jsx("div",{className:"transcript-dialog-error",role:"alert",children:be.error}):null,be.result?.hits.map((oe,ke)=>u.jsxs("button",{type:"button",className:`transcript-prompt-index-item${O?.id===oe.id?" transcript-prompt-index-item-active":""}`,"aria-current":O?.id===oe.id?"true":void 0,onClick:()=>{rn(ke)},children:[u.jsxs("span",{children:[oe.timestamp?new Date(oe.timestamp).toLocaleString():""," · ",oe.role]}),u.jsx("strong",{children:oe.preview.slice(0,500)})]},oe.id))]}):null,J?u.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:rt.length>0?rt.map((oe,ke)=>u.jsxs("button",{type:"button",className:Ke===oe.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>ft(ke),children:[u.jsx("span",{children:oe.timestampLabel}),u.jsx("strong",{children:oe.snippet})]},`${oe.key}:${ke}`)):u.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,Re?u.jsxs("div",{className:"transcript-dialog-status",role:"status",children:["The pinned transcript session changed."," ",u.jsx("button",{type:"button",onClick:()=>{d()},children:"Choose session"})]}):null,pe?u.jsx("div",{className:"transcript-dialog-error",role:"alert",children:pe}):null,V?u.jsx("div",{className:"transcript-dialog-status",role:"status",children:"Loading search result..."}):null,u.jsxs("div",{ref:b,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Dt,onPointerDownCapture:()=>{W.current=!0},children:[Le?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ge&&Oe?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,jt?u.jsx(NE,{entries:Qt,searchQuery:M,activeEntryIndex:Gn,activeEntryMode:nn,activeSearchMatch:he,fontSize:o}):null,ge?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Re&&!ge&&!jt&&!pe?Oe&&ve?u.jsxs("div",{className:"transcript-dialog-status",children:[Z?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",u.jsx("button",{type:"button",onClick:()=>{Ft(ve,"older")},disabled:Le,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null]})]})})});function E6(e){const t=[];for(let o=0;o<e.length;o+=1){const l=e[o];!l||l.kind!=="user"||t.push({contentKey:R6(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 d=n.get(l.contentKey)??0;n.set(l.contentKey,d+1),s.set(o,JSON.stringify([l.contentKey,d]))}return t.map((o,l)=>({entryIndex:o.entryIndex,key:s.get(l)??JSON.stringify([o.contentKey,0]),snippet:D6(o.entry.body),timestampLabel:M6(o.entry.header)}))}function R6(e){return JSON.stringify([e.header??"",e.body.length,N6(e.body)])}function N6(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 D6(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function M6(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function A6(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function L6(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 j6(e){return e.includes("\r")||e.includes(`
|
|
57
|
-
`)}function Ov(e){return e instanceof Vn&&e.status===404}function xl(e){return Cb(e)||kb(e)}function Cb(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function kb(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function kC(e){if(xl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function O6(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 Bv(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function B6(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 TC(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 qr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function I6(e,t){return!t||qr(e)}function EC(e){return qr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function P6(e,t){const{markIntent:n,markKeyboardIntent:s,setPointerScrollActive:o}=t;let l=null;const d={capture:!0,passive:!0},f=()=>n(),m=()=>{l&&(l.scrolling=!0,n(),o(!0))},p=x=>{if(x.button!==0)return;_(),l={id:x.pointerId,x:x.clientX,y:x.clientY,scrolling:!1};const R=x.target;R instanceof Element&&R.closest(z6)&&m()},b=x=>{if(!(!l||x.pointerId!==l.id)){if((x.buttons&1)===0){_();return}if(l.scrolling){n();return}x.pointerType!=="touch"&&Math.hypot(x.clientX-l.x,x.clientY-l.y)>=H6&&m()}},_=()=>{if(!l)return;const x=l.scrolling;l=null,x&&(n(),o(!1))},S=x=>{l&&x.pointerId===l.id&&_()},w=x=>{U6(x)&&s()};return e.addEventListener("wheel",f,d),e.addEventListener("touchmove",f,d),e.addEventListener("pointerdown",p,d),e.addEventListener("keydown",w,{capture:!0}),window.addEventListener("pointermove",b,d),window.addEventListener("pointerup",S,{capture:!0}),window.addEventListener("pointercancel",S,{capture:!0}),window.addEventListener("blur",_),()=>{window.removeEventListener("blur",_),e.removeEventListener("wheel",f,{capture:!0}),e.removeEventListener("touchmove",f,{capture:!0}),e.removeEventListener("pointerdown",p,{capture:!0}),e.removeEventListener("keydown",w,{capture:!0}),window.removeEventListener("pointermove",b,{capture:!0}),window.removeEventListener("pointerup",S,{capture:!0}),window.removeEventListener("pointercancel",S,{capture:!0}),l=null,o(!1)}}const z6=".xterm-scrollable-element > .scrollbar",H6=4;function U6(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?!1:e.key==="PageUp"||e.key==="PageDown"||e.key==="Home"||e.key==="End"}function $6(e,t,n,s,o,l,d,f){const m=p=>{const b=W6(p);if(b!==0){if(d()){if(Tb(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(b);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),F6(t,b,n,s,o,l)}};return e.addEventListener("wheel",m,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",m,{capture:!0})}}function F6(e,t,n,s,o,l){const d=()=>{o();try{e.scrollLines(t)}finally{l()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};e.buffer.active.type!=="alternate"&&d()}function W6(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 K6(e,t,n,s,o,l,d,f,m,p,b){let _=null,S=0;const w=new jL,x={passive:!1};function R(W){_=Iv(W),S=0,w.reset()}function L(W){const z=Iv(W);if(z===null){_=null,S=0,w.reset();return}if(_===null){_=z;return}const H=z.clientY-_.clientY;if(_=z,W.cancelable&&W.preventDefault(),H===0)return;const q=p();if(f()&&Tb(t)&&q!==null){const I=w.consume(-H,n(),q);I!==0&&b(z,I),S=0;return}if(w.reset(),f()&&Tb(t)&&q6(t,z,-H)){S=0;return}S-=H/n();const Y=S<0?Math.ceil(S):Math.floor(S);if(Y!==0){if(S-=Y,f()){m(Y);return}if(t.buffer.active.type!=="alternate"){l();try{t.scrollLines(Y)}finally{d()}s(),Y<0&&t.buffer.active.viewportY<=3&&o(Y)}}}function A(W){if(w.reset(),W.touches.length>0){_=Iv(W);return}_=null,S=0}return e.addEventListener("touchstart",R,x),e.addEventListener("touchmove",L,x),e.addEventListener("touchend",A),e.addEventListener("touchcancel",A),()=>{e.removeEventListener("touchstart",R,x),e.removeEventListener("touchmove",L,x),e.removeEventListener("touchend",A),e.removeEventListener("touchcancel",A)}}function Iv(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function Tb(e){return e.modes.mouseTrackingMode!=="none"}function q6(e,t,n){const s=e.element;return s?(s.dispatchEvent(w2(t,n)),!0):!1}function w2(e,t,n=0){const 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:n}}),o}function Eb({node:e,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l=!0,refreshCwdOnEnter:d=!1,tabId:f,codeServerContext:m,dropZoneActive:p=!1,draggingTerminalId:b=null,mobileFocusLeafKey:_=null,path:S=[],totalPanes:w,onSelect:x,onClose:R,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:z,onAuthClose:H}){const q=w??Rb(e);if(S.length===0&&_){const de=Nb(e),me=de.some(K=>K.key===_)?_:de[0]?.key;if(de.length>1&&me)return u.jsx("div",{className:"mobile-focused-split",children:de.map(K=>{const ne=K.key===me;if(K.type==="editor"){const Z=n[K.editorId];return u.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:Z?u.jsx(Z1,{api:s,editor:Z,canClose:q>1,onClose:()=>z(K.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},K.key)}const ee=t[K.terminalId];return ee?u.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:u.jsx(yC,{terminal:ee,serverApi:s,active:ne,visible:l&&ne,canClose:q>1,refreshCwdOnEnter:d&&ne,tabId:f,codeServerContext:m,onSelect:()=>x(K.terminalId),onClose:()=>R(K.terminalId),onExit:Z=>A(K.terminalId,Z),onSnapshot:W,...H?{onAuthClose:H}:{}})},K.key):u.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},K.key)})})}if(e.type==="pane"){const de=t[e.terminalId];if(!de)return u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const me=u.jsx(yC,{terminal:de,serverApi:s,active:e.terminalId===o,visible:l,canClose:q>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:f,codeServerContext:m,onSelect:()=>x(e.terminalId),onClose:()=>R(e.terminalId),onExit:ne=>A(e.terminalId,ne),onSnapshot:W,...H?{onAuthClose:H}:{}});return p&&b!==e.terminalId?u.jsxs("div",{className:"pane-drop-host",children:[me,u.jsx(Af,{terminalId:e.terminalId,side:"top"}),u.jsx(Af,{terminalId:e.terminalId,side:"right"}),u.jsx(Af,{terminalId:e.terminalId,side:"bottom"}),u.jsx(Af,{terminalId:e.terminalId,side:"left"})]}):me}if(e.type==="editor"){const de=n[e.editorId];return de?u.jsx(Z1,{api:s,editor:de,canClose:q>1,onClose:()=>z(e.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const Y=Math.max(.1,Math.min(.9,e.ratio)),I=1-Y,$=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${Y}fr) 1px minmax(0, ${I}fr)`}:{gridTemplateRows:`minmax(0, ${Y}fr) 1px minmax(0, ${I}fr)`};return u.jsxs("div",{className:"split-pane","data-direction":e.direction,style:$,children:[u.jsx("div",{className:"split-cell",children:u.jsx(Eb,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:m,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...S,0],totalPanes:q,onSelect:x,onClose:R,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:z,...H?{onAuthClose:H}:{}})}),u.jsx(V6,{direction:e.direction,path:S,onResize:L}),u.jsx("div",{className:"split-cell",children:u.jsx(Eb,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:m,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...S,1],totalPanes:q,onSelect:x,onClose:R,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:z,...H?{onAuthClose:H}:{}})})]})}function Af({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=Wp({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return u.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function V6({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 d=l.parentElement;if(!d)return;const f=d.getBoundingClientRect();function m(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",m),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),l.removeEventListener("lostpointercapture",p),l.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",m),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),l.addEventListener("lostpointercapture",p)}return u.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:u.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Rb(e){return e.type==="pane"||e.type==="editor"?1:Rb(e.first)+Rb(e.second)}function Nb(e){return e.type==="pane"?[{key:Y6(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:G6(e.editorId),type:"editor",editorId:e.editorId}]:[...Nb(e.first),...Nb(e.second)]}function Y6(e){return`terminal:${e}`}function G6(e){return`editor:${e}`}const om="workspace-default",X6="NTerminal";function Z6(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function Bc(e,t){switch(t.type){case"workspace.hydrated":return Ap(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return Q6(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return nP(e,t.workspaceId);case"workspace.selected":return x2(e,t.workspaceId);case"workspace.renamed":return J6(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return eP(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return tP(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return Xy(e,t.terminal);case"terminal.split":return rP(e,t.terminal,t.direction);case"terminal.updated":return pP(e,t.terminal);case"terminal.exited":return mP(e,t.terminalId,t.exitCode);case"terminal.closed":return E2(e,t.terminalId);case"terminal.detached":return gP(e,t.terminalId,t.workspaceId);case"terminal.revealed":return iP(e,t.terminalId);case"editor.split":return sP(e,t.editorId,t.title,t.direction);case"editor.closed":return vP(e,t.editorId);case"pane.selected":return T2(e,t.terminalId);case"pane.resized":return fP(e,t.path,t.ratio);case"tab.selected":return oP(e,t.tabId);case"tab.renamed":return hP(e,t.tabId,t.title);case"tab.reordered":return Zy(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return lP(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return C2(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return k2(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return cP(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return aP(e);default:return e}}function Q6(e,t){if(e.workspaces.some(s=>s.id===t.id))return x2(e,t.id);const n={id:t.id,title:t.title,defaultCwd:ps(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function x2(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function J6(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.title===s?d:(o=!0,{...d,title:s}));return o?{...e,workspaces:l}:e}function eP(e,t,n){const s=ps(n);let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.defaultCwd===s?d:(o=!0,{...d,defaultCwd:s}));return o?{...e,workspaces:l}:e}function tP(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 d=e.workspaces.slice(),[f]=d.splice(o,1);if(!f)return e;const m=d.findIndex(_=>_.id===n);if(m<0)return e;const p=s==="before"?m:m+1,b=d.slice();return b.splice(p,0,f),dP(e.workspaces,b)?e:{...e,workspaces:b}}function nP(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?Ls(n):[]),o={...e.terminals};for(const f of s)delete o[f];const l=e.workspaces.filter(f=>f.id!==t),d=e.activeWorkspaceId===t?l[0]?.id??null:e.activeWorkspaceId;return{workspaces:l,activeWorkspaceId:d,terminals:o}}function Xy(e,t){const n=N2(e),s=Hl(n)??cm(),o=B2(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??ps(t.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...l.tabs,o],activeTabId:o.id}:O2(l,t.id))}}function iP(e,t){if(M2(e,t))return T2(e,t);const n=A2(e,t),s=e.terminals[t];return!n||!s?e:Xy({...e,activeWorkspaceId:n.id},s)}function rP(e,t,n){const s=Hl(e),o=s?lm(s):void 0;if(!s||!o)return Xy(e,t);const l=o.activeTerminalId,d=th(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??ps(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(m=>m!==t.id),tabs:f.tabs.map(m=>m.id===o.id?{...m,root:d,activeTerminalId:t.id}:m)}:O2(f,t.id))}}function sP(e,t,n,s){const o=Hl(e),l=o?lm(o):void 0;if(!o||!l)return e;const d=l.activeTerminalId,f=th(l.root,d,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(m=>m.id===o.id?{...m,tabs:m.tabs.map(p=>p.id===l.id?{...p,root:f,activeTerminalId:d}:p)}:m)}}function aP(e){const t=Hl(e),n=t?lm(t):void 0;return n?E2(e,n.activeTerminalId):e}function oP(e,t){const n=Hl(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 Zy(e,t,n){const s=e.workspaces.map(o=>{const l=o.tabs.findIndex(b=>b.id===t);if(l<0)return o;const d=o.tabs.slice(),[f]=d.splice(l,1);if(!f)return o;const m=Math.max(0,Math.min(d.length,n)),p=d.slice();return p.splice(m,0,f),uP(o.tabs,p)?o:{...o,tabs:p}});return s.every((o,l)=>o===e.workspaces[l])?e:{...e,workspaces:s}}function lP(e,t,n,s,o){if(n===s||!e.terminals[n]||!e.terminals[s])return e;let l=e.workspaces.map(m=>{const p=m.tabs.findIndex(x=>x.id===t);if(p<0)return m;const b=m.tabs[p];if(!b)return m;const _=Jc(b.root,n);if(!_){const x=m.tabs.filter((R,L)=>L!==p);return{...m,tabs:x}}const S={...b,root:_,activeTerminalId:jn(_)[0]??b.activeTerminalId},w=m.tabs.slice();return w[p]=S,{...m,tabs:w}});const d=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return l=l.map(m=>{const p=m.tabs.findIndex(R=>jn(R.root).includes(s));if(p<0)return m;const b=m.tabs[p];if(!b)return m;const _={type:"pane",terminalId:n},S={type:"split",direction:d,ratio:.5,first:f?_:{type:"pane",terminalId:s},second:f?{type:"pane",terminalId:s}:_},w=th(b.root,s,S),x=m.tabs.slice();return x[p]={...b,root:w,activeTerminalId:n},{...m,tabs:x,activeTabId:b.id}}),N2({...e,workspaces:l})}function C2(e,t,n,s){let o=-1,l=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(W=>W.id===t);if(A>=0){o=L,l=A;break}}if(o<0)return e;const d=e.workspaces[o],f=d.tabs[l],m=jn(f.root);if(!m.includes(n))return e;if(m.length===1)return Zy(e,t,s);const p=Jc(f.root,n);if(!p)return e;const b={...f,root:p,activeTerminalId:jn(p)[0]??f.activeTerminalId},_=e.terminals[n],S={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:_?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=d.tabs.slice();w[l]=b;const x=Math.max(0,Math.min(w.length,s));w.splice(x,0,S);const R=e.workspaces.slice();return R[o]={...d,tabs:w,activeTabId:S.id},{...e,workspaces:R}}function k2(e,t,n,s=Number.MAX_SAFE_INTEGER){const o=D2(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:Zy(e,t,s);const d=jn(o.tab.root),f=d.map(p=>e.terminals[p]).find(Boolean),m=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Ul({...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??ps(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(S=>!d.includes(S)),tabs:b,activeTabId:o.tab.id}}return p});return{...e,workspaces:m,activeWorkspaceId:n}}function cP(e,t,n,s,o=Number.MAX_SAFE_INTEGER){const l=e.workspaces.find(w=>w.id===s),d=D2(e.workspaces,t);if(!l||!d||!e.terminals[n]||!jn(d.tab.root).includes(n))return e;if(d.workspace.id===s)return C2(e,t,n,o);if(jn(d.tab.root).length===1)return k2(e,t,s,o);const m=Jc(d.tab.root,n);if(!m)return e;const p={...d.tab,root:m,activeTerminalId:jn(m)[0]??d.tab.activeTerminalId},b=e.terminals[n],_={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},S=e.workspaces.map(w=>{if(w.id===d.workspace.id)return Ul({...w,tabs:w.tabs.map(x=>x.id===t?p:x)});if(w.id===s){const x=w.tabs.slice(),R=Math.max(0,Math.min(x.length,o));return x.splice(R,0,_),{...w,defaultCwd:w.defaultCwd??ps(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(L=>L!==n),tabs:x,activeTabId:_.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function uP(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 dP(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 hP(e,t,n){const s=n.trim();if(!s)return e;let o=!1;const l=e.workspaces.map(d=>{let f=!1;const m=d.tabs.map(p=>p.id!==t||p.title===s?p:(o=!0,f=!0,{...p,title:s}));return f?{...d,tabs:m}:d});return o?{...e,workspaces:l}:e}function T2(e,t){const n=e.workspaces.find(o=>o.tabs.some(l=>eu(l.root,t))),s=n?.tabs.find(o=>eu(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 fP(e,t,n){const s=Hl(e),o=s?lm(s):void 0;if(!s||!o)return e;const l=jb(o.root,t,z2(n));return l===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===s.id?{...d,tabs:d.tabs.map(f=>f.id===o.id?{...f,root:l}:f)}:d)}}function Ap(e,t,n,s){const o=Object.fromEntries(e.map(_=>[_.id,_])),l=new Set(e.map(_=>_.id)),d=new Set,f=!!(n&&n.some(_=>I2(_))||t&&t.some(_=>P2(_)));let m=_P(t,n,l,d);m.length===0&&(m=[cm()]);const p=typeof s=="string"&&m.some(_=>_.id===s)?s:m[0]?.id??null,b=p??m[0]?.id??om;for(const _ of e)if(!d.has(_.id)){if(f)m=bP(m,b,_.id,_);else{const S=B2(_);m=SP(m,b,S,_)}d.add(_.id)}return{workspaces:m.map(_=>Ul(yP(_,o))),activeWorkspaceId:p,terminals:o}}function Tl(e){return jn(e.root)}function Lp(e){return Ob(e.root)}function Ls(e){return Qy([...e.tabs.flatMap(t=>jn(t.root)),...e.detachedTerminalIds])}function xo(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(o=>{const l=Ab(o.root);return l?[{...o,root:l}]:[]});return Ul({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function pP(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>eu(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function mP(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function E2(e,t){const n={...e.terminals};return delete n[t],R2(e,t,n)}function gP(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(l=>l.id===n)?n:null)??M2(e,t)?.id??A2(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??om,o=e.workspaces.find(l=>l.id===s);return!o||!j2(o,t)?e:R2(e,t,{...e.terminals},{detachToWorkspaceId:s})}function R2(e,t,n,s={}){let o=e.workspaces.map(d=>{const f=[];for(const m of d.tabs){const p=Jc(m.root,t);if(!p)continue;const b=jn(p),_=b.includes(m.activeTerminalId)?m.activeTerminalId:b[0];_&&f.push({...m,root:p,activeTerminalId:_})}return Ul({...d,detachedTerminalIds:d.detachedTerminalIds.filter(m=>m!==t),tabs:f})});s.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===s.detachToWorkspaceId?L2(d,t,n[t]):d));const l=o.some(d=>d.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:l?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function vP(e,t){const n=e.workspaces.map(o=>{const l=[];for(const d of o.tabs){const f=Db(d.root,t);if(!f)continue;const m=jn(f),p=m.includes(d.activeTerminalId)?d.activeTerminalId:m[0];p&&l.push({...d,root:f,activeTerminalId:p})}return Ul({...o,tabs:l})}),s=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function _P(e,t,n,s){if(t&&t.length>0){const o=[];for(const l of t)I2(l)&&o.push(RC(l,n,s));if(o.length>0)return o}return[RC({...cm(),tabs:e??[]},n,s)]}function RC(e,t,n){const s=[];for(const l of e.tabs){if(!P2(l))continue;const d=Mb(l.root,t);if(!d)continue;const f=jn(d);for(const p of f)n.add(p);const m=f.includes(l.activeTerminalId)?l.activeTerminalId:f[0];m&&s.push({...l,root:d,activeTerminalId:m})}const o=[];for(const l of e.detachedTerminalIds??[])!t.has(l)||n.has(l)||(n.add(l),o.push(l));return Ul({...e,defaultCwd:ps(e.defaultCwd),detachedTerminalIds:o,tabs:s})}function N2(e){return Hl(e)?e:{...e,workspaces:[cm()],activeWorkspaceId:om}}function Hl(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function lm(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function D2(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 M2(e,t){return e.workspaces.find(n=>n.tabs.some(s=>eu(s.root,t)))}function A2(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function bP(e,t,n,s){return e.map(o=>o.id===t?L2(o,n,s):o)}function L2(e,t,n){return j2(e,t)?{...e,defaultCwd:e.defaultCwd??ps(n?.cwd),detachedTerminalIds:Qy([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function j2(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Ao}function O2(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function yP(e,t){if(e.defaultCwd)return e;const n=Ls(e).find(o=>!!t[o]),s=n?ps(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function cm(){return{id:om,title:X6,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ul(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:ps(e.defaultCwd),detachedTerminalIds:Qy(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function SP(e,t,n,s){const o=jn(n.root);return e.map(l=>l.id===t?{...l,defaultCwd:l.defaultCwd??ps(s?.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(d=>!o.includes(d)),tabs:[...l.tabs,n],activeTabId:l.activeTabId??n.id}:l)}function B2(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function th(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:th(e.first,t,n),second:th(e.second,t,n)}}function Jc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Jc(e.first,t),s=Jc(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function Db(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=Db(e.first,t),s=Db(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function Mb(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Mb(e.first,t),s=Mb(e.second,t);return n&&s?{...e,ratio:z2(e.ratio),first:n,second:s}:n??s}function Ab(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Ab(e.first),n=Ab(e.second);return t&&n?{...e,first:t,second:n}:t??n}function I2(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 P2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Lb(t.root)}function Lb(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")&&Lb(t.first)&&Lb(t.second):!1}function jb(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=jb(e.first,o,n);return l===e.first?e:{...e,first:l}}if(s===1){const l=jb(e.second,o,n);return l===e.second?e:{...e,second:l}}return e}function z2(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ps(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Qy(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));return n}function eu(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:eu(e.first,t)||eu(e.second,t)}function jn(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...jn(e.first),...jn(e.second)]}function Ob(e){return e.type==="pane"||e.type==="editor"?1:Ob(e.first)+Ob(e.second)}function jp(e,t,n=!1){if(!e)return t;const s=e.agentStatus,o=t.agentStatus,l=Date.parse(e.updatedAt),d=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(d)||d<l)?e:Number.isFinite(d)&&(!Number.isFinite(l)||d>l)?t:e.status!==t.status?e.status==="exited"?e:t:n?e:t}function wP(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 ur=new Map,nh=new Map,ih=new Map,rh=new Map,sh=new Map,Cd=new Set;let Sa=null,xP=0;const Bb=new Set;let H2=0;function Er(e){return e??"__local__"}function CP(e){return{agentId:e,generation:++xP,state:Z6(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,hydration:{requestId:0,layoutSequence:0,metadataSequence:0,pending:null,mutations:new Map,overflow:!1},saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function gt(e){const t=Er(e);let n=ur.get(t);return n||(n=CP(e),ur.set(t,n)),n}function vo(e){return ur.get(Er(e))??null}function U2(e,t){const n=Er(e);let s=nh.get(n);return s||(s=new Set,nh.set(n,s)),s.add(t),()=>{s.delete(t)}}function kP(e){const t=Er(e),n=nh.get(t);if(n)for(const s of Array.from(n))s()}function $l(e,t,n=!0){const s=ur.get(Er(e)),o=n&&NC(s)!==NC(t);ur.set(Er(e),t),kP(e),o&&eS()}function Ib(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 Jy(e,t){const n=e.state.workspaces.find(d=>d.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const s=new Set;for(const d of n.tabs)for(const f of jn(d.root))s.add(f);let o=0,l=0;for(const d of s)Ib(e.state.terminals[d])&&(o+=1),e.unreadCompletions.has(d)&&(l+=1);return{workingTerminalCount:o,unreadCompletionCount:l}}function NC(e){return e?e.state.workspaces.map(t=>{const n=Jy(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function $2(e){return!!(e&&e.state.workspaces.some(t=>{const n=Jy(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function eS(){H2+=1;for(const e of Array.from(Bb))e()}function TP(e){return Bb.add(e),()=>{Bb.delete(e)}}function DC(){return H2}function EP(e,t){return Jy(gt(e),t)}const Pb=new Set;function RP(e){return Pb.add(e),()=>{Pb.delete(e)}}function tS(e,t,n=gt(e).state){const s=Sa;if(!s||s.agentId!==e||s.generation!==ur.get(Er(e))?.generation)return!1;const o=n.workspaces.find(d=>d.id===s.workspaceId),l=o?.tabs.find(d=>d.id===s.tabId);return!!(o?.id===n.activeWorkspaceId&&l?.id===o?.activeTabId&&l?.root===s.root&&n.terminals[t]&&s.terminalIds.has(t))}function Lf(e,t=!0){let n=typeof e=="object"&&e!==null?e:null;if(e!==void 0&&!n&&t){const d=ur.get(Er(e)),f=d?.state.workspaces.find(p=>p.id===d.state.activeWorkspaceId),m=f?.tabs.find(p=>p.id===f.activeTabId);d&&f&&m&&(n={generation:d.generation,agentId:d.agentId,workspaceId:f.id,tabId:m.id,root:m.root,terminalIds:new Set(jn(m.root))})}if(Sa=t&&n?{...n,terminalIds:new Set(jn(n.root).filter(d=>n.terminalIds.has(d)))}:null,!Sa)return;const s=Sa.agentId,o=ur.get(Er(s));if(!o||o.generation!==Sa.generation){Sa=null;return}const l=new Set([...o.unreadCompletions].filter(d=>!tS(s,d,o.state)));l.size!==o.unreadCompletions.size&&($l(s,{...o,unreadCompletions:l}),um())}function kd(e,t){const n=gt(e),s=Er(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&&jp(b,t.terminal)===b&&t.terminal!==b)return}const o=DP(n.state,t);t.type==="workspace.hydrated"&&(ih.delete(s),rh.delete(s),sh.delete(s));const l=Bc(n.state,t);zP(n,t,l);let d=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const b=n.state.terminals[t.terminal.id],_=$P(s),S=FP(s),w=MP(s);if(t.terminal.agentStatus?.source==="hook"){_.delete(t.terminal.id),S.delete(t.terminal.id),w.delete(t.terminal.id);const x=t.terminal.agentStatus.completion;if(x){const R=`${s}:${x.id}`,L=Cd.has(R)||b?.agentStatus?.completion?.id===x.id;W2(R),!L&&t.notifyCompletion===!0&&(f=LC(l,t.terminal.id,t.terminal.currentCommand??null,x.outcome))}}else if(t.terminal.agentStatus){const x=t.terminal.agentStatus.state,R=t.terminal.agentStatus.sessionId,L=w.get(t.terminal.id),A=!!(b&&(b.currentCommand!==t.terminal.currentCommand||b.agentStatus?.provider!==t.terminal.agentStatus.provider||NP(L,R)));A&&(S.delete(t.terminal.id),_.delete(t.terminal.id),w.delete(t.terminal.id)),R&&w.set(t.terminal.id,R),t.notifyCompletion===!0&&(x==="working"?(S.add(t.terminal.id),_.delete(t.terminal.id)):x==="unknown"&&t.terminal.activity==="busy"&&_.add(t.terminal.id)),!A&&(x==="done"||x==="stopped")&&(S.has(t.terminal.id)||_.has(t.terminal.id))&&(f=LC(l,t.terminal.id,b?.currentCommand??null,x==="stopped"?"stopped":"finished"),S.delete(t.terminal.id),_.delete(t.terminal.id)),x==="idle"&&(S.delete(t.terminal.id),_.delete(t.terminal.id))}else b?.agentStatus&&(S.delete(t.terminal.id),w.delete(t.terminal.id)),_.delete(t.terminal.id);f&&!tS(e,t.terminal.id,l)&&!d.has(t.terminal.id)&&(d=new Set(d),d.add(t.terminal.id)),t.terminal.status==="exited"&&(_.delete(t.terminal.id),S.delete(t.terminal.id),w.delete(t.terminal.id))}if(t.type==="terminal.closed"||t.type==="workspace.closed"){const b=new Set([...d].filter(_=>l.terminals[_]));b.size!==d.size&&(d=b)}const m=l!==n.state,p=d!==n.unreadCompletions;if((m||p)&&$l(e,{...n,state:l,unreadCompletions:d},o||p),p&&um(),f)for(const b of Array.from(Pb))b({agentId:e,...f})}function NP(e,t){return e!==void 0&&t!==void 0&&e!==t}function DP(e,t){switch(t.type){case"terminal.updated":return Ib(e.terminals[t.terminal.id])!==Ib(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 MP(e){let t=sh.get(e);return t||(t=new Map,sh.set(e,t)),t}function AP(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(jn(s.root).includes(t))return{workspace:n,tab:s};return null}const zb=new Set;function LP(e){return zb.add(e),()=>{zb.delete(e)}}function jP(){let e=0;for(const t of ur.values())e+=t.unreadCompletions.size;return e}function um(){for(const e of Array.from(zb))e()}function MC(e,t){const n=gt(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]&&Ic(n,s,t.terminals[s]?t.terminals[s].status==="exited"?"exit":"upsert":"delete");$l(e,{...n,state:t})}}function OP(e){const t=gt(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 ah(e,t){const n=ur.get(Er(e));return n?.generation===t.generation&&n.mutable.hydration.pending===t}function AC(e,t){if(!ah(e,t))return;const n=gt(e).mutable.hydration;n.pending=null,n.mutations.clear()}function F2(e,t,n){if(!ah(e,t))return null;const s=gt(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 d of s.state.workspaces.flatMap(Ls)){const f=s.state.terminals[d];f&&l.set(d,f)}for(const d of n){const f=o.mutations.get(d.id);if(f==="delete")continue;const m=s.state.terminals[d.id];l.set(d.id,f==="exit"&&m?m:jp(m,d,!0))}for(const[d,f]of o.mutations)f==="delete"?l.delete(d):s.state.terminals[d]&&l.set(d,jp(l.get(d),s.state.terminals[d]));return[...l.values()]}function BP(e,t,n){if(!ah(e,t)||n.length>0)return!1;const s=gt(e).mutable.hydration;return s.layoutSequence===t.layoutSequence&&s.metadataSequence===t.metadataSequence&&s.mutations.size===0}function IP(e,t,n){const s=F2(e,t,n.terminals);if(!s)return null;const o=gt(e),l=o.mutable.hydration,d=l.metadataSequence!==t.metadataSequence,f=l.layoutSequence!==t.layoutSequence||d,m=f?{...o.state,terminals:Object.fromEntries(s.map(_=>[_.id,_]))}:Ap(s,n.savedTabs,n.savedWorkspaces,n.savedActiveWorkspaceId),p=PP(m,n.savedWorkspaces??n.persistedLayout?.workspaces),b=d?o.lastPersistedLayoutJson:f?n.persistedLayout?JSON.stringify(n.persistedLayout):o.lastPersistedLayoutJson:JSON.stringify(xo(p));l.pending=null,l.mutations.clear();for(const _ of s)_.agentStatus?.source==="hook"&&_.agentStatus.completion&&W2(`${Er(e)}:${_.agentStatus.completion.id}`);return $l(e,{...o,state:p,loaded:!0,error:null,layoutRevision:d?o.layoutRevision:n.revision,lastPersistedLayoutJson:b}),{state:p,layoutPreserved:f,metadataPreserved:d}}function PP(e,t=[]){const n=new Set(e.workspaces.flatMap(Ls)),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)),d=new Map;for(const _ of t)if(l.has(_.id))for(const S of Ls(_))d.has(S)||d.set(S,_.id);const f=e.workspaces.slice(),m=new Set(f.flatMap(_=>_.tabs.map(S=>S.id)));let p=!1;for(const _ of s){const S=f.findIndex(x=>x.id===(d.get(_.id)??o.id)),w=f[S];if(w.detachedTerminalIds.length<Ao)f[S]={...w,detachedTerminalIds:[...w.detachedTerminalIds,_.id]};else{if(!w.tabs.some(L=>L.id===w.activeTabId))throw new Error(`This workspace already has ${Ao} hidden terminal sessions and no selected tab. Re-open or delete hidden sessions before retrying.`);const x=`hydrated-${_.id}`;let R=x;for(let L=1;m.has(R);L++)R=`${x}-${L}`;m.add(R),f[S]={...w,tabs:[...w.tabs,{id:R,title:_.title||_.id,activeTerminalId:_.id,root:{type:"pane",terminalId:_.id}}]},p=!0}}const b={...e,workspaces:f};if(p&&!Kp(xo(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(Cd.add(e);Cd.size>2048;)Cd.delete(Cd.values().next().value)}function Ic(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 zP(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&&Ic(e,t.terminal.id,t.terminal.status==="exited"?"exit":"upsert");else if(t.type==="terminal.created"||t.type==="terminal.split")Ic(e,t.terminal.id,"upsert");else if(t.type==="terminal.exited"&&n.terminals[t.terminalId])Ic(e,t.terminalId,"exit");else if(t.type==="terminal.closed")Ic(e,t.terminalId,"delete");else if(t.type==="workspace.closed")for(const s of Object.keys(e.state.terminals))n.terminals[s]||Ic(e,s,"delete")}function Pv(e,t){const n=gt(e),s=t(n.editors);s!==n.editors&&$l(e,{...n,editors:s},!1)}function _o(e,t,n){const s=gt(e);s.loaded===t&&s.error===n||$l(e,{...s,loaded:t,error:n},!1)}function jf(e,t,n){const s=gt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||(s.mutable.hydration.metadataSequence++,$l(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n},!1))}function HP(e){const t=gt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function UP(e){const t=Er(e),n=ur.get(t);Sa?.agentId===e&&(Sa=null),n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1,o=$2(n);ur.delete(t),nh.delete(t),ih.delete(t),rh.delete(t),sh.delete(t),s&&um(),o&&eS()}function zv(){Sa=null;let e=!1,t=!1;for(const n of ur.values()){const s=n.mutable.saveCoord.saveTimer;s!==null&&window.clearTimeout(s),n.unreadCompletions.size>0&&(e=!0),$2(n)&&(t=!0)}ur.clear(),nh.clear(),ih.clear(),rh.clear(),sh.clear(),e&&um(),t&&eS()}function $P(e){let t=ih.get(e);return t||(t=new Set,ih.set(e,t)),t}function FP(e){let t=rh.get(e);return t||(t=new Set,rh.set(e,t)),t}function LC(e,t,n,s){const o=AP(e,t);return{terminalId:t,tabId:o?.tab.id??null,commandName:n,outcome:s}}function WP(e,t,n){const s=jp(e.terminals[t.id],t,!0);if(s.status!=="running")throw new Error("This terminal is no longer running.");let o=Bc(e,{type:"terminal.updated",terminal:s});if(o.workspaces.some(l=>Ls(l).includes(t.id)))o=Bc(o,{type:"terminal.revealed",terminalId:t.id});else{const l=n?.workspaces.find(d=>Ls(d).includes(t.id));l&&(o.workspaces.some(d=>d.id===l.id)?o=Bc(o,{type:"workspace.selected",workspaceId:l.id}):o=Bc(o,{type:"workspace.created",workspaceId:l.id,title:l.title,defaultCwd:l.defaultCwd})),o=Bc(o,{type:"terminal.created",terminal:s})}if(!Kp(xo(o)))throw new Error("This terminal cannot be opened because the workspace layout limit was reached.");return o}function Hb(e,t){let n=!1,s=!1,o=null,l=!1;for(const d of Tl(e)){const f=t[d];if(!f)continue;if(f.status==="exited"){l=!0,n=!0;continue}const m=f.agentStatus?.state,p=m&&m!=="unknown"?["working","finishing"].includes(m)?"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 nS(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Ub(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function KP(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 qP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,onSelectTab:d,onCreateTab:f,onToggleWorkspaces:m,onCloseTerminals:p,onReattachTerminal:b,onDeleteTerminal:_,onSplitVertical:S,onSplitHorizontal:w,onRenameTab:x,onToggleFavorite:R,onOpenFavorites:L,activePaneAvailable:A}){const[W,z]=v.useState(null),[H,q]=v.useState(!1),[Y,I]=v.useState(null),$=v.useRef(null),de=e.findIndex(T=>T.id===t),me=de>=0?e[de]:e[0]??null,K=me?Hb(me,n):null,ne=me?Lp(me):0,ee=me?Ub(me,n):"No tab";v.useEffect(()=>{$.current?.focus(),$.current?.select()},[W?.tabId]),v.useEffect(()=>{if(!H)return;const T=O=>{O.key==="Escape"&&q(!1)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[H]),v.useEffect(()=>{H&&e.length===0&&q(!1)},[H,e.length]);function Z(T,O){z({tabId:T,title:O})}function X(){if(!W)return;const T=W.title.trim();T&&x(W.tabId,T),z(null)}function M(){return u.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[u.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${qL()}`,onClick:S,disabled:!A,children:u.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),u.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${VL()}`,onClick:w,disabled:!A,children:u.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return u.jsxs(u.Fragment,{children:[u.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[u.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:u.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[u.jsx("span",{}),u.jsx("span",{}),u.jsx("span",{})]})}),u.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:ee,onClick:()=>q(!0),disabled:e.length===0,children:[K?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":K.state,"aria-hidden":"true",title:nS(K)}):null,u.jsx("span",{children:ee}),u.jsxs("small",{children:[de>=0?de+1:0,"/",e.length||0,ne>1?` / ${ne}`:""]})]}),u.jsxs("div",{className:"terminal-tab-list",children:[e.map((T,O)=>{const re=Tl(T),he=Lp(T),N=Ub(T,n),V=T.id===t,se=W?.tabId===T.id,J=Hb(T,n),xe=s?.has(T.id)??!1;return u.jsxs(zt.Fragment,{children:[u.jsx(jC,{index:O}),u.jsx(VP,{tab:T,active:V,editing:se,title:N,paneCount:he,terminalIds:re,canClose:e.length>1,editValue:se?W.title:null,editInputRef:se?$:null,activity:J,unread:xe,favorite:o?.has(T.id)??!1,onSelect:()=>d(T.id),onBeginRename:()=>Z(T.id,N),onCloseAll:()=>p(re),onCommitRename:X,onCancelRename:()=>z(null),onRenameChange:ye=>z({tabId:T.id,title:ye}),onToggleFavorite:()=>R?.(T)})]},T.id)}),u.jsx(jC,{index:e.length}),u.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),u.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>L?.(),children:"★"}),(l?.length??0)>0?u.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(T=>u.jsx(GP,{terminal:T,onReattach:()=>b?.(T.id),onDelete:()=>I(T)},T.id))}):null]}),u.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),A?M():null]}),H?u.jsx(YP,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,editingTab:W,editInputRef:$,onClose:()=>q(!1),onSelectTab:T=>{d(T),q(!1)},onCreateTab:()=>{f(),q(!1)},onBeginRename:Z,onCloseTerminals:T=>{p(T),q(!1)},onCommitRename:X,onCancelRename:()=>z(null),onRenameChange:(T,O)=>z({tabId:T,title:O}),onToggleFavorite:R,onOpenFavorites:L,onReattachTerminal:T=>{b?.(T),q(!1)},onDeleteTerminal:T=>{I(T),q(!1)}}):null,Y?u.jsx(XP,{terminal:Y,onCancel:()=>I(null),onConfirm:()=>{_?.(Y.id),I(null)}}):null]})}function VP({tab:e,active:t,editing:n,title:s,paneCount:o,canClose:l,editValue:d,editInputRef:f,activity:m,unread:p,favorite:b,onSelect:_,onBeginRename:S,onCloseAll:w,onCommitRename:x,onCancelRename:R,onRenameChange:L,onToggleFavorite:A}){const{attributes:W,listeners:z,setNodeRef:H,transform:q,isDragging:Y}=ay({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),I={transform:Ea.Translate.toString(q),opacity:Y?.4:void 0,zIndex:Y?2:void 0};return u.jsxs("div",{ref:H,className:"terminal-tab","data-active":t,"data-dragging":Y,"data-unread":p?"true":void 0,style:I,...W,...z,children:[m?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":m.state,"aria-hidden":"true",title:nS(m)}):null,n&&f&&d!==null?u.jsxs("form",{className:"terminal-tab-editor",onSubmit:$=>{$.preventDefault(),x()},children:[u.jsx("input",{ref:f,"aria-label":`Rename ${s}`,value:d,onBlur:x,onChange:$=>L($.target.value),onKeyDown:$=>{if($.key==="Enter"){$.preventDefault(),x();return}$.key==="Escape"&&($.preventDefault(),R())}}),u.jsx("small",{children:o})]}):u.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:_,onDoubleClick:$=>{$.preventDefault(),S()},children:[u.jsx("span",{children:s}),u.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:u.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":b?`Remove ${s} from favorites`:`Add ${s} to favorites`,title:b?"Remove from favorites":"Add to favorites",onPointerDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),A()},children:b?"★":"☆"}),l&&!n?u.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),w()},children:"x"}):null]})}function YP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,favoriteTabIds:o,detachedTerminals:l,editingTab:d,editInputRef:f,onClose:m,onSelectTab:p,onCreateTab:b,onBeginRename:_,onCloseTerminals:S,onCommitRename:w,onCancelRename:x,onRenameChange:R,onToggleFavorite:L,onOpenFavorites:A,onReattachTerminal:W,onDeleteTerminal:z}){const H=v.useRef(null);return v.useEffect(()=>{H.current?.scrollIntoView?.({block:"nearest"})},[t]),u.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:u.jsxs("section",{className:"mobile-tab-sheet",onClick:q=>q.stopPropagation(),children:[u.jsxs("header",{children:[u.jsxs("div",{children:[u.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),u.jsxs("small",{children:[e.length," open"]})]}),u.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[u.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:b,children:"+"}),u.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{m(),A?.()},children:"★"}),u.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),u.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((q,Y)=>{const I=Tl(q),$=Lp(q),de=Ub(q,n),me=q.id===t,K=d?.tabId===q.id,ne=Hb(q,n),ee=s?.has(q.id)??!1,Z=o?.has(q.id)??!1;return u.jsxs("div",{ref:me?H:null,className:"mobile-tab-sheet-row","data-active":me,"data-unread":ee?"true":void 0,children:[K&&d?u.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:X=>{X.preventDefault(),w()},children:u.jsx("input",{ref:f,"aria-label":`Rename ${de}`,value:d.title,onBlur:w,onChange:X=>R(q.id,X.target.value),onKeyDown:X=>{if(X.key==="Enter"){X.preventDefault(),w();return}X.key==="Escape"&&(X.preventDefault(),x())}})}):u.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${de}`,onClick:()=>p(q.id),children:[u.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),u.jsxs("span",{className:"mobile-tab-sheet-copy",children:[u.jsx("strong",{children:de}),u.jsx("small",{children:KP(q,n,$,ne)})]}),u.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ne?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":ne.state,"aria-hidden":"true",title:nS(ne)}):null,u.jsx("span",{children:$})]})]}),u.jsxs("div",{className:"mobile-tab-sheet-actions",children:[K?u.jsx("button",{type:"button","aria-label":`Done renaming ${de}`,onClick:w,children:"Done"}):u.jsx("button",{type:"button","aria-label":`Rename ${de}`,onClick:()=>_(q.id,de),children:"Rename"}),K?null:u.jsx("button",{type:"button","aria-label":Z?`Remove ${de} from favorites`:`Add ${de} to favorites`,title:Z?"Remove from favorites":"Add to favorites",onClick:()=>L?.(q),children:Z?"★":"☆"}),e.length>1?u.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${de}`,onClick:()=>S(I),children:"×"}):null]})]},q.id)}),(l?.length??0)>0?u.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[u.jsx("span",{children:"Detached"}),(l??[]).map(q=>{const Y=q.title||q.cwd||q.id.slice(0,8);return u.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[u.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>W(q.id),children:[u.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),u.jsxs("span",{className:"mobile-tab-sheet-copy",children:[u.jsx("strong",{children:Y}),u.jsx("small",{children:q.cwd})]}),u.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),u.jsx("div",{className:"mobile-tab-sheet-actions",children:u.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>z(q),children:"×"})})]},q.id)})]}):null]})]})})}function jC({index:e}){const{setNodeRef:t,isOver:n}=Wp({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return u.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function GP({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
58
|
-
${e.cwd}
|
|
59
|
-
(detached — click to re-open, × to delete)`;return u.jsxs("span",{className:"terminal-detached-pill",title:o,children:[u.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),u.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 XP({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:"Delete this terminal?"}),u.jsx("span",{children:s}),u.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}const ZP="nonce-v1",OC=512,Hv=3e4,Uv=1e4;function QP(e){if(e.length>OC||new TextEncoder().encode(e).byteLength>OC)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 JP=1024*1024,ez=1e3,tz=5e3,nz=1e3;function iz(e,t,n,s={...typeof document>"u"?{}:{document},...typeof window>"u"?{}:{window}},o){const l=s.now??Date.now,d=s.document,f=s.window;let m=!1,p=!1,b="",_=0,S=0,w=!1,x=d?.visibilityState==="hidden",R,L,A,W,z=0,H=0,q=0,Y,I=l(),$=-1/0;const de=[],me=()=>!w&&d?.visibilityState!=="hidden",K=ve=>!m&&R===ve,ne=(ve,We)=>!ve.ready&&We>=ve.handshakeUntil||ve.pending!==void 0&&We>=ve.pending.until,ee=()=>{clearTimeout(A),A=void 0},Z=()=>{clearTimeout(W),W=void 0},X=()=>{for(const ve of de.splice(0))ve()},M=ve=>Math.min(3e4,1e3*2**Math.min(ve,5)),T=()=>{m||p||L!==void 0||(L=setTimeout(()=>{L=void 0,Pe()},M(z++)))},O=ve=>{p&&(b=ve,S=l()+M(_++));try{o?.(ve)}catch{}},re=(ve,We=1e3,Oe="activity reconnect",j=!1,ge=!0)=>{if(R===ve){if(R=void 0,ve.pending=void 0,ee(),Z(),ve.socket.onmessage=null,ve.socket.onerror=null,ve.socket.onclose=null,j&&(m=!0,clearTimeout(L),L=void 0,X()),ge)try{ve.socket.close(We,Oe)}catch{}j||T()}},he=()=>{A!==void 0||m||!R||!me()||(A=setTimeout(()=>{A=void 0,J()},ez))},N=ve=>{if(!K(ve)||!ve.ready||!ve.probes||ve.pending||!me())return;if(ve.socket.readyState!==1||ve.socket.bufferedAmount>512){re(ve);return}const We=`${ve.generation}-${++q}`;ve.pending={nonce:We,until:l()+Uv},ve.nextProbeAt=l()+Hv;const Oe={type:"activity.ping",version:1,nonce:We};try{ve.socket.send(JSON.stringify(Oe))}catch{re(ve)}},V=(ve=!1)=>{if(m||!me())return;if(I=l(),$=I,p){O(b);return}const We=R;We&&(We.pending=void 0,We.ready?We.probes?N(We):re(We):((ve||!Number.isFinite(We.handshakeUntil))&&(We.handshakeUntil=I+Uv),We.resumeProbe=!0),he())},se=()=>{const ve=l();return ve>=I&&ve-I<=tz?!1:(Z(),V(!0),!0)},J=()=>{if(m||!me()||!R)return;se(),I=l();const ve=R;ve&&(ne(ve,I)?re(ve):ve.ready&&I>=ve.nextProbeAt&&N(ve),he())},xe=()=>{if(m||!me()||W!==void 0||!p&&l()>=$&&l()-$<nz)return;const ve=p?Math.min(3e4,Math.max(0,S-l())):0;W=setTimeout(()=>{W=void 0,V()},ve)},ye=()=>{R&&(R.pending=void 0,R.ready||(R.handshakeUntil=1/0)),ee(),Z(),$=-1/0},Pe=()=>{if(m||p)return;const ve=Y;let We;try{const Me=new URL(e);ve&&Me.searchParams.set("cursor",ve),We=t(Me.toString())}catch{T();return}const Oe={socket:We,generation:++H,ready:!1,probes:!1,handshakeUntil:me()?l()+Uv:1/0,nextProbeAt:1/0,pending:void 0,resumeProbe:!1};R=Oe,I=l();let j=ve!==void 0,ge=!1;We.onmessage=Me=>{if(K(Oe)&&(me()&&se(),!!K(Oe))){if(me()&&ne(Oe,l())){re(Oe);return}try{if(typeof Me.data!="string"||Me.data.length>JP)throw new Error("invalid activity frame");const Le=JSON.parse(Me.data);if(Le?.type==="activity.pong"){const F=QP(Me.data);if(!Oe.ready||!Oe.probes||!F)throw new Error("invalid activity probe");me()&&Oe.pending?.nonce===F.nonce&&(Oe.pending=void 0,Oe.nextProbeAt=l()+Hv);return}if(Le?.type==="activity.ready"){if(Oe.ready||Le.version!==1||!BC(Le.cursor)||!["snapshot","resume","gap"].includes(Le.mode)||(Le.mode==="resume"?!ve:!ge))throw new Error("invalid activity acknowledgement");Y=Le.cursor,Oe.ready=!0,Oe.probes=Le.probe===ZP,Oe.nextProbeAt=l()+Hv,j=!0,z=0,Oe.resumeProbe&&N(Oe),he();return}if(!sz(Le)||!j&&!Le.initial)throw new Error("invalid activity snapshot");if(Le.initial)ge=!0;else if(!BC(Le.cursor))throw new Error("activity cursor required");j=!0,n(Le),(Oe.ready||!ge&&ve)&&(Y=Le.cursor)}catch{re(Oe,1e3,"invalid activity message",!0)}}},We.onerror=()=>{K(Oe)&&(re(Oe),Oe.ready||O("activity handshake failed"))},We.onclose=Me=>{if(!K(Oe))return;const Le=Me.code===1008&&rz(Me.reason);Le&&(p=!0),re(Oe,Me.code,"",Me.code===1008&&!Le,!1),Le?O(Me.reason):Me.code!==1008&&!Oe.ready&&O("activity handshake failed")},he()},Fe=(ve,We,Oe)=>{ve?.addEventListener(We,Oe),de.push(()=>ve?.removeEventListener(We,Oe))};Fe(d,"visibilitychange",()=>{const ve=x;x=d?.visibilityState==="hidden",x?ye():ve&&xe()}),Fe(d,"freeze",()=>{w=!0,ye()}),Fe(d,"resume",()=>{w=!1,xe()}),Fe(f,"pagehide",()=>{w=!0,ye()}),Fe(f,"pageshow",ve=>{const We=w;w=!1,(We||ve.persisted)&&xe()}),Fe(f,"offline",()=>{$=-1/0}),Fe(f,"online",xe),Pe();const ze=()=>{m=!0,clearTimeout(L),L=void 0,ee(),Z(),X(),R&&re(R,1e3,"activity disposed",!0)};return ze.reauthenticate=()=>{m||!p||(Z(),p=!1,b="",_=0,S=0,T())},ze}function rz(e){return["unauthorized","session expired","session revoked","authentication no longer valid"].includes(e?.trim().toLowerCase()??"")}function BC(e){return typeof e=="string"&&e.length<=128&&/^[a-f0-9-]+:\d+$/.test(e)}function sz(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 IC=0,Zf;const $b=new Set;let oh;function az(e){return $b.add(e),oh!==void 0&&e(oh),()=>{$b.delete(e)}}function oz(){oh=void 0,Zf?.reauthenticate()}function lz(e=!0){v.useEffect(()=>{if(e){if(IC++===0){const t=new URL("/api/activity/ws",window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:",Zf=uz(t.toString(),void 0,void 0,n=>{oh=n;for(const s of $b)s(n)})}return()=>{--IC===0&&(Zf?.(),Zf=void 0,oh=void 0)}}},[e])}function cz(e){for(const t of e.terminals){const n=gt(e.agentId).state.terminals[t.id];e.initial&&n&&Date.parse(t.updatedAt)<Date.parse(n.updatedAt)||kd(e.agentId,{type:"terminal.updated",terminal:t,notifyCompletion:!e.initial})}}function uz(e,t=o=>new WebSocket(o),n=cz,s){return iz(e,t,n,void 0,s)}function K2(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function dz(e,t){return e.reduce((n,s,o)=>{const l=t.get(s);return l&&(n[o]=l),n},Array(e.length))}function Of(e){return e!==null&&e>=0}function hz(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 fz(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const iS=e=>{let{rects:t,activeIndex:n,overIndex:s,index:o}=e;const l=K2(t,s,n),d=t[o],f=l[o];return!f||!d?null:{x:f.left-d.left,y:f.top-d.top,scaleX:f.width/d.width,scaleY:f.height/d.height}},Bf={scaleX:1,scaleY:1},pz=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:o,rects:l,overIndex:d}=e;const f=(t=l[n])!=null?t:s;if(!f)return null;if(o===n){const p=l[d];return p?{x:0,y:n<d?p.top+p.height-(f.top+f.height):p.top-f.top,...Bf}:null}const m=mz(l,o,n);return o>n&&o<=d?{x:0,y:-f.height-m,...Bf}:o<n&&o>=d?{x:0,y:f.height+m,...Bf}:{x:0,y:0,...Bf}};function mz(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 q2="Sortable",V2=zt.createContext({activeIndex:-1,containerId:q2,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:iS,disabled:{draggable:!1,droppable:!1}});function gz(e){let{children:t,id:n,items:s,strategy:o=iS,disabled:l=!1}=e;const{active:d,dragOverlay:f,droppableRects:m,over:p,measureDroppableContainers:b}=Sk(),_=uh(q2,n),S=f.rect!==null,w=v.useMemo(()=>s.map(Y=>typeof Y=="object"&&"id"in Y?Y.id:Y),[s]),x=d!=null,R=d?w.indexOf(d.id):-1,L=p?w.indexOf(p.id):-1,A=v.useRef(w),W=!hz(w,A.current),z=L!==-1&&R===-1||W,H=fz(l);hs(()=>{W&&x&&b(w)},[W,w,x,b]),v.useEffect(()=>{A.current=w},[w]);const q=v.useMemo(()=>({activeIndex:R,containerId:_,disabled:H,disableTransforms:z,items:w,overIndex:L,useDragOverlay:S,sortedRects:dz(w,m),strategy:o}),[R,_,H.draggable,H.droppable,z,w,L,m,S,o]);return zt.createElement(V2.Provider,{value:q},t)}const vz=e=>{let{id:t,items:n,activeIndex:s,overIndex:o}=e;return K2(n,s,o).indexOf(t)},_z=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:o,items:l,newIndex:d,previousItems:f,previousContainerId:m,transition:p}=e;return!p||!s||f!==l&&o===d?!1:n?!0:d!==o&&t===m},bz={duration:200,easing:"ease"},Y2="transform",yz=Ea.Transition.toString({property:Y2,duration:0,easing:"linear"}),Sz={roleDescription:"sortable"};function wz(e){let{disabled:t,index:n,node:s,rect:o}=e;const[l,d]=v.useState(null),f=v.useRef(n);return hs(()=>{if(!t&&n!==f.current&&s.current){const m=o.current;if(m){const p=iu(s.current,{ignoreTransform:!0}),b={x:m.left-p.left,y:m.top-p.top,scaleX:m.width/p.width,scaleY:m.height/p.height};(b.x||b.y)&&d(b)}}n!==f.current&&(f.current=n)},[t,n,s,o]),v.useEffect(()=>{l&&d(null)},[l]),l}function xz(e){let{animateLayoutChanges:t=_z,attributes:n,disabled:s,data:o,getNewIndex:l=vz,id:d,strategy:f,resizeObserverConfig:m,transition:p=bz}=e;const{items:b,containerId:_,activeIndex:S,disabled:w,disableTransforms:x,sortedRects:R,overIndex:L,useDragOverlay:A,strategy:W}=v.useContext(V2),z=Cz(s,w),H=b.indexOf(d),q=v.useMemo(()=>({sortable:{containerId:_,index:H,items:b},...o}),[_,o,H,b]),Y=v.useMemo(()=>b.slice(b.indexOf(d)),[b,d]),{rect:I,node:$,isOver:de,setNodeRef:me}=Wp({id:d,data:q,disabled:z.droppable,resizeObserverConfig:{updateMeasurementsFor:Y,...m}}),{active:K,activatorEvent:ne,activeNodeRect:ee,attributes:Z,setNodeRef:X,listeners:M,isDragging:T,over:O,setActivatorNodeRef:re,transform:he}=ay({id:d,data:q,attributes:{...Sz,...n},disabled:z.draggable}),N=jN(me,X),V=!!K,se=V&&!x&&Of(S)&&Of(L),J=!A&&T,xe=J&&se?he:null,Pe=se?xe??(f??W)({rects:R,activeNodeRect:ee,activeIndex:S,overIndex:L,index:H}):null,Fe=Of(S)&&Of(L)?l({id:d,items:b,activeIndex:S,overIndex:L}):H,ze=K?.id,ve=v.useRef({activeId:ze,items:b,newIndex:Fe,containerId:_}),We=b!==ve.current.items,Oe=t({active:K,containerId:_,isDragging:T,isSorting:V,id:d,index:H,items:b,newIndex:ve.current.newIndex,previousItems:ve.current.items,previousContainerId:ve.current.containerId,transition:p,wasDragging:ve.current.activeId!=null}),j=wz({disabled:!Oe,index:H,node:$,rect:I});return v.useEffect(()=>{V&&ve.current.newIndex!==Fe&&(ve.current.newIndex=Fe),_!==ve.current.containerId&&(ve.current.containerId=_),b!==ve.current.items&&(ve.current.items=b)},[V,Fe,_,b]),v.useEffect(()=>{if(ze===ve.current.activeId)return;if(ze!=null&&ve.current.activeId==null){ve.current.activeId=ze;return}const Me=setTimeout(()=>{ve.current.activeId=ze},50);return()=>clearTimeout(Me)},[ze]),{active:K,activeIndex:S,attributes:Z,data:q,rect:I,index:H,newIndex:Fe,items:b,isOver:de,isSorting:V,isDragging:T,listeners:M,node:$,overIndex:L,over:O,setNodeRef:N,setActivatorNodeRef:re,setDroppableNodeRef:me,setDraggableNodeRef:X,transform:j??Pe,transition:ge()};function ge(){if(j||We&&ve.current.newIndex===H)return yz;if(!(J&&!Up(ne)||!p)&&(V||Oe))return Ea.Transition.toString({...p,property:Y2})}}function Cz(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}}Gt.Down,Gt.Right,Gt.Up,Gt.Left;function kz({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:s=null,getRuntimeStatus:o,onClose:l,onOpen:d,onRemove:f,onReorder:m}){const p=v.useRef(null),[b,_]=v.useState(()=>Date.now()),[S,w]=v.useState("grid"),[x,R]=v.useState(null),L=nk(op(iy,{activationConstraint:{distance:6}}),op(ry,{activationConstraint:{delay:180,tolerance:8}})),A=v.useMemo(()=>e.map(us),[e]),W=v.useMemo(()=>new Map(e.map(I=>[us(I),o?.(I)??null])),[e,o,b]);v.useEffect(()=>{const I=window.setInterval(()=>_(Date.now()),3e4);return()=>window.clearInterval(I)},[]),v.useEffect(()=>{const I=$=>{if($.key==="Escape"){$.preventDefault(),$.stopImmediatePropagation(),l();return}const de=$.target;if((de instanceof HTMLInputElement||de instanceof HTMLTextAreaElement)&&p.current?.contains(de)||$.ctrlKey||$.altKey||$.metaKey)return;const me=Number.parseInt($.key,10)-1;me>=0&&me<Math.min(9,e.length)&&($.preventDefault(),$.stopImmediatePropagation(),d(e[me]))};return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[e,l,d]);const z=I=>{R(null);const $=String(I.active.id),de=I.over?String(I.over.id):null;if(!de||$===de)return;const me=e.find(ne=>us(ne)===$),K=e.find(ne=>us(ne)===de);me&&K&&m(me,K)},H=I=>R({activeId:String(I.active.id),overId:null}),q=I=>{const $=String(I.active.id),de=I.over?String(I.over.id):null;R(me=>me?.activeId===$&&me.overId===de?me:{activeId:$,overId:de})},Y=x?e.find(I=>us(I)===x.activeId)??null:null;return u.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:l,children:u.jsxs("section",{ref:p,className:"favorite-tabs-dialog",onClick:I=>I.stopPropagation(),children:[u.jsxs("header",{className:"favorite-tabs-header",children:[u.jsxs("div",{children:[u.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",u.jsx("span",{children:e.length})]}),u.jsx("p",{children:"Press 1–9 to open a favorite"})]}),u.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[u.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":S==="grid",onClick:()=>w("grid"),children:"▦"}),u.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":S==="list",onClick:()=>w("list"),children:"☷"}),u.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:l,children:"×"})]})]}),u.jsxs(yk,{sensors:L,collisionDetection:JN,onDragStart:H,onDragOver:q,onDragEnd:z,onDragCancel:()=>R(null),children:[u.jsxs("div",{className:"favorite-tabs-list","data-view":S,children:[s?u.jsx("p",{className:"favorite-tabs-error",role:"alert",children:s}):null,e.length===0?u.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):u.jsx(gz,{items:A,strategy:S==="grid"?iS:pz,children:e.map((I,$)=>u.jsx(Tz,{favorite:I,index:$,busy:n,unavailable:t?.has(us(I))??!1,runtimeStatus:W.get(us(I))??null,now:b,isDropTarget:x?.overId===us(I)&&x.activeId!==us(I),onOpen:d,onRemove:f},us(I)))})]}),u.jsx(oM,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:Y?u.jsx(Ez,{favorite:Y}):null})]})]})})}const Tz=v.memo(function({favorite:t,index:n,busy:s,unavailable:o,runtimeStatus:l,now:d,isDropTarget:f,onOpen:m,onRemove:p}){const b=us(t),{attributes:_,listeners:S,setActivatorNodeRef:w,setNodeRef:x,transform:R,transition:L,isDragging:A}=xz({id:b,disabled:s,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),W={transform:Ea.Transform.toString(R),transition:L,zIndex:A?1:void 0,opacity:A?.16:void 0};return u.jsxs("div",{ref:x,className:"favorite-tab-row","data-dragging":A||void 0,"data-drop-target":f||void 0,style:W,children:[u.jsx("button",{ref:w,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:z=>z.stopPropagation(),..._,...S,children:"⋮⋮"}),u.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>m(t),disabled:s||o,title:o?"Server is no longer registered":void 0,children:[u.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),u.jsxs("span",{className:"favorite-tab-copy",children:[u.jsx("strong",{children:t.tabName}),u.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),l&&!o?u.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${l.state}`,title:"Last observed terminal status",children:[u.jsx("i",{"aria-hidden":"true"}),Rz(l.state),l.lastActivityAt?` · ${Nz(l.lastActivityAt,d)}`:""]}):null,l?.unread&&!o?u.jsxs("small",{className:"favorite-tab-runtime favorite-tab-runtime--unread",title:"Unread completion",children:[u.jsx("i",{"aria-hidden":"true"}),"Unread"]}):null]}),u.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(z=>u.jsx("img",{src:`/brand/${z}.webp`,alt:"","aria-hidden":"true"},z)),u.jsx("em",{children:t.paneCount})]})]}),u.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:s,onClick:()=>p(t),children:"×"})]})}),Ez=v.memo(function({favorite:t}){return u.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[u.jsx("span",{className:"favorite-tab-index",children:"★"}),u.jsxs("span",{className:"favorite-tab-copy",children:[u.jsx("strong",{children:t.tabName}),u.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),u.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(n=>u.jsx("img",{src:`/brand/${n}.webp`,alt:""},n)),u.jsx("em",{children:t.paneCount})]})]})});function us(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function Rz(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function Nz(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 Dz({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:o}){if(e.length===0)return null;const d=e.some(m=>m.status==="failed"||m.status==="partial")?"alert":"status",f=e.filter(m=>m.status==="queued"||m.status==="uploading").length;return u.jsxs("aside",{className:`upload-toast upload-toast-${Oz(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[u.jsxs("header",{className:"upload-toast-header",children:[u.jsx("strong",{children:e.length===1?Qf(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),u.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),u.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(m=>u.jsx(Mz,{upload:m,compact:e.length>1,onDismiss:()=>t(m.id),onRetry:()=>s(m.id),onCancel:()=>o(m.id)},m.id))})]})}function Mz({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:o}){const l="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return u.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Qf(e),children:[u.jsxs("div",{className:"upload-queue-item-header",children:[u.jsx("strong",{children:Qf(e)}),u.jsxs("div",{className:"upload-queue-actions",children:[f?u.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?u.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,u.jsx("button",{type:"button","aria-label":`Dismiss ${Qf(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?u.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?u.jsx(Az,{toast:e}):null,l&&"message"in e&&e.message?u.jsx("p",{className:"upload-toast-muted",children:e.message}):null,l?u.jsx(Lz,{response:l,compact:t}):null,e.status==="failed"&&!l&&e.message?u.jsx("p",{children:e.message}):null]})}function Az({toast:e}){const t=e.percent===null?Bz(e.loaded):`${e.percent}%`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"upload-progress-row",children:[u.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),u.jsx("span",{children:t})]}),u.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:u.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function Lz({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),s=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,l=[...n,...s].slice(0,o);return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),l.length>0?u.jsx("ul",{className:"upload-result-list",children:l.map((d,f)=>u.jsx(jz,{result:d},`${d.relativePath}-${f}`))}):null,e.results.length>l.length?u.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-l.length," more"]}):null]})}function jz({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return u.jsxs("li",{"data-status":e.status,children:[u.jsx("span",{className:"upload-result-path",children:t}),n?u.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?u.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Qf(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 Oz(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 Bz(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function Iz({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 d(m){m.stopPropagation(),n()}function f(m){m.target===m.currentTarget&&(m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),t(s)))}return u.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:f,children:[u.jsxs("header",{className:"completion-toast-header",children:[u.jsxs("div",{className:"completion-toast-copy",children:[u.jsx("strong",{children:s.tabTitle}),u.jsx("span",{children:l})]}),u.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:m=>m.stopPropagation(),children:"x"})]}),u.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const Pz=Ed(0,0,1,1),ba=1e-6;function zz(e){return G2(e).map(t=>t.terminalId)}function G2(e){return Td(e,Pz).sort(Fz).map((t,n)=>({...t,index:n+1}))}function Hz(e,t,n){const s=G2(e),o=s.find(d=>d.terminalId===t);return o?s.filter(d=>d.terminalId!==t).map(d=>$z(o,d,n)).filter(d=>d!==null).sort(Wz)[0]?.entry.terminalId??null:null}function Uz(e,t){return!Number.isInteger(t)||t<1?null:zz(e)[t-1]??null}function Td(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=Kz(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Td(e.first,Ed(t.left,t.top,o,t.bottom)),...Td(e.second,Ed(o,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...Td(e.first,Ed(t.left,t.top,t.right,s)),...Td(e.second,Ed(t.left,s,t.right,t.bottom))]}function $z(e,t,n){const s=e.bounds,o=t.bounds,l=PC(s.left,s.right,o.left,o.right),d=PC(s.top,s.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=s.centerX-ba||d<=ba?null:{entry:t,primaryDistance:Math.max(0,s.left-o.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:d};case"right":return o.centerX<=s.centerX+ba||d<=ba?null:{entry:t,primaryDistance:Math.max(0,o.left-s.right),perpendicularDistance:Math.abs(s.centerY-o.centerY),overlap:d};case"up":return o.centerY>=s.centerY-ba||l<=ba?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+ba||l<=ba?null:{entry:t,primaryDistance:Math.max(0,o.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-o.centerX),overlap:l};default:return null}}function Fz(e,t){return $c(e.bounds.top,t.bounds.top)||$c(e.bounds.left,t.bounds.left)}function Wz(e,t){return $c(e.primaryDistance,t.primaryDistance)||$c(e.perpendicularDistance,t.perpendicularDistance)||$c(t.overlap,e.overlap)||$c(e.entry.index,t.entry.index)}function $c(e,t){const n=e-t;return Math.abs(n)<=ba?0:n}function PC(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function Ed(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function Kz(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const zC="nterminal.terminalWorkspaces.v2",X2="nterminal.sidebarCollapsed.v1",qz=75,HC=xk.map(e=>e.url),Vz=xk[0].url,Yz=6;function Gz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:o=null,previewMode:l=!1,onLogout:d=async()=>{},onSessionInvalid:f}){lz();const m=v.useMemo(()=>e??Ip(),[e]),p=v.useMemo(()=>t??Rs(null),[t]),b=v.useMemo(()=>g8(n),[n]),_=v.useMemo(()=>C=>U2(n,C),[n]),S=v.useMemo(()=>()=>gt(n),[n]),w=v.useSyncExternalStore(_,S,S),x=w.state,R=w.editors,L=!w.loaded,A=w.error,[W,z]=v.useState(!1),[H,q]=v.useState(()=>x8()),[Y,I]=v.useState("servers"),[$,de]=v.useState(!1),[me,K]=v.useState(!1),[ne,ee]=v.useState([]),[Z,X]=v.useState(!1),[M,T]=v.useState(null),[O,re]=v.useState(null),[he,N]=v.useState(null),V=v.useMemo(()=>Rs(he?.agentId??null),[he?.agentId]),se=v.useMemo(()=>Rs(O?.agentId??null),[O?.agentId]),J=v.useSyncExternalStore(ij,q1,q1);v.useSyncExternalStore(jd,K1,K1);const[xe,ye]=v.useState(0),[Pe,Fe]=v.useState(null),[ze,ve]=v.useState(()=>[null]),[We,Oe]=v.useState(()=>({[Zt]:"Local"})),j=v.useRef(new Set),[ge,Me]=v.useState(0),[Le,F]=v.useState(()=>[n]),[pe,Ce]=v.useState(()=>new Set),[Re,je]=v.useState({}),[be,Ue]=v.useState(null),$e=v.useRef(0),Be=v.useRef(0),[ot,ct]=v.useState(null),[ht,jt]=v.useState(null),Qt=v.useRef(null),rt=v.useRef(0),Yn=v.useRef(null),_n=v.useRef(null),pt=v.useRef(null),Et=v.useRef(null),Nt=v.useRef([]),Di=v.useRef(0),Gn=v.useRef(!1),nn=v.useRef(0),fn=v.useRef(0),te=v.useRef([]),Ke=v.useRef(null),et=v.useRef(null),bt=v.useRef(null),Pt=v.useRef(!0),[bn,Ft]=v.useState(0),pn=v.useRef(()=>{});v.useEffect(()=>(Pt.current=!0,()=>{Pt.current=!1}),[]);const[Jt,Dt]=v.useState(null),yn=nk(op(iy,{activationConstraint:{distance:8}}),op(ry,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>rj(m),[m]);function Sn(C){const E=C.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Dt({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Dt({tabId:E.sourceTabId,terminalId:E.terminalId})}}function Dn(C){Dt(null);const E=C.active.data.current,B=C.over?.data.current;if(!(!E||!B||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){mt({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){mt({type:"tab.moved_to_workspace",sourceTabId:E.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")&&mt({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){mt({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){mt({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.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")&&mt({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function rn(){Dt(null)}const ft=x.workspaces.find(C=>C.id===x.activeWorkspaceId)??x.workspaces[0],wt=ft?.tabs.find(C=>C.id===ft.activeTabId)??ft?.tabs[0],wn=wt?.activeTerminalId??null,oe=wn?x.terminals[wn]:void 0,ke=h8("(max-width: 760px)"),Xe=v.useMemo(()=>wt?Op(wt.root):[],[wt]),qe=ft&&wt?Rd(n,ft.id,wt.id):null,nt=wt?Z2(Xe,wt.activeTerminalId,qe?Re[qe]:void 0):null,sn=ke&&Xe.length>1;v.useLayoutEffect(()=>{Xn.current=n;const C=()=>{if(Lf(void 0),document.visibilityState!=="visible"||!w.loaded||ns()||!ft||!wt)return;const E=gt(n);E.generation!==w.generation||E.state!==x||Lf({generation:w.generation,agentId:n,workspaceId:ft.id,tabId:wt.id,root:wt.root,terminalIds:wP(wt.root,sn?nt:null)})};return C(),document.addEventListener("visibilitychange",C),()=>{document.removeEventListener("visibilitychange",C),Lf(void 0)}},[n,x,w.generation,w.loaded,w.error,ft?.id,wt?.id,wt?.root,wt?.activeTerminalId,ke,nt,bn]);const On=v.useMemo(()=>(ft?.detachedTerminalIds??[]).flatMap(C=>{const E=x.terminals[C];return E?[E]:[]}),[ft?.detachedTerminalIds,x.terminals]),dr=v.useMemo(()=>{const C=new Set;for(const E of ft?.tabs??[])Tl(E).some(B=>w.unreadCompletions.has(B))&&C.add(E.id);return C},[ft?.tabs,w.unreadCompletions]);v.useSyncExternalStore(TP,DC,DC);const[Xt,Xi]=v.useState([]),Mn=v.useRef([]),Bn=v.useRef(null),[hr,Ci]=v.useState(null),[an,Zi]=v.useState(null),[ms,fr]=v.useState([]),[Mi,Fl]=v.useState(()=>Al()),Aa=v.useRef(0),Xn=v.useRef(n),Rr=v.useRef(HC),Bs=v.useRef(Mi),pr=v.useRef(()=>{});pr.current=Pa,pn.current=Ha;const ri=v.useCallback(async()=>{try{const C=await m.listNotificationAssets();fr(C.assets.filter(E=>E.enabled).map(E=>E.url))}catch{fr([])}},[m]),ki=v.useCallback(C=>{for(const E of C)j.current.add(Cl(E.agentId));Oe(E=>{const B={...E};for(const Q of C)B[Cl(Q.agentId)]=Q.label;return Fv(E,B)?E:B})},[]);v.useEffect(()=>{const C=fn.current+1;fn.current=C;const E=nn.current;m.getFavorites().then(B=>{C!==fn.current||E!==nn.current||(Li(B.favorites,B.revision),Mr(B.favorites,n,x))}).catch(()=>{})},[m]),v.useEffect(()=>{Mr(Nt.current,n,x)},[n,We]),v.useEffect(()=>{F(C=>C.some(E=>hi(E,n))?C:[...C,n])},[n]);const Qi=v.useCallback(C=>{const E=gt(C),B=Rs(C);for(const Q of Object.keys(E.state.terminals))xd(B.createWebSocketUrl(Q)),Rf(Q),wd(Q);UP(C),F(Q=>Q.filter(ae=>!hi(ae,C))),Ce(Q=>{const ae=`${ep(C)}:`;let le=!1;const Te=new Set;for(const Ie of Q){if(Ie.startsWith(ae)){le=!0;continue}Te.add(Ie)}return le?Te:Q}),je(Q=>{const ae=`${ep(C)}:`;let le=!1;const Te={};for(const[Ie,Ve]of Object.entries(Q)){if(Ie.startsWith(ae)){le=!0;continue}Te[Ie]=Ve}return le?Te:Q})},[]);v.useEffect(()=>{let C=!1;return m.getMainInfo().then(E=>{if(C)return;const B=E.name?.trim()||"Local";j.current.add(Zt),Oe(Q=>{const ae={...Q,[Zt]:B};return Fv(Q,ae)?Q:ae})}).catch(()=>{}),m.listAgents().then(E=>{if(!C){const B=E.agents.map(le=>le.id),Q=IA(E.serverOrder,E.agents);for(const le of E.agents)j.current.add(Cl(le.id));Oe(le=>{const Te={[Zt]:le[Zt]??"Local"};for(const Ie of E.agents)Te[Ie.id]=Ie.name;return Fv(le,Te)?le:Te}),n!==null&&!B.includes(n)&&(Qi(n),s?.(null));const ae=Et.current;ae&&ae.serverId!==Zt&&!B.includes(ae.serverId)&&(Et.current=null,T(`${ae.serverName} is no longer registered.`),K(!0)),ve(Q)}}).catch(()=>{}),()=>{C=!0}},[n,m,Qi,s,ge]);const Ho=v.useCallback(C=>{Qi(C),Me(E=>E+1),hi(C,Xn.current)&&s?.(null)},[Qi,s]);v.useEffect(()=>{ve(C=>C.some(E=>hi(E,n))?C:[...C,n])},[n]),v.useEffect(()=>{Fe(null)},[n]),v.useEffect(()=>{const C=Yn.current;if(!C)return;if(!hi(C.agentId,n)){Yn.current=null;return}if(!w.loaded||x.workspaces.length===0)return;Yn.current=null;const E=C.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];E&&E.id!==x.activeWorkspaceId&&mt({type:"workspace.selected",workspaceId:E.id})},[n,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const C=_n.current;if(C){if(!hi(C.agentId,n)){_n.current=null;return}w.loaded&&(_n.current=null,x.workspaces.some(E=>E.id===C.workspaceId)&&mt({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,w.loaded,x.workspaces]),v.useEffect(()=>{const C=pt.current;if(C){if(!hi(C.agentId,n)){pt.current=null;return}w.loaded&&(pt.current=null,w.error||Is())}},[n,w.error,w.loaded]),v.useEffect(()=>{const C=Et.current;if(!(!C||!hi(C.serverId===Zt?null:C.serverId,n)||!w.loaded)){if(Et.current=null,w.error){T(`Could not reach ${C.serverName}.`),K(!0);return}Us(C)}},[n,w.loaded]),v.useEffect(()=>{const C=()=>{const Q=p8();Q&&pn.current(Q)},E=Q=>{const ae=m8(Q.data);ae&&pn.current(ae)},B=Q=>{const ae=qp(Q.detail);ae&&pn.current(ae)};return C(),window.addEventListener("hashchange",C),window.addEventListener(Zv,B),navigator.serviceWorker?.addEventListener?.("message",E),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(Zv,B),navigator.serviceWorker?.removeEventListener?.("message",E)}},[]),v.useEffect(()=>{ri()},[ri]),v.useEffect(()=>Lk(()=>Fl(Al())),[]),v.useEffect(()=>{const C=E=>{pr.current(E)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{Rr.current=ms.length>0?ms:HC},[ms]),v.useEffect(()=>{Bs.current=Mi},[Mi]),v.useEffect(()=>{if(!w.loaded||!ft||!wt)return;const C=Rd(n,ft.id,wt.id);Ce(E=>{if(E.has(C))return E;const B=new Set(E);return B.add(C),B})},[n,w.loaded,ft?.id,wt?.id]),v.useEffect(()=>()=>{uu()},[]),v.useEffect(()=>{const C=rA(m),E=oA(m);return()=>{C(),E()}},[m]),v.useEffect(()=>RP(C=>{const E=gt(C.agentId).state,B=E.workspaces.flatMap(Te=>Te.tabs).find(Te=>Te.id===C.tabId),Q=E.terminals[C.terminalId],ae=B?.title?.trim()||Q?.title||C.commandName||"terminal",le=tS(C.agentId,C.terminalId);if(le||QM({agentId:C.agentId,tabTitle:ae,commandName:C.commandName,terminalId:C.terminalId,outcome:C.outcome}),!le&&document.visibilityState==="visible"&&Bs.current.enabled){const Te=Aa.current+1;Aa.current=Te;const Ie=Rr.current;Ci({id:Te,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:ae,commandName:C.commandName,outcome:C.outcome,assetSrc:Ie[Math.floor(Math.random()*Ie.length)]??Vz})}}),[]),v.useEffect(()=>{if(!hr||Mi.persistUntilDismissed)return;const C=window.setTimeout(()=>{Ci(E=>E?.id===hr.id?null:E)},Mi.durationSeconds*1e3);return()=>window.clearTimeout(C)},[hr,Mi]),v.useEffect(()=>{C8(H),H&&zi()},[H]),v.useEffect(()=>{let C=!1,E;async function B(){if(!gt(n).loaded){E=OP(n),_o(n,!1,null);try{let ae=null,le=null;try{ae=v8(b)}catch(Ve){if(!(Ve instanceof Bp))throw Ve;le=Ve}const[Te,Ie]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]);if(!C&&ah(n,E)){const Ve=Ie.layout?Wb(Ie.layout):null;if(!Ve&&le)throw le;const Ge=Ve??ae??{};let _t=Te.terminals;const Cn=F2(n,E,_t);if(!Cn)return;if(BP(n,E,Cn)){const Fa=await p.createTerminal({cols:80,rows:24});_t=[..._t,Fa.terminal]}if(C)return;const Rt=IP(n,E,{terminals:_t,...Ge,revision:Ie.revision,persistedLayout:Ie.layout});if(!Rt)return;const kn=xo(Rt.state),du=gt(n);(Rt.layoutPreserved&&JSON.stringify(kn)!==du.lastPersistedLayoutJson||!Rt.metadataPreserved&&!Ve&&ae)&&Ys(kn,{},E.generation)}}catch(ae){!C&&E&&ah(n,E)&&!Hi(ae)&&_o(n,!0,va(ae))}finally{E&&AC(n,E)}}}return B(),()=>{C=!0,E&&AC(n,E)}},[n,p,xe]);function La(){_o(n,!1,null),ye(C=>C+1)}function zi(){$e.current+=1,Be.current+=1,Ue(null)}function ja(C){$e.current+=1,Be.current+=1,Ue(E=>E&&{...E,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Is(){$e.current+=1,Be.current+=1;const C=x.workspaces.length+1,E=Wl();Ue({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Nr(E)}function mi(C){if(hi(C,n)){Is();return}pt.current={agentId:C},s?.(C)}function Ps(C){if(H&&!W)return;const E=x.workspaces.find(Q=>Q.id===C);if(!E)return;$e.current+=1,Be.current+=1;const B=E.defaultCwd??oe?.cwd??"";Ue({mode:"edit",workspaceId:C,title:E.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Nr(B)}function Wl(){return ft?.defaultCwd??oe?.cwd??""}async function Nr(C){const E=$e.current+1;$e.current=E;const B=C.trim();if(Ue(Q=>Q&&{...Q,cwd:C,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const Q=await p.createFileRoot({path:B}),ae=await p.listFiles({rootToken:Q.rootToken,path:""});if($e.current!==E)return;Ue(le=>le&&{...le,cwd:Q.rootPath,browseRoot:{rootToken:Q.rootToken,rootPath:Q.rootPath},browseEntries:ae.entries.filter(Te=>Te.kind==="directory"),browseStatus:"idle",error:null})}catch(Q){if($e.current!==E)return;Ue(ae=>ae&&{...ae,browseStatus:"idle",error:va(Q)})}}async function Dr(){const C=be;if(!C)return;const E=C.title.trim(),B=C.cwd.trim();if(!E||!B){Ue({...C,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const Q=Be.current+1;Be.current=Q,Ue({...C,submitStatus:"submitting",error:null});try{const ae=await p.createFileRoot({path:B});if(Be.current!==Q)return;if(C.mode==="create"){const le=x.workspaces.length+1;mt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${le}`,title:E,defaultCwd:ae.rootPath})}else C.workspaceId&&(mt({type:"workspace.renamed",workspaceId:C.workspaceId,title:E}),mt({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:ae.rootPath}));Ue(null)}catch(ae){if(Be.current!==Q)return;Ue(le=>le&&{...le,submitStatus:"idle",error:va(ae)})}}function Oa(C){Be.current+=1,Ue(C)}function Uo(C,E,B){if(C===E)return;const Q=x.workspaces.some(le=>le.id===C),ae=x.workspaces.some(le=>le.id===E);!Q||!ae||mt({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:E,placement:B})}function Jr(C,E){const B=x.workspaces.findIndex(ae=>ae.id===C),Q=x.workspaces[B+E];B<0||!Q||Uo(C,Q.id,E<0?"before":"after")}function lu(C,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),Qt.current={sourceId:C,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function $o(C){const E=Qt.current;if(!E||E.pointerId!==C.pointerId)return;const B=Math.hypot(C.clientX-E.startX,C.clientY-E.startY);if(!E.active){if(B<Yz)return;E.active=!0,ct(E.sourceId)}const ae=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),le=ae?.dataset.workspaceId??null;if(!ae||!le||le===E.sourceId||!x.workspaces.some(Ve=>Ve.id===le)){E.targetId=null,jt(null);return}const Te=ae.getBoundingClientRect(),Ie=C.clientY<Te.top+Te.height/2?"before":"after";E.targetId=le,E.placement=Ie,jt({workspaceId:le,placement:Ie})}function Kl(C){const E=Qt.current;!E||E.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),Qt.current=null,ct(null),jt(null),E.active&&E.targetId&&Uo(E.sourceId,E.targetId,E.placement))}function Ai(C){const E=Qt.current;E&&E.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),Qt.current=null,ct(null),jt(null)}async function ql(){await xn(async()=>{const C=ft?.defaultCwd?{cols:80,rows:24,cwd:ft.defaultCwd}:{cols:80,rows:24},E=await p.createTerminal(C);mt({type:"terminal.created",terminal:E.terminal})})}function zs(C,E=ft,B=x,Q=n){const ae=B.terminals[C.activeTerminalId],le=Array.from(new Set(Tl(C).flatMap(Te=>{const Ie=B.terminals[Te]?.agentStatus?.provider;return Ie==="codex"||Ie==="claude"?[Ie]:[]})));return{serverId:Q??Zt,workspaceId:E.id,tabId:C.id,serverName:We[Cl(Q)]??(Q===null?"Local":"Server"),workspaceName:E.title,tabName:C.title||ae?.title||"Terminal",cwd:ae?.cwd||E.defaultCwd,paneCount:Lp(C),providers:le}}function Hs(C){const E=C.serverId===Zt?null:C.serverId,B=vo(E);if(!B?.loaded||B.error)return null;const Q=B.state,le=Q.workspaces.find(Ge=>Ge.tabs.some(_t=>_t.id===C.tabId))?.tabs.find(Ge=>Ge.id===C.tabId);if(!le)return null;const Te=Tl(le).flatMap(Ge=>{const _t=Q.terminals[Ge];return _t?[_t]:[]});if(Te.length===0)return null;const Ie=Te.reduce((Ge,_t)=>{const Cn=_t.agentCache?.lastCallAt;return Cn&&(!Ge||Date.parse(Cn)>Date.parse(Ge))?Cn:Ge},null),Ve=Te.some(Ge=>B.unreadCompletions.has(Ge.id));return Te.some(Ge=>Ge.status==="running"&&(Ge.agentStatus?.state==="working"||Ge.agentStatus?.state==="finishing"||!Ge.agentStatus&&Ge.activity==="busy"))?{state:"working",lastActivityAt:Ie,unread:Ve}:Te.some(Ge=>Ge.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Ie,unread:Ve}:Te.some(Ge=>Ge.agentStatus?.state==="done")?{state:"done",lastActivityAt:Ie,unread:Ve}:Te.every(Ge=>Ge.status==="exited")?{state:"exited",lastActivityAt:Ie,unread:Ve}:{state:"idle",lastActivityAt:Ie,unread:Ve}}function Li(C,E){Nt.current=C,Di.current=E,ee(C)}function on(C){nn.current+=1,te.current.push(C),!Gn.current&&(Gn.current=!0,X(!0),T(null),(async()=>{try{for(;te.current.length>0;){const E=te.current.shift();let B=0;for(;B<2;){const Q=E(Nt.current);if($C(Q,Nt.current))break;Li(Q,Di.current);try{const ae=await m.saveFavorites({favorites:Q,baseRevision:Di.current});Li(ae.favorites,ae.revision);break}catch(ae){const le=await m.getFavorites().catch(()=>null);if(le&&Li(le.favorites,le.revision),ae instanceof Vn&&ae.status===409&&le){B+=1;continue}te.current=[],T("Could not save favorites. Please try again.");return}}if(B>=2){te.current=[],T("Favorites changed on another device. Please try again.");return}}}finally{Gn.current=!1,X(!1)}})())}function Mr(C,E,B){const Q=E??Zt,ae=le=>le.map(Te=>{if(Te.serverId!==Q)return Te;const Ie=B.workspaces.find(_t=>_t.tabs.some(Cn=>Cn.id===Te.tabId)),Ve=Ie?.tabs.find(_t=>_t.id===Te.tabId);if(!Ie||!Ve)return Te;const Ge=zs(Ve,Ie,B,E);return j.current.has(Cl(E))?Ge:{...Ge,serverName:Te.serverName}});$C(C,ae(C))||on(ae)}function es(C){const E=n??Zt,B=Nt.current.find(ae=>ae.serverId===E&&ae.tabId===C.id);if(B){const ae=Vr(B);on(le=>le.filter(Te=>Vr(Te)!==ae));return}if(!ft||Nt.current.length>=100)return;const Q=zs(C);on(ae=>ae.length>=100?ae:[...ae,Q])}function Ar(C){const E=C.serverId===Zt?null:C.serverId;if(E!==null&&!ze.some(B=>hi(B,E))){T(`${C.serverName} is no longer registered.`);return}if(T(null),K(!1),!hi(E,n)){Et.current=C,s?.(E);return}Us(C)}async function Us(C){const E=gt(n).state,B=E.workspaces.find(ae=>ae.tabs.some(le=>le.id===C.tabId));if(B){mt({type:"workspace.selected",workspaceId:B.id}),mt({type:"tab.selected",tabId:C.tabId});return}let Q=E.workspaces.find(ae=>ae.id===C.workspaceId);if(!Q){const ae=`workspace-favorite-${Date.now().toString(36)}`;mt({type:"workspace.created",workspaceId:ae,title:C.workspaceName,defaultCwd:C.cwd}),Q=gt(n).state.workspaces.find(le=>le.id===ae)}Q&&mt({type:"workspace.selected",workspaceId:Q.id}),await xn(async()=>{const ae=await p.createTerminal(C.cwd?{cols:80,rows:24,cwd:C.cwd}:{cols:80,rows:24});mt({type:"terminal.created",terminal:ae.terminal});const Te=gt(n).state.workspaces.find(Rt=>Rt.tabs.some(kn=>kn.activeTerminalId===ae.terminal.id)),Ie=Te?.tabs.find(Rt=>Rt.activeTerminalId===ae.terminal.id);if(!Ie||!Te)return;Ie.title!==C.tabName&&mt({type:"tab.renamed",tabId:Ie.id,title:C.tabName});const Ve=gt(n).state,Ge=Ve.workspaces.find(Rt=>Rt.id===Te.id)??Te,_t=Ge.tabs.find(Rt=>Rt.id===Ie.id)??Ie,Cn=zs(_t,Ge,Ve);on(Rt=>Rt.map(kn=>kn.serverId===C.serverId&&kn.workspaceId===C.workspaceId&&kn.tabId===C.tabId?Cn:kn))})}async function si(C){await xn(async()=>{const E=wn?{parentTerminalId:wn,cols:80,rows:24}:ft?.defaultCwd?{cols:80,rows:24,cwd:ft.defaultCwd}:{cols:80,rows:24},B=await p.createTerminal(E);mt({type:"terminal.split",terminal:B.terminal,direction:C})})}async function Ba(C){let E=wn,B=qe;const Q=ft?.defaultCwd?.trim();if(!E&&!Q)throw new Error("No active pane is available.");const ae=await p.readFile(C);if(!E&&Q){const Ie=await p.createTerminal({cols:80,rows:24,cwd:Q});E=Ie.terminal.id,mt({type:"terminal.created",terminal:Ie.terminal})}if(E){mt({type:"pane.selected",terminalId:E});const Ie=gt(n).state,Ve=Ie.workspaces.find(_t=>_t.id===Ie.activeWorkspaceId)??Ie.workspaces[0],Ge=Ve?.tabs.find(_t=>_t.id===Ve.activeTabId)??Ve?.tabs[0];B=Ve&&Ge?Rd(n,Ve.id,Ge.id):null}const le=`editor-${Date.now().toString(36)}-${HP(n)}`,Te=w8(ae.path);Pv(n,Ie=>({...Ie,[le]:{id:le,title:Te,rootToken:C.rootToken,path:ae.path,read:ae}})),B&&je(Ie=>({...Ie,[B]:Q2(le)})),mt({type:"editor.split",editorId:le,title:Te,direction:"vertical"})}function $s(C){Pv(n,E=>{const B={...E};return delete B[C],B}),mt({type:"editor.closed",editorId:C})}function Ti(C){gs([C])}function gs(C){const E=[...new Set(C)].filter(Q=>x.terminals[Q]);if(E.length===0)return;const B=E.length===1?x.terminals[E[0]]?.title||x.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;Fe(null),Zi({terminalIds:E,label:B,workspaceId:ft?.id??x.activeWorkspaceId??null})}function Fs(C,E){const B=Wo(C,E);if(!B)return!1;const Q=C.filter(ae=>!B.detachedTerminalIds.includes(ae));if(B.detachedTerminalIds.length+Q.length>Ao)return Fe(b8(B.detachedTerminalIds.length)),!1;Fe(null);for(const ae of C)mt(B.id?{type:"terminal.detached",terminalId:ae,workspaceId:B.id}:{type:"terminal.detached",terminalId:ae});return!0}async function Ji(C){await xn(async()=>{for(const E of C)await ai(E),xd(p.createWebSocketUrl(E)),Rf(E),wd(E),mt({type:"terminal.closed",terminalId:E})})}async function Ws(C){const E=x.workspaces.find(B=>B.id===C);!E||x.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await xn(async()=>{const B=Ls(E),Q=[];let ae=null;for(const Te of B)try{await ai(Te)}catch(Ie){Q.push(va(Ie)),Ie instanceof Vn&&Ie.status===401&&!p.isAgent&&(ae=Ie)}finally{xd(p.createWebSocketUrl(Te)),Rf(Te),wd(Te)}const le=E.tabs.flatMap(Te=>Fb(Te.root));if(le.length>0){const Te=new Set(le);Pv(n,Ie=>{const Ve={...Ie};for(const Ge of Te)delete Ve[Ge];return Ve})}if(mt({type:"workspace.closed",workspaceId:C}),ae)throw ae;if(Q.length>0)throw new Error(`Workspace was removed, but ${Q.length} terminal session${Q.length===1?"":"s"} may still be running. ${Q[0]}`)})}async function ts(C){await xn(async()=>{await ai(C),xd(p.createWebSocketUrl(C)),Rf(C),wd(C),mt({type:"terminal.closed",terminalId:C})})}async function Ia(C,E){const B=E.trim();if(!B)return;let Q=null;for(const ae of x.workspaces){const le=ae.tabs.find(Te=>Te.id===C);if(le){Q=le.activeTerminalId;break}}if(mt({type:"tab.renamed",tabId:C,title:B}),!!Q)try{const ae=await p.renameTerminal(Q,B);er({type:"terminal.updated",terminal:ae.terminal})}catch(ae){_o(n,!0,va(ae))}}function Lr(C){const E=x.terminals[C];E&&mt({type:"terminal.created",terminal:E})}async function ai(C){try{await p.closeTerminal(C)}catch(E){if(E instanceof Vn&&E.status===404)return;throw E}}async function Ks(){await xn(async()=>{await d()})}async function xn(C){_o(n,!0,null);try{await C()}catch(E){if(Hi(E))return;_o(n,!0,va(E))}}function Hi(C){return C instanceof Vn&&C.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function mt(C){kd(n,C);const E=gt(n),B=E.state;if(Mr(Nt.current,n,B),!E.loaded||B.workspaces.length===0)return;const Q=xo(B);JSON.stringify(Q)!==E.lastPersistedLayoutJson&&Go(Q)}function er(C){kd(n,C),Mr(Nt.current,n,gt(n).state)}function Fo(C,E,B,Q){const ae=Rd(C,E,B);je(le=>({...le,[ae]:Q}))}function mr(C){qe&&je(E=>({...E,[qe]:C}))}function qs(C,E){const B=Fc(C);E?Fo(n,E.workspaceId,E.tabId,B):mr(B),mt({type:"pane.selected",terminalId:C})}function vs(C){mr(C.key),C.type==="terminal"&&mt({type:"pane.selected",terminalId:C.terminalId})}function Pa(C){if($||he||an||C.isComposing||C.key==="Process"||t8(C.target))return;const E=Zz(C);if(!E)return;if(C.preventDefault(),C.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){jr(E.type==="server.next"?1:-1);return}if(E.type==="favorites.toggle"){K(!0);return}const B=gt(n).state,Q=B.workspaces.find(Te=>Te.id===B.activeWorkspaceId)??B.workspaces[0],ae=Q?.tabs.find(Te=>Te.id===Q.activeTabId)??Q?.tabs[0];if(E.type==="split"){if(!ae)return;si(E.direction);return}if(!Q||!ae)return;if(E.type==="tab.previous"||E.type==="tab.next"){const Te=e8(Q.tabs,ae.id,E.type==="tab.next"?1:-1);Te&&mt({type:"tab.selected",tabId:Te.id});return}if(E.type==="tab.index"){const Te=Q.tabs[E.index-1];Te&&mt({type:"tab.selected",tabId:Te.id});return}const le=Qz(ae.root,ae.activeTerminalId,E);le&&qs(le,{workspaceId:Q.id,tabId:ae.id})}function za(C,E){if(!s||ze.length===0)return;const B=ze.findIndex(Te=>hi(Te,n)),ae=((B===-1?0:B)+C+ze.length)%ze.length,le=ze[ae]??null;hi(le,n)||(E&&(Yn.current={agentId:le,edge:E}),s(le))}function jr(C){const E=gt(n).state,B=E.workspaces;if(B.length===0){za(C,C===1?"first":"last");return}const Q=B.findIndex(Te=>Te.id===E.activeWorkspaceId),le=(Q===-1?0:Q)+C;if(le>=0&&le<B.length){mt({type:"workspace.selected",workspaceId:B[le].id});return}za(C,C===1?"first":"last")}function cu(C,E){if(hi(C,n)){mt({type:"workspace.selected",workspaceId:E});return}_n.current={agentId:C,workspaceId:E},s?.(C)}function Wo(C,E){if(E)return x.workspaces.find(B=>B.id===E)??null;for(const B of C){const Q=x.workspaces.find(le=>le.tabs.some(Te=>Tl(Te).includes(B)));if(Q)return Q;const ae=x.workspaces.find(le=>le.detachedTerminalIds.includes(B));if(ae)return ae}return x.workspaces.find(B=>B.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Ui(C){Hc(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function Vl(C){if(!Hc(C.dataTransfer))return;C.preventDefault();const E=y8(gt(n).state),B=rt.current+1;if(rt.current=B,!E){Gl({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Gl({id:B,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),Ko(B,E.id,C.dataTransfer)}async function Ko(C,E,B){try{const Q=await QE(B);if(Q.length===0)throw new Error("No files were found in the drop.");ji(C,{id:C,status:"queued",fileCount:Q.length,message:"Queued"},{terminalId:E,files:Q})}catch(Q){ji(C,{id:C,status:"failed",fileCount:0,message:va(Q)},{terminalId:E})}finally{Vs()}}async function Yl(C){const E=Mn.current.find(le=>le.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const B=E.terminalId,Q=E.files,ae=new AbortController;Bn.current=C,ji(C,{id:C,status:"uploading",fileCount:Q.length,loaded:0,total:null,percent:null},{terminalId:B,files:Q,abortController:ae});try{const le=await VC({terminalId:B,files:Q,signal:ae.signal,onProgress:Ge=>{ji(C,{id:C,status:"uploading",fileCount:Q.length,loaded:Ge.loaded,total:Ge.total,percent:Ge.percent},{terminalId:B,files:Q,abortController:ae})}}),Te=le.failed>0?le.uploaded>0?"partial":"failed":"success",Ie=le.failed>0?S8(le):void 0,Ve={id:C,status:Te,fileCount:Q.length,response:le};Ie&&(Ve.message=Ie),ji(C,Ve,{terminalId:B,files:Q})}catch(le){ji(C,{id:C,status:"failed",fileCount:Q.length,message:ae.signal.aborted?"Upload canceled.":va(le)},{terminalId:B,files:Q})}finally{Bn.current===C&&(Bn.current=null),Vs()}}function Vs(){if(Bn.current!==null)return;const C=Mn.current.find(E=>E.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&Yl(C.id)}function Gl(C){qo(E=>[...E,C])}function ji(C,E,B={}){qo(Q=>Q.map(ae=>{if(ae.id!==C)return ae;const le={...E},Te=B.terminalId??ae.terminalId,Ie=B.files??ae.files;return Te!==void 0&&(le.terminalId=Te),Ie!==void 0&&(le.files=Ie),B.abortController!==void 0&&(le.abortController=B.abortController),le}))}function qo(C){const E=C(Mn.current);Mn.current=E,Xi(E)}function oi(C){Mn.current.find(B=>B.id===C)?.abortController?.abort(),Bn.current===C&&(Bn.current=null),qo(B=>B.filter(Q=>Q.id!==C)),Vs()}function Vo(){for(const C of Mn.current)C.abortController?.abort();Bn.current=null,qo(()=>[])}function Xl(C){const E=Mn.current.find(B=>B.id===C);if(E){if(E.status==="queued"){oi(C);return}E.abortController?.abort()}}function gr(C){const E=Mn.current.find(Q=>Q.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const B=Zl(E);if(B.length===0){ji(C,{id:C,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}ji(C,{id:C,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:E.terminalId,files:B}),Vs()}function Zl(C){const E=C.files??[],B="response"in C?C.response:void 0;if(!B)return E;const Q=B.results.filter(Te=>Te.status==="failed").map(Te=>Te.relativePath);if(Q.length===0)return[];const ae=new Map;for(const Te of E){const Ie=ae.get(Te.relativePath)??[];Ie.push(Te),ae.set(Te.relativePath,Ie)}const le=[];for(const Te of Q){const Ve=ae.get(Te)?.shift();Ve&&le.push(Ve)}return le}function Yo(C){Ha({kind:"terminal",agentId:C.agentId,terminalId:C.terminalId}),Ci(null)}function Ha(C){if(Ke.current=C,et.current=null,bt.current=null,Ft(E=>E+1),Lf(void 0),!hi(C.agentId,n)){s?s(C.agentId):Ke.current=null;return}}function ns(){const C=Ke.current;if(!C||!hi(C.agentId,n))return!1;if(!w.loaded||document.visibilityState!=="visible")return!0;if(bt.current?.target===C){const Q=bt.current;return Q.generation===w.generation&&(Q.applying||Q.layoutSequence===gt(C.agentId).mutable.hydration.layoutSequence)?!0:(bt.current=null,Ke.current=null,et.current=null,!1)}if(et.current?.target!==C||et.current.generation!==w.generation){if(et.current={target:C,generation:w.generation},!gt(C.agentId).state.workspaces.some(le=>Ls(le).includes(C.terminalId)))return is(C),!0;mt({type:"terminal.revealed",terminalId:C.terminalId});const ae=$v(gt(C.agentId).state,C.terminalId);if(ae)return Fo(C.agentId,ae.workspaceId,ae.tabId,Fc(C.terminalId)),Ft(le=>le+1),!0}const E=gt(C.agentId),B=$v(E.state,C.terminalId);return B&&(x!==E.state||ft?.id!==B.workspaceId||wt?.id!==B.tabId||sn&&nt!==Fc(C.terminalId))?!0:(Ke.current=null,et.current=null,!1)}async function is(C){const E=gt(C.agentId),B={target:C,generation:E.generation,layoutSequence:E.mutable.hydration.layoutSequence,applying:!1};bt.current=B;let Q=!1;const ae=()=>Pt.current&&bt.current===B&&Ke.current===C&&vo(C.agentId)?.generation===B.generation;try{const le=Rs(C.agentId),[Te,Ie]=await Promise.all([le.listTerminals(),le.getTerminalLayout()]);if(!ae())return;const Ve=gt(C.agentId);if(!hi(Xn.current,C.agentId)||!Ve.loaded||Ve.mutable.hydration.layoutSequence!==B.layoutSequence)return;const Ge=Te.terminals.find(kn=>kn.id===C.terminalId);if(!Ge)throw new Error("This terminal is no longer available.");const _t=WP(Ve.state,Ge,Ie.layout);B.applying=!0,MC(C.agentId,_t);const Cn=xo(_t);Ie.revision===Ve.layoutRevision?Go(Cn):Mc(Cn,b);const Rt=$v(_t,C.terminalId);Fo(C.agentId,Rt.workspaceId,Rt.tabId,Fc(C.terminalId)),et.current={target:C,generation:B.generation},Q=!0}catch(le){ae()&&!Hi(le)&&_o(C.agentId,!0,va(le))}finally{ae()&&(bt.current=null,Q||(Ke.current=null,et.current=null),Ft(le=>le+1))}}function Go(C){const E=vo(n);if(E?.generation!==w.generation)return;const B=E.mutable.saveCoord;B.pendingLayoutSave=C,Mc(C,b),B.saveTimer!==null&&window.clearTimeout(B.saveTimer),B.saveTimer=window.setTimeout(()=>{B.saveTimer=null;const Q=B.pendingLayoutSave;B.pendingLayoutSave=null,Q&&Ys(Q,{},E.generation)},qz)}function uu(){const C=vo(n);if(C?.generation!==w.generation)return;const E=C.mutable.saveCoord;E.saveTimer!==null&&(window.clearTimeout(E.saveTimer),E.saveTimer=null);const B=E.pendingLayoutSave;E.pendingLayoutSave=null,B&&(Mc(B,b),Ys(B,{},C.generation))}function Ys(C,E={},B=w.generation){const Q=vo(n);if(Q?.generation!==B)return;const ae=Q.mutable.saveCoord;ae.nextPersistLayout=C,E.baseRevision!==void 0&&(ae.queuedBaseRevision=E.baseRevision),!ae.nextPersistQueued&&(ae.nextPersistQueued=!0,ae.persistChain=ae.persistChain.then(async()=>{if(vo(n)?.generation!==B)return;ae.nextPersistQueued=!1;const le=ae.nextPersistLayout,Te=ae.queuedBaseRevision;ae.nextPersistLayout=null,ae.queuedBaseRevision=void 0,le&&await Ua(le,Te!==void 0?{baseRevision:Te}:{},B)}))}async function Ua(C,E,B){const Q=vo(n);if(Q?.generation!==B||JSON.stringify(xo(Q.state))!==JSON.stringify(C))return;const ae=Q.mutable.hydration.layoutSequence,le=()=>vo(n)?.generation===B,Te=E.baseRevision??Q.layoutRevision,Ie={layout:C,...typeof Te=="number"?{baseRevision:Te}:{}};try{const Ve=await p.saveTerminalLayout(Ie);if(!le())return;const Ge=Ve.layout??C;jf(n,Ve.revision,JSON.stringify(Ge)),Mc(Ge,b);return}catch(Ve){if(!le())return;if(Ve instanceof Vn&&Ve.status===400&&Ve.message===uM){_8(n,b),_o(n,!0,J2());return}if(Ve instanceof Vn&&Ve.status===409)try{const Ge=await p.getTerminalLayout();if(!le())return;const _t=gt(n).mutable.saveCoord;if(_t.nextPersistLayout||_t.pendingLayoutSave||gt(n).mutable.hydration.layoutSequence!==ae){const Cn=Ge.layout?JSON.stringify(Ge.layout):gt(n).lastPersistedLayoutJson;jf(n,Ge.revision,Cn);return}if(Ge.layout){const Cn=gt(n).state,Rt=Ap(Object.values(Cn.terminals),void 0,Ge.layout.workspaces,Ge.layout.activeWorkspaceId),kn=xo(Rt);MC(n,Rt),jf(n,Ge.revision,JSON.stringify(kn)),Mc(kn,b)}else jf(n,Ge.revision,Q.lastPersistedLayoutJson);return}catch{}le()&&Mc(C,b)}}const Xo=k8(o),vr=!H||W,$a=vr?Y:"servers";function Zo(C){const E=C.active?w:gt(C.agentId),B=C.active?x:E.state,Q=C.active?w.loaded:E.loaded,ae=C.active?A:E.error;return u.jsxs("div",{className:`workspace-list-panel${C.active?" workspace-list-panel--active-server":""}`,"aria-label":`${C.label} workspaces`,children:[u.jsxs("div",{className:"workspace-list-header",children:[u.jsx("span",{children:"Workspaces"}),u.jsx("button",{type:"button","aria-label":`New workspace on ${C.label}`,title:"New workspace",onClick:()=>mi(C.agentId),children:"+"})]}),Q?ae?u.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(C.agentId),children:ae}):u.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(le=>{const Te=C.active&&le.id===ft?.id,Ie=Ls(le).length,Ve=EP(C.agentId,le.id),Ge=a8(Ve),_t=C.active&&B.workspaces.length>1,Cn=ht?.workspaceId===le.id&&ot!==le.id?ht.placement:null;return u.jsxs(l8,{workspaceId:le.id,active:Te,disabled:!C.active,reorderable:_t,dragging:ot===le.id,dropPlacement:Cn,working:Ve.workingTerminalCount>0,unread:Ve.unreadCompletionCount>0,children:[_t?u.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":le.id,title:"Drag to reorder","aria-label":`Reorder ${le.title}`,"aria-grabbed":ot===le.id,onPointerDown:Rt=>lu(le.id,Rt),onPointerMove:$o,onPointerUp:Kl,onPointerCancel:Ai,onKeyDown:Rt=>{(Rt.key==="ArrowUp"||Rt.key==="ArrowDown")&&(Rt.preventDefault(),Rt.stopPropagation(),Jr(le.id,Rt.key==="ArrowUp"?-1:1))},onClick:Rt=>Rt.stopPropagation(),children:"::"}):null,u.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Te?"page":void 0,title:le.defaultCwd??void 0,onClick:()=>cu(C.agentId,le.id),onDoubleClick:()=>{C.active&&Ps(le.id)},children:[u.jsxs("span",{className:"workspace-list-title-row",children:[u.jsx("span",{className:"workspace-list-name",children:le.title}),Ve.workingTerminalCount>0||Ve.unreadCompletionCount>0?u.jsxs("span",{className:"workspace-list-attention",title:Ge,"aria-label":Ge,children:[Ve.workingTerminalCount>0?u.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,Ve.unreadCompletionCount>0?u.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:s8(Ve.unreadCompletionCount)}):null]}):null]}),u.jsxs("small",{children:[le.defaultCwd??"No folder"," · ",Ie," ",Ie===1?"session":"sessions"]})]}),C.active?u.jsxs("div",{className:"workspace-list-actions",children:[u.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${le.title}`,title:"Edit workspace",onClick:()=>Ps(le.id),children:"..."}),u.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${le.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{Ws(le.id)},children:"x"})]}):null]},le.id)})}):u.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(C.agentId),children:"Open server to load workspaces"})]})}function rs(C,E){re({...C,provider:E})}async function Gs(C){if(N(C),!gt(C.agentId).loaded)try{const E=Rs(C.agentId),[B,Q]=await Promise.all([E.listTerminals(),E.getTerminalLayout()]),ae=Q.layout?Wb(Q.layout):null,le=Ap(B.terminals,void 0,ae?.savedWorkspaces,ae?.savedActiveWorkspaceId),Te=le.workspaces.flatMap(Ie=>Ie.tabs.flatMap(Ve=>jn(Ve.root).flatMap(Ge=>{const _t=le.terminals[Ge];return _t?[{terminalId:Ge,cwd:_t.cwd,label:`${Ie.title} / ${Ve.title} / ${_t.title}`}]:[]})));N(Ie=>Ie===C?{...Ie,targets:Te}:Ie)}catch{N(E=>E===C?{...E,targetError:"Could not retrieve open tabs."}:E)}}return u.jsx(yk,{sensors:yn,onDragStart:Sn,onDragEnd:Dn,onDragCancel:rn,children:u.jsxs("main",{className:"terminal-shell","data-collapsed":H,"data-sidebar-open":W,onDragOver:Ui,onDrop:Vl,children:[u.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>z(!1)}),u.jsxs("aside",{className:"workspace-sidebar",children:[u.jsxs("header",{className:"workspace-brand",children:[u.jsxs("div",{className:"workspace-brand-lockup",children:[vr?u.jsx(QC,{height:20}):u.jsx(ZC,{size:24}),l&&vr?u.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),u.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":H?"Expand sidebar":"Collapse sidebar",title:H?"Expand sidebar":"Collapse sidebar",onClick:()=>q(C=>!C),children:H?">":"<"}),u.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>z(!1),children:"x"})]}),u.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${$a==="files"?"files":"servers"}`,children:[vr?u.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[u.jsx("button",{type:"button",role:"tab","aria-selected":Y==="servers",onClick:()=>{I("servers")},children:"Workspaces"}),u.jsx("button",{type:"button",role:"tab","aria-selected":Y==="files",onClick:()=>{I("files")},children:"Files"})]}):null,$a==="servers"&&vr?u.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:u.jsx(I1,{api:m,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:f,refreshToken:ge,onServerLabelsChange:ki,onManageAccounts:rs,onServerInfo:C=>{Gs(C)},renderServerChildren:Zo})}):null,vr?null:u.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:u.jsx(I1,{api:m,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:f,refreshToken:ge,onServerLabelsChange:ki,compact:!0})}),$a==="files"?u.jsx(yj,{api:p,activeTerminalId:wn,activeTerminalCwd:oe?.cwd??null,workspaceRootPath:wn?null:ft?.defaultCwd??null,onOpenFile:Ba},`${n??"local"}:${ft?.id??"no-workspace"}`):null]}),u.jsxs("div",{className:"workspace-sidebar-footer",children:[vr?u.jsx("span",{children:Xo}):null,u.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[u.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>de(!0),children:[u.jsx(FC,{name:"settings"}),J.hasUpdates?u.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),vr?u.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{Ks()},children:u.jsx(FC,{name:"logout"})}):null]})]})]}),$?u.jsx(pj,{api:m,onClose:()=>de(!1),updateAvailable:J.hasUpdates,onNotificationAssetsChanged:()=>{ri()},onAgentRemoved:Ho}):null,O?u.jsx(uL,{provider:O.provider,serverLabel:O.label,api:se,onClose:()=>re(null)}):null,he&&u.jsx(RL,{api:V,label:he.label,main:he.agentId===null,getRuntimeStatus:Hs,favorites:ne.filter(C=>C.serverId===(he.agentId??Zt)),targetStatus:he.targetError??(!gt(he.agentId).loaded&&!he.targets?"Loading open tabs...":null),targets:he.targets??gt(he.agentId).state.workspaces.flatMap(C=>C.tabs.flatMap(E=>jn(E.root).flatMap(B=>{const Q=gt(he.agentId).state.terminals[B];return Q?[{terminalId:B,cwd:Q.cwd,label:`${C.title} / ${E.title} / ${Q.title}`}]:[]}))),onClose:()=>N(null),onFavorite:C=>{N(null),Ar(C)},onTarget:C=>{Ha({kind:"terminal",agentId:he.agentId,terminalId:C.terminalId}),N(null)}},he.agentId??Zt),be?u.jsx(n8,{dialog:be,activePaneCwd:oe?.cwd??null,activeWorkspaceCwd:ft?.defaultCwd??null,onChange:Oa,onManualCwdChange:ja,onBrowse:Nr,onCancel:zi,onSubmit:()=>{Dr()}}):null,u.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":sn?"true":void 0,children:[u.jsx(qP,{tabs:ft?.tabs??[],activeTabId:ft?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:dr,favoriteTabIds:new Set(ne.filter(C=>C.serverId===(n??Zt)).map(C=>C.tabId)),detachedTerminals:On,onSelectTab:C=>mt({type:"tab.selected",tabId:C}),onCreateTab:()=>{ql()},onToggleWorkspaces:()=>z(C=>!C),onCloseTerminals:C=>gs(C),onReattachTerminal:C=>Lr(C),onDeleteTerminal:C=>{ts(C)},onSplitVertical:()=>{si("vertical")},onSplitHorizontal:()=>{si("horizontal")},onRenameTab:(C,E)=>{Ia(C,E)},onToggleFavorite:es,onOpenFavorites:()=>K(!0),activePaneAvailable:!!wn}),me?u.jsx(kz,{favorites:ne,unavailableFavoriteIds:new Set(ne.filter(C=>C.serverId!==Zt&&!ze.some(E=>hi(E,C.serverId))).map(Vr)),busy:Z,error:M,getRuntimeStatus:Hs,onClose:()=>{K(!1),T(null)},onOpen:Ar,onRemove:C=>{on(E=>E.filter(B=>Vr(B)!==Vr(C)))},onReorder:(C,E)=>{const B=Vr(C),Q=Vr(E);on(ae=>{const le=ae.findIndex(_t=>Vr(_t)===B),Te=ae.findIndex(_t=>Vr(_t)===Q);if(le<0||Te<0||le===Te)return ae;const Ie=ae.slice(),[Ve]=Ie.splice(le,1),Ge=Ie.findIndex(_t=>Vr(_t)===Q);return Ve&&Ge>=0&&Ie.splice(Ge,0,Ve),Ie})}}):null,sn?u.jsx(u8,{targets:Xe,activeLeafKey:nt,terminals:x.terminals,editors:R,onSelect:vs}):null,A?u.jsxs("div",{className:"workspace-error",role:"alert",children:[u.jsx("span",{children:A}),u.jsxs("div",{className:"workspace-error-actions",children:[u.jsx("button",{type:"button",onClick:La,children:"Retry"}),n!==null&&s?u.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,u.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?u.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!wt?u.jsx(o8,{onCreate:()=>{ql()}}):null,Le.map(C=>{const E=hi(C,n);return u.jsx(Xz,{agentId:C,serverName:We[Cl(C)]??(C===null?"Local":"Server"),active:E,activeServerApi:E?p:void 0,visitedTabKeys:pe,refreshCwdOnEnter:E,draggingTab:E?Jt:null,mobileSplitFocus:ke,mobileFocusedLeafByTabKey:Re,onSelect:B=>{E&&qs(B)},onClose:B=>{E&&Ti(B)},onCloseEditor:B=>{E&&$s(B)},onResize:(B,Q)=>{E&&mt({type:"pane.resized",path:B,ratio:Q})},onExit:(B,Q)=>{E?er({type:"terminal.exited",terminalId:B,exitCode:Q}):kd(C,{type:"terminal.exited",terminalId:B,exitCode:Q})},onSnapshot:(B,Q)=>{const ae={type:"terminal.updated",terminal:B,notifyCompletion:Q?.notifyCompletion===!0};E?er(ae):kd(C,ae)},...f?{onAuthClose:B=>f({...B,source:B?.source??"terminal-ws-1008",activeAgentId:C})}:{}},ep(C))})]}),an?u.jsx(c8,{label:an.label,count:an.terminalIds.length,warning:Pe,onCancel:()=>{Fe(null),Zi(null)},onHide:()=>{Fs(an.terminalIds,an.workspaceId)&&Zi(null)},onDelete:()=>{const C=an.terminalIds;Fe(null),Zi(null),Ji(C)}}):null,u.jsx(Iz,{toast:hr,onActivate:Yo,onDismiss:()=>Ci(null)}),u.jsx(Dz,{uploads:Xt,onDismiss:oi,onDismissAll:Vo,onRetry:gr,onCancel:Xl})]})]})})}function Xz({agentId:e,serverName:t,active:n,activeServerApi:s,visitedTabKeys:o,refreshCwdOnEnter:l,draggingTab:d,mobileSplitFocus:f,mobileFocusedLeafByTabKey:m,onSelect:p,onClose:b,onCloseEditor:_,onResize:S,onExit:w,onSnapshot:x,onAuthClose:R}){const L=v.useMemo(()=>me=>U2(e,me),[e]),A=v.useMemo(()=>()=>gt(e),[e]),W=v.useSyncExternalStore(L,A,A),z=v.useMemo(()=>Rs(e),[e]),H=s??z,q=W.state,Y=q.workspaces.find(me=>me.id===q.activeWorkspaceId)??q.workspaces[0],I=Y?.id??null,de=(Y?.tabs.find(me=>me.id===Y.activeTabId)??Y?.tabs[0])?.id??null;return!W.loaded||q.workspaces.length===0?null:u.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:q.workspaces.flatMap(me=>me.tabs.map(K=>{const ne=n&&me.id===I&&K.id===de,ee=Rd(e,me.id,K.id),Z=Op(K.root),X=f&&Z.length>1?Z2(Z,K.activeTerminalId,m[ee]):null;return!ne&&!o.has(ee)?null:u.jsx("div",{className:"workspace-tab-surface","data-active":ne,"aria-hidden":!ne,children:u.jsx(Eb,{node:K.root,terminals:q.terminals,editors:W.editors,api:H,activeTerminalId:K.activeTerminalId,visible:ne,refreshCwdOnEnter:ne&&l,tabId:K.id,codeServerContext:{serverKey:Cl(e),serverName:t,tabName:K.title||q.terminals[K.activeTerminalId]?.title||"Terminal"},dropZoneActive:ne&&d!==null,draggingTerminalId:ne?d?.terminalId??null:null,mobileFocusLeafKey:X,onSelect:p,onClose:b,onCloseEditor:_,onResize:S,onExit:w,onSnapshot:x,...R?{onAuthClose:R}:{}})},K.id)}))})}function Zz(e){const t=DT(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=Jz(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function Qz(e,t,n){switch(n.type){case"pane.direction":return Hz(e,t,n.direction);case"pane.index":return Uz(e,n.index);default:return null}}function Jz(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function e8(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 Op(e){return e.type==="pane"?[{key:Fc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Q2(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Op(e.first),...Op(e.second)]}function Fb(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Fb(e.first),...Fb(e.second)]}function Z2(e,t,n){if(n&&e.some(o=>o.key===n))return n;const s=t?Fc(t):null;return s&&e.some(o=>o.key===s)?s:e[0]?.key??null}function Fc(e){return`terminal:${e}`}function Q2(e){return`editor:${e}`}function t8(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 n8({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:o,onBrowse:l,onCancel:d,onSubmit:f}){const m=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function _(w){s(x=>x&&{...x,...w})}function S(w){w&&(_({cwd:w,error:null}),l(w))}return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:u.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||f()},children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),u.jsxs("section",{className:"workspace-dialog-body",children:[u.jsxs("label",{className:"workspace-dialog-field",children:[u.jsx("span",{children:"Name"}),u.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:w=>_({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),u.jsxs("label",{className:"workspace-dialog-field",children:[u.jsx("span",{children:"Default cwd"}),u.jsxs("div",{className:"workspace-dialog-path-row",children:[u.jsx("input",{value:e.cwd,disabled:b,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),u.jsx("button",{type:"button",onClick:()=>{l(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),u.jsxs("div",{className:"workspace-dialog-quick-actions",children:[u.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),u.jsx("button",{type:"button",onClick:()=>S(n),disabled:b||!n,children:"Use current workspace"})]}),u.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[u.jsxs("div",{className:"workspace-dialog-browser-header",children:[u.jsx("span",{title:m,children:m||"No folder selected"}),u.jsx("button",{type:"button",onClick:()=>{l(r8(m))},disabled:b||!m||m==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?u.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?u.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?u.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(w=>u.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{l(i8(m,w.path))},children:[u.jsx("span",{children:w.name}),u.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?u.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),u.jsxs("div",{className:"workspace-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),u.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function i8(e,t){return t?t.startsWith("/")?Jf(t):Jf(`${e||"/"}/${t}`):Jf(e)}function r8(e){const t=Jf(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Jf(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function s8(e){return e>99?"99+":String(e)}function a8(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 o8({onCreate:e}){return u.jsxs("div",{className:"empty-workspace",children:[u.jsx("span",{children:"No terminal is open."}),u.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function l8({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:o=!1,dropPlacement:l=null,working:d=!1,unread:f=!1,children:m}){const{setNodeRef:p,isOver:b}=Wp({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":"",d?"workspace-list-item--working":"",f?"workspace-list-item--unread":"",l?"workspace-list-item--drop-target":"",l?`workspace-list-item--drop-${l}`:""].filter(Boolean).join(" ");return u.jsx("div",{ref:p,className:_,"data-workspace-id":e,"data-drop-over":b?"true":void 0,children:m})}function c8({label:e,count:t,warning:n,onCancel:s,onHide:o,onDelete:l}){return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),u.jsx("span",{children:e}),u.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?u.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:l,children:"Delete"})]})]})})}function u8({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:o}){const[l,d]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(S=>S.key===t):-1,m=f>=0?f:0,p=e[m]??e[0],b=UC(p,n,s);function _(S){const w=(m+S+e.length)%e.length,x=e[w];x&&o(x)}return u.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[u.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>_(-1),children:"<"}),u.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":l,title:b,onClick:()=>d(!0),children:["Pane ",m+1,"/",e.length," | ",b]}),u.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>_(1),children:">"}),l?u.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:u.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[u.jsxs("header",{children:[u.jsx("strong",{children:"Panes"}),u.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),u.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const x=UC(S,n,s),R=d8(S,n,s),L=S.key===p.key;return u.jsxs("button",{type:"button","data-active":L,onClick:()=>{o(S),d(!1)},children:[u.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),u.jsxs("span",{className:"mobile-pane-sheet-copy",children:[u.jsx("strong",{children:x}),u.jsx("small",{children:R})]}),u.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function UC(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 d8(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 h8(e){const[t,n]=v.useState(()=>f8(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 f8(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function p8(){if(typeof window>"u")return null;const e=SM(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 m8(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:qp(t.focus)}function $v(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(jn(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function hi(e,t){return e===t}function Vr(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function $C(e,t){return e.length!==t.length?!1:e.every((n,s)=>{const o=t[s];return o!==void 0&&Vr(n)===Vr(o)&&n.serverName===o.serverName&&n.workspaceName===o.workspaceName&&n.tabName===o.tabName&&n.cwd===o.cwd&&n.paneCount===o.paneCount&&n.providers.length===o.providers.length&&n.providers.every((l,d)=>l===o.providers[d])})}function ep(e){return e??"__local__"}function Rd(e,t,n){return`${ep(e)}:${t}:${n}`}class Bp extends Error{constructor(){super(J2())}}function g8(e){return e?{workspaceKey:`${zC}:${e}`}:{workspaceKey:zC}}function v8(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(wk(n))throw new Bp;const s=Kp(n);return s?Wb(s):null}catch(n){if(n instanceof Bp)throw n;return null}}function Wb(e){if(wk(e))throw new Bp;const t=Kp(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Mc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function _8(e,t){const n=gt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function b8(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Ao}. Re-open or delete hidden sessions before hiding more.`}function J2(){return`A saved terminal layout has more than ${Ao} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function y8(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 S8(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function w8(e){return e.split("/").filter(Boolean).pop()??e}function x8(){try{return localStorage.getItem(X2)==="true"}catch{return!1}}function C8(e){try{localStorage.setItem(X2,e?"true":"false")}catch{}}function Cl(e){return e??Zt}function Fv(e,t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every(o=>e[o]===t[o])}function k8(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 FC({name:e}){return u.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M4 7h9"}),u.jsx("path",{d:"M17 7h3"}),u.jsx("circle",{cx:"15",cy:"7",r:"2"}),u.jsx("path",{d:"M4 12h3"}),u.jsx("path",{d:"M11 12h9"}),u.jsx("circle",{cx:"9",cy:"12",r:"2"}),u.jsx("path",{d:"M4 17h9"}),u.jsx("path",{d:"M17 17h3"}),u.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M10 6H6v12h4"}),u.jsx("path",{d:"M13 8l4 4-4 4"}),u.jsx("path",{d:"M8 12h9"})]}):null]})}function va(e){return e instanceof Error?e.message:"Request failed"}function T8({api:e,onDone:t}){const[n,s]=v.useState(null),[o,l]=v.useState(null),[d,f]=v.useState(""),[m,p]=v.useState(!1),[b,_]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let R=!1;return e.setupTotp().then(L=>{R||(s(L.qrDataUrl),l(L.secret))}).catch(L=>{R||w(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{R=!0}},[e]);async function x(R){if(R.preventDefault(),!!o){p(!0),_(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(L){_(L instanceof Error?L.message:"Verification failed")}finally{p(!1)}}}return S?u.jsx("p",{className:"form-error",children:S}):!n||!o?u.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):u.jsxs("div",{className:"totp-setup",children:[u.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),u.jsx("div",{className:"totp-qr-container",children:u.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),u.jsxs("details",{className:"totp-secret-details",children:[u.jsx("summary",{children:"Can't scan? Enter manually"}),u.jsx("p",{className:"totp-secret-text",children:o})]}),u.jsxs("form",{className:"auth-form",onSubmit:x,children:[u.jsxs("label",{children:["Verification code",u.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:R=>f(R.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?u.jsx("p",{className:"form-error",children:b}):null,u.jsx("button",{type:"submit",disabled:m||d.length!==6,children:"Activate 2FA"})]})]})}function E8(e){return{source:Wv(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Wv(e.terminalId)}:{},...e?.detail?{detail:Wv(e.detail)}:{}}}function R8(e){return{invalidationSource:e.source}}function N8(e){Pi("auth.session_invalid.request",eR(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),ly("session-invalid-request").catch(()=>{}))}function D8(e,t){Pi("auth.session_invalid.result",{...eR(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),ly("session-invalid-result").catch(()=>{}))}function eR(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 Wv(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function M8({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const o=v.useMemo(()=>e??Ip(),[e]),l=v.useMemo(()=>t??Rs(null),[t]),[d,f]=v.useState(null),[m,p]=v.useState(null),b=v.useRef(null),_=v.useRef(0),S=v.useRef("loading"),w=v.useCallback(()=>{_.current++,b.current=null},[]);v.useEffect(()=>w,[w]),v.useEffect(()=>{let z=!1;return o.getSession().then(H=>{z||(f(H),p(null))}).catch(H=>{z||(p(Ml(H)),f(null))}),()=>{z=!0}},[o]);const x=O8(d);v.useEffect(()=>{const z=S.current;Pi("auth.view",{view:x,previousView:z,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),z==="workspace"&&x!=="workspace"&&(yv(),ly(`auth-left-workspace-${x}`).catch(()=>{})),S.current=x},[d,x]);async function R(){const z=await o.getSession();f(z),p(null)}async function L(){w(),yv(),Mv(),zv(),eC(),tC(),p(null),f(null);try{await R()}catch(z){p(Ml(z))}}const A=v.useCallback(z=>{const H=E8(z);if(N8(H),b.current)return b.current;const q=_.current,Y=(async()=>{p(null);try{const I=await o.getSession(R8(H));if(q!==_.current)return;if(D8(H,I.authenticated),f(I),I.authenticated){oz(),sI();return}Mv(),zv(),eC(),tC()}catch(I){q===_.current&&p(Ml(I))}finally{q===_.current&&(b.current=null)}})();return b.current=Y,Y},[o]);if(v.useEffect(()=>{if(x==="workspace")return az(z=>{A({source:"activity-auth-check",detail:z})})},[x,A]),x==="workspace")return u.jsx(Gz,{api:o,serverApi:l,activeAgentId:n,onSelectServer:s,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:z=>{A(z)},onLogout:async()=>{w(),yv(),Mv(),zv();const z=await o.logout();f(z)}});const W={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return u.jsxs("main",{className:"auth-screen",children:[u.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[u.jsx("div",{className:"auth-grid"}),u.jsx("div",{className:"auth-glow"})]}),u.jsxs("section",{className:"auth-panel","aria-busy":x==="loading",children:[u.jsxs("header",{className:"auth-header",children:[u.jsxs("div",{className:"auth-brand",children:[u.jsx(ZC,{size:26}),u.jsxs("div",{children:[u.jsx(QC,{height:17}),u.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),u.jsx("h1",{children:W[x]})]}),m?u.jsx("p",{className:"form-error",children:m}):null,x==="loading"?u.jsx("p",{className:"muted",children:"Checking session..."}):null,x==="loading"&&m?u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{L()},children:"Retry"}):null,x==="setup_password"?u.jsx(A8,{api:o,onSession:z=>{f(z)}}):null,x==="setup_totp"?u.jsx(T8,{api:o,onDone:()=>{R()}}):null,x==="login"?u.jsx(L8,{api:o,session:d,onSession:f,onRefresh:R}):null,x==="reauth"?u.jsx(j8,{api:o,session:d,onSession:f,onFullLogin:()=>f(z=>z&&{...z,deviceTrusted:!1})}):null]})]})}function A8({api:e,onSession:t}){const[n,s]=v.useState(""),[o,l]=v.useState(""),[d,f]=v.useState(!1),[m,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(S){p(Ml(S))}finally{f(!1)}}return u.jsxs("form",{className:"auth-form",onSubmit:b,children:[u.jsxs("label",{children:["Password",u.jsx("input",{autoFocus:!0,value:n,onChange:_=>s(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),u.jsxs("label",{children:["Confirm password",u.jsx("input",{value:o,onChange:_=>l(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),m?u.jsx("p",{className:"form-error",children:m}):null,u.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function L8({api:e,session:t,onSession:n,onRefresh:s}){const[o,l]=v.useState(""),[d,f]=v.useState(""),[m,p]=v.useState(!1),[b,_]=v.useState(!1),[S,w]=v.useState(null),x=t?.totpEnabled??!1,R=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),_(!0),w(null);try{n(await e.login({password:o,...x?{otp:d}:{},rememberNetwork:m}))}catch(W){w(Ml(W))}finally{_(!1)}}return u.jsxs("form",{className:"auth-form",onSubmit:L,children:[u.jsxs("label",{children:["Password",u.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>l(A.currentTarget.value),required:!0})]}),x?u.jsxs("label",{children:["Authenticator code",u.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:A=>f(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,R?null:u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:m,onChange:A=>p(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?u.jsx("p",{className:"form-error",children:S}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:b||o.length===0||x&&d.length!==6,children:"Unlock"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function j8({api:e,session:t,onSession:n,onFullLogin:s}){const o=t?.currentIpWhitelisted??!1,[l,d]=v.useState(""),[f,m]=v.useState(!1),[p,b]=v.useState(!1),[_,S]=v.useState(!1),[w,x]=v.useState(!1),[R,L]=v.useState(null),A=zt.useCallback(async(z,H)=>{b(!0),L(null);try{n(await e.reauth({...z?{otp:z}:{},rememberNetwork:H}))}catch(q){L(Ml(q))}finally{b(!1)}},[e,n]);v.useEffect(()=>{if(o){let z=!1;S(!0),x(!1),L(null);const H=window.setTimeout(()=>{z||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{z||n(q)}).catch(q=>{z||(L(Ml(q)),x(!0))}).finally(()=>{window.clearTimeout(H),z||S(!1)}),()=>{z=!0,window.clearTimeout(H)}}},[e,o,n]);async function W(z){z.preventDefault(),await A(l,f)}return o&&_&&!w&&!R?u.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):u.jsxs("form",{className:"auth-form",onSubmit:W,children:[o&&w&&!R?u.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,u.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),u.jsxs("label",{children:["Authenticator code",u.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:l,onChange:z=>d(z.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:f,onChange:z=>m(z.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),R?u.jsx("p",{className:"form-error",children:R}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:p||l.length!==6,children:"Continue"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:p,children:"Use password instead"})]})]})}function O8(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Ml(e){return e instanceof Error?e.message:"Request failed"}const WC="NTerminal",Kb="nterminal.activeAgentId";function B8(){const[e,t]=v.useState(()=>I8()),n=v.useMemo(()=>Ip(),[]),s=v.useMemo(()=>Rs(e),[e]);v.useEffect(()=>{const l=()=>{const d=jP();document.title=d>0?`(${d}) ${WC}`:WC};return l(),LP(l)},[]);function o(l){P8(l),t(l)}return u.jsx(M8,{api:n,activeAgentId:e,serverApi:s,onSelectServer:o})}function I8(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Kb);return e&&e.trim()?e:null}catch{return null}}function P8(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Kb,e);return}window.localStorage.removeItem(Kb)}catch{}}const KC=["gesturestart","gesturechange","gestureend"],z8=[".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 H8(e=window){if(!$8(e))return()=>{};const t={passive:!1},n=e.document;function s(l){l.cancelable&&l.preventDefault()}function o(l){if(l.defaultPrevented)return;const d=l.touches;!d||d.length===0||(d.length>1||!U8(l.target))&&s(l)}for(const l of KC)n.addEventListener(l,s,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",s,t),()=>{for(const l of KC)n.removeEventListener(l,s,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",s,t)}}function U8(e){return e instanceof Element&&e.closest(z8)!==null}function $8(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}EM();k5();H8();Xb();TN.createRoot(document.getElementById("root")).render(u.jsx(zt.StrictMode,{children:u.jsx(B8,{})}));export{zt as R,vN as g,u as j};
|