nterminal 1.3.19 → 1.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/assets/MarkdownPreview-DD_7eToU.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BwFMI5GZ.js → TranscriptMarkdownBody-CUFmcDlb.js} +1 -1
- package/dist/client/assets/{index-DoDjMjz2.css → index-BA_6Pzsw.css} +1 -1
- package/dist/client/assets/index-BhgCPGn4.js +59 -0
- package/dist/client/assets/{index-B3ojUGo8.js → index-CSIqEVno.js} +1 -1
- package/dist/client/index.html +2 -2
- package/docs/features.md +3 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-DN1hmlZg.js +0 -1
- package/dist/client/assets/index-qXAESSsY.js +0 -59
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-DD_7eToU.js","assets/index-CSIqEVno.js","assets/TranscriptMarkdownBody-CUFmcDlb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function vN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pg={exports:{}},Uu={};var Jw;function _N(){if(Jw)return Uu;Jw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var d=null;if(l!==void 0&&(d=""+l),o.key!==void 0&&(d=""+o.key),"key"in o){l={};for(var f in o)f!=="key"&&(l[f]=o[f])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:d,ref:o!==void 0?o:null,props:l}}return Uu.Fragment=t,Uu.jsx=n,Uu.jsxs=n,Uu}var e1;function bN(){return e1||(e1=1,Pg.exports=_N()),Pg.exports}var u=bN(),zg={exports:{}},bt={};var t1;function yN(){if(t1)return bt;t1=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),w=Symbol.iterator;function S(N){return N===null||typeof N!="object"?null:(N=w&&N[w]||N["@@iterator"],typeof N=="function"?N:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,L={};function A(N,V,re){this.props=N,this.context=V,this.refs=L,this.updater=re||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 K(){}K.prototype=A.prototype;function P(N,V,re){this.props=N,this.context=V,this.refs=L,this.updater=re||x}var z=P.prototype=new K;z.constructor=P,E(z,A.prototype),z.isPureReactComponent=!0;var q=Array.isArray;function Y(){}var I={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function he(N,V,re){var Z=re.ref;return{$$typeof:e,type:N,key:V,ref:Z!==void 0?Z:null,props:re}}function Q(N,V){return he(N.type,V,N.props)}function ee(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function ie(N){var V={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(re){return V[re]})}var J=/\/+/g;function H(N,V){return typeof N=="object"&&N!==null&&N.key!=null?ie(""+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,re,Z,Te){var ye=typeof N;(ye==="undefined"||ye==="boolean")&&(N=null);var He=!1;if(N===null)He=!0;else switch(ye){case"bigint":case"string":case"number":He=!0;break;case"object":switch(N.$$typeof){case e:case t:He=!0;break;case b:return He=N._init,M(He(N._payload),V,re,Z,Te)}}if(He)return Te=Te(N),He=Z===""?"."+H(N,0):Z,q(Te)?(re="",He!=null&&(re=He.replace(J,"$&/")+"/"),M(Te,V,re,"",function(_e){return _e})):Te!=null&&(ee(Te)&&(Te=Q(Te,re+(Te.key==null||N&&N.key===Te.key?"":(""+Te.key).replace(J,"$&/")+"/")+He)),V.push(Te)),1;He=0;var Ke=Z===""?".":Z+":";if(q(N))for(var Ie=0;Ie<N.length;Ie++)Z=N[Ie],ye=Ke+H(Z,Ie),He+=M(Z,V,re,ye,Te);else if(Ie=S(N),typeof Ie=="function")for(N=Ie.call(N),Ie=0;!(Z=N.next()).done;)Z=Z.value,ye=Ke+H(Z,Ie++),He+=M(Z,V,re,ye,Te);else if(ye==="object"){if(typeof N.then=="function")return M(X(N),V,re,Z,Te);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 He}function R(N,V,re){if(N==null)return N;var Z=[],Te=0;return M(N,Z,"","",function(ye){return V.call(re,ye,Te++)}),Z}function B(N){if(N._status===-1){var V=N._result;V=V(),V.then(function(re){(N._status===0||N._status===-1)&&(N._status=1,N._result=re)},function(re){(N._status===0||N._status===-1)&&(N._status=2,N._result=re)}),N._status===-1&&(N._status=0,N._result=V)}if(N._status===1)return N._result.default;throw N._result}var oe=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)},ge={map:R,forEach:function(N,V,re){R(N,function(){V.apply(this,arguments)},re)},count:function(N){var V=0;return R(N,function(){V++}),V},toArray:function(N){return R(N,function(V){return V})||[]},only:function(N){if(!ee(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return bt.Activity=_,bt.Children=ge,bt.Component=A,bt.Fragment=n,bt.Profiler=o,bt.PureComponent=P,bt.StrictMode=r,bt.Suspense=m,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,bt.__COMPILER_RUNTIME={__proto__:null,c:function(N){return I.H.useMemoCache(N)}},bt.cache=function(N){return function(){return N.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function(N,V,re){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Z=E({},N.props),Te=N.key;if(V!=null)for(ye in V.key!==void 0&&(Te=""+V.key),V)!F.call(V,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&V.ref===void 0||(Z[ye]=V[ye]);var ye=arguments.length-2;if(ye===1)Z.children=re;else if(1<ye){for(var He=Array(ye),Ke=0;Ke<ye;Ke++)He[Ke]=arguments[Ke+2];Z.children=He}return he(N.type,Te,Z)},bt.createContext=function(N){return N={$$typeof:d,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:l,_context:N},N},bt.createElement=function(N,V,re){var Z,Te={},ye=null;if(V!=null)for(Z in V.key!==void 0&&(ye=""+V.key),V)F.call(V,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(Te[Z]=V[Z]);var He=arguments.length-2;if(He===1)Te.children=re;else if(1<He){for(var Ke=Array(He),Ie=0;Ie<He;Ie++)Ke[Ie]=arguments[Ie+2];Te.children=Ke}if(N&&N.defaultProps)for(Z in He=N.defaultProps,He)Te[Z]===void 0&&(Te[Z]=He[Z]);return he(N,ye,Te)},bt.createRef=function(){return{current:null}},bt.forwardRef=function(N){return{$$typeof:f,render:N}},bt.isValidElement=ee,bt.lazy=function(N){return{$$typeof:b,_payload:{_status:-1,_result:N},_init:B}},bt.memo=function(N,V){return{$$typeof:p,type:N,compare:V===void 0?null:V}},bt.startTransition=function(N){var V=I.T,re={};I.T=re;try{var Z=N(),Te=I.S;Te!==null&&Te(re,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(Y,oe)}catch(ye){oe(ye)}finally{V!==null&&re.types!==null&&(V.types=re.types),I.T=V}},bt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},bt.use=function(N){return I.H.use(N)},bt.useActionState=function(N,V,re){return I.H.useActionState(N,V,re)},bt.useCallback=function(N,V){return I.H.useCallback(N,V)},bt.useContext=function(N){return I.H.useContext(N)},bt.useDebugValue=function(){},bt.useDeferredValue=function(N,V){return I.H.useDeferredValue(N,V)},bt.useEffect=function(N,V){return I.H.useEffect(N,V)},bt.useEffectEvent=function(N){return I.H.useEffectEvent(N)},bt.useId=function(){return I.H.useId()},bt.useImperativeHandle=function(N,V,re){return I.H.useImperativeHandle(N,V,re)},bt.useInsertionEffect=function(N,V){return I.H.useInsertionEffect(N,V)},bt.useLayoutEffect=function(N,V){return I.H.useLayoutEffect(N,V)},bt.useMemo=function(N,V){return I.H.useMemo(N,V)},bt.useOptimistic=function(N,V){return I.H.useOptimistic(N,V)},bt.useReducer=function(N,V,re){return I.H.useReducer(N,V,re)},bt.useRef=function(N){return I.H.useRef(N)},bt.useState=function(N){return I.H.useState(N)},bt.useSyncExternalStore=function(N,V,re){return I.H.useSyncExternalStore(N,V,re)},bt.useTransition=function(){return I.H.useTransition()},bt.version="19.2.6",bt}var n1;function Wb(){return n1||(n1=1,zg.exports=yN()),zg.exports}var v=Wb();const Ht=vN(v);var Hg={exports:{}},$u={},Ug={exports:{}},$g={};var i1;function SN(){return i1||(i1=1,(function(e){function t(M,R){var B=M.length;M.push(R);e:for(;0<B;){var oe=B-1>>>1,ge=M[oe];if(0<o(ge,R))M[oe]=R,M[B]=ge,B=oe;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var R=M[0],B=M.pop();if(B!==R){M[0]=B;e:for(var oe=0,ge=M.length,N=ge>>>1;oe<N;){var V=2*(oe+1)-1,re=M[V],Z=V+1,Te=M[Z];if(0>o(re,B))Z<ge&&0>o(Te,re)?(M[oe]=Te,M[Z]=B,oe=Z):(M[oe]=re,M[V]=B,oe=V);else if(Z<ge&&0>o(Te,B))M[oe]=Te,M[Z]=B,oe=Z;else break e}}return R}function o(M,R){var B=M.sortIndex-R.sortIndex;return B!==0?B:M.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],p=[],b=1,_=null,w=3,S=!1,x=!1,E=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,K=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function z(M){for(var R=n(p);R!==null;){if(R.callback===null)r(p);else if(R.startTime<=M)r(p),R.sortIndex=R.expirationTime,t(m,R);else break;R=n(p)}}function q(M){if(E=!1,z(M),!x)if(n(m)!==null)x=!0,Y||(Y=!0,ie());else{var R=n(p);R!==null&&X(q,R.startTime-M)}}var Y=!1,I=-1,F=5,he=-1;function Q(){return L?!0:!(e.unstable_now()-he<F)}function ee(){if(L=!1,Y){var M=e.unstable_now();he=M;var R=!0;try{e:{x=!1,E&&(E=!1,K(I),I=-1),S=!0;var B=w;try{t:{for(z(M),_=n(m);_!==null&&!(_.expirationTime>M&&Q());){var oe=_.callback;if(typeof oe=="function"){_.callback=null,w=_.priorityLevel;var ge=oe(_.expirationTime<=M);if(M=e.unstable_now(),typeof ge=="function"){_.callback=ge,z(M),R=!0;break t}_===n(m)&&r(m),z(M)}else r(m);_=n(m)}if(_!==null)R=!0;else{var N=n(p);N!==null&&X(q,N.startTime-M),R=!1}}break e}finally{_=null,w=B,S=!1}R=void 0}}finally{R?ie():Y=!1}}}var ie;if(typeof P=="function")ie=function(){P(ee)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,H=J.port2;J.port1.onmessage=ee,ie=function(){H.postMessage(null)}}else ie=function(){A(ee,0)};function X(M,R){I=A(function(){M(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(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"):F=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(M){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var B=w;w=R;try{return M()}finally{w=B}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(M,R){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var B=w;w=M;try{return R()}finally{w=B}},e.unstable_scheduleCallback=function(M,R,B){var oe=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?oe+B:oe):B=oe,M){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=B+ge,M={id:b++,callback:R,priorityLevel:M,startTime:B,expirationTime:ge,sortIndex:-1},B>oe?(M.sortIndex=B,t(p,M),n(m)===null&&M===n(p)&&(E?(K(I),I=-1):E=!0,X(q,B-oe))):(M.sortIndex=ge,t(m,M),x||S||(x=!0,Y||(Y=!0,ie()))),M},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(M){var R=w;return function(){var B=w;w=R;try{return M.apply(this,arguments)}finally{w=B}}}})($g)),$g}var s1;function wN(){return s1||(s1=1,Ug.exports=SN()),Ug.exports}var Fg={exports:{}},Bi={};var r1;function xN(){if(r1)return Bi;r1=1;var e=Wb();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 r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(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=r,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=r.p;try{if(d.T=null,r.p=2,m)return m()}finally{d.T=p,r.p=b,r.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,r.d.C(m,p))},Bi.prefetchDNS=function(m){typeof m=="string"&&r.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),w=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;b==="style"?r.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:_,integrity:w,fetchPriority:S}):b==="script"&&r.d.X(m,{crossOrigin:_,integrity:w,fetchPriority:S,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);r.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&&r.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);r.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);r.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 r.d.m(m)},Bi.requestFormReset=function(m){r.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 a1;function qC(){if(a1)return Fg.exports;a1=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(),Fg.exports=xN(),Fg.exports}var o1;function CN(){if(o1)return $u;o1=1;var e=wN(),t=Wb(),n=qC();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function d(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(l(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=l(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,c=s;;){var h=a.return;if(h===null)break;var 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),s;g=g.sibling}throw Error(r(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(r(189))}}if(a.alternate!==c)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function b(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=b(i),s!==null)return s;i=i.sibling}return null}var _=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),K=Symbol.for("react.consumer"),P=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),he=Symbol.for("react.activity"),Q=Symbol.for("react.memo_cache_sentinel"),ee=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=ee&&i[ee]||i["@@iterator"],typeof i=="function"?i:null)}var J=Symbol.for("react.client.reference");function H(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===J?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case E:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case q:return"Suspense";case Y:return"SuspenseList";case he:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case P:return i.displayName||"Context";case K:return(i._context.displayName||"Context")+".Consumer";case z:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case I:return s=i.displayName||null,s!==null?s:H(i.type)||"Memo";case F:s=i._payload,i=i._init;try{return H(i(s))}catch{}}return null}var X=Array.isArray,M=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},oe=[],ge=-1;function N(i){return{current:i}}function V(i){0>ge||(i.current=oe[ge],oe[ge]=null,ge--)}function re(i,s){ge++,oe[ge]=i.current,i.current=s}var Z=N(null),Te=N(null),ye=N(null),He=N(null);function Ke(i,s){switch(re(ye,s),re(Te,i),re(Z,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?ww(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=ww(s),i=xw(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(Z),re(Z,i)}function Ie(){V(Z),V(Te),V(ye)}function _e(i){i.memoizedState!==null&&re(He,i);var s=Z.current,a=xw(s,i.type);s!==a&&(re(Te,i),re(Z,a))}function We(i){Te.current===i&&(V(Z),V(Te)),He.current===i&&(V(He),Iu._currentValue=B)}var Oe,j;function me(i){if(Oe===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);Oe=s&&s[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 ze(i,s){if(!i||Me)return"";Me=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(s){var Ee=function(){throw Error()};if(Object.defineProperty(Ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ee,[])}catch(be){var fe=be}Reflect.construct(i,[],Ee)}else{try{Ee.call()}catch(be){fe=be}i.call(Ee.prototype)}}else{try{throw Error()}catch(be){fe=be}(Ee=i())&&typeof Ee.catch=="function"&&Ee.catch(function(){})}}catch(be){if(be&&fe&&typeof be.stack=="string")return[be.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
|
+
`),de=D.split(`
|
|
6
|
+
`);for(h=c=0;c<U.length&&!U[c].includes("DetermineComponentFrameRoot");)c++;for(;h<de.length&&!de[h].includes("DetermineComponentFrameRoot");)h++;if(c===U.length||h===de.length)for(c=U.length-1,h=de.length-1;1<=c&&0<=h&&U[c]!==de[h];)h--;for(;1<=c&&0<=h;c--,h--)if(U[c]!==de[h]){if(c!==1||h!==1)do if(c--,h--,0>h||U[c]!==de[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:"")?me(a):""}function W(i,s){switch(i.tag){case 26:case 27:case 5:return me(i.type);case 16:return me("Lazy");case 13:return i.child!==s&&s!==null?me("Suspense Fallback"):me("Suspense");case 19:return me("SuspenseList");case 0:case 15:return ze(i.type,!1);case 11:return ze(i.type.render,!1);case 1:return ze(i.type,!0);case 31:return me("Activity");default:return""}}function pe(i){try{var s="",a=null;do s+=W(i,a),a=i,i=i.return;while(i);return s}catch(c){return`
|
|
8
|
+
Error generating stack: `+c.message+`
|
|
9
|
+
`+c.stack}}var Ce=Object.prototype.hasOwnProperty,Ne=e.unstable_scheduleCallback,Le=e.unstable_cancelCallback,ve=e.unstable_shouldYield,Pe=e.unstable_requestPaint,$e=e.unstable_now,Be=e.unstable_getCurrentPriorityLevel,ut=e.unstable_ImmediatePriority,ht=e.unstable_UserBlockingPriority,vt=e.unstable_NormalPriority,Rt=e.unstable_LowPriority,cn=e.unstable_IdlePriority,at=e.log,Wn=e.unstable_setDisableYieldValue,kn=null,_t=null;function jt(i){if(typeof at=="function"&&Wn(i),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(kn,i)}catch{}}var Nt=Math.clz32?Math.clz32:fn,pn=Math.log,ui=Math.LN2;function fn(i){return i>>>=0,i===0?32:31-(pn(i)/ui|0)|0}var mn=256,ae=262144,Fe=4194304;function Qe(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function St(i,s,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=Qe(c):(y&=D,y!==0?h=Qe(y):a||(a=D&~i,a!==0&&(h=Qe(a))))):(D=c&~g,D!==0?h=Qe(D):y!==0?h=Qe(y):a||(a=c&~i,a!==0&&(h=Qe(a)))),h===0?0:s!==0&&s!==h&&(s&g)===0&&(g=h&-h,a=s&-s,g>=a||g===32&&(a&4194048)!==0)?s:h}function Ut(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function $t(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Wt(){var i=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),i}function un(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function Bn(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Vt(i,s,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,de=i.hiddenUpdates;for(a=y&~a;0<a;){var Se=31-Nt(a),Ee=1<<Se;D[Se]=0,U[Se]=-1;var fe=de[Se];if(fe!==null)for(de[Se]=null,Se=0;Se<fe.length;Se++){var be=fe[Se];be!==null&&(be.lane&=-536870913)}a&=~Ee}c!==0&&Kn(i,c,0),g!==0&&h===0&&i.tag!==0&&(i.suspendedLanes|=g&~(y&~s))}function Kn(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var c=31-Nt(s);i.entangledLanes|=s,i.entanglements[c]=i.entanglements[c]|1073741824|a&261930}function Nn(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var c=31-Nt(a),h=1<<c;h&s|i[c]&s&&(i[c]|=s),a&=~h}}function en(i,s){var a=s&-s;return a=(a&42)!==0?1:qn(a),(a&(i.suspendedLanes|s))!==0?0:a}function qn(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 lt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function kt(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:qw(i.type))}function Dn(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var ce=Math.random().toString(36).slice(2),ke="__reactFiber$"+ce,Ve="__reactProps$"+ce,Xe="__reactContainer$"+ce,tt="__reactEvents$"+ce,sn="__reactListeners$"+ce,Vn="__reactHandles$"+ce,xi="__reactResources$"+ce,Yt="__reactMarker$"+ce;function qi(i){delete i[ke],delete i[Ve],delete i[tt],delete i[sn],delete i[Vn]}function Yn(i){var s=i[ke];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Xe]||a[ke]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=Dw(i);i!==null;){if(a=i[ke])return a;i=Dw(i)}return s}i=a,a=i.parentNode}return null}function ti(i){if(i=i[ke]||i[Xe]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function is(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function In(i){var s=i[xi];return s||(s=i[xi]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Ft(i){i[Yt]=!0}var wr=new Set,ys={};function Ai(i,s){zi(i,s),zi(i+"Capture",s)}function zi(i,s){for(ys[i]=s,i=0;i<s.length;i++)wr.add(s[i])}var Js=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]*$"),xr={},Cr={};function Vi(i){return Ce.call(Cr,i)?!0:Ce.call(xr,i)?!1:Js.test(i)?Cr[i]=!0:(xr[i]=!0,!1)}function kr(i,s,a){if(Vi(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var c=s.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function Ss(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function Ci(i,s,a,c){if(c===null)i.removeAttribute(a);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+c)}}function di(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Tr(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function wa(i,s,a){var c=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var h=c.get,g=c.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,g.call(this,y)}}),Object.defineProperty(i,s,{enumerable:c.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function Er(i){if(!i._valueTracker){var s=Tr(i)?"checked":"value";i._valueTracker=wa(i,s,""+i[s])}}function Rr(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),c="";return i&&(c=Tr(i)?i.checked?"true":"false":i.value),i=c,i!==a?(s.setValue(i),!0):!1}function xa(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 Ao=/[\n"\\]/g;function Li(i){return i.replace(Ao,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Nr(i,s,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"),s!=null?y==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+di(s)):i.value!==""+di(s)&&(i.value=""+di(s)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),s!=null?ki(i,y,di(s)):a!=null?ki(i,y,di(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=""+di(D):i.removeAttribute("name")}function Tl(i,s,a,c,h,g,y,D){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(i.type=g),s!=null||a!=null){if(!(g!=="submit"&&g!=="reset"||s!=null)){Er(i);return}a=a!=null?""+di(a):"",s=s!=null?""+di(s):a,D||s===i.value||(i.value=s),i.defaultValue=s}c=c??h,c=typeof c!="function"&&typeof c!="symbol"&&!!c,i.checked=D?i.checked:!!c,i.defaultChecked=!!c,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.name=y),Er(i)}function ki(i,s,a){s==="number"&&xa(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function er(i,s,a,c){if(i=i.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<i.length;a++)h=s.hasOwnProperty("$"+i[a].value),i[a].selected!==h&&(i[a].selected=h),h&&c&&(i[a].defaultSelected=!0)}else{for(a=""+di(a),s=null,h=0;h<i.length;h++){if(i[h].value===a){i[h].selected=!0,c&&(i[h].defaultSelected=!0);return}s!==null||i[h].disabled||(s=i[h])}s!==null&&(s.selected=!0)}}function Ca(i,s,a){if(s!=null&&(s=""+di(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+di(a):""}function Lo(i,s,a,c){if(s==null){if(c!=null){if(a!=null)throw Error(r(92));if(X(c)){if(1<c.length)throw Error(r(93));c=c[0]}a=c}a==null&&(a=""),s=a}a=di(s),i.defaultValue=a,c=i.textContent,c===a&&c!==""&&c!==null&&(i.value=c),Er(i)}function tr(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var Pn=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 ka(i,s,a){var c=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?c?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":c?i.setProperty(s,a):typeof a!="number"||a===0||Pn.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function jo(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var c in a)!a.hasOwnProperty(c)||s!=null&&s.hasOwnProperty(c)||(c.indexOf("--")===0?i.setProperty(c,""):c==="float"?i.cssFloat="":i[c]="");for(var h in s)c=s[h],s.hasOwnProperty(h)&&a[h]!==c&&ka(i,h,c)}else for(var g in s)s.hasOwnProperty(g)&&ka(i,g,s[g])}function Ta(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 Ea=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"]]),Ti=/^[\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 Ps(i){return Ti.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function ji(){}var Oi=null;function ws(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var nr=null,ss=null;function Dr(i){var s=ti(i);if(s&&(i=s.stateNode)){var a=i[Ve]||null;e:switch(i=s.stateNode,s.type){case"input":if(Nr(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Li(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var c=a[s];if(c!==i&&c.form===i.form){var h=c[Ve]||null;if(!h)throw Error(r(90));Nr(c,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(s=0;s<a.length;s++)c=a[s],c.form===i.form&&Rr(c)}break e;case"textarea":Ca(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&er(i,!!a.multiple,s,!1)}}}var xs=!1;function Ra(i,s,a){if(xs)return i(s,a);xs=!0;try{var c=i(s);return c}finally{if(xs=!1,(nr!==null||ss!==null)&&(Ih(),nr&&(s=nr,i=ss,ss=nr=null,Dr(s),i)))for(s=0;s<i.length;s++)Dr(i[s])}}function rs(i,s){var a=i.stateNode;if(a===null)return null;var c=a[Ve]||null;if(c===null)return null;a=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(i=i.type,c=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!c;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zs=!1;if(Mn)try{var Mr={};Object.defineProperty(Mr,"passive",{get:function(){zs=!0}}),window.addEventListener("test",Mr,Mr),window.removeEventListener("test",Mr,Mr)}catch{zs=!1}var Yi=null,Na=null,Hs=null;function El(){if(Hs)return Hs;var i,s=Na,a=s.length,c,h="value"in Yi?Yi.value:Yi.textContent,g=h.length;for(i=0;i<a&&s[i]===h[i];i++);var y=a-i;for(c=1;c<=y&&s[a-c]===h[g-c];c++);return Hs=h.slice(i,1<c?1-c:void 0)}function as(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function Us(){return!0}function Oo(){return!1}function Gt(i){function s(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)?Us:Oo,this.isPropagationStopped=Oo,this}return _(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Us)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Us)},persist:function(){},isPersistent:Us}),s}var os={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ft=Gt(os),ni=_({},os,{view:0,detail:0}),Da=Gt(ni),ir,Ar,sr,Ma=_({},ni,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Or,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!==sr&&(sr&&i.type==="mousemove"?(ir=i.screenX-sr.screenX,Ar=i.screenY-sr.screenY):Ar=ir=0,sr=i),ir)},movementY:function(i){return"movementY"in i?i.movementY:Ar}}),rr=Gt(Ma),th=_({},Ma,{dataTransfer:0}),hi=Gt(th),Bo=_({},ni,{relatedTarget:0}),Aa=Gt(Bo),$s=_({},os,{animationName:0,elapsedTime:0,pseudoElement:0}),Rl=Gt($s),Io=_({},os,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Lr=Gt(Io),Fs=_({},os,{data:0}),fi=Gt(Fs),jr={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nl={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"},Po={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function La(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Po[i])?!!s[i]:!1}function Or(){return La}var Dl=_({},ni,{key:function(i){if(i.key){var s=jr[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=as(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Nl[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Or,charCode:function(i){return i.type==="keypress"?as(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?as(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Ml=Gt(Dl),Br=_({},Ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ir=Gt(Br),Yc=_({},ni,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Or}),zo=Gt(Yc),Pr=_({},os,{propertyName:0,elapsedTime:0,pseudoElement:0}),ja=Gt(Pr),Gc=_({},Ma,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Xc=Gt(Gc),Cs=_({},os,{newState:0,oldState:0}),zr=Gt(Cs),Al=[9,13,27,32],Ho=Mn&&"CompositionEvent"in window,Hr=null;Mn&&"documentMode"in document&&(Hr=document.documentMode);var C=Mn&&"TextEvent"in window&&!Hr,T=Mn&&(!Ho||Hr&&8<Hr&&11>=Hr),O=" ",te=!1;function se(i,s){switch(i){case"keyup":return Al.indexOf(s.keyCode)!==-1;case"keydown":return s.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 we=!1;function Ae(i,s){switch(i){case"compositionend":return le(s);case"keypress":return s.which!==32?null:(te=!0,O);case"textInput":return i=s.data,i===O&&te?null:i;default:return null}}function qe(i,s){if(we)return i==="compositionend"||!Ho&&se(i,s)?(i=El(),Hs=Na=Yi=null,we=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return T&&s.locale!=="ko"?null:s.data;default:return null}}var Ye={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 pt(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!Ye[i.type]:s==="textarea"}function gn(i,s,a,c){nr?ss?ss.push(c):ss=[c]:nr=c,s=Wh(s,"onChange"),0<s.length&&(a=new ft("onChange","change",null,a,c),i.push({event:a,listeners:s}))}var wt=null,dn=null;function Ll(i){gw(i,0)}function ls(i){var s=is(i);if(Rr(s))return i}function pi(i,s){if(i==="change")return s}var nh=!1;if(Mn){var jl;if(Mn){var Ol="oninput"in document;if(!Ol){var Zc=document.createElement("div");Zc.setAttribute("oninput","return;"),Ol=typeof Zc.oninput=="function"}jl=Ol}else jl=!1;nh=jl&&(!document.documentMode||9<document.documentMode)}function ih(){wt&&(wt.detachEvent("onpropertychange",Qc),dn=wt=null)}function Qc(i){if(i.propertyName==="value"&&ls(dn)){var s=[];gn(s,dn,i,ws(i)),Ra(Ll,s)}}function Ur(i,s,a){i==="focusin"?(ih(),wt=s,dn=a,wt.attachEvent("onpropertychange",Qc)):i==="focusout"&&ih()}function Jc(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return ls(dn)}function Jp(i,s){if(i==="click")return ls(s)}function em(i,s){if(i==="input"||i==="change")return ls(s)}function sh(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var Hi=typeof Object.is=="function"?Object.is:sh;function $r(i,s){if(Hi(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),c=Object.keys(s);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var h=a[c];if(!Ce.call(s,h)||!Hi(i[h],s[h]))return!1}return!0}function Bl(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Il(i,s){var a=Bl(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=s&&c>=s)return{node:a,offset:s-i};i=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Bl(a)}}function Uo(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?Uo(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function eu(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=xa(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=xa(i.document)}return s}function Pl(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var tm=Mn&&"documentMode"in document&&11>=document.documentMode,Fr=null,tu=null,$o=null,nu=!1;function Oa(i,s,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;nu||Fr==null||Fr!==xa(c)||(c=Fr,"selectionStart"in c&&Pl(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}),$o&&$r($o,c)||($o=c,c=Wh(tu,"onSelect"),0<c.length&&(s=new ft("onSelect","select",null,s,a),i.push({event:s,listeners:c}),s.target=Fr)))}function ar(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var Ws={animationend:ar("Animation","AnimationEnd"),animationiteration:ar("Animation","AnimationIteration"),animationstart:ar("Animation","AnimationStart"),transitionrun:ar("Transition","TransitionRun"),transitionstart:ar("Transition","TransitionStart"),transitioncancel:ar("Transition","TransitionCancel"),transitionend:ar("Transition","TransitionEnd")},zl={},iu={};Mn&&(iu=document.createElement("div").style,"AnimationEvent"in window||(delete Ws.animationend.animation,delete Ws.animationiteration.animation,delete Ws.animationstart.animation),"TransitionEvent"in window||delete Ws.transitionend.transition);function Wr(i){if(zl[i])return zl[i];if(!Ws[i])return i;var s=Ws[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in iu)return zl[i]=s[a];return i}var su=Wr("animationend"),ru=Wr("animationiteration"),au=Wr("animationstart"),nm=Wr("transitionrun"),rh=Wr("transitionstart"),or=Wr("transitioncancel"),ah=Wr("transitionend"),oh=new Map,Hl="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(" ");Hl.push("scrollEnd");function cs(i,s){oh.set(i,s),Ai(s,[i])}var Ul=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},zn=[],Ba=0,$l=0;function Fl(){for(var i=Ba,s=$l=Ba=0;s<i;){var a=zn[s];zn[s++]=null;var c=zn[s];zn[s++]=null;var h=zn[s];zn[s++]=null;var g=zn[s];if(zn[s++]=null,c!==null&&h!==null){var y=c.pending;y===null?h.next=h:(h.next=y.next,y.next=h),c.pending=h}g!==0&&lu(a,h,g)}}function Wl(i,s,a,c){zn[Ba++]=i,zn[Ba++]=s,zn[Ba++]=a,zn[Ba++]=c,$l|=c,i.lanes|=c,i=i.alternate,i!==null&&(i.lanes|=c)}function ou(i,s,a,c){return Wl(i,s,a,c),Gi(i)}function Kr(i,s){return Wl(i,null,null,s),Gi(i)}function lu(i,s,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&&s!==null&&(h=31-Nt(a),i=g.hiddenUpdates,c=i[h],c===null?i[h]=[s]:c.push(s),s.lane=a|536870912),g):null}function Gi(i){if(50<Du)throw Du=0,lg=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var Ia={};function im(i,s,a,c){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(i,s,a,c){return new im(i,s,a,c)}function lr(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ks(i,s){var a=i.alternate;return a===null?(a=mi(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function lh(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function Fo(i,s,a,c,h,g){var y=0;if(c=i,typeof i=="function")lr(i)&&(y=1);else if(typeof i=="string")y=rN(i,a,Z.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case he:return i=mi(31,a,s,h),i.elementType=he,i.lanes=g,i;case E:return k(a.children,h,g,s);case L:y=8,h|=24;break;case A:return i=mi(12,a,s,h|2),i.elementType=A,i.lanes=g,i;case q:return i=mi(13,a,s,h),i.elementType=q,i.lanes=g,i;case Y:return i=mi(19,a,s,h),i.elementType=Y,i.lanes=g,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case P:y=10;break e;case K:y=9;break e;case z:y=11;break e;case I:y=14;break e;case F:y=16,c=null;break e}y=29,a=Error(r(130,i===null?"null":typeof i,"")),c=null}return s=mi(y,a,s,h),s.elementType=i,s.type=c,s.lanes=g,s}function k(i,s,a,c){return i=mi(7,i,c,s),i.lanes=a,i}function $(i,s,a){return i=mi(6,i,null,s),i.lanes=a,i}function je(i){var s=mi(18,null,null,0);return s.stateNode=i,s}function et(i,s,a){return s=mi(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var ot=new WeakMap;function st(i,s){if(typeof i=="object"&&i!==null){var a=ot.get(i);return a!==void 0?a:(s={value:i,source:s,stack:pe(s)},ot.set(i,s),s)}return{value:i,source:s,stack:pe(s)}}var Dt=[],Mt=0,it=null,dt=0,Ot=[],Bt=0,Qt=null,ii=1,ks="";function vn(i,s){Dt[Mt++]=dt,Dt[Mt++]=it,it=i,dt=s}function cu(i,s,a){Ot[Bt++]=ii,Ot[Bt++]=ks,Ot[Bt++]=Qt,Qt=i;var c=ii;i=ks;var h=32-Nt(c)-1;c&=~(1<<h),a+=1;var g=32-Nt(s)+h;if(30<g){var y=h-h%5;g=(c&(1<<y)-1).toString(32),c>>=y,h-=y,ii=1<<32-Nt(s)+h|a<<h|c,ks=g+i}else ii=1<<g|a<<h|c,ks=i}function Kl(i){i.return!==null&&(vn(i,1),cu(i,1,0))}function sm(i){for(;i===it;)it=Dt[--Mt],Dt[Mt]=null,dt=Dt[--Mt],Dt[Mt]=null;for(;i===Qt;)Qt=Ot[--Bt],Ot[Bt]=null,ks=Ot[--Bt],Ot[Bt]=null,ii=Ot[--Bt],Ot[Bt]=null}function nS(i,s){Ot[Bt++]=ii,Ot[Bt++]=ks,Ot[Bt++]=Qt,ii=s.id,ks=s.overflow,Qt=i}var Ei=null,_n=null,zt=!1,Pa=null,Ts=!1,rm=Error(r(519));function za(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw uu(st(s,i)),rm}function iS(i){var s=i.stateNode,a=i.type,c=i.memoizedProps;switch(s[ke]=i,s[Ve]=c,a){case"dialog":Lt("cancel",s),Lt("close",s);break;case"iframe":case"object":case"embed":Lt("load",s);break;case"video":case"audio":for(a=0;a<Au.length;a++)Lt(Au[a],s);break;case"source":Lt("error",s);break;case"img":case"image":case"link":Lt("error",s),Lt("load",s);break;case"details":Lt("toggle",s);break;case"input":Lt("invalid",s),Tl(s,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Lt("invalid",s);break;case"textarea":Lt("invalid",s),Lo(s,c.value,c.defaultValue,c.children)}a=c.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||c.suppressHydrationWarning===!0||yw(s.textContent,a)?(c.popover!=null&&(Lt("beforetoggle",s),Lt("toggle",s)),c.onScroll!=null&&Lt("scroll",s),c.onScrollEnd!=null&&Lt("scrollend",s),c.onClick!=null&&(s.onclick=ji),s=!0):s=!1,s||za(i,!0)}function sS(i){for(Ei=i.return;Ei;)switch(Ei.tag){case 5:case 31:case 13:Ts=!1;return;case 27:case 3:Ts=!0;return;default:Ei=Ei.return}}function ql(i){if(i!==Ei)return!1;if(!zt)return sS(i),zt=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||xg(i.type,i.memoizedProps)),a=!a),a&&_n&&za(i),sS(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));_n=Nw(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));_n=Nw(i)}else s===27?(s=_n,Ja(i.type)?(i=Rg,Rg=null,_n=i):_n=s):_n=Ei?Rs(i.stateNode.nextSibling):null;return!0}function Wo(){_n=Ei=null,zt=!1}function am(){var i=Pa;return i!==null&&(Ji===null?Ji=i:Ji.push.apply(Ji,i),Pa=null),i}function uu(i){Pa===null?Pa=[i]:Pa.push(i)}var om=N(null),Ko=null,qr=null;function Ha(i,s,a){re(om,s._currentValue),s._currentValue=a}function Vr(i){i._currentValue=om.current,V(om)}function lm(i,s,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),i===a)break;i=i.return}}function cm(i,s,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<s.length;U++)if(D.context===s[U]){g.lanes|=a,D=g.alternate,D!==null&&(D.lanes|=a),lm(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(r(341));y.lanes|=a,g=y.alternate,g!==null&&(g.lanes|=a),lm(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 Vl(i,s,a,c){i=null;for(var h=s,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(r(387));if(y=y.memoizedProps,y!==null){var D=h.type;Hi(h.pendingProps.value,y.value)||(i!==null?i.push(D):i=[D])}}else if(h===He.current){if(y=h.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(i!==null?i.push(Iu):i=[Iu])}h=h.return}i!==null&&cm(s,i,a,c),s.flags|=262144}function ch(i){for(i=i.firstContext;i!==null;){if(!Hi(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function qo(i){Ko=i,qr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ri(i){return rS(Ko,i)}function uh(i,s){return Ko===null&&qo(i),rS(i,s)}function rS(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},qr===null){if(i===null)throw Error(r(308));qr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else qr=qr.next=s;return a}var tR=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,c){i.push(c)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},nR=e.unstable_scheduleCallback,iR=e.unstable_NormalPriority,Gn={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function um(){return{controller:new tR,data:new Map,refCount:0}}function du(i){i.refCount--,i.refCount===0&&nR(iR,function(){i.controller.abort()})}var hu=null,dm=0,Yl=0,Gl=null;function sR(i,s){if(hu===null){var a=hu=[];dm=0,Yl=pg(),Gl={status:"pending",value:void 0,then:function(c){a.push(c)}}}return dm++,s.then(aS,aS),s}function aS(){if(--dm===0&&hu!==null){Gl!==null&&(Gl.status="fulfilled");var i=hu;hu=null,Yl=0,Gl=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function rR(i,s){var a=[],c={status:"pending",value:null,reason:null,then:function(h){a.push(h)}};return i.then(function(){c.status="fulfilled",c.value=s;for(var h=0;h<a.length;h++)(0,a[h])(s)},function(h){for(c.status="rejected",c.reason=h,h=0;h<a.length;h++)(0,a[h])(void 0)}),c}var oS=M.S;M.S=function(i,s){W0=$e(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&sR(i,s),oS!==null&&oS(i,s)};var Vo=N(null);function hm(){var i=Vo.current;return i!==null?i:hn.pooledCache}function dh(i,s){s===null?re(Vo,Vo.current):re(Vo,s.pool)}function lS(){var i=hm();return i===null?null:{parent:Gn._currentValue,pool:i}}var Xl=Error(r(460)),fm=Error(r(474)),hh=Error(r(542)),fh={then:function(){}};function cS(i){return i=i.status,i==="fulfilled"||i==="rejected"}function uS(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(ji,ji),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,hS(i),i;default:if(typeof s.status=="string")s.then(ji,ji);else{if(i=hn,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(c){if(s.status==="pending"){var h=s;h.status="fulfilled",h.value=c}},function(c){if(s.status==="pending"){var h=s;h.status="rejected",h.reason=c}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,hS(i),i}throw Go=s,Xl}}function Yo(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Go=a,Xl):a}}var Go=null;function dS(){if(Go===null)throw Error(r(459));var i=Go;return Go=null,i}function hS(i){if(i===Xl||i===hh)throw Error(r(483))}var Zl=null,fu=0;function ph(i){var s=fu;return fu+=1,Zl===null&&(Zl=[]),uS(Zl,i,s)}function pu(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function mh(i,s){throw s.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function fS(i){function s(ne,G){if(i){var ue=ne.deletions;ue===null?(ne.deletions=[G],ne.flags|=16):ue.push(G)}}function a(ne,G){if(!i)return null;for(;G!==null;)s(ne,G),G=G.sibling;return null}function c(ne){for(var G=new Map;ne!==null;)ne.key!==null?G.set(ne.key,ne):G.set(ne.index,ne),ne=ne.sibling;return G}function h(ne,G){return ne=Ks(ne,G),ne.index=0,ne.sibling=null,ne}function g(ne,G,ue){return ne.index=ue,i?(ue=ne.alternate,ue!==null?(ue=ue.index,ue<G?(ne.flags|=67108866,G):ue):(ne.flags|=67108866,G)):(ne.flags|=1048576,G)}function y(ne){return i&&ne.alternate===null&&(ne.flags|=67108866),ne}function D(ne,G,ue,xe){return G===null||G.tag!==6?(G=$(ue,ne.mode,xe),G.return=ne,G):(G=h(G,ue),G.return=ne,G)}function U(ne,G,ue,xe){var rt=ue.type;return rt===E?Se(ne,G,ue.props.children,xe,ue.key):G!==null&&(G.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===F&&Yo(rt)===G.type)?(G=h(G,ue.props),pu(G,ue),G.return=ne,G):(G=Fo(ue.type,ue.key,ue.props,null,ne.mode,xe),pu(G,ue),G.return=ne,G)}function de(ne,G,ue,xe){return G===null||G.tag!==4||G.stateNode.containerInfo!==ue.containerInfo||G.stateNode.implementation!==ue.implementation?(G=et(ue,ne.mode,xe),G.return=ne,G):(G=h(G,ue.children||[]),G.return=ne,G)}function Se(ne,G,ue,xe,rt){return G===null||G.tag!==7?(G=k(ue,ne.mode,xe,rt),G.return=ne,G):(G=h(G,ue),G.return=ne,G)}function Ee(ne,G,ue){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=$(""+G,ne.mode,ue),G.return=ne,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return ue=Fo(G.type,G.key,G.props,null,ne.mode,ue),pu(ue,G),ue.return=ne,ue;case x:return G=et(G,ne.mode,ue),G.return=ne,G;case F:return G=Yo(G),Ee(ne,G,ue)}if(X(G)||ie(G))return G=k(G,ne.mode,ue,null),G.return=ne,G;if(typeof G.then=="function")return Ee(ne,ph(G),ue);if(G.$$typeof===P)return Ee(ne,uh(ne,G),ue);mh(ne,G)}return null}function fe(ne,G,ue,xe){var rt=G!==null?G.key:null;if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return rt!==null?null:D(ne,G,""+ue,xe);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case S:return ue.key===rt?U(ne,G,ue,xe):null;case x:return ue.key===rt?de(ne,G,ue,xe):null;case F:return ue=Yo(ue),fe(ne,G,ue,xe)}if(X(ue)||ie(ue))return rt!==null?null:Se(ne,G,ue,xe,null);if(typeof ue.then=="function")return fe(ne,G,ph(ue),xe);if(ue.$$typeof===P)return fe(ne,G,uh(ne,ue),xe);mh(ne,ue)}return null}function be(ne,G,ue,xe,rt){if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return ne=ne.get(ue)||null,D(G,ne,""+xe,rt);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case S:return ne=ne.get(xe.key===null?ue:xe.key)||null,U(G,ne,xe,rt);case x:return ne=ne.get(xe.key===null?ue:xe.key)||null,de(G,ne,xe,rt);case F:return xe=Yo(xe),be(ne,G,ue,xe,rt)}if(X(xe)||ie(xe))return ne=ne.get(ue)||null,Se(G,ne,xe,rt,null);if(typeof xe.then=="function")return be(ne,G,ue,ph(xe),rt);if(xe.$$typeof===P)return be(ne,G,ue,uh(G,xe),rt);mh(G,xe)}return null}function Ze(ne,G,ue,xe){for(var rt=null,Kt=null,Je=G,Ct=G=0,Pt=null;Je!==null&&Ct<ue.length;Ct++){Je.index>Ct?(Pt=Je,Je=null):Pt=Je.sibling;var qt=fe(ne,Je,ue[Ct],xe);if(qt===null){Je===null&&(Je=Pt);break}i&&Je&&qt.alternate===null&&s(ne,Je),G=g(qt,G,Ct),Kt===null?rt=qt:Kt.sibling=qt,Kt=qt,Je=Pt}if(Ct===ue.length)return a(ne,Je),zt&&vn(ne,Ct),rt;if(Je===null){for(;Ct<ue.length;Ct++)Je=Ee(ne,ue[Ct],xe),Je!==null&&(G=g(Je,G,Ct),Kt===null?rt=Je:Kt.sibling=Je,Kt=Je);return zt&&vn(ne,Ct),rt}for(Je=c(Je);Ct<ue.length;Ct++)Pt=be(Je,ne,Ct,ue[Ct],xe),Pt!==null&&(i&&Pt.alternate!==null&&Je.delete(Pt.key===null?Ct:Pt.key),G=g(Pt,G,Ct),Kt===null?rt=Pt:Kt.sibling=Pt,Kt=Pt);return i&&Je.forEach(function(so){return s(ne,so)}),zt&&vn(ne,Ct),rt}function ct(ne,G,ue,xe){if(ue==null)throw Error(r(151));for(var rt=null,Kt=null,Je=G,Ct=G=0,Pt=null,qt=ue.next();Je!==null&&!qt.done;Ct++,qt=ue.next()){Je.index>Ct?(Pt=Je,Je=null):Pt=Je.sibling;var so=fe(ne,Je,qt.value,xe);if(so===null){Je===null&&(Je=Pt);break}i&&Je&&so.alternate===null&&s(ne,Je),G=g(so,G,Ct),Kt===null?rt=so:Kt.sibling=so,Kt=so,Je=Pt}if(qt.done)return a(ne,Je),zt&&vn(ne,Ct),rt;if(Je===null){for(;!qt.done;Ct++,qt=ue.next())qt=Ee(ne,qt.value,xe),qt!==null&&(G=g(qt,G,Ct),Kt===null?rt=qt:Kt.sibling=qt,Kt=qt);return zt&&vn(ne,Ct),rt}for(Je=c(Je);!qt.done;Ct++,qt=ue.next())qt=be(Je,ne,Ct,qt.value,xe),qt!==null&&(i&&qt.alternate!==null&&Je.delete(qt.key===null?Ct:qt.key),G=g(qt,G,Ct),Kt===null?rt=qt:Kt.sibling=qt,Kt=qt);return i&&Je.forEach(function(gN){return s(ne,gN)}),zt&&vn(ne,Ct),rt}function on(ne,G,ue,xe){if(typeof ue=="object"&&ue!==null&&ue.type===E&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case S:e:{for(var rt=ue.key;G!==null;){if(G.key===rt){if(rt=ue.type,rt===E){if(G.tag===7){a(ne,G.sibling),xe=h(G,ue.props.children),xe.return=ne,ne=xe;break e}}else if(G.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===F&&Yo(rt)===G.type){a(ne,G.sibling),xe=h(G,ue.props),pu(xe,ue),xe.return=ne,ne=xe;break e}a(ne,G);break}else s(ne,G);G=G.sibling}ue.type===E?(xe=k(ue.props.children,ne.mode,xe,ue.key),xe.return=ne,ne=xe):(xe=Fo(ue.type,ue.key,ue.props,null,ne.mode,xe),pu(xe,ue),xe.return=ne,ne=xe)}return y(ne);case x:e:{for(rt=ue.key;G!==null;){if(G.key===rt)if(G.tag===4&&G.stateNode.containerInfo===ue.containerInfo&&G.stateNode.implementation===ue.implementation){a(ne,G.sibling),xe=h(G,ue.children||[]),xe.return=ne,ne=xe;break e}else{a(ne,G);break}else s(ne,G);G=G.sibling}xe=et(ue,ne.mode,xe),xe.return=ne,ne=xe}return y(ne);case F:return ue=Yo(ue),on(ne,G,ue,xe)}if(X(ue))return Ze(ne,G,ue,xe);if(ie(ue)){if(rt=ie(ue),typeof rt!="function")throw Error(r(150));return ue=rt.call(ue),ct(ne,G,ue,xe)}if(typeof ue.then=="function")return on(ne,G,ph(ue),xe);if(ue.$$typeof===P)return on(ne,G,uh(ne,ue),xe);mh(ne,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint"?(ue=""+ue,G!==null&&G.tag===6?(a(ne,G.sibling),xe=h(G,ue),xe.return=ne,ne=xe):(a(ne,G),xe=$(ue,ne.mode,xe),xe.return=ne,ne=xe),y(ne)):a(ne,G)}return function(ne,G,ue,xe){try{fu=0;var rt=on(ne,G,ue,xe);return Zl=null,rt}catch(Je){if(Je===Xl||Je===hh)throw Je;var Kt=mi(29,Je,null,ne.mode);return Kt.lanes=xe,Kt.return=ne,Kt}}}var Xo=fS(!0),pS=fS(!1),Ua=!1;function pm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mm(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function $a(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Fa(i,s,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Xt&2)!==0){var h=c.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),c.pending=s,s=Gi(i),lu(i,null,a),s}return Wl(i,c,s,a),Gi(i)}function mu(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,Nn(i,a)}}function gm(i,s){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=s:g=g.next=s}else h=g=s;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=s:i.next=s,a.lastBaseUpdate=s}var vm=!1;function gu(){if(vm){var i=Gl;if(i!==null)throw i}}function vu(i,s,a,c){vm=!1;var h=i.updateQueue;Ua=!1;var g=h.firstBaseUpdate,y=h.lastBaseUpdate,D=h.shared.pending;if(D!==null){h.shared.pending=null;var U=D,de=U.next;U.next=null,y===null?g=de:y.next=de,y=U;var Se=i.alternate;Se!==null&&(Se=Se.updateQueue,D=Se.lastBaseUpdate,D!==y&&(D===null?Se.firstBaseUpdate=de:D.next=de,Se.lastBaseUpdate=U))}if(g!==null){var Ee=h.baseState;y=0,Se=de=U=null,D=g;do{var fe=D.lane&-536870913,be=fe!==D.lane;if(be?(It&fe)===fe:(c&fe)===fe){fe!==0&&fe===Yl&&(vm=!0),Se!==null&&(Se=Se.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Ze=i,ct=D;fe=s;var on=a;switch(ct.tag){case 1:if(Ze=ct.payload,typeof Ze=="function"){Ee=Ze.call(on,Ee,fe);break e}Ee=Ze;break e;case 3:Ze.flags=Ze.flags&-65537|128;case 0:if(Ze=ct.payload,fe=typeof Ze=="function"?Ze.call(on,Ee,fe):Ze,fe==null)break e;Ee=_({},Ee,fe);break e;case 2:Ua=!0}}fe=D.callback,fe!==null&&(i.flags|=64,be&&(i.flags|=8192),be=h.callbacks,be===null?h.callbacks=[fe]:be.push(fe))}else be={lane:fe,tag:D.tag,payload:D.payload,callback:D.callback,next:null},Se===null?(de=Se=be,U=Ee):Se=Se.next=be,y|=fe;if(D=D.next,D===null){if(D=h.shared.pending,D===null)break;be=D,D=be.next,be.next=null,h.lastBaseUpdate=be,h.shared.pending=null}}while(!0);Se===null&&(U=Ee),h.baseState=U,h.firstBaseUpdate=de,h.lastBaseUpdate=Se,g===null&&(h.shared.lanes=0),Ya|=y,i.lanes=y,i.memoizedState=Ee}}function mS(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function gS(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)mS(a[i],s)}var Ql=N(null),gh=N(0);function vS(i,s){i=na,re(gh,i),re(Ql,s),na=i|s.baseLanes}function _m(){re(gh,na),re(Ql,Ql.current)}function bm(){na=gh.current,V(Ql),V(gh)}var us=N(null),Es=null;function Wa(i){var s=i.alternate;re(Hn,Hn.current&1),re(us,i),Es===null&&(s===null||Ql.current!==null||s.memoizedState!==null)&&(Es=i)}function ym(i){re(Hn,Hn.current),re(us,i),Es===null&&(Es=i)}function _S(i){i.tag===22?(re(Hn,Hn.current),re(us,i),Es===null&&(Es=i)):Ka()}function Ka(){re(Hn,Hn.current),re(us,us.current)}function ds(i){V(us),Es===i&&(Es=null),V(Hn)}var Hn=N(0);function vh(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Tg(a)||Eg(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Yr=0,xt=null,rn=null,Xn=null,_h=!1,Jl=!1,Zo=!1,bh=0,_u=0,ec=null,aR=0;function An(){throw Error(r(321))}function Sm(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!Hi(i[a],s[a]))return!1;return!0}function wm(i,s,a,c,h,g){return Yr=g,xt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,M.H=i===null||i.memoizedState===null?t0:Im,Zo=!1,g=a(c,h),Zo=!1,Jl&&(g=yS(s,a,c,h)),bS(i),g}function bS(i){M.H=Su;var s=rn!==null&&rn.next!==null;if(Yr=0,Xn=rn=xt=null,_h=!1,_u=0,ec=null,s)throw Error(r(300));i===null||Zn||(i=i.dependencies,i!==null&&ch(i)&&(Zn=!0))}function yS(i,s,a,c){xt=i;var h=0;do{if(Jl&&(ec=null),_u=0,Jl=!1,25<=h)throw Error(r(301));if(h+=1,Xn=rn=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=n0,g=s(a,c)}while(Jl);return g}function oR(){var i=M.H,s=i.useState()[0];return s=typeof s.then=="function"?bu(s):s,i=i.useState()[0],(rn!==null?rn.memoizedState:null)!==i&&(xt.flags|=1024),s}function xm(){var i=bh!==0;return bh=0,i}function Cm(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function km(i){if(_h){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}_h=!1}Yr=0,Xn=rn=xt=null,Jl=!1,_u=bh=0,ec=null}function Ui(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xn===null?xt.memoizedState=Xn=i:Xn=Xn.next=i,Xn}function Un(){if(rn===null){var i=xt.alternate;i=i!==null?i.memoizedState:null}else i=rn.next;var s=Xn===null?xt.memoizedState:Xn.next;if(s!==null)Xn=s,rn=i;else{if(i===null)throw xt.alternate===null?Error(r(467)):Error(r(310));rn=i,i={memoizedState:rn.memoizedState,baseState:rn.baseState,baseQueue:rn.baseQueue,queue:rn.queue,next:null},Xn===null?xt.memoizedState=Xn=i:Xn=Xn.next=i}return Xn}function yh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function bu(i){var s=_u;return _u+=1,ec===null&&(ec=[]),i=uS(ec,i,s),s=xt,(Xn===null?s.memoizedState:Xn.next)===null&&(s=s.alternate,M.H=s===null||s.memoizedState===null?t0:Im),i}function Sh(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return bu(i);if(i.$$typeof===P)return Ri(i)}throw Error(r(438,String(i)))}function Tm(i){var s=null,a=xt.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var c=xt.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(s={data:c.data.map(function(h){return h.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=yh(),xt.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),c=0;c<i;c++)a[c]=Q;return s.index++,a}function Gr(i,s){return typeof s=="function"?s(i):s}function wh(i){var s=Un();return Em(s,rn,i)}function Em(i,s,a){var c=i.queue;if(c===null)throw Error(r(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}s.baseQueue=h=g,c.pending=null}if(g=i.baseState,h===null)i.memoizedState=g;else{s=h.next;var D=y=null,U=null,de=s,Se=!1;do{var Ee=de.lane&-536870913;if(Ee!==de.lane?(It&Ee)===Ee:(Yr&Ee)===Ee){var fe=de.revertLane;if(fe===0)U!==null&&(U=U.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),Ee===Yl&&(Se=!0);else if((Yr&fe)===fe){de=de.next,fe===Yl&&(Se=!0);continue}else Ee={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},U===null?(D=U=Ee,y=g):U=U.next=Ee,xt.lanes|=fe,Ya|=fe;Ee=de.action,Zo&&a(g,Ee),g=de.hasEagerState?de.eagerState:a(g,Ee)}else fe={lane:Ee,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},U===null?(D=U=fe,y=g):U=U.next=fe,xt.lanes|=Ee,Ya|=Ee;de=de.next}while(de!==null&&de!==s);if(U===null?y=g:U.next=D,!Hi(g,i.memoizedState)&&(Zn=!0,Se&&(a=Gl,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 Rm(i){var s=Un(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var c=a.dispatch,h=a.pending,g=s.memoizedState;if(h!==null){a.pending=null;var y=h=h.next;do g=i(g,y.action),y=y.next;while(y!==h);Hi(g,s.memoizedState)||(Zn=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),a.lastRenderedState=g}return[g,c]}function SS(i,s,a){var c=xt,h=Un(),g=zt;if(g){if(a===void 0)throw Error(r(407));a=a()}else a=s();var y=!Hi((rn||h).memoizedState,a);if(y&&(h.memoizedState=a,Zn=!0),h=h.queue,Mm(CS.bind(null,c,h,i),[i]),h.getSnapshot!==s||y||Xn!==null&&Xn.memoizedState.tag&1){if(c.flags|=2048,tc(9,{destroy:void 0},xS.bind(null,c,h,a,s),null),hn===null)throw Error(r(349));g||(Yr&127)!==0||wS(c,s,a)}return a}function wS(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=xt.updateQueue,s===null?(s=yh(),xt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function xS(i,s,a,c){s.value=a,s.getSnapshot=c,kS(s)&&TS(i)}function CS(i,s,a){return a(function(){kS(s)&&TS(i)})}function kS(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!Hi(i,a)}catch{return!0}}function TS(i){var s=Kr(i,2);s!==null&&es(s,i,2)}function Nm(i){var s=Ui();if(typeof i=="function"){var a=i;if(i=a(),Zo){jt(!0);try{a()}finally{jt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:i},s}function ES(i,s,a,c){return i.baseState=a,Em(i,rn,typeof c=="function"?c:Gr)}function lR(i,s,a,c,h){if(kh(i))throw Error(r(485));if(i=s.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=s.pending,a===null?(g.next=s.pending=g,RS(s,g)):(g.next=a.next,s.pending=a.next=g)}}function RS(i,s){var a=s.action,c=s.payload,h=i.state;if(s.isTransition){var g=M.T,y={};M.T=y;try{var D=a(h,c),U=M.S;U!==null&&U(y,D),NS(i,s,D)}catch(de){Dm(i,s,de)}finally{g!==null&&y.types!==null&&(g.types=y.types),M.T=g}}else try{g=a(h,c),NS(i,s,g)}catch(de){Dm(i,s,de)}}function NS(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(c){DS(i,s,c)},function(c){return Dm(i,s,c)}):DS(i,s,a)}function DS(i,s,a){s.status="fulfilled",s.value=a,MS(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,RS(i,a)))}function Dm(i,s,a){var c=i.pending;if(i.pending=null,c!==null){c=c.next;do s.status="rejected",s.reason=a,MS(s),s=s.next;while(s!==c)}i.action=null}function MS(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function AS(i,s){return s}function LS(i,s){if(zt){var a=hn.formState;if(a!==null){e:{var c=xt;if(zt){if(_n){t:{for(var h=_n,g=Ts;h.nodeType!==8;){if(!g){h=null;break t}if(h=Rs(h.nextSibling),h===null){h=null;break t}}g=h.data,h=g==="F!"||g==="F"?h:null}if(h){_n=Rs(h.nextSibling),c=h.data==="F!";break e}}za(c)}c=!1}c&&(s=a[0])}}return a=Ui(),a.memoizedState=a.baseState=s,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:AS,lastRenderedState:s},a.queue=c,a=QS.bind(null,xt,c),c.dispatch=a,c=Nm(!1),g=Bm.bind(null,xt,!1,c.queue),c=Ui(),h={state:s,dispatch:null,action:i,pending:null},c.queue=h,a=lR.bind(null,xt,h,g,a),h.dispatch=a,c.memoizedState=i,[s,a,!1]}function jS(i){var s=Un();return OS(s,rn,i)}function OS(i,s,a){if(s=Em(i,s,AS)[0],i=wh(Gr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var c=bu(s)}catch(y){throw y===Xl?hh:y}else c=s;s=Un();var h=s.queue,g=h.dispatch;return a!==s.memoizedState&&(xt.flags|=2048,tc(9,{destroy:void 0},cR.bind(null,h,a),null)),[c,g,i]}function cR(i,s){i.action=s}function BS(i){var s=Un(),a=rn;if(a!==null)return OS(s,a,i);Un(),s=s.memoizedState,a=Un();var c=a.queue.dispatch;return a.memoizedState=i,[s,c,!1]}function tc(i,s,a,c){return i={tag:i,create:a,deps:c,inst:s,next:null},s=xt.updateQueue,s===null&&(s=yh(),xt.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,s.lastEffect=i),i}function IS(){return Un().memoizedState}function xh(i,s,a,c){var h=Ui();xt.flags|=i,h.memoizedState=tc(1|s,{destroy:void 0},a,c===void 0?null:c)}function Ch(i,s,a,c){var h=Un();c=c===void 0?null:c;var g=h.memoizedState.inst;rn!==null&&c!==null&&Sm(c,rn.memoizedState.deps)?h.memoizedState=tc(s,g,a,c):(xt.flags|=i,h.memoizedState=tc(1|s,g,a,c))}function PS(i,s){xh(8390656,8,i,s)}function Mm(i,s){Ch(2048,8,i,s)}function uR(i){xt.flags|=4;var s=xt.updateQueue;if(s===null)s=yh(),xt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function zS(i){var s=Un().memoizedState;return uR({ref:s,nextImpl:i}),function(){if((Xt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function HS(i,s){return Ch(4,2,i,s)}function US(i,s){return Ch(4,4,i,s)}function $S(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function FS(i,s,a){a=a!=null?a.concat([i]):null,Ch(4,4,$S.bind(null,s,i),a)}function Am(){}function WS(i,s){var a=Un();s=s===void 0?null:s;var c=a.memoizedState;return s!==null&&Sm(s,c[1])?c[0]:(a.memoizedState=[i,s],i)}function KS(i,s){var a=Un();s=s===void 0?null:s;var c=a.memoizedState;if(s!==null&&Sm(s,c[1]))return c[0];if(c=i(),Zo){jt(!0);try{i()}finally{jt(!1)}}return a.memoizedState=[c,s],c}function Lm(i,s,a){return a===void 0||(Yr&1073741824)!==0&&(It&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=q0(),xt.lanes|=i,Ya|=i,a)}function qS(i,s,a,c){return Hi(a,s)?a:Ql.current!==null?(i=Lm(i,a,c),Hi(i,s)||(Zn=!0),i):(Yr&42)===0||(Yr&1073741824)!==0&&(It&261930)===0?(Zn=!0,i.memoizedState=a):(i=q0(),xt.lanes|=i,Ya|=i,s)}function VS(i,s,a,c,h){var g=R.p;R.p=g!==0&&8>g?g:8;var y=M.T,D={};M.T=D,Bm(i,!1,s,a);try{var U=h(),de=M.S;if(de!==null&&de(D,U),U!==null&&typeof U=="object"&&typeof U.then=="function"){var Se=rR(U,c);yu(i,s,Se,ps(i))}else yu(i,s,c,ps(i))}catch(Ee){yu(i,s,{then:function(){},status:"rejected",reason:Ee},ps())}finally{R.p=g,y!==null&&D.types!==null&&(y.types=D.types),M.T=y}}function dR(){}function jm(i,s,a,c){if(i.tag!==5)throw Error(r(476));var h=YS(i).queue;VS(i,h,s,B,a===null?dR:function(){return GS(i),a(c)})}function YS(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:B},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function GS(i){var s=YS(i);s.next===null&&(s=i.alternate.memoizedState),yu(i,s.next.queue,{},ps())}function Om(){return Ri(Iu)}function XS(){return Un().memoizedState}function ZS(){return Un().memoizedState}function hR(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=ps();i=$a(a);var c=Fa(s,i,a);c!==null&&(es(c,s,a),mu(c,s,a)),s={cache:um()},i.payload=s;return}s=s.return}}function fR(i,s,a){var c=ps();a={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},kh(i)?JS(s,a):(a=ou(i,s,a,c),a!==null&&(es(a,i,c),e0(a,s,c)))}function QS(i,s,a){var c=ps();yu(i,s,a,c)}function yu(i,s,a,c){var h={lane:c,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(kh(i))JS(s,h);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var y=s.lastRenderedState,D=g(y,a);if(h.hasEagerState=!0,h.eagerState=D,Hi(D,y))return Wl(i,s,h,0),hn===null&&Fl(),!1}catch{}if(a=ou(i,s,h,c),a!==null)return es(a,i,c),e0(a,s,c),!0}return!1}function Bm(i,s,a,c){if(c={lane:2,revertLane:pg(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},kh(i)){if(s)throw Error(r(479))}else s=ou(i,a,c,2),s!==null&&es(s,i,2)}function kh(i){var s=i.alternate;return i===xt||s!==null&&s===xt}function JS(i,s){Jl=_h=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function e0(i,s,a){if((a&4194048)!==0){var c=s.lanes;c&=i.pendingLanes,a|=c,s.lanes=a,Nn(i,a)}}var Su={readContext:Ri,use:Sh,useCallback:An,useContext:An,useEffect:An,useImperativeHandle:An,useLayoutEffect:An,useInsertionEffect:An,useMemo:An,useReducer:An,useRef:An,useState:An,useDebugValue:An,useDeferredValue:An,useTransition:An,useSyncExternalStore:An,useId:An,useHostTransitionStatus:An,useFormState:An,useActionState:An,useOptimistic:An,useMemoCache:An,useCacheRefresh:An};Su.useEffectEvent=An;var t0={readContext:Ri,use:Sh,useCallback:function(i,s){return Ui().memoizedState=[i,s===void 0?null:s],i},useContext:Ri,useEffect:PS,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,xh(4194308,4,$S.bind(null,s,i),a)},useLayoutEffect:function(i,s){return xh(4194308,4,i,s)},useInsertionEffect:function(i,s){xh(4,2,i,s)},useMemo:function(i,s){var a=Ui();s=s===void 0?null:s;var c=i();if(Zo){jt(!0);try{i()}finally{jt(!1)}}return a.memoizedState=[c,s],c},useReducer:function(i,s,a){var c=Ui();if(a!==void 0){var h=a(s);if(Zo){jt(!0);try{a(s)}finally{jt(!1)}}}else h=s;return c.memoizedState=c.baseState=h,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:h},c.queue=i,i=i.dispatch=fR.bind(null,xt,i),[c.memoizedState,i]},useRef:function(i){var s=Ui();return i={current:i},s.memoizedState=i},useState:function(i){i=Nm(i);var s=i.queue,a=QS.bind(null,xt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:Am,useDeferredValue:function(i,s){var a=Ui();return Lm(a,i,s)},useTransition:function(){var i=Nm(!1);return i=VS.bind(null,xt,i.queue,!0,!1),Ui().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var c=xt,h=Ui();if(zt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),hn===null)throw Error(r(349));(It&127)!==0||wS(c,s,a)}h.memoizedState=a;var g={value:a,getSnapshot:s};return h.queue=g,PS(CS.bind(null,c,g,i),[i]),c.flags|=2048,tc(9,{destroy:void 0},xS.bind(null,c,g,a,s),null),a},useId:function(){var i=Ui(),s=hn.identifierPrefix;if(zt){var a=ks,c=ii;a=(c&~(1<<32-Nt(c)-1)).toString(32)+a,s="_"+s+"R_"+a,a=bh++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=aR++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:Om,useFormState:LS,useActionState:LS,useOptimistic:function(i){var s=Ui();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=Bm.bind(null,xt,!0,a),a.dispatch=s,[i,s]},useMemoCache:Tm,useCacheRefresh:function(){return Ui().memoizedState=hR.bind(null,xt)},useEffectEvent:function(i){var s=Ui(),a={impl:i};return s.memoizedState=a,function(){if((Xt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Im={readContext:Ri,use:Sh,useCallback:WS,useContext:Ri,useEffect:Mm,useImperativeHandle:FS,useInsertionEffect:HS,useLayoutEffect:US,useMemo:KS,useReducer:wh,useRef:IS,useState:function(){return wh(Gr)},useDebugValue:Am,useDeferredValue:function(i,s){var a=Un();return qS(a,rn.memoizedState,i,s)},useTransition:function(){var i=wh(Gr)[0],s=Un().memoizedState;return[typeof i=="boolean"?i:bu(i),s]},useSyncExternalStore:SS,useId:XS,useHostTransitionStatus:Om,useFormState:jS,useActionState:jS,useOptimistic:function(i,s){var a=Un();return ES(a,rn,i,s)},useMemoCache:Tm,useCacheRefresh:ZS};Im.useEffectEvent=zS;var n0={readContext:Ri,use:Sh,useCallback:WS,useContext:Ri,useEffect:Mm,useImperativeHandle:FS,useInsertionEffect:HS,useLayoutEffect:US,useMemo:KS,useReducer:Rm,useRef:IS,useState:function(){return Rm(Gr)},useDebugValue:Am,useDeferredValue:function(i,s){var a=Un();return rn===null?Lm(a,i,s):qS(a,rn.memoizedState,i,s)},useTransition:function(){var i=Rm(Gr)[0],s=Un().memoizedState;return[typeof i=="boolean"?i:bu(i),s]},useSyncExternalStore:SS,useId:XS,useHostTransitionStatus:Om,useFormState:BS,useActionState:BS,useOptimistic:function(i,s){var a=Un();return rn!==null?ES(a,rn,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Tm,useCacheRefresh:ZS};n0.useEffectEvent=zS;function Pm(i,s,a,c){s=i.memoizedState,a=a(c,s),a=a==null?s:_({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var zm={enqueueSetState:function(i,s,a){i=i._reactInternals;var c=ps(),h=$a(c);h.payload=s,a!=null&&(h.callback=a),s=Fa(i,h,c),s!==null&&(es(s,i,c),mu(s,i,c))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var c=ps(),h=$a(c);h.tag=1,h.payload=s,a!=null&&(h.callback=a),s=Fa(i,h,c),s!==null&&(es(s,i,c),mu(s,i,c))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=ps(),c=$a(a);c.tag=2,s!=null&&(c.callback=s),s=Fa(i,c,a),s!==null&&(es(s,i,a),mu(s,i,a))}};function i0(i,s,a,c,h,g,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,y):s.prototype&&s.prototype.isPureReactComponent?!$r(a,c)||!$r(h,g):!0}function s0(i,s,a,c){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,c),s.state!==i&&zm.enqueueReplaceState(s,s.state,null)}function Qo(i,s){var a=s;if("ref"in s){a={};for(var c in s)c!=="ref"&&(a[c]=s[c])}if(i=i.defaultProps){a===s&&(a=_({},a));for(var h in i)a[h]===void 0&&(a[h]=i[h])}return a}function r0(i){Ul(i)}function a0(i){console.error(i)}function o0(i){Ul(i)}function Th(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(c){setTimeout(function(){throw c})}}function l0(i,s,a){try{var c=i.onCaughtError;c(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function Hm(i,s,a){return a=$a(a),a.tag=3,a.payload={element:null},a.callback=function(){Th(i,s)},a}function c0(i){return i=$a(i),i.tag=3,i}function u0(i,s,a,c){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var g=c.value;i.payload=function(){return h(g)},i.callback=function(){l0(s,a,c)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){l0(s,a,c),typeof h!="function"&&(Ga===null?Ga=new Set([this]):Ga.add(this));var D=c.stack;this.componentDidCatch(c.value,{componentStack:D!==null?D:""})})}function pR(i,s,a,c,h){if(a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(s=a.alternate,s!==null&&Vl(s,a,h,!0),a=us.current,a!==null){switch(a.tag){case 31:case 13:return Es===null?Ph():a.alternate===null&&Ln===0&&(Ln=3),a.flags&=-257,a.flags|=65536,a.lanes=h,c===fh?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([c]):s.add(c),dg(i,c,h)),!1;case 22:return a.flags|=65536,c===fh?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([c])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([c]):a.add(c)),dg(i,c,h)),!1}throw Error(r(435,a.tag))}return dg(i,c,h),Ph(),!1}if(zt)return s=us.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=h,c!==rm&&(i=Error(r(422),{cause:c}),uu(st(i,a)))):(c!==rm&&(s=Error(r(423),{cause:c}),uu(st(s,a))),i=i.current.alternate,i.flags|=65536,h&=-h,i.lanes|=h,c=st(c,a),h=Hm(i.stateNode,c,h),gm(i,h),Ln!==4&&(Ln=2)),!1;var g=Error(r(520),{cause:c});if(g=st(g,a),Nu===null?Nu=[g]:Nu.push(g),Ln!==4&&(Ln=2),s===null)return!0;c=st(c,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=h&-h,a.lanes|=i,i=Hm(a.stateNode,c,i),gm(a,i),!1;case 1:if(s=a.type,g=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ga===null||!Ga.has(g))))return a.flags|=65536,h&=-h,a.lanes|=h,h=c0(h),u0(h,i,a,c),gm(a,h),!1}a=a.return}while(a!==null);return!1}var Um=Error(r(461)),Zn=!1;function Ni(i,s,a,c){s.child=i===null?pS(s,null,a,c):Xo(s,i.child,a,c)}function d0(i,s,a,c,h){a=a.render;var g=s.ref;if("ref"in c){var y={};for(var D in c)D!=="ref"&&(y[D]=c[D])}else y=c;return qo(s),c=wm(i,s,a,y,g,h),D=xm(),i!==null&&!Zn?(Cm(i,s,h),Xr(i,s,h)):(zt&&D&&Kl(s),s.flags|=1,Ni(i,s,c,h),s.child)}function h0(i,s,a,c,h){if(i===null){var g=a.type;return typeof g=="function"&&!lr(g)&&g.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=g,f0(i,s,g,c,h)):(i=Fo(a.type,null,c,s,s.mode,h),i.ref=s.ref,i.return=s,s.child=i)}if(g=i.child,!Gm(i,h)){var y=g.memoizedProps;if(a=a.compare,a=a!==null?a:$r,a(y,c)&&i.ref===s.ref)return Xr(i,s,h)}return s.flags|=1,i=Ks(g,c),i.ref=s.ref,i.return=s,s.child=i}function f0(i,s,a,c,h){if(i!==null){var g=i.memoizedProps;if($r(g,c)&&i.ref===s.ref)if(Zn=!1,s.pendingProps=c=g,Gm(i,h))(i.flags&131072)!==0&&(Zn=!0);else return s.lanes=i.lanes,Xr(i,s,h)}return $m(i,s,a,c,h)}function p0(i,s,a,c){var h=c.children,g=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((s.flags&128)!==0){if(g=g!==null?g.baseLanes|a:a,i!==null){for(c=s.child=i.child,h=0;c!==null;)h=h|c.lanes|c.childLanes,c=c.sibling;c=h&~g}else c=0,s.child=null;return m0(i,s,g,a,c)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&dh(s,g!==null?g.cachePool:null),g!==null?vS(s,g):_m(),_S(s);else return c=s.lanes=536870912,m0(i,s,g!==null?g.baseLanes|a:a,a,c)}else g!==null?(dh(s,g.cachePool),vS(s,g),Ka(),s.memoizedState=null):(i!==null&&dh(s,null),_m(),Ka());return Ni(i,s,h,a),s.child}function wu(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function m0(i,s,a,c,h){var g=hm();return g=g===null?null:{parent:Gn._currentValue,pool:g},s.memoizedState={baseLanes:a,cachePool:g},i!==null&&dh(s,null),_m(),_S(s),i!==null&&Vl(i,s,c,!0),s.childLanes=h,null}function Eh(i,s){return s=Nh({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function g0(i,s,a){return Xo(s,i.child,null,a),i=Eh(s,s.pendingProps),i.flags|=2,ds(s),s.memoizedState=null,i}function mR(i,s,a){var c=s.pendingProps,h=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(zt){if(c.mode==="hidden")return i=Eh(s,c),s.lanes=536870912,wu(null,i);if(ym(s),(i=_n)?(i=Rw(i,Ts),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qt!==null?{id:ii,overflow:ks}:null,retryLane:536870912,hydrationErrors:null},a=je(i),a.return=s,s.child=a,Ei=s,_n=null)):i=null,i===null)throw za(s);return s.lanes=536870912,null}return Eh(s,c)}var g=i.memoizedState;if(g!==null){var y=g.dehydrated;if(ym(s),h)if(s.flags&256)s.flags&=-257,s=g0(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Zn||Vl(i,s,a,!1),h=(a&i.childLanes)!==0,Zn||h){if(c=hn,c!==null&&(y=en(c,a),y!==0&&y!==g.retryLane))throw g.retryLane=y,Kr(i,y),es(c,i,y),Um;Ph(),s=g0(i,s,a)}else i=g.treeContext,_n=Rs(y.nextSibling),Ei=s,zt=!0,Pa=null,Ts=!1,i!==null&&nS(s,i),s=Eh(s,c),s.flags|=4096;return s}return i=Ks(i.child,{mode:c.mode,children:c.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Rh(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function $m(i,s,a,c,h){return qo(s),a=wm(i,s,a,c,void 0,h),c=xm(),i!==null&&!Zn?(Cm(i,s,h),Xr(i,s,h)):(zt&&c&&Kl(s),s.flags|=1,Ni(i,s,a,h),s.child)}function v0(i,s,a,c,h,g){return qo(s),s.updateQueue=null,a=yS(s,c,a,h),bS(i),c=xm(),i!==null&&!Zn?(Cm(i,s,g),Xr(i,s,g)):(zt&&c&&Kl(s),s.flags|=1,Ni(i,s,a,g),s.child)}function _0(i,s,a,c,h){if(qo(s),s.stateNode===null){var g=Ia,y=a.contextType;typeof y=="object"&&y!==null&&(g=Ri(y)),g=new a(c,g),s.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=zm,s.stateNode=g,g._reactInternals=s,g=s.stateNode,g.props=c,g.state=s.memoizedState,g.refs={},pm(s),y=a.contextType,g.context=typeof y=="object"&&y!==null?Ri(y):Ia,g.state=s.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Pm(s,a,y,c),g.state=s.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&&zm.enqueueReplaceState(g,g.state,null),vu(s,c,g,h),gu(),g.state=s.memoizedState),typeof g.componentDidMount=="function"&&(s.flags|=4194308),c=!0}else if(i===null){g=s.stateNode;var D=s.memoizedProps,U=Qo(a,D);g.props=U;var de=g.context,Se=a.contextType;y=Ia,typeof Se=="object"&&Se!==null&&(y=Ri(Se));var Ee=a.getDerivedStateFromProps;Se=typeof Ee=="function"||typeof g.getSnapshotBeforeUpdate=="function",D=s.pendingProps!==D,Se||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(D||de!==y)&&s0(s,g,c,y),Ua=!1;var fe=s.memoizedState;g.state=fe,vu(s,c,g,h),gu(),de=s.memoizedState,D||fe!==de||Ua?(typeof Ee=="function"&&(Pm(s,a,Ee,c),de=s.memoizedState),(U=Ua||i0(s,a,U,c,fe,de,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"&&(s.flags|=4194308)):(typeof g.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=de),g.props=c,g.state=de,g.context=y,c=U):(typeof g.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{g=s.stateNode,mm(i,s),y=s.memoizedProps,Se=Qo(a,y),g.props=Se,Ee=s.pendingProps,fe=g.context,de=a.contextType,U=Ia,typeof de=="object"&&de!==null&&(U=Ri(de)),D=a.getDerivedStateFromProps,(de=typeof D=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(y!==Ee||fe!==U)&&s0(s,g,c,U),Ua=!1,fe=s.memoizedState,g.state=fe,vu(s,c,g,h),gu();var be=s.memoizedState;y!==Ee||fe!==be||Ua||i!==null&&i.dependencies!==null&&ch(i.dependencies)?(typeof D=="function"&&(Pm(s,a,D,c),be=s.memoizedState),(Se=Ua||i0(s,a,Se,c,fe,be,U)||i!==null&&i.dependencies!==null&&ch(i.dependencies))?(de||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,be,U),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,be,U)),typeof g.componentDidUpdate=="function"&&(s.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof g.componentDidUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(s.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=be),g.props=c,g.state=be,g.context=U,c=Se):(typeof g.componentDidUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(s.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&fe===i.memoizedState||(s.flags|=1024),c=!1)}return g=c,Rh(i,s),c=(s.flags&128)!==0,g||c?(g=s.stateNode,a=c&&typeof a.getDerivedStateFromError!="function"?null:g.render(),s.flags|=1,i!==null&&c?(s.child=Xo(s,i.child,null,h),s.child=Xo(s,null,a,h)):Ni(i,s,a,h),s.memoizedState=g.state,i=s.child):i=Xr(i,s,h),i}function b0(i,s,a,c){return Wo(),s.flags|=256,Ni(i,s,a,c),s.child}var Fm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wm(i){return{baseLanes:i,cachePool:lS()}}function Km(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=fs),i}function y0(i,s,a){var c=s.pendingProps,h=!1,g=(s.flags&128)!==0,y;if((y=g)||(y=i!==null&&i.memoizedState===null?!1:(Hn.current&2)!==0),y&&(h=!0,s.flags&=-129),y=(s.flags&32)!==0,s.flags&=-33,i===null){if(zt){if(h?Wa(s):Ka(),(i=_n)?(i=Rw(i,Ts),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qt!==null?{id:ii,overflow:ks}:null,retryLane:536870912,hydrationErrors:null},a=je(i),a.return=s,s.child=a,Ei=s,_n=null)):i=null,i===null)throw za(s);return Eg(i)?s.lanes=32:s.lanes=536870912,null}var D=c.children;return c=c.fallback,h?(Ka(),h=s.mode,D=Nh({mode:"hidden",children:D},h),c=k(c,h,a,null),D.return=s,c.return=s,D.sibling=c,s.child=D,c=s.child,c.memoizedState=Wm(a),c.childLanes=Km(i,y,a),s.memoizedState=Fm,wu(null,c)):(Wa(s),qm(s,D))}var U=i.memoizedState;if(U!==null&&(D=U.dehydrated,D!==null)){if(g)s.flags&256?(Wa(s),s.flags&=-257,s=Vm(i,s,a)):s.memoizedState!==null?(Ka(),s.child=i.child,s.flags|=128,s=null):(Ka(),D=c.fallback,h=s.mode,c=Nh({mode:"visible",children:c.children},h),D=k(D,h,a,null),D.flags|=2,c.return=s,D.return=s,c.sibling=D,s.child=c,Xo(s,i.child,null,a),c=s.child,c.memoizedState=Wm(a),c.childLanes=Km(i,y,a),s.memoizedState=Fm,s=wu(null,c));else if(Wa(s),Eg(D)){if(y=D.nextSibling&&D.nextSibling.dataset,y)var de=y.dgst;y=de,c=Error(r(419)),c.stack="",c.digest=y,uu({value:c,source:null,stack:null}),s=Vm(i,s,a)}else if(Zn||Vl(i,s,a,!1),y=(a&i.childLanes)!==0,Zn||y){if(y=hn,y!==null&&(c=en(y,a),c!==0&&c!==U.retryLane))throw U.retryLane=c,Kr(i,c),es(y,i,c),Um;Tg(D)||Ph(),s=Vm(i,s,a)}else Tg(D)?(s.flags|=192,s.child=i.child,s=null):(i=U.treeContext,_n=Rs(D.nextSibling),Ei=s,zt=!0,Pa=null,Ts=!1,i!==null&&nS(s,i),s=qm(s,c.children),s.flags|=4096);return s}return h?(Ka(),D=c.fallback,h=s.mode,U=i.child,de=U.sibling,c=Ks(U,{mode:"hidden",children:c.children}),c.subtreeFlags=U.subtreeFlags&65011712,de!==null?D=Ks(de,D):(D=k(D,h,a,null),D.flags|=2),D.return=s,c.return=s,c.sibling=D,s.child=c,wu(null,c),c=s.child,D=i.child.memoizedState,D===null?D=Wm(a):(h=D.cachePool,h!==null?(U=Gn._currentValue,h=h.parent!==U?{parent:U,pool:U}:h):h=lS(),D={baseLanes:D.baseLanes|a,cachePool:h}),c.memoizedState=D,c.childLanes=Km(i,y,a),s.memoizedState=Fm,wu(i.child,c)):(Wa(s),a=i.child,i=a.sibling,a=Ks(a,{mode:"visible",children:c.children}),a.return=s,a.sibling=null,i!==null&&(y=s.deletions,y===null?(s.deletions=[i],s.flags|=16):y.push(i)),s.child=a,s.memoizedState=null,a)}function qm(i,s){return s=Nh({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function Nh(i,s){return i=mi(22,i,null,s),i.lanes=0,i}function Vm(i,s,a){return Xo(s,i.child,null,a),i=qm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function S0(i,s,a){i.lanes|=s;var c=i.alternate;c!==null&&(c.lanes|=s),lm(i.return,s,a)}function Ym(i,s,a,c,h,g){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:h,treeForkCount:g}:(y.isBackwards=s,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=a,y.tailMode=h,y.treeForkCount=g)}function w0(i,s,a){var c=s.pendingProps,h=c.revealOrder,g=c.tail;c=c.children;var y=Hn.current,D=(y&2)!==0;if(D?(y=y&1|2,s.flags|=128):y&=1,re(Hn,y),Ni(i,s,c,a),c=zt?dt:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&S0(i,a,s);else if(i.tag===19)S0(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(h){case"forwards":for(a=s.child,h=null;a!==null;)i=a.alternate,i!==null&&vh(i)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),Ym(s,!1,h,a,g,c);break;case"backwards":case"unstable_legacy-backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(i=h.alternate,i!==null&&vh(i)===null){s.child=h;break}i=h.sibling,h.sibling=a,a=h,h=i}Ym(s,!0,a,null,g,c);break;case"together":Ym(s,!1,null,null,void 0,c);break;default:s.memoizedState=null}return s.child}function Xr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),Ya|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Vl(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=Ks(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=Ks(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function Gm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&ch(i)))}function gR(i,s,a){switch(s.tag){case 3:Ke(s,s.stateNode.containerInfo),Ha(s,Gn,i.memoizedState.cache),Wo();break;case 27:case 5:_e(s);break;case 4:Ke(s,s.stateNode.containerInfo);break;case 10:Ha(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,ym(s),null;break;case 13:var c=s.memoizedState;if(c!==null)return c.dehydrated!==null?(Wa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?y0(i,s,a):(Wa(s),i=Xr(i,s,a),i!==null?i.sibling:null);Wa(s);break;case 19:var h=(i.flags&128)!==0;if(c=(a&s.childLanes)!==0,c||(Vl(i,s,a,!1),c=(a&s.childLanes)!==0),h){if(c)return w0(i,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),re(Hn,Hn.current),c)break;return null;case 22:return s.lanes=0,p0(i,s,a,s.pendingProps);case 24:Ha(s,Gn,i.memoizedState.cache)}return Xr(i,s,a)}function x0(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Zn=!0;else{if(!Gm(i,a)&&(s.flags&128)===0)return Zn=!1,gR(i,s,a);Zn=(i.flags&131072)!==0}else Zn=!1,zt&&(s.flags&1048576)!==0&&cu(s,dt,s.index);switch(s.lanes=0,s.tag){case 16:e:{var c=s.pendingProps;if(i=Yo(s.elementType),s.type=i,typeof i=="function")lr(i)?(c=Qo(i,c),s.tag=1,s=_0(null,s,i,c,a)):(s.tag=0,s=$m(null,s,i,c,a));else{if(i!=null){var h=i.$$typeof;if(h===z){s.tag=11,s=d0(null,s,i,c,a);break e}else if(h===I){s.tag=14,s=h0(null,s,i,c,a);break e}}throw s=H(i)||i,Error(r(306,s,""))}}return s;case 0:return $m(i,s,s.type,s.pendingProps,a);case 1:return c=s.type,h=Qo(c,s.pendingProps),_0(i,s,c,h,a);case 3:e:{if(Ke(s,s.stateNode.containerInfo),i===null)throw Error(r(387));c=s.pendingProps;var g=s.memoizedState;h=g.element,mm(i,s),vu(s,c,null,a);var y=s.memoizedState;if(c=y.cache,Ha(s,Gn,c),c!==g.cache&&cm(s,[Gn],a,!0),gu(),c=y.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:y.cache},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){s=b0(i,s,c,a);break e}else if(c!==h){h=st(Error(r(424)),s),uu(h),s=b0(i,s,c,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,_n=Rs(i.firstChild),Ei=s,zt=!0,Pa=null,Ts=!0,a=pS(s,null,c,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Wo(),c===h){s=Xr(i,s,a);break e}Ni(i,s,c,a)}s=s.child}return s;case 26:return Rh(i,s),i===null?(a=jw(s.type,null,s.pendingProps,null))?s.memoizedState=a:zt||(a=s.type,i=s.pendingProps,c=Kh(ye.current).createElement(a),c[ke]=s,c[Ve]=i,Di(c,a,i),Ft(c),s.stateNode=c):s.memoizedState=jw(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return _e(s),i===null&&zt&&(c=s.stateNode=Mw(s.type,s.pendingProps,ye.current),Ei=s,Ts=!0,h=_n,Ja(s.type)?(Rg=h,_n=Rs(c.firstChild)):_n=h),Ni(i,s,s.pendingProps.children,a),Rh(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&zt&&((h=c=_n)&&(c=qR(c,s.type,s.pendingProps,Ts),c!==null?(s.stateNode=c,Ei=s,_n=Rs(c.firstChild),Ts=!1,h=!0):h=!1),h||za(s)),_e(s),h=s.type,g=s.pendingProps,y=i!==null?i.memoizedProps:null,c=g.children,xg(h,g)?c=null:y!==null&&xg(h,y)&&(s.flags|=32),s.memoizedState!==null&&(h=wm(i,s,oR,null,null,a),Iu._currentValue=h),Rh(i,s),Ni(i,s,c,a),s.child;case 6:return i===null&&zt&&((i=a=_n)&&(a=VR(a,s.pendingProps,Ts),a!==null?(s.stateNode=a,Ei=s,_n=null,i=!0):i=!1),i||za(s)),null;case 13:return y0(i,s,a);case 4:return Ke(s,s.stateNode.containerInfo),c=s.pendingProps,i===null?s.child=Xo(s,null,c,a):Ni(i,s,c,a),s.child;case 11:return d0(i,s,s.type,s.pendingProps,a);case 7:return Ni(i,s,s.pendingProps,a),s.child;case 8:return Ni(i,s,s.pendingProps.children,a),s.child;case 12:return Ni(i,s,s.pendingProps.children,a),s.child;case 10:return c=s.pendingProps,Ha(s,s.type,c.value),Ni(i,s,c.children,a),s.child;case 9:return h=s.type._context,c=s.pendingProps.children,qo(s),h=Ri(h),c=c(h),s.flags|=1,Ni(i,s,c,a),s.child;case 14:return h0(i,s,s.type,s.pendingProps,a);case 15:return f0(i,s,s.type,s.pendingProps,a);case 19:return w0(i,s,a);case 31:return mR(i,s,a);case 22:return p0(i,s,a,s.pendingProps);case 24:return qo(s),c=Ri(Gn),i===null?(h=hm(),h===null&&(h=hn,g=um(),h.pooledCache=g,g.refCount++,g!==null&&(h.pooledCacheLanes|=a),h=g),s.memoizedState={parent:c,cache:h},pm(s),Ha(s,Gn,h)):((i.lanes&a)!==0&&(mm(i,s),vu(s,null,null,a),gu()),h=i.memoizedState,g=s.memoizedState,h.parent!==c?(h={parent:c,cache:c},s.memoizedState=h,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=h),Ha(s,Gn,c)):(c=g.cache,Ha(s,Gn,c),c!==h.cache&&cm(s,[Gn],a,!0))),Ni(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function Zr(i){i.flags|=4}function Xm(i,s,a,c,h){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(h&335544128)===h)if(i.stateNode.complete)i.flags|=8192;else if(X0())i.flags|=8192;else throw Go=fh,fm}else i.flags&=-16777217}function C0(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!zw(s))if(X0())i.flags|=8192;else throw Go=fh,fm}function Dh(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Wt():536870912,i.lanes|=s,rc|=s)}function xu(i,s){if(!zt)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function bn(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(s)for(var h=i.child;h!==null;)a|=h.lanes|h.childLanes,c|=h.subtreeFlags&65011712,c|=h.flags&65011712,h.return=i,h=h.sibling;else for(h=i.child;h!==null;)a|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=i,h=h.sibling;return i.subtreeFlags|=c,i.childLanes=a,s}function vR(i,s,a){var c=s.pendingProps;switch(sm(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(s),null;case 1:return bn(s),null;case 3:return a=s.stateNode,c=null,i!==null&&(c=i.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),Vr(Gn),Ie(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(ql(s)?Zr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,am())),bn(s),null;case 26:var h=s.type,g=s.memoizedState;return i===null?(Zr(s),g!==null?(bn(s),C0(s,g)):(bn(s),Xm(s,h,null,c,a))):g?g!==i.memoizedState?(Zr(s),bn(s),C0(s,g)):(bn(s),s.flags&=-16777217):(i=i.memoizedProps,i!==c&&Zr(s),bn(s),Xm(s,h,i,c,a)),null;case 27:if(We(s),a=ye.current,h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==c&&Zr(s);else{if(!c){if(s.stateNode===null)throw Error(r(166));return bn(s),null}i=Z.current,ql(s)?iS(s):(i=Mw(h,c,a),s.stateNode=i,Zr(s))}return bn(s),null;case 5:if(We(s),h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==c&&Zr(s);else{if(!c){if(s.stateNode===null)throw Error(r(166));return bn(s),null}if(g=Z.current,ql(s))iS(s);else{var y=Kh(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]=s,g[Ve]=c;e:for(y=s.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===s)break e;for(;y.sibling===null;){if(y.return===null||y.return===s)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}s.stateNode=g;e:switch(Di(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&&Zr(s)}}return bn(s),Xm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==c&&Zr(s);else{if(typeof c!="string"&&s.stateNode===null)throw Error(r(166));if(i=ye.current,ql(s)){if(i=s.stateNode,a=s.memoizedProps,c=null,h=Ei,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}i[ke]=s,i=!!(i.nodeValue===a||c!==null&&c.suppressHydrationWarning===!0||yw(i.nodeValue,a)),i||za(s,!0)}else i=Kh(i).createTextNode(c),i[ke]=s,s.stateNode=i}return bn(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(c=ql(s),a!==null){if(i===null){if(!c)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[ke]=s}else Wo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;bn(s),i=!1}else a=am(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(ds(s),s):(ds(s),null);if((s.flags&128)!==0)throw Error(r(558))}return bn(s),null;case 13:if(c=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(h=ql(s),c!==null&&c.dehydrated!==null){if(i===null){if(!h)throw Error(r(318));if(h=s.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[ke]=s}else Wo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;bn(s),h=!1}else h=am(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=h),h=!0;if(!h)return s.flags&256?(ds(s),s):(ds(s),null)}return ds(s),(s.flags&128)!==0?(s.lanes=a,s):(a=c!==null,i=i!==null&&i.memoizedState!==null,a&&(c=s.child,h=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(h=c.alternate.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==h&&(c.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Dh(s,s.updateQueue),bn(s),null);case 4:return Ie(),i===null&&_g(s.stateNode.containerInfo),bn(s),null;case 10:return Vr(s.type),bn(s),null;case 19:if(V(Hn),c=s.memoizedState,c===null)return bn(s),null;if(h=(s.flags&128)!==0,g=c.rendering,g===null)if(h)xu(c,!1);else{if(Ln!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(g=vh(i),g!==null){for(s.flags|=128,xu(c,!1),i=g.updateQueue,s.updateQueue=i,Dh(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)lh(a,i),a=a.sibling;return re(Hn,Hn.current&1|2),zt&&vn(s,c.treeForkCount),s.child}i=i.sibling}c.tail!==null&&$e()>Oh&&(s.flags|=128,h=!0,xu(c,!1),s.lanes=4194304)}else{if(!h)if(i=vh(g),i!==null){if(s.flags|=128,h=!0,i=i.updateQueue,s.updateQueue=i,Dh(s,i),xu(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!zt)return bn(s),null}else 2*$e()-c.renderingStartTime>Oh&&a!==536870912&&(s.flags|=128,h=!0,xu(c,!1),s.lanes=4194304);c.isBackwards?(g.sibling=s.child,s.child=g):(i=c.last,i!==null?i.sibling=g:s.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=Hn.current,re(Hn,h?a&1|2:a&1),zt&&vn(s,c.treeForkCount),i):(bn(s),null);case 22:case 23:return ds(s),bm(),c=s.memoizedState!==null,i!==null?i.memoizedState!==null!==c&&(s.flags|=8192):c&&(s.flags|=8192),c?(a&536870912)!==0&&(s.flags&128)===0&&(bn(s),s.subtreeFlags&6&&(s.flags|=8192)):bn(s),a=s.updateQueue,a!==null&&Dh(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),c=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),c!==a&&(s.flags|=2048),i!==null&&V(Vo),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),Vr(Gn),bn(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function _R(i,s){switch(sm(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return Vr(Gn),Ie(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return We(s),null;case 31:if(s.memoizedState!==null){if(ds(s),s.alternate===null)throw Error(r(340));Wo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(ds(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));Wo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return V(Hn),null;case 4:return Ie(),null;case 10:return Vr(s.type),null;case 22:case 23:return ds(s),bm(),i!==null&&V(Vo),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return Vr(Gn),null;case 25:return null;default:return null}}function k0(i,s){switch(sm(s),s.tag){case 3:Vr(Gn),Ie();break;case 26:case 27:case 5:We(s);break;case 4:Ie();break;case 31:s.memoizedState!==null&&ds(s);break;case 13:ds(s);break;case 19:V(Hn);break;case 10:Vr(s.type);break;case 22:case 23:ds(s),bm(),i!==null&&V(Vo);break;case 24:Vr(Gn)}}function Cu(i,s){try{var a=s.updateQueue,c=a!==null?a.lastEffect:null;if(c!==null){var h=c.next;a=h;do{if((a.tag&i)===i){c=void 0;var g=a.create,y=a.inst;c=g(),y.destroy=c}a=a.next}while(a!==h)}}catch(D){nn(s,s.return,D)}}function qa(i,s,a){try{var c=s.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=s;var U=a,de=D;try{de()}catch(Se){nn(h,U,Se)}}}c=c.next}while(c!==g)}}catch(Se){nn(s,s.return,Se)}}function T0(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{gS(s,a)}catch(c){nn(i,i.return,c)}}}function E0(i,s,a){a.props=Qo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(c){nn(i,s,c)}}function ku(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var c=i.stateNode;break;case 30:c=i.stateNode;break;default:c=i.stateNode}typeof a=="function"?i.refCleanup=a(c):a.current=c}}catch(h){nn(i,s,h)}}function cr(i,s){var a=i.ref,c=i.refCleanup;if(a!==null)if(typeof c=="function")try{c()}catch(h){nn(i,s,h)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(h){nn(i,s,h)}else a.current=null}function R0(i){var s=i.type,a=i.memoizedProps,c=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&c.focus();break e;case"img":a.src?c.src=a.src:a.srcSet&&(c.srcset=a.srcSet)}}catch(h){nn(i,i.return,h)}}function Zm(i,s,a){try{var c=i.stateNode;HR(c,i.type,a,s),c[Ve]=s}catch(h){nn(i,i.return,h)}}function N0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ja(i.type)||i.tag===4}function Qm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||N0(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&&Ja(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 Jm(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=ji));else if(c!==4&&(c===27&&Ja(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Jm(i,s,a),i=i.sibling;i!==null;)Jm(i,s,a),i=i.sibling}function Mh(i,s,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(c!==4&&(c===27&&Ja(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Mh(i,s,a),i=i.sibling;i!==null;)Mh(i,s,a),i=i.sibling}function D0(i){var s=i.stateNode,a=i.memoizedProps;try{for(var c=i.type,h=s.attributes;h.length;)s.removeAttributeNode(h[0]);Di(s,c,a),s[ke]=i,s[Ve]=a}catch(g){nn(i,i.return,g)}}var Qr=!1,Qn=!1,eg=!1,M0=typeof WeakSet=="function"?WeakSet:Set,gi=null;function bR(i,s){if(i=i.containerInfo,Sg=Qh,i=eu(i),Pl(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,de=0,Se=0,Ee=i,fe=null;t:for(;;){for(var be;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),(be=Ee.firstChild)!==null;)fe=Ee,Ee=be;for(;;){if(Ee===i)break t;if(fe===a&&++de===h&&(D=y),fe===g&&++Se===c&&(U=y),(be=Ee.nextSibling)!==null)break;Ee=fe,fe=Ee.parentNode}Ee=be}a=D===-1||U===-1?null:{start:D,end:U}}else a=null}a=a||{start:0,end:0}}else a=null;for(wg={focusedElem:i,selectionRange:a},Qh=!1,gi=s;gi!==null;)if(s=gi,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,gi=i;else for(;gi!==null;){switch(s=gi,g=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)h=i[a],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&g!==null){i=void 0,a=s,h=g.memoizedProps,g=g.memoizedState,c=a.stateNode;try{var Ze=Qo(a.type,h);i=c.getSnapshotBeforeUpdate(Ze,g),c.__reactInternalSnapshotBeforeUpdate=i}catch(ct){nn(a,a.return,ct)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)kg(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":kg(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,gi=i;break}gi=s.return}}function A0(i,s,a){var c=a.flags;switch(a.tag){case 0:case 11:case 15:ea(i,a),c&4&&Cu(5,a);break;case 1:if(ea(i,a),c&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(y){nn(a,a.return,y)}else{var h=Qo(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(h,s,i.__reactInternalSnapshotBeforeUpdate)}catch(y){nn(a,a.return,y)}}c&64&&T0(a),c&512&&ku(a,a.return);break;case 3:if(ea(i,a),c&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{gS(i,s)}catch(y){nn(a,a.return,y)}}break;case 27:s===null&&c&4&&D0(a);case 26:case 5:ea(i,a),s===null&&c&4&&R0(a),c&512&&ku(a,a.return);break;case 12:ea(i,a);break;case 31:ea(i,a),c&4&&O0(i,a);break;case 13:ea(i,a),c&4&&B0(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||Qr,!c){s=s!==null&&s.memoizedState!==null||Qn,h=Qr;var g=Qn;Qr=c,(Qn=s)&&!g?ta(i,a,(a.subtreeFlags&8772)!==0):ea(i,a),Qr=h,Qn=g}break;case 30:break;default:ea(i,a)}}function L0(i){var s=i.alternate;s!==null&&(i.alternate=null,L0(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&qi(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Sn=null,Xi=!1;function Jr(i,s,a){for(a=a.child;a!==null;)j0(i,s,a),a=a.sibling}function j0(i,s,a){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(kn,a)}catch{}switch(a.tag){case 26:Qn||cr(a,s),Jr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Qn||cr(a,s);var c=Sn,h=Xi;Ja(a.type)&&(Sn=a.stateNode,Xi=!1),Jr(i,s,a),ju(a.stateNode),Sn=c,Xi=h;break;case 5:Qn||cr(a,s);case 6:if(c=Sn,h=Xi,Sn=null,Jr(i,s,a),Sn=c,Xi=h,Sn!==null)if(Xi)try{(Sn.nodeType===9?Sn.body:Sn.nodeName==="HTML"?Sn.ownerDocument.body:Sn).removeChild(a.stateNode)}catch(g){nn(a,s,g)}else try{Sn.removeChild(a.stateNode)}catch(g){nn(a,s,g)}break;case 18:Sn!==null&&(Xi?(i=Sn,Tw(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),fc(i)):Tw(Sn,a.stateNode));break;case 4:c=Sn,h=Xi,Sn=a.stateNode.containerInfo,Xi=!0,Jr(i,s,a),Sn=c,Xi=h;break;case 0:case 11:case 14:case 15:qa(2,a,s),Qn||qa(4,a,s),Jr(i,s,a);break;case 1:Qn||(cr(a,s),c=a.stateNode,typeof c.componentWillUnmount=="function"&&E0(a,s,c)),Jr(i,s,a);break;case 21:Jr(i,s,a);break;case 22:Qn=(c=Qn)||a.memoizedState!==null,Jr(i,s,a),Qn=c;break;default:Jr(i,s,a)}}function O0(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{fc(i)}catch(a){nn(s,s.return,a)}}}function B0(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{fc(i)}catch(a){nn(s,s.return,a)}}function yR(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new M0),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new M0),s;default:throw Error(r(435,i.tag))}}function Ah(i,s){var a=yR(i);s.forEach(function(c){if(!a.has(c)){a.add(c);var h=NR.bind(null,i,c);c.then(h,h)}})}function Zi(i,s){var a=s.deletions;if(a!==null)for(var c=0;c<a.length;c++){var h=a[c],g=i,y=s,D=y;e:for(;D!==null;){switch(D.tag){case 27:if(Ja(D.type)){Sn=D.stateNode,Xi=!1;break e}break;case 5:Sn=D.stateNode,Xi=!1;break e;case 3:case 4:Sn=D.stateNode.containerInfo,Xi=!0;break e}D=D.return}if(Sn===null)throw Error(r(160));j0(g,y,h),Sn=null,Xi=!1,g=h.alternate,g!==null&&(g.return=null),h.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)I0(s,i),s=s.sibling}var qs=null;function I0(i,s){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Zi(s,i),Qi(i),c&4&&(qa(3,i,i.return),Cu(3,i),qa(5,i,i.return));break;case 1:Zi(s,i),Qi(i),c&512&&(Qn||a===null||cr(a,a.return)),c&64&&Qr&&(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=qs;if(Zi(s,i),Qi(i),c&512&&(Qn||a===null||cr(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[Yt]||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"))),Di(g,c,a),g[ke]=i,Ft(g),c=g;break e;case"link":var y=Iw("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),Di(g,c,a),h.head.appendChild(g);break;case"meta":if(y=Iw("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),Di(g,c,a),h.head.appendChild(g);break;default:throw Error(r(468,c))}g[ke]=i,Ft(g),c=g}i.stateNode=c}else Pw(h,i.type,i.stateNode);else i.stateNode=Bw(h,c,i.memoizedProps);else g!==c?(g===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):g.count--,c===null?Pw(h,i.type,i.stateNode):Bw(h,c,i.memoizedProps)):c===null&&i.stateNode!==null&&Zm(i,i.memoizedProps,a.memoizedProps)}break;case 27:Zi(s,i),Qi(i),c&512&&(Qn||a===null||cr(a,a.return)),a!==null&&c&4&&Zm(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Zi(s,i),Qi(i),c&512&&(Qn||a===null||cr(a,a.return)),i.flags&32){h=i.stateNode;try{tr(h,"")}catch(Ze){nn(i,i.return,Ze)}}c&4&&i.stateNode!=null&&(h=i.memoizedProps,Zm(i,h,a!==null?a.memoizedProps:h)),c&1024&&(eg=!0);break;case 6:if(Zi(s,i),Qi(i),c&4){if(i.stateNode===null)throw Error(r(162));c=i.memoizedProps,a=i.stateNode;try{a.nodeValue=c}catch(Ze){nn(i,i.return,Ze)}}break;case 3:if(Yh=null,h=qs,qs=qh(s.containerInfo),Zi(s,i),qs=h,Qi(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{fc(s.containerInfo)}catch(Ze){nn(i,i.return,Ze)}eg&&(eg=!1,P0(i));break;case 4:c=qs,qs=qh(i.stateNode.containerInfo),Zi(s,i),Qi(i),qs=c;break;case 12:Zi(s,i),Qi(i);break;case 31:Zi(s,i),Qi(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Ah(i,c)));break;case 13:Zi(s,i),Qi(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(jh=$e()),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Ah(i,c)));break;case 22:h=i.memoizedState!==null;var U=a!==null&&a.memoizedState!==null,de=Qr,Se=Qn;if(Qr=de||h,Qn=Se||U,Zi(s,i),Qn=Se,Qr=de,Qi(i),c&8192)e:for(s=i.stateNode,s._visibility=h?s._visibility&-2:s._visibility|1,h&&(a===null||U||Qr||Qn||Jo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){U=a=s;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(Ze){nn(U,U.return,Ze)}}}else if(s.tag===6){if(a===null){U=s;try{U.stateNode.nodeValue=h?"":U.memoizedProps}catch(Ze){nn(U,U.return,Ze)}}}else if(s.tag===18){if(a===null){U=s;try{var be=U.stateNode;h?Ew(be,!0):Ew(U.stateNode,!1)}catch(Ze){nn(U,U.return,Ze)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}c&4&&(c=i.updateQueue,c!==null&&(a=c.retryQueue,a!==null&&(c.retryQueue=null,Ah(i,a))));break;case 19:Zi(s,i),Qi(i),c&4&&(c=i.updateQueue,c!==null&&(i.updateQueue=null,Ah(i,c)));break;case 30:break;case 21:break;default:Zi(s,i),Qi(i)}}function Qi(i){var s=i.flags;if(s&2){try{for(var a,c=i.return;c!==null;){if(N0(c)){a=c;break}c=c.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var h=a.stateNode,g=Qm(i);Mh(i,g,h);break;case 5:var y=a.stateNode;a.flags&32&&(tr(y,""),a.flags&=-33);var D=Qm(i);Mh(i,D,y);break;case 3:case 4:var U=a.stateNode.containerInfo,de=Qm(i);Jm(i,de,U);break;default:throw Error(r(161))}}catch(Se){nn(i,i.return,Se)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function P0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;P0(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function ea(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)A0(i,s.alternate,s),s=s.sibling}function Jo(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:qa(4,s,s.return),Jo(s);break;case 1:cr(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&E0(s,s.return,a),Jo(s);break;case 27:ju(s.stateNode);case 26:case 5:cr(s,s.return),Jo(s);break;case 22:s.memoizedState===null&&Jo(s);break;case 30:Jo(s);break;default:Jo(s)}i=i.sibling}}function ta(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var c=s.alternate,h=i,g=s,y=g.flags;switch(g.tag){case 0:case 11:case 15:ta(h,g,a),Cu(4,g);break;case 1:if(ta(h,g,a),c=g,h=c.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(de){nn(c,c.return,de)}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++)mS(U[h],D)}catch(de){nn(c,c.return,de)}}a&&y&64&&T0(g),ku(g,g.return);break;case 27:D0(g);case 26:case 5:ta(h,g,a),a&&c===null&&y&4&&R0(g),ku(g,g.return);break;case 12:ta(h,g,a);break;case 31:ta(h,g,a),a&&y&4&&O0(h,g);break;case 13:ta(h,g,a),a&&y&4&&B0(h,g);break;case 22:g.memoizedState===null&&ta(h,g,a),ku(g,g.return);break;case 30:break;default:ta(h,g,a)}s=s.sibling}}function tg(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&du(a))}function ng(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&du(i))}function Vs(i,s,a,c){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)z0(i,s,a,c),s=s.sibling}function z0(i,s,a,c){var h=s.flags;switch(s.tag){case 0:case 11:case 15:Vs(i,s,a,c),h&2048&&Cu(9,s);break;case 1:Vs(i,s,a,c);break;case 3:Vs(i,s,a,c),h&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&du(i)));break;case 12:if(h&2048){Vs(i,s,a,c),i=s.stateNode;try{var g=s.memoizedProps,y=g.id,D=g.onPostCommit;typeof D=="function"&&D(y,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(U){nn(s,s.return,U)}}else Vs(i,s,a,c);break;case 31:Vs(i,s,a,c);break;case 13:Vs(i,s,a,c);break;case 23:break;case 22:g=s.stateNode,y=s.alternate,s.memoizedState!==null?g._visibility&2?Vs(i,s,a,c):Tu(i,s):g._visibility&2?Vs(i,s,a,c):(g._visibility|=2,nc(i,s,a,c,(s.subtreeFlags&10256)!==0||!1)),h&2048&&tg(y,s);break;case 24:Vs(i,s,a,c),h&2048&&ng(s.alternate,s);break;default:Vs(i,s,a,c)}}function nc(i,s,a,c,h){for(h=h&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var g=i,y=s,D=a,U=c,de=y.flags;switch(y.tag){case 0:case 11:case 15:nc(g,y,D,U,h),Cu(8,y);break;case 23:break;case 22:var Se=y.stateNode;y.memoizedState!==null?Se._visibility&2?nc(g,y,D,U,h):Tu(g,y):(Se._visibility|=2,nc(g,y,D,U,h)),h&&de&2048&&tg(y.alternate,y);break;case 24:nc(g,y,D,U,h),h&&de&2048&&ng(y.alternate,y);break;default:nc(g,y,D,U,h)}s=s.sibling}}function Tu(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,c=s,h=c.flags;switch(c.tag){case 22:Tu(a,c),h&2048&&tg(c.alternate,c);break;case 24:Tu(a,c),h&2048&&ng(c.alternate,c);break;default:Tu(a,c)}s=s.sibling}}var Eu=8192;function ic(i,s,a){if(i.subtreeFlags&Eu)for(i=i.child;i!==null;)H0(i,s,a),i=i.sibling}function H0(i,s,a){switch(i.tag){case 26:ic(i,s,a),i.flags&Eu&&i.memoizedState!==null&&aN(a,qs,i.memoizedState,i.memoizedProps);break;case 5:ic(i,s,a);break;case 3:case 4:var c=qs;qs=qh(i.stateNode.containerInfo),ic(i,s,a),qs=c;break;case 22:i.memoizedState===null&&(c=i.alternate,c!==null&&c.memoizedState!==null?(c=Eu,Eu=16777216,ic(i,s,a),Eu=c):ic(i,s,a));break;default:ic(i,s,a)}}function U0(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Ru(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var c=s[a];gi=c,F0(c,i)}U0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)$0(i),i=i.sibling}function $0(i){switch(i.tag){case 0:case 11:case 15:Ru(i),i.flags&2048&&qa(9,i,i.return);break;case 3:Ru(i);break;case 12:Ru(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,Lh(i)):Ru(i);break;default:Ru(i)}}function Lh(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var c=s[a];gi=c,F0(c,i)}U0(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:qa(8,s,s.return),Lh(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,Lh(s));break;default:Lh(s)}i=i.sibling}}function F0(i,s){for(;gi!==null;){var a=gi;switch(a.tag){case 0:case 11:case 15:qa(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var c=a.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:du(a.memoizedState.cache)}if(c=a.child,c!==null)c.return=a,gi=c;else e:for(a=i;gi!==null;){c=gi;var h=c.sibling,g=c.return;if(L0(c),c===a){gi=null;break e}if(h!==null){h.return=g,gi=h;break e}gi=g}}}var SR={getCacheForType:function(i){var s=Ri(Gn),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return Ri(Gn).controller.signal}},wR=typeof WeakMap=="function"?WeakMap:Map,Xt=0,hn=null,At=null,It=0,tn=0,hs=null,Va=!1,sc=!1,ig=!1,na=0,Ln=0,Ya=0,el=0,sg=0,fs=0,rc=0,Nu=null,Ji=null,rg=!1,jh=0,W0=0,Oh=1/0,Bh=null,Ga=null,si=0,Xa=null,ac=null,ia=0,ag=0,og=null,K0=null,Du=0,lg=null;function ps(){return(Xt&2)!==0&&It!==0?It&-It:M.T!==null?pg():kt()}function q0(){if(fs===0)if((It&536870912)===0||zt){var i=ae;ae<<=1,(ae&3932160)===0&&(ae=262144),fs=i}else fs=536870912;return i=us.current,i!==null&&(i.flags|=32),fs}function es(i,s,a){(i===hn&&(tn===2||tn===9)||i.cancelPendingCommit!==null)&&(oc(i,0),Za(i,It,fs,!1)),Bn(i,a),((Xt&2)===0||i!==hn)&&(i===hn&&((Xt&2)===0&&(el|=a),Ln===4&&Za(i,It,fs,!1)),ur(i))}function V0(i,s,a){if((Xt&6)!==0)throw Error(r(327));var c=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Ut(i,s),h=c?kR(i,s):ug(i,s,!0),g=c;do{if(h===0){sc&&!c&&Za(i,s,0,!1);break}else{if(a=i.current.alternate,g&&!xR(a)){h=ug(i,s,!1),g=!1;continue}if(h===2){if(g=s,i.errorRecoveryDisabledLanes&g)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){s=y;e:{var D=i;h=Nu;var U=D.current.memoizedState.isDehydrated;if(U&&(oc(D,y).flags|=256),y=ug(D,y,!1),y!==2){if(ig&&!U){D.errorRecoveryDisabledLanes|=g,el|=g,h=4;break e}g=Ji,Ji=h,g!==null&&(Ji===null?Ji=g:Ji.push.apply(Ji,g))}h=y}if(g=!1,h!==2)continue}}if(h===1){oc(i,0),Za(i,s,0,!0);break}e:{switch(c=i,g=h,g){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:Za(c,s,fs,!Va);break e;case 2:Ji=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(h=jh+300-$e(),10<h)){if(Za(c,s,fs,!Va),St(c,0,!0)!==0)break e;ia=s,c.timeoutHandle=Cw(Y0.bind(null,c,a,Ji,Bh,rg,s,fs,el,rc,Va,g,"Throttled",-0,0),h);break e}Y0(c,a,Ji,Bh,rg,s,fs,el,rc,Va,g,null,-0,0)}}break}while(!0);ur(i)}function Y0(i,s,a,c,h,g,y,D,U,de,Se,Ee,fe,be){if(i.timeoutHandle=-1,Ee=s.subtreeFlags,Ee&8192||(Ee&16785408)===16785408){Ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ji},H0(s,g,Ee);var Ze=(g&62914560)===g?jh-$e():(g&4194048)===g?W0-$e():0;if(Ze=oN(Ee,Ze),Ze!==null){ia=g,i.cancelPendingCommit=Ze(nw.bind(null,i,s,g,a,c,h,y,D,U,Se,Ee,null,fe,be)),Za(i,g,y,!de);return}}nw(i,s,g,a,c,h,y,D,U)}function xR(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var c=0;c<a.length;c++){var h=a[c],g=h.getSnapshot;h=h.value;try{if(!Hi(g(),h))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Za(i,s,a,c){s&=~sg,s&=~el,i.suspendedLanes|=s,i.pingedLanes&=~s,c&&(i.warmLanes|=s),c=i.expirationTimes;for(var h=s;0<h;){var g=31-Nt(h),y=1<<g;c[g]=-1,h&=~y}a!==0&&Kn(i,a,s)}function Ih(){return(Xt&6)===0?(Mu(0),!1):!0}function cg(){if(At!==null){if(tn===0)var i=At.return;else i=At,qr=Ko=null,km(i),Zl=null,fu=0,i=At;for(;i!==null;)k0(i.alternate,i),i=i.return;At=null}}function oc(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,FR(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),ia=0,cg(),hn=i,At=a=Ks(i.current,null),It=s,tn=0,hs=null,Va=!1,sc=Ut(i,s),ig=!1,rc=fs=sg=el=Ya=Ln=0,Ji=Nu=null,rg=!1,(s&8)!==0&&(s|=s&32);var c=i.entangledLanes;if(c!==0)for(i=i.entanglements,c&=s;0<c;){var h=31-Nt(c),g=1<<h;s|=i[h],c&=~g}return na=s,Fl(),a}function G0(i,s){xt=null,M.H=Su,s===Xl||s===hh?(s=dS(),tn=3):s===fm?(s=dS(),tn=4):tn=s===Um?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,hs=s,At===null&&(Ln=1,Th(i,st(s,i.current)))}function X0(){var i=us.current;return i===null?!0:(It&4194048)===It?Es===null:(It&62914560)===It||(It&536870912)!==0?i===Es:!1}function Z0(){var i=M.H;return M.H=Su,i===null?Su:i}function Q0(){var i=M.A;return M.A=SR,i}function Ph(){Ln=4,Va||(It&4194048)!==It&&us.current!==null||(sc=!0),(Ya&134217727)===0&&(el&134217727)===0||hn===null||Za(hn,It,fs,!1)}function ug(i,s,a){var c=Xt;Xt|=2;var h=Z0(),g=Q0();(hn!==i||It!==s)&&(Bh=null,oc(i,s)),s=!1;var y=Ln;e:do try{if(tn!==0&&At!==null){var D=At,U=hs;switch(tn){case 8:cg(),y=6;break e;case 3:case 2:case 9:case 6:us.current===null&&(s=!0);var de=tn;if(tn=0,hs=null,lc(i,D,U,de),a&&sc){y=0;break e}break;default:de=tn,tn=0,hs=null,lc(i,D,U,de)}}CR(),y=Ln;break}catch(Se){G0(i,Se)}while(!0);return s&&i.shellSuspendCounter++,qr=Ko=null,Xt=c,M.H=h,M.A=g,At===null&&(hn=null,It=0,Fl()),y}function CR(){for(;At!==null;)J0(At)}function kR(i,s){var a=Xt;Xt|=2;var c=Z0(),h=Q0();hn!==i||It!==s?(Bh=null,Oh=$e()+500,oc(i,s)):sc=Ut(i,s);e:do try{if(tn!==0&&At!==null){s=At;var g=hs;t:switch(tn){case 1:tn=0,hs=null,lc(i,s,g,1);break;case 2:case 9:if(cS(g)){tn=0,hs=null,ew(s);break}s=function(){tn!==2&&tn!==9||hn!==i||(tn=7),ur(i)},g.then(s,s);break e;case 3:tn=7;break e;case 4:tn=5;break e;case 7:cS(g)?(tn=0,hs=null,ew(s)):(tn=0,hs=null,lc(i,s,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?zw(y):D.stateNode.complete){tn=0,hs=null;var U=D.sibling;if(U!==null)At=U;else{var de=D.return;de!==null?(At=de,zh(de)):At=null}break t}}tn=0,hs=null,lc(i,s,g,5);break;case 6:tn=0,hs=null,lc(i,s,g,6);break;case 8:cg(),Ln=6;break e;default:throw Error(r(462))}}TR();break}catch(Se){G0(i,Se)}while(!0);return qr=Ko=null,M.H=c,M.A=h,Xt=a,At!==null?0:(hn=null,It=0,Fl(),Ln)}function TR(){for(;At!==null&&!ve();)J0(At)}function J0(i){var s=x0(i.alternate,i,na);i.memoizedProps=i.pendingProps,s===null?zh(i):At=s}function ew(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=v0(a,s,s.pendingProps,s.type,void 0,It);break;case 11:s=v0(a,s,s.pendingProps,s.type.render,s.ref,It);break;case 5:km(s);default:k0(a,s),s=At=lh(s,na),s=x0(a,s,na)}i.memoizedProps=i.pendingProps,s===null?zh(i):At=s}function lc(i,s,a,c){qr=Ko=null,km(s),Zl=null,fu=0;var h=s.return;try{if(pR(i,h,s,a,It)){Ln=1,Th(i,st(a,i.current)),At=null;return}}catch(g){if(h!==null)throw At=h,g;Ln=1,Th(i,st(a,i.current)),At=null;return}s.flags&32768?(zt||c===1?i=!0:sc||(It&536870912)!==0?i=!1:(Va=i=!0,(c===2||c===9||c===3||c===6)&&(c=us.current,c!==null&&c.tag===13&&(c.flags|=16384))),tw(s,i)):zh(s)}function zh(i){var s=i;do{if((s.flags&32768)!==0){tw(s,Va);return}i=s.return;var a=vR(s.alternate,s,na);if(a!==null){At=a;return}if(s=s.sibling,s!==null){At=s;return}At=s=i}while(s!==null);Ln===0&&(Ln=5)}function tw(i,s){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),!s&&(i=i.sibling,i!==null)){At=i;return}At=i=a}while(i!==null);Ln=6,At=null}function nw(i,s,a,c,h,g,y,D,U){i.cancelPendingCommit=null;do Hh();while(si!==0);if((Xt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(g=s.lanes|s.childLanes,g|=$l,Vt(i,a,g,y,D,U),i===hn&&(At=hn=null,It=0),ac=s,Xa=i,ia=a,ag=g,og=h,K0=c,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,DR(vt,function(){return ow(),null})):(i.callbackNode=null,i.callbackPriority=0),c=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||c){c=M.T,M.T=null,h=R.p,R.p=2,y=Xt,Xt|=4;try{bR(i,s,a)}finally{Xt=y,R.p=h,M.T=c}}si=1,iw(),sw(),rw()}}function iw(){if(si===1){si=0;var i=Xa,s=ac,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=M.T,M.T=null;var c=R.p;R.p=2;var h=Xt;Xt|=4;try{I0(s,i);var g=wg,y=eu(i.containerInfo),D=g.focusedElem,U=g.selectionRange;if(y!==D&&D&&D.ownerDocument&&Uo(D.ownerDocument.documentElement,D)){if(U!==null&&Pl(D)){var de=U.start,Se=U.end;if(Se===void 0&&(Se=de),"selectionStart"in D)D.selectionStart=de,D.selectionEnd=Math.min(Se,D.value.length);else{var Ee=D.ownerDocument||document,fe=Ee&&Ee.defaultView||window;if(fe.getSelection){var be=fe.getSelection(),Ze=D.textContent.length,ct=Math.min(U.start,Ze),on=U.end===void 0?ct:Math.min(U.end,Ze);!be.extend&&ct>on&&(y=on,on=ct,ct=y);var ne=Il(D,ct),G=Il(D,on);if(ne&&G&&(be.rangeCount!==1||be.anchorNode!==ne.node||be.anchorOffset!==ne.offset||be.focusNode!==G.node||be.focusOffset!==G.offset)){var ue=Ee.createRange();ue.setStart(ne.node,ne.offset),be.removeAllRanges(),ct>on?(be.addRange(ue),be.extend(G.node,G.offset)):(ue.setEnd(G.node,G.offset),be.addRange(ue))}}}}for(Ee=[],be=D;be=be.parentNode;)be.nodeType===1&&Ee.push({element:be,left:be.scrollLeft,top:be.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<Ee.length;D++){var xe=Ee[D];xe.element.scrollLeft=xe.left,xe.element.scrollTop=xe.top}}Qh=!!Sg,wg=Sg=null}finally{Xt=h,R.p=c,M.T=a}}i.current=s,si=2}}function sw(){if(si===2){si=0;var i=Xa,s=ac,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=M.T,M.T=null;var c=R.p;R.p=2;var h=Xt;Xt|=4;try{A0(i,s.alternate,s)}finally{Xt=h,R.p=c,M.T=a}}si=3}}function rw(){if(si===4||si===3){si=0,Pe();var i=Xa,s=ac,a=ia,c=K0;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?si=5:(si=0,ac=Xa=null,aw(i,i.pendingLanes));var h=i.pendingLanes;if(h===0&&(Ga=null),lt(a),s=s.stateNode,_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(kn,s,void 0,(s.current.flags&128)===128)}catch{}if(c!==null){s=M.T,h=R.p,R.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=s,R.p=h}}(ia&3)!==0&&Hh(),ur(i),h=i.pendingLanes,(a&261930)!==0&&(h&42)!==0?i===lg?Du++:(Du=0,lg=i):Du=0,Mu(0)}}function aw(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,du(s)))}function Hh(){return iw(),sw(),rw(),ow()}function ow(){if(si!==5)return!1;var i=Xa,s=ag;ag=0;var a=lt(ia),c=M.T,h=R.p;try{R.p=32>a?32:a,M.T=null,a=og,og=null;var g=Xa,y=ia;if(si=0,ac=Xa=null,ia=0,(Xt&6)!==0)throw Error(r(331));var D=Xt;if(Xt|=4,$0(g.current),z0(g,g.current,y,a),Xt=D,Mu(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(kn,g)}catch{}return!0}finally{R.p=h,M.T=c,aw(i,s)}}function lw(i,s,a){s=st(a,s),s=Hm(i.stateNode,s,2),i=Fa(i,s,2),i!==null&&(Bn(i,2),ur(i))}function nn(i,s,a){if(i.tag===3)lw(i,i,a);else for(;s!==null;){if(s.tag===3){lw(s,i,a);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ga===null||!Ga.has(c))){i=st(a,i),a=c0(2),c=Fa(s,a,2),c!==null&&(u0(a,c,s,i),Bn(c,2),ur(c));break}}s=s.return}}function dg(i,s,a){var c=i.pingCache;if(c===null){c=i.pingCache=new wR;var h=new Set;c.set(s,h)}else h=c.get(s),h===void 0&&(h=new Set,c.set(s,h));h.has(a)||(ig=!0,h.add(a),i=ER.bind(null,i,s,a),s.then(i,i))}function ER(i,s,a){var c=i.pingCache;c!==null&&c.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,hn===i&&(It&a)===a&&(Ln===4||Ln===3&&(It&62914560)===It&&300>$e()-jh?(Xt&2)===0&&oc(i,0):sg|=a,rc===It&&(rc=0)),ur(i)}function cw(i,s){s===0&&(s=Wt()),i=Kr(i,s),i!==null&&(Bn(i,s),ur(i))}function RR(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),cw(i,a)}function NR(i,s){var a=0;switch(i.tag){case 31:case 13:var c=i.stateNode,h=i.memoizedState;h!==null&&(a=h.retryLane);break;case 19:c=i.stateNode;break;case 22:c=i.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(s),cw(i,a)}function DR(i,s){return Ne(i,s)}var Uh=null,cc=null,hg=!1,$h=!1,fg=!1,Qa=0;function ur(i){i!==cc&&i.next===null&&(cc===null?Uh=cc=i:cc=cc.next=i),$h=!0,hg||(hg=!0,AR())}function Mu(i,s){if(!fg&&$h){fg=!0;do for(var a=!1,c=Uh;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,fw(c,g))}else g=It,g=St(c,c===hn?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||Ut(c,g)||(a=!0,fw(c,g));c=c.next}while(a);fg=!1}}function MR(){uw()}function uw(){$h=hg=!1;var i=0;Qa!==0&&$R()&&(i=Qa);for(var s=$e(),a=null,c=Uh;c!==null;){var h=c.next,g=dw(c,s);g===0?(c.next=null,a===null?Uh=h:a.next=h,h===null&&(cc=a)):(a=c,(i!==0||(g&3)!==0)&&($h=!0)),c=h}si!==0&&si!==5||Mu(i),Qa!==0&&(Qa=0)}function dw(i,s){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]=$t(D,s)):U<=s&&(i.expiredLanes|=D),g&=~D}if(s=hn,a=It,a=St(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c=i.callbackNode,a===0||i===s&&(tn===2||tn===9)||i.cancelPendingCommit!==null)return c!==null&&c!==null&&Le(c),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Ut(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(c!==null&&Le(c),lt(a)){case 2:case 8:a=ht;break;case 32:a=vt;break;case 268435456:a=cn;break;default:a=vt}return c=hw.bind(null,i),a=Ne(a,c),i.callbackPriority=s,i.callbackNode=a,s}return c!==null&&c!==null&&Le(c),i.callbackPriority=2,i.callbackNode=null,2}function hw(i,s){if(si!==0&&si!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Hh()&&i.callbackNode!==a)return null;var c=It;return c=St(i,i===hn?c:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),c===0?null:(V0(i,c,s),dw(i,$e()),i.callbackNode!=null&&i.callbackNode===a?hw.bind(null,i):null)}function fw(i,s){if(Hh())return null;V0(i,s,!0)}function AR(){WR(function(){(Xt&6)!==0?Ne(ut,MR):uw()})}function pg(){if(Qa===0){var i=Yl;i===0&&(i=mn,mn<<=1,(mn&261888)===0&&(mn=256)),Qa=i}return Qa}function pw(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Ps(""+i)}function mw(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function LR(i,s,a,c,h){if(s==="submit"&&a&&a.stateNode===h){var g=pw((h[Ve]||null).action),y=c.submitter;y&&(s=(s=y[Ve]||null)?pw(s.formAction):y.getAttribute("formAction"),s!==null&&(g=s,y=null));var D=new ft("action","action",null,c,h);i.push({event:D,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Qa!==0){var U=y?mw(h,y):new FormData(h);jm(a,{pending:!0,data:U,method:h.method,action:g},null,U)}}else typeof g=="function"&&(D.preventDefault(),U=y?mw(h,y):new FormData(h),jm(a,{pending:!0,data:U,method:h.method,action:g},g,U))},currentTarget:h}]})}}for(var mg=0;mg<Hl.length;mg++){var gg=Hl[mg],jR=gg.toLowerCase(),OR=gg[0].toUpperCase()+gg.slice(1);cs(jR,"on"+OR)}cs(su,"onAnimationEnd"),cs(ru,"onAnimationIteration"),cs(au,"onAnimationStart"),cs("dblclick","onDoubleClick"),cs("focusin","onFocus"),cs("focusout","onBlur"),cs(nm,"onTransitionRun"),cs(rh,"onTransitionStart"),cs(or,"onTransitionCancel"),cs(ah,"onTransitionEnd"),zi("onMouseEnter",["mouseout","mouseover"]),zi("onMouseLeave",["mouseout","mouseover"]),zi("onPointerEnter",["pointerout","pointerover"]),zi("onPointerLeave",["pointerout","pointerover"]),Ai("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ai("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ai("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ai("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ai("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ai("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Au="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(Au));function gw(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var c=i[a],h=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var y=c.length-1;0<=y;y--){var D=c[y],U=D.instance,de=D.currentTarget;if(D=D.listener,U!==g&&h.isPropagationStopped())break e;g=D,h.currentTarget=de;try{g(h)}catch(Se){Ul(Se)}h.currentTarget=null,g=U}else for(y=0;y<c.length;y++){if(D=c[y],U=D.instance,de=D.currentTarget,D=D.listener,U!==g&&h.isPropagationStopped())break e;g=D,h.currentTarget=de;try{g(h)}catch(Se){Ul(Se)}h.currentTarget=null,g=U}}}}function Lt(i,s){var a=s[tt];a===void 0&&(a=s[tt]=new Set);var c=i+"__bubble";a.has(c)||(vw(s,i,2,!1),a.add(c))}function vg(i,s,a){var c=0;s&&(c|=4),vw(a,i,c,s)}var Fh="_reactListening"+Math.random().toString(36).slice(2);function _g(i){if(!i[Fh]){i[Fh]=!0,wr.forEach(function(a){a!=="selectionchange"&&(BR.has(a)||vg(a,!1,i),vg(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[Fh]||(s[Fh]=!0,vg("selectionchange",!1,s))}}function vw(i,s,a,c){switch(qw(s)){case 2:var h=uN;break;case 8:h=dN;break;default:h=Lg}a=h.bind(null,s,a,i),h=void 0,!zs||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),c?h!==void 0?i.addEventListener(s,a,{capture:!0,passive:h}):i.addEventListener(s,a,!0):h!==void 0?i.addEventListener(s,a,{passive:h}):i.addEventListener(s,a,!1)}function bg(i,s,a,c,h){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var y=c.tag;if(y===3||y===4){var D=c.stateNode.containerInfo;if(D===h)break;if(y===4)for(y=c.return;y!==null;){var U=y.tag;if((U===3||U===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;D!==null;){if(y=Yn(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}Ra(function(){var de=g,Se=ws(a),Ee=[];e:{var fe=oh.get(i);if(fe!==void 0){var be=ft,Ze=i;switch(i){case"keypress":if(as(a)===0)break e;case"keydown":case"keyup":be=Ml;break;case"focusin":Ze="focus",be=Aa;break;case"focusout":Ze="blur",be=Aa;break;case"beforeblur":case"afterblur":be=Aa;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":be=rr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":be=hi;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":be=zo;break;case su:case ru:case au:be=Rl;break;case ah:be=ja;break;case"scroll":case"scrollend":be=Da;break;case"wheel":be=Xc;break;case"copy":case"cut":case"paste":be=Lr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":be=Ir;break;case"toggle":case"beforetoggle":be=zr}var ct=(s&4)!==0,on=!ct&&(i==="scroll"||i==="scrollend"),ne=ct?fe!==null?fe+"Capture":null:fe;ct=[];for(var G=de,ue;G!==null;){var xe=G;if(ue=xe.stateNode,xe=xe.tag,xe!==5&&xe!==26&&xe!==27||ue===null||ne===null||(xe=rs(G,ne),xe!=null&&ct.push(Lu(G,xe,ue))),on)break;G=G.return}0<ct.length&&(fe=new be(fe,Ze,null,a,Se),Ee.push({event:fe,listeners:ct}))}}if((s&7)===0){e:{if(fe=i==="mouseover"||i==="pointerover",be=i==="mouseout"||i==="pointerout",fe&&a!==Oi&&(Ze=a.relatedTarget||a.fromElement)&&(Yn(Ze)||Ze[Xe]))break e;if((be||fe)&&(fe=Se.window===Se?Se:(fe=Se.ownerDocument)?fe.defaultView||fe.parentWindow:window,be?(Ze=a.relatedTarget||a.toElement,be=de,Ze=Ze?Yn(Ze):null,Ze!==null&&(on=l(Ze),ct=Ze.tag,Ze!==on||ct!==5&&ct!==27&&ct!==6)&&(Ze=null)):(be=null,Ze=de),be!==Ze)){if(ct=rr,xe="onMouseLeave",ne="onMouseEnter",G="mouse",(i==="pointerout"||i==="pointerover")&&(ct=Ir,xe="onPointerLeave",ne="onPointerEnter",G="pointer"),on=be==null?fe:is(be),ue=Ze==null?fe:is(Ze),fe=new ct(xe,G+"leave",be,a,Se),fe.target=on,fe.relatedTarget=ue,xe=null,Yn(Se)===de&&(ct=new ct(ne,G+"enter",Ze,a,Se),ct.target=ue,ct.relatedTarget=on,xe=ct),on=xe,be&&Ze)t:{for(ct=IR,ne=be,G=Ze,ue=0,xe=ne;xe;xe=ct(xe))ue++;xe=0;for(var rt=G;rt;rt=ct(rt))xe++;for(;0<ue-xe;)ne=ct(ne),ue--;for(;0<xe-ue;)G=ct(G),xe--;for(;ue--;){if(ne===G||G!==null&&ne===G.alternate){ct=ne;break t}ne=ct(ne),G=ct(G)}ct=null}else ct=null;be!==null&&_w(Ee,fe,be,ct,!1),Ze!==null&&on!==null&&_w(Ee,on,Ze,ct,!0)}}e:{if(fe=de?is(de):window,be=fe.nodeName&&fe.nodeName.toLowerCase(),be==="select"||be==="input"&&fe.type==="file")var Kt=pi;else if(pt(fe))if(nh)Kt=em;else{Kt=Jc;var Je=Ur}else be=fe.nodeName,!be||be.toLowerCase()!=="input"||fe.type!=="checkbox"&&fe.type!=="radio"?de&&Ta(de.elementType)&&(Kt=pi):Kt=Jp;if(Kt&&(Kt=Kt(i,de))){gn(Ee,Kt,a,Se);break e}Je&&Je(i,fe,de),i==="focusout"&&de&&fe.type==="number"&&de.memoizedProps.value!=null&&ki(fe,"number",fe.value)}switch(Je=de?is(de):window,i){case"focusin":(pt(Je)||Je.contentEditable==="true")&&(Fr=Je,tu=de,$o=null);break;case"focusout":$o=tu=Fr=null;break;case"mousedown":nu=!0;break;case"contextmenu":case"mouseup":case"dragend":nu=!1,Oa(Ee,a,Se);break;case"selectionchange":if(tm)break;case"keydown":case"keyup":Oa(Ee,a,Se)}var Ct;if(Ho)e:{switch(i){case"compositionstart":var Pt="onCompositionStart";break e;case"compositionend":Pt="onCompositionEnd";break e;case"compositionupdate":Pt="onCompositionUpdate";break e}Pt=void 0}else we?se(i,a)&&(Pt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Pt="onCompositionStart");Pt&&(T&&a.locale!=="ko"&&(we||Pt!=="onCompositionStart"?Pt==="onCompositionEnd"&&we&&(Ct=El()):(Yi=Se,Na="value"in Yi?Yi.value:Yi.textContent,we=!0)),Je=Wh(de,Pt),0<Je.length&&(Pt=new fi(Pt,i,null,a,Se),Ee.push({event:Pt,listeners:Je}),Ct?Pt.data=Ct:(Ct=le(a),Ct!==null&&(Pt.data=Ct)))),(Ct=C?Ae(i,a):qe(i,a))&&(Pt=Wh(de,"onBeforeInput"),0<Pt.length&&(Je=new fi("onBeforeInput","beforeinput",null,a,Se),Ee.push({event:Je,listeners:Pt}),Je.data=Ct)),LR(Ee,i,de,a,Se)}gw(Ee,s)})}function Lu(i,s,a){return{instance:i,listener:s,currentTarget:a}}function Wh(i,s){for(var a=s+"Capture",c=[];i!==null;){var h=i,g=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||g===null||(h=rs(i,a),h!=null&&c.unshift(Lu(i,h,g)),h=rs(i,s),h!=null&&c.push(Lu(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 _w(i,s,a,c,h){for(var g=s._reactName,y=[];a!==null&&a!==c;){var D=a,U=D.alternate,de=D.stateNode;if(D=D.tag,U!==null&&U===c)break;D!==5&&D!==26&&D!==27||de===null||(U=de,h?(de=rs(a,g),de!=null&&y.unshift(Lu(a,de,U))):h||(de=rs(a,g),de!=null&&y.push(Lu(a,de,U)))),a=a.return}y.length!==0&&i.push({event:s,listeners:y})}var PR=/\r\n?/g,zR=/\u0000|\uFFFD/g;function bw(i){return(typeof i=="string"?i:""+i).replace(PR,`
|
|
10
|
+
`).replace(zR,"")}function yw(i,s){return s=bw(s),bw(i)===s}function an(i,s,a,c,h,g){switch(a){case"children":typeof c=="string"?s==="body"||s==="textarea"&&c===""||tr(i,c):(typeof c=="number"||typeof c=="bigint")&&s!=="body"&&tr(i,""+c);break;case"className":Ss(i,"class",c);break;case"tabIndex":Ss(i,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Ss(i,a,c);break;case"style":jo(i,c,g);break;case"data":if(s!=="object"){Ss(i,"data",c);break}case"src":case"href":if(c===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){i.removeAttribute(a);break}c=Ps(""+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"?(s!=="input"&&an(i,s,"name",h.name,h,null),an(i,s,"formEncType",h.formEncType,h,null),an(i,s,"formMethod",h.formMethod,h,null),an(i,s,"formTarget",h.formTarget,h,null)):(an(i,s,"encType",h.encType,h,null),an(i,s,"method",h.method,h,null),an(i,s,"target",h.target,h,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){i.removeAttribute(a);break}c=Ps(""+c),i.setAttribute(a,c);break;case"onClick":c!=null&&(i.onclick=ji);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(r(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":i.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){i.removeAttribute("xlink:href");break}a=Ps(""+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),kr(i,"popover",c);break;case"xlinkActuate":Ci(i,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Ci(i,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Ci(i,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Ci(i,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Ci(i,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Ci(i,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Ci(i,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Ci(i,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Ci(i,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":kr(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=Ea.get(a)||a,kr(i,a,c))}}function yg(i,s,a,c,h,g){switch(a){case"style":jo(i,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(a=c.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof c=="string"?tr(i,c):(typeof c=="number"||typeof c=="bigint")&&tr(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=ji);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ys.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),s=a.slice(2,h?a.length-7:void 0),g=i[Ve]||null,g=g!=null?g[a]:null,typeof g=="function"&&i.removeEventListener(s,g,h),typeof c=="function")){typeof g!="function"&&g!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,c,h);break e}a in i?i[a]=c:c===!0?i.setAttribute(a,""):kr(i,a,c)}}}function Di(i,s,a){switch(s){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(r(137,s));default:an(i,s,g,y,a,null)}}h&&an(i,s,"srcSet",a.srcSet,a,null),c&&an(i,s,"src",a.src,a,null);return;case"input":Lt("invalid",i);var D=g=y=h=null,U=null,de=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":de=Se;break;case"value":g=Se;break;case"defaultValue":D=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(r(137,s));break;default:an(i,s,c,Se,a,null)}}Tl(i,g,D,U,de,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:an(i,s,h,D,a,null)}s=g,a=y,i.multiple=!!c,s!=null?er(i,!!c,s,!1):a!=null&&er(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(r(91));break;default:an(i,s,y,D,a,null)}Lo(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":an(i,s,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<Au.length;c++)Lt(Au[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(de in a)if(a.hasOwnProperty(de)&&(c=a[de],c!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:an(i,s,de,c,a,null)}return;default:if(Ta(s)){for(Se in a)a.hasOwnProperty(Se)&&(c=a[Se],c!==void 0&&yg(i,s,Se,c,a,void 0));return}}for(D in a)a.hasOwnProperty(D)&&(c=a[D],c!=null&&an(i,s,D,c,a,null))}function HR(i,s,a,c){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,g=null,y=null,D=null,U=null,de=null,Se=null;for(be in a){var Ee=a[be];if(a.hasOwnProperty(be)&&Ee!=null)switch(be){case"checked":break;case"value":break;case"defaultValue":U=Ee;default:c.hasOwnProperty(be)||an(i,s,be,null,c,Ee)}}for(var fe in c){var be=c[fe];if(Ee=a[fe],c.hasOwnProperty(fe)&&(be!=null||Ee!=null))switch(fe){case"type":g=be;break;case"name":h=be;break;case"checked":de=be;break;case"defaultChecked":Se=be;break;case"value":y=be;break;case"defaultValue":D=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(r(137,s));break;default:be!==Ee&&an(i,s,fe,be,c,Ee)}}Nr(i,y,D,U,de,Se,g,h);return;case"select":be=y=D=fe=null;for(g in a)if(U=a[g],a.hasOwnProperty(g)&&U!=null)switch(g){case"value":break;case"multiple":be=U;default:c.hasOwnProperty(g)||an(i,s,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&&an(i,s,h,g,c,U)}s=D,a=y,c=be,fe!=null?er(i,!!a,fe,!1):!!c!=!!a&&(s!=null?er(i,!!a,s,!0):er(i,!!a,a?[]:"",!1));return;case"textarea":be=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:an(i,s,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":be=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(91));break;default:h!==g&&an(i,s,y,h,c,g)}Ca(i,fe,be);return;case"option":for(var Ze in a)fe=a[Ze],a.hasOwnProperty(Ze)&&fe!=null&&!c.hasOwnProperty(Ze)&&(Ze==="selected"?i.selected=!1:an(i,s,Ze,null,c,fe));for(U in c)fe=c[U],be=a[U],c.hasOwnProperty(U)&&fe!==be&&(fe!=null||be!=null)&&(U==="selected"?i.selected=fe&&typeof fe!="function"&&typeof fe!="symbol":an(i,s,U,fe,c,be));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ct in a)fe=a[ct],a.hasOwnProperty(ct)&&fe!=null&&!c.hasOwnProperty(ct)&&an(i,s,ct,null,c,fe);for(de in c)if(fe=c[de],be=a[de],c.hasOwnProperty(de)&&fe!==be&&(fe!=null||be!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,s));break;default:an(i,s,de,fe,c,be)}return;default:if(Ta(s)){for(var on in a)fe=a[on],a.hasOwnProperty(on)&&fe!==void 0&&!c.hasOwnProperty(on)&&yg(i,s,on,void 0,c,fe);for(Se in c)fe=c[Se],be=a[Se],!c.hasOwnProperty(Se)||fe===be||fe===void 0&&be===void 0||yg(i,s,Se,fe,c,be);return}}for(var ne in a)fe=a[ne],a.hasOwnProperty(ne)&&fe!=null&&!c.hasOwnProperty(ne)&&an(i,s,ne,null,c,fe);for(Ee in c)fe=c[Ee],be=a[Ee],!c.hasOwnProperty(Ee)||fe===be||fe==null&&be==null||an(i,s,Ee,fe,c,be)}function Sw(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,s=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&&Sw(y)){for(y=0,D=h.responseEnd,c+=1;c<a.length;c++){var U=a[c],de=U.startTime;if(de>D)break;var Se=U.transferSize,Ee=U.initiatorType;Se&&Sw(Ee)&&(U=U.responseEnd,y+=Se*(U<D?1:(D-de)/(U-de)))}if(--c,s+=8*(g+y)/(h.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Sg=null,wg=null;function Kh(i){return i.nodeType===9?i:i.ownerDocument}function ww(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 xw(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function xg(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Cg=null;function $R(){var i=window.event;return i&&i.type==="popstate"?i===Cg?!1:(Cg=i,!0):(Cg=null,!1)}var Cw=typeof setTimeout=="function"?setTimeout:void 0,FR=typeof clearTimeout=="function"?clearTimeout:void 0,kw=typeof Promise=="function"?Promise:void 0,WR=typeof queueMicrotask=="function"?queueMicrotask:typeof kw<"u"?function(i){return kw.resolve(null).then(i).catch(KR)}:Cw;function KR(i){setTimeout(function(){throw i})}function Ja(i){return i==="head"}function Tw(i,s){var a=s,c=0;do{var h=a.nextSibling;if(i.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"||a==="/&"){if(c===0){i.removeChild(h),fc(s);return}c--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")c++;else if(a==="html")ju(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,ju(a);for(var g=a.firstChild;g;){var y=g.nextSibling,D=g.nodeName;g[Yt]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&g.rel.toLowerCase()==="stylesheet"||a.removeChild(g),g=y}}else a==="body"&&ju(i.ownerDocument.body);a=h}while(a);fc(s)}function Ew(i,s){var a=i;i=0;do{var c=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),c&&c.nodeType===8)if(a=c.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=c}while(a)}function kg(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":kg(a),qi(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function qR(i,s,a,c){for(;i.nodeType===1;){var h=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!c&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(c){if(!i[Yt])switch(s){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(s==="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=Rs(i.nextSibling),i===null)break}return null}function VR(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Rs(i.nextSibling),i===null))return null;return i}function Rw(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=Rs(i.nextSibling),i===null))return null;return i}function Tg(i){return i.data==="$?"||i.data==="$~"}function Eg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function YR(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var c=function(){s(),a.removeEventListener("DOMContentLoaded",c)};a.addEventListener("DOMContentLoaded",c),i._reactRetry=c}}function Rs(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var Rg=null;function Nw(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return Rs(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function Dw(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function Mw(i,s,a){switch(s=Kh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function ju(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);qi(i)}var Ns=new Map,Aw=new Set;function qh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var sa=R.d;R.d={f:GR,r:XR,D:ZR,C:QR,L:JR,m:eN,X:nN,S:tN,M:iN};function GR(){var i=sa.f(),s=Ih();return i||s}function XR(i){var s=ti(i);s!==null&&s.tag===5&&s.type==="form"?GS(s):sa.r(i)}var uc=typeof document>"u"?null:document;function Lw(i,s,a){var c=uc;if(c&&typeof s=="string"&&s){var h=Li(s);h='link[rel="'+i+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),Aw.has(h)||(Aw.add(h),i={rel:i,crossOrigin:a,href:s},c.querySelector(h)===null&&(s=c.createElement("link"),Di(s,"link",i),Ft(s),c.head.appendChild(s)))}}function ZR(i){sa.D(i),Lw("dns-prefetch",i,null)}function QR(i,s){sa.C(i,s),Lw("preconnect",i,s)}function JR(i,s,a){sa.L(i,s,a);var c=uc;if(c&&i&&s){var h='link[rel="preload"][as="'+Li(s)+'"]';s==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+Li(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+Li(a.imageSizes)+'"]')):h+='[href="'+Li(i)+'"]';var g=h;switch(s){case"style":g=dc(i);break;case"script":g=hc(i)}Ns.has(g)||(i=_({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),Ns.set(g,i),c.querySelector(h)!==null||s==="style"&&c.querySelector(Ou(g))||s==="script"&&c.querySelector(Bu(g))||(s=c.createElement("link"),Di(s,"link",i),Ft(s),c.head.appendChild(s)))}}function eN(i,s){sa.m(i,s);var a=uc;if(a&&i){var c=s&&typeof s.as=="string"?s.as:"script",h='link[rel="modulepreload"][as="'+Li(c)+'"][href="'+Li(i)+'"]',g=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=hc(i)}if(!Ns.has(g)&&(i=_({rel:"modulepreload",href:i},s),Ns.set(g,i),a.querySelector(h)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Bu(g)))return}c=a.createElement("link"),Di(c,"link",i),Ft(c),a.head.appendChild(c)}}}function tN(i,s,a){sa.S(i,s,a);var c=uc;if(c&&i){var h=In(c).hoistableStyles,g=dc(i);s=s||"default";var y=h.get(g);if(!y){var D={loading:0,preload:null};if(y=c.querySelector(Ou(g)))D.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":s},a),(a=Ns.get(g))&&Ng(i,a);var U=y=c.createElement("link");Ft(U),Di(U,"link",i),U._p=new Promise(function(de,Se){U.onload=de,U.onerror=Se}),U.addEventListener("load",function(){D.loading|=1}),U.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Vh(y,s,c)}y={type:"stylesheet",instance:y,count:1,state:D},h.set(g,y)}}}function nN(i,s){sa.X(i,s);var a=uc;if(a&&i){var c=In(a).hoistableScripts,h=hc(i),g=c.get(h);g||(g=a.querySelector(Bu(h)),g||(i=_({src:i,async:!0},s),(s=Ns.get(h))&&Dg(i,s),g=a.createElement("script"),Ft(g),Di(g,"link",i),a.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function iN(i,s){sa.M(i,s);var a=uc;if(a&&i){var c=In(a).hoistableScripts,h=hc(i),g=c.get(h);g||(g=a.querySelector(Bu(h)),g||(i=_({src:i,async:!0,type:"module"},s),(s=Ns.get(h))&&Dg(i,s),g=a.createElement("script"),Ft(g),Di(g,"link",i),a.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function jw(i,s,a,c){var h=(h=ye.current)?qh(h):null;if(!h)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=dc(a.href),a=In(h).hoistableStyles,c=a.get(s),c||(c={type:"style",instance:null,count:0,state:null},a.set(s,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=dc(a.href);var g=In(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(Ou(i)))&&!g._p&&(y.instance=g,y.state.loading=5),Ns.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},Ns.set(i,a),g||sN(h,i,a,y.state))),s&&c===null)throw Error(r(528,""));return y}if(s&&c!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=hc(a),a=In(h).hoistableScripts,c=a.get(s),c||(c={type:"script",instance:null,count:0,state:null},a.set(s,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function dc(i){return'href="'+Li(i)+'"'}function Ou(i){return'link[rel="stylesheet"]['+i+"]"}function Ow(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function sN(i,s,a,c){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?c.loading=1:(s=i.createElement("link"),c.preload=s,s.addEventListener("load",function(){return c.loading|=1}),s.addEventListener("error",function(){return c.loading|=2}),Di(s,"link",a),Ft(s),i.head.appendChild(s))}function hc(i){return'[src="'+Li(i)+'"]'}function Bu(i){return"script[async]"+i}function Bw(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var c=i.querySelector('style[data-href~="'+Li(a.href)+'"]');if(c)return s.instance=c,Ft(c),c;var h=_({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return c=(i.ownerDocument||i).createElement("style"),Ft(c),Di(c,"style",h),Vh(c,a.precedence,i),s.instance=c;case"stylesheet":h=dc(a.href);var g=i.querySelector(Ou(h));if(g)return s.state.loading|=4,s.instance=g,Ft(g),g;c=Ow(a),(h=Ns.get(h))&&Ng(c,h),g=(i.ownerDocument||i).createElement("link"),Ft(g);var y=g;return y._p=new Promise(function(D,U){y.onload=D,y.onerror=U}),Di(g,"link",c),s.state.loading|=4,Vh(g,a.precedence,i),s.instance=g;case"script":return g=hc(a.src),(h=i.querySelector(Bu(g)))?(s.instance=h,Ft(h),h):(c=a,(h=Ns.get(g))&&(c=_({},a),Dg(c,h)),i=i.ownerDocument||i,h=i.createElement("script"),Ft(h),Di(h,"link",c),i.head.appendChild(h),s.instance=h);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(c=s.instance,s.state.loading|=4,Vh(c,a.precedence,i));return s.instance}function Vh(i,s,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===s)g=D;else if(g!==h)break}g?g.parentNode.insertBefore(i,g.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function Ng(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Dg(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var Yh=null;function Iw(i,s,a){if(Yh===null){var c=new Map,h=Yh=new Map;h.set(a,c)}else h=Yh,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[Yt]||g[ke]||i==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var y=g.getAttribute(s)||"";y=i+y;var D=c.get(y);D?D.push(g):c.set(y,[g])}}return c}function Pw(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function rN(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function zw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function aN(i,s,a,c){if(a.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var h=dc(c.href),g=s.querySelector(Ou(h));if(g){s=g._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=Gh.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=g,Ft(g);return}g=s.ownerDocument||s,c=Ow(c),(h=Ns.get(h))&&Ng(c,h),g=g.createElement("link"),Ft(g);var y=g;y._p=new Promise(function(D,U){y.onload=D,y.onerror=U}),Di(g,"link",c),a.instance=g}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Gh.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var Mg=0;function oN(i,s){return i.stylesheets&&i.count===0&&Zh(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var c=setTimeout(function(){if(i.stylesheets&&Zh(i,i.stylesheets),i.unsuspend){var g=i.unsuspend;i.unsuspend=null,g()}},6e4+s);0<i.imgBytes&&Mg===0&&(Mg=62500*UR());var h=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Zh(i,i.stylesheets),i.unsuspend)){var g=i.unsuspend;i.unsuspend=null,g()}},(i.imgBytes>Mg?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(c),clearTimeout(h)}}:null}function Gh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zh(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Xh=null;function Zh(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Xh=new Map,s.forEach(lN,i),Xh=null,Gh.call(i))}function lN(i,s){if(!(s.state.loading&4)){var a=Xh.get(i);if(a)var c=a.get(null);else{a=new Map,Xh.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=s.instance,y=h.getAttribute("data-precedence"),g=a.get(y)||c,g===c&&a.set(null,h),a.set(y,h),this.count++,c=Gh.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)),s.state.loading|=4}}var Iu={$$typeof:P,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function cN(i,s,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=un(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=un(0),this.hiddenUpdates=un(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 Hw(i,s,a,c,h,g,y,D,U,de,Se,Ee){return i=new cN(i,s,a,y,U,de,Se,Ee,D),s=1,g===!0&&(s|=24),g=mi(3,null,null,s),i.current=g,g.stateNode=i,s=um(),s.refCount++,i.pooledCache=s,s.refCount++,g.memoizedState={element:c,isDehydrated:a,cache:s},pm(g),i}function Uw(i){return i?(i=Ia,i):Ia}function $w(i,s,a,c,h,g){h=Uw(h),c.context===null?c.context=h:c.pendingContext=h,c=$a(s),c.payload={element:a},g=g===void 0?null:g,g!==null&&(c.callback=g),a=Fa(i,c,s),a!==null&&(es(a,i,s),mu(a,i,s))}function Fw(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function Ag(i,s){Fw(i,s),(i=i.alternate)&&Fw(i,s)}function Ww(i){if(i.tag===13||i.tag===31){var s=Kr(i,67108864);s!==null&&es(s,i,67108864),Ag(i,67108864)}}function Kw(i){if(i.tag===13||i.tag===31){var s=ps();s=qn(s);var a=Kr(i,s);a!==null&&es(a,i,s),Ag(i,s)}}var Qh=!0;function uN(i,s,a,c){var h=M.T;M.T=null;var g=R.p;try{R.p=2,Lg(i,s,a,c)}finally{R.p=g,M.T=h}}function dN(i,s,a,c){var h=M.T;M.T=null;var g=R.p;try{R.p=8,Lg(i,s,a,c)}finally{R.p=g,M.T=h}}function Lg(i,s,a,c){if(Qh){var h=jg(c);if(h===null)bg(i,s,c,Jh,a),Vw(i,c);else if(fN(h,i,s,a,c))c.stopPropagation();else if(Vw(i,c),s&4&&-1<hN.indexOf(i)){for(;h!==null;){var g=ti(h);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var y=Qe(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}ur(g),(Xt&6)===0&&(Oh=$e()+500,Mu(0))}}break;case 31:case 13:D=Kr(g,2),D!==null&&es(D,g,2),Ih(),Ag(g,2)}if(g=jg(c),g===null&&bg(i,s,c,Jh,a),g===h)break;h=g}h!==null&&c.stopPropagation()}else bg(i,s,c,null,a)}}function jg(i){return i=ws(i),Og(i)}var Jh=null;function Og(i){if(Jh=null,i=Yn(i),i!==null){var s=l(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=d(s),i!==null)return i;i=null}else if(a===31){if(i=f(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return Jh=i,null}function qw(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 ut:return 2;case ht:return 8;case vt:case Rt:return 32;case cn:return 268435456;default:return 32}default:return 32}}var Bg=!1,eo=null,to=null,no=null,Pu=new Map,zu=new Map,io=[],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 Vw(i,s){switch(i){case"focusin":case"focusout":eo=null;break;case"dragenter":case"dragleave":to=null;break;case"mouseover":case"mouseout":no=null;break;case"pointerover":case"pointerout":Pu.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":zu.delete(s.pointerId)}}function Hu(i,s,a,c,h,g){return i===null||i.nativeEvent!==g?(i={blockedOn:s,domEventName:a,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},s!==null&&(s=ti(s),s!==null&&Ww(s)),i):(i.eventSystemFlags|=c,s=i.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),i)}function fN(i,s,a,c,h){switch(s){case"focusin":return eo=Hu(eo,i,s,a,c,h),!0;case"dragenter":return to=Hu(to,i,s,a,c,h),!0;case"mouseover":return no=Hu(no,i,s,a,c,h),!0;case"pointerover":var g=h.pointerId;return Pu.set(g,Hu(Pu.get(g)||null,i,s,a,c,h)),!0;case"gotpointercapture":return g=h.pointerId,zu.set(g,Hu(zu.get(g)||null,i,s,a,c,h)),!0}return!1}function Yw(i){var s=Yn(i.target);if(s!==null){var a=l(s);if(a!==null){if(s=a.tag,s===13){if(s=d(a),s!==null){i.blockedOn=s,Dn(i.priority,function(){Kw(a)});return}}else if(s===31){if(s=f(a),s!==null){i.blockedOn=s,Dn(i.priority,function(){Kw(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function ef(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=jg(i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);Oi=c,a.target.dispatchEvent(c),Oi=null}else return s=ti(a),s!==null&&Ww(s),i.blockedOn=a,!1;s.shift()}return!0}function Gw(i,s,a){ef(i)&&a.delete(s)}function pN(){Bg=!1,eo!==null&&ef(eo)&&(eo=null),to!==null&&ef(to)&&(to=null),no!==null&&ef(no)&&(no=null),Pu.forEach(Gw),zu.forEach(Gw)}function tf(i,s){i.blockedOn===s&&(i.blockedOn=null,Bg||(Bg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,pN)))}var nf=null;function Xw(i){nf!==i&&(nf=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){nf===i&&(nf=null);for(var s=0;s<i.length;s+=3){var a=i[s],c=i[s+1],h=i[s+2];if(typeof c!="function"){if(Og(c||a)===null)continue;break}var g=ti(a);g!==null&&(i.splice(s,3),s-=3,jm(g,{pending:!0,data:h,method:a.method,action:c},c,h))}}))}function fc(i){function s(U){return tf(U,i)}eo!==null&&tf(eo,i),to!==null&&tf(to,i),no!==null&&tf(no,i),Pu.forEach(s),zu.forEach(s);for(var a=0;a<io.length;a++){var c=io[a];c.blockedOn===i&&(c.blockedOn=null)}for(;0<io.length&&(a=io[0],a.blockedOn===null);)Yw(a),a.blockedOn===null&&io.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[Ve]||null;if(typeof g=="function")y||Xw(a);else if(y){var D=null;if(g&&g.hasAttribute("formAction")){if(h=g,y=g[Ve]||null)D=y.formAction;else if(Og(h)!==null)continue}else D=y.action;typeof D=="function"?a[c+1]=D:(a.splice(c,3),c-=3),Xw(a)}}}function Zw(){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 s(){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",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){c=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),h!==null&&(h(),h=null)}}}function Ig(i){this._internalRoot=i}sf.prototype.render=Ig.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,c=ps();$w(a,c,i,s,null,null)},sf.prototype.unmount=Ig.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;$w(i.current,2,null,i,null,null),Ih(),s[Xe]=null}};function sf(i){this._internalRoot=i}sf.prototype.unstable_scheduleHydration=function(i){if(i){var s=kt();i={blockedOn:null,target:i,priority:s};for(var a=0;a<io.length&&s!==0&&s<io[a].priority;a++);io.splice(a,0,i),a===0&&Yw(i)}};var Qw=t.version;if(Qw!=="19.2.6")throw Error(r(527,Qw,"19.2.6"));R.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var mN={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var rf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rf.isDisabled&&rf.supportsFiber)try{kn=rf.inject(mN),_t=rf}catch{}}return $u.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,c="",h=r0,g=a0,y=o0;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onUncaughtError!==void 0&&(h=s.onUncaughtError),s.onCaughtError!==void 0&&(g=s.onCaughtError),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=Hw(i,1,!1,null,null,a,c,null,h,g,y,Zw),i[Xe]=s.current,_g(i),new Ig(s)},$u.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var c=!1,h="",g=r0,y=a0,D=o0,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)),s=Hw(i,1,!0,s,a??null,c,h,U,g,y,D,Zw),s.context=Uw(null),a=s.current,c=ps(),c=qn(c),h=$a(c),h.callback=null,Fa(a,h,c),a=c,s.current.lanes=a,Bn(s,a),ur(s),i[Xe]=s.current,_g(i),new sf(s)},$u.version="19.2.6",$u}var l1;function kN(){if(l1)return Hg.exports;l1=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(),Hg.exports=CN(),Hg.exports}var TN=kN();class tl 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,r=e.files.map((o,l)=>({fieldName:`file${l}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,l]of e.files.entries())n.append(`file${o}`,l.file);return new Promise((o,l)=>{let d=!1;const f=()=>{e.signal?.removeEventListener("abort",b)},m=_=>{d||(d=!0,f(),o(_))},p=_=>{d||(d=!0,f(),l(_))},b=()=>{t.abort(),p(new tl(0,"Upload aborted."))};if(e.signal?.aborted){p(new tl(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 tl(t.status,"Invalid upload response."))}return}p(new tl(t.status,EN(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new tl(0,"Upload failed.")),t.onabort=()=>p(new tl(0,"Upload aborted.")),t.ontimeout=()=>p(new tl(0,"Upload timed out.")),t.send(n)})}function EN(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class Fn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function kp(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${mr(t)}`),setupPassword:t=>De(e,"/api/auth/password",nt("POST",t)),login:t=>De(e,"/api/auth/login",nt("POST",t)),reauth:t=>De(e,"/api/auth/reauth",nt("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",nt("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",nt("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await vc(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",nt("POST",t)),removeNetwork:async t=>{await vc(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",nt("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",nt("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,nt("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",nt("PATCH",{name:t})),removeAgent:async t=>{await vc(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${mr(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",nt("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",nt("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",nt("PUT",t)),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",nt("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",nt("POST",t)),listFiles:t=>De(e,"/api/files/list",nt("POST",t)),readFile:t=>De(e,"/api/files/read",nt("POST",t)),writeFile:t=>De(e,"/api/files/write",nt("POST",t)),createFileEntry:t=>De(e,"/api/files/create",nt("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",nt("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",nt("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",nt("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",nt("POST",t)),previewFile:t=>YC(e,"/api/files/preview",nt("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",nt("POST",t)),closeTerminal:async t=>{await vc(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,nt("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${mr(n)}`),getTerminalTranscriptHistory:(t,n={},r)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${mr(n)}`,r?{signal:r}:void 0),searchTerminalTranscript:(t,n,r)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-search`,{...nt("POST",n),...r?{signal:r}:{}}),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${mr(r)}`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",nt("PUT",t)),deleteNotificationAsset:async t=>{await vc(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?mr({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",nt("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",nt("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",nt("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",nt("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",nt("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",nt("POST",t))}}function pr(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{transcriptCacheScope:e?`agent:${e}`:"local",isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(r={})=>De(t,n("terminals"),nt("POST",r)),closeTerminal:async r=>{await vc(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>De(t,n(`terminals/${encodeURIComponent(r)}`),nt("PATCH",{title:o})),getTerminalHistory:(r,o={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${mr(o)}`),getTerminalTranscriptHistory:(r,o={},l)=>De(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${mr(o)}`,l?{signal:l}:void 0),searchTerminalTranscript:(r,o,l)=>De(t,n(`terminals/${encodeURIComponent(r)}/transcript-search`),{...nt("POST",o),...l?{signal:l}:{}}),getTerminalTranscriptSource:r=>De(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>De(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,l={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${mr(l)}`),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:r=>De(t,n("terminal-layout"),nt("PUT",r)),createFileRoot:r=>De(t,n("files/root"),nt("POST",r)),listFiles:r=>De(t,n("files/list"),nt("POST",r)),readFile:r=>De(t,n("files/read"),nt("POST",r)),writeFile:r=>De(t,n("files/write"),nt("POST",r)),createFileEntry:r=>De(t,n("files/create"),nt("POST",r)),moveFileEntry:r=>De(t,n("files/move"),nt("POST",r)),previewDeleteFileEntry:r=>De(t,n("files/delete-preview"),nt("POST",r)),deleteFileEntry:r=>De(t,n("files/delete"),nt("POST",r)),openFileInTerminal:r=>De(t,n("files/open"),nt("POST",r)),previewFile:r=>YC(t,n("files/preview"),nt("POST",r)),uploadComposeAttachments:r=>VC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:r=>De(t,n("attachments/limits"),r?{credentials:"same-origin",signal:r}:void 0),deleteComposeAttachments:r=>De(t,n("attachments/delete"),nt("POST",r)),getCodeServerStatus:(r={})=>De(t,`${n("code-server/status")}${mr(r)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>De(t,n("code-server/open"),nt("POST",r)),stopCodeServer:(r={})=>De(t,n("code-server/stop"),nt("POST",r)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getProviderHooks:r=>De(t,n(`hooks/${r}`)),installProviderHooks:r=>De(t,n(`hooks/${r}/install`),{method:"POST",credentials:"same-origin"}),removeProviderHooks:r=>De(t,n(`hooks/${r}/remove`),{method:"POST",credentials:"same-origin"}),checkProviderHookTrust:r=>De(t,n(`hooks/${r}/trust`)),trustProviderHooks:r=>De(t,n(`hooks/${r}/trust`),{method:"POST",credentials:"same-origin"}),getAccounts:()=>De(t,n("accounts")),getAccountUsage:r=>De(t,n(`accounts/${r}/usage`),{method:"POST",credentials:"same-origin"}),getServerProcesses:()=>De(t,n("server-info/processes")),renameServerProject:(r,o)=>De(t,n("server-info/project-name"),nt("POST",{path:r,name:o})),getServerExternalIp:(r=!1)=>De(t,n("server-info/external-ip")+(r?"?refresh=1":"")),selectAccount:(r,o)=>De(t,n(`accounts/${r}/select`),nt("POST",{profileId:o})),renameAccount:(r,o,l)=>De(t,n(`accounts/${r}/rename`),nt("POST",{profileId:o,label:l})),removeAccount:(r,o)=>De(t,n(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>De(t,n(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),submitAccountLoginCode:(r,o)=>De(t,n(`accounts/${r}/login/code`),nt("POST",{code:o})),completeAccountLogin:(r,o)=>De(t,n(`accounts/${r}/login/complete`),nt("POST",{label:o})),cancelAccountLogin:r=>De(t,n(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>De(t,n(`accounts/${r}/refresh`),nt("POST",o?{profileId:o}:{})),terminateProviderSessions:r=>De(t,n(`accounts/${r}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>RN(n(`terminals/${encodeURIComponent(r)}/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 nt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function mr(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 r=await e(t,n??{credentials:"same-origin"});await Kb(r);try{return await r.json()}catch{throw new Fn(r.status,"invalid_json_response")}}async function vc(e,t,n){const r=await e(t,n);await Kb(r)}async function YC(e,t,n){const r=await e(t,n);return await Kb(r),r.blob()}async function Kb(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Fn(e.status,t)}const qb="nterminal.theme.id",GC="nterminal.theme.accent",Fv="nterminal:theme",$f=[{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",...c1({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",...c1({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Lc="midnight";function Tp(e){return $f.some(t=>t.id===e)?e:Lc}function Vb(e){return $f.find(t=>t.id===e)??$f[0]}function xo(){if(typeof window>"u")return Lc;try{const e=window.localStorage.getItem(qb);return e?Tp(e):LN(window.localStorage.getItem(GC))}catch{return Lc}}function NN(e){const t=Tp(e);if(typeof window<"u"){try{window.localStorage.setItem(qb,t)}catch{}Yb(t),window.dispatchEvent(new CustomEvent(Fv,{detail:t}))}return t}function Yb(e=xo()){if(typeof document>"u")return;const t=Vb(Tp(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),yt(n,"--nt-bg",t.tokens.bg),yt(n,"--nt-bg-2",t.tokens.bg2),yt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),yt(n,"--nt-line",t.tokens.line),yt(n,"--nt-line-2",t.tokens.line2),yt(n,"--nt-fg",t.tokens.fg),yt(n,"--nt-fg-2",t.tokens.fg2),yt(n,"--nt-fg-3",t.tokens.fg3),yt(n,"--nt-fg-4",t.tokens.fg4),yt(n,"--nt-accent",t.tokens.accent),yt(n,"--nt-accent-soft",t.tokens.accentSoft),yt(n,"--nt-accent-glow",t.tokens.accentGlow),yt(n,"--nt-on-accent",t.tokens.onAccent),yt(n,"--nt-ok",t.tokens.ok),yt(n,"--nt-working",t.tokens.working),yt(n,"--nt-unread",t.tokens.unread),yt(n,"--nt-on-unread",t.tokens.onUnread),yt(n,"--nt-danger",t.tokens.danger),yt(n,"--nt-on-danger",t.tokens.onDanger),yt(n,"--nt-danger-soft",t.tokens.dangerSoft),yt(n,"--nt-danger-line",t.tokens.dangerLine),yt(n,"--nt-warning",t.tokens.warning),yt(n,"--nt-warn",t.tokens.warning),yt(n,"--nt-warning-soft",t.tokens.warningSoft),yt(n,"--nt-warning-glow",t.tokens.warningGlow),yt(n,"--nt-scrim",t.tokens.scrim),yt(n,"--nt-scrim-soft",t.tokens.scrimSoft),yt(n,"--nt-shadow",t.tokens.shadow),yt(n,"--nt-shadow-strong",t.tokens.shadowStrong),yt(n,"--nt-floating-bg",t.tokens.floatingBg),yt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),yt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),yt(n,"--nt-subtle-fill",t.tokens.subtleFill),yt(n,"--nt-hover-fill",t.tokens.hoverFill),yt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),yt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),yt(n,"--nt-transcript-user",t.tokens.transcriptUser),yt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),yt(n,"--nt-transcript-tool",t.tokens.transcriptTool),yt(n,"--nt-transcript-command",t.tokens.transcriptCommand),yt(n,"--nt-transcript-code",t.tokens.transcriptCode),yt(n,"--nt-transcript-search",t.tokens.transcriptSearch),yt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),yt(n,"--nt-qr-bg",t.tokens.qrBg)}function DN(e=xo()){return Vb(Tp(e)).xterm}function Gb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===qb||n.key===GC)&&(Yb(xo()),e())};return window.addEventListener(Fv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Fv,e),window.removeEventListener("storage",t)}}function yt(e,t,n){e.style.setProperty(t,n)}function c1(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],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],l=n[t%6];return u1(r,o,l)}if(e>=232&&e<=255){const t=8+(e-232)*10;return u1(t,t,t)}return"#000000"}function u1(e,t,n){return`#${Wg(e)}${Wg(t)}${Wg(n)}`}function Wg(e){return e.toString(16).padStart(2,"0")}function LN(e){return e==="signal-red"?"signal-red":Lc}function XC(){const e=v.useSyncExternalStore(Gb,xo,()=>Lc);return Vb(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 ed=qC();function jN(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const Ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Uc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Xb(e){return"nodeType"in e}function Fi(e){var t,n;return e?Uc(e)?e:Xb(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Zb(e){const{Document:t}=Fi(e);return e instanceof t}function qd(e){return Uc(e)?!1:e instanceof Fi(e).HTMLElement}function JC(e){return e instanceof Fi(e).SVGElement}function $c(e){return e?Uc(e)?e.document:Xb(e)?Zb(e)?e:qd(e)||JC(e)?e.ownerDocument:document:document:document}const Xs=Ep?v.useLayoutEffect:v.useEffect;function Rp(e){const t=v.useRef(e);return Xs(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function ON(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Cd(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Xs(()=>{n.current!==e&&(n.current=e)},t),n}function Vd(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ff(e){const t=Rp(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Wf(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Kg={};function Yd(e,t){return v.useMemo(()=>{if(t)return t;const n=Kg[e]==null?0:Kg[e]+1;return Kg[e]=n,e+"-"+n},[e,t])}function ek(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((l,d)=>{const f=Object.entries(d);for(const[m,p]of f){const b=l[m];b!=null&&(l[m]=b+e*p)}return l},{...t})}}const Nc=ek(1),Kf=ek(-1);function BN(e){return"clientX"in e&&"clientY"in e}function Np(e){if(!e)return!1;const{KeyboardEvent:t}=Fi(e.target);return t&&e instanceof t}function IN(e){if(!e)return!1;const{TouchEvent:t}=Fi(e.target);return t&&e instanceof t}function qf(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 va=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[va.Translate.toString(e),va.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),d1="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(d1)?e:e.querySelector(d1)}const zN={display:"none"};function HN(e){let{id:t,value:n}=e;return Ht.createElement("div",{id:t,style:zN},n)}function UN(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ht.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function $N(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),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(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:l}=r;e.forEach(d=>{var f;return(f=d[o])==null?void 0:f.call(d,l)})},[e]),t]}const 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:r,screenReaderInstructions:o=KN}=e;const{announce:l,announcement:d}=$N(),f=Yd("DndLiveRegion"),[m,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),FN(v.useMemo(()=>({onDragStart(_){let{active:w}=_;l(t.onDragStart({active:w}))},onDragMove(_){let{active:w,over:S}=_;t.onDragMove&&l(t.onDragMove({active:w,over:S}))},onDragOver(_){let{active:w,over:S}=_;l(t.onDragOver({active:w,over:S}))},onDragEnd(_){let{active:w,over:S}=_;l(t.onDragEnd({active:w,over:S}))},onDragCancel(_){let{active:w,over:S}=_;l(t.onDragCancel({active:w,over:S}))}}),[l,t])),!m)return null;const b=Ht.createElement(Ht.Fragment,null,Ht.createElement(HN,{id:r,value:o.draggable}),Ht.createElement(UN,{id:f,announcement:d}));return n?ed.createPortal(b,n):b}var li;(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"})(li||(li={}));function Vf(){}function Yf(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(r=>r!=null),[...t])}const Zs=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=qf(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function XN(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ZN(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function QN(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function h1(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:r}=e;const o=h1(t,t.left,t.top),l=[];for(const d of r){const{id:f}=d,m=n.get(f);if(m){const p=YN(h1(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),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),d=o-r,f=l-n;if(r<o&&n<l){const 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:r}=e;const o=[];for(const l of r){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}:Zs}function iD(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),l=1;l<r;l++)o[l-1]=arguments[l];return o.reduce((d,f)=>({...d,top:d.top+e*f.y,bottom:d.bottom+e*f.y,left:d.left+e*f.x,right:d.right+e*f.x}),{...n})}}const sD=iD(1);function sk(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 rD(e,t,n){const r=sk(t);if(!r)return e;const{scaleX:o,scaleY:l,x:d,y:f}=r,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 Fc(e,t){t===void 0&&(t=aD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:b}=Fi(e).getComputedStyle(e);p&&(n=rD(n,p,b))}const{top:r,left:o,width:l,height:d,bottom:f,right:m}=n;return{top:r,left:o,width:l,height:d,bottom:f,right:m}}function f1(e){return Fc(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=Fi(e).getComputedStyle(e)),t.position==="fixed"}function cD(e,t){t===void 0&&(t=Fi(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 Qb(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Zb(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!qd(o)||JC(o)||n.includes(o))return n;const l=Fi(e).getComputedStyle(o);return o!==e&&cD(o,l)&&n.push(o),lD(o,l)?n:r(o.parentNode)}return e?r(e):n}function rk(e){const[t]=Qb(e,1);return t??null}function qg(e){return!Ep||!e?null:Uc(e)?e:Xb(e)?Zb(e)||e===$c(e).scrollingElement?window:qd(e)?e:null:null}function ak(e){return Uc(e)?e.scrollX:e.scrollLeft}function ok(e){return Uc(e)?e.scrollY:e.scrollTop}function Wv(e){return{x:ak(e),y:ok(e)}}var _i;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(_i||(_i={}));function lk(e){return!Ep||!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},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,d=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:l,isBottom:d,isRight:f,maxScroll:r,minScroll:t}}const uD={x:.2,y:.2};function dD(e,t,n,r,o){let{top:l,left:d,right:f,bottom:m}=n;r===void 0&&(r=10),o===void 0&&(o=uD);const{isTop:p,isBottom:b,isLeft:_,isRight:w}=ck(e),S={x:0,y:0},x={x:0,y:0},E={height:t.height*o.y,width:t.width*o.x};return!p&&l<=t.top+E.height?(S.y=_i.Backward,x.y=r*Math.abs((t.top+E.height-l)/E.height)):!b&&m>=t.bottom-E.height&&(S.y=_i.Forward,x.y=r*Math.abs((t.bottom-E.height-m)/E.height)),!w&&f>=t.right-E.width?(S.x=_i.Forward,x.x=r*Math.abs((t.right-E.width-f)/E.width)):!_&&d<=t.left+E.width&&(S.x=_i.Backward,x.x=r*Math.abs((t.left+E.width-d)/E.width)),{direction:S,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:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function uk(e){return e.reduce((t,n)=>Nc(t,Wv(n)),Zs)}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=Fc),!e)return;const{top:n,left:r,bottom:o,right:l}=t(e);rk(e)&&(o<=0||l<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const mD=[["x",["left","right"],fD],["y",["top","bottom"],pD]];class Jb{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Qb(n),o=uk(r);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(r),b=o[l]-p;return this.rect[m]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class pd{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function gD(e){const{EventTarget:t}=Fi(e);return e instanceof t?e:$c(e)}function Vg(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Ls;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Ls||(Ls={}));function p1(e){e.preventDefault()}function vD(e){e.stopPropagation()}var Zt;(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"})(Zt||(Zt={}));const hk={start:[Zt.Space,Zt.Enter],cancel:[Zt.Esc],end:[Zt.Space,Zt.Enter,Zt.Tab]},_D=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Zt.Right:return{...n,x:n.x+25};case Zt.Left:return{...n,x:n.x-25};case Zt.Down:return{...n,y:n.y+25};case Zt.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 pd($c(n)),this.windowListeners=new pd(Fi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ls.Resize,this.handleCancel),this.windowListeners.add(Ls.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ls.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&dk(r),n(Zs)}handleKeyDown(t){if(Np(t)){const{active:n,context:r,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}=r.current,b=p?{x:p.left,y:p.top}:Zs;this.referenceCoordinates||(this.referenceCoordinates=b);const _=d(t,{active:n,context:r.current,currentCoordinates:b});if(_){const w=Kf(_,b),S={x:0,y:0},{scrollableAncestors:x}=r.current;for(const E of x){const L=t.code,{isTop:A,isRight:K,isLeft:P,isBottom:z,maxScroll:q,minScroll:Y}=ck(E),I=hD(E),F={x:Math.min(L===Zt.Right?I.right-I.width/2:I.right,Math.max(L===Zt.Right?I.left:I.left+I.width/2,_.x)),y:Math.min(L===Zt.Down?I.bottom-I.height/2:I.bottom,Math.max(L===Zt.Down?I.top:I.top+I.height/2,_.y))},he=L===Zt.Right&&!K||L===Zt.Left&&!P,Q=L===Zt.Down&&!z||L===Zt.Up&&!A;if(he&&F.x!==_.x){const ee=E.scrollLeft+w.x,ie=L===Zt.Right&&ee<=q.x||L===Zt.Left&&ee>=Y.x;if(ie&&!w.y){E.scrollTo({left:ee,behavior:f});return}ie?S.x=E.scrollLeft-ee:S.x=L===Zt.Right?E.scrollLeft-q.x:E.scrollLeft-Y.x,S.x&&E.scrollBy({left:-S.x,behavior:f});break}else if(Q&&F.y!==_.y){const ee=E.scrollTop+w.y,ie=L===Zt.Down&&ee<=q.y||L===Zt.Up&&ee>=Y.y;if(ie&&!w.x){E.scrollTo({top:ee,behavior:f});return}ie?S.y=E.scrollTop-ee:S.y=L===Zt.Down?E.scrollTop-q.y:E.scrollTop-Y.y,S.y&&E.scrollBy({top:-S.y,behavior:f});break}}this.handleMove(t,Nc(Kf(_,this.referenceCoordinates),S))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}fk.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=hk,onActivation:o}=t,{active:l}=n;const{code:d}=e.nativeEvent;if(r.start.includes(d)){const f=l.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function m1(e){return!!(e&&"distance"in e)}function g1(e){return!!(e&&"delay"in e)}class ey{constructor(t,n,r){var o;r===void 0&&(r=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=$c(d),this.documentListeners=new pd(this.document),this.listeners=new pd(r),this.windowListeners=new pd(Fi(d)),this.initialCoordinates=(o=qf(l))!=null?o:Zs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Ls.Resize,this.handleCancel),this.windowListeners.add(Ls.DragStart,p1),this.windowListeners.add(Ls.VisibilityChange,this.handleCancel),this.windowListeners.add(Ls.ContextMenu,p1),this.documentListeners.add(Ls.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(g1(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(m1(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Ls.Click,vD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ls.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:l}=this,{onMove:d,options:{activationConstraint:f}}=l;if(!o)return;const m=(n=qf(t))!=null?n:Zs,p=Kf(o,m);if(!r&&f){if(m1(f)){if(f.tolerance!=null&&Vg(p,f.tolerance))return this.handleCancel();if(Vg(p,f.distance))return this.handleStart()}if(g1(f)&&Vg(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===Zt.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 ey{constructor(t){const{event:n}=t,r=$c(n.target);super(t,bD,r)}}pk.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const yD={move:{name:"mousemove"},end:{name:"mouseup"}};var Kv;(function(e){e[e.RightClick=2]="RightClick"})(Kv||(Kv={}));class ty extends ey{constructor(t){super(t,yD,$c(t.event.target))}}ty.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Kv.RightClick?!1:(r?.({event:n}),!0)}}];const Yg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ny extends ey{constructor(t){super(t,Yg)}static setup(){return window.addEventListener(Yg.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Yg.move.name,t)};function t(){}}}ny.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var md;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(md||(md={}));var Gf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gf||(Gf={}));function SD(e){let{acceleration:t,activator:n=md.Pointer,canScroll:r,draggingRect:o,enabled:l,interval:d=5,order:f=Gf.TreeOrder,pointerCoordinates:m,scrollableAncestors:p,scrollableAncestorRects:b,delta:_,threshold:w}=e;const S=xD({delta:_,disabled:!l}),[x,E]=ON(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),K=v.useMemo(()=>{switch(n){case md.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case md.DraggableRect:return o}},[n,o,m]),P=v.useRef(null),z=v.useCallback(()=>{const Y=P.current;if(!Y)return;const I=L.current.x*A.current.x,F=L.current.y*A.current.y;Y.scrollBy(I,F)},[]),q=v.useMemo(()=>f===Gf.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!l||!p.length||!K){E();return}for(const Y of q){if(r?.(Y)===!1)continue;const I=p.indexOf(Y),F=b[I];if(!F)continue;const{direction:he,speed:Q}=dD(Y,F,K,t,w);for(const ee of["x","y"])S[ee][he[ee]]||(Q[ee]=0,he[ee]=0);if(Q.x>0||Q.y>0){E(),P.current=Y,x(z,d),L.current=Q,A.current=he;return}}L.current={x:0,y:0},A.current={x:0,y:0},E()},[t,z,r,E,l,d,JSON.stringify(K),JSON.stringify(S),x,p,q,b,JSON.stringify(w)])}const wD={x:{[_i.Backward]:!1,[_i.Forward]:!1},y:{[_i.Backward]:!1,[_i.Forward]:!1}};function xD(e){let{delta:t,disabled:n}=e;const r=Wf(t);return Vd(o=>{if(n||!r||!o)return wD;const l={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[_i.Backward]:o.x[_i.Backward]||l.x===-1,[_i.Forward]:o.x[_i.Forward]||l.x===1},y:{[_i.Backward]:o.y[_i.Backward]||l.y===-1,[_i.Forward]:o.y[_i.Forward]||l.y===1}}},[n,t,r])}function CD(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Vd(o=>{var l;return t==null?null:(l=r??o)!=null?l:null},[r,t])}function kD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,l=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,r)}));return[...n,...l]},[]),[e,t])}var kd;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(kd||(kd={}));var qv;(function(e){e.Optimized="optimized"})(qv||(qv={}));const v1=new Map;function TD(e,t){let{dragging:n,dependencies:r,config:o}=t;const[l,d]=v.useState(null),{frequency:f,measure:m,strategy:p}=o,b=v.useRef(e),_=L(),w=Cd(_),S=v.useCallback(function(A){A===void 0&&(A=[]),!w.current&&d(K=>K===null?A:K.concat(A.filter(P=>!K.includes(P))))},[w]),x=v.useRef(null),E=Vd(A=>{if(_&&!n)return v1;if(!A||A===v1||b.current!==e||l!=null){const K=new Map;for(let P of e){if(!P)continue;if(l&&l.length>0&&!l.includes(P.id)&&P.rect.current){K.set(P.id,P.rect.current);continue}const z=P.node.current,q=z?new Jb(m(z),z):null;P.rect.current=q,q&&K.set(P.id,q)}return K}return A},[e,l,n,_,m]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{_||S()},[n,_]),v.useEffect(()=>{l&&l.length>0&&d(null)},[JSON.stringify(l)]),v.useEffect(()=>{_||typeof f!="number"||x.current!==null||(x.current=setTimeout(()=>{S(),x.current=null},f))},[f,_,S,...r]),{droppableRects:E,measureDroppableContainers:S,measuringScheduled:l!=null};function L(){switch(p){case kd.Always:return!1;case kd.BeforeDragging:return n;default:return!n}}}function iy(e,t){return Vd(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ED(e,t){return iy(e,t)}function RD(e){let{callback:t,disabled:n}=e;const r=Rp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Dp(e){let{callback:t,disabled:n}=e;const r=Rp(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function ND(e){return new Jb(Fc(e),e)}function _1(e,t,n){t===void 0&&(t=ND);const[r,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=Dp({callback:l});return Xs(()=>{l(),e?(f?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),d?.disconnect())},[e]),r}function DD(e){const t=iy(e);return ik(e,t)}const b1=[];function MD(e){const t=v.useRef(e),n=Vd(r=>e?r&&r!==b1&&e&&t.current&&e.parentNode===t.current.parentNode?r:Qb(e):b1,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function AD(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(l=>{const d=qg(l.target);d&&n(f=>f?(f.set(d,Wv(d)),new Map(f)):null)},[]);return v.useEffect(()=>{const l=r.current;if(e!==l){d(l);const f=e.map(m=>{const p=qg(m);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Wv(p)]):null}).filter(m=>m!=null);n(f.length?new Map(f):null),r.current=e}return()=>{d(e),d(l)};function d(f){f.forEach(m=>{const p=qg(m);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,d)=>Nc(l,d),Zs):uk(e):Zs,[e,t])}function y1(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==Zs;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Kf(e,n.current):Zs}function LD(e){v.useEffect(()=>{if(!Ep)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function jD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:l}=r;return n[o]=d=>{l(d,t)},n},{}),[e,t])}function mk(e){return v.useMemo(()=>e?oD(e):null,[e])}const S1=[];function OD(e,t){t===void 0&&(t=Fc);const[n]=e,r=mk(n?Fi(n):null),[o,l]=v.useState(S1);function d(){l(()=>e.length?e.map(m=>lk(m)?r:new Jb(t(m),m)):S1)}const f=Dp({callback:d});return Xs(()=>{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 qd(t)?t:e}function BD(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:b}of p)if(qd(b)){r(_=>{const w=t(b);return _?{..._,width:w.width,height:w.height}:w});break}},[t]),l=Dp({callback:o}),d=v.useCallback(p=>{const b=gk(p);l?.disconnect(),b&&l?.observe(b),r(b?t(b):null)},[t,l]),[f,m]=Ff(d);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:m}),[n,f,m])}const ID=[{sensor:pk,options:{}},{sensor:fk,options:{}}],PD={current:{}},Cf={draggable:{measure:f1},droppable:{measure:f1,strategy:kd.WhileDragging,frequency:qv.Optimized},dragOverlay:{measure:Fc}};class gd extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const zD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new gd,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vf},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Cf,measureDroppableContainers:Vf,windowRect:null,measuringScheduled:!1},vk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vf,draggableNodes:new Map,over:null,measureDroppableContainers:Vf},Gd=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 gd}}}function UD(e,t){switch(t.type){case li.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case li.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 li.DragEnd:case li.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case li.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new gd(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case li.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,l=e.droppable.containers.get(n);if(!l||r!==l.key)return e;const d=new gd(e.droppable.containers);return d.set(n,{...l,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case li.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const l=new gd(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:r,draggableNodes:o}=v.useContext(Gd),l=Wf(r),d=Wf(n?.id);return v.useEffect(()=>{if(!t&&!r&&l&&d!=null){if(!Np(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}}})}},[r,t,o,d,l]),null}function bk(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,l)=>l({transform:o,...r}),n):n}function FD(e){return v.useMemo(()=>({draggable:{...Cf.draggable,...e?.draggable},droppable:{...Cf.droppable,...e?.droppable},dragOverlay:{...Cf.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function WD(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const l=v.useRef(!1),{x:d,y:f}=typeof o=="boolean"?{x:o,y:o}:o;Xs(()=>{if(!d&&!f||!t){l.current=!1;return}if(l.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const b=n(p),_=ik(b,r);if(d||(_.x=0),f||(_.y=0),l.current=!0,Math.abs(_.x)>0||Math.abs(_.y)>0){const w=rk(p);w&&w.scrollBy({top:_.y,left:_.x})}},[t,d,f,r,n])}const Mp=v.createContext({...Zs,scaleX:1,scaleY:1});var ho;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ho||(ho={}));const yk=v.memo(function(t){var n,r,o,l;let{id:d,accessibility:f,autoScroll:m=!0,children:p,sensors:b=ID,collisionDetection:_=tD,measuring:w,modifiers:S,...x}=t;const E=v.useReducer(UD,void 0,HD),[L,A]=E,[K,P]=WN(),[z,q]=v.useState(ho.Uninitialized),Y=z===ho.Initialized,{draggable:{active:I,nodes:F,translate:he},droppable:{containers:Q}}=L,ee=I!=null?F.get(I):null,ie=v.useRef({initial:null,translated:null}),J=v.useMemo(()=>{var Fe;return I!=null?{id:I,data:(Fe=ee?.data)!=null?Fe:PD,rect:ie}:null},[I,ee]),H=v.useRef(null),[X,M]=v.useState(null),[R,B]=v.useState(null),oe=Cd(x,Object.values(x)),ge=Yd("DndDescribedBy",d),N=v.useMemo(()=>Q.getEnabled(),[Q]),V=FD(w),{droppableRects:re,measureDroppableContainers:Z,measuringScheduled:Te}=TD(N,{dragging:Y,dependencies:[he.x,he.y],config:V.droppable}),ye=CD(F,I),He=v.useMemo(()=>R?qf(R):null,[R]),Ke=ae(),Ie=ED(ye,V.draggable.measure);WD({activeNode:I!=null?F.get(I):null,config:Ke.layoutShiftCompensation,initialRect:Ie,measure:V.draggable.measure});const _e=_1(ye,V.draggable.measure,Ie),We=_1(ye?ye.parentElement:null),Oe=v.useRef({activatorEvent:null,active:null,activeNode:ye,collisionRect:null,collisions:null,droppableRects:re,draggableNodes:F,draggingNode:null,draggingNodeRect:null,droppableContainers:Q,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),j=Q.getNodeFor((n=Oe.current.over)==null?void 0:n.id),me=BD({measure:V.dragOverlay.measure}),Me=(r=me.nodeRef.current)!=null?r:ye,ze=Y?(o=me.rect)!=null?o:_e:null,W=!!(me.nodeRef.current&&me.rect),pe=DD(W?null:_e),Ce=mk(Me?Fi(Me):null),Ne=MD(Y?j??ye:null),Le=OD(Ne),ve=bk(S,{transform:{x:he.x-pe.x,y:he.y-pe.y,scaleX:1,scaleY:1},activatorEvent:R,active:J,activeNodeRect:_e,containerNodeRect:We,draggingNodeRect:ze,over:Oe.current.over,overlayNodeRect:me.rect,scrollableAncestors:Ne,scrollableAncestorRects:Le,windowRect:Ce}),Pe=He?Nc(He,he):null,$e=AD(Ne),Be=y1($e),ut=y1($e,[_e]),ht=Nc(ve,Be),vt=ze?sD(ze,ve):null,Rt=J&&vt?_({active:J,collisionRect:vt,droppableRects:re,droppableContainers:N,pointerCoordinates:Pe}):null,cn=QN(Rt,"id"),[at,Wn]=v.useState(null),kn=W?ve:Nc(ve,ut),_t=nD(kn,(l=at?.rect)!=null?l:null,_e),jt=v.useRef(null),Nt=v.useCallback((Fe,Qe)=>{let{sensor:St,options:Ut}=Qe;if(H.current==null)return;const $t=F.get(H.current);if(!$t)return;const Wt=Fe.nativeEvent,un=new St({active:H.current,activeNode:$t,event:Wt,options:Ut,context:Oe,onAbort(Vt){if(!F.get(Vt))return;const{onDragAbort:Nn}=oe.current,en={id:Vt};Nn?.(en),K({type:"onDragAbort",event:en})},onPending(Vt,Kn,Nn,en){if(!F.get(Vt))return;const{onDragPending:lt}=oe.current,kt={id:Vt,constraint:Kn,initialCoordinates:Nn,offset:en};lt?.(kt),K({type:"onDragPending",event:kt})},onStart(Vt){const Kn=H.current;if(Kn==null)return;const Nn=F.get(Kn);if(!Nn)return;const{onDragStart:en}=oe.current,qn={activatorEvent:Wt,active:{id:Kn,data:Nn.data,rect:ie}};ed.unstable_batchedUpdates(()=>{en?.(qn),q(ho.Initializing),A({type:li.DragStart,initialCoordinates:Vt,active:Kn}),K({type:"onDragStart",event:qn}),M(jt.current),B(Wt)})},onMove(Vt){A({type:li.DragMove,coordinates:Vt})},onEnd:Bn(li.DragEnd),onCancel:Bn(li.DragCancel)});jt.current=un;function Bn(Vt){return async function(){const{active:Nn,collisions:en,over:qn,scrollAdjustedTranslate:lt}=Oe.current;let kt=null;if(Nn&<){const{cancelDrop:Dn}=oe.current;kt={activatorEvent:Wt,active:Nn,collisions:en,delta:lt,over:qn},Vt===li.DragEnd&&typeof Dn=="function"&&await Promise.resolve(Dn(kt))&&(Vt=li.DragCancel)}H.current=null,ed.unstable_batchedUpdates(()=>{A({type:Vt}),q(ho.Uninitialized),Wn(null),M(null),B(null),jt.current=null;const Dn=Vt===li.DragEnd?"onDragEnd":"onDragCancel";if(kt){const ce=oe.current[Dn];ce?.(kt),K({type:Dn,event:kt})}})}}},[F]),pn=v.useCallback((Fe,Qe)=>(St,Ut)=>{const $t=St.nativeEvent,Wt=F.get(Ut);if(H.current!==null||!Wt||$t.dndKit||$t.defaultPrevented)return;const un={active:Wt};Fe(St,Qe.options,un)===!0&&($t.dndKit={capturedBy:Qe.sensor},H.current=Ut,Nt(St,Qe))},[F,Nt]),ui=kD(b,pn);LD(b),Xs(()=>{_e&&z===ho.Initializing&&q(ho.Initialized)},[_e,z]),v.useEffect(()=>{const{onDragMove:Fe}=oe.current,{active:Qe,activatorEvent:St,collisions:Ut,over:$t}=Oe.current;if(!Qe||!St)return;const Wt={active:Qe,activatorEvent:St,collisions:Ut,delta:{x:ht.x,y:ht.y},over:$t};ed.unstable_batchedUpdates(()=>{Fe?.(Wt),K({type:"onDragMove",event:Wt})})},[ht.x,ht.y]),v.useEffect(()=>{const{active:Fe,activatorEvent:Qe,collisions:St,droppableContainers:Ut,scrollAdjustedTranslate:$t}=Oe.current;if(!Fe||H.current==null||!Qe||!$t)return;const{onDragOver:Wt}=oe.current,un=Ut.get(cn),Bn=un&&un.rect.current?{id:un.id,rect:un.rect.current,data:un.data,disabled:un.disabled}:null,Vt={active:Fe,activatorEvent:Qe,collisions:St,delta:{x:$t.x,y:$t.y},over:Bn};ed.unstable_batchedUpdates(()=>{Wn(Bn),Wt?.(Vt),K({type:"onDragOver",event:Vt})})},[cn]),Xs(()=>{Oe.current={activatorEvent:R,active:J,activeNode:ye,collisionRect:vt,collisions:Rt,droppableRects:re,draggableNodes:F,draggingNode:Me,draggingNodeRect:ze,droppableContainers:Q,over:at,scrollableAncestors:Ne,scrollAdjustedTranslate:ht},ie.current={initial:ze,translated:vt}},[J,ye,Rt,vt,F,Me,ze,re,Q,at,Ne,ht]),SD({...Ke,delta:he,draggingRect:vt,pointerCoordinates:Pe,scrollableAncestors:Ne,scrollableAncestorRects:Le});const fn=v.useMemo(()=>({active:J,activeNode:ye,activeNodeRect:_e,activatorEvent:R,collisions:Rt,containerNodeRect:We,dragOverlay:me,draggableNodes:F,droppableContainers:Q,droppableRects:re,over:at,measureDroppableContainers:Z,scrollableAncestors:Ne,scrollableAncestorRects:Le,measuringConfiguration:V,measuringScheduled:Te,windowRect:Ce}),[J,ye,_e,R,Rt,We,me,F,Q,re,at,Z,Ne,Le,V,Te,Ce]),mn=v.useMemo(()=>({activatorEvent:R,activators:ui,active:J,activeNodeRect:_e,ariaDescribedById:{draggable:ge},dispatch:A,draggableNodes:F,over:at,measureDroppableContainers:Z}),[R,ui,J,_e,A,ge,F,at,Z]);return Ht.createElement(tk.Provider,{value:P},Ht.createElement(Gd.Provider,{value:mn},Ht.createElement(_k.Provider,{value:fn},Ht.createElement(Mp.Provider,{value:_t},p)),Ht.createElement($D,{disabled:f?.restoreFocus===!1})),Ht.createElement(VN,{...f,hiddenTextDescribedById:ge}));function ae(){const Fe=X?.autoScrollEnabled===!1,Qe=typeof m=="object"?m.enabled===!1:m===!1,St=Y&&!Fe&&!Qe;return typeof m=="object"?{...m,enabled:St}:{enabled:St}}}),KD=v.createContext(null),w1="button",qD="Draggable";function sy(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const l=Yd(qD),{activators:d,activatorEvent:f,active:m,activeNodeRect:p,ariaDescribedById:b,draggableNodes:_,over:w}=v.useContext(Gd),{role:S=w1,roleDescription:x="draggable",tabIndex:E=0}=o??{},L=m?.id===t,A=v.useContext(L?Mp:KD),[K,P]=Ff(),[z,q]=Ff(),Y=jD(d,t),I=Cd(n);Xs(()=>(_.set(t,{id:t,key:l,node:K,activatorNode:z,data:I}),()=>{const he=_.get(t);he&&he.key===l&&_.delete(t)}),[_,t]);const F=v.useMemo(()=>({role:S,tabIndex:E,"aria-disabled":r,"aria-pressed":L&&S===w1?!0:void 0,"aria-roledescription":x,"aria-describedby":b.draggable}),[r,S,E,L,x,b.draggable]);return{active:m,activatorEvent:f,activeNodeRect:p,attributes:F,isDragging:L,listeners:r?void 0:Y,node:K,over:w,setNodeRef:P,setActivatorNodeRef:q,transform:A}}function Sk(){return v.useContext(_k)}const VD="Droppable",YD={timeout:25};function Ap(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const l=Yd(VD),{active:d,dispatch:f,over:m,measureDroppableContainers:p}=v.useContext(Gd),b=v.useRef({disabled:n}),_=v.useRef(!1),w=v.useRef(null),S=v.useRef(null),{disabled:x,updateMeasurementsFor:E,timeout:L}={...YD,...o},A=Cd(E??r),K=v.useCallback(()=>{if(!_.current){_.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),S.current=null},L)},[L]),P=Dp({callback:K,disabled:x||!d}),z=v.useCallback((F,he)=>{P&&(he&&(P.unobserve(he),_.current=!1),F&&P.observe(F))},[P]),[q,Y]=Ff(z),I=Cd(t);return v.useEffect(()=>{!P||!q.current||(P.disconnect(),_.current=!1,P.observe(q.current))},[q,P]),v.useEffect(()=>(f({type:li.RegisterDroppable,element:{id:r,key:l,disabled:n,node:q,rect:w,data:I}}),()=>f({type:li.UnregisterDroppable,key:l,id:r})),[r]),v.useEffect(()=>{n!==b.current.disabled&&(f({type:li.SetDroppableDisabled,id:r,key:l,disabled:n}),b.current.disabled=n)},[r,l,n,f]),{active:d,rect:w,isOver:m?.id===r,node:q,over:m,setNodeRef:Y}}function GD(e){let{animation:t,children:n}=e;const[r,o]=v.useState(null),[l,d]=v.useState(null),f=Wf(n);return!n&&!r&&f&&o(f),Xs(()=>{if(!l)return;const m=r?.key,p=r?.props.id;if(m==null||p==null){o(null);return}Promise.resolve(t(p,l)).then(()=>{o(null)})},[t,r,l]),Ht.createElement(Ht.Fragment,null,n,r?v.cloneElement(r,{ref:d}):null)}const XD={x:0,y:0,scaleX:1,scaleY:1};function ZD(e){let{children:t}=e;return Ht.createElement(Gd.Provider,{value:vk},Ht.createElement(Mp.Provider,{value:XD},t))}const QD={position:"fixed",touchAction:"none"},JD=e=>Np(e)?"transform 250ms ease":void 0,eM=v.forwardRef((e,t)=>{let{as:n,activatorEvent:r,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},w={...QD,width:f.width,height:f.height,top:f.top,left:f.left,transform:va.Transform.toString(_),transformOrigin:o&&r?GN(r,f):void 0,transition:typeof b=="function"?b(r):b,...m};return Ht.createElement(n,{className:d,style:w,ref:t},l)}),tM=e=>t=>{let{active:n,dragOverlay:r}=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&&r.node.style.setProperty(f,m);return d!=null&&d.active&&n.node.classList.add(d.active),d!=null&&d.dragOverlay&&r.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:va.Transform.toString(t)},{transform:va.Transform.toString(n)}]},iM={duration:250,easing:"ease",keyframes:nM,sideEffects:tM({styles:{active:{opacity:"0"}}})};function sM(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return Rp((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}=Fi(d).getComputedStyle(d),_=sk(b);if(!_)return;const w=typeof t=="function"?t:rM(t);return dk(m,o.draggable.measure),w({active:{id:l,data:f.data,node:m,rect:o.draggable.measure(m)},draggableNodes:n,dragOverlay:{node:d,rect:o.dragOverlay.measure(p)},droppableContainers:r,measuringConfiguration:o,transform:_})})}function rM(e){const{duration:t,easing:n,sideEffects:r,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},w={x:m.x-b.x,y:m.y-b.y,..._},S=o({...p,active:d,dragOverlay:f,transform:{initial:m,final:w}}),[x]=S,E=S[S.length-1];if(JSON.stringify(x)===JSON.stringify(E))return;const L=r?.({active:d,dragOverlay:f,...p}),A=f.node.animate(S,{duration:t,easing:n,fill:"forwards"});return new Promise(K=>{A.onfinish=()=>{L?.(),K()}})}}let x1=0;function aM(e){return v.useMemo(()=>{if(e!=null)return x1++,x1},[e])}const oM=Ht.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:l,modifiers:d,wrapperElement:f="div",className:m,zIndex:p=999}=e;const{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:S,draggableNodes:x,droppableContainers:E,dragOverlay:L,over:A,measuringConfiguration:K,scrollableAncestors:P,scrollableAncestorRects:z,windowRect:q}=Sk(),Y=v.useContext(Mp),I=aM(_?.id),F=bk(d,{activatorEvent:b,active:_,activeNodeRect:w,containerNodeRect:S,draggingNodeRect:L.rect,over:A,overlayNodeRect:L.rect,scrollableAncestors:P,scrollableAncestorRects:z,transform:Y,windowRect:q}),he=iy(w),Q=sM({config:r,draggableNodes:x,droppableContainers:E,measuringConfiguration:K}),ee=he?L.setRef:void 0;return Ht.createElement(ZD,null,Ht.createElement(GD,{animation:Q},_&&I?Ht.createElement(eM,{key:I,id:_.id,ref:ee,as:f,activatorEvent:b,adjustScale:t,className:m,transition:l,rect:he,style:{zIndex:p,...o},transform:F},n):null))}),lM=128,cM=512,Co=100,uM="too_many_detached_terminals",dM=64,hM=4096;function Lp(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 r=n,o=new Set,l=new Set;for(const d of r){if(o.has(d.id))return null;o.add(d.id);for(const f of d.tabs){if(l.has(f.id))return null;l.add(f.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function 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 r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>Co}):!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 r=_M(t.detachedTerminalIds,Co);return r===null?null:{id:t.id,title:t.title,defaultCwd:vM(t.defaultCwd),detachedTerminalIds:r,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 Vv(e,1,()=>(t+=1,t<=hM))}function Vv(e,t,n){if(!e||typeof e!="object"||t>dM||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=Vv(r.first,t+1,n),l=Vv(r.second,t+1,n);return!o||!l?null:{type:"split",direction:r.direction,ratio:gM(r.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,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}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:jp({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function jp(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!C1(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!C1(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function C1(e){return typeof e=="string"&&yM.test(e)}const Jt="__main__",Ck=128,wM=600*1e3,kk="nterminal.clientDiagnostics.v1",Tk="nterminal.terminalDiagnosticsCursor.v1",Op=150,xM=24,CM=160,kM=48*1024,TM="terminal-connection-recovery";let k1=!1,Fu=null,Wu=null,Gg=0;function EM(){k1||typeof window>"u"||(k1=!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:Td(e,80),data:Dk({...t,visibility:t.visibility??UM(),online:t.online??$M(),viewport:t.viewport??Mk()})},r=ry();return r.push(n),jM(r.slice(-Op)),n}function ry(){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(-Op):[]}catch{return[]}}async function ay(e,t=fetch){if(Fu)return Fu;const n=ry(),r={reason:Td(e,80),events:n},o=JSON.stringify(r);Fu=(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 Fu}finally{Fu=null}}function Bp(){return Ek().events.length>0}async function RM(e=fetch){if(Wu)return Wu;Wu=NM(e);try{return await Wu}finally{Wu=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=ry().filter(o=>DM(o)&&AM(o,e)),n=[];let r=T1([]);for(const o of t){const l=[...n,o],d=T1(l);if(MM(d)>kM)break;n.push(o),r=d}return{events:n,body:r,hasMore:n.length<t.length}}function T1(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(-Op):[]}}catch{return null}}function LM(e){const t=e.at(-1);if(!t)return;const n=Rk(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const l of e)l.at===t.at&&r.add(Nk(l));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-Op)};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:Td(t.id,128)}:{},at:t.at.slice(0,40),event:Td(t.event,80),...t.data&&typeof t.data=="object"?{data:Dk(t.data)}:{}}}function BM(){return Gg=(Gg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${Gg.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 r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function Dk(e){const t={};for(const[n,r]of Object.entries(e).slice(0,xM)){const o=Td(n,64);if(!o||IM(o))continue;const l=PM(r);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 Td(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",oy="nterminal.notifications.completionToastEnabled",ly="nterminal.notifications.completionToastDurationSeconds",cy="nterminal.notifications.completionToastPersistent",Yv="nterminal:completion-toast-display",Gv="nterminal:notification-focus",vd=6.5,Xv=2,Zv=60;function Ip(){return typeof window<"u"&&"Notification"in window}function uy(){try{return window.localStorage.getItem(Ak)==="true"}catch{return!1}}function E1(e){try{window.localStorage.setItem(Ak,e?"true":"false")}catch{}}function gl(){return{enabled:XM(),durationSeconds:GM(),persistUntilDismissed:ZM()}}function VM(e){if(typeof window<"u"){try{window.localStorage.setItem(oy,e?"true":"false")}catch{}dy()}return gl()}function R1(e){const t=jk(e);if(typeof window<"u"){try{window.localStorage.setItem(ly,String(t))}catch{}dy()}return gl()}function YM(e){if(typeof window<"u"){try{window.localStorage.setItem(cy,e?"true":"false")}catch{}dy()}return gl()}function Lk(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===oy||n.key===ly||n.key===cy)&&e()};return window.addEventListener(Yv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Yv,e),window.removeEventListener("storage",t)}}function Wc(){return Ip()?window.Notification.permission:"unsupported"}function GM(){if(typeof window>"u")return vd;try{const e=window.localStorage.getItem(ly);return e===null?vd:jk(Number(e))}catch{return vd}}function XM(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(oy)!=="false"}catch{return!0}}function ZM(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(cy)==="true"}catch{return!1}}function jk(e){if(!Number.isFinite(e))return vd;const t=Math.round(e*2)/2;return Math.max(Xv,Math.min(Zv,t))}function dy(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Yv))}async function Ok(){if(!Ip())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Wc()}}function QM(e){if(!Ip()||Wc()!=="granted"||!uy()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=jp({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),JM(r)})}catch{}}function JM(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Gv,{detail:e}))}const N1="nterminal.push.clientId",eA=2e4,D1=[5e3,3e4,12e4];function ha(){try{const e=window.localStorage.getItem(N1);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Jv()}`;return window.localStorage.setItem(N1,t),t}catch{return`client-${Jv()}`}}function tA(){return`page-${Jv()}`}function Pp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=lA(),n=cA(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function nA(e,t){const n=Pp();if(!n.supported)throw new Error(n.reason);if((Wc()==="granted"?"granted":await Ok())!=="granted")throw new Error("permission_denied");const o=ha(),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=Pp();if(!t.supported||Wc()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=ha(),l=await hA(r.endpoint),d=await e.getPushNotificationStatus(o,l);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&Qv(r,d.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),m=d.endpointRegistered===!0&&Qv(r,f.publicKey);m||await r.unsubscribe();const p=m?r: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 sA(e){let t=!1,n=!1,r=0,o=null;const l=()=>{o!==null&&(window.clearTimeout(o),o=null)},d=b=>{t||n||(n=!0,iA(e).then(_=>{r=0,_&&Pi("push.subscription.reconciled",{trigger:b})}).catch(_=>{if(Pi("push.subscription.reconcile_failed",{trigger:b,reason:_ instanceof Error?_.message:String(_)}),!t&&r<D1.length){const w=D1[r++];o=window.setTimeout(()=>{o=null,d("retry")},w)}}).finally(()=>{n=!1}))},f=b=>{l(),r=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 rA(e){const t=ha();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:ha(),alwaysNotify:t})}function oA(e){if(typeof window>"u")return()=>{};const t=ha(),n=tA();let r=null,o=!1;const l=(p=!0)=>{const b=Pp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:uA(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:uy()&&Wc()==="granted",active:p}).catch(()=>{})},d=()=>{o||r!==null||(r=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,r!==null&&(window.clearInterval(r),r=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,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function dA(e,t){const n=await e.pushManager.getSubscription();return n?Qv(n,t)?n:(await n.unsubscribe(),null):null}function Qv(e,t){const n=e.options.applicationServerKey;return n?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,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),l=new Uint8Array(o);for(let d=0;d<r.length;d+=1)l[d]=r.charCodeAt(d);return o}function zk(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Jv(){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 r of e){if(r==="-"||r==="_"||r<=" "){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t};const gA=e=>{const t=mA(e);return t.charAt(0).toUpperCase()+t.slice(1)};const e_=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const nl={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 Xg(e){return e!=null}function vA(e,t={}){const n=t.attributeNames??{},r=w=>n[w]??w,o=e.size??e.width??nl.width,l=e.size??e.height??nl.height,d=e.aliases?.filter(w=>typeof w=="string"&&w.trim()!=="").map(w=>`lucide-${w}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...d],m=t.className?.split(" ").filter(Boolean)??[],p=t.includeDefaultClasses===!1?e_(...m):e_("lucide",...f,...m),b=t.absoluteStrokeWidth?Number(t.strokeWidth??nl["stroke-width"])*Number(e.size??e.width??nl.width)/Number(t.size??t.width??nl.width):t.strokeWidth??nl["stroke-width"];return["svg",{...Object.entries(nl).reduce((w,[S,x])=>(w[r(S)]=x,w),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&Xg(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&Xg(t.width)&&{[r("width")]:t.width},..."height"in t&&Xg(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:b,...p&&{[r("class")]:p},[r("viewBox")]:`0 0 ${o} ${l}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(w=>{const[S,x,E]=w,L=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return E?[S,L,E]:[S,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:r,strokeWidth:o,absoluteStrokeWidth:l,nonScalingStroke:d,className:f="",children:m,iconNode:p=[],icon:b={node:p,aliases:[],size:24},..._},w)=>{const{size:S=24,strokeWidth:x=2,absoluteStrokeWidth:E=!1,nonScalingStroke:L=!1,color:A="currentColor",className:K=""}=SA()??{},P=!!m||bA(_),[z,q,Y=[]]=_A(b,{color:e??A,width:n??t??S,height:r??t??S,strokeWidth:o??x,absoluteStrokeWidth:l??E,nonScalingStroke:d??L,className:e_(K,f),hasA11yProp:P,attributes:_});return v.createElement(z,{ref:w,...q},[...Y.map(([I,F])=>v.createElement(I,F)),...Array.isArray(m)?m:[m]])});function Cn(e,t=[],n=[]){const r=typeof e=="string"?pA(e,t,n):e,o=v.forwardRef(({className:l,...d},f)=>v.createElement(wA,{ref:f,icon:r,className:l,...d}));return r.name&&(o.displayName=gA(r.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=Cn(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=Cn(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=Cn($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=Cn(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=Cn(Wk);const Kk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Kk.node;const qk=Cn(Kk);const Vk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Vk.node;const RA=Cn(Vk);const Yk={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Yk.node;const Gk=Cn(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 Xf=Cn(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=Cn(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=Cn(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=Cn(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=Cn(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=Cn(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 M1=Cn(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=Cn(iT);const sT={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"}]]};sT.node;const rT=Cn(sT);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 Zg=Cn(aT);const oT={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};oT.node;const OA=Cn(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 jc=Cn(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 A1=Cn(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=Cn(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 L1=Cn(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 Zf=Cn(hT);function ua(e,t){const n=[Jt,...t.map(d=>d.id)],r=new Set(n),o=new Set,l=[];for(const d of e??[])!r.has(d)||o.has(d)||(o.add(d),l.push(d));for(const d of n)o.has(d)||l.push(d);return l}function IA(e,t){return ua(e,t).map(n=>n===Jt?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 j1="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(r=>[r.id,r]));return ua(t,e).flatMap(r=>{if(r===Jt)return[{kind:"main",id:Jt}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function O1(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function pT(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Os(e.value.cpuPercent)} ${hy(e.value)}`,`MEM ${Os(e.value.memoryPercent)} ${ga(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Os(e.value.diskPercent)} ${ga(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Os(e.value.swapPercent)} ${ga(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function B1(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Os(e.value.cpuPercent)} (${hy(e.value)})`,`RAM ${Os(e.value.memoryPercent)} (${ga(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Os(e.value.diskPercent)} (${ga(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Os(e.value.swapPercent)} (${ga(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 Os(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function hy(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`:`${t_(e.cpuPercent/100*t)}/${t} cores`}function ga(e,t){return!I1(e)||!I1(t)?"–/–":VA(e,t)}function VA(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${t_(e/r)}/${t_(t/r)} ${n}`}function t_(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function I1(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function af(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function YA(e){return[{label:"CPU",percent:Os(e.cpuPercent),detail:hy(e),tone:af(e.cpuPercent)},{label:"MEM",percent:Os(e.memoryPercent),detail:ga(e.memoryUsedBytes,e.memoryTotalBytes),tone:af(e.memoryPercent)},{label:"DISK",percent:Os(e.diskPercent),detail:ga(e.diskUsedBytes,e.diskTotalBytes),tone:af(e.diskPercent)},{label:"SWAP",percent:Os(e.swapPercent),detail:ga(e.swapUsedBytes,e.swapTotalBytes),tone:af(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:B1(e),"aria-label":B1(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 P1({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:l,onManageAccounts:d,onServerInfo:f,renderServerChildren:m,compact:p=!1}){const[b,_]=v.useState([]),[w,S]=v.useState([Jt]),[x,E]=v.useState(null),[L,A]=v.useState(!1),[K,P]=v.useState(!1),[z,q]=v.useState(null),[Y,I]=v.useState(""),F=v.useRef(null),[he,Q]=v.useState(()=>FA()),[ee,ie]=v.useState(null),[J,H]=v.useState(null),[X,M]=v.useState({}),R=v.useRef({}),B=v.useRef(0),oe=v.useRef([]),ge=v.useRef([Jt]),N=v.useRef(null);v.useEffect(()=>{oe.current=b},[b]),v.useEffect(()=>{const W=ua(w,b);ge.current=W,O1(W,w)||S(W)},[b,w]),v.useEffect(()=>{let W=!1;return e.listAgents().then(pe=>{W||(_(pe.agents),P(!0),S(ua(pe.serverOrder,pe.agents)))}).catch(()=>{}),e.getMainInfo().then(pe=>{W||(E(pe.name),A(!0))}).catch(()=>{}),()=>{W=!0}},[e,o]),v.useEffect(()=>{z&&(F.current?.focus(),F.current?.select())},[z]),v.useEffect(()=>{let W=!1;function pe(){const Ne=[{key:Jt,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...b.map(ve=>({key:ve.id,load:()=>e.getAgentStats(ve.id),probe:async()=>(await e.pingAgent(ve.id)).ok}))],Le=new Set(Ne.map(ve=>ve.key));for(const ve of Object.keys(R.current))Le.has(ve)||delete R.current[ve];M(ve=>{const Pe={};for(const $e of Le)$e in ve&&(Pe[$e]=ve[$e]);return Pe});for(const ve of Ne)ve.load().then(Pe=>{W||(R.current[ve.key]=0,M($e=>Le.has(ve.key)?{...$e,[ve.key]:{status:"online",value:Pe,stale:!1}}:$e))}).catch(async Pe=>{if(W)return;if(Pe instanceof Fn&&Pe.status===401&&ve.key===Jt){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(ve.key===Jt&&Pe instanceof Fn){R.current[ve.key]=0,M(Be=>{if(!Le.has(ve.key))return Be;const ut=Be[ve.key];return{...Be,[ve.key]:{status:"online",value:ut?.value??null,stale:!0}}});return}if(ve.probe)try{if(await ve.probe()){if(W)return;R.current[ve.key]=0,M(Be=>{if(!Le.has(ve.key))return Be;const ut=Be[ve.key];return{...Be,[ve.key]:{status:"online",value:ut?.value??null,stale:!0}}});return}}catch(Be){if(W)return;if(Be instanceof Fn&&Be.status===401){r?.({source:ve.key===Jt?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const $e=(R.current[ve.key]??0)+1;R.current[ve.key]=$e,$e>=UA&&M(Be=>Le.has(ve.key)?{...Be,[ve.key]:{status:"offline",value:Be[ve.key]?.value??null,stale:!0}}:Be)})}pe();const Ce=window.setInterval(pe,HA);return()=>{W=!0,window.clearInterval(Ce)}},[e,b,r]);function V(W){W==="main"?(I(x??""),q({kind:"main"})):(I(W.name),q({kind:"agent",id:W.id}))}async function re(){if(!z)return;const W=Y.trim(),pe=z;if(q(null),pe.kind==="main"){const Ce=W||"";try{const Ne=await e.renameMain(Ce);E(Ne.name)}catch{}}else{if(!W)return;const Ce=b.find(Ne=>Ne.id===pe.id)?.name;_(Ne=>Ne.map(Le=>Le.id===pe.id?{...Le,name:W}:Le));try{await e.renameAgent(pe.id,W)}catch{Ce!==void 0&&_(Ne=>Ne.map(Le=>Le.id===pe.id?{...Le,name:Ce}:Le))}}}function Z(){q(null)}function Te(W){Q(W),WA(W)}function ye(W,pe,Ce){if(W===pe)return;const Ne=ua(ge.current,oe.current),Le=Ne.findIndex(vt=>vt===W),ve=Ne.findIndex(vt=>vt===pe);if(Le<0||ve<0)return;const Pe=[...Ne],[$e]=Pe.splice(Le,1);if(!$e)return;const Be=Pe.findIndex(vt=>vt===pe);if(Be<0)return;const ut=Ce==="before"?Be:Be+1;if(Pe.splice(ut,0,$e),O1(Pe,Ne))return;const ht=B.current+1;B.current=ht,ge.current=Pe,S(Pe),e.reorderAgents(Pe).then(vt=>{if(B.current===ht){oe.current=vt.agents;const Rt=ua(vt.serverOrder,vt.agents);ge.current=Rt,_(vt.agents),S(Rt)}}).catch(async()=>{if(B.current===ht)try{const vt=await e.listAgents();if(B.current===ht){oe.current=vt.agents;const Rt=ua(vt.serverOrder,vt.agents);ge.current=Rt,_(vt.agents),S(Rt)}}catch{B.current===ht&&(ge.current=Ne,S(Ne))}})}function He(W,pe){const Ce=ua(ge.current,oe.current),Ne=Ce.findIndex(ve=>ve===W),Le=Ce[Ne+pe];Ne<0||!Le||ye(W,Le,pe<0?"before":"after")}function Ke(W,pe){pe.pointerType==="mouse"&&pe.button!==0||(pe.stopPropagation(),N.current={sourceId:W,pointerId:pe.pointerId,startX:pe.clientX,startY:pe.clientY,active:!1,targetId:null,placement:"after"},pe.currentTarget.setPointerCapture?.(pe.pointerId))}function Ie(W){const pe=N.current;if(!pe||pe.pointerId!==W.pointerId)return;const Ce=Math.hypot(W.clientX-pe.startX,W.clientY-pe.startY);if(!pe.active){if(Ce<$A)return;pe.active=!0,ie(pe.sourceId)}const Le=document.elementFromPoint(W.clientX,W.clientY)?.closest("[data-server-id]"),ve=Le?.dataset.serverId??null;if(!Le||!ve||ve===pe.sourceId){pe.targetId=null,H(null);return}const Pe=Le.getBoundingClientRect(),$e=W.clientY<Pe.top+Pe.height/2?"before":"after";pe.targetId=ve,pe.placement=$e,H({serverId:ve,placement:$e})}function _e(W){const pe=N.current;!pe||pe.pointerId!==W.pointerId||(W.stopPropagation(),W.currentTarget.releasePointerCapture?.(W.pointerId),N.current=null,ie(null),H(null),pe.active&&pe.targetId&&ye(pe.sourceId,pe.targetId,pe.placement))}function We(W){const pe=N.current;pe&&pe.pointerId===W.pointerId&&W.currentTarget.releasePointerCapture?.(W.pointerId),N.current=null,ie(null),H(null)}const Oe=x?.trim()||j1,j=z?.kind==="main",me=he==="stats",Me=KA(b,w),ze=Me.length>1;return v.useEffect(()=>{l?.([...L?[{agentId:null,label:Oe}]:[],...K?b.map(W=>({agentId:W.id,label:W.name})):[]])},[b,K,Oe,L,l]),p?u.jsx("div",{className:"server-list server-list--compact",children:Me.map(W=>{const pe=W.kind==="main",Ce=pe?Oe:W.agent.name,Ne=pe?Jt:W.id,Le=X[Ne],ve=pT(Le);return u.jsxs("button",{type:"button",className:`server-list-chip${(pe?t===null:t===W.id)?" server-list-chip--active":""}`,onClick:()=>n(pe?null:W.id),"aria-label":`${Ce}${ve?` — ${ve}`:""}`,title:`${Ce}${ve?` — ${ve}`:""}`,children:[u.jsx("span",{className:"server-list-chip-initial",children:zA(Ce)}),u.jsx("span",{className:"server-list-chip-pip","data-status":PA(Le)})]},W.id)})}):u.jsxs("div",{className:`server-list server-list--${he}`,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":he==="list",onClick:()=>Te("list"),title:"Show server names only",children:"List"}),u.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":he==="stats",onClick:()=>Te("stats"),title:"Show resource usage",children:"Stats"})]}),Me.map(W=>{const pe=W.kind==="main",Ce=pe?Oe:W.agent.name,Ne=pe?Jt:W.id,Le=pe?t===null:t===W.id,ve=pe?j:z?.kind==="agent"&&z.id===W.id,Pe=m?.({agentId:pe?null:W.id,serverId:W.id,label:Ce,active:Le}),$e=J?.serverId===W.id&&ee!==W.id?` server-list-section--drop-target server-list-section--drop-${J.placement}`:"";return u.jsxs("section",{className:`server-list-section${$e}`,"aria-label":`${Ce} server`,children:[u.jsx("div",{className:["server-list-row",ee===W.id?"server-list-row--dragging":"",J?.serverId===W.id&&ee!==W.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":W.id,children:ve?u.jsxs(u.Fragment,{children:[ze?u.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,u.jsx("form",{className:"server-list-editor",onSubmit:Be=>{Be.preventDefault(),re()},children:u.jsx("input",{ref:F,"aria-label":pe?"Rename main server":`Rename ${Ce}`,value:Y,onChange:Be=>I(Be.target.value),onBlur:()=>{re()},onKeyDown:Be=>{Be.key==="Escape"&&(Be.preventDefault(),Z())},placeholder:pe?j1:void 0})})]}):u.jsxs(u.Fragment,{children:[ze?u.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":W.id,title:"Drag to reorder","aria-label":`Reorder ${Ce}`,"aria-grabbed":ee===W.id,onPointerDown:Be=>Ke(W.id,Be),onPointerMove:Ie,onPointerUp:_e,onPointerCancel:We,onKeyDown:Be=>{(Be.key==="ArrowUp"||Be.key==="ArrowDown")&&(Be.preventDefault(),Be.stopPropagation(),He(W.id,Be.key==="ArrowUp"?-1:1))},onClick:Be=>Be.stopPropagation(),children:"::"}):null,u.jsxs("div",{className:`server-list-item${Le?" server-list-item--active":""}`,title:qA(Ce,X[Ne]),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:W.id),onDoubleClick:Be=>{Be.preventDefault(),V(pe?"main":{id:W.id,name:Ce})},children:[u.jsx("span",{className:"server-list-dot"}),u.jsx("span",{className:"server-list-name",title:pe?void 0:W.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 ut=Be==="codex"?"Codex":"Claude",ht=X[Ne]?.value?.accountsReloginRequired?.includes(Be)===!0;return u.jsxs("button",{type:"button",className:`server-list-provider-button${ht?" server-list-provider-button--attention":""}`,title:ht?`Manage ${ut} accounts: a saved account needs re-login`:`Manage ${ut} accounts`,"aria-label":`Manage ${ut} accounts on ${Ce}${ht?" (re-login required)":""}`,onClick:()=>d({agentId:pe?null:W.id,label:Ce},Be),children:[u.jsx("img",{src:`/brand/${Be}.webp`,alt:""}),ht?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:W.id,label:Ce}),children:u.jsx(MA,{size:17})})]}),me?u.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(pe?null:W.id),children:u.jsx(GA,{entry:X[Ne]})}):null]})]})}),Pe?u.jsx("div",{className:"server-list-children",children:Pe}):null]},W.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."}const QA={codex:[{host:"auth.openai.com",path:"/codex/device"}],claude:[{host:"claude.com",path:"/cai/oauth/authorize"},{host:"platform.claude.com",path:"/oauth/authorize"}]},JA=2048,eL=/^[A-Za-z0-9._~-]{8,512}#[A-Za-z0-9._~-]{8,512}$/,z1=1024;function tL(e,t){if(typeof t!="string"||t.length>JA)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 r=n.hostname.toLowerCase();return QA[e].some(o=>o.host===r&&o.path===n.pathname)?n.toString():null}function nL(e,t){if(typeof t!="string"||t.length>z1+64)return null;const n=t.trim();return n.length>z1||!eL.test(n)?null:n}function iL({provider:e,serverLabel:t,api:n,disabled:r=!1,onBusyChange:o}){const[l,d]=v.useState(null),[f,m]=v.useState(!0),[p,b]=v.useState(!1),[_,w]=v.useState(null),[S,x]=v.useState(null),[E,L]=v.useState(null),A=v.useRef(null),K=v.useRef(null),P=v.useRef(null),z=v.useRef(null),q=v.useRef(null),Y=v.useRef(!1),I=v.useId(),F=v.useId(),he=e==="codex"?"Codex":"Claude",Q=r||l?.reason==="preview_mode",ee=H1(l),ie=e==="codex"&&!!l?.installed&&!ee&&l?.reason!=="hooks_disabled",J=v.useCallback(async()=>{const X=A.current;if(!X?.active||X.busy)return;const M=++X.generation;m(!0),x(null),L(null);let R=null;try{R=await n.getProviderHooks(e),X.active&&M===X.generation&&d(R)}catch(B){X.active&&M===X.generation&&x(F1(B))}finally{X.active&&M===X.generation&&m(!1)}if(!(e!=="codex"||!R?.installed||R.trust||R.reason==="preview_mode"||R.reason==="hooks_disabled"))try{const B=await n.checkProviderHookTrust(e);X.active&&M===X.generation&&!X.busy&&B.trust&&!B.trust.reason&&d(B)}catch{}},[n,e]);v.useEffect(()=>{const X={active:!0,busy:!1,generation:0};return A.current=X,d(null),w(null),b(!1),L(null),q.current=null,J(),()=>{X.active=!1}},[J]),v.useEffect(()=>{_&&!p?K.current?.focus():!p&&Y.current&&(q.current==="trust"&&z.current?z:P).current?.focus(),Y.current=!!_||p;const X=M=>{M.key!=="Escape"||!_&&!p||(M.preventDefault(),M.stopImmediatePropagation(),p||w(null))};return window.addEventListener("keydown",X,!0),()=>window.removeEventListener("keydown",X,!0)},[_,p]);async function H(){const X=A.current;if(!(!X?.active||X.busy||Q||!_)){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 R=_==="trust";_==="install"&&e==="codex"&&M.installed&&(!M.reason||M.reason==="approval_unknown"||M.reason==="approval_required")&&(w(null),M=await n.trustProviderHooks(e),R=!0),X.active&&(d(M),w(null),R?M.trust?M.trust.reason?x($1(M.trust.reason)):H1(M)?L(oL(M.trust)):x($1("verification_failed")):x("Codex did not report a trust result. Use /hooks in Codex instead."):M.installed!==(_==="install")&&x(M.reason?n_(M.reason):"The requested hook change was not applied."))}catch(M){X.active&&x(F1(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(Zg,{size:14,"aria-hidden":"true"}),"Provider hooks"]}),u.jsx("span",{className:"provider-hooks-status",role:"status",children:f?"Checking...":l?rL(l):"Status unavailable"})]}),u.jsxs("div",{className:"provider-hooks-actions",children:[u.jsx("button",{type:"button",className:"account-icon-button",title:"Refresh hook status","aria-label":"Refresh hook status",disabled:r||f||p||!!_,onClick:()=>{J()},children:u.jsx(jc,{size:14,"aria-hidden":"true"})}),u.jsxs("button",{ref:P,type:"button",disabled:Q||f||p||!l||!!_,onClick:()=>w(l?.installed?"remove":"install"),children:[l?.installed?u.jsx(L1,{size:14,"aria-hidden":"true"}):u.jsx(Zg,{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:[n_(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:lL(X)},X))}):null,e==="codex"&&ee?u.jsxs("p",{className:"provider-hooks-trusted",children:["Codex reports ",aL(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,ie&&!p?u.jsx("div",{className:"provider-hooks-actions",children:u.jsxs("button",{ref:z,type:"button",disabled:Q||f||p||!!_,onClick:()=>w("trust"),children:[u.jsx(A1,{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":F,children:[_==="trust"?u.jsxs(u.Fragment,{children:[u.jsxs("p",{id:F,children:["Trust ",U1(l?.hookCount)," Codex hooks on ",t,"?"]}),u.jsxs("p",{children:["This marks only ",U1(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:F,children:[_==="install"?"Install":"Remove"," ",he," 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:K,type:"button",disabled:p,onClick:()=>w(null),children:"Cancel"}),u.jsxs("button",{type:"button",className:_==="remove"?"danger-button":"primary-button",disabled:Q||p,onClick:()=>{H()},children:[p?u.jsx(M1,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"}):_==="install"?u.jsx(Zg,{size:14,"aria-hidden":"true"}):_==="trust"?u.jsx(A1,{size:14,"aria-hidden":"true"}):u.jsx(L1,{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(M1,{size:14,className:"provider-hooks-spinner","aria-hidden":"true"})," Trusting NTerminal hooks in Codex..."]}):null,E?u.jsx("p",{className:"provider-hooks-notice",role:"status",children:E}):null,S?u.jsx("p",{className:"provider-hooks-error",role:"alert",children:S}):null]})}function sL({panes:e}){const t=e.some(o=>o.reason==="shared_daemon_same_cwd"),n=e.map(o=>o.title).filter(Boolean),r=e.length===1?"1 Codex pane is":`${e.length} Codex panes are`;return u.jsxs("p",{className:"provider-hooks-note",role:"note",children:[r," not linked to hook events",n.length?` (${n.join(", ")})`:"","."," ",t?"Codex runs sessions in a shared background server, and another session is open in the same directory, so events cannot be matched to a pane.":"Codex runs sessions in a shared background server, and NTerminal could not confirm which session belongs to the pane."," ","These panes use transcript detection instead. Run one Codex per directory, or start Codex with ",u.jsx("code",{children:"--no-daemon"}),"."]})}function rL(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 H1(e){return!!(e?.installed&&e.trust&&!e.trust.reason&&e.trust.pending===0&&e.trust.total>0)}function aL(e){return e===void 0?"all NTerminal hooks":e===1?"the NTerminal hook":`all ${e} NTerminal hooks`}function U1(e){return e===void 0?"NTerminal's":`NTerminal's ${e}`}function oL(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 $1(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]??n_(e)}function F1(e){if(e instanceof Fn){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 n_(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 lL(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 cL(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(uL,{...e},t.revision)}function uL({provider:e,serverLabel:t,api:n,onClose:r}){const[o,l]=v.useState(null),[d,f]=v.useState(!0),[m,p]=v.useState(null),[b,_]=v.useState(!1),[w,S]=v.useState(null),[x,E]=v.useState(""),[L,A]=v.useState(null),[K,P]=v.useState(!1),[z,q]=v.useState(()=>Date.now()),[Y,I]=v.useState({}),[F,he]=v.useState(!0),[Q,ee]=v.useState(!1),[ie,J]=v.useState(!1),H=v.useRef(null),X=v.useCallback(async(N=!1)=>{const V=H.current;if(!V?.active||V.actionPending||N&&V.statusPending)return;const re=++V.statusGeneration;V.statusPending=!0,N||(f(!0),S(null));try{const Z=await n.getAccounts();V.active&&re===V.statusGeneration&&l(Z)}catch(Z){V.active&&re===V.statusGeneration&&!N&&S(K1(Z))}finally{V.active&&re===V.statusGeneration&&(V.statusPending=!1,N||f(!1))}},[n]),M=v.useCallback(async()=>{const N=H.current;if(!(!N?.active||N.actionPending)&&(N.usageGeneration+=1,N.usageQueued=!0,!N.usagePending)){N.usagePending=!0,he(!0);do{N.usageQueued=!1;const V=N.usageGeneration;try{const re=await n.getAccountUsage(e);if(re.provider!==e)throw new Error("Unexpected account usage provider");N.active&&V===N.usageGeneration&&(I(Object.fromEntries(re.profiles.map(Z=>[Z.profileId,Z.usage]))),ee(!1),J(!1),q(Date.now()))}catch{N.active&&V===N.usageGeneration&&(ee(!0),J(!0))}}while(N.active&&N.usageQueued&&!N.actionPending);N.usagePending=!1,N.active&&he(!1)}},[n,e]),R=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 H.current=N,X(),M(),()=>{N.active=!1}},[X,M]),v.useEffect(()=>{const N=V=>{V.key==="Escape"&&!V.defaultPrevented&&!m&&!b&&(K?P(!1):r())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[r,m,b,K]),v.useEffect(()=>{const N=window.setInterval(()=>q(Date.now()),6e4);return()=>window.clearInterval(N)},[]),v.useEffect(()=>{if(!R?.pendingLogin||m)return;const V=window.setInterval(()=>{X(!0)},1500);return()=>window.clearInterval(V)},[m,R?.pendingLogin,X]),v.useEffect(()=>{if(!R?.pendingLogin)return;const N=window.setInterval(()=>q(Date.now()),15e3);return()=>window.clearInterval(N)},[R?.pendingLogin]);async function B(N,V){const re=H.current;if(!re?.active||re.actionPending||b)return!1;re.actionPending=!0,re.statusGeneration+=1,re.statusPending=!1,re.usageGeneration+=1,ee(!0),f(!1),p(N),S(null);try{const Z=await V();return re.active&&l(Z),!0}catch(Z){return re.active&&S(K1(Z)),!1}finally{re.actionPending=!1,re.active&&(p(null),X(!0),M())}}async function oe(N=null){A(N?.label??null),E(""),await B("login",()=>n.beginAccountLogin(e))}const ge=e==="codex"?"Codex":"Claude";return u.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&!m&&!b&&r()},children:[u.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${ge} accounts on ${t}`,children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{className:"account-dialog-title",children:[u.jsx(SL,{provider:e}),u.jsxs("div",{children:[u.jsxs("h2",{children:[ge," accounts"]}),u.jsx("p",{children:t})]})]}),u.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",title:"Close accounts",onClick:r,disabled:!!m||b,children:u.jsx(Zf,{size:16,"aria-hidden":"true"})})]}),u.jsxs("div",{className:"account-dialog-scroll",children:[d&&!R?u.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,R?u.jsx(dL,{provider:e,status:R,pendingAction:m??(b?"hooks":null),clock:z,usage:Y,usageLoading:F,usageStale:Q,label:x,onLabelChange:E,onSelect:N=>{B(`select:${N}`,()=>n.selectAccount(e,N))},onRename:(N,V)=>B(`rename:${N}`,()=>n.renameAccount(e,N,V)),onDelete:N=>{B(`delete:${N}`,()=>n.removeAccount(e,N))},onRefresh:N=>{B(`refresh:${N}`,()=>n.refreshAccount(e,N))},onBeginLogin:()=>{oe()},onRelogin:N=>{oe(N)},reloginFor:L,onCompleteLogin:()=>{B("complete",()=>n.completeAccountLogin(e,x))},onCancelLogin:()=>{B("cancel",()=>n.cancelAccountLogin(e))},onSubmitCode:async N=>{await B("code",()=>n.submitAccountLoginCode(e,N))},onRequestTerminate:()=>P(!0)}):null,ie?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,w?u.jsx("p",{className:"account-dialog-error",role:"alert",children:w}):null,u.jsx(iL,{provider:e,serverLabel:t,api:n,disabled:!!m||K,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(jc,{size:14,"aria-hidden":"true"}),"Refresh"]}),u.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!m||b,children:"Close"})]})]}),K?u.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&!m&&P(!1)},children:u.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${ge} sessions`,children:[u.jsxs("h3",{children:["Exit all ",ge," sessions?"]}),u.jsxs("p",{children:["This stops detected ",ge," 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:()=>P(!1),disabled:!!m,children:"Cancel"}),u.jsx("button",{type:"button",className:"danger-button",disabled:!!m,onClick:()=>{P(!1),B("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function dL({provider:e,status:t,pendingAction:n,clock:r,usage:o,usageLoading:l,usageStale:d,label:f,onLabelChange:m,onSelect:p,onRename:b,onDelete:_,onRefresh:w,onBeginLogin:S,onRelogin:x,reloginFor:E,onCompleteLogin:L,onCancelLogin:A,onSubmitCode:K,onRequestTerminate:P}){const z=t.runningProcesses??[],q=t.runningPanes.length>0||z.length>0||t.processCheckUnavailable===!0,Y=e==="codex"?"Codex":"Claude",I=q?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsxs("strong",{children:[Y," is running. Changing accounts here does not stop these sessions; they keep their current account until restarted."]}),e==="codex"?u.jsx("small",{children:"New Codex sessions started through the shared background server may also use the previous account until that server restarts."}):null,t.runningPanes.map(H=>u.jsxs("span",{children:[u.jsx("b",{children:H.title}),u.jsx("small",{children:H.cwd})]},H.terminalId)),z.map(H=>u.jsxs("span",{children:[u.jsxs("b",{children:[H.command," ",u.jsxs("em",{children:["PID ",H.pid]})]}),u.jsx("small",{children:H.role==="daemon"?"Shared Codex daemon / manager":"Provider process on this server"})]},H.pid)),t.processCheckUnavailable?u.jsxs("span",{children:[u.jsx("b",{children:"Process check unavailable"}),u.jsx("small",{children:"Running sessions could not be listed. Refreshing the active account's credentials is paused until they can."})]}):null,t.processCheckUnavailable?null:u.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:P,children:["Exit all ",Y," sessions"]})]}):null;if(t.pendingLogin){const H=t.pendingLogin,X=H.ready&&(H.login?.phase??"done")==="done";return u.jsxs(u.Fragment,{children:[I,u.jsxs("div",{className:"account-dialog-section account-login",children:[E?u.jsxs("p",{className:"account-dialog-muted",children:["Signing in again to ",u.jsx("b",{children:E}),". Use the same account: its saved name is kept, and it becomes the active account when saved."]}):null,X?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:M=>m(M.target.value),placeholder:H.suggestedLabel??(E?"Leave blank to keep the saved name":`${Y} account`),maxLength:80,autoFocus:!0})]}),H.suggestedLabel?u.jsxs("p",{className:"account-dialog-muted account-login-suggested",children:["Leave blank to save it as ",u.jsx("b",{children:H.suggestedLabel}),". You can rename it later by clicking its name."]}):null]}):u.jsx(mL,{provider:e,pending:H,clock:r,busy:!!n,onSubmitCode:K}),u.jsxs("div",{className:"account-dialog-inline-actions",children:[X?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 F=t.lastExternalSwitch??null,he=F?t.profiles.find(H=>H.id===F.fromProfileId&&H.id!==t.activeProfileId):void 0,Q=F?.toProfileId?t.profiles.find(H=>H.id===F.toProfileId):void 0,ee=he?u.jsxs("div",{className:"account-dialog-running",role:"status",children:[u.jsx("strong",{children:Q?`${Y} on this server was switched to ${Q.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:[he.label," is still saved. Restart old ",Y," sessions, then press Use on ",he.label,"."]})]}):null,ie=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,J=t.application?.profileId===t.activeProfileId&&t.application.state==="pending";return u.jsxs(u.Fragment,{children:[I,ee,ie,J?u.jsxs("p",{className:"account-dialog-error",role:"status",children:["Account saved; CLI setup is pending. ",t.application?.reason==="sessions_running"?`Exit existing ${Y} sessions, then press Apply again.`:t.application?.reason==="daemon_unverified"?"The shared Codex daemon could not be safely released. Exit its sessions, then press Apply again.":"CLI setup could not be verified. Your credentials are saved. Press Apply to retry."]}):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:S,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(H=>{const X=H.id===t.activeProfileId,M=XA(H,r);return u.jsxs("article",{className:`account-profile${X?" account-profile--active":""}${M?" account-profile--relogin":""}`,children:[u.jsxs("div",{children:[u.jsx(hL,{profile:H,pending:n===`rename:${H.id}`,disabled:!!n,onRename:R=>b(H.id,R)}),H.email&&H.email!==H.label?u.jsx("small",{className:"account-profile-email",title:H.email,children:H.email}):null,u.jsxs("small",{title:xL(H.expiresAt),children:[X?J?"Selected (setup pending)":"Active":"Saved"," · ",wL(H.expiresAt,r)," · ",CL(H.updatedAt,r)]}),u.jsx(yL,{refresh:H.refresh,clock:r}),M?u.jsxs("div",{className:"account-relogin",role:"status","aria-label":`${H.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(M)}),u.jsxs("button",{type:"button",className:"primary-button",title:`Sign in to ${H.label} again; its saved name is kept`,disabled:!!n,onClick:()=>x(H),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:X?`Apply ${H.label} to new CLI sessions`:`Use ${H.label}`,disabled:!!n||X&&t.application?.state==="ready",onClick:()=>p(H.id),children:[u.jsx(kA,{size:14,"aria-hidden":"true"}),X?"Apply":"Use"]}),u.jsxs("button",{type:"button",title:X&&q?t.processCheckUnavailable?"Credential refresh deferred: process check unavailable":"Managed by running CLI":"Refresh OAuth credentials (rotates tokens); does not reset usage limits",disabled:X&&q||!!n,onClick:()=>w(H.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 ${H.label}`,title:`Remove ${H.label}`,disabled:!!n||X,onClick:()=>_(H.id),children:u.jsx(BA,{size:14,"aria-hidden":"true"})})]}),u.jsx(bL,{usage:o[H.id],loading:l,stale:d,clock:r})]},H.id)})]})]})}function hL({profile:e,pending:t,disabled:n,onRename:r}){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 w(){if(o===null||!d.current||f.current)return;if(o.trim()===e.label){_();return}f.current=!0;const S=await r(o);f.current=!1,d.current&&(S?_():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(rT,{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:S=>S.currentTarget.select(),onChange:S=>l(S.target.value),onKeyDown:S=>{S.key==="Enter"?(S.preventDefault(),w()):S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),_())},onBlur:()=>{w()}}),t?u.jsx("small",{role:"status",children:"Saving..."}):null]})}const fL=2*6e4,pL=2e4;function mL({provider:e,pending:t,clock:n,busy:r,onSubmitCode:o}){const[l,d]=v.useState(""),[f,m]=v.useState(null),p=t.login??{phase:"starting"},b=e==="codex"?"Codex":"Claude",_=tL(e,p.verificationUrl),w=e==="codex"&&p.userCode&&/^[A-Z0-9-]{3,40}$/.test(p.userCode)?p.userCode:null,S=p.expiresAt?fy(p.expiresAt,n):null,x=p.phase==="starting"&&n-Date.parse(t.startedAt)>pL,E=p.recentOutput??[];async function L(A){A.preventDefault();const K=nL("claude",l);if(!K){m("Paste the complete code shown after approval, including the part after #.");return}m(null),await o(K),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(W1,{lines:E,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(W1,{lines:E})]}):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(gL,{url:_})]}),e==="codex"?u.jsxs("li",{children:[u.jsxs("span",{children:["Enter this one-time code",S?u.jsxs("small",{children:[" (expires ",S,")"]}):null,":"]}),w?u.jsx(vL,{code:w}):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:r||p.phase==="completing","aria-invalid":f?!0:void 0,placeholder:"code#state"})]}),u.jsx("button",{type:"submit",className:"primary-button",disabled:r||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 W1({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 gL({url:e}){const t=v.useRef(null),[n,r]=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:()=>{r(e,t.current)},children:[u.jsx(Xf,{size:14,"aria-hidden":"true"}),"Copy link"]}),n?u.jsx("small",{className:"account-login-copied",role:"status",children:n}):null]})]})}function vL({code:e}){const t=v.useRef(null),[n,r]=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:()=>{r(e,t.current)},children:[u.jsx(Xf,{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 r=v.useCallback(async(o,l)=>{const d=await _L(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,r]}async function _L(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,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.opacity="0",document.body.appendChild(r);try{if(r.select(),typeof document.execCommand=="function"&&document.execCommand("copy"))return"copied"}catch{}finally{r.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 bL({usage:e,loading:t,stale:n,clock:r}){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)||r-l>=fL||o.some(m=>m.resetsAt&&Date.parse(m.resetsAt)<=r)),f=!e&&t?"Checking weekly usage...":e?.status==="reauth_required"?"Weekly usage unavailable: sign-in required":e?.status==="unsupported"?"Weekly usage not provided":e?.code==="usage_authentication_required"?"Weekly usage unavailable: access token not accepted":"Weekly usage unavailable";return u.jsxs("div",{className:"account-quota","aria-label":"Account usage","aria-busy":t,title:"Read-only usage check; does not rotate credentials",children:[o.some(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:Qf(p.resetsAt),children:p.resetsAt&&Number.isFinite(Date.parse(p.resetsAt))?`Resets ${fy(p.resetsAt,r)}`:"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:Qf(e.checkedAt)})]}):"Not yet checked",d?u.jsx("span",{className:"account-quota-warning",children:"Stale"}):null,t&&e?u.jsx("span",{children:"Updating..."}):null]}),e?.code?u.jsx("small",{className:"account-diagnostic-code",children:e.code}):null]})}function yL({refresh:e,clock:t}){if(!e)return null;const n={success:"Credentials refreshed",retrying:"Credential refresh retrying",reauth_required:"Sign-in required",deferred:"Credential refresh deferred"},r=e.state==="deferred"&&e.code==="active_cli_refresh_deferred"?"Managed by running CLI":e.state==="deferred"&&e.code==="account_process_check_unavailable"?"Refresh deferred: process check unavailable":n[e.state];return u.jsxs("div",{className:`account-refresh-status account-refresh-status--${e.state}`,children:[u.jsxs("span",{children:[r,e.nextRetryAt?` · Next retry ${fy(e.nextRetryAt,t)}`:""]}),e.lastAttemptAt?u.jsxs("small",{children:["Last attempt ",Qf(e.lastAttemptAt)]}):null,e.lastSuccessAt?u.jsxs("small",{children:["Last success ",Qf(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 Qf(e){return e&&Number.isFinite(Date.parse(e))?new Date(e).toLocaleString():"Timestamp unavailable"}function fy(e,t){const n=Date.parse(e)-t;if(!Number.isFinite(n))return"time unavailable";if(n<=0)return"due now";const r=Math.ceil(n/6e4),o=Math.floor(r/1440),l=Math.floor(r%1440/60);return`in ${o?`${o}d `:""}${l?`${l}h `:""}${o?"":`${r%60}m`}`.trim()}function SL({provider:e}){return u.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function wL(e,t=Date.now()){if(!e||!Number.isFinite(Date.parse(e)))return"Access token expiry unavailable";const n=Math.ceil((Date.parse(e)-t)/6e4);if(n<=0)return"Access token expired";const r=Math.floor(n/1440),o=Math.floor(n%1440/60),l=n%60;return`Access token ${[r?`${r}d`:null,o?`${o}h`:null,`${l}m`].filter(Boolean).join(" ")} remaining`}function xL(e){return!e||!Number.isFinite(Date.parse(e))?"Access token expiry timestamp unavailable":`Access token expires ${new Date(e).toLocaleString()}`}function CL(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 K1(e){return e instanceof Fn?{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 kL(e){const t=new Map(e.map(l=>[l.pid,{process:l,children:[],count:1,cpuPercent:l.cpuPercent,memoryBytes:l.memoryBytes}])),n=[];for(const l of t.values()){const d=t.get(l.process.ppid);d&&d!==l?d.children.push(l):n.push(l)}const r=[...n],o=new Set;for(let l=0;l<r.length;l++){const d=r[l];o.add(d.process.pid);for(const f of d.children)r.push(f)}for(const l of t.values())o.has(l.process.pid)||(l.children=[],n.push(l));for(let l=r.length-1;l>=0;l--){const d=r[l];for(const f of d.children)d.count+=f.count,d.cpuPercent+=f.cpuPercent,d.memoryBytes+=f.memoryBytes}return n}const i_=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function TL({api:e,label:t,main:n,favorites:r,targets:o,onClose:l,onFavorite:d,onTarget:f,getRuntimeStatus:m,targetStatus:p}){const[b,_]=v.useState(null),[w,S]=v.useState(null),[x,E]=v.useState(!0),[L,A]=v.useState(!0),[K,P]=v.useState(null),[z,q]=v.useState(!1),[Y,I]=v.useState(null),[F,he]=v.useState(""),[Q,ee]=v.useState(!1),[ie,J]=v.useState(null),H=v.useRef(null),X=v.useRef(l);X.current=l;const M=v.useRef(!0);async function R(Z=!1){E(!0);try{const Te=await e.getServerExternalIp(Z);M.current&&_(Te)}catch{M.current&&_(Te=>({address:Te?.address??null,checkedAt:Te?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{M.current&&E(!1)}}async function B(){A(!0),P(null);try{const Z=await e.getServerProcesses();M.current&&S(Z)}catch{M.current&&P("Could not retrieve processes. The server may be offline or need an update.")}finally{M.current&&A(!1)}}v.useEffect(()=>(M.current=!0,R(),B(),()=>{M.current=!1}),[e]),v.useEffect(()=>{const Z=document.activeElement;H.current?.focus();const Te=ye=>{if(ye.key==="Escape"){ye.preventDefault(),ye.stopImmediatePropagation(),X.current();return}if(ye.key==="Tab"){const He=[...H.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(Ie=>Ie.getClientRects().length>0),Ke=He.indexOf(document.activeElement);He.length&&(Ke<0||(ye.shiftKey?Ke===0:Ke===He.length-1))&&(ye.preventDefault(),He[ye.shiftKey?He.length-1:0]?.focus()),ye.stopPropagation();return}H.current?.contains(ye.target)||(ye.preventDefault(),ye.stopImmediatePropagation())};return window.addEventListener("keydown",Te,!0),()=>{window.removeEventListener("keydown",Te,!0),Z instanceof HTMLButtonElement&&Z.isConnected&&Z.focus({preventScroll:!0})}},[]);async function oe(Z){try{await navigator.clipboard.writeText(Z),q(!1)}catch{q(!0)}}async function ge(Z){if(!(Q||!F.trim())){ee(!0),J(null);try{const Te=await e.renameServerProject(Z,F.trim());if(!M.current)return;S(ye=>ye&&{...ye,projects:ye.projects.map(He=>He.path===Z?{...He,name:Te.name}:He)}),I(null)}catch{M.current&&J("Could not save project name.")}finally{M.current&&ee(!1)}}}const N=v.useMemo(()=>w?.projects.filter(Z=>Z.category!=="services")??[],[w]),V=v.useMemo(()=>{const Z=w?.projects.filter(Te=>Te.category==="services")??[];return N.length?[...Z,{name:"Development tools",path:"",category:"tools",cpuPercent:N.reduce((Te,ye)=>Te+ye.cpuPercent,0),memoryBytes:N.reduce((Te,ye)=>Te+ye.memoryBytes,0),processes:N.flatMap(Te=>Te.processes)}]:Z},[w,N]);function re(Z){const Te=Z.path?o.filter(ye=>ye.cwd===Z.path||ye.cwd.startsWith(Z.path.replace(/\/$/,"")+"/")):[];return u.jsxs(u.Fragment,{children:[Z.category!=="services"&&u.jsxs("div",{className:"server-info-tool-name",children:[u.jsx(DA,{size:15,"aria-hidden":"true"}),u.jsx("strong",{children:Z.path?Z.name:"Shared tools"})]}),u.jsxs("div",{className:"server-info-path",children:[u.jsx("code",{children:Z.path||"Shared across projects"}),Z.path&&u.jsxs(u.Fragment,{children:[u.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{oe(Z.path)},children:u.jsx(Xf,{size:14})}),u.jsx("button",{disabled:L||Q,title:"Rename project","aria-label":`Rename ${Z.name}`,onClick:()=>{I(`${Z.category}:${Z.path}`),he(Z.name),J(null)},children:u.jsx(rT,{size:14})})]})]}),Y===`${Z.category}:${Z.path}`&&u.jsxs("form",{className:"server-info-rename",onSubmit:ye=>{ye.preventDefault(),ge(Z.path)},children:[u.jsx("input",{"aria-label":"Project display name",maxLength:80,value:F,disabled:Q,onChange:ye=>he(ye.target.value)}),u.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:Q||!F.trim(),children:u.jsx(qk,{size:16})}),u.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:Q,onClick:()=>I(null),children:u.jsx(Zf,{size:16})}),ie&&u.jsx("small",{role:"alert",className:"server-info-error",children:ie})]}),Z.path&&u.jsx("div",{className:"server-info-targets",children:Te.length?Te.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(EL,{processes:Z.processes})]})}return u.jsx("div",{className:"server-info-backdrop",onMouseDown:Z=>{Z.target===Z.currentTarget&&l()},children:u.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:H,onKeyDown:Z=>Z.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(Zf,{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:()=>{oe(b.address)},children:u.jsx(Xf,{size:16})}),u.jsx("button",{disabled:x,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{R(!0)},children:u.jsx(jc,{size:16})})]})]}),b?.error&&u.jsx("p",{role:"status",className:"server-info-error",children:b.error})]}),u.jsxs("section",{children:[u.jsx("h3",{children:"Favorites"}),u.jsx("div",{className:"server-info-favorites",children:r.map(Z=>u.jsxs("button",{onClick:()=>d(Z),children:[u.jsx("strong",{children:Z.tabName}),u.jsxs("small",{children:[Z.workspaceName," · ",m?.(Z)?.state??"Not loaded"]}),u.jsx("span",{children:Z.providers.map(Te=>u.jsx("img",{alt:Te,src:`/brand/${Te}.webp`},Te))})]},`${Z.workspaceId}:${Z.tabId}`))}),!r.length&&u.jsx("small",{children:"No favorite tabs on this server."})]}),u.jsxs("section",{children:[u.jsxs("div",{className:"server-info-heading",children:[u.jsx("h3",{children:"Projects"}),u.jsx("button",{disabled:L||Q,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{B()},children:u.jsx(jc,{size:16})})]}),L&&u.jsx("p",{role:"status",children:"Sampling processes..."}),K&&u.jsx("p",{role:"alert",className:"server-info-error",children:K}),w&&u.jsxs("small",{children:["Sampled ",new Date(w.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),V.map(Z=>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:Z.name,children:Z.name}),u.jsx("small",{className:"server-info-project-location",title:Z.path,children:Z.path}),u.jsx("small",{className:"server-info-project-count",title:`${Z.processes.length} processes`,children:Z.processes.length})]}),u.jsxs("span",{className:"server-info-metrics",children:[u.jsxs("span",{children:[Z.cpuPercent.toFixed(1),"%"]}),u.jsx("span",{children:i_(Z.memoryBytes)})]})]}),u.jsx("div",{className:"server-info-project-body",children:Z.category==="services"?re(Z):N.map(Te=>u.jsx("div",{className:"server-info-tool-project",children:re(Te)},`${Te.category}:${Te.path}`))})]},`${Z.category}:${Z.path}`)),w&&!w.projects.length&&u.jsx("p",{children:"No processes found for the runtime user."})]}),z&&u.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function EL({processes:e}){const t=v.useMemo(()=>kL(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:i_(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:i_(t.memoryBytes)})]})]}),e.children.map(r=>u.jsx(gT,{node:r},r.process.pid))]})]}):u.jsx("div",{className:"server-info-process",children:n})}function vT({children:e,className:t}){const[n,r]=v.useState(!1),[o,...l]=Ht.Children.toArray(e);return u.jsxs("details",{className:t,onToggle:d=>{d.target===d.currentTarget&&r(d.currentTarget.open)},children:[o,n?l:null]})}function RL({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[l,d]=v.useState(!1),[f,m]=v.useState(null),[p,b]=v.useState(""),[_,w]=v.useState("");async function S(){try{const[A,K,P]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(K.networks),d(P.totpEnabled),m(null)}catch(A){m(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{S()},[]);async function x(A){await e.revokeDevice(A),await S()}async function E(A){await e.removeNetwork(A),await S()}async function L(A){A.preventDefault(),m(null);try{await e.addNetwork({value:p.trim(),label:_.trim()}),b(""),w(""),await S()}catch(K){m(K instanceof Error?K.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."}),r.length===0?u.jsx("p",{className:"muted",children:"No trusted networks."}):u.jsx("ul",{className:"security-list",children:r.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:()=>{E(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=>w(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 S()},children:"Disable 2FA"})]}):null]})}const NL=1500,py="nterminal.terminal.fontSize",my="nterminal.terminal.fontFamily",s_="nterminal:terminal-font-size",r_="nterminal:terminal-font-family",a_=11,o_=20,dl=14,Jf=[{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:[]}],Oc="meslo";l_(Oc);async function Qg(e=dl,t=Oc){if(typeof document>"u"||!document.fonts)return;const n=yT(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,NL)})])}function _T(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return dl;const n=Math.round(t);return Math.max(a_,Math.min(o_,n))}function bT(e){return Jf.some(t=>t.id===e)?e:Oc}function l_(e){return yT(e).cssFamily}function yT(e){return Jf.find(t=>t.id===e)??Jf[0]}function c_(){if(typeof window>"u")return dl;try{const e=window.localStorage.getItem(py);return e?_T(e):dl}catch{return dl}}function u_(){if(typeof window>"u")return Oc;try{return bT(window.localStorage.getItem(my))}catch{return Oc}}function of(e){const t=_T(e);if(typeof window>"u")return t;try{window.localStorage.setItem(py,String(t))}catch{}return window.dispatchEvent(new CustomEvent(s_,{detail:t})),t}function DL(e){const t=bT(e);if(typeof window>"u")return t;try{window.localStorage.setItem(my,t)}catch{}return window.dispatchEvent(new CustomEvent(r_,{detail:t})),t}function ST(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===py&&e()};return window.addEventListener(s_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(s_,e),window.removeEventListener("storage",t)}}function wT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===my&&e()};return window.addEventListener(r_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(r_,e),window.removeEventListener("storage",t)}}const Ed=3,xT=1,CT=5,kT=30;function gy(e){return Number.isFinite(e)?Math.max(xT,Math.min(CT,Math.round(e))):Ed}function ML(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,(r,o)=>{const l=Number(o)&-29;return l===64||l===65?r.repeat(n):r})}class AL{remainder=0;direction=0;scale=0;reset(){this.remainder=0,this.direction=0,this.scale=0}consume(t,n,r){if(!Number.isFinite(t)||!Number.isFinite(n)||n<=0)return this.reset(),0;if(t===0)return 0;const o=gy(r)/(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 vy="nterminal.terminal.showScrollProgress",d_="nterminal:terminal-scroll-progress",_y="nterminal.terminal.tmuxScrollback.shell",by="nterminal.terminal.tmuxScrollback.agent",yy="nterminal.terminal.tmuxScrollback.overrides",Bc="nterminal:terminal-tmux-scrollback",LL=200,ep="nterminal.terminal.codexScrollSpeed";let h_=Ed,tp=!1;function f_(){if(typeof window>"u")return Ed;if(tp)return h_;try{const e=window.localStorage.getItem(ep);return e===null||e.trim()===""?Ed:gy(Number(e))}catch{return h_}}function jL(e){const t=gy(e);if(h_=t,typeof window<"u"){try{window.localStorage.setItem(ep,String(t)),tp=!1}catch{tp=!0}window.dispatchEvent(new CustomEvent(Bc))}return t}function p_(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(vy)!=="false"}catch{return!0}}function OL(e){if(typeof window<"u"){try{window.localStorage.setItem(vy,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(d_,{detail:e}))}return e}function TT(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===vy&&e()};return window.addEventListener(d_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(d_,e),window.removeEventListener("storage",t)}}function m_(){return ET(_y,!0)}function BL(e){return RT(_y,e,Bc)}function g_(){return ET(by,!0)}function IL(e){return RT(by,e,Bc)}function td(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===ep||n.key===null)&&(tp=!1),(n.key===_y||n.key===by||n.key===ep||n.key===null||n.key===yy)&&e()};return window.addEventListener(Bc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bc,e),window.removeEventListener("storage",t)}}function Jg(e){const n=NT()[e];return typeof n=="boolean"?n:null}function PL(e,t){if(typeof window<"u"){try{const n=NT(),r=Object.entries(n).filter(([l])=>l!==e);r.push([e,t]);const o=r.slice(-LL);window.localStorage.setItem(yy,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Bc,{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(yy);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const Sy="nterminal.shortcuts.workspace.v1",v_="nterminal:workspace-shortcuts",Rd=[{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":wn("ArrowUp",{ctrlKey:!0}),"server.next":wn("ArrowDown",{ctrlKey:!0}),"tab.previous":wn("ArrowLeft",{ctrlKey:!0}),"tab.next":wn("ArrowRight",{ctrlKey:!0}),"tab.index":wn("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":wn("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":wn("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":wn("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":wn("KeyH",{altKey:!0}),"subagents.toggle":wn("KeyA",{altKey:!0}),"scrollback.toggle":wn("KeyS",{altKey:!0}),"favorites.toggle":wn("KeyF",{ctrlKey:!0,altKey:!0})},zL={"server.previous":wn("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":wn("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":wn("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":wn("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":wn("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":wn("Digit",{ctrlKey:!0,altKey:!0}),"split.right":wn("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":wn("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":wn("KeyH",{altKey:!0}),"subagents.toggle":wn("KeyA",{altKey:!0}),"scrollback.toggle":wn("KeyS",{altKey:!0}),"favorites.toggle":wn("KeyF",{ctrlKey:!0,altKey:!0})};function vl(){const e=AT(zp);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Sy);if(!t)return e;const n=JSON.parse(t);for(const r of Rd){const o=n[r.id];if(VL(o)){const l=LT(o,r);qL(l,zL[r.id])||(e[r.id]=l)}}}catch{return e}return e}function q1(){return JSON.stringify(vl())}function HL(e,t){const n=vl(),r=Rd.find(o=>o.id===e);return r&&(n[e]=LT(t,r),wy(n)),n}function UL(e){const t=vl();return t[e]={...zp[e]},wy(t),t}function $L(){const e=AT(zp);return wy(e),e}function _d(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Sy&&e()};return window.addEventListener(v_,e),window.addEventListener("storage",t),()=>{window.removeEventListener(v_,e),window.removeEventListener("storage",t)}}function FL(e,t){const n=BT(e);return!n||GL(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=vl();for(const n of Rd){const r=t[n.id];if(!(!r||!YL(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=OT(e);if(o!==null)return{id:n.id,index:o};continue}if(BT(e)===r.code)return{id:n.id,index:null}}}return null}function bd(e){return MT(vl()[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(XL(e.code)),t.join("+")}const WL=()=>bd("split.right"),KL=()=>bd("split.down");function wn(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 qL(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function wy(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Sy,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(v_))}}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 VL(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 YL(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 GL(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function XL(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 ZL="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 QL(e="nterminal",t=new Date){return{reason:"permission",message:ZL,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function JL(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,ej="local",__=new Set,vo=new Map;let ko={checking:!1,hasUpdates:!1,lastCheckedAt:null},xy=null,yd=null,np=0,uo=null;function tj(e){return __.add(e),()=>{__.delete(e)}}function V1(){return ko}function nj(e){const t=oj();xy=e,Cy(),b_(e,t);const n=()=>{if(document.visibilityState!=="visible"||!To(e,t))return;const r=ko.lastCheckedAt;(r===null||Date.now()-r>=IT)&&b_(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),To(e,t)&&aj()}}function ij(e,t){vo.set(e,PT(t)),Ic({...ko,hasUpdates:ky(),lastCheckedAt:Date.now()})}function ev(e){e===void 0?vo.clear():vo.set(e,!1),Ic({...ko,hasUpdates:ky()})}async function b_(e,t){if(!To(e,t))return;if(uo&&uo.api===e&&uo.runId===t)return uo.promise;Ic({...ko,checking:!0});const n=sj(e,t).finally(()=>{uo?.promise===n&&(uo=null),To(e,t)&&(Ic({...ko,checking:!1,lastCheckedAt:Date.now()}),rj(e,t))});return uo={api:e,runId:t,promise:n},n}async function sj(e,t){try{const n=await e.listAgents();if(!To(e,t))return;const r=[{key:ej,check:()=>e.checkUpdate()},...n.agents.map(l=>({key:l.id,check:()=>e.checkAgentUpdate(l.id)}))],o=new Map;if(await Promise.all(r.map(async l=>{try{const d=await l.check();o.set(l.key,PT(d))}catch{o.set(l.key,vo.get(l.key)??!1)}})),!To(e,t))return;vo.clear();for(const[l,d]of o)vo.set(l,d);Ic({...ko,hasUpdates:ky()})}catch{}}function rj(e,t){To(e,t)&&(Cy(),yd=window.setTimeout(()=>{yd=null,To(e,t)&&b_(e,t)},IT))}function aj(){np+=1,Cy(),xy=null,uo=null,vo.clear(),Ic({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Cy(){yd!==null&&(window.clearTimeout(yd),yd=null)}function oj(){return np+=1,np}function To(e,t){return xy===e&&np===t}function PT(e){return e.updateAvailable===!0}function ky(){return Array.from(vo.values()).some(Boolean)}function Ic(e){ko=e;for(const t of Array.from(__))t()}const lj=e=>new Promise(t=>setTimeout(t,e));function cj({api:e,onAgentRemoved:t}){const[n,r]=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),[w,S]=v.useState({});function x(R,B){l(oe=>({...oe,[R]:{...oe[R],...B}}))}function E(R,B){S(oe=>({...oe,[R]:{status:oe[R]?.status??null,busy:oe[R]?.busy??!1,error:oe[R]?.error??null,...B}}))}const L=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),A=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),K=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),P=R=>R.id===null?e:pr(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async B=>{if(R)return;let oe="Local";try{oe=(await e.getMainInfo()).name?.trim()||oe}catch{}if(R)return;const ge=new Map(B.agents.map(V=>[V.id,V])),N=ua(B.serverOrder,B.agents).flatMap(V=>{if(V===Jt)return[{key:"local",id:null,name:oe}];const re=ge.get(V);return re?[{key:re.id,id:re.id,name:re.name}]:[]});r(N);for(const V of N)L(V).then(re=>x(V.key,{version:re,manualUpdate:re.manualUpdate??null})).catch(re=>x(V.key,{error:re instanceof Error?re.message:"unreachable"})),H(V)}).catch(()=>{}),()=>{R=!0}},[]);async function z(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const B=await A(R);ij(R.key,B),x(R.key,{latestVersion:B.latestVersion,updateAvailable:B.updateAvailable,status:ee(B),...B.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(B){x(R.key,{busy:!1,error:B instanceof Error?B.message:"check failed"})}}async function q(){f(!0),await Promise.all(n.map(R=>z(R))),f(!1)}async function Y(R,B){const oe=Date.now()+18e4;for(;Date.now()<oe;){await lj(3e3);try{const ge=await L(R);if(B&&ge.runningVersion!==B.runningVersion)return ge}catch{}}return null}async function I(R){let B=o[R.key]?.version;if(!B)try{B=await L(R),x(R.key,{version:B,manualUpdate:B.manualUpdate??null})}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let oe;try{oe=await K(R)}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!oe.ok){const N=oe.manualUpdate??(JL(oe.message)?QL():null);return N?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(x(R.key,{busy:!1,status:void 0,error:oe.message}),"failed")}if(!oe.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),ev(R.key),"unchanged";x(R.key,{status:"restarting…"});const ge=await Y(R,B);return ge?(x(R.key,{busy:!1,version:ge,updateAvailable:!1,status:"updated",manualUpdate:ge.manualUpdate??null}),ev(R.key),R.id===null&&(_(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(x(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function F(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
16
|
+
`)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const oe=await e.uninstallAgent(R.id);r(ge=>ge.filter(N=>N.key!==R.key)),l(ge=>{const N={...ge};return delete N[R.key],N}),ev(R.key),t?.(R.id),p(oe.message)}catch(oe){x(R.key,{busy:!1,status:void 0,error:oe instanceof Error?oe.message:"delete failed"})}}}async function he(){f(!0),p(null);const R=n.filter(re=>re.id!==null),B=n.find(re=>re.id===null),oe=await Promise.all(R.map(re=>I(re))),ge=oe.filter(re=>re==="failed").length;let N=oe.filter(re=>re==="manual").length,V=null;if(B&&(V=await I(B),V==="manual"&&(N+=1),V==="updated")){ge>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}ge>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):ge>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 Q(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function ee(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function ie(R){const B=R?.version;return B?`npm package v${B.runningVersion}`:""}async function J(R,B){try{await dj(B),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(oe){x(R,{error:oe instanceof Error?oe.message:"copy failed"})}}async function H(R,B=!1){try{const oe=await P(R).getCodeServerStatus(B?{checkLatest:!0}:void 0);E(R.key,{status:oe,error:null})}catch(oe){E(R.key,{error:oe instanceof Error?oe.message:"code-server status failed"})}}async function X(R,B){if(B==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const oe=P(R);E(R.key,{busy:!0,error:null});try{if(B==="install"){const ge=await oe.installCodeServer();E(R.key,{status:ge.status})}else if(B==="update"){const ge=await oe.updateCodeServer();E(R.key,{status:ge.status})}else{const ge=await oe.uninstallCodeServer();E(R.key,{status:ge.status})}}catch(ge){E(R.key,{error:ge instanceof Error?ge.message:"code-server action failed"})}finally{E(R.key,{busy:!1})}}const M=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(oe=>w[oe.key]?.status?.job?.status==="running");if(R.length===0)return;const B=window.setInterval(()=>{for(const oe of R)H(oe)},1e3);return()=>window.clearInterval(B)},[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:()=>{he()},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(R=>{const B=o[R.key],oe=ie(B),ge=B?.manualUpdate??null,N=w[R.key]??{status:null,busy:!1,error:null},V=B?.version!==void 0&&B?.updateAvailable!==!1&&!B?.busy&&!d,re=R.id!==null&&!B?.busy&&!d;return u.jsxs("li",{children:[u.jsxs("div",{className:"server-row-main",children:[u.jsxs("div",{children:[u.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?u.jsx("span",{className:"security-badge",children:"Main"}):null]}),u.jsxs("span",{className:"security-item-meta",children:[oe?`${oe} — `:"",Q(B)]})]}),ge?u.jsxs("div",{className:"server-manual-update",children:[u.jsx("span",{children:ge.message}),u.jsxs("div",{className:"server-manual-command",children:[u.jsx("code",{children:ge.command}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{J(R.key,ge.command)},children:B?.copiedCommand?"Copied":"Copy"})]})]}):null,u.jsx(uj,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{H(R,!0)},onInstall:()=>{X(R,"install")},onUpdate:()=>{X(R,"update")},onUninstall:()=>{X(R,"uninstall")}})]}),u.jsxs("div",{className:"server-row-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{I(R)},disabled:!V,children:B?.busy?"…":"Update"}),R.id!==null?u.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{F(R)},disabled:!re,children:"Delete"}):null]})]},R.key)})})]})}function uj({status:e,busy:t,error:n,onCheck:r,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,w=e===null&&!n;return u.jsxs("div",{className:"server-code-addon-inline",children:[u.jsxs("div",{className:"server-code-addon-summary",children:[u.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),u.jsxs("span",{className:"security-item-meta",children:[_?w?"checking...":b?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?u.jsx("p",{className:"settings-error",children:n}):null,f?u.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,u.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[u.jsx("a",{className:"server-code-addon-icon-button",href:"https://github.com/coder/code-server",target:"_blank",rel:"noreferrer",title:"Open code-server on GitHub","aria-label":"Open code-server on GitHub",children:"↗"}),b?u.jsxs(u.Fragment,{children:[e?.updateAvailable?u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:l,disabled:t||m||!_,title:"Update code-server","aria-label":"Update code-server",children:"↑"}):u.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:r,disabled:t||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||w||t||m||!_,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function dj(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 lf=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function hj({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const l=v.useMemo(()=>t??kp(),[t]),[d,f]=v.useState(()=>c_()),[m,p]=v.useState(()=>u_()),[b,_]=v.useState(()=>p_()),[w,S]=v.useState(()=>m_()),[x,E]=v.useState(()=>g_()),[L,A]=v.useState(()=>f_()),[K,P]=v.useState(()=>xo()),[z,q]=v.useState(()=>vl()),[Y,I]=v.useState(null),[F,he]=v.useState(null),[Q,ee]=v.useState("appearance"),[ie,J]=v.useState(()=>uy()),[H,X]=v.useState(()=>gl()),[M,R]=v.useState(()=>Wc()),[B,oe]=v.useState([]),[ge,N]=v.useState([]),[V,re]=v.useState([]),[Z,Te]=v.useState(5*1024*1024),[ye,He]=v.useState(!1),[Ke,Ie]=v.useState(null),[_e,We]=v.useState(null),[Oe,j]=v.useState(!1),[me,Me]=v.useState(null),[ze,W]=v.useState(null),pe=v.useRef(null),Ce=v.useRef(null),Ne=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),Le=v.useMemo(()=>new Set(ge),[ge]),ve=!pj(ge,V),Pe=v.useMemo(()=>Pp(),[]),$e=_e?.displayMode==="standalone"&&(_e.deviceKind==="mobile"||_e.deviceKind==="tablet");v.useEffect(()=>ST(()=>f(c_())),[]),v.useEffect(()=>wT(()=>p(u_())),[]),v.useEffect(()=>TT(()=>_(p_())),[]),v.useEffect(()=>td(()=>{S(m_()),E(g_()),A(f_())}),[]),v.useEffect(()=>Gb(()=>P(xo())),[]),v.useEffect(()=>_d(()=>q(vl())),[]),v.useEffect(()=>Lk(()=>X(gl())),[]),v.useEffect(()=>{if(!Y)return;const ae=Rd.find(Qe=>Qe.id===Y);if(!ae)return;const Fe=Qe=>{if(Qe.preventDefault(),Qe.stopPropagation(),Qe.key==="Escape"){I(null),he(null);return}const St=FL(Qe,ae);if(!St){he(fj(ae));return}q(HL(Y,St)),I(null),he(null)};return window.addEventListener("keydown",Fe,!0),()=>window.removeEventListener("keydown",Fe,!0)},[Y]),v.useEffect(()=>{let ae=!1;return l.listNotificationAssets().then(Fe=>{ae||at(Fe)}).catch(Fe=>{ae||Ie(_c(Fe))}),()=>{ae=!0}},[l]),v.useEffect(()=>{let ae=!1;return l.getPushNotificationStatus(ha()).then(Fe=>{ae||(We(Fe.currentDevice),Me(null))}).catch(Fe=>{ae||Me(_c(Fe))}),()=>{ae=!0}},[l]);function Be(ae){f(of(Number(ae)))}function ut(ae){X(R1(Number(ae)))}function ht(ae){ee(ae);const Fe=Ce.current,Qe=Ne.current[ae];if(!Fe||!Qe)return;const St=Math.max(0,Y1(Qe,Fe)-12);typeof Fe.scrollTo=="function"?Fe.scrollTo({top:St,behavior:"smooth"}):Fe.scrollTop=St}function vt(){const ae=Ce.current;if(!ae)return;if(ae.scrollTop+ae.clientHeight>=ae.scrollHeight-2){ee(lf[lf.length-1].id);return}let Fe="appearance";const Qe=ae.scrollTop+Math.min(180,Math.max(48,ae.clientHeight*.28));for(const St of lf){const Ut=Ne.current[St.id];Ut&&Y1(Ut,ae)<=Qe&&(Fe=St.id)}ee(Fe)}function Rt(ae){q(UL(ae)),I(null),he(null)}function cn(){q($L()),I(null),he(null)}function at(ae){const Fe=ae.assets.filter(Qe=>Qe.enabled).map(Qe=>Qe.id);oe(ae.assets),N(Fe),re(Fe),Te(ae.maxFileBytes),Ie(null)}async function Wn(){if(ie){E1(!1),J(!1);return}let ae=M;ae==="default"&&(ae=await Ok(),R(ae)),ae==="granted"&&(E1(!0),J(!0))}async function kn(){j(!0),Me(null),W(null);try{if(_e)await rA(l),We(null);else{await nA(l,!1);const ae=await l.getPushNotificationStatus(ha());We(ae.currentDevice)}}catch(ae){Me(nv(ae))}finally{j(!1)}}async function _t(ae){j(!0),Me(null),W(null);try{await aA(l,ae);const Fe=await l.getPushNotificationStatus(ha());We(Fe.currentDevice)}catch(Fe){Me(nv(Fe))}finally{j(!1)}}async function jt(){j(!0),Me(null),W(null);try{await l.testPushNotification({clientId:ha()}),W("Test notification accepted by the push service.")}catch(ae){Me(nv(ae))}finally{j(!1)}}async function Nt(ae){const Fe=ae?.[0];if(Fe){if(Fe.size>Z){Ie(`File must be ${tv(Z)} or smaller.`),ui();return}if(Fe.type!=="video/mp4"&&Fe.type!=="video/webm"){Ie("Upload an MP4 or WebM video."),ui();return}He(!0),Ie(null);try{await l.uploadNotificationAsset(Fe),at(await l.listNotificationAssets()),r?.()}catch(Qe){Ie(_c(Qe))}finally{He(!1),ui()}}}async function pn(ae){He(!0),Ie(null);try{await l.deleteNotificationAsset(ae),at(await l.listNotificationAssets()),r?.()}catch(Fe){Ie(_c(Fe))}finally{He(!1)}}function ui(){pe.current&&(pe.current.value="")}function fn(ae,Fe){const Qe=new Set(ge);if(Fe?Qe.add(ae):Qe.delete(ae),Qe.size===0){Ie("Keep at least one toast video selected.");return}Ie(null),N(Array.from(Qe))}async function mn(){if(ge.length===0){Ie("Keep at least one toast video selected.");return}He(!0),Ie(null);try{const ae=await l.updateNotificationAssetSelection({enabledAssetIds:ge});at(ae),r?.()}catch(ae){Ie(_c(ae))}finally{He(!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:ae=>ae.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:lf.map(ae=>u.jsxs("button",{type:"button","data-active":Q===ae.id?"true":"false","aria-current":Q===ae.id?"true":void 0,onClick:()=>ht(ae.id),children:[ae.label,ae.id==="servers"&&n?u.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ae.id))}),u.jsxs("div",{ref:Ce,className:"settings-content",onScroll:vt,children:[u.jsxs("section",{id:"settings-appearance",ref:ae=>{Ne.current.appearance=ae},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:$f.map(ae=>u.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":K===ae.id,"data-active":K===ae.id?"true":"false",onClick:()=>P(NN(ae.id)),style:{"--settings-theme-bg":ae.tokens.bg,"--settings-theme-bg-2":ae.tokens.bg2,"--settings-theme-sidebar":ae.tokens.bgSidebar,"--settings-theme-line":ae.tokens.line,"--settings-theme-fg":ae.tokens.fg,"--settings-theme-fg-2":ae.tokens.fg2,"--settings-theme-accent":ae.tokens.accent,"--settings-theme-xterm-bg":ae.xterm.background,"--settings-theme-xterm-fg":ae.xterm.foreground,"--settings-theme-xterm-selection":ae.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:ae.label}),u.jsx("small",{children:ae.description})]})]},ae.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:a_,max:o_,step:1,value:d,"aria-label":"Terminal font size",onChange:ae=>Be(ae.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row",children:[u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(of(d-1)),children:"-"}),u.jsx("input",{type:"number",min:a_,max:o_,step:1,value:d,"aria-label":"Terminal font size value",onChange:ae=>Be(ae.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(of(d+1)),children:"+"}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(of(dl)),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:ae=>p(DL(ae.currentTarget.value)),children:Jf.map(ae=>u.jsx("option",{value:ae.id,children:ae.label},ae.id))})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:b,onChange:ae=>_(OL(ae.currentTarget.checked))}),"Show scroll progress"]}),u.jsx("div",{className:"settings-section-heading",children:u.jsxs("div",{children:[u.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),u.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:w,onChange:ae=>S(BL(ae.currentTarget.checked))}),"Shell panes"]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:x,onChange:ae=>E(IL(ae.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:ae=>A(jL(Number(ae.currentTarget.value)))})]})]}),u.jsxs("section",{id:"settings-shortcuts",ref:ae=>{Ne.current.shortcuts=ae},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:cn,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."}),F?u.jsx("p",{className:"settings-error",children:F}):null,u.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Rd.map(ae=>{const Fe=Y===ae.id;return u.jsxs("li",{children:[u.jsxs("div",{children:[u.jsx("span",{className:"settings-shortcut-label",children:ae.label}),u.jsx("span",{className:"settings-shortcut-group",children:ae.group})]}),u.jsxs("div",{className:"settings-shortcut-actions",children:[u.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Fe?"true":"false",onClick:()=>{I(ae.id),he(null)},children:Fe?"Press keys…":MT(z[ae.id])}),u.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Rt(ae.id),children:"Reset"})]})]},ae.id)})})]}),u.jsxs("section",{id:"settings-notifications",ref:ae=>{Ne.current.notifications=ae},className:"security-section settings-section",children:[u.jsx("h3",{children:"Notifications"}),Ip()?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:ie&&M==="granted",onChange:()=>{Wn()},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:!!_e,onChange:()=>{kn()},disabled:Oe||!Pe.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."}),Pe.supported?null:u.jsx("p",{className:"muted",children:kf(Pe.reason)}),_e?u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"muted",children:["Registered as ",_e.label,". Last active ",new Date(_e.lastActiveAt).toLocaleString(),"."]}),u.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{jt()},disabled:Oe,children:"Send test notification"})]}):null,$e?u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:_e?.alwaysNotify===!0,onChange:ae=>{_t(ae.currentTarget.checked)},disabled:Oe||!_e}),"Always notify this mobile device"]}):null,me?u.jsx("p",{className:"form-error",children:me}):null,ze?u.jsx("p",{className:"muted",role:"status",children:ze}):null]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:H.enabled,onChange:ae=>X(VM(ae.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:H.persistUntilDismissed?"Until closed":`${H.durationSeconds}s`}),u.jsx("input",{type:"range",min:Xv,max:Zv,step:.5,value:H.durationSeconds,disabled:!H.enabled||H.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ae=>ut(ae.currentTarget.value)})]}),u.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[u.jsx("input",{type:"number",min:Xv,max:Zv,step:.5,value:H.durationSeconds,disabled:!H.enabled||H.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ae=>ut(ae.currentTarget.value)}),u.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!H.enabled||H.persistUntilDismissed,onClick:()=>X(R1(vd)),children:"Reset"})]}),u.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[u.jsx("input",{type:"checkbox",checked:H.persistUntilDismissed,disabled:!H.enabled,onChange:ae=>X(YM(ae.currentTarget.checked))}),"Keep toast until dismissed"]}),u.jsxs("div",{className:"settings-assets-header",children:[u.jsx("span",{children:"Toast videos"}),u.jsxs("span",{children:[tv(Z)," max"]})]}),u.jsx("input",{ref:pe,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ae=>{Nt(ae.currentTarget.files)}}),u.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ye,onClick:()=>pe.current?.click(),children:"Upload video"}),Ke?u.jsx("p",{className:"settings-error",children:Ke}):null,B.length>0?u.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:B.map(ae=>u.jsxs("li",{"data-enabled":Le.has(ae.id)?"true":"false",children:[u.jsxs("label",{className:"settings-asset-choice",children:[u.jsx("input",{type:"checkbox",checked:Le.has(ae.id),disabled:ye,"aria-label":`Use ${ae.filename}`,onChange:Fe=>fn(ae.id,Fe.currentTarget.checked)}),u.jsx("video",{src:ae.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),u.jsxs("span",{className:"settings-asset-copy",children:[u.jsx("span",{children:ae.filename}),u.jsx("small",{children:ae.source==="built-in"?"Built-in":tv(ae.size)})]})]}),ae.source==="uploaded"?u.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ye,"aria-label":`Delete ${ae.filename}`,onClick:()=>{pn(ae.id)},children:"x"}):null]},ae.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||B.length===0||!ve,onClick:()=>{mn()},children:"Save selected videos"})]}),u.jsx("div",{id:"settings-security",ref:ae=>{Ne.current.security=ae},className:"settings-section-group",children:u.jsx(RL,{api:l})}),u.jsx("div",{id:"settings-servers",ref:ae=>{Ne.current.servers=ae},className:"settings-section-group",children:u.jsx(cj,{api:l,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Y1(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function tv(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 _c(e){return e instanceof Error?e.message:"Request failed."}function kf(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 nv(e){const t=_c(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?kf("not_standalone"):t==="insecure"?kf("insecure"):t==="not_mobile"?kf("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 fj(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 pj(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const mj="modulepreload",gj=function(e){return"/"+e},G1={},Ty=function(t,n,r){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=gj(p),p in G1)return;G1[p]=!0;const b=p.endsWith(".css"),_=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${_}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":mj,b||(w.as="script"),w.crossOrigin="",w.href=p,f&&w.setAttribute("nonce",f),document.head.appendChild(w),b)return new Promise((S,x)=>{w.addEventListener("load",S),w.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&l(f.reason);return t().catch(l)})},vj=v.lazy(()=>Ty(()=>import("./MarkdownPreview-DD_7eToU.js"),__vite__mapDeps([0,1])));function _j({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[l,d]=v.useState(null),[f,m]=v.useState(""),[p,b]=v.useState({}),[_,w]=v.useState(()=>new Set),[S,x]=v.useState(null),[E,L]=v.useState({type:"empty"}),[A,K]=v.useState("idle"),[P,z]=v.useState(null),q=v.useRef(null),Y=v.useRef(null),I=v.useRef(!1),F=v.useRef(0),he=v.useRef(null);he.current===null&&t&&(he.current=t);const Q=he.current,ee=r?yj(r):t?X1(t,n):null,ie=l?[l.rootPath,f].filter(Boolean).join("/"):"",J=S?.path??null;v.useEffect(()=>(I.current=!0,()=>{I.current=!1,F.current+=1,We()}),[]),v.useEffect(()=>{he.current=t,Y.current=null,H(ee)},[e]),v.useEffect(()=>{r&&ee!==Y.current&&X(r,ee)},[r,ee]),v.useEffect(()=>{if(r||!Q||t!==Q)return;const W=X1(Q,n);W!==Y.current&&M(Q,W)},[Q,t,n,r]);async function H(W=ee){if(r){await X(r,W);return}await M(t,W)}async function X(W,pe=ee){const Ce=Oe();if(Y.current=pe,We(),d(null),m(""),b({}),w(new Set),x(null),L({type:"empty"}),z(null),!W){K("idle");return}K("loading");try{const Ne=await e.createFileRoot({path:W});if(!j(Ce))return;d({rootToken:Ne.rootToken,rootPath:Ne.rootPath});const Le=await e.listFiles({rootToken:Ne.rootToken,path:""});if(!j(Ce))return;oe(Le),K("idle")}catch(Ne){j(Ce)&&(z(ra(Ne)),K("idle"))}}async function M(W,pe=ee){const Ce=Oe();if(Y.current=pe,We(),d(null),m(""),b({}),w(new Set),x(null),L({type:"empty"}),z(null),!W){K("idle");return}K("loading");try{const Ne=await e.createFileRoot({terminalId:W});if(!j(Ce))return;d({rootToken:Ne.rootToken,rootPath:Ne.rootPath});const Le=await e.listFiles({rootToken:Ne.rootToken,path:""});if(!j(Ce))return;oe(Le),K("idle")}catch(Ne){if(await me(Ne,Ce))return;j(Ce)&&(z(ra(Ne)),K("idle"))}}async function R(W=f,pe=l){if(!pe)return;const Ce=Oe();K("loading"),z(null);try{const Ne=await e.listFiles({rootToken:pe.rootToken,path:W});if(!j(Ce))return;oe(Ne),K("idle")}catch(Ne){if(await me(Ne,Ce))return;j(Ce)&&(z(ra(Ne)),K("idle"))}}async function B(){if(r){await X(r,ee);return}he.current=t,await M(t,ee)}function oe(W){b(pe=>({...pe,[W.path]:Sj(W.entries)}))}async function ge(W){if(!(!iv(W)||!l)){if(x(W),z(null),W.kind==="directory"){m(W.path),_e(),await V(W);return}if(m(il(W.path)),W.editable){await Z(W);return}W.previewKind!=="none"&&await ye(W,W.previewKind)}}async function N(W){if(!(!iv(W)||!l)){if(x(W),z(null),W.kind==="directory"){m(W.path),_e(),await V(W);return}if(m(il(W.path)),W.editable){await Te(W);return}W.previewKind!=="none"&&await ye(W,W.previewKind)}}async function V(W){if(_.has(W.path)){w(pe=>{const Ce=new Set(pe);return Ce.delete(W.path),Ce});return}w(pe=>new Set(pe).add(W.path)),await R(W.path)}function re(W,pe){W.key==="Enter"&&(W.preventDefault(),N(pe))}async function Z(W){if(!l)return;const pe=Oe();K("loading"),We();try{const Ce=await e.readFile({rootToken:l.rootToken,path:W.path});if(!j(pe))return;L({type:"text-preview",file:W,read:Ce}),K("idle")}catch(Ce){if(await me(Ce,pe))return;j(pe)&&(z(ra(Ce)),K("idle"))}}async function Te(W){if(!l)return;const pe=Oe();K("loading");try{await o({rootToken:l.rootToken,path:W.path,...t?{terminalId:t}:{}}),j(pe)&&K("idle")}catch(Ce){if(await me(Ce,pe))return;j(pe)&&(z(ra(Ce)),K("idle"))}}async function ye(W,pe){if(!l)return;const Ce=Oe();K("loading"),We();try{const Ne=await e.previewFile({rootToken:l.rootToken,path:W.path});if(!j(Ce))return;const Le=URL.createObjectURL(Ne);if(!j(Ce)){URL.revokeObjectURL(Le);return}q.current=Le,L({type:"preview",file:W,previewKind:pe,url:Le}),K("idle")}catch(Ne){if(await me(Ne,Ce))return;j(Ce)&&(z(ra(Ne)),K("idle"))}}async function He(W){if(!l)return;const pe=W==="file"?"New file":"New folder",Ce=window.prompt(pe,""),Ne=S?S.kind==="directory"?S.path:il(S.path):f,Le=Z1(Ce,Ne);if(Le){z(null);try{const ve=await e.createFileEntry({rootToken:l.rootToken,path:Le,kind:W});x(ve.entry),await R(Ne)}catch(ve){if(await me(ve))return;z(ra(ve))}}}async function Ke(){if(!l||!S)return;const W=window.prompt("Move selected entry",S.path),pe=Z1(W,"");if(!pe||pe===S.path)return;const Ce=il(S.path),Ne=il(pe);z(null);try{const Le=await e.moveFileEntry({rootToken:l.rootToken,sourcePath:S.path,destinationPath:pe});x(Le.entry),m(Le.entry.kind==="directory"?Le.entry.path:il(Le.entry.path)),_e(),await R(Ce),Ne!==Ce&&await R(Ne)}catch(Le){if(await me(Le))return;z(ra(Le))}}async function Ie(){if(!l||!S)return;const W=S.path,pe=il(W);z(null);try{const Ce=await e.previewDeleteFileEntry({rootToken:l.rootToken,path:S.path}),Ne=Ce.descendantCount>0?` and ${Ce.descendantCount} nested item${Ce.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Ce.path}${Ne}?`))return;await e.deleteFileEntry({rootToken:l.rootToken,path:S.path,previewToken:Ce.previewToken}),x(null),m(pe),w(Le=>{const ve=new Set(Le);for(const Pe of Le)(Pe===W||Pe.startsWith(`${W}/`))&&ve.delete(Pe);return ve}),_e(),await R(pe)}catch(Ce){if(await me(Ce))return;z(ra(Ce))}}function _e(){F.current+=1,We(),L({type:"empty"})}function We(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function Oe(){return F.current+=1,F.current}function j(W){return I.current&&W===F.current}async function me(W,pe){return wj(W)?(pe!==void 0&&!j(pe)||await H(ee),!0):!1}function Me(W,pe){const Ce=iv(W),Ne=W.kind==="directory"&&_.has(W.path),Le=p[W.path]??[],ve={"--file-tree-depth":pe};return u.jsxs(Ht.Fragment,{children:[u.jsxs("button",{type:"button",className:"file-entry-button","data-kind":W.kind,"data-expanded":Ne,"data-active":J===W.path,disabled:!Ce,style:ve,"aria-expanded":W.kind==="directory"?Ne:void 0,"aria-label":`${W.kind==="directory"?"Open folder":"Open file"} ${W.name}`,title:W.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ge(W)},onDoubleClick:()=>{N(W)},onKeyDown:Pe=>re(Pe,W),children:[u.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:W.kind==="directory"?Ne?"▾":"▸":""}),u.jsx("span",{className:"file-entry-name",children:W.name}),u.jsx("small",{children:bj(W)})]}),Ne?u.jsx("div",{className:"file-tree-children",role:"group",children:Le.map(Pe=>Me(Pe,pe+1))}):null]},W.path)}const ze=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:ie,children:ie||"No active pane"}),u.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[u.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{B()},children:"↻"}),u.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!l,onClick:()=>{He("file")},children:"+"}),u.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!l,onClick:()=>{He("directory")},children:"▣"})]})]}),P?u.jsx("div",{className:"file-explorer-alert",role:"alert",children:P}):null,u.jsxs("div",{className:"file-explorer-layout",children:[u.jsx("div",{className:"file-tree","aria-label":ie?`Files in ${ie}`:"Files",children:ze.map(W=>Me(W,0))}),u.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[u.jsxs("div",{className:"file-detail-header",children:[u.jsx("strong",{children:S?.name??"detail"}),u.jsxs("div",{className:"file-detail-actions",children:[u.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{Ke()},children:"Move"}),u.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{Ie()},children:"Delete"})]})]}),A==="loading"?u.jsx("div",{className:"file-detail-empty",children:"loading"}):null,E.type==="empty"&&A!=="loading"?u.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,E.type==="preview"?u.jsxs("div",{className:"file-preview-frame",children:[E.previewKind==="image"?u.jsx("img",{src:E.url,alt:E.file.name}):null,E.previewKind==="pdf"?u.jsx("iframe",{src:E.url,title:E.file.name}):null]}):null,E.type==="text-preview"&&E.read.language==="markdown"?u.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${E.file.name}`,children:u.jsx(v.Suspense,{fallback:u.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:u.jsx(vj,{content:E.read.content})})}):null,E.type==="text-preview"&&E.read.language==="text"?u.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${E.file.name}`,children:E.read.content}):null]})]})]})}function iv(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function bj(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function X1(e,t){return`${e}\0${t??""}`}function yj(e){return`workspace\0${e}`}function Sj(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 il(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Z1(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 ra(e){return e instanceof Error?e.message:"Request failed"}function wj(e){return e instanceof Fn&&e.status===409&&e.message==="terminal_cwd_changed"}const xj=v.lazy(()=>Ty(()=>import("./MarkdownPreview-DD_7eToU.js"),__vite__mapDeps([0,1])));function Q1({api:e,editor:t,canClose:n,onClose:r}){const[o,l]=v.useState(t.read),[d,f]=v.useState(t.read.content),[m,p]=v.useState("idle"),[b,_]=v.useState(null),[w,S]=v.useState(!1),[x,E]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),K=v.useRef(t.read.content),P=v.useRef(!1),z=v.useRef(!1),q=v.useRef(0),Y=d!==o.content&&m!=="saving"&&!w;v.useEffect(()=>(z.current=!0,()=>{z.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,P.current=!1,L.current=t,A.current=t.read,K.current=t.read.content,l(t.read),f(t.read.content),p("idle"),_(null),S(!1),E("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{K.current=d},[d]),v.useEffect(()=>{if(d===o.content||w)return;const ee=window.setInterval(()=>{!P.current&&K.current!==A.current.content&&I()},1e3);return()=>window.clearInterval(ee)},[d===o.content,w,t.id]);async function I(){if(P.current)return;const ee=K.current,ie=A.current;if(ee===ie.content)return;const J=L.current,H=q.current;P.current=!0,p("saving"),_(null),S(!1);try{const X=await e.writeFile({rootToken:J.rootToken,path:J.path,content:ee,expectedVersion:ie.version});if(!z.current||H!==q.current)return;const M={...ie,content:ee,version:X.version};A.current=M,l(M),p(K.current===ee?"saved":"idle")}catch(X){if(!z.current||H!==q.current)return;if(X instanceof Fn&&X.status===409){S(!0),p("idle");return}_(Cj(X)),p("idle")}finally{H===q.current&&(P.current=!1)}}const F=m==="saving"?"saving":m==="saved"?"saved":o.language,he=o.language==="markdown",Q=he&&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:F}),u.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!Y,onClick:()=>{I()},children:"Save"}),he?u.jsx("button",{type:"button","aria-label":`${Q?"Edit":"Preview"} ${t.title}`,onClick:()=>E(ee=>ee==="preview"?"edit":"preview"),children:Q?"Edit":"Preview"}):null,n?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),b?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,w?u.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Q?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(xj,{content:d})})}):u.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:ee=>{const ie=ee.target.value;K.current=ie,f(ie),p("idle"),_(null),S(!1)}})]})}function Cj(e){return e instanceof Error?e.message:"Request failed"}var kj=2,Tj=1,Ej=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),d={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=d.top+d.bottom,m=d.right+d.left,p=r-f,b=o-m-t;return{cols:Math.max(kj,Math.floor(b/e.css.cell.width)),rows:Math.max(Tj,Math.floor(p/e.css.cell.height))}}};var zT=Object.defineProperty,Rj=Object.getOwnPropertyDescriptor,Nj=(e,t)=>{for(var n in t)zT(e,n,{get:t[n],enumerable:!0})},On=(e,t,n,r)=>{for(var o=r>1?void 0:r?Rj(t,n):t,l=e.length-1,d;l>=0;l--)(d=e[l])&&(o=(r?d(t,n,o):d(o))||o);return r&&o&&zT(t,n,o),o},Ge=(e,t)=>(n,r)=>t(n,r,e),J1="Terminal input",y_={get:()=>J1,set:e=>J1=e},ex="Too much output to announce, navigate to rows manually to read",S_={get:()=>ex,set:e=>ex=e};function Dj(e){return e.replace(/\r?\n/g,"\r")}function Mj(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Aj(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Lj(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");HT(o,t,n,r)}}function HT(e,t,n,r){e=Dj(e),e=Mj(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function UT(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,l=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function tx(e,t,n,r,o){UT(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function fo(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Hp(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,r+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):r+=String.fromCharCode(l)}return r}var jj=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[r++]=(this._interim-55296)*1024+l-56320+65536:(t[r++]=this._interim,t[r++]=l),this._interim=0}for(let l=o;l<n;++l){let d=e.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=n)return this._interim=d,r;let f=e.charCodeAt(l);56320<=f&&f<=57343?t[r++]=(d-55296)*1024+f-56320+65536:(t[r++]=d,t[r++]=f);continue}d!==65279&&(t[r++]=d)}return r}},Oj=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,l,d,f,m=0,p=0;if(this.interim[0]){let w=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let x=0,E;for(;(E=this.interim[++x]&63)&&x<4;)S<<=6,S|=E;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(E=e[p++],(E&192)!==128){p--,w=!0;break}else this.interim[x++]=E,S<<=6,S|=E&63}w||(L===2?S<128?p--:t[r++]=S:L===3?S<2048||S>=55296&&S<=57343||S===65279||(t[r++]=S):S<65536||S>1114111||(t[r++]=S)),this.interim.fill(0)}let b=n-4,_=p;for(;_<n;){for(;_<b&&!((o=e[_])&128)&&!((l=e[_+1])&128)&&!((d=e[_+2])&128)&&!((f=e[_+3])&128);)t[r++]=o,t[r++]=l,t[r++]=d,t[r++]=f,_+=4;if(o=e[_++],o<128)t[r++]=o;else if((o&224)===192){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(m=(o&31)<<6|l&63,m<128){_--;continue}t[r++]=m}else if((o&240)===224){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,r;if(d=e[_++],(d&192)!==128){_--;continue}if(m=(o&15)<<12|(l&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[r++]=m}else if((o&248)===240){if(_>=n)return this.interim[0]=o,r;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,r;if(d=e[_++],(d&192)!==128){_--;continue}if(_>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=d,r;if(f=e[_++],(f&192)!==128){_--;continue}if(m=(o&7)<<18|(l&63)<<12|(d&63)<<6|f&63,m<65536||m>1114111)continue;t[r++]=m}}return r}},$T="",go=" ",Xd=class FT{constructor(){this.fg=0,this.bg=0,this.extended=new ip}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}},ip=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}},Bs=class KT extends Xd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ip,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?fo(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},nx="di$target",w_="di$dependencies",sv=new Map;function Bj(e){return e[w_]||[]}function wi(e){if(sv.has(e))return sv.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ij(t,n,o)};return t._id=e,sv.set(e,t),t}function Ij(e,t,n){t[nx]===t?t[w_].push({id:e,index:n}):(t[w_]=[{id:e,index:n}],t[nx]=t)}var Wi=wi("BufferService"),qT=wi("CoreMouseService"),Sl=wi("CoreService"),Pj=wi("CharsetService"),Ey=wi("InstantiationService"),VT=wi("LogService"),Ki=wi("OptionsService"),YT=wi("OscLinkService"),zj=wi("UnicodeService"),Zd=wi("DecorationService"),x_=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,l=new Bs,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 w={start:{x:m+1,y:e},end:{x:b+(!p&&b===d-1?1:0),y:e}},S=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(S=!0)}catch{S=!0}S||r.push({text:_,range:w,activate:(x,E)=>o?o.activate(x,E,w):Hj(x,E),hover:(x,E)=>o?.hover?.(x,E,w),leave:(x,E)=>o?.leave?.(x,E,w)})}p=!1,l.hasExtendedAttrs()&&l.extended.urlId?(m=b,f=l.extended.urlId):(m=-1,f=-1)}}t(r)}};x_=On([Ge(0,Wi),Ge(1,Ki),Ge(2,YT)],x_);function Hj(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 Up=wi("CharSizeService"),ya=wi("CoreBrowserService"),Ry=wi("MouseService"),Sa=wi("RenderService"),Uj=wi("SelectionService"),GT=wi("CharacterJoinerService"),Kc=wi("ThemeService"),XT=wi("LinkProviderService"),$j=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ix.isErrorNoTelemetry(e)?new ix(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)}},Fj=new $j;function Tf(e){Wj(e)||Fj.onUnexpectedError(e)}var C_="Canceled";function Wj(e){return e instanceof Kj?!0:e instanceof Error&&e.name===C_&&e.message===C_}var Kj=class extends Error{constructor(){super(C_),this.name=this.message}};function qj(e){return new Error(`Illegal argument: ${e}`)}var ix=class k_ extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof k_)return t;let n=new k_;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},T_=class ZT extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,ZT.prototype)}};function ms(e,t=0){return e[e.length-(1+t)]}var Vj;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function r(l){return l>0}e.isGreaterThan=r;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Vj||={});function Yj(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var QT;(e=>{function t(z){return z&&typeof z=="object"&&typeof z[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(z){yield z}e.single=o;function l(z){return t(z)?z:o(z)}e.wrap=l;function d(z){return z||n}e.from=d;function*f(z){for(let q=z.length-1;q>=0;q--)yield z[q]}e.reverse=f;function m(z){return!z||z[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(z){return z[Symbol.iterator]().next().value}e.first=p;function b(z,q){let Y=0;for(let I of z)if(q(I,Y++))return!0;return!1}e.some=b;function _(z,q){for(let Y of z)if(q(Y))return Y}e.find=_;function*w(z,q){for(let Y of z)q(Y)&&(yield Y)}e.filter=w;function*S(z,q){let Y=0;for(let I of z)yield q(I,Y++)}e.map=S;function*x(z,q){let Y=0;for(let I of z)yield*q(I,Y++)}e.flatMap=x;function*E(...z){for(let q of z)yield*q}e.concat=E;function L(z,q,Y){let I=Y;for(let F of z)I=q(I,F);return I}e.reduce=L;function*A(z,q,Y=z.length){for(q<0&&(q+=z.length),Y<0?Y+=z.length:Y>z.length&&(Y=z.length);q<Y;q++)yield z[q]}e.slice=A;function K(z,q=Number.POSITIVE_INFINITY){let Y=[];if(q===0)return[Y,z];let I=z[Symbol.iterator]();for(let F=0;F<q;F++){let he=I.next();if(he.done)return[Y,e.empty()];Y.push(he.value)}return[Y,{[Symbol.iterator](){return I}}]}e.consume=K;async function P(z){let q=[];for await(let Y of z)q.push(Y);return Promise.resolve(q)}e.asyncToArray=P})(QT||={});function _l(e){if(QT.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Gj(...e){return xn(()=>_l(e))}function xn(e){return{dispose:Yj(()=>{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{_l(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 _o=JT,Et=class{constructor(){this._store=new _o,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)}};Et.None=Object.freeze({dispose(){}});var Pc=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}},fa=typeof window=="object"?window:globalThis,E_=class R_{constructor(t){this.element=t,this.next=R_.Undefined,this.prev=R_.Undefined}};E_.Undefined=new E_(void 0);var Tn=E_,sx=class{constructor(){this._first=Tn.Undefined,this._last=Tn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Tn.Undefined}clear(){let e=this._first;for(;e!==Tn.Undefined;){let t=e.next;e.prev=Tn.Undefined,e.next=Tn.Undefined,e=t}this._first=Tn.Undefined,this._last=Tn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Tn(e);if(this._first===Tn.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==Tn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Tn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Tn.Undefined&&e.next!==Tn.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Tn.Undefined&&e.next===Tn.Undefined?(this._first=Tn.Undefined,this._last=Tn.Undefined):e.next===Tn.Undefined?(this._last=this._last.prev,this._last.next=Tn.Undefined):e.prev===Tn.Undefined&&(this._first=this._first.next,this._first.prev=Tn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Tn.Undefined;)yield e.element,e=e.next}},Xj=globalThis.performance&&typeof globalThis.performance.now=="function",Zj=class tE{static create(t){return new tE(t)}constructor(t){this._now=Xj&&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}},Mi;(e=>{e.None=()=>Et.None;function t(ie,J){return _(ie,()=>{},0,void 0,!0,void 0,J)}e.defer=t;function n(ie){return(J,H=null,X)=>{let M=!1,R;return R=ie(B=>{if(!M)return R?R.dispose():M=!0,J.call(H,B)},null,X),M&&R.dispose(),R}}e.once=n;function r(ie,J,H){return p((X,M=null,R)=>ie(B=>X.call(M,J(B)),null,R),H)}e.map=r;function o(ie,J,H){return p((X,M=null,R)=>ie(B=>{J(B),X.call(M,B)},null,R),H)}e.forEach=o;function l(ie,J,H){return p((X,M=null,R)=>ie(B=>J(B)&&X.call(M,B),null,R),H)}e.filter=l;function d(ie){return ie}e.signal=d;function f(...ie){return(J,H=null,X)=>{let M=Gj(...ie.map(R=>R(B=>J.call(H,B))));return b(M,X)}}e.any=f;function m(ie,J,H,X){let M=H;return r(ie,R=>(M=J(M,R),M),X)}e.reduce=m;function p(ie,J){let H,X={onWillAddFirstListener(){H=ie(M.fire,M)},onDidRemoveLastListener(){H?.dispose()}},M=new Ue(X);return J?.add(M),M.event}function b(ie,J){return J instanceof Array?J.push(ie):J&&J.add(ie),ie}function _(ie,J,H=100,X=!1,M=!1,R,B){let oe,ge,N,V=0,re,Z={leakWarningThreshold:R,onWillAddFirstListener(){oe=ie(ye=>{V++,ge=J(ge,ye),X&&!N&&(Te.fire(ge),ge=void 0),re=()=>{let He=ge;ge=void 0,N=void 0,(!X||V>1)&&Te.fire(He),V=0},typeof H=="number"?(clearTimeout(N),N=setTimeout(re,H)):N===void 0&&(N=0,queueMicrotask(re))})},onWillRemoveListener(){M&&V>0&&re?.()},onDidRemoveLastListener(){re=void 0,oe.dispose()}},Te=new Ue(Z);return B?.add(Te),Te.event}e.debounce=_;function w(ie,J=0,H){return e.debounce(ie,(X,M)=>X?(X.push(M),X):[M],J,void 0,!0,void 0,H)}e.accumulate=w;function S(ie,J=(X,M)=>X===M,H){let X=!0,M;return l(ie,R=>{let B=X||!J(R,M);return X=!1,M=R,B},H)}e.latch=S;function x(ie,J,H){return[e.filter(ie,J,H),e.filter(ie,X=>!J(X),H)]}e.split=x;function E(ie,J=!1,H=[],X){let M=H.slice(),R=ie(ge=>{M?M.push(ge):oe.fire(ge)});X&&X.add(R);let B=()=>{M?.forEach(ge=>oe.fire(ge)),M=null},oe=new Ue({onWillAddFirstListener(){R||(R=ie(ge=>oe.fire(ge)),X&&X.add(R))},onDidAddFirstListener(){M&&(J?setTimeout(B):B())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return X&&X.add(oe),oe.event}e.buffer=E;function L(ie,J){return(H,X,M)=>{let R=J(new K);return ie(function(B){let oe=R.evaluate(B);oe!==A&&H.call(X,oe)},void 0,M)}}e.chain=L;let A=Symbol("HaltChainable");class K{constructor(){this.steps=[]}map(J){return this.steps.push(J),this}forEach(J){return this.steps.push(H=>(J(H),H)),this}filter(J){return this.steps.push(H=>J(H)?H:A),this}reduce(J,H){let X=H;return this.steps.push(M=>(X=J(X,M),X)),this}latch(J=(H,X)=>H===X){let H=!0,X;return this.steps.push(M=>{let R=H||!J(M,X);return H=!1,X=M,R?M:A}),this}evaluate(J){for(let H of this.steps)if(J=H(J),J===A)break;return J}}function P(ie,J,H=X=>X){let X=(...oe)=>B.fire(H(...oe)),M=()=>ie.on(J,X),R=()=>ie.removeListener(J,X),B=new Ue({onWillAddFirstListener:M,onDidRemoveLastListener:R});return B.event}e.fromNodeEventEmitter=P;function z(ie,J,H=X=>X){let X=(...oe)=>B.fire(H(...oe)),M=()=>ie.addEventListener(J,X),R=()=>ie.removeEventListener(J,X),B=new Ue({onWillAddFirstListener:M,onDidRemoveLastListener:R});return B.event}e.fromDOMEventEmitter=z;function q(ie){return new Promise(J=>n(ie)(J))}e.toPromise=q;function Y(ie){let J=new Ue;return ie.then(H=>{J.fire(H)},()=>{J.fire(void 0)}).finally(()=>{J.dispose()}),J.event}e.fromPromise=Y;function I(ie,J){return ie(H=>J.fire(H))}e.forward=I;function F(ie,J,H){return J(H),ie(X=>J(X))}e.runAndSubscribe=F;class he{constructor(J,H){this._observable=J,this._counter=0,this._hasChanged=!1;let X={onWillAddFirstListener:()=>{J.addObserver(this)},onDidRemoveLastListener:()=>{J.removeObserver(this)}};this.emitter=new Ue(X),H&&H.add(this.emitter)}beginUpdate(J){this._counter++}handlePossibleChange(J){}handleChange(J,H){this._hasChanged=!0}endUpdate(J){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Q(ie,J){return new he(ie,J).emitter.event}e.fromObservable=Q;function ee(ie){return(J,H,X)=>{let M=0,R=!1,B={beginUpdate(){M++},endUpdate(){M--,M===0&&(ie.reportChanges(),R&&(R=!1,J.call(H)))},handlePossibleChange(){},handleChange(){R=!0}};ie.addObserver(B),ie.reportChanges();let oe={dispose(){ie.removeObserver(B)}};return X instanceof _o?X.add(oe):Array.isArray(X)&&X.push(oe),oe}}e.fromObservableLight=ee})(Mi||={});var N_=class D_{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${D_._idPool++}`,D_.all.add(this)}start(t){this._stopWatch=new Zj,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}}};N_.all=new Set,N_._idPool=0;var Qj=N_,Jj=-1,nE=class iE{constructor(t,n,r=(iE._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[l,d]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(f),console.warn(l);let m=new n3(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[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};nE._idPool=1;var e3=nE,t3=class sE{constructor(t){this.value=t}static create(){let t=new Error;return new sE(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
+
`).slice(2).join(`
|
|
24
|
+
`))}},n3=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},i3=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},s3=0,rv=class{constructor(e){this.value=e,this.id=s3++}},r3=2,a3,Ue=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new e3(e?.onListenerError??Tf,this._options?.leakWarningThreshold??Jj):void 0,this._perfMon=this._options?._profName?new Qj(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 i3(`${d}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||Tf)(m),Et.None}if(this._disposed)return Et.None;t&&(e=e.bind(t));let r=new rv(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=t3.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof rv?(this._deliveryQueue??=new o3,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let l=xn(()=>{o?.(),this._removeListener(r)});return n instanceof _o?n.add(l):Array.isArray(n)&&n.push(l),l},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*r3<=t.length){let o=0;for(let l=0;l<t.length;l++)t[l]?t[o++]=t[l]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Tf;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof rv)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}},o3=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}},M_=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ue,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ue,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};M_.INSTANCE=new M_;var Ny=M_;function l3(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Ny.INSTANCE.onDidChangeZoomLevel;function c3(e){return Ny.INSTANCE.getZoomFactor(e)}Ny.INSTANCE.onDidChangeFullscreen;var qc=typeof navigator=="object"?navigator.userAgent:"",A_=qc.indexOf("Firefox")>=0,u3=qc.indexOf("AppleWebKit")>=0,Dy=qc.indexOf("Chrome")>=0,d3=!Dy&&qc.indexOf("Safari")>=0;qc.indexOf("Electron/")>=0;qc.indexOf("Android")>=0;var av=!1;if(typeof fa.matchMedia=="function"){let e=fa.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=fa.matchMedia("(display-mode: fullscreen)");av=e.matches,l3(fa,e,({matches:n})=>{av&&t.matches||(av=n)})}var xc="en",L_=!1,j_=!1,Ef=!1,rE=!1,cf,Rf=xc,rx=xc,h3,la,hl=globalThis,_s;typeof hl.vscode<"u"&&typeof hl.vscode.process<"u"?_s=hl.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(_s=process);var f3=typeof _s?.versions?.electron=="string",p3=f3&&_s?.type==="renderer";if(typeof _s=="object"){L_=_s.platform==="win32",j_=_s.platform==="darwin",Ef=_s.platform==="linux",Ef&&_s.env.SNAP&&_s.env.SNAP_REVISION,_s.env.CI||_s.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cf=xc,Rf=xc;let e=_s.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);cf=t.userLocale,rx=t.osLocale,Rf=t.resolvedLanguage||xc,h3=t.languagePack?.translationsConfigFile}catch{}rE=!0}else typeof navigator=="object"&&!p3?(la=navigator.userAgent,L_=la.indexOf("Windows")>=0,j_=la.indexOf("Macintosh")>=0,(la.indexOf("Macintosh")>=0||la.indexOf("iPad")>=0||la.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ef=la.indexOf("Linux")>=0,la?.indexOf("Mobi")>=0,Rf=globalThis._VSCODE_NLS_LANGUAGE||xc,cf=navigator.language.toLowerCase(),rx=cf):console.error("Unable to resolve platform.");var aE=L_,vr=j_,m3=Ef,ax=rE,yr=la,ro=Rf,g3;(e=>{function t(){return ro}e.value=t;function n(){return ro.length===2?ro==="en":ro.length>=3?ro[0]==="e"&&ro[1]==="n"&&ro[2]==="-":!1}e.isDefaultVariant=n;function r(){return ro==="en"}e.isDefault=r})(g3||={});var v3=typeof hl.postMessage=="function"&&!hl.importScripts;(()=>{if(v3){let e=[];hl.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let l=e[r];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),l.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),hl.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var _3=!!(yr&&yr.indexOf("Chrome")>=0);yr&&yr.indexOf("Firefox")>=0;!_3&&yr&&yr.indexOf("Safari")>=0;yr&&yr.indexOf("Edg/")>=0;yr&&yr.indexOf("Android")>=0;var pc=typeof navigator=="object"?navigator:{};ax||document.queryCommandSupported&&document.queryCommandSupported("copy")||pc&&pc.clipboard&&pc.clipboard.writeText,ax||pc&&pc.clipboard&&pc.clipboard.readText;var My=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}},ov=new My,ox=new My,lx=new My,b3=new Array(230),oE;(e=>{function t(f){return ov.keyCodeToStr(f)}e.toString=t;function n(f){return ov.strToKeyCode(f)}e.fromString=n;function r(f){return ox.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return lx.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function l(f){return ox.strToKeyCode(f)||lx.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 ov.keyCodeToStr(f)}e.toElectronAccelerator=d})(oE||={});var y3=class lE{constructor(t,n,r,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof 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",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new S3([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},S3=class{constructor(e){if(e.length===0)throw qj("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 w3(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(A_)switch(t){case 59:return 85;case 60:if(m3)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vr)return 57;break}else if(u3&&(vr&&t===93||!vr&&t===92))return 57;return b3[t]||0}var x3=vr?256:2048,C3=512,k3=1024,T3=vr?2048:256,cx=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=w3(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|=x3),this.altKey&&(t|=C3),this.shiftKey&&(t|=k3),this.metaKey&&(t|=T3),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new y3(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},ux=new WeakMap;function E3(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 R3=class{static getSameOriginWindowChain(e){let t=ux.get(e);if(!t){t=[],ux.set(e,t);let n=e,r;do r=E3(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let l of o){let d=l.window.deref();if(n+=d?.scrollY??0,r+=d?.scrollX??0,d===t||!l.iframeElement)break;let f=l.iframeElement.getBoundingClientRect();n+=f.top,r+=f.left}return{top:n,left:r}}},uf=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=R3.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},dx=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(Dy){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,d=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*d):this.deltaY=o.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?A_&&!vr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")d3&&aE?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*d):this.deltaX=o.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?A_&&!vr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},cE=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),N3;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof D3?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:cE})})(N3||={});var D3=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 Ue),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ay=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 T_("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new T_("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},M3=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 T_("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=xn(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},A3;(e=>{async function t(r){let o,l=await Promise.all(r.map(d=>d.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(r){return new Promise(async(o,l)=>{try{await r(o,l)}catch(d){l(d)}})}e.withAsyncBody=n})(A3||={});var hx=class Ms{static fromArray(t){return new Ms(n=>{n.emitMany(t)})}static fromPromise(t){return new Ms(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ms(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new Ms(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Ue,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new Ms(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return Ms.map(this,t)}static filter(t,n){return new Ms(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return Ms.filter(this,t)}static coalesce(t){return Ms.filter(t,n=>!!n)}coalesce(){return Ms.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return Ms.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())}};hx.EMPTY=hx.fromArray([]);var{getWindow:gr,getWindowId:L3,onDidRegisterWindow:j3}=(function(){let e=new Map,t={window:fa,disposables:new _o};e.set(fa.vscodeWindowId,t);let n=new Ue,r=new Ue,o=new Ue;function l(d,f){return(typeof d=="number"?e.get(d):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(d){if(e.has(d.vscodeWindowId))return Et.None;let f=new _o,m={window:d,disposables:f.add(new _o)};return e.set(d.vscodeWindowId,m),f.add(xn(()=>{e.delete(d.vscodeWindowId),r.fire(d)})),f.add(gt(d,vi.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:fa},getDocument(d){return gr(d).document}}})(),O3=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function gt(e,t,n,r){return new O3(e,t,n,r)}var fx=function(e,t,n,r){return gt(e,t,n,r)},Ly,B3=class extends M3{constructor(e){super(),this.defaultTarget=e&&gr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},px=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){Tf(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=l=>{n.set(l,!1);let d=e.get(l)??[];for(t.set(l,d),e.set(l,[]),r.set(l,!0);d.length>0;)d.sort(px.sort),d.shift().execute();r.set(l,!1)};Ly=(l,d,f=0)=>{let m=L3(l),p=new px(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 I3(e){let t=e.getBoundingClientRect(),n=gr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var vi={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"},P3=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=ts(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=ts(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=ts(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=ts(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=ts(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=ts(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=ts(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=ts(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=ts(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=ts(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=ts(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=ts(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=ts(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=ts(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 ts(e){return typeof e=="number"?`${e}px`:e}function Sd(e){return new P3(e)}var uE=class{constructor(){this._hooks=new _o,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(xn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=gr(e)}this._hooks.add(gt(l,vi.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(gt(l,vi.POINTER_UP,d=>this.stopMonitoring(!0)))}};function z3(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;n[r]=function(...d){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,d)}),this[l]}}var fr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(fr||={});var nd=class Ii extends Et{constructor(){super(),this.dispatched=!1,this.targets=new sx,this.ignoreTargets=new sx,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Mi.runAndSubscribe(j3,({window:t,disposables:n})=>{n.add(gt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(gt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(gt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:fa,disposables:this._store}))}static addTarget(t){if(!Ii.isTouchDevice())return Et.None;Ii.INSTANCE||(Ii.INSTANCE=new Ii);let n=Ii.INSTANCE.targets.push(t);return xn(n)}static ignoreTarget(t){if(!Ii.isTouchDevice())return Et.None;Ii.INSTANCE||(Ii.INSTANCE=new Ii);let n=Ii.INSTANCE.ignoreTargets.push(t);return xn(n)}static isTouchDevice(){return"ontouchstart"in fa||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let l=t.targetTouches.item(r);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let d=this.newGestureEvent(fr.Start,l.target);d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,d=n.changedTouches.length;l<d;l++){let f=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let m=this.activeTouches[f.identifier],p=Date.now()-m.initialTimeStamp;if(p<Ii.HOLD_DELAY&&Math.abs(m.initialPageX-ms(m.rollingPageX))<30&&Math.abs(m.initialPageY-ms(m.rollingPageY))<30){let b=this.newGestureEvent(fr.Tap,m.initialTarget);b.pageX=ms(m.rollingPageX),b.pageY=ms(m.rollingPageY),this.dispatchEvent(b)}else if(p>=Ii.HOLD_DELAY&&Math.abs(m.initialPageX-ms(m.rollingPageX))<30&&Math.abs(m.initialPageY-ms(m.rollingPageY))<30){let b=this.newGestureEvent(fr.Contextmenu,m.initialTarget);b.pageX=ms(m.rollingPageX),b.pageY=ms(m.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=ms(m.rollingPageX),_=ms(m.rollingPageY),w=ms(m.rollingTimestamps)-m.rollingTimestamps[0],S=b-m.rollingPageX[0],x=_-m.rollingPageY[0],E=[...this.targets].filter(L=>m.initialTarget instanceof Node&&L.contains(m.initialTarget));this.inertia(t,E,r,Math.abs(S)/w,S>0?1:-1,b,Math.abs(x)/w,x>0?1:-1,_)}this.dispatchEvent(this.newGestureEvent(fr.End,m.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===fr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>Ii.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===fr.Change||t.type===fr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==r;)o++,l=l.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,l,d,f,m,p){this.handle=Ly(t,()=>{let b=Date.now(),_=b-r,w=0,S=0,x=!0;o+=Ii.SCROLL_FRICTION*_,f+=Ii.SCROLL_FRICTION*_,o>0&&(x=!1,w=l*o*_),f>0&&(x=!1,S=m*f*_);let E=this.newGestureEvent(fr.Change);E.translationX=w,E.translationY=S,n.forEach(L=>L.dispatchEvent(E)),x||this.inertia(t,n,b,o,l,d+w,f,m,p+S)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let l=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let d=this.activeTouches[l.identifier],f=this.newGestureEvent(fr.Change,d.initialTarget);f.translationX=l.pageX-ms(d.rollingPageX),f.translationY=l.pageY-ms(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)}};nd.SCROLL_FRICTION=-.005,nd.HOLD_DELAY=700,nd.CLEAR_TAP_COUNT_TIME=400,On([z3],nd,"isTouchDevice",1);var H3=nd,jy=class extends Et{onclick(e,t){this._register(gt(e,vi.CLICK,n=>t(new uf(gr(e),n))))}onmousedown(e,t){this._register(gt(e,vi.MOUSE_DOWN,n=>t(new uf(gr(e),n))))}onmouseover(e,t){this._register(gt(e,vi.MOUSE_OVER,n=>t(new uf(gr(e),n))))}onmouseleave(e,t){this._register(gt(e,vi.MOUSE_LEAVE,n=>t(new uf(gr(e),n))))}onkeydown(e,t){this._register(gt(e,vi.KEY_DOWN,n=>t(new cx(n))))}onkeyup(e,t){this._register(gt(e,vi.KEY_UP,n=>t(new cx(n))))}oninput(e,t){this._register(gt(e,vi.INPUT,t))}onblur(e,t){this._register(gt(e,vi.BLUR,t))}onfocus(e,t){this._register(gt(e,vi.FOCUS,t))}onchange(e,t){this._register(gt(e,vi.CHANGE,t))}ignoreGesture(e){return H3.ignoreTarget(e)}},mx=11,U3=class extends jy{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=mx+"px",this.domNode.style.height=mx+"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(fx(this.bgDomNode,vi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(fx(this.domNode,vi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new B3),this._pointerdownScheduleRepeatTimer=this._register(new Ay)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,gr(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()}},$3=class O_{constructor(t,n,r,o,l,d,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,l=l|0,d=d|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),l<0&&(l=0),f+l>d&&(f=d-l),f<0&&(f=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=l,this.scrollHeight=d,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new O_(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 O_(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,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:r,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:d,scrollHeightChanged:f,scrollTopChanged:m}}},F3=class extends Et{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $3(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new vx(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=vx.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)))}},gx=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function lv(e,t){let n=t-e;return function(r){return e+n*q3(r)}}function W3(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var vx=class B_{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let o,l;return t<n?(o=t+.75*r,l=n-.75*r):(o=t-.75*r,l=n+.75*r),W3(lv(t,o),lv(l,n),.33)}return lv(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new gx(r,o,!1)}return new gx(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return B_.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new B_(t,n,o,r)}};function K3(e){return Math.pow(e,3)}function q3(e){return 1-K3(1-e)}var V3=class extends Et{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 Ay)}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":"")))}},Y3=140,dE=class extends jy{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 V3(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=Sd(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(gt(this.domNode.domNode,vi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new U3(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Sd(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(gt(this.slider.domNode,vi.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=I3(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),d=Math.abs(l-n);if(aE&&d>Y3){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},hE=class I_{constructor(t,n,r,o,l,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new I_(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,l){let d=Math.max(0,r-t),f=Math.max(0,d-2*n),m=o>0&&o>r;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(r*f/o))),b=(f-p)/(o-r),_=l*b;return{computedAvailableSize:Math.round(d),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:b,computedSliderPosition:Math.round(_)}}_refreshComputedValues(){let t=I_._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},G3=class extends dE{constructor(e,t,n){let r=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,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},X3=class extends dE{constructor(e,t,n){let r=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,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Z3=500,_x=50,Q3=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},P_=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-r);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Dy){let n=gr(t.browserEvent),r=c3(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,l=new Q3(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=l,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=l),l.score=this._computeScore(l,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),d=Math.abs(n.deltaX),f=Math.abs(n.deltaY),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&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};P_.INSTANCE=new P_;var J3=P_,eO=class extends jy{constructor(e,t,n){super(),this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ue),this.onWillScroll=this._onWillScroll.event,this._options=nO(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new X3(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new G3(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Sd(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Sd(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Sd(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Ay),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=_l(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,vr&&(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 dx(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=_l(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new dx(n))};this._mouseWheelToDispose.push(gt(this._listenOnDomNode,vi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=J3.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=!vr&&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=_x*o,b=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(m,b)}if(l){let p=_x*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 r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Z3)}},tO=class extends eO{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 nO(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,vr&&(t.className+=" mac"),t}var z_=class extends Et{constructor(e,t,n,r,o,l,d,f){super(),this._bufferService=n,this._optionsService=d,this._renderService=f,this._onRequestScrollLines=this._register(new Ue),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new F3({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Ly(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new tO(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(Mi.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(xn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(xn(()=>this._styleElement.remove())),this._register(Mi.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}};z_=On([Ge(2,Wi),Ge(3,ya),Ge(4,qT),Ge(5,Kc),Ge(6,Ki),Ge(7,Sa)],z_);var H_=class extends Et{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(xn(()=>{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()}};H_=On([Ge(1,Wi),Ge(2,ya),Ge(3,Zd),Ge(4,Sa)],H_);var iO=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)}},dr={full:0,left:0,center:0,right:0},ao={full:0,left:0,center:0,right:0},Ku={full:0,left:0,center:0,right:0},sp=class extends Et{constructor(e,t,n,r,o,l,d,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=l,this._themeService=d,this._coreBrowserService=f,this._colorZoneStore=new iO,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(xn(()=>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);ao.full=this._canvas.width,ao.left=e,ao.center=t,ao.right=e,this._refreshDrawHeightConstants(),Ku.full=1,Ku.left=1,Ku.center=1+ao.left,Ku.right=1+ao.left+ao.center}_refreshDrawHeightConstants(){dr.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);dr.left=t,dr.center=t,dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.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(Ku[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dr[e.position||"full"]/2),ao[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dr[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}))}};sp=On([Ge(2,Wi),Ge(3,Zd),Ge(4,Sa),Ge(5,Ki),Ge(6,Kc),Ge(7,ya)],sp);var Re;(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=""))(Re||={});var Nf;(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=""))(Nf||={});var fE;(e=>e.ST=`${Re.ESC}\\`)(fE||={});var U_=class{constructor(e,t,n,r,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Re.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};U_=On([Ge(2,Wi),Ge(3,Ki),Ge(4,Sl),Ge(5,Sa)],U_);var bi=0,yi=0,Si=0,jn=0,bx={css:"#00000000",rgba:0},ei;(e=>{function t(o,l,d,f){return f!==void 0?`#${sl(o)}${sl(l)}${sl(d)}${sl(f)}`:`#${sl(o)}${sl(l)}${sl(d)}`}e.toCss=t;function n(o,l,d,f=255){return(o<<24|l<<16|d<<8|f)>>>0}e.toRgba=n;function r(o,l,d,f){return{css:e.toCss(o,l,d,f),rgba:e.toRgba(o,l,d,f)}}e.toColor=r})(ei||={});var yn;(e=>{function t(m,p){if(jn=(p.rgba&255)/255,jn===1)return{css:p.css,rgba:p.rgba};let b=p.rgba>>24&255,_=p.rgba>>16&255,w=p.rgba>>8&255,S=m.rgba>>24&255,x=m.rgba>>16&255,E=m.rgba>>8&255;bi=S+Math.round((b-S)*jn),yi=x+Math.round((_-x)*jn),Si=E+Math.round((w-E)*jn);let L=ei.toCss(bi,yi,Si),A=ei.toRgba(bi,yi,Si);return{css:L,rgba:A}}e.blend=t;function n(m){return(m.rgba&255)===255}e.isOpaque=n;function r(m,p,b){let _=Df.ensureContrastRatio(m.rgba,p.rgba,b);if(_)return ei.toColor(_>>24&255,_>>16&255,_>>8&255)}e.ensureContrastRatio=r;function o(m){let p=(m.rgba|255)>>>0;return[bi,yi,Si]=Df.toChannels(p),{css:ei.toCss(bi,yi,Si),rgba:p}}e.opaque=o;function l(m,p){return jn=Math.round(p*255),[bi,yi,Si]=Df.toChannels(m.rgba),{css:ei.toCss(bi,yi,Si,jn),rgba:ei.toRgba(bi,yi,Si,jn)}}e.opacity=l;function d(m,p){return jn=m.rgba&255,l(m,jn*p/255)}e.multiplyOpacity=d;function f(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=f})(yn||={});var En;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return bi=parseInt(o.slice(1,2).repeat(2),16),yi=parseInt(o.slice(2,3).repeat(2),16),Si=parseInt(o.slice(3,4).repeat(2),16),ei.toColor(bi,yi,Si);case 5:return bi=parseInt(o.slice(1,2).repeat(2),16),yi=parseInt(o.slice(2,3).repeat(2),16),Si=parseInt(o.slice(3,4).repeat(2),16),jn=parseInt(o.slice(4,5).repeat(2),16),ei.toColor(bi,yi,Si,jn);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 bi=parseInt(l[1]),yi=parseInt(l[2]),Si=parseInt(l[3]),jn=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),ei.toColor(bi,yi,Si,jn);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),[bi,yi,Si,jn]=t.getImageData(0,0,1,1).data,jn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ei.toRgba(bi,yi,Si,jn),css:o}}e.toColor=r})(En||={});var $i;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,l){let d=r/255,f=o/255,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})($i||={});var Df;(e=>{function t(d,f){if(jn=(f&255)/255,jn===1)return f;let m=f>>24&255,p=f>>16&255,b=f>>8&255,_=d>>24&255,w=d>>16&255,S=d>>8&255;return bi=_+Math.round((m-_)*jn),yi=w+Math.round((p-w)*jn),Si=S+Math.round((b-S)*jn),ei.toRgba(bi,yi,Si)}e.blend=t;function n(d,f,m){let p=$i.relativeLuminance(d>>8),b=$i.relativeLuminance(f>>8);if(aa(p,b)<m){if(b<p){let S=r(d,f,m),x=aa(p,$i.relativeLuminance(S>>8));if(x<m){let E=o(d,f,m),L=aa(p,$i.relativeLuminance(E>>8));return x>L?S:E}return S}let _=o(d,f,m),w=aa(p,$i.relativeLuminance(_>>8));if(w<m){let S=r(d,f,m),x=aa(p,$i.relativeLuminance(S>>8));return w>x?_:S}return _}}e.ensureContrastRatio=n;function r(d,f,m){let p=d>>24&255,b=d>>16&255,_=d>>8&255,w=f>>24&255,S=f>>16&255,x=f>>8&255,E=aa($i.relativeLuminance2(w,S,x),$i.relativeLuminance2(p,b,_));for(;E<m&&(w>0||S>0||x>0);)w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),x-=Math.max(0,Math.ceil(x*.1)),E=aa($i.relativeLuminance2(w,S,x),$i.relativeLuminance2(p,b,_));return(w<<24|S<<16|x<<8|255)>>>0}e.reduceLuminance=r;function o(d,f,m){let p=d>>24&255,b=d>>16&255,_=d>>8&255,w=f>>24&255,S=f>>16&255,x=f>>8&255,E=aa($i.relativeLuminance2(w,S,x),$i.relativeLuminance2(p,b,_));for(;E<m&&(w<255||S<255||x<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),E=aa($i.relativeLuminance2(w,S,x),$i.relativeLuminance2(p,b,_));return(w<<24|S<<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})(Df||={});function sl(e){let t=e.toString(16);return t.length<2?"0"+t:t}function aa(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var sO=class extends Xd{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()]}},rp=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Bs}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,l=0,d=0,f=t.getFg(0),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(r,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||go.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,d,l,t,o);for(let b=0;b<p.length;b++)n.push(p[b])}return n}_getJoinedRanges(e,t,n,r,o){let l=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(l)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let m=this._characterJoiners[f].handler(l);for(let p=0;p<m.length;p++)rp._mergeRanges(d,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(d,r,o),d}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,l=0,d=e[r];if(d){for(let f=n;f<this._bufferService.cols;f++){let m=t.getWidth(f),p=t.getString(f).length||go.length;if(m!==0){if(!o&&d[0]<=l&&(d[0]=f,o=!0),d[1]<=l){if(d[1]=f,d=e[++r],!d)break;d[0]<=l?(d[0]=f,o=!0):o=!1}l+=p}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};rp=On([Ge(0,Wi)],rp);function rO(e){return 57508<=e&&e<=57558}function aO(e){return 9472<=e&&e<=9631}function oO(e){return rO(e)||aO(e)}function lO(){return{css:{canvas:df(),cell:df()},device:{canvas:df(),cell:df(),char:{width:0,height:0,left:0,top:0}}}}function df(){return{width:0,height:0}}var $_=class{constructor(e,t,n,r,o,l,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=l,this._themeService=d,this._workCell=new Bs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,l,d,f,m,p,b){let _=[],w=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<l+1&&(x=l+1);let E,L=0,A="",K=0,P=0,z=0,q=0,Y=!1,I=0,F=!1,he=0,Q=0,ee=[],ie=p!==-1&&b!==-1;for(let J=0;J<x;J++){e.loadCell(J,this._workCell);let H=this._workCell.getWidth();if(H===0)continue;let X=!1,M=J>=Q,R=J,B=this._workCell;if(w.length>0&&J===w[0][0]&&M){let j=w.shift(),me=this._isCellInSelection(j[0],t);for(K=j[0]+1;K<j[1];K++)M&&=me===this._isCellInSelection(K,t);M&&=!n||l<j[0]||l>=j[1],M?(X=!0,B=new sO(this._workCell,e.translateToString(!0,j[0],j[1]),j[1]-j[0]),R=j[1]-1,H=B.getWidth()):Q=j[1]}let oe=this._isCellInSelection(J,t),ge=n&&J===l,N=ie&&J>=p&&J<=b,V=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,j=>{V=!0});let re=B.getChars()||go;if(re===" "&&(B.isUnderline()||B.isOverline())&&(re=" "),he=H*f-m.get(re,B.isBold(),B.isItalic()),!E)E=this._document.createElement("span");else if(L&&(oe&&F||!oe&&!F&&B.bg===P)&&(oe&&F&&S.selectionForeground||B.fg===z)&&B.extended.ext===q&&N===Y&&he===I&&!ge&&!X&&!V&&M){B.isInvisible()?A+=go:A+=re,L++;continue}else L&&(E.textContent=A),E=this._document.createElement("span"),L=0,A="";if(P=B.bg,z=B.fg,q=B.extended.ext,Y=N,I=he,F=oe,X&&l>=J&&l<=R&&(l=J),!this._coreService.isCursorHidden&&ge&&this._coreService.isCursorInitialized){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&ee.push("xterm-cursor-blink"),ee.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline");break}}if(B.isBold()&&ee.push("xterm-bold"),B.isItalic()&&ee.push("xterm-italic"),B.isDim()&&ee.push("xterm-dim"),B.isInvisible()?A=go:A=B.getChars()||go,B.isUnderline()&&(ee.push(`xterm-underline-${B.extended.underlineStyle}`),A===" "&&(A=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${Xd.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let j=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&j<8&&(j+=8),E.style.textDecorationColor=S.ansi[j].css}B.isOverline()&&(ee.push("xterm-overline"),A===" "&&(A=" ")),B.isStrikethrough()&&ee.push("xterm-strikethrough"),N&&(E.style.textDecoration="underline");let Z=B.getFgColor(),Te=B.getFgColorMode(),ye=B.getBgColor(),He=B.getBgColorMode(),Ke=!!B.isInverse();if(Ke){let j=Z;Z=ye,ye=j;let me=Te;Te=He,He=me}let Ie,_e,We=!1;this._decorationService.forEachDecorationAtCell(J,t,void 0,j=>{j.options.layer!=="top"&&We||(j.backgroundColorRGB&&(He=50331648,ye=j.backgroundColorRGB.rgba>>8&16777215,Ie=j.backgroundColorRGB),j.foregroundColorRGB&&(Te=50331648,Z=j.foregroundColorRGB.rgba>>8&16777215,_e=j.foregroundColorRGB),We=j.options.layer==="top")}),!We&&oe&&(Ie=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,ye=Ie.rgba>>8&16777215,He=50331648,We=!0,S.selectionForeground&&(Te=50331648,Z=S.selectionForeground.rgba>>8&16777215,_e=S.selectionForeground)),We&&ee.push("xterm-decoration-top");let Oe;switch(He){case 16777216:case 33554432:Oe=S.ansi[ye],ee.push(`xterm-bg-${ye}`);break;case 50331648:Oe=ei.toColor(ye>>16,ye>>8&255,ye&255),this._addStyle(E,`background-color:#${yx((ye>>>0).toString(16),"0",6)}`);break;default:Ke?(Oe=S.foreground,ee.push("xterm-bg-257")):Oe=S.background}switch(Ie||B.isDim()&&(Ie=yn.multiplyOpacity(Oe,.5)),Te){case 16777216:case 33554432:B.isBold()&&Z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Z+=8),this._applyMinimumContrast(E,Oe,S.ansi[Z],B,Ie,void 0)||ee.push(`xterm-fg-${Z}`);break;case 50331648:let j=ei.toColor(Z>>16&255,Z>>8&255,Z&255);this._applyMinimumContrast(E,Oe,j,B,Ie,_e)||this._addStyle(E,`color:#${yx(Z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(E,Oe,S.foreground,B,Ie,_e)||Ke&&ee.push("xterm-fg-257")}ee.length&&(E.className=ee.join(" "),ee.length=0),!ge&&!X&&!V&&M?L++:E.textContent=A,he!==this.defaultSpacing&&(E.style.letterSpacing=`${he}px`),_.push(E),J=R}return E&&L&&(E.textContent=A),_}_applyMinimumContrast(e,t,n,r,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||oO(r.getCode()))return!1;let d=this._getContrastCache(r),f;if(!o&&!l&&(f=d.getColor(t.rgba,n.rgba)),f===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=yn.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,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};$_=On([Ge(1,GT),Ge(2,Ki),Ge(3,ya),Ge(4,Sl),Ge(5,Zd),Ge(6,Kc)],$_);function yx(e,t,n){for(;e.length<n;)e=t+e;return e}var cO=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,r,o,l],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let d=this._measure(e,0);return d>0&&(this._flat[r]=d),d}let o=e;t&&(o+="B"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let d=0;t&&(d|=1),n&&(d|=2),l=this._measure(e,d),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},uO=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,d=n[1]-o,f=Math.max(l,0),m=Math.min(d,e.rows-1);if(f>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,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 dO(){return new uO}var cv="xterm-dom-renderer-owner-",Ds="xterm-rows",hf="xterm-fg-",Sx="xterm-bg-",qu="xterm-focus",ff="xterm-selection",hO=1,F_=class extends Et{constructor(e,t,n,r,o,l,d,f,m,p,b,_,w,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=l,this._linkifier2=d,this._charSizeService=m,this._optionsService=p,this._bufferService=b,this._coreService=_,this._coreBrowserService=w,this._themeService=S,this._terminalClass=hO++,this._rowElements=[],this._selectionRenderModel=dO(),this.onRequestRedraw=this._register(new Ue).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ds),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(ff),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=lO(),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($_,document),this._element.classList.add(cv+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(xn(()=>{this._element.classList.remove(cv+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new cO(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} .${Ds} 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} .${Ds} { 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} .${Ds} .xterm-dim { color: ${yn.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ds}.${qu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ds}.${qu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ds}.${qu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ff} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ff} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ff} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,d]of e.ansi.entries())t+=`${this._terminalSelector} .${hf}${l} { color: ${d.css}; }${this._terminalSelector} .${hf}${l}.xterm-dim { color: ${yn.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${Sx}${l} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${hf}257 { color: ${yn.opaque(e.background).css}; }${this._terminalSelector} .${hf}257.xterm-dim { color: ${yn.multiplyOpacity(yn.opaque(e.background),.5).css}; }${this._terminalSelector} .${Sx}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(qu),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(qu),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let 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=r===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,r=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return l+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-l),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}px`,o.style.width=`${d}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let 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===r,d,f,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${cv}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,l){n<0&&(e=0),r<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),r=Math.max(Math.min(r,d),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,m=f.ybase+f.y,p=Math.min(f.x,o-1),b=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=n;S<=r;++S){let x=S+f.ydisp,E=this._rowElements[S],L=f.lines.get(x);if(!E||!L)break;E.replaceChildren(...this._rowFactory.createRow(L,x,x===m,_,w,p,b,this.dimensions.css.cell.width,this._widthCache,l?S===n?e:0:-1,l?(S===r?t:o)-1:-1))}}};F_=On([Ge(7,Ey),Ge(8,Up),Ge(9,Ki),Ge(10,Wi),Ge(11,Sl),Ge(12,ya),Ge(13,Kc)],F_);var W_=class extends Et{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ue),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new pO(this._optionsService))}catch{this._measureStrategy=this._register(new fO(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())}};W_=On([Ge(2,Ki)],W_);var pE=class extends Et{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)}},fO=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}},pO=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}},mO=class extends Et{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 gO(this._window)),this._onDprChange=this._register(new Ue),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ue),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Mi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(gt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(gt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},gO=class extends Et{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Pc),this._onDprChange=this._register(new Ue),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(xn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=gt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},vO=class extends Et{constructor(){super(),this.linkProviders=[],this._register(xn(()=>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 Oy(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),d=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-l,t.clientY-r.top-d]}function _O(e,t,n,r,o,l,d,f,m){if(!l)return;let p=Oy(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),r+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var K_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return _O(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Oy(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])}}};K_=On([Ge(0,Sa),Ge(1,Up)],K_);var bO=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={};Nj(mE,{getSafariVersion:()=>SO,isChromeOS:()=>bE,isFirefox:()=>gE,isIpad:()=>wO,isIphone:()=>xO,isLegacyEdge:()=>yO,isLinux:()=>By,isMac:()=>ap,isNode:()=>$p,isSafari:()=>vE,isWindows:()=>_E});var $p=typeof process<"u"&&"title"in process,Qd=$p?"node":navigator.userAgent,Jd=$p?"node":navigator.platform,gE=Qd.includes("Firefox"),yO=Qd.includes("Edge"),vE=/^((?!chrome|android).)*safari/i.test(Qd);function SO(){if(!vE)return 0;let e=Qd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ap=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Jd),wO=Jd==="iPad",xO=Jd==="iPhone",_E=["Windows","Win16","Win32","WinCE"].includes(Jd),By=Jd.indexOf("Linux")>=0,bE=/\bCrOS\b/.test(Qd),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,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},CO=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())}}},kO=class extends yE{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},op=!$p&&"requestIdleCallback"in window?kO:CO,TO=class{constructor(){this._queue=new op}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},q_=class extends Et{constructor(e,t,n,r,o,l,d,f,m){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Pc),this._pausedResizeTask=new TO,this._observerDisposable=this._register(new Pc),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Ue),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ue),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ue),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ue),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new bO((p,b)=>this._renderRows(p,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new EO(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(xn(()=>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(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=xn(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};q_=On([Ge(2,Ki),Ge(3,Up),Ge(4,Sl),Ge(5,Zd),Ge(6,Wi),Ge(7,ya),Ge(8,Kc)],q_);var EO=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 RO(e,t,n,r){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return MO(o,l,e,t,n,r)+Fp(l,t,n,r)+AO(o,l,e,t,n,r);let d;if(l===t)return d=o>e?"D":"C",Dd(Math.abs(o-e),Nd(d,r));d=l>t?"D":"C";let f=Math.abs(l-t),m=DO(l>t?e:o,n)+(f-1)*n.cols+1+NO(l>t?o:e);return Dd(m,Nd(d,r))}function NO(e,t){return e-1}function DO(e,t){return t.cols-e}function MO(e,t,n,r,o,l){return Fp(t,r,o,l).length===0?"":Dd(wE(e,t,e,t-bl(t,o),!1,o).length,Nd("D",l))}function Fp(e,t,n,r){let o=e-bl(e,n),l=t-bl(t,n),d=Math.abs(o-l)-LO(e,t,n);return Dd(d,Nd(SE(e,t),r))}function AO(e,t,n,r,o,l){let d;Fp(t,r,o,l).length>0?d=r-bl(r,o):d=t;let f=r,m=jO(e,t,n,r,o,l);return Dd(wE(e,d,n,f,m==="C",o).length,Nd(m,l))}function LO(e,t,n){let r=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&&r++}return r}function bl(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function jO(e,t,n,r,o,l){let d;return Fp(n,r,o,l).length>0?d=r-bl(r,o):d=t,e<n&&d<=r||e>=n&&d<r?"C":"D"}function SE(e,t){return e>t?"A":"B"}function wE(e,t,n,r,o,l){let d=e,f=t,m="";for(;(d!==n||f!==r)&&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 Nd(e,t){let n=t?"O":"[";return Re.ESC+n+e}function Dd(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var OO=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 wx(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 uv=50,BO=15,IO=50,PO=500,zO=" ",HO=new RegExp(zO,"g"),V_=class extends Et{constructor(e,t,n,r,o,l,d,f,m){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=l,this._optionsService=d,this._renderService=f,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Bs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ue),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ue),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ue),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ue),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new OO(this._bufferService),this._activeSelectionMode=0,this._register(xn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let f=n.translateBufferLineToString(d,!0,o,l);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let d=n.lines.get(l),f=n.translateBufferLineToString(l,!0);d?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?r[r.length-1]+=d:r.push(d)}}return r.map(o=>o.replace(HO," ")).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())),By&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=wx(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Oy(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,-uv),uv),t/=uv,t/Math.abs(t)+Math.round(t*(BO-1)))}shouldForceSelection(e){return ap?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(),IO)}_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&&!(ap&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<PO&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=RO(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let d=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(l,e[0]),m=f,p=e[0]-f,b=0,_=0,w=0,S=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 K=l.getString(A).length;for(K>1&&(S+=K-1,m+=K-1);L>0&&f>0&&!this._isCharWordSeparator(l.loadCell(L-1,this._workCell));){l.loadCell(L-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,L--):P>1&&(w+=P-1,f-=P-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 P=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,A++):P>1&&(S+=P-1,m+=P-1),m++,A++}}m++;let x=f+p-b+w,E=Math.min(this._bufferService.cols,m-f+b+_-w-S);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 K=this._bufferService.cols-A.start;x-=K,E+=K}}}if(r&&x+E===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&&(E+=A.length)}}return{start:x,length:E}}}_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=wx(n,this._bufferService.cols)}};V_=On([Ge(3,Wi),Ge(4,Sl),Ge(5,Ry),Ge(6,Ki),Ge(7,Sa),Ge(8,ya)],V_);var xx=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={}}},Cx=class{constructor(){this._color=new xx,this._css=new xx}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()}},ri=Object.freeze((()=>{let e=[En.toColor("#2e3436"),En.toColor("#cc0000"),En.toColor("#4e9a06"),En.toColor("#c4a000"),En.toColor("#3465a4"),En.toColor("#75507b"),En.toColor("#06989a"),En.toColor("#d3d7cf"),En.toColor("#555753"),En.toColor("#ef2929"),En.toColor("#8ae234"),En.toColor("#fce94f"),En.toColor("#729fcf"),En.toColor("#ad7fa8"),En.toColor("#34e2e2"),En.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],l=t[n%6];e.push({css:ei.toCss(r,o,l),rgba:ei.toRgba(r,o,l)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:ei.toCss(r,r,r),rgba:ei.toRgba(r,r,r)})}return e})()),rl=En.toColor("#ffffff"),id=En.toColor("#000000"),kx=En.toColor("#ffffff"),Tx=id,Vu={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},UO=rl,Y_=class extends Et{constructor(e){super(),this._optionsService=e,this._contrastCache=new Cx,this._halfContrastCache=new Cx,this._onChangeColors=this._register(new Ue),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rl,background:id,cursor:kx,cursorAccent:Tx,selectionForeground:void 0,selectionBackgroundTransparent:Vu,selectionBackgroundOpaque:yn.blend(id,Vu),selectionInactiveBackgroundTransparent:Vu,selectionInactiveBackgroundOpaque:yn.blend(id,Vu),scrollbarSliderBackground:yn.opacity(rl,.2),scrollbarSliderHoverBackground:yn.opacity(rl,.4),scrollbarSliderActiveBackground:yn.opacity(rl,.5),overviewRulerBorder:rl,ansi:ri.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=ln(e.foreground,rl),t.background=ln(e.background,id),t.cursor=yn.blend(t.background,ln(e.cursor,kx)),t.cursorAccent=yn.blend(t.background,ln(e.cursorAccent,Tx)),t.selectionBackgroundTransparent=ln(e.selectionBackground,Vu),t.selectionBackgroundOpaque=yn.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ln(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=yn.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ln(e.selectionForeground,bx):void 0,t.selectionForeground===bx&&(t.selectionForeground=void 0),yn.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=yn.opacity(t.selectionBackgroundTransparent,.3)),yn.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=yn.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ln(e.scrollbarSliderBackground,yn.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ln(e.scrollbarSliderHoverBackground,yn.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ln(e.scrollbarSliderActiveBackground,yn.opacity(t.foreground,.5)),t.overviewRulerBorder=ln(e.overviewRulerBorder,UO),t.ansi=ri.slice(),t.ansi[0]=ln(e.black,ri[0]),t.ansi[1]=ln(e.red,ri[1]),t.ansi[2]=ln(e.green,ri[2]),t.ansi[3]=ln(e.yellow,ri[3]),t.ansi[4]=ln(e.blue,ri[4]),t.ansi[5]=ln(e.magenta,ri[5]),t.ansi[6]=ln(e.cyan,ri[6]),t.ansi[7]=ln(e.white,ri[7]),t.ansi[8]=ln(e.brightBlack,ri[8]),t.ansi[9]=ln(e.brightRed,ri[9]),t.ansi[10]=ln(e.brightGreen,ri[10]),t.ansi[11]=ln(e.brightYellow,ri[11]),t.ansi[12]=ln(e.brightBlue,ri[12]),t.ansi[13]=ln(e.brightMagenta,ri[13]),t.ansi[14]=ln(e.brightCyan,ri[14]),t.ansi[15]=ln(e.brightWhite,ri[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=ln(e.extendedAnsi[r],ri[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Y_=On([Ge(0,Ki)],Y_);function ln(e,t){if(e!==void 0)try{return En.toColor(e)}catch{}return t}var $O=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)}},FO=class{constructor(){this._services=new $O,this._services.set(Ey,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Bj(e).sort((l,d)=>l.index-d.index),r=[];for(let l of n){let d=this._services.get(l.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);r.push(d)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},WO={trace:0,debug:1,info:2,warn:3,error:4,off:5},KO="xterm.js: ",G_=class extends Et{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=WO[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?"":KO)+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)}};G_=On([Ge(0,Ki)],G_);var Ex=class extends Et{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ue),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ue),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ue),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Tt=3,Jn=Object.freeze(new Xd),pf=0,dv=2,sd=class xE{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Tt);let o=n||Bs.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*Tt+0],r=n&2097151;return[this._data[t*Tt+1],n&2097152?this._combined[t]:r?fo(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Tt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Tt+0]=t|2097152|n[2]<<22):this._data[t*Tt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Tt+0]>>22}hasWidth(t){return this._data[t*Tt+0]&12582912}getFg(t){return this._data[t*Tt+1]}getBg(t){return this._data[t*Tt+2]}hasContent(t){return this._data[t*Tt+0]&4194303}getCodePoint(t){let n=this._data[t*Tt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Tt+0]&2097152}getString(t){let n=this._data[t*Tt+0];return n&2097152?this._combined[t]:n&2097151?fo(n&2097151):""}isProtected(t){return this._data[t*Tt+2]&536870912}loadCell(t,n){return pf=t*Tt,n.content=this._data[pf+0],n.fg=this._data[pf+1],n.bg=this._data[pf+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*Tt+0]=n.content,this._data[t*Tt+1]=n.fg,this._data[t*Tt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Tt+0]=n|r<<22,this._data[t*Tt+1]=o.fg,this._data[t*Tt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*Tt+0];o&2097152?this._combined[t]+=fo(n):o&2097151?(this._combined[t]=fo(o&2097151)+fo(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*Tt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new Bs;for(let l=this.length-t-n-1;l>=0;--l)this.setCell(t+n+l,this.loadCell(t+l,o));for(let l=0;l<n;++l)this.setCell(t+l,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new Bs;for(let l=0;l<this.length-t-n;++l)this.setCell(t+l,this.loadCell(t+n+l,o));for(let l=this.length-n;l<this.length;++l)this.setCell(l,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*dv<this._data.buffer.byteLength;let r=t*Tt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let d=0;d<o.length;d++){let f=parseInt(o[d],10);f>=t&&delete this._combined[f]}let l=Object.keys(this._extendedAttrs);for(let d=0;d<l.length;d++){let f=parseInt(l[d],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*dv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*dv<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new 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*Tt+0]&4194303)return t+(this._data[t*Tt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Tt+0]&4194303||this._data[t*Tt+2]&50331648)return t+(this._data[t*Tt+0]>>22);return 0}copyCellsFrom(t,n,r,o,l){let d=t._data;if(l)for(let m=o-1;m>=0;m--){for(let p=0;p<Tt;p++)this._data[(r+m)*Tt+p]=d[(n+m)*Tt+p];d[(n+m)*Tt+2]&268435456&&(this._extendedAttrs[r+m]=t._extendedAttrs[n+m])}else for(let m=0;m<o;m++){for(let p=0;p<Tt;p++)this._data[(r+m)*Tt+p]=d[(n+m)*Tt+p];d[(n+m)*Tt+2]&268435456&&(this._extendedAttrs[r+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+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;n<r;){let d=this._data[n*Tt+0],f=d&2097151,m=d&2097152?this._combined[n]:f?fo(f):go;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 qO(e,t,n,r,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&&r>=f&&r<m){f+=b.length-1;continue}let _=0,w=Md(b,_,t),S=1,x=0;for(;S<b.length;){let L=Md(b,S,t),A=L-x,K=n-w,P=Math.min(A,K);b[_].copyCellsFrom(b[S],x,w,P,!1),w+=P,w===n&&(_++,w=0),x+=P,x===L&&(S++,x=0),w===0&&_!==0&&b[_-1].getWidth(n-1)===2&&(b[_].copyCellsFrom(b[_-1],n-1,w++,1,!1),b[_-1].setCell(n-1,o))}b[_].replaceCells(w,n,o);let E=0;for(let L=b.length-1;L>0&&(L>_||b[L].getTrimmedLength()===0);L--)E++;E>0&&(d.push(f+b.length-E),d.push(E)),f+=b.length-1}return d}function VO(e,t){let n=[],r=0,o=t[r],l=0;for(let d=0;d<e.length;d++)if(o===d){let f=t[++r];e.onDeleteEmitter.fire({index:d-l,amount:f}),d+=f-1,l+=f,o=t[++r]}else n.push(d);return{layout:n,countRemoved:l}}function YO(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function GO(e,t,n){let r=[],o=e.map((m,p)=>Md(e,p,t)).reduce((m,p)=>m+p),l=0,d=0,f=0;for(;f<o;){if(o-f<n){r.push(o-f);break}l+=n;let m=Md(e,d,t);l>m&&(l-=m,d++);let p=e[d].getWidth(l-1)===2;p&&l--;let b=p?n-1:n;r.push(b),f+=b}return r}function Md(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var CE=class kE{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=kE._nextId++,this._onDispose=this.register(new Ue),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),_l(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};CE._nextId=1;var XO=CE,ci={},al=ci.B;ci[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:"≥","{":"π","|":"≠","}":"£","~":"·"};ci.A={"#":"£"};ci.B=void 0;ci[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ci.C=ci[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ci.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ci.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ci.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ci.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ci.E=ci[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ci.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ci.H=ci[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ci["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Rx=4294967295,Nx=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=Jn.clone(),this.savedCharset=al,this.markers=[],this._nullCell=Bs.fromCharData([0,$T,1,0]),this._whitespaceCell=Bs.fromCharData([0,go,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new op,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ex(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 ip),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 ip),this._whitespaceCell}getBlankLine(e,t){return new sd(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>Rx?Rx:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Jn);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 Ex(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Jn),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let d=0;d<this.lines.length;d++)r+=+this.lines.get(d).resize(e,n);let l=0;if(this._rows<t)for(let d=this._rows;d<t;d++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new sd(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 sd(e,n)));else for(let d=this._rows;d>t;d--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let d=this.lines.length-o;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),l&&(this.y+=l),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let l=0;l<this.lines.length;l++)r+=+this.lines.get(l).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=qO(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Jn),n);if(r.length>0){let o=VO(this.lines,r);YO(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Jn),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new sd(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Jn),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 P=this.ybase+this.y;if(P>=d&&P<d+m.length)continue}let p=m[m.length-1].getTrimmedLength(),b=GO(m,this._cols,e),_=b.length-m.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+_):w=Math.max(0,this.lines.length-this.lines.maxLength+_);let S=[];for(let P=0;P<_;P++){let z=this.getBlankLine(Jn,!0);S.push(z)}S.length>0&&(o.push({start:d+m.length+l,newLines:S}),l+=S.length),m.push(...S);let x=b.length-1,E=b[x];E===0&&(x--,E=b[x]);let L=m.length-_-1,A=p;for(;L>=0;){let P=Math.min(A,E);if(m[x]===void 0)break;if(m[x].copyCellsFrom(m[L],A-P,E-P,P,!0),E-=P,E===0&&(x--,E=b[x]),A-=P,A===0){L--;let z=Math.max(L,0);A=Md(m,z,this._cols)}}for(let P=0;P<m.length;P++)b[P]<e&&m[P].setCell(b[P],r);let K=_-w;for(;K-- >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 E=0;E<this.lines.length;E++)f.push(this.lines.get(E));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 w=0;for(let E=Math.min(this.lines.maxLength-1,m+l-1);E>=0;E--)if(_&&_.start>p+w){for(let L=_.newLines.length-1;L>=0;L--)this.lines.set(E--,_.newLines[L]);E++,d.push({index:p+1,amount:_.newLines.length}),w+=_.newLines.length,_=o[++b]}else this.lines.set(E,f[p--]);let S=0;for(let E=d.length-1;E>=0;E--)d[E].index+=S,this.lines.onInsertEmitter.fire(d[E]),S+=d[E].amount;let x=Math.max(0,m+l-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new XO(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)}},ZO=class extends Et{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ue),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Nx(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Nx(!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,X_=class extends Et{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ue),this.onResize=this._onResize.event,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,TE),this.rows=Math.max(e.rawOptions.rows||0,EE),this.buffers=this._register(new ZO(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;l===n.lines.length-1?d?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(l+1,0,r.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=l-o+1;n.lines.shiftElements(o+1,d-1,-1),n.lines.set(l,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};X_=On([Ge(0,Ki)],X_);var mc={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:ap,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},QO=["normal","bold","100","200","300","400","500","600","700","800","900"],JO=class extends Et{constructor(e){super(),this._onOptionChange=this._register(new Ue),this.onOptionChange=this._onOptionChange.event;let t={...mc};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(xn(()=>{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 mc))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in mc))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=mc[e]),!eB(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=mc[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=QO.includes(t)?t:mc[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 eB(e){return e==="block"||e==="underline"||e==="bar"}function rd(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&rd(e[r],t-1);return n}var Dx=Object.freeze({insertMode:!1}),Mx=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Z_=class extends Et{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ue),this.onData=this._onData.event,this._onUserInput=this._register(new Ue),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ue),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ue),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=rd(Dx),this.decPrivateModes=rd(Mx)}reset(){this.modes=rd(Dx),this.decPrivateModes=rd(Mx)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Z_=On([Ge(0,Wi),Ge(1,VT),Ge(2,Ki)],Z_);var Ax={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 hv(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 fv=String.fromCharCode,Lx={DEFAULT:e=>{let t=[hv(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${fv(t[0])}${fv(t[1])}${fv(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hv(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hv(e,!0)};${e.x};${e.y}${t}`}},Q_=class extends Et{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ue),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Ax))this.addProtocol(r,Ax[r]);for(let r of Object.keys(Lx))this.addEncoding(r,Lx[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Q_=On([Ge(0,Wi),Ge(1,Sl),Ge(2,Ki)],Q_);var pv=[[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]],tB=[[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]],ai;function nB(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var iB=class{constructor(){if(this.version="6",!ai){ai=new Uint8Array(65536),ai.fill(1),ai[0]=0,ai.fill(0,1,32),ai.fill(0,127,160),ai.fill(2,4352,4448),ai[9001]=2,ai[9002]=2,ai.fill(2,11904,42192),ai[12351]=1,ai.fill(2,44032,55204),ai.fill(2,63744,64256),ai.fill(2,65040,65050),ai.fill(2,65072,65136),ai.fill(2,65280,65377),ai.fill(2,65504,65511);for(let e=0;e<pv.length;++e)ai.fill(0,pv[e][0],pv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ai[e]:nB(e,tB)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=cl.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return cl.createPropertyValue(0,n,r)}},cl=class Mf{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ue,this.onChange=this._onChange.event;let t=new iB;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let l=0;l<o;++l){let d=t.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=o)return n+this.wcwidth(d);let p=t.charCodeAt(l);56320<=p&&p<=57343?d=(d-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let f=this.charProperties(d,r),m=Mf.extractWidth(f);Mf.extractShouldJoin(f)&&(m-=Mf.extractWidth(r)),n+=m,r=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},sB=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 jx(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 Yu=2147483647,rB=256,RE=class J_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>rB)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 J_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new J_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Yu?Yu: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>Yu?Yu:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Yu):t}},Gu=[],aB=class{constructor(){this._state=0,this._active=Gu,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gu}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=Gu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gu,!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",Hp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Gu,this._id=-1,this._state=0}}},gs=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+=Hp(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}},Xu=[],oB=class{constructor(){this._handlers=Object.create(null),this._active=Xu,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xu}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Xu,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xu,!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",Hp(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Xu,this._ident=0}},ad=new RE;ad.addParam(0);var Ox=class{constructor(e){this._handler=e,this._data="",this._params=ad,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ad,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Hp(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=ad,this._data="",this._hitLimit=!1,n));return this._params=ad,this._data="",this._hitLimit=!1,t}},lB=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},js=160,cB=(function(){let e=new lB(4095),t=Array.apply(null,Array(256)).map((f,m)=>m),n=(f,m)=>t.slice(f,m),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),d;e.setDefault(1,0),e.addMany(r,0,2,0);for(d in l)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(js,0,2,0),e.add(js,8,5,8),e.add(js,6,0,6),e.add(js,11,0,11),e.add(js,13,13,13),e})(),uB=class extends Et{constructor(e=cB){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,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(xn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new aB),this._dcsParser=this._register(new oB),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,l=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,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(r=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(r!==24&&r!==26,n),d)return d;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],d=this._oscParser.end(r!==24&&r!==26,n),d)return d;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=l;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:js)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<js){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<js){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<js){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<js){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|r],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|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++f<t&&(r=e[f])>47&&r<60);f--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let b=this._escHandlers[this._collect<<8|r],_=b?b.length-1:-1;for(;_>=0&&(d=b[_](),d!==!0);_--)if(d instanceof Promise)return this._preserveStack(4,b,_,o,f),d;_<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let w=f+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<js){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(d=this._dcsParser.unhook(r!==24&&r!==26),d)return this._preserveStack(6,[],0,o,f),d;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=f+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<js){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(d=this._oscParser.end(r!==24&&r!==26),d)return this._preserveStack(5,[],0,o,f),d;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},dB=/^([\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})$/,hB=/^[\da-f]+$/;function Bx(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=dB.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),hB.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return r}}function mv(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function fB(e,t=16){let[n,r,o]=e;return`rgb:${mv(n,t)}/${mv(r,t)}/${mv(o,t)}`}var pB={"(":0,")":1,"*":2,"+":3,"-":1,".":2},oo=131072,Ix=10;function Px(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 zx=5e3,Hx=0,mB=class extends Et{constructor(e,t,n,r,o,l,d,f,m=new uB){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=d,this._unicodeService=f,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new jj,this._utf8Decoder=new Oj,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Jn.clone(),this._eraseAttrDataInternal=Jn.clone(),this._onRequestBell=this._register(new Ue),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ue),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ue),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ue),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ue),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ue),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ue),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ue),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ue),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ue),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ue),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ue),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ue),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new eb(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(Re.BEL,()=>this.bell()),this._parser.setExecuteHandler(Re.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Re.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Re.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Re.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Re.BS,()=>this.backspace()),this._parser.setExecuteHandler(Re.HT,()=>this.tab()),this._parser.setExecuteHandler(Re.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Re.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Nf.IND,()=>this.index()),this._parser.setExecuteHandler(Nf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Nf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new gs(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new gs(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new gs(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new gs(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new gs(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new gs(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new gs(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new gs(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new gs(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new gs(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new gs(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new gs(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 ci)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 Ox((p,b)=>this.requestStatusString(p,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),zx))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${zx} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,l=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>oo&&(l=this._parseStack.position+oo)}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<oo&&(this._parseBuffer=new Uint32Array(Math.min(e.length,oo))),d||this._dirtyRowTracker.clearRange(),e.length>oo)for(let p=l;p<e.length;p+=oo){let b=p+oo<e.length?p+oo:e.length,_=typeof e=="string"?this._stringDecoder.decode(e.substring(p,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,b),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,_))return this._preserveStack(r,o,_,p),this._logSlowResolvingAsync(n),n}else if(!d){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),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 r,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 w=this._parser.precedingJoinState;for(let S=t;S<n;++S){if(r=e[S],r<127&&l){let A=l[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let x=this._unicodeService.charProperties(r,w);o=cl.extractWidth(x);let E=cl.extractShouldJoin(x),L=E?cl.extractWidth(w):0;if(w=x,d&&this._onA11yChar.fire(fo(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-L>f){if(m){let A=_,K=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 sd&&_.copyCellsFrom(A,K,0,L,!1);K<f;)A.setCellFromCodepoint(K++,0,1,b)}else if(this._activeBuffer.x=f-1,o===2)continue}if(E&&this._activeBuffer.x){let A=_.getWidth(this._activeBuffer.x-1)?1:2;_.addCodepointToCell(this._activeBuffer.x-A,r,o);for(let K=o-L;--K>=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++,r,o,b),o>0)for(;--o;)_.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&n-t>0&&_.getWidth(this._activeBuffer.x)===0&&!_.hasContent(this._activeBuffer.x)&&_.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Px(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Ox(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new gs(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Jn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=cl.extractWidth(t),o=this._activeBuffer.x-r,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),d=new Uint32Array(l.length*n),f=0;for(let p=0;p<l.length;){let b=l.codePointAt(p)||0;d[f++]=b,p+=b>65535?2:1}let 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(Re.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Re.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Re.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Re.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Re.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,al),this._charsetService.setgCharset(1,al),this._charsetService.setgCharset(2,al),this._charsetService.setgCharset(3,al);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;(E=>(E[E.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",E[E.SET=1]="SET",E[E.RESET=2]="RESET",E[E.PERMANENTLY_SET=3]="PERMANENTLY_SET",E[E.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=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,w=(E,L)=>(d.triggerDataEvent(`${Re.ESC}[${t?"":"?"}${E};${L}$y`),!0),S=E=>E?1:2,x=e.params[0];return t?x===2?w(x,4):x===4?w(x,S(d.modes.insertMode)):x===12?w(x,3):x===20?w(x,S(_.convertEol)):w(x,0):x===1?w(x,S(r.applicationCursorKeys)):x===3?w(x,_.windowOptions.setWinLines?m===80?2:m===132?1:0:0):x===6?w(x,S(r.origin)):x===7?w(x,S(r.wraparound)):x===8?w(x,3):x===9?w(x,S(o==="X10")):x===12?w(x,S(_.cursorBlink)):x===25?w(x,S(!d.isCursorHidden)):x===45?w(x,S(r.reverseWraparound)):x===66?w(x,S(r.applicationKeypad)):x===67?w(x,4):x===1e3?w(x,S(o==="VT200")):x===1002?w(x,S(o==="DRAG")):x===1003?w(x,S(o==="ANY")):x===1004?w(x,S(r.sendFocus)):x===1005?w(x,4):x===1006?w(x,S(l==="SGR")):x===1015?w(x,4):x===1016?w(x,S(l==="SGR_PIXELS")):x===1048?w(x,1):x===47||x===1047||x===1049?w(x,S(p===b)):x===2004?w(x,S(r.bracketedPasteMode)):x===2026?w(x,S(r.synchronizedOutput)):w(x,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=Xd.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,l=0;do{if(r[l+o]=e.params[t+l],e.hasSubParams(t+l)){let d=e.getSubParams(t+l),f=0;do r[1]===5&&(o=1),r[l+f+1+o]=d[f];while(++f<d.length&&f+l+1+o<r.length);break}if(r[1]===5&&l+o>=2||r[1]===2&&l+o>=5)break;r[1]&&(o=1)}while(++l+t<e.length&&l+o<r.length);for(let d=2;d<r.length;++d)r[d]===-1&&(r[d]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return l}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Jn.fg,e.bg=Jn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Jn.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Jn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Jn.fg&16777215,r.bg&=-67108864,r.bg|=Jn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Re.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Re.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(`${Re.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=Jn.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(!Px(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(`${Re.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ix&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ix&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let l=parseInt(r);if(Ux(l))if(o==="?")t.push({type:0,index:l});else{let d=Bx(o);d&&t.push({type:1,index:l,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(l=>l.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Bx(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);Ux(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,al),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(pB[e[0]],ci[e[1]]||al),!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=Jn.clone(),this._eraseAttrDataInternal=Jn.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 Bs;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${Re.ESC}${d}${Re.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},eb=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&&(Hx=e,e=t,t=Hx),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};eb=On([Ge(0,Wi)],eb);function Ux(e){return 0<=e&&e<256}var gB=5e7,$x=12,vB=50,_B=class extends Et{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Ue),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>gB)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let d=f=>performance.now()-n>=$x?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(d);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=$x)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vB&&(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()}},tb=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,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(d,l)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};tb=On([Ge(0,Wi)],tb);var Fx=!1,bB=class extends Et{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Pc),this._onBinary=this._register(new Ue),this.onBinary=this._onBinary.event,this._onData=this._register(new Ue),this.onData=this._onData.event,this._onLineFeed=this._register(new Ue),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ue),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ue),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ue),this._instantiationService=new FO,this.optionsService=this._register(new JO(e)),this._instantiationService.setService(Ki,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(X_)),this._instantiationService.setService(Wi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(G_)),this._instantiationService.setService(VT,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Z_)),this._instantiationService.setService(Sl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Q_)),this._instantiationService.setService(qT,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(cl)),this._instantiationService.setService(zj,this.unicodeService),this._charsetService=this._instantiationService.createInstance(sB),this._instantiationService.setService(Pj,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(tb),this._instantiationService.setService(YT,this._oscLinkService),this._inputHandler=this._register(new mB(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Mi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Mi.forward(this._bufferService.onResize,this._onResize)),this._register(Mi.forward(this.coreService.onData,this._onData)),this._register(Mi.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 _B((t,n)=>this._inputHandler.parse(t,n))),this._register(Mi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ue),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Fx&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fx=!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(jx.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(jx(this._bufferService),!1))),this._windowsWrappingHeuristics.value=xn(()=>{for(let t of e)t.dispose()})}}},yB={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 SB(e,t,n,r){let o={type:0,cancel:!1,key:void 0},l=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=Re.ESC+"OA":o.key=Re.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=Re.ESC+"OD":o.key=Re.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=Re.ESC+"OC":o.key=Re.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=Re.ESC+"OB":o.key=Re.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":Re.DEL,e.altKey&&(o.key=Re.ESC+o.key);break;case 9:if(e.shiftKey){o.key=Re.ESC+"[Z";break}o.key=Re.HT,o.cancel=!0;break;case 13:o.key=e.altKey?Re.ESC+Re.CR:Re.CR,o.cancel=!0;break;case 27:o.key=Re.ESC,e.altKey&&(o.key=Re.ESC+Re.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=Re.ESC+"[1;"+(l+1)+"D":t?o.key=Re.ESC+"OD":o.key=Re.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=Re.ESC+"[1;"+(l+1)+"C":t?o.key=Re.ESC+"OC":o.key=Re.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=Re.ESC+"[1;"+(l+1)+"A":t?o.key=Re.ESC+"OA":o.key=Re.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=Re.ESC+"[1;"+(l+1)+"B":t?o.key=Re.ESC+"OB":o.key=Re.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=Re.ESC+"[2~");break;case 46:l?o.key=Re.ESC+"[3;"+(l+1)+"~":o.key=Re.ESC+"[3~";break;case 36:l?o.key=Re.ESC+"[1;"+(l+1)+"H":t?o.key=Re.ESC+"OH":o.key=Re.ESC+"[H";break;case 35:l?o.key=Re.ESC+"[1;"+(l+1)+"F":t?o.key=Re.ESC+"OF":o.key=Re.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=Re.ESC+"[5;"+(l+1)+"~":o.key=Re.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=Re.ESC+"[6;"+(l+1)+"~":o.key=Re.ESC+"[6~";break;case 112:l?o.key=Re.ESC+"[1;"+(l+1)+"P":o.key=Re.ESC+"OP";break;case 113:l?o.key=Re.ESC+"[1;"+(l+1)+"Q":o.key=Re.ESC+"OQ";break;case 114:l?o.key=Re.ESC+"[1;"+(l+1)+"R":o.key=Re.ESC+"OR";break;case 115:l?o.key=Re.ESC+"[1;"+(l+1)+"S":o.key=Re.ESC+"OS";break;case 116:l?o.key=Re.ESC+"[15;"+(l+1)+"~":o.key=Re.ESC+"[15~";break;case 117:l?o.key=Re.ESC+"[17;"+(l+1)+"~":o.key=Re.ESC+"[17~";break;case 118:l?o.key=Re.ESC+"[18;"+(l+1)+"~":o.key=Re.ESC+"[18~";break;case 119:l?o.key=Re.ESC+"[19;"+(l+1)+"~":o.key=Re.ESC+"[19~";break;case 120:l?o.key=Re.ESC+"[20;"+(l+1)+"~":o.key=Re.ESC+"[20~";break;case 121:l?o.key=Re.ESC+"[21;"+(l+1)+"~":o.key=Re.ESC+"[21~";break;case 122:l?o.key=Re.ESC+"[23;"+(l+1)+"~":o.key=Re.ESC+"[23~";break;case 123:l?o.key=Re.ESC+"[24;"+(l+1)+"~":o.key=Re.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=Re.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=Re.DEL:e.keyCode===219?o.key=Re.ESC:e.keyCode===220?o.key=Re.FS:e.keyCode===221&&(o.key=Re.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=yB[e.keyCode]?.[e.shiftKey?1:0];if(d)o.key=Re.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=Re.ESC+m}else if(e.keyCode===32)o.key=Re.ESC+(e.ctrlKey?Re.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=Re.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=Re.US),e.key==="@"&&(o.key=Re.NUL));break}return o}var $n=0,wB=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new op,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new op,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,l)=>this._getKey(o)-this._getKey(l)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($n=this._search(t),$n===-1)||this._getKey(this._array[$n])!==t)return!1;do if(this._array[$n]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($n),!0;while(++$n<this._array.length&&this._getKey(this._array[$n])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($n=this._search(e),!($n<0||$n>=this._array.length)&&this._getKey(this._array[$n])===e))do yield this._array[$n];while(++$n<this._array.length&&this._getKey(this._array[$n])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($n=this._search(e),!($n<0||$n>=this._array.length)&&this._getKey(this._array[$n])===e))do t(this._array[$n]);while(++$n<this._array.length&&this._getKey(this._array[$n])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},gv=0,Wx=0,xB=class extends Et{constructor(){super(),this._decorations=new wB(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ue),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ue),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(xn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new CB(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let l of this._decorations.getKeyIterator(t))r=l.options.x??0,o=r+(l.options.width??1),e>=r&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{gv=o.options.x??0,Wx=gv+(o.options.width??1),e>=gv&&e<Wx&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},CB=class extends _o{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ue),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ue),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=En.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=En.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},kB=1e3,TB=class{constructor(e,t=kB){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Kx=20,lp=class extends Et{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new TB(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(gt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(xn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Kx+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Kx+1&&(this._liveRegion.textContent+=S_.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let l=n.lines.get(n.ydisp+o),d=[],f=l?.translateToString(!0,void 0,void 0,d)||"",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",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==r)return;let d,f;if(t===0?(d=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(d=this._rowElements.shift(),f=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let 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 r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:f,offset: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 w=m<_.length?_[m]:_.slice(-1)[0]+1;return w>=this._terminal.cols&&(++b,w=0),{row:b,column:w}},l=o(t),d=o(n);if(!(!l||!d)){if(l.row>d.row||l.row===d.row&&l.column>=d.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(d.row-l.row)*this._terminal.cols-l.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};lp=On([Ge(1,Ey),Ge(2,ya),Ge(3,Sa)],lp);var nb=class extends Et{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ue),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ue),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(xn(()=>{_l(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(gt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(gt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(gt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(gt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,l=>{if(this._isMouseOut)return;let d=l?.map(f=>({link:f}));this._activeProviderReplies?.set(r,d),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let l=0;l<o.length;l++){let d=o[l],f=d.link.range.start.y<e?0:d.link.range.start.x,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 r=this._activeProviderReplies.get(e),o=!1;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(o=!0);if(!o&&r){let l=r.find(d=>this._linkAtPosition(d.link,t));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=this._activeProviderReplies.get(l)?.find(f=>this._linkAtPosition(f.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&EB(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,_l(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};nb=On([Ge(1,Ry),Ge(2,Sa),Ge(3,Wi),Ge(4,XT)],nb);function EB(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 RB=class extends bB{constructor(e={}){super(e),this._linkifier=this._register(new Pc),this.browser=mE,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Pc),this._onCursorMove=this._register(new Ue),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ue),this.onKey=this._onKey.event,this._onRender=this._register(new Ue),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ue),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ue),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ue),this.onBell=this._onBell.event,this._onFocus=this._register(new Ue),this._onBlur=this._register(new Ue),this._onA11yCharEmitter=this._register(new Ue),this._onA11yTabEmitter=this._register(new Ue),this._onWillOpen=this._register(new Ue),this._setup(),this._decorationService=this._instantiationService.createInstance(xB),this._instantiationService.setService(Zd,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(vO),this._instantiationService.setService(XT,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x_)),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(Mi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Mi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Mi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Mi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(xn(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=yn.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${Re.ESC}]${r};${fB(o)}${fE.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=ei.toColor(...t.color));else{let l=n;this._themeService.modifyColors(d=>d[l]=ei.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(lp,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Re.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(Re.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=d+"px",this.textarea.style.width=l+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(gt(this.element,"copy",t=>{this.hasSelection()&&Aj(t,this._selectionService)}));let e=t=>Lj(t,this.textarea,this.coreService,this.optionsService);this._register(gt(this.textarea,"paste",e)),this._register(gt(this.element,"paste",e)),gE?this._register(gt(this.element,"mousedown",t=>{t.button===2&&tx(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(gt(this.element,"contextmenu",t=>{tx(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),By&&this._register(gt(this.element,"auxclick",t=>{t.button===1&&UT(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(gt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(gt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(gt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(gt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(gt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(gt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(gt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(gt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",y_.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(mO,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ya,this._coreBrowserService),this._register(gt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(gt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(W_,this._document,this._helperContainer),this._instantiationService.setService(Up,this._charSizeService),this._themeService=this._instantiationService.createInstance(Y_),this._instantiationService.setService(Kc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(rp),this._instantiationService.setService(GT,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(q_,this.rows,this.screenElement)),this._instantiationService.setService(Sa,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(U_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(K_),this._instantiationService.setService(Ry,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(nb,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(z_,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(V_,this.element,this.screenElement,r)),this._instantiationService.setService(Uj,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(Mi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(H_,this.screenElement)),this._register(gt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(lp,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sp,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sp,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(F_,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 r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(l)),wheel:l=>(n(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&n(l)},mousemove:l=>{l.buttons||n(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),l&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),l&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),l&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),l&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(gt(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(l)})),this._register(gt(t,"wheel",l=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(l,!0);let d=Re.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=SB(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Re.ETX||n.key===Re.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)&&(NB(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(Jn));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(Re.ESC+"[I"):this.coreService.triggerDataEvent(Re.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(`${Re.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Re.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function NB(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var DB=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)}},MB=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 Bs)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},qx=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 MB(t)}getNullCell(){return new Bs}},AB=class extends Et{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ue),this.onBufferChange=this._onBufferChange.event,this._normal=new qx(this._core.buffers.normal,"normal"),this._alternate=new qx(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)}},LB=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},jB=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}},OB=["cols","rows"],hr=0,BB=class extends Et{constructor(e){super(),this._core=this._register(new RB(e)),this._addonManager=this._register(new DB),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(OB.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 LB(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jB(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 AB(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 y_.get()},set promptLabel(e){y_.set(e)},get tooMuchOutput(){return S_.get()},set tooMuchOutput(e){S_.set(e)}}}_verifyIntegers(...e){for(hr of e)if(hr===1/0||isNaN(hr)||hr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(hr of e)if(hr&&(hr===1/0||isNaN(hr)||hr%1!==0||hr<0))throw new Error("This API only accepts positive integers")}};function Wp(e){return e.normalize("NFC").trim().toLowerCase()}function IB(e){const t=Wp(e);if(t.length>256)return"Use at most 256 characters.";const n=[...t.replace(/\s/gu,"")].length,r=/[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/u.test(t)?2:3;return n<r?`Enter at least ${r} non-space characters.`:null}const PB=Ht.lazy(()=>Ty(()=>import("./TranscriptMarkdownBody-CUFmcDlb.js"),__vite__mapDeps([2,1])));function NE({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:l}){const d=v.useRef(new Map),f=v.useMemo(()=>{const p=new Map,b=new Array(e.length);for(let _=e.length-1;_>=0;_--){const w=e[_],S=`${w.kind}\0${w.header??""}\0${w.body}`;let x=2166136261,E=5381;for(let K=0;K<S.length;K++)x=Math.imul(x^S.charCodeAt(K),16777619),E=Math.imul(E,33)^S.charCodeAt(K);const L=`${S.length}:${x>>>0}:${E>>>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(r==="prompt"){p.scrollIntoView({block:"start",inline:"nearest"});return}const b=p.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?b[o.matchIndexInEntry]:null)??p).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let 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,w=n===b?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return u.jsxs("section",{ref:S=>{S?d.current.set(b,S):d.current.delete(b)},className:`transcript-entry transcript-entry-${p.kind}${w}`,"data-transcript-kind":p.kind,"data-transcript-entry-key":f[b],"data-transcript-entry-index":b,..._!==null?{"data-transcript-prompt-position":_}:{},children:[p.header?u.jsx("div",{className:"transcript-entry-header",children:DE(p.header,t)}):null,p.body?u.jsx("div",{className:"transcript-entry-body",children:p.kind==="tool"?u.jsx(Vx,{text:p.body,searchQuery:t}):u.jsx(Ht.Suspense,{fallback:u.jsx(Vx,{text:p.body,searchQuery:t}),children:u.jsx(PB,{text:p.body,searchQuery:t})})}):null]},f[b])})})}function Vx({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((r,o)=>u.jsx("span",{className:`transcript-line transcript-line-${FB(r,o===0||n[o-1]?.trim()==="")}`,children:DE(r,t)},o))})}function DE(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),l=[];let d=0,f=r.indexOf(o);for(;f!==-1;){f>d&&l.push(e.slice(d,f));const m=f+n.length;l.push(u.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,m)},`${f}-${m}`)),d=m,f=r.indexOf(o,d)}return d<e.length&&l.push(e.slice(d)),l.length>0?l:e||" "}function zB(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,l=r.indexOf(n);for(;l!==-1;)o+=1,l=r.indexOf(n,l+n.length);return o}function ib(e){const t=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",l=[];function d(){const f=HB(l).join(`
|
|
36
|
+
`);(r||f)&&n.push({header:r,body:f,kind:o}),r=null,o="plain",l=[]}for(const f of t.split(`
|
|
37
|
+
`)){const m=UB(f);m?(d(),r=f,o=m):l.push(f)}return d(),n}function HB(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function UB(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 $B(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const l=o.header?`${o.header}
|
|
38
|
+
${o.body}`:o.body,d=zB(l,t);for(let f=0;f<d;f+=1)n.push({entryIndex:r,matchIndexInEntry:f})}return n}function FB(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||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 bo(e){return e==="codex"?"Codex":"Claude"}function bc(e,t,n={}){const r=`[nterminal] ${bo(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
+
`).replace(/\r/g,`
|
|
40
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
41
|
+
|
|
42
|
+
`).trimEnd(),l=Iy(o),d=n.includeTools?l:ME(l);return d?`${d}
|
|
43
|
+
`:""}function Iy(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=WB(n);return r?`[${r}]`:t})}function WB(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=Zu(t.getMonth()+1),o=Zu(t.getDate()),l=Zu(t.getHours()),d=Zu(t.getMinutes()),f=Zu(t.getSeconds());return`${n}-${r}-${o} ${l}:${d}:${f}`}function Zu(e){return e.toString().padStart(2,"0")}function cp(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 r=!1,o=!1,l=!0;for(const d of t){const f=d.trim()==="",m=l?KB(d):null;if(m&&(r=m==="tool",o=!1),AE(d)){o=!0,l=!1;continue}if(o){f?(o=!1,r||n.push(d),l=!0):l=!1;continue}r||n.push(d),l=f}return n.join(`
|
|
47
|
+
`).replace(/\n{3,}/g,`
|
|
48
|
+
|
|
49
|
+
`).trimEnd()}function KB(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 pa(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Yx(e,t){return e===null?t===null:t!==null&&pa(e,t)}const qB=5e3,VB=200,YB=1200,GB=4,XB=Ht.memo(function({terminalId:t,serverApi:n,source:r,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),[w,S]=v.useState(null),[x,E]=v.useState(null),[L,A]=v.useState(null),[K,P]=v.useState(()=>new Set),[z,q]=v.useState(!1),[Y,I]=v.useState(!1),[F,he]=v.useState([]),[Q,ee]=v.useState(null),[ie,J]=v.useState(!1),[H,X]=v.useState(!1),[M,R]=v.useState(!1),[B,oe]=v.useState(null),ge=w?.find(j=>j.id===L)??null;v.useEffect(()=>{function j(me){me.key==="Escape"&&(me.preventDefault(),me.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(E(null),S(me=>me&&t5(me,j.subagents)?me:j.subagents),!_.current){const me=j.subagents.find(Me=>Me.hasTranscript);me&&(_.current=!0,A(Me=>Me??me.id))}}catch(j){E(j instanceof Error?j.message:"Failed to load subagents."),S(me=>me??[])}},[n,t]);v.useEffect(()=>{N();const j=window.setInterval(()=>{document.hidden||N()},qB);function me(){document.hidden||N()}return document.addEventListener("visibilitychange",me),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",me)}},[N]),v.useEffect(()=>{f.current+=1;const j=f.current;return m.current=!1,p.current=!0,b.current=null,he([]),ee(null),J(!1),oe(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(H||F.length===0)return;p.current=!1;const Me=()=>{j.scrollTop=j.scrollHeight};Me(),window.requestAnimationFrame?.(Me);return}const me=b.current;me!==null&&(b.current=null,j.scrollTop+=j.scrollHeight-me)},[F,H,Y]);async function V(j,me,Me=f.current){const ze=L;if(!(!ze||m.current)){m.current=!0,me==="initial"?X(!0):(R(!0),b.current=d.current?.scrollHeight??null),oe(null);try{let W=j,pe=0,Ce=0,Ne=[];for(;f.current===Me;){const Le=await n.getTerminalSubagentTranscriptHistory(t,ze,{...W?{cursor:W}:{},limit:VB,maxLines:YB,includeTools:Y});if(f.current!==Me)return;if(!Le.source){if(Ce<1){Ce+=1,await new Promise(Pe=>setTimeout(Pe,600));continue}oe("Subagent transcript is unavailable.");return}const ve=bc(Le.output,Le.source.provider,{includeTools:Y});if(ee(Le.cursor),J(!!(Le.hasMore&&Le.cursor)),ve&&(Ne=[ve,...Ne],cp(Ne,Y))){he(Pe=>me==="older"?[...Ne,...Pe]:Ne);return}if(!Le.hasMore||!Le.cursor||pe>=GB){Ne.length>0&&he(Pe=>me==="older"?[...Ne,...Pe]:Ne);return}W=Le.cursor,pe+=1}}catch(W){if(f.current!==Me)return;oe(W instanceof Error?W.message:"Failed to load subagent transcript.")}finally{f.current===Me&&(m.current=!1,X(!1),R(!1))}}}function re(){const j=d.current;j&&(j.scrollTop>72||!ie||!Q||m.current||V(Q,"older"))}function Z(j){P(me=>{const Me=new Set(me);return Me.delete(j)||Me.add(j),Me})}function Te(j){_.current=!0,q(!0),j.id!==L&&A(j.id),ye(j.id)}function ye(j){const me=JB(w??[],j);me.length!==0&&P(Me=>{if(me.every(W=>Me.has(W)))return Me;const ze=new Set(Me);for(const W of me)ze.add(W);return ze})}function He(){f.current+=1;const j=f.current;m.current=!1,p.current=!0,b.current=null,he([]),ee(null),J(!1),oe(null),V(null,"initial",j)}const Ke=v.useMemo(()=>cp(F,Y),[F,Y]),Ie=v.useMemo(()=>ib(Ke),[Ke]),_e=w===null;v.useEffect(()=>{if(H||M||!ie||!Q||m.current)return;const j=d.current;!j||F.length===0||j.scrollHeight<=j.clientHeight+4&&V(Q,"older")},[F,ie,Q,H,M]);const We=w?.filter(j=>j.state==="working").length??0,Oe=v.useMemo(()=>OE(ZB(w??[]),K),[w,K]);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":z?"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",w&&w.length>0?u.jsx("span",{className:"subagents-count",children:We>0?`${We} working · ${w.length} total`:`${w.length} total`}):null]}),u.jsxs("span",{title:r.sessionId,children:[bo(r.provider)," session ",r.sessionId]})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:l,children:"×"})]}),u.jsxs("div",{className:"subagents-body",children:[u.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[_e?u.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!_e&&x?u.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!_e&&!x&&w!==null&&w.length===0?u.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Oe.map(j=>{const me=j.subagent,Me=K.has(me.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 ${me.name}`,title:j.nestedWorkingCount>0?`${j.nestedCount} nested · ${j.nestedWorkingCount} working`:`${j.nestedCount} nested`,onClick:()=>Z(me.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":me.id===L?"true":"false","data-state":me.state,disabled:!me.hasTranscript,title:me.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Te(me),children:[u.jsx("span",{className:"subagent-row-dot","data-state":me.state,"aria-hidden":"true"}),u.jsxs("span",{className:"subagent-row-main",children:[u.jsxs("span",{className:"subagent-row-title",children:[u.jsx("strong",{children:me.name}),u.jsx("span",{className:"subagent-row-badge","data-kind":me.kind,children:me.kind==="cross"?bo(me.provider):me.provider})]}),me.description?u.jsx("span",{className:"subagent-row-description",children:me.description}):null,u.jsxs("span",{className:"subagent-row-meta",children:[n5(me.state),me.model?` · ${me.model}`:"",me.updatedAt?` · ${i5(me.updatedAt)}`:"",j.nestedCount>0&&!Me?` · ${j.nestedCount} nested${j.nestedWorkingCount>0?` (${j.nestedWorkingCount} working)`:""}`:""]})]})]})]},me.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:ge?ge.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:!ge,onClick:He,children:"↻"})]}),ge?u.jsx("div",{className:"subagents-transcript-hint",children:e5(ge)}):null,u.jsxs("div",{ref:d,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:re,children:[M?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!H&&ie?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Ke?u.jsx(NE,{entries:Ie,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,H?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!H&&ge&&!Ke&&!B?ie&&Q?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(Q,"older")},disabled:M,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!ge&&!_e&&!Ke?u.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,B?u.jsx("div",{className:"transcript-dialog-error",children:B}):null]})]})]})]})})});function ZB(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=QB(r,t);o?o.children.push(r):n.push(r)}for(const r of n)LE(r);return jE(n),n}function QB(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let l=r;l;){if(o.has(l.subagent.id))return null;o.add(l.subagent.id);const d=l.subagent.parentId;l=d?t.get(d):void 0}return r}function LE(e){let t=0,n=0;for(const r of e.children)LE(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,jE(e.children)}function jE(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function OE(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...OE(o.children,t,n+1));return r}function JB(e,t){const n=new Map(e.map(d=>[d.id,d])),r=[],o=new Set([t]);let l=n.get(t)?.parentId??null;for(;l&&!o.has(l);)o.add(l),r.push(l),l=n.get(l)?.parentId??null;return r}function e5(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 t5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function n5(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function i5(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function s5({options:e,value:t,onSelect:n}){const[r,o]=v.useState(!1),l=v.useRef(null),d=v.useRef(null),f=e.find(m=>m.id===t);return v.useEffect(()=>{if(!r)return;const m=()=>Array.from(l.current?.querySelectorAll('[role="menuitemradio"]')??[]),p=m();(p.find(w=>w.getAttribute("aria-checked")==="true")??p[0])?.focus();function b(w){l.current?.contains(w.target)||o(!1)}function _(w){if(w.key==="Escape")w.preventDefault(),w.stopPropagation(),o(!1),d.current?.focus();else if(["ArrowDown","ArrowUp","Home","End"].includes(w.key)){w.preventDefault(),w.stopPropagation();const S=m(),x=S.findIndex(L=>L===document.activeElement),E=w.key==="Home"?0:w.key==="End"?S.length-1:(x+(w.key==="ArrowDown"?1:-1)+S.length)%S.length;S[E]?.focus()}else w.key==="Tab"&&o(!1)}return document.addEventListener("pointerdown",b,!0),window.addEventListener("keydown",_,!0),()=>{document.removeEventListener("pointerdown",b,!0),window.removeEventListener("keydown",_,!0)}},[r]),u.jsxs("div",{className:"transcript-session-menu",ref:l,children:[u.jsxs("button",{ref:d,type:"button",className:"transcript-session-trigger","aria-label":"Transcript session","aria-haspopup":"menu","aria-expanded":r,onClick:()=>o(!r),children:[u.jsx("span",{children:f?.title??"Choose a session"}),u.jsx(RA,{size:16,"aria-hidden":"true"})]}),r?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 Py(e){const t=new Set;return e.filter(n=>t.has(n.id)?!1:(t.add(n.id),!0))}function sb(e){return!e.page||e.page.unchanged?null:{page:{...e.page,records:Py(e.page.records)},cursor:e.cursor,hasMore:e.hasMore,scrollTop:0,atBottom:!0}}function Gx(e,t){const n=sb(t);if(!n||n.page.identity!==e.page.identity||n.page.endOffset!==e.page.startOffset)return null;const r=n.page.snapshot===e.page.snapshot&&n.page.snapshotSize===e.page.snapshotSize&&n.page.snapshotMtime===e.page.snapshotMtime,o=n.page.snapshotSize<e.page.snapshotSize&&n.page.endOffset<=e.page.stableBefore&&n.page.endOffset<=n.page.stableBefore;return!r&&!o?null:{...e,page:{...e.page,startOffset:n.page.startOffset,records:Py([...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 r5(e,t){if(!BE(e.page,t.page)||!IE(e,t))return t;const n=new Set(t.page.records.map(l=>l.id)),r=e.page.records.filter(l=>l.startOffset<t.page.startOffset&&l.endOffset<=t.page.startOffset&&!n.has(l.id)),o=e.page.startOffset<t.page.startOffset;return{...t,page:{...t.page,startOffset:Math.min(e.page.startOffset,t.page.startOffset),records:Py([...r,...t.page.records])},cursor:o?e.cursor:t.cursor,hasMore:o?e.hasMore:t.hasMore,scrollTop:e.scrollTop,atBottom:e.atBottom,...e.scrollAnchor?{scrollAnchor:e.scrollAnchor}:{}}}const a5=64*1024*1024,o5=1800*1e3;let rb=0,ab=new WeakMap;const Ad=new Map,Ld=new Set;function l5(e){const t=e.page;return 2*(t.identity.length+t.snapshot.length+(e.cursor?.length??0)+t.records.reduce((n,r)=>n+r.id.length+r.block.length,0))}function ob(e){e.owner.delete(e.key),Ld.delete(e),e.snapshot=null,e.bytes=0}function vv(e){for(const r of Ld)!r.leases&&e-r.closedAt>=o5&&ob(r);let t=0;const n=[];for(const r of Ld)t+=r.bytes,r.leases||n.push(r);n.sort((r,o)=>r.closedAt-o.closedAt);for(const r of n){if(t<=a5)break;t-=r.bytes,ob(r)}for(const[r,o]of Ad)o.size||Ad.delete(r)}function _v(){rb+=1;for(const e of Ld)ob(e);Ad.clear(),ab=new WeakMap}function c5(e,t,n,r){vv(Date.now());const o=e.transcriptCacheScope;let l=o===void 0?ab.get(e):Ad.get(o);l||(l=new Map,o===void 0?ab.set(e,l):Ad.set(o,l));const d=JSON.stringify([t,n.provider,n.sessionId,r]);let f=l.get(d);f||(f={snapshot:null,bytes:0,leases:0,closedAt:0,owner:l,key:d},l.set(d,f),Ld.add(f));const m=rb,p=f;p.leases+=1;let b=!1;const _=()=>!b&&m===rb;return{get snapshot(){return _()?p.snapshot:null},current:_,write(w){_()&&(p.snapshot=w,p.bytes=l5(w),vv(Date.now()))},invalidate(){_()&&(p.snapshot=null,p.bytes=0)},release(){b||(b=!0,p.leases-=1,p.leases||(p.closedAt=Date.now()),vv(Date.now()))}}}function u5(e,t,n){if(!e.length)return null;const r=t.timestamp?Iy(`[${t.timestamp}] ${t.role}`):null;let o=e.length-1;if(r){for(let d=e.length-1;d>=0;d-=1)if(e[d]?.header===r){o=d;break}}const l=$B(e,Wp(n)).filter(d=>d.entryIndex===o);return(r&&e[o]?.header===r?l[0]:l.at(-1))??{entryIndex:o,matchIndexInEntry:0}}function d5(e,t,n,r,o,l){const[d,f]=v.useState(null),[m,p]=v.useState(!1),[b,_]=v.useState(null),w=v.useRef(null),S=v.useRef(0);function x(){S.current+=1,w.current?.abort(),w.current=null}function E(){x(),p(!1)}v.useEffect(()=>(x(),f(null),p(!1),_(null),x),[e,t,n.provider,n.sessionId,r,o,l]);async function L(A=!1){const K=IB(l);if(K){_(K);return}x();const P=S.current,z=new AbortController;w.current=z,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:Wp(l),...q?.cursor?{cursor:q.cursor}:{},...r?{candidateId:r}:{},expectedSessionId:n.sessionId,includeTools:o},z.signal);if(z.signal.aborted||P!==S.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 F=new Set(q?.hits.map(ee=>ee.id)),he=[...q?.hits??[],...I.hits.filter(ee=>!F.has(ee.id))],Q=q?.cursor;if(q={...I,hits:he.slice(-200)},f(q),I.complete||!I.cursor||I.cursor===Q||I.hits.length)break}}catch(Y){!z.signal.aborted&&P===S.current&&_(Y instanceof Error?Y.message:"Search failed.")}finally{P===S.current&&p(!1)}}return{result:d,busy:m,error:b,search:L,cancel:E}}class h5{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():UE.has(t)?this.acceptConsonant(t):$E.has(t)?this.acceptVowel(t):g5(t)&&this.canReplacePendingWith(t)?(this.pending=Zx(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=m5.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const l=p5.get(`${this.pending.vowel}${t}`);return l?(this.pending.vowel=l,""):this.flushPending()+t}const n=Xx.get(this.pending.final);if(n){this.pending.final=n[0];const l=this.flushPending();return this.pending={initial:n[1],vowel:t},l}const r=this.pending.final,o=Qx({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=Xx.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=Zx(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=Qx(this.pending);return this.pending=null,t}}const up=44032,dp=21,Cc=28,f5=19*dp*Cc,PE=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],zE=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],HE=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],UE=zy(PE),$E=zy(zE),FE=zy(HE),p5=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),WE=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],m5=new Map(WE),Xx=new Map(WE.map(([e,t])=>[t,[e[0],e[1]]]));function zy(e){return new Map(e.map((t,n)=>[t,n]))}function g5(e){const t=e.codePointAt(0);return t!==void 0&&t>=up&&t<up+f5}function Zx(e){const t=e.codePointAt(0)-up,n=Math.floor(t/(dp*Cc)),r=Math.floor(t%(dp*Cc)/Cc),o=t%Cc,l={initial:PE[n],vowel:zE[r]};return o===0?l:{...l,final:HE[o]}}function Qx(e){if(!e.vowel)return e.initial;const t=UE.get(e.initial),n=$E.get(e.vowel),r=e.final?FE.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(up+(t*dp+n)*Cc+r)}class Jx{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 r of t){if(this.state==="string-escape"){if(r==="\\"){n+="\x1B\\",this.state="text";continue}n+="",this.pending="\x1B",this.state="escape"}if(this.state==="string"){if(r==="\x1B"){this.state="string-escape";continue}n+=r,(r===""||r===""||r===""||this.stringIsOsc&&r==="\x07")&&(this.state="text");continue}if(r==="\x1B"){n+=this.pending,this.pending=r,this.state="escape",this.oversizedCsi=!1;continue}if(this.state==="escape"){const o=r.charCodeAt(0);if(o===127)continue;if(o<32&&r!==""&&r!==""){n+=r;continue}this.pending+=r,r==="["?this.state="csi":(n+=this.pending,this.pending="",this.stringIsOsc=r==="]",this.state="]PX^_".includes(r)?"string":"text");continue}if(this.state==="csi"){const o=r.charCodeAt(0);if(o===127)continue;if(o<32&&r!==""&&r!==""){n+=r;continue}this.oversizedCsi||(this.pending+=r),o>=64&&o<=126?(this.oversizedCsi||(n+=this.filterModes(this.pending)),this.pending="",this.state="text"):r===""||r===""?(n+=this.pending,this.pending="",this.state="text"):this.pending.length>4096&&(this.pending="",this.oversizedCsi=!0);continue}r===""?(this.pending=r,this.state="csi",this.oversizedCsi=!1):(n+=r,"".includes(r)&&(this.stringIsOsc=r==="",this.state="string"))}return n}filterModes(t){const n=/^(\x1b\[|\x9b)\?([0-9;:]*)([hl])$/.exec(t);if(!n)return t;const r=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=r?d:null,this.mouseEnabled||!r):[1005,1006,1015,1016].includes(d)?(r?this.mouseEncodings.add(d):this.mouseEncodings.delete(d),this.mouseEnabled||!r):!0});return o.length>0?`${n[1]}?${o.join(";")}${n[3]}`:""}}function v5(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"},_5={...KE,tab:"\x1B[Z",arrowUp:"\x1B[1;2A",arrowDown:"\x1B[1;2B",arrowRight:"\x1B[1;2C",arrowLeft:"\x1B[1;2D"};function lb(e,t=!1){return(t?_5:KE)[e]}function b5(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const y5=[{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 S5({ctrlActive:e,shiftActive:t,onCtrl:n,onShift:r,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,r(p)},children:u.jsx(xA,{size:16,"aria-hidden":"true"})}),y5.map(p=>{const _=t&&lb(p.key,!0)!==lb(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",Kp="data-nterminal-compose-open",hp="nterminal:viewport-refresh",w5=120;function x5(e=window){const t=e.document.documentElement,n=e.visualViewport,r=N5(e);function o(){Hy(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(hp,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(hp,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 Hy(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=cb(e),o=C5(e,r);return o!==null&&eC(t,qE,`${o}px`),eC(t,VE,`${n}px`),k5(t,YE,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function cb(e=window){const t=T5(e);return{keyboardInsetBottom:t,keyboardVisible:t>w5}}function C5(e,t){if((e.document.documentElement.hasAttribute(Kp)||t)&&fl(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return fl(n)?n:fl(e.innerHeight)?e.innerHeight:null}function fl(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function eC(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function k5(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function T5(e){return Math.max(E5(e),R5(e))}function E5(e){const t=e.visualViewport?.height;if(!fl(t)||!fl(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 R5(e){if(!fl(e.innerHeight))return 0;const n=GE(e)?.boundingRect?.height;return!fl(n)||n>=e.innerHeight*.8?0:Math.round(n)}function GE(e){return e.navigator.virtualKeyboard}function N5(e){const t=GE(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const eh=new Map,jd=new Map,D5=Object.freeze({open:!1,text:""});function M5(e){let t=jd.get(e);return t||(t=new Set,jd.set(e,t)),t}function XE(e){const t=jd.get(e);if(t)for(const n of Array.from(t))n()}function Dc(e){return eh.get(e)??D5}function A5(e,t){const n=M5(e);return n.add(t),()=>{n.delete(t)}}function L5(e,t){const n=Dc(e);n.open!==t&&(eh.set(e,{...n,open:t}),XE(e))}function j5(e,t){const n=Dc(e);n.text!==t&&(eh.set(e,{...n,text:t}),XE(e))}function mf(e){eh.delete(e),jd.delete(e)}function tC(){eh.clear(),jd.clear()}const Eo=new Map,Od=new Map,fp=new Map,O5=Object.freeze([]);function Bd(e){return Eo.get(e)??O5}function B5(e,t){let n=Od.get(e);return n||(n=new Set,Od.set(e,n)),n.add(t),()=>n?.delete(t)}function bv(e,t){t.length!==0&&(Eo.set(e,[...Bd(e),...t]),qp(e))}function yv(e){const t=fp.get(e)??1;return fp.set(e,t+1),`attach${t}`}function ub(e){fp.delete(e)}function Qu(e,t,n){const r=Bd(e);r.length!==0&&(Eo.set(e,r.map(o=>t.has(o.id)?n(o):o)),qp(e))}function gf(e,t){const n=Bd(e);n.find(l=>l.id===t)?.cancel?.();const o=n.filter(l=>l.id!==t);o.length!==n.length&&(o.length===0?Eo.delete(e):Eo.set(e,o),qp(e))}function ZE(e){const t=Eo.get(e);if(t){for(const n of t)n.cancel?.();Eo.delete(e),qp(e)}}function od(e){ZE(e),ub(e),Od.delete(e)}function nC(){for(const e of Array.from(Eo.keys()))od(e);Od.clear(),fp.clear()}function qp(e){for(const t of Array.from(Od.get(e)??[]))t()}class I5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function kc(e){return e?Array.from(e.types??[]).includes("Files")||$y(e.items).some(n=>n.kind==="file")?!0:i2(e.files).length>0:!1}async function QE(e){const t=$y(e.items).filter(n=>n.kind==="file");return t.length>0?P5(t):e2(e.files)}function JE(e){const t=$y(e.items).filter(o=>o.kind==="file").flatMap(o=>{const l=o.getAsFile();return l?[{relativePath:Uy(l),file:l}]:[]}),n=e2(e.files);if(t.length===0)return n;if(n.length===0)return t;const r=[...t];for(const o of n)r.some(l=>$5(l.file,o.file))||r.push(o);return r}async function P5(e){const t=[];for(const n of e){const r=F5(n);if(r){await t2(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Uy(o),file:o});continue}throw new I5("Folder upload is not supported by this browser.")}return t}function e2(e){return i2(e).map(t=>({relativePath:Uy(t),file:t}))}async function t2(e,t,n){const r=K5(t,e.name);if(e.isFile){const d=await z5(e);n.push({relativePath:r,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),l=await H5(o);for(const d of l)await t2(d,r,n)}function z5(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function H5(e){const t=[];for(;;){const n=await U5(e);if(n.length===0)return t;t.push(...n)}}function U5(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Uy(e){const t=e.webkitRelativePath;return n2(typeof t=="string"&&t?t:e.name)}function $5(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type}function F5(e){const t=e.webkitGetAsEntry?.();return W5(t)?t:null}function W5(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 K5(e,t){return n2(e?`${e}/${t}`:t)}function n2(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function $y(e){return e?Array.from(e):[]}function i2(e){return e?Array.from(e):[]}const q5=120,V5="\x1B[200~",Y5="\x1B[201~";function Af(e,t){const n=t.stripTrailingLineBreaks===!1?e:s2(e),r=X5(n);return r?t.bracketedPasteMode?`${V5}${r}${Y5}`:r:""}function G5(e){return e==="queue"?" ":"\r"}function s2(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function X5(e){return e.replace(/\r\n/g,`
|
|
50
|
+
`).replace(/\r/g,`
|
|
51
|
+
`).replace(/\n/g,"\r")}const Z5=420,Q5=3e3,iC=650,J5=80,e4=3,t4=10,n4=50*1024*1024,i4=100*1024*1024,s4=2,r4={maxFiles:t4,maxFileBytes:n4,maxBatchBytes:i4},Lf=new Set;let Mc=null;function a4({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:l,onDeleteAttachments:d}){const f=v.useMemo(()=>j=>A5(e,j),[e]),m=v.useMemo(()=>()=>Dc(e),[e]),p=v.useSyncExternalStore(f,m,m),{open:b,text:_}=p,w=v.useMemo(()=>j=>B5(e,j),[e]),S=v.useMemo(()=>()=>Bd(e),[e]),x=v.useSyncExternalStore(w,S,S),[E,L]=v.useState(r4),[A,K]=v.useState(!1),P=v.useRef(null),z=v.useRef(null),q=v.useRef(null),Y=v.useRef(null),I=v.useRef(new Map),F=v.useRef(l),he=v.useRef(d),Q=v.useRef(null),ee=v.useRef({start:0,end:0});F.current=l,he.current=d,v.useEffect(()=>()=>{Q.current?.(),Q.current=null},[]),v.useEffect(()=>{if(!b||!F.current)return;let j=!0;return F.current().then(me=>{j&&L(me)}).catch(()=>{}),()=>{j=!1}},[b,e]),v.useLayoutEffect(()=>{if(!(!b||!jf()))return p4(e),()=>m4(e)},[b,e]),v.useLayoutEffect(()=>{const j=P.current?.closest(".terminal-pane");if(!j)return;function me(){j?.removeAttribute("data-compose-open"),j?.style.removeProperty("--compose-drawer-panel-height")}if(!b){me();return}const Me=z.current;j.setAttribute("data-compose-open","true");function ze(){const Ne=Me?.getBoundingClientRect().height??0;Ne>0&&j?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Ne)}px`)}ze();const W=[window.setTimeout(ze,0),window.setTimeout(ze,180),window.setTimeout(ze,260)],pe=window.requestAnimationFrame?.(ze)??null,Ce=typeof ResizeObserver=="function"&&Me?new ResizeObserver(ze):null;return Ce&&Me&&Ce.observe(Me),()=>{for(const Ne of W)window.clearTimeout(Ne);pe!==null&&window.cancelAnimationFrame?.(pe),Ce?.disconnect(),me()}},[b]),v.useEffect(()=>{if(!b){Q.current?.(),Q.current=null;return}Cv(q.current),_e()},[b]);function ie(j){L5(e,j)}function J(j){j5(e,j)}function H(){f4(P.current),ie(!1),aC()}function X(j="send"){const me=x.filter(ze=>ze.status==="uploaded"&&ze.path);if(r||x.some(ze=>ze.status==="uploading"||ze.status==="failed")||!_&&me.length===0)return;const Me=c4(_,x);if(Me.parts.some(ze=>ze.kind==="image"||ze.value.trim())&&t(Me,j)){if(J(""),ZE(e),ub(e),jf()){q.current?.blur(),aC();return}window.setTimeout(()=>q.current?.focus(),q5+20)}}async function M(j){if(r||j.length===0)return;const me=Bd(e).filter(ve=>ve.status!=="failed"),Me=me.reduce((ve,Pe)=>ve+Pe.file.size,0);let ze=0,W=me.length;const pe=[],Ce=j.filter((ve,Pe)=>{const $e=Me+ze+ve.file.size,Be=ve.file.size>E.maxFileBytes?`File exceeds the ${rC(E.maxFileBytes)} attachment limit.`:W>=E.maxFiles?`A compose message can include up to ${E.maxFiles} attachments.`:$e>E.maxBatchBytes?`Compose attachments cannot exceed ${rC(E.maxBatchBytes)} in total.`:null;return Be?(pe.push({id:wv(Pe),reference:yv(e),file:ve.file,relativePath:sC(ve.relativePath,ve.file.name),status:"failed",error:Be}),!1):(W+=1,ze+=ve.file.size,!0)});if(pe.length>0&&bv(e,pe),Ce.length===0)return;const Ne=new Map,Le=Ce.map((ve,Pe)=>{const $e=wv(Pe),Be=new AbortController;return Ne.set($e,Be),{id:$e,reference:yv(e),file:ve.file,relativePath:sC(ve.relativePath,ve.file.name),status:"uploading",loaded:0,total:ve.file.size,cancel:()=>Be.abort()}});bv(e,Le),We(Le.map(ve=>ve.reference));for(const ve of Le)I.current.set(ve.id,Ne.get(ve.id));await h4(Le,s4,async ve=>{const Pe=Ne.get(ve.id),$e=new Set([ve.id]);try{const ut=(await o([{relativePath:ve.relativePath,file:ve.file}],{signal:Pe.signal,onProgress:ht=>{Qu(e,$e,vt=>({...vt,loaded:ht.loaded,total:ht.total}))}})).results[0];if(Pe.signal.aborted){const ht=he.current;ut?.status==="uploaded"&&ut.attachmentId&&ht&&ht([ut.attachmentId]).catch(()=>{});return}Qu(e,$e,ht=>{const{error:vt,cancel:Rt,...cn}=ht;return ut?.status==="uploaded"&&ut.path?{...cn,status:"uploaded",...ut.attachmentId?{attachmentId:ut.attachmentId}:{},path:ut.path,loaded:ut.size??ht.file.size,total:ut.size??ht.file.size}:{...cn,status:"failed",error:ut?.error??"upload_failed"}})}catch(Be){const ut=Pe.signal.aborted?"Upload canceled.":xv(Be);Qu(e,$e,ht=>{const{cancel:vt,...Rt}=ht;return{...Rt,status:"failed",error:ut}})}finally{I.current.get(ve.id)===Pe&&I.current.delete(ve.id)}})}function R(j){if(j.status!=="removing"){if(Oe(j.reference),j.status!=="uploaded"&&j.status!=="failed"||!j.attachmentId||!he.current){I.current.delete(j.id),gf(e,j.id);return}oe([j])}}function B(){J(""),ub(e);const j=x.filter(me=>!!(me.path&&me.attachmentId));for(const me of x)j.includes(me)||(I.current.delete(me.id),gf(e,me.id));j.length>0&&oe(j)}function oe(j){const me=j.flatMap(ze=>ze.attachmentId?[ze.attachmentId]:[]);if(me.length===0||!he.current){for(const ze of j)gf(e,ze.id);return}const Me=new Set(j.map(ze=>ze.id));Qu(e,Me,ze=>{const{error:W,...pe}=ze;return{...pe,status:"removing"}}),he.current(me).then(()=>{for(const ze of j)gf(e,ze.id)}).catch(ze=>{Qu(e,Me,W=>({...W,status:"failed",error:`Could not remove attachment: ${xv(ze)}`}))})}function ge(j){const me=Array.from(j.currentTarget.files??[]).map(Me=>({relativePath:Me.name,file:Me}));j.currentTarget.value="",M(me)}function N(j){const me=JE(j.clipboardData);me.length!==0&&(j.preventDefault(),M(me))}function V(j){r||!kc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),j.dataTransfer.dropEffect="copy",K(!0))}function re(j){r||!kc(j.dataTransfer)||(j.preventDefault(),j.stopPropagation(),K(!0))}function Z(j){if(!kc(j.dataTransfer))return;const me=j.relatedTarget;me instanceof Node&&j.currentTarget.contains(me)||K(!1)}function Te(j){kc(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),K(!1),QE(j.dataTransfer).then(M).catch(me=>{const Me={id:wv(0),reference:yv(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:xv(me)};bv(e,[Me])}))}const ye=x.some(j=>j.status==="uploading"),He=x.some(j=>j.status==="failed"),Ke=x.filter(j=>j.status==="uploaded"&&j.path).length,Ie=!r&&!ye&&!He&&(!!_||Ke>0);function _e(){jf()&&(Q.current?.(),Q.current=g4())}function We(j){if(j.length===0)return;const me=j.map(Be=>`@${Be}`).join(" "),Me=Dc(e).text,ze=Math.min(ee.current.start,Me.length),W=Math.min(Math.max(ze,ee.current.end),Me.length),pe=Me.slice(0,ze),Ce=Me.slice(W),Ne=pe&&!/\s$/.test(pe)?" ":"",Le=Ce&&!/^\s/.test(Ce)?" ":"",ve=`${Ne}${me}${Le}`,Pe=`${pe}${ve}${Ce}`,$e=pe.length+ve.length;ee.current={start:$e,end:$e},J(Pe),window.requestAnimationFrame(()=>{const Be=q.current;Be&&(Cv(Be),Be.setSelectionRange($e,$e))})}function Oe(j){const me=Dc(e).text,Me=me.replace(new RegExp(`@${d4(j)}(?![A-Za-z0-9_])`,"g"),"");Me!==me&&J(Me.replace(/[ \t]{2,}/g," "))}return u.jsxs("div",{ref:P,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:()=>ie(!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:z,className:"compose-drawer-panel","aria-hidden":b?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:re,onDragOver:V,onDragLeave:Z,onDrop:Te,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:H,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=>{ee.current={start:j.target.selectionStart,end:j.target.selectionEnd},J(j.target.value)},onSelect:j=>{ee.current={start:j.currentTarget.selectionStart,end:j.currentTarget.selectionEnd}},onPaste:N,onFocus:_e,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(),H())},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:ge}),x.length>0?u.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:x.map(j=>u.jsx(o4,{attachment:j,onRemove:()=>R(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:r,children:"+"}),u.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:b?0:-1,onClick:()=>{B(),Cv(q.current),_e()},disabled:!_&&x.length===0,children:"Clear"}),n?u.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:b?0:-1,title:He?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>X("queue"),disabled:!Ie,children:"Queue"}):null,u.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:b?0:-1,title:He?"Remove failed attachments before sending.":void 0,onClick:()=>X("send"),disabled:!Ie,children:"Send"})]})]})]})}function o4({attachment:e,onRemove:t}){const n=l4(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return u.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?u.jsx("img",{src:n,alt:""}):u.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),u.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),u.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),u.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),u.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function l4(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 c4(e,t){const n=new Map(t.map(f=>[f.reference,f])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let l=0,d;for(;(d=o.exec(e))!==null;){const f=n.get(d[1]);f&&(Sv(r,e.slice(l,d.index)),f.status==="uploaded"&&f.path&&(u4(f)?r.push({kind:"image",path:f.path}):Sv(r,f.path)),l=o.lastIndex)}return Sv(r,e.slice(l)),{parts:r}}function Sv(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 u4(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function d4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sC(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function wv(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function xv(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 h4(e,t,n){let r=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){const l=r;if(r+=1,l>=e.length)return;await n(e[l])}});await Promise.all(o)}function f4(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Cv(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function jf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function aC(){if(!jf())return;const e=Tc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function p4(e){Mc!==null&&(window.clearTimeout(Mc),Mc=null),Lf.add(e),document.documentElement.setAttribute(Kp,"true"),Tc()}function m4(e){if(Lf.delete(e),Lf.size>0||Mc!==null){Tc();return}Mc=window.setTimeout(()=>{if(Mc=null,Lf.size>0){Tc();return}document.documentElement.removeAttribute(Kp),Tc()},Z5),Tc()}function g4(){let e=!1,t=null,n=null,r=null,o=0;const l=Date.now(),d=window.visualViewport,f=v4();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(w){if(!e){if(w<iC&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(_);return}t=window.setTimeout(_,J5)}}function _(){if(e)return;m();const w=Hy(),S=Date.now()-l;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),S>=Q5||S>=iC&&o>=e4){p();return}b(S)}return d?.addEventListener("resize",_),d?.addEventListener("scroll",_),f?.addEventListener("geometrychange",_),_(),p}function Tc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Hy()}function v4(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function _4(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(S4(d))return d.preventDefault(),d.stopPropagation(),b4(e),!1;if(y4(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(w4(d)){const f=db(e);return f?(d.preventDefault(),d.stopPropagation(),hb(f),!1):!0}return x4(d)?(d.stopPropagation(),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const f=db(e);if(f){if(d.clipboardData){d.clipboardData.setData("text/plain",f),d.preventDefault();return}d.preventDefault(),hb(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=s2(f);d.preventDefault(),d.stopImmediatePropagation(),C4(e,m,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",l,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",l,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function b4(e){const t=db(e);t&&await hb(t)}function y4(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function S4(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 w4(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function x4(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 C4(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function db(e){return e.hasSelection()?e.getSelection():k4(e.element??null)}function k4(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function hb(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}T4(e)}function T4(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 E4=10,R4=100*1024*1024;class N4{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 r of this.jobs)r.controller.abort(),r.timer!==null&&clearTimeout(r.timer),r.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 r=t.map(D4);if(r.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>E4||[...o,...t].reduce((l,d)=>l+d.size,0)>R4?(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:r,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((r,o)=>r+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:r,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,r.length>m.maxFiles||r.some(_=>_.size>m.maxFileBytes)||r.reduce((_,w)=>_+w.size,0)>m.maxBatchBytes)throw new Error("Images exceed the server attachment limits.");const p=await n.api.uploadComposeAttachments({terminalId:n.terminalId,files:r.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!==r.length||d.length!==r.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(_=>Af(_.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 D4(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 M4=[4,10,11,12];function A4(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>oC(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>oC(r)),e.parser.registerCsiHandler({final:"n"},r=>L4(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>j4(r)),e.parser.registerCsiHandler({final:"t"},r=>O4(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...M4.map(r=>e.parser.registerOscHandler(r,o=>B4(o)))];return{dispose(){for(const r of n)r.dispose()}}}function oC(e){return Vp(e)===0}function L4(e){const t=Vp(e);return t===5||t===6}function j4(e){return Vp(e)===6}function O4(e){const t=Vp(e);return t===14||t===16||t===18}function B4(e){return e.split(";").some(t=>t==="?")}function Vp(e){const t=e[0];return typeof t=="number"?t:0}const Is=new Map,kv=2*1024*1024,I4=1500,lC=25e3,P4=2500,z4=2500,H4=1e3,U4=2e3,$4=3e4,F4=16*1024*1024,fb=256,r2=wM-3e4,W4=3e3,a2=1e4,K4=3e3,pb=16*1024*1024,Yp=4*1024*1024,pp=25,q4=1e3,V4=3e3,Tv=8,Y4=100,o2=1e3,cC=[2e3,5e3,15e3,6e4];let G4=0,X4=0,Ev=0,Rv=null,Of=!1,mb=0,Bf=0,yo=!1,uC=!1,wd=null,dC=!1,gb=0,Id=document.visibilityState!=="hidden";const mp=new Set;let Ac=null,xd=0;const Z4=new TextEncoder,Q4=SI();function J4(e,t){tI(),cI(),Bp()&&ma(0);let n=Is.get(e);n||(n=sI(e),Is.set(e,n),Vc(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Wy(n));const o=(f,m)=>dI(n,f,m),l=f=>{f?(n.foregroundAttachments.add(r),gp(),u2(n)):(n.foregroundAttachments.delete(r),vb())},d=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),vb()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:l,detach:d}}function ld(e){const t=Is.get(e);t&&(yI(t),Is.delete(e),vb())}function eI(e){const t=Is.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),No(t),Gs(t),Sr(t),Do(t),_r(t,"reconnecting"),Mo(t);const n=t.socket;return t.socket=null,po(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Vc(t),!0}function tI(){if(dC)return;dC=!0;const e=()=>{if(document.visibilityState==="hidden"){Id=!1,gb+=1,d2(),c2(),nI();return}Fy(),xd=Date.now(),gp()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),gp()}function gp(){Ac!==null||document.visibilityState==="hidden"||!l2()||typeof window.requestAnimationFrame!="function"||(Ac=window.requestAnimationFrame(()=>{if(Ac=null,document.visibilityState==="hidden")return;const e=Date.now(),t=xd>0?e-xd:0;if(xd=e,t>=U4){for(const n of Is.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&_a("terminal.connection.foreground_gap",n,{gapMs:t});Fy(void 0,{foregroundOnly:!0})}gp()}))}function l2(){for(const e of Is.values())if(e.foregroundAttachments.size>0)return!0;return!1}function vb(){l2()||(c2(),xd=0)}function c2(){Ac!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Ac),Ac=null}function u2(e){if(document.visibilityState!=="hidden"){if(!Id||e?.heartbeatSuspended){Fy(e);return}e&&_b(e)}}function Fy(e,t={}){if(document.visibilityState==="hidden")return;Id=!0;const n=++gb;d2();const r=Array.from(Is.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=r.filter(f=>f===e||f.foregroundAttachments.size>0||fI(f)),l=new Set(o),d=r.filter(f=>!l.has(f));for(const f of o)_b(f);if(!t.foregroundOnly)for(let f=0;f<d.length;f+=Tv){const m=d.slice(f,f+Tv),p=Math.floor(f/Tv)*Y4,b=window.setTimeout(()=>{if(mp.delete(b),!(n!==gb||!Id||document.visibilityState==="hidden"))for(const _ of m)_b(_)},p);mp.add(b)}}function d2(){for(const e of mp)window.clearTimeout(e);mp.clear()}function _b(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,Vc(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<H4)return Promise.resolve("alive");_r(e,"reconnecting"),Mo(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++G4).toString(36)}`;let o;const l=new Promise(f=>{o=f}),d={socket:t,nonce:r,timeout:0,promise:l,resolve:o};e.resumeProbe=d,pl(e,{type:"resume"}),d.timeout=window.setTimeout(()=>{e.resumeProbe!==d||e.socket!==t||(_a("terminal.connection.resume_timeout",e,{pendingInputs:So(e)}),_r(e,"reconnecting"),wo(e))},P4);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{_r(e,"reconnecting"),wo(e)}return l}function nI(){Id=!1;for(const e of Is.values())e.heartbeatSuspended=!0,No(e),Gs(e),Sr(e),Do(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,_r(e,"skipped"),Mo(e)}function iI(){yo=!1,Bp()&&ma(0);for(const e of Is.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),No(e),Gs(e),Sr(e),Do(e),_r(e,"reconnecting"),Mo(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,po(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Vc(e)}}function Nv(){for(const e of Array.from(Is.keys()))ld(e)}function sI(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:pp,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 Vc(e){if(!e.reconnectEnabled)return;po(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Gs(e),Sr(e),Do(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,No(e),Gs(e),po(e,"connected"),Ro(e,t),h2(e,t),e.isAlive=!0,hC(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let l=null;try{l=JSON.parse(o)}catch{return}if(!l||typeof l.type!="string")return;if(NI(l)){DI(e,t,l.instanceId,l.inputAck,l.inputReceipt===!0),yo&&(yo=!1,Bp()&&ma(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(),So(e)>0&&_a("terminal.connection.resume_alive",e,{pendingInputs:So(e)}),_r(e,"alive"),Ro(e,t),hC(e),yl(e),pl(e,{type:"resume"}));const m=e.inputAckProbe;m?.socket===t&&m.nonce===l.nonce&&(Pd(e),_a("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:So(e)}),wo(e));return}if(l.type==="input_ack"){kI(e,t,l);return}if(l.type==="input_received"){TI(e,t,l);return}if(l.type==="error"&&EI(e,l),l.type==="input_ack_confirmed"){AI(e,l);return}const d=aI(e,l);if(pl(e,{type:"message",message:d}),l.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;Wy(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",No(e),Gs(e),Sr(e),Do(e),_r(e,"reconnecting"),Mo(e),r.code===1008){e.reconnectEnabled=!1,po(e,rI(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=$4)&&(e.lastUpgradeAuthProbeAt=o,pl(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){po(e,"closed");return}po(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Vc(e)},I4)}}),t.addEventListener("error",()=>{})}function hC(e){if(Mo(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>lC*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},lC)}function Mo(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function rI(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function aI(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+ba(r),0),fC(e),e.exited&&If(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=ba(t.data),fC(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,If(e)),t):(t.type==="exit"&&(e.exited=!0,If(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function fC(e){for(;e.outputBytes>kv&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=ba(t)}e.outputBytes>kv&&e.output.length===1&&(e.output[0]=jI(e.output[0],kv),e.outputBytes=ba(e.output[0]))}function po(e,t){e.status!==t&&(e.status=t,pl(e,{type:"status",status:t}))}function pl(e,t){for(const n of Array.from(e.listeners))n(t)}function So(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function oI(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 lI(e,t,n={}){const r=Is.get(e);r&&_a(`terminal.connection.render_${t}`,r,n)}function _a(e,t,n={}){Pi(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:So(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??oI(t)}),mb+=1,Bf=0,ma(o2)}function cI(){if(uC)return;uC=!0;const e=()=>{document.visibilityState==="hidden"||yo||Bp()&&ma(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function ma(e){if(Of){wd=wd===null?e:Math.min(wd,e);return}Rv!==null||yo||document.visibilityState==="hidden"||navigator.onLine===!1||(Rv=window.setTimeout(()=>{Rv=null,uI()},e))}async function uI(){if(Of||yo||document.visibilityState==="hidden"||navigator.onLine===!1)return;Of=!0;const e=mb;try{const t=await RM();if(t.outcome==="auth_blocked"){yo=!0;return}if(t.outcome==="retryable"){const n=cC[Math.min(Bf,cC.length-1)];Bf+=1,ma(n);return}if(Bf=0,t.outcome==="sent"&&t.hasMore){ma(0);return}}finally{Of=!1;const t=wd;wd=null,t!==null&&ma(t),mb!==e&&!yo&&ma(o2)}}function dI(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=xI(e,t);if(!r)return"rejected";const o=JSON.stringify(r),l=ba(o);if(l>F4)return"rejected";const d=n.durability!=="live-only",f={message:r,encoded:o,bytes:l,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:d};if(!CI(e,f))return"rejected";const m=e.socket,p=m?.readyState===WebSocket.OPEN;r.type==="input"&&d&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(_a("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:So(e)}),u2(e));const _=r.type!=="ping"&&r.type!=="resize";if(_&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(m?.bufferedAmount??0)>Yp))return r.type==="redraw"||!d?"rejected":hI(e,r)?(p&&m&&Ro(e,m),"queued"):e.pendingOut.length>=fb||e.pendingOutBytes+l>pb?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=l,mC(e,f),p&&m&&Ro(e,m),"queued");if(p){mC(e,f);try{return m.send(o),p2(e,f),"sent"}catch{if(_&&d&&e.pendingOut.length<fb&&e.pendingOutBytes+l<=pb)return e.pendingOut.push(f),e.pendingOutBytes+=l,m.close(),"queued";wl(e,f),m.close()}}return"rejected"}function Ro(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Gs(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Yp){LI(e,t),mI(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){h2(e,t);return}try{t.send(r.encoded),p2(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=pp,n=!0}e.outboundFlushDelayMs=pp,Gs(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&pl(e,{type:"outbound_flushed"})})}function hI(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const d=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(d===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:d}}}if(!r)return!1;const o=JSON.stringify(r),l=ba(o);return e.pendingOutBytes+=l-n.bytes,n.message=r,n.encoded=o,n.bytes=l,!0}function No(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=pp}function Gs(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function vp(e){return e.pendingOut.some(t=>t.message.type==="input")}function fI(e){return vp(e)||e.unackedInputs.size>0}function pI(e){if(!vp(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function mI(e,t){e.outboundStallWatchdog!==null||!vp(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!vp(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Yp;if(!n&&!r){Ro(e,t);return}pI(e),wo(e)},V4))}function Sr(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)&&wo(e)},K4))}function f2(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function Pd(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function Do(e){f2(e),Pd(e)}function yl(e){f2(e),bb(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=pC(e),r=gI(e),o=_I(e);if(n===null&&r===null&&o===null){Pd(e);return}if(e.inputAckProbe)return;const l=n===null?Number.POSITIVE_INFINITY:n+W4,d=Math.max(0,Math.min(l,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(bb(e,{notifyImmediately:!0})){yl(e);return}if(vI(e),pC(e)===null){yl(e);return}bI(e,t)},d)}function gI(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+a2;t=t===null?r:Math.min(t,r)}return t}function vI(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<a2||(n.writeSlowReported=!0,_a("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function pC(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 _I(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+r2;t=t===null?r:Math.min(t,r)}return t}function bI(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Yp){wo(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++X4).toString(36)}`;_a("terminal.input.delivery_probe_started",e,{pendingInputs:So(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(_a("terminal.input.delivery_probe_timeout",e,{pendingInputs:So(e)}),Pd(e),wo(e))},z4);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{Pd(e),wo(e)}}function _r(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function wo(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),No(e),Gs(e),Sr(e),Do(e),_r(e,"reconnecting"),Mo(e);const t=e.socket;e.socket=null,po(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Vc(e)}function yI(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),No(e),Gs(e),Sr(e),Do(e),_r(e,"skipped"),Mo(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),If(e),e.listeners.clear()}function SI(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function wI(){return Ev=(Ev+1)%Number.MAX_SAFE_INTEGER,`${Q4}-${Ev.toString(36)}`.slice(0,Ck)}function xI(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=wI();return n.length===0||n.length>Ck?null:{...t,messageId:n}}function CI(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<fb&&e.unackedInputBytes+t.bytes<=pb)}function mC(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function wl(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 kI(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const l=e.pendingAckReceipts.get(n.messageId);l?.terminalId===n.terminalId&&yb(e,t,l);return}if(wl(e,r),yl(e),!Ky(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),yb(e,t,o)}function TI(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",yl(e))}function EI(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(wl(e,n),yl(e))}function p2(e,t){if(t.message.type!=="input"||!t.message.messageId||!Ky(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",yl(e)}function RI(e){if(bb(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){wl(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function bb(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[l,d]of e.unackedInputs)d.firstSentAt!==null&&n-d.firstSentAt>=r2&&(r.add(l),d.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(l=>{const d=l.message.type==="input"?l.message.messageId:void 0;return!d||!r.has(d)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-l.bytes),!1)});for(const l of r){const d=e.unackedInputs.get(l);d&&wl(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&&Wy(e)),!0}function NI(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function DI(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){m2(e,t);return}Sr(e);const l=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,l===n?(RI(e),MI(e,t)):l!==null&&(g2(e),_2(e)),Ro(e,t)}function m2(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",Sr(e),e.serverInstanceId=null,g2(e),_2(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;wl(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const l=ba(n.encoded);e.pendingOutBytes+=l-n.bytes,n.bytes=l}Ro(e,t)}}function g2(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&wl(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 Wy(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)pl(e,{type:"message",message:{type:"error",message:n.message}})}}function If(e){No(e),Gs(e),Sr(e),Do(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function yb(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Ky(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Ky(e){return e==="ack"||e==="receipt-ack"}function MI(e,t){for(const n of e.pendingAckReceipts.values())if(yb(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function AI(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function _2(e){e.pendingAckReceipts.clear()}function LI(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(q4,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Ro(e,t)},n)}function ba(e){return Z4.encode(e).byteLength}function jI(e,t){if(ba(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);ba(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const OI=[0,50,150,350],Dv=[100,300,750],BI=2,II=[300,1200,2500],PI=1e3,zI=1e5,HI="",UI=400,Mv=9,$I=9,FI=32,WI=1.42,KI=2,qI=24,VI=720,YI=60,GI=1260,XI=6,ZI=2,gC=[500,1500,3e3,5e3,8e3],vC=15e3,QI=2,JI=1e3,_C="Do not take action. Wait for my next input.",_p=6e4,e6=_p+5*6e4,bC=_p+6e4,t6=40,vf=240,n6=5e3,bp=new Map,yc=new Map;function yC({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:l=!1,tabId:d,codeServerContext:f,onSelect:m,onClose:p,onExit:b,onSnapshot:_,onAuthClose:w}){const S=v.useSyncExternalStore(ST,c_,()=>dl),x=v.useSyncExternalStore(wT,u_,()=>Oc),E=v.useSyncExternalStore(TT,p_,()=>!0),L=v.useSyncExternalStore(td,m_,()=>!0),A=v.useSyncExternalStore(td,g_,()=>!0),K=v.useSyncExternalStore(td,f_,()=>Ed),P=v.useSyncExternalStore(Gb,xo,()=>Lc),z=v.useSyncExternalStore(_d,()=>bd("history.toggle"),()=>"Alt+H"),q=v.useSyncExternalStore(_d,()=>bd("scrollback.toggle"),()=>"Alt+S"),Y=v.useSyncExternalStore(_d,()=>bd("subagents.toggle"),()=>"Alt+A"),I=v.useRef(null),F=v.useRef(null),he=v.useRef(null),Q=v.useRef(null),ee=v.useRef(null),ie=v.useRef(e.id),J=v.useRef({onExit:b,onSnapshot:_}),H=v.useRef(t.createWebSocketUrl),X=v.useRef(w),M=v.useRef(null),R=v.useRef(null),B=v.useRef(null),oe=v.useRef(!1),ge=v.useRef(new Map),N=v.useRef(new Map),V=v.useRef(new Set),re=v.useRef(null),Z=v.useRef(!1),Te=v.useRef(!1),ye=v.useRef(null),He=v.useRef(0),Ke=v.useRef(0),Ie=v.useRef([]),_e=v.useRef(!1),We=v.useRef(null),Oe=v.useRef(0),j=v.useRef(!1),me=v.useRef(!1),Me=v.useRef(e.scrollbackMode),ze=v.useRef({codex:!1,speed:K}),W=v.useRef(null),pe=v.useRef(new Jx),Ce=v.useRef(!1),Ne=v.useRef({terminalId:e.id,enabled:!1}),Le=v.useRef([]),ve=v.useRef([]),Pe=v.useRef(0),$e=v.useRef(!1),Be=v.useRef(null),ut=v.useRef(0),ht=v.useRef(0),vt=v.useRef(null),Rt=v.useRef(null),cn=v.useRef(!1),at=v.useRef(!1),Wn=v.useRef(!1),kn=v.useRef(null),_t=v.useRef(!1),jt=v.useRef(null),Nt=v.useRef(null),pn=v.useRef(!1),ui=v.useRef(!1),fn=v.useRef(!1),mn=v.useRef(!1),ae=v.useRef(!1),Fe=v.useRef(!1),Qe=v.useRef(!1),St=v.useRef(!1),Ut=v.useRef(n),$t=v.useRef(r),Wt=v.useRef(l),un=v.useRef(S),Bn=v.useRef(x),Vt=v.useRef(!1),Kn=v.useRef(!1),Nn=v.useRef(null),en=v.useRef(null),qn=v.useRef(0),lt=v.useRef(0),kt=v.useRef(e.id),Dn=v.useRef(()=>{}),ce=v.useRef(null),ke=v.useRef(null),Ve=v.useRef(!1),Xe=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),tt=v.useRef(0),sn=v.useRef(null),Vn=v.useRef(0),xi=v.useRef(null),Yt=v.useRef(!1),qi=v.useRef(null),Yn=v.useRef(0),ti=v.useRef(!1),is=v.useRef(!1),In=v.useRef(null),Ft=v.useRef(null),[wr,ys]=v.useState("connecting"),[Ai,zi]=v.useState(null),Js=v.useRef(null),xr=v.useRef(null),Cr=v.useRef(()=>!1),Vi=v.useRef(null);Vi.current||(Vi.current=new N4({getTarget:()=>Js.current,send:k=>Cr.current(k),onState:zi}));const[kr,Ss]=v.useState(!1),[Ci,di]=v.useState(null),[Tr,wa]=v.useState(!1),[Er,Rr]=v.useState(null),[xa,Ao]=v.useState(!1),[Li,Nr]=v.useState(!1),[Tl,ki]=v.useState(!1),[er,Ca]=v.useState(!1),[Lo,tr]=v.useState(!1),[Pn,ka]=v.useState(null),[jo,Ta]=v.useState([]),Ea=v.useRef([]),Ti=e.agentCache&&Pn&&e.agentCache.source.provider===Pn.provider&&e.agentCache.source.sessionId===Pn.sessionId?e.agentCache:null,[Ps,ji]=v.useState(()=>Date.now()),[Oi,ws]=v.useState(!1),[nr,ss]=v.useState(null),[Dr,xs]=v.useState(!1),[Ra,rs]=v.useState(!1),[Mn,zs]=v.useState(null),[Mr,Yi]=v.useState(!1),[Na,Hs]=v.useState(!1),[El,as]=v.useState(null),[Us,Oo]=v.useState(null),Gt=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[os,ft]=v.useState(()=>Jg(e.id)),ni=Pn?.provider??e.agentStatus?.provider??null,Da=ol(e.currentCommand)||kC(e.currentCommand)&&ni!==null,ir=e.agentStatus?.sessionId??Pn?.sessionId??null,Ar=ni!==null||ol(e.currentCommand),sr=ni==="claude"||xb(e.currentCommand),Ma=ni!==null||ol(e.currentCommand),rr=e.capabilities?.tmuxScrollback===!0,hi=rr&&(os??(Ma?A:L)),[Bo,Aa]=v.useState(!1);v.useLayoutEffect(()=>{Cr.current=k=>zn(k,{liveOnly:!0})==="sent"}),v.useLayoutEffect(()=>(xr.current=null,Js.current=n&&r&&e.status==="running"?{api:t,terminalId:e.id,supportsImages:Da}:null,()=>{Js.current=null,Vi.current?.cancel()}),[t,e.id,e.pid,e.status,e.currentCommand,Da,n,r,wr]),v.useLayoutEffect(()=>{const k=Js.current;if(!k||ir===null)return;const $=xr.current;xr.current=ir,$!==null&&$!==ir&&(Js.current={...k},Vi.current?.pending&&Vi.current.cancel("Image paste canceled because the active session changed."))}),v.useLayoutEffect(()=>{(!n||!r||!Bo||e.status!=="running")&&lr(!1)},[n,r,Bo,e.status]),v.useLayoutEffect(()=>{Ut.current=n},[n]),v.useLayoutEffect(()=>{$t.current=r},[r]),v.useLayoutEffect(()=>{Wt.current=l},[l]),v.useLayoutEffect(()=>{un.current=S},[S]),v.useLayoutEffect(()=>{Bn.current=x},[x]),v.useLayoutEffect(()=>{Vt.current=Dr},[Dr]),v.useLayoutEffect(()=>{Kn.current=Ra},[Ra]),v.useLayoutEffect(()=>{en.current=Pn},[Pn]);const $s=v.useCallback((k,$={})=>{!k&&$.preserveOnNull||(Yx(en.current,k)||(lt.current+=1),en.current=k,ka(je=>je&&k&&je.provider===k.provider&&je.sessionId===k.sessionId?je:k))},[]),Rl=v.useCallback(async()=>{const k=await t.getTerminalTranscriptSource(e.id);return kt.current===e.id&&(Ea.current=k.candidates??[],Ta(k.candidates??[])),k.source},[t,e.id]),Io=v.useCallback(()=>{rs(!1),xs(!0)},[]),Lr=v.useCallback(()=>{en.current&&(xs(!1),rs(!0))},[]),Fs=v.useCallback(async(k={})=>{const $=await wC(Gt,t,k);return zs($),$},[Gt,t]),fi=v.useCallback((k,$="info")=>{xi.current!==null&&window.clearTimeout(xi.current),Oo({id:Vn.current++,message:k,tone:$}),xi.current=window.setTimeout(()=>{Oo(null),xi.current=null},3200)},[]),jr=v.useCallback(()=>{if(Yt.current)return;Yt.current=!0;const k=Gt,$=f?.serverName.trim()||"Local",je=f?.tabName.trim()||e.title||"Terminal",et=qi.current,ot=et?.terminalId===e.id&&et.requestedCwd===e.cwd?et.instance:Mn?.instances.find(dt=>dt.cwd===e.cwd),st=ot?xC(k,ot.id):null,{handle:Dt,ownsPopup:Mt}=i6(st);Mt&&l6(Dt);const it=()=>{Mt&&c6(Dt)};Hs(!0),as(null),(async()=>{let dt=Mn;if(dt?.installed||(dt=await Fs({force:!0})),!dt?.installed||dt.supported===!1){it(),Yi(!0);return}return t.openCodeServer({terminalId:e.id,serverName:$,tabName:je})})().then(dt=>{if(!dt)return;qi.current={terminalId:e.id,requestedCwd:e.cwd,instance:dt.instance},Sb(Gt,dt.status),zs(dt.status);const Ot=xC(k,dt.instance.id),Bt=b2(Ot);if(Bt?.createdAt===dt.instance.createdAt&&r6(Bt.handle,dt.instance.url)){Vy(Bt.handle),Dt!==Bt.handle&&it(),fi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}const Qt=Bt?.handle??(Mt||st===Ot?Dt:null);if(o6(Qt,Ot,dt.url,dt.instance.createdAt))Dt!==Qt&&it(),fi("Opening VS Code...");else{const ii=a6(Ot,dt.url,dt.instance.createdAt);Dt!==ii&&it(),ii?fi("Opening VS Code..."):fi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}}).catch(async dt=>{it(),dt instanceof Fn&&dt.message==="code_server_not_installed"&&await Fs({force:!0}).catch(()=>{}),Yi(!0),as(_f(dt))}).finally(()=>{Yt.current=!1,Hs(!1)})},[f?.serverName,f?.tabName,Gt,Mn,Fs,t,fi,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return wC(Gt,t).then($=>{k||zs($)}).catch(()=>{}),()=>{k=!0}},[Gt,t]),v.useEffect(()=>{if(Mn?.job?.status!=="running")return;const k=window.setInterval(()=>{Fs({force:!0}).catch($=>as(_f($)))},1e3);return()=>window.clearInterval(k)},[Mn?.job?.status,Fs]),v.useEffect(()=>()=>{xi.current!==null&&window.clearTimeout(xi.current)},[]),v.useLayoutEffect(()=>{Dn.current=Io},[Io]),v.useLayoutEffect(()=>{ke.current=Ti},[Ti]),v.useLayoutEffect(()=>{Ve.current=Oi},[Oi]),v.useLayoutEffect(()=>{ti.current=Ar},[Ar]),v.useLayoutEffect(()=>{is.current=sr},[sr]),v.useLayoutEffect(()=>{const k=Ne.current;me.current=hi,Ce.current=rr,Ne.current={terminalId:e.id,enabled:hi},TC(I.current,hi);const $=pe.current.setMouseEnabled(hi);$&&F.current?.write($),k.terminalId===e.id&&k.enabled&&!hi&&Wr(),hi||ki(!1)},[e.id,hi,rr]),v.useLayoutEffect(()=>{Me.current=e.scrollbackMode,e.scrollbackMode&&ki(e.scrollbackMode==="copy")},[e.id,e.scrollbackMode]),v.useLayoutEffect(()=>{ze.current={codex:!xb(e.currentCommand)&&(ni==="codex"||wb(e.currentCommand)),speed:K}},[ni,e.currentCommand,K]),v.useEffect(()=>{ft(Jg(e.id)),Oe.current=0,j.current=!1,ki(!1),Ws()},[e.id]),v.useEffect(()=>td(()=>{ft(Jg(e.id))}),[e.id]),v.useEffect(()=>()=>{rh()},[]),v.useEffect(()=>{ee.current?.(r&&e.status==="running"),r&&e.status==="running"&&Pr()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&Gi("auto")},[n,r,e.status]),v.useEffect(()=>{J.current={onExit:b,onSnapshot:_}},[b,_]),v.useLayoutEffect(()=>{H.current=t.createWebSocketUrl,X.current=w},[t,w]),v.useLayoutEffect(()=>{ie.current=e.id,Qe.current=!1,Ca(!1),lr(!1)},[e.id]),v.useEffect(()=>{let k=!1,$=null,je=0;const et=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",ot=et||kC(e.currentCommand),st=et||ol(e.currentCommand);function Dt(){$!==null&&(window.clearTimeout($),$=null)}function Mt(dt){if(k)return;let Ot;if(dt)Ot=vC;else if(je<gC.length){if(!ot)return;Ot=gC[je++]}else{if(!st)return;Ot=vC}$=window.setTimeout(()=>{$=null,it()},Ot)}async function it(){try{const dt=en.current!==null,Ot=await Rl();if(k)return;if(Ot){qn.current=0,$s(Ot),Mt(!0);return}qn.current+=1;const Bt=!!(dt&&ot&&qn.current<QI);$s(null,{preserveOnNull:Bt}),Mt(Bt)}catch(dt){if(k)return;Lv(dt)&&$s(null),Mt(!1)}}return kt.current!==e.id&&(Ea.current=[],Ta([]),kt.current=e.id,lt.current+=1,en.current=null,qn.current=0,ka(null)),e.status!=="running"?(lt.current+=1,en.current=null,qn.current=0,ka(null),()=>{k=!0,Dt()}):(it(),()=>{k=!0,Dt()})},[$s,Rl,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=h6(e.id,Pn),$=ce.current;$!==null&&k!==null&&$!==k&&(Rt.current=null,cn.current=!1,at.current=!1,rs(!1)),ce.current=k},[e.id,Pn?.provider,Pn?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!Pn){ws(!1);return}const k=window.setInterval(()=>{ji(Date.now())},JI);return()=>{window.clearInterval(k)}},[e.status,Pn?.provider,Pn?.sessionId]),v.useEffect(()=>{const k=d6(Ti);Xe.current.key!==k&&(Xe.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[Ti?.expiresAt,Ti?.source?.provider,Ti?.source?.sessionId]),v.useEffect(()=>{if(!Oi||!Ti||Ti.status!=="ready")return;const k=S2(Ti,Ps);if(k===null||k<=0)return;const $=Xe.current;!$.warnedFiveMinutes&&k<=e6&&k>bC&&($.warnedFiveMinutes=!0,or({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."})),!$.warnedOneMinute&&k<=bC&&k>_p&&($.warnedOneMinute=!0,or({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!$.sent&&!$.skipped&&k<=_p&&Hl()},[Oi,Ps,Ti,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k($){if(!Ut.current||!$t.current||$.isComposing||$.key==="Process"||m6($.target))return;const je=DT($);if(je?.id==="history.toggle"&&(en.current||Ea.current.length)){$.preventDefault(),$.stopPropagation(),Vt.current?xs(!1):Dn.current();return}if(je?.id==="subagents.toggle"&&en.current){$.preventDefault(),$.stopPropagation(),Kn.current?rs(!1):Lr();return}if(je?.id==="scrollback.toggle"&&Ce.current){$.preventDefault(),$.stopPropagation(),au();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=F.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&ys("closed")},[e.status]),v.useEffect(()=>{const k=F.current;k&&(k.options.fontSize=S,Qg(S,Bn.current).then(()=>{un.current===S&&Ae()}))},[S]),v.useEffect(()=>{const k=F.current;k&&(k.options.fontFamily=l_(x),Qg(un.current,x).then(()=>{Bn.current===x&&Ae()}))},[x]),v.useEffect(()=>{const k=F.current;k&&(k.options.theme=SC(P))},[P]),v.useEffect(()=>{const k=I.current;if(!k)return;let $=!1,je=null,et=null,ot=null,st=null,Dt=null,Mt=null,it=null,dt=null;M.current=null,ae.current=!1,Fe.current=!1,_t.current=!1,pt(),gn(),Z.current=!1,Te.current=!1,He.current=0,Ke.current=0,Po(),_e.current=!1;const Ot=un.current,Bt=Bn.current,Qt=new BB({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:l_(Bt),fontSize:Ot,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:zI,theme:{...SC(xo())}}),ii=new Ej;return Qt.loadAddon(ii),Dt=A4(Qt),F.current=Qt,he.current=ii,Qg(Ot,Bt).then(()=>{if($)return;Qt.open(k),TC(k,me.current),ae.current=!0,st=Qt.onRender(()=>{const vn=re.current;vn!==null&&(re.current=null,wt("painted",{elapsedMs:Date.now()-vn}))}),je=_4(Qt,{onPasteText:ou,onPasteFiles:vn=>{Vi.current?.paste(vn)},canPaste:()=>Js.current!==null,onInterrupt:Wl,shouldInterruptPlainCtrlC:()=>is.current}),$t.current&&Ut.current&&e.status==="running"&&Gi("auto"),Ae(),Mt=I6(k,Qt,()=>un.current*1.2,ls,vn=>{Ir(vn)},Bl,Il,()=>me.current,iu,$l,Fl),it=j6(k,Qt,ls,vn=>{Ir(vn)},Bl,Il,()=>me.current,iu);const ks=new h5;et=Qt.onData(vn=>{if(v5(vn)){Ba(vn);return}if(Qe.current){const Kl=b5(vn);if(Kl){mi(!1),zn(Kl);return}}const cu=ks.accept(vn);cu&&zn(cu)}),ot=Qt.onScroll(vn=>{if(ui.current||mn.current||fn.current){pi();return}Ol(),vs(Qt)&&Ur({scrollToBottom:!0}),ls(),!me.current&&vn<=3&&Ir()}),dt=new ResizeObserver(()=>{zr()}),dt.observe(k),Fe.current&&(Ml(),Fe.current=!1,Ae()),we()}),()=>{su(Q.current,{updateUi:!1}),$=!0,ae.current=!1,Fe.current=!1,pt(),gn(),ye.current!==null&&window.clearTimeout(ye.current),ye.current=null,Te.current=!1,R.current=null,B.current=null,oe.current=!1,Ll(),_e.current=!1,jl(),fn.current=!1,$e.current=!1,ut.current+=1,ht.current+=1,Be.current=null,In.current=null,Ft.current=null,Wn.current=!1,kn.current=null,Ss(!1),Mt?.(),it?.(),dt?.disconnect(),je?.dispose(),et?.dispose(),ot?.dispose(),st?.dispose(),Dt?.dispose(),Qt.dispose(),F.current=null,he.current=null}},[e.id]),v.useEffect(()=>{const k=H.current(e.id),$=J4(k,Nl);return Q.current=$.send,ee.current=$.setForeground,$.setForeground($t.current&&e.status==="running"),ys($.status),$.status==="connected"&&Ae(),$.snapshot&&(Z.current=$.snapshot.capabilities?.screenRedraw===!0,J.current.onSnapshot($.snapshot,{notifyCompletion:!1}),F.current&&(Ae(),La($.output,$.history),Ae())),()=>{su($.send,{updateUi:!1}),$.setForeground(!1),$.detach(),Q.current=null,ee.current=null}},[e.id,e.status]);function Nl(k){if(k.type==="resume"){Pr();return}if(k.type==="status"){ys(k.status),k.status==="unauthorized"&&X.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(Ae(),qe());return}if(k.type==="upgrade_rejected"){X.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){dn(),_e.current&&(_e.current=!1,lu());return}Gc(k.message)}function Po(k=[],$=null){Le.current=[],ve.current=k.filter(Boolean),Pe.current=0,$e.current=!1,Be.current=null,fn.current=!1,ut.current+=1,vt.current=$,Rt.current=null,cn.current=!1,at.current=!1,Wn.current=!1,kn.current=null,Fe.current=!1,In.current=null,Ft.current=null,jt.current=null,pn.current=!1,Ss(!1),di(null),wa(!1),Rr(null),Ao(!1),Nr(!1)}function La(k=[],$=null){if(fn.current||$e.current){Ft.current={output:k,history:$,appendFromLiveOutputIndex:ve.current.length};return}Po(k,$),Dl()}function Or(){if(fn.current||$e.current)return!1;const k=Ft.current;if(!k)return!1;const $=ve.current.slice(k.appendFromLiveOutputIndex);return Ft.current=null,Po([...k.output,...$],k.history),Dl(),!0}function Dl(){if(!F.current||!ae.current){Fe.current=!0;return}Fe.current=!1,Ml()}async function Ml(){const k=F.current;if(!k)return;const $=Ju(k,pn.current),je=$?ve.current.length:Pe.current,et=await Br(k,{liveOutputLimit:je,scrollToBottom:$});F.current===k&&(pi(),et&&(Te.current=!0,He.current=0,dn(),qe()))}function Br(k,$={}){return new Promise(je=>{fn.current=!0,$e.current=!1;const et=ut.current+1;ut.current=et;const ot=Math.max(0,Math.min($.liveOutputLimit??ve.current.length,ve.current.length)),st=$.historyPages??Le.current,Dt=()=>F.current===k&&ut.current===et,Mt=()=>Dt()&&($.isCurrent?.()??!0),it=()=>{Dt()&&(fn.current=!1),je(!1)},dt=()=>{if(!Mt()){it();return}try{Pe.current=ot,$.scrollToBottom&&Uo(k)}finally{if(fn.current=!1,Or()){je(!1);return}const Bt=Qc();Bt?Ur(Bt):$.applyDeferredSnapshot!==!1&&$r(),je(!0)}};(()=>{if(!Mt()){it();return}k.clear(),pe.current=new Jx(me.current);const Bt=[...st,...ve.current.slice(0,ot)].filter(Boolean);if(Bt.length===0){dt();return}for(let Qt=0;Qt<Bt.length;Qt+=1){const ii=sh(Bt[Qt]);Qt===Bt.length-1?k.write(ii,dt):k.write(ii)}})()})}async function Ir(k=0){const $=F.current;if(Wn.current||!$||$.buffer.active.type==="alternate")return;if(Jc($)){pi();return}const je=vt.current,et=ht.current,ot=Symbol("history-load"),st=()=>F.current===$&&ht.current===et;kn.current=ot,Wn.current=!0,Ss(!0);const Dt=$.buffer.active.viewportY;try{let Mt=!!(je&&!je.hasMore);if(!Mt)try{const it=await t.getTerminalHistory(e.id,{beforeLine:je?.startLine??0,...je?.snapshotHistorySize!==void 0?{snapshotHistorySize:je.snapshotHistorySize}:{},...je?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:je.snapshotHistoryLimit}:{},...je?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:je.snapshotHistoryToken}:{},...je?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:je.snapshotPaneWidth}:{},limit:PI});if(!st()||vt.current!==je)return;const dt=()=>st()&&vt.current===je;if(it.invalidated){ja();return}const Ot=it.hasMore&&it.snapshotHistorySize!==void 0&&it.snapshotPaneWidth!==void 0,Bt={startLine:it.startLine,endLine:it.endLine,hasMore:Ot,...it.snapshotHistorySize!==void 0?{snapshotHistorySize:it.snapshotHistorySize}:{},...it.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:it.snapshotHistoryLimit}:{},...it.snapshotHistoryToken!==void 0?{snapshotHistoryToken:it.snapshotHistoryToken}:{},...it.snapshotPaneWidth!==void 0?{snapshotPaneWidth:it.snapshotPaneWidth}:{}};if(it.output.length>0){await zo($,it.output,Dt,k)&&dt()&&(vt.current=Bt);return}if(!dt())return;vt.current=Bt,Mt=!Ot}catch(it){Mt=st()&&Lv(it)}if(Mt){if(!st()||Jc($)){pi();return}await Yc($,Dt,k,st)}}catch{}finally{kn.current===ot&&(kn.current=null,Wn.current=!1,Ss(!1))}}async function Yc(k,$,je,et){if(!et()||cn.current||at.current)return;const ot=en.current,st=lt.current,Dt=Rt.current,Mt=()=>et()&<.current===st&&Yx(ot,en.current)&&Rt.current===Dt;try{const it=await t.getTerminalTranscriptHistory(e.id,{...Dt?{cursor:Dt}:{},limit:UI}),dt=it.output.map(Iy);if(!it.source||it.terminalId!==e.id||!Mt())return;if(ot&&!pa(ot,it.source)){Rt.current=null,cn.current=!1,at.current=!1,$s(it.source);return}if(dt.length===0){$s(it.source),Rt.current=it.cursor,at.current=!it.hasMore||!it.cursor;return}await zo(k,dt,$,je,Mt)&&Mt()&&($s(it.source),Rt.current=it.cursor,at.current=!it.hasMore||!it.cursor)}catch(it){Mt()&&Lv(it)&&(cn.current=!0)}}async function zo(k,$,je,et,ot){if(Jc(k)||ot&&!ot())return pi(),!1;const st=Le.current,Dt=[...$,...st],Mt=A6($),it=ut.current+1,dt=await Br(k,{liveOutputLimit:Pe.current,scrollToBottom:!1,historyPages:Dt,applyDeferredSnapshot:!1,...ot?{isCurrent:ot}:{}}),Ot=ot!==void 0&&!ot();return!dt||Ot||F.current!==k?(Ot&&F.current===k&&ut.current===it&&await Br(k,{liveOutputLimit:Pe.current,scrollToBottom:!1,historyPages:st,applyDeferredSnapshot:!1})&&F.current===k&&(eu(k,je),pn.current=!vs(k),ls()),!1):(Le.current=Dt,eu(k,Math.max(0,je+Mt+Math.min(0,et))),pn.current=!vs(k),ls(),!0)}v.useEffect(()=>{const k=window.visualViewport;function $(){document.visibilityState!=="hidden"&&Pr()}function je(){Pr()}function et(){Pr()}function ot(){zr()}function st(){Ho()}return document.addEventListener("visibilitychange",$),document.addEventListener("resume",je),window.addEventListener("pageshow",je),window.addEventListener("focus",je),window.addEventListener("online",et),window.addEventListener("resize",ot),window.addEventListener(hp,st),k?.addEventListener("resize",ot),k?.addEventListener("scroll",ot),()=>{document.removeEventListener("visibilitychange",$),document.removeEventListener("resume",je),window.removeEventListener("pageshow",je),window.removeEventListener("focus",je),window.removeEventListener("online",et),window.removeEventListener("resize",ot),window.removeEventListener(hp,st),k?.removeEventListener("resize",ot),k?.removeEventListener("scroll",ot)}},[e.id]);function Pr(){document.visibilityState==="hidden"||!$t.current||(qe(),zr(),dn())}function ja(){const k=H.current(e.id);ht.current+=1,_t.current=!0,In.current=null,ys("reconnecting"),Ae(),eI(k)}function Gc(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Z.current=k.terminal.capabilities?.screenRedraw===!0,ht.current+=1,J.current.onSnapshot(k.terminal,{notifyCompletion:!1});const je=_t.current;_t.current=!1;const et=F.current;if(!et)return;if(Ae(),je){Xc(k.output,k.history??null);return}if(Jp(et,k.terminal)){Hi(k.output,k.history??null),pi(),Ae();return}La(k.output,k.history??null),Ae();return}if(k.type==="redraw_result"&&k.terminalId===e.id){wt("redraw_result",{ok:k.ok});return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){J.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const je=k.data;if(!je)return;ve.current.push(je),F.current&&ae.current?Ur({scrollToBottom:!0}):Fe.current=!0;return}const $=F.current;if($){if(k.type==="exit"&&k.terminalId===e.id){J.current.onExit(k.exitCode),ys("closed");return}k.type==="error"&&$.writeln(`\r
|
|
52
|
+
[nterminal] ${k.message}`)}}function Xc(k,$){La(k,$),Ae()}function Cs(k=25){if(document.visibilityState==="hidden"||!$t.current||ge.current.has(k))return;const $=window.setTimeout(()=>{ge.current.delete(k),!Al()&&nu()},k);ge.current.set(k,$)}function zr(){Al()||we()}function Al(){const k=T();return k&&Hr(k)?(oe.current=!0,B.current=k,!0):k&&C(k)?(oe.current=!1,B.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(oe.current=!1,B.current=null),!1)}function Ho(){if(!oe.current)return;const k=T();k&&(k.composeOpen||k.keyboardVisible)||(oe.current=!1,B.current=null)}function Hr(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const $=R.current;return $?le(k.windowWidth,$.windowWidth)&&le(k.visualViewportWidth,$.visualViewportWidth)&&le(k.containerWidth,$.containerWidth):!1}function C(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const $=B.current;return!$||!$.composeOpen&&!$.keyboardVisible?!1:le(k.windowWidth,$.windowWidth)&&le(k.visualViewportWidth,$.visualViewportWidth)&&le(k.containerWidth,$.containerWidth)}function T(){const k=I.current;if(!k||k.isConnected===!1)return null;const $=k.getBoundingClientRect(),je=se(window.innerWidth)??0,et=se(window.visualViewport?.width)??je,ot=se($.width)??se(k.clientWidth)??je;if(je<=0||et<=0||ot<=0)return null;const{keyboardVisible:st}=cb(),Dt=document.documentElement.hasAttribute(Kp),Mt=O()||st;return{windowWidth:je,visualViewportWidth:et,containerWidth:ot,composeOpen:Dt,keyboardVisible:st,mobileLike:Mt}}function O(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function te(){return cb().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function se(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function le(k,$){return Math.abs(k-$)<=BI}function we(){for(const k of OI)Cs(k)}function Ae(){M.current=null,we()}function qe(){if(re.current===null&&$t.current&&document.visibilityState!=="hidden"&&(re.current=Date.now(),wt("requested")),Ye(),V.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{V.current.delete(k),Ye();const $=window.requestAnimationFrame(()=>{V.current.delete($),Ye()});V.current.add($)});V.current.add(k)}for(const k of Dv){if(N.current.has(k))continue;const $=window.setTimeout(()=>{N.current.delete(k),Ye(),k===Dv[Dv.length-1]&&re.current!==null&&(wt("timeout",{elapsedMs:Date.now()-re.current}),re.current=null)},k);N.current.set(k,$)}}function Ye(){const k=F.current;if(!(!k||!ae.current||document.visibilityState==="hidden"||!$t.current||I.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function pt(){for(const k of ge.current.values())window.clearTimeout(k);ge.current.clear()}function gn(){re.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 wt(k,$={}){const je=F.current;lI(H.current(e.id),k,{visible:$t.current,cols:je?.cols??0,rows:je?.rows??0,viewportY:je?.buffer.active.viewportY??0,baseY:je?.buffer.active.baseY??0,pendingChunks:ve.current.length-Pe.current,replaying:fn.current,...$})}function dn(){const k=F.current;if(!Te.current||!Z.current||!k||!ae.current||!$t.current||document.visibilityState==="hidden"||fn.current||$e.current||In.current||Ft.current||!Ju(k,pn.current))return;const $=1100-(Date.now()-Ke.current);if($>0){ye.current===null&&(ye.current=window.setTimeout(()=>{ye.current=null,dn()},$));return}Oa({type:"redraw",terminalId:e.id},{durability:"live-only"})==="sent"?(Te.current=!1,Ke.current=Date.now(),wt("redraw_sent")):ye.current===null&&He.current<4&&(He.current+=1,ye.current=window.setTimeout(()=>{ye.current=null,dn()},250))}function Ll(){for(const k of Ie.current)window.clearTimeout(k);Ie.current=[]}function ls(){if(pi(),!jt.current){wa(!1);return}wa(!0),jl(),Nt.current=window.setTimeout(()=>{Nt.current=null,wa(!1)},1200)}function pi(){const k=F.current,$=k?L6(k):null;if(jt.current=$,di($),Nr(!!(k&&$)),Ao(!!(k&&$&&!vs(k))),$||!k||!nh()){Rr(null);return}Rr({alternate:k.buffer.active.type==="alternate"})}function nh(){const k=vt.current;return Le.current.length>0||!!k?.hasMore}function jl(){Nt.current!==null&&(window.clearTimeout(Nt.current),Nt.current=null)}function Ol(){const k=F.current;k&&(pn.current=!vs(k),pi())}function Zc(k){Be.current=jv(Be.current,k)}function ih(k){const $=Be.current;return Be.current=null,jv($,k)}function Qc(){const k=Be.current;return Be.current=null,k}function Ur(k={}){const $=F.current;if(!$||!ae.current){Fe.current=!0;return}if(In.current&&!fn.current&&!$e.current&&vs($)){$r();return}if(fn.current){Zc(k);return}if($e.current){Zc(k);return}const je=ih(k);if(!je.force&&!Ju($,pn.current)){pi();return}$e.current=!0;const et=ut.current,ot=()=>{if(F.current!==$||ut.current!==et)return;if(!je.force&&!Ju($,pn.current)){if($e.current=!1,Or())return;pi();return}const st=Pe.current,Dt=ve.current[st];if(Dt===void 0){if($e.current=!1,Or())return;je.scrollToBottom&&Uo($),pi();const Mt=Qc();Mt?Ur(jv(je,Mt)):($r(),dn());return}$.write(sh(Dt),()=>{F.current!==$||ut.current!==et||(Pe.current=st+1,ot())})};ot()}function Jc(k){return In.current!==null||!vs(k)&&(em()||$e.current||fn.current)}function Jp(k,$){return($?.agentStatus?.provider==="codex"||$?.agentStatus?.provider==="claude"||ti.current||ol($?.currentCommand))&&!vs(k)}function em(){return Pe.current<ve.current.length}function sh(k){return pe.current.write(k)}function Hi(k,$){In.current={output:k,history:$,appendFromLiveOutputIndex:ve.current.length}}function $r(){const k=F.current,$=In.current;if(!k||!$||!vs(k)||$e.current||fn.current)return;const je=$.output,et=ve.current.slice($.appendFromLiveOutputIndex);In.current=null,La([...je,...et],$.history),Ae()}function Bl(){mn.current=!0}function Il(){Ol(),mn.current=!1;const k=F.current;k&&vs(k)&&Ur({scrollToBottom:!0})}function Uo(k){Pl(()=>EC(k))&&(pn.current=!1)}function eu(k,$){Pl(()=>(k.scrollToLine($),!0))}function Pl(k){ui.current=!0;try{return k()}finally{ui.current=!1}}function tm(){const k=F.current;if(!k)return;me.current&&(ru(Q.current),ki(!1)),EC(k),pn.current=!1,pi(),Ur({force:!0,scrollToBottom:!0}),Gi("scroll-action")}function Fr(k){const $=F.current,je=I.current;if(!$||!je)return;const et=je.getBoundingClientRect();if(et.height<=0)return;const ot=Math.max(0,Math.min(1,(k-et.top)/et.height)),st=Math.round($.buffer.active.baseY*ot);Bl();try{$.scrollToLine(st)}finally{Il()}pn.current=!vs($),pi(),ls(),st<=3&&Ir()}function tu(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),Fr(k.clientY)}function $o(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),Fr(k.clientY))}function nu(){const k=F.current,$=he.current;if(!(!k||!$)&&!(document.visibilityState==="hidden"||!$t.current||I.current?.isConnected===!1))try{const je=Ju(k,pn.current),et=T();$.fit(),et&&(R.current=et),je&&Uo(k),k.refresh(0,Math.max(0,k.rows-1)),pi();const ot={cols:k.cols,rows:k.rows},st=M.current;if(st&&st.cols===ot.cols&&st.rows===ot.rows)return;ar({type:"resize",terminalId:e.id,cols:ot.cols,rows:ot.rows})&&(M.current=ot)}catch{}}function Oa(k,$){const je=Q.current;return je?je(k,$):"rejected"}function ar(k){return Oa(k)!=="rejected"}function Ws(){We.current!==null&&(window.clearTimeout(We.current),We.current=null)}function zl(){Ws();const k=Math.max(-vf,Math.min(vf,Oe.current));if(Oe.current=0,k===0)return!1;const $=Oa({type:"scrollback_scroll",terminalId:e.id,lines:k},{durability:"live-only"})==="sent";return $&&(j.current=!0,k<0&&ki(!0)),$}function iu(k){if(!me.current||k===0)return;const $=Oe.current+k;Oe.current=Math.max(-vf,Math.min(vf,$)),We.current===null&&(We.current=window.setTimeout(()=>{We.current=null,zl()},t6))}function Wr(){ru(Q.current)}function su(k=Q.current,$={}){const je=j.current;Ws(),Oe.current=0,j.current=!1,$.updateUi!==!1&&ki(!1),je&&k?.({type:"cancel_scrollback",terminalId:e.id})}function ru(k){Ws(),Oe.current=0,j.current=!1,ki(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function au(){if(!Ce.current)return;const k=!me.current;ft(PL(ie.current,k)),Ul()}function nm(){const k=!Ve.current;Ve.current=k,ws(k),or({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 rh(){sn.current!==null&&(window.clearTimeout(sn.current),sn.current=null)}function or(k,$={}){rh();const je=tt.current+1;tt.current=je,ss({...k,id:je}),!$.sticky&&(sn.current=window.setTimeout(()=>{sn.current=null,ss(et=>et?.id===je?null:et)},12e3))}function ah(){Xe.current.skipped=!0,or({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function oh(){Ve.current=!1,ws(!1),or({tone:"skipped",message:"Cache keep-alive off"})}async function Hl(){const k=Xe.current;if(k.sent||k.skipped)return;const $=cs();if(k.sent=!0,$){or({tone:"skipped",message:"Skipped cache keep-alive",detail:$});return}if(zn(`${_C}\r`,{userInitiated:!1})==="rejected"){or({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}or({tone:"success",message:"Cache keep-alive sent",detail:_C})}function cs(){const k=ke.current,$=en.current;return Ve.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!$?"Transcript cache status is unavailable.":k.source.provider!==$.provider||k.source.sessionId!==$.sessionId?"The transcript session changed.":e.agentStatus&&["working","finishing","waiting"].includes(e.agentStatus.state)?`${bo($.provider)} has an active turn or is waiting for a response.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Dc(e.id).text.trim()?"Compose has an unsent draft.":g6(I.current)?"Pane input is focused.":Date.now()-Yn.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function Ul(){const k=F.current;k&&(Uo(k),pi())}function zn(k,$={}){if(Vi.current?.allowInput(k,$.textPaste)===!1)return"rejected";St.current&&$.userInitiated!==!1&&!$.preserveMobileShift&&k&&k!=="\x1B[I"&&k!=="\x1B[O"&&lr(!1),zl();const je=j.current;Ur({force:!0,scrollToBottom:!0});const et=Oa({type:"input",terminalId:e.id,data:k,...je?{cancelScrollbackMode:!0}:{}},{durability:$.userInitiated===!1||$.liveOnly?"live-only":"durable"});return et==="rejected"?($.userInitiated!==!1&&fi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),et):($.userInitiated!==!1&&(Yn.current=Date.now()),je&&(j.current=!1,ki(!1)),M6(k)&&(et==="sent"?lu():et==="queued"&&(_e.current=!0)),et)}function Ba(k){if(!me.current||!Ut.current||!$t.current)return;const $=ML(k,W.current??$l()??1);Oa({type:"input",terminalId:e.id,data:$},{durability:"live-only"})==="sent"&&/\x1b\[<(?:0|32|64|65);/.test(k)&&(j.current=!0,(Me.current==="tmux"||Me.current==="copy")&&ki(!0))}function $l(){return Me.current==="application"&&ze.current.codex?ze.current.speed:null}function Fl(k,$){const je=F.current;if(!(!je||$===0)){W.current=Math.abs($);try{je.element?.dispatchEvent(w2(k,Math.sign($),1))}finally{W.current=null}}}function Wl(){Qe.current&&mi(!1),zn(HI)}function ou(k){const $=Af(k,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0||Vi.current?.pending===!0,stripTrailingLineBreaks:!0});$&&zn($,{textPaste:!0})}function Kr(k,$){const je=F.current?.modes.bracketedPasteMode===!0,et=ni==="codex"||ni==="claude"||ol(e.currentCommand),ot=k.parts.map(st=>st.kind==="image"&&et?Af(st.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Af(st.kind==="image"?st.path:st.value,{bracketedPasteMode:je,stripTrailingLineBreaks:!1})).join("");return ot?zn(`${ot}${G5($)}`)!=="rejected":!1}function lu(){!Wt.current||!Ut.current||(Ll(),Ie.current=II.map(k=>{const $=window.setTimeout(()=>{Ie.current=Ie.current.filter(je=>je!==$),Wt.current&&Ut.current&&ar({type:"refresh_cwd",terminalId:e.id})},k);return $}))}function Gi(k="terminal-interaction"){Vt.current||te()&&(k==="auto"||k==="scroll-action")||F.current?.focus()}const Ia=v.useCallback(()=>{xs(!1)},[]);function im(){lr(!1),Ca(k=>{const $=!k;return Qe.current=$,$}),Gi("input-action")}function mi(k){Qe.current=k,Ca(k)}function lr(k){St.current=k,tr(k)}function Ks(k){mi(!1),lr(k),Gi("input-action")}function lh(k){Qe.current&&mi(!1);const $=St.current&&k!=="interrupt"&&k!=="escape";zn(lb(k,$),{preserveMobileShift:$}),Gi("input-action")}async function Fo(k="install"){Hs(!0),as(null);try{const $=k==="update"?await t.updateCodeServer():await t.installCodeServer();Sb(Gt,$.status),zs($.status)}catch($){as(_f($))}finally{Hs(!1)}}return u.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":hi?"true":"false",onMouseDown:()=>{n||m()},children:[u.jsx(v6,{terminal:e,canClose:o,tabId:d,transcriptSource:Pn,hasTranscriptCandidates:jo.length>0,transcriptShortcutLabel:z,subagentsShortcutLabel:Y,transcriptCacheStatus:Ti,transcriptCacheNow:Ps,cacheKeepAliveEnabled:Oi,codeServerAvailable:!0,codeServerInstallState:Mn===null?"unknown":Mn.installed?"installed":"missing",codeServerBusy:Na||Mn?.job?.status==="running",codeServerSupported:Mn?.supported!==!1,scrollbackShortcutLabel:q,tmuxScrollbackSupported:rr,tmuxScrollbackEnabled:hi,onToggleCacheKeepAlive:nm,onOpenCodeServer:jr,onToggleTmuxScrollback:au,onOpenTranscript:Io,onOpenSubagents:Lr,onReload:ja,onClose:p}),u.jsx("div",{className:"xterm-container",ref:I}),Ai?u.jsxs("div",{className:"terminal-image-paste-status","data-error":Ai.error?"true":"false",role:"status","aria-live":"polite",children:[u.jsx("span",{children:Ai.message}),u.jsx("button",{type:"button","aria-label":Ai.uploading?"Cancel image paste":"Dismiss image paste message",title:Ai.uploading?"Cancel image paste":"Dismiss",onMouseDown:k=>k.preventDefault(),onClick:()=>{Vi.current?.cancel()},children:u.jsx(Zf,{size:16,"aria-hidden":"true"})})]}):null,kr?u.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:u.jsx("span",{"aria-hidden":"true"})}):null,E&&!hi&&Ci?u.jsxs("div",{className:"terminal-scroll-progress","data-active":Tr,"aria-hidden":"true",children:[Ci.current,"/",Ci.total]}):E&&!hi&&Er?u.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Er.alternate?"alternate":"normal","aria-hidden":"true",children:[Er.alternate?"alt ":"","0/?"]}):null,!hi&&xa||hi&&Tl&&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(),tm()},children:"↓"}):null,Li&&!hi?u.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:tu,onPointerMove:$o,children:u.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Bo?u.jsx(S5,{ctrlActive:er,shiftActive:Lo,onCtrl:im,onShift:Ks,onStandaloneKey:lh,onPreserveFocus:()=>Gi("input-action"),onHide:()=>{lr(!1),Aa(!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(),Gi("input-action")},onPointerDown:k=>{k.stopPropagation(),Gi("input-action")},onClick:()=>Aa(!0),children:"⌨"}):null,u.jsx(a4,{terminalId:e.id,onSubmit:Kr,onUploadAttachments:(k,$)=>t.uploadComposeAttachments({terminalId:e.id,files:k,signal:$.signal,onProgress:$.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:k=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:k})}:{},queueAvailable:ni==="codex"||wb(e.currentCommand),disabled:e.status!=="running"}),u.jsx(S6,{toast:nr,onSendNow:()=>{Hl()},onSkipOnce:ah,onTurnOff:oh,onDismiss:()=>ss(null)}),Dr?u.jsx(w6,{terminalId:e.id,serverApi:t,source:Pn,candidates:jo,rememberedSelection:Nn,fontSize:S,onClose:Ia},e.id):null,Ra&&Pn?u.jsx(XB,{terminalId:e.id,serverApi:t,source:Pn,fontSize:S,onClose:()=>rs(!1)}):null,Us?u.jsx(b6,{notice:Us}):null,Mr?u.jsx(_6,{status:Mn,busy:Na,error:El,onInstall:()=>{Fo("install")},onUpdate:()=>{Fo("update")},onOpen:jr,onRefresh:()=>{Fs({checkLatest:!0}).catch(k=>as(_f(k)))},onClose:()=>Yi(!1)}):null]})}function SC(e){return DN(e)}async function wC(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,l=Date.now(),d=yc.get(e);if(!o&&d?.status&&l-d.fetchedAt<=n6)return d.status;if(d?.inflight&&(!r||d.inflightCheckLatest))return d.inflight;let f;return f=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(m=>(Sb(e,m),m)).catch(m=>{const p=yc.get(e);throw p?.inflight===f&&(p.status?yc.set(e,{status:p.status,fetchedAt:p.fetchedAt}):yc.delete(e)),m}),yc.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:l},inflight:f,inflightCheckLatest:r}),f}function Sb(e,t){yc.set(e,{status:t,fetchedAt:Date.now()})}function xC(e,t){return`${e}:${t}`}function qy(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function b2(e){const t=bp.get(e);return t?y2(t.handle)?(bp.delete(e),null):t:null}function i6(e){if(e){const t=b2(e);if(t)return{handle:t.handle,ownsPopup:!1}}try{const t=e?window.open("",qy(e)):window.open("about:blank","_blank");return{handle:t,ownsPopup:s6(t)}}catch{return{handle:null,ownsPopup:!1}}}function s6(e){try{return!!(e&&!e.closed&&e.location.href==="about:blank")}catch{return!1}}function r6(e,t){try{const n=new URL(e.location.href,window.location.href),r=new URL(t,window.location.href);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}}function Vy(e){try{e.focus()}catch{}}function a6(e,t,n){let r;try{r=window.open(t,qy(e))}catch{return null}return r?(bp.set(e,{handle:r,createdAt:n}),Vy(r),r):null}function o6(e,t,n,r){if(!e||y2(e))return!1;try{e.name=qy(t),e.location.href=n,bp.set(t,{handle:e,createdAt:r})}catch{return!1}return Vy(e),!0}function l6(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 c6(e){if(e)try{e.closed||e.close()}catch{}}function Av(e,t,n){const r=u6(e,t),o=CC(r*Math.max(1,n),YI,GI);return{limit:CC(Math.ceil(o/KI),qI,VI),maxLines:o}}function u6(e,t){const n=e?.clientHeight??0;if(n<=0)return FI;const r=Math.max(10,t*WI);return Math.max(1,Math.floor(n/r))}function CC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function d6(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function h6(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 f6(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function p6(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const l=Math.floor(r/24),d=r%24;return d>0?`${l}d ${d}h`:`${l}d`}function m6(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function _f(e){return e instanceof Fn||e instanceof Error?e.message:"Something went wrong."}function g6(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function v6({terminal:e,canClose:t,tabId:n,transcriptSource:r,hasTranscriptCandidates:o,transcriptShortcutLabel:l,subagentsShortcutLabel:d,transcriptCacheStatus:f,transcriptCacheNow:m,cacheKeepAliveEnabled:p,codeServerAvailable:b,codeServerInstallState:_,codeServerBusy:w,codeServerSupported:S,scrollbackShortcutLabel:x,tmuxScrollbackSupported:E,tmuxScrollbackEnabled:L,onToggleCacheKeepAlive:A,onOpenCodeServer:K,onToggleTmuxScrollback:P,onOpenTranscript:z,onOpenSubagents:q,onReload:Y,onClose:I}){const F=sy({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),he={cursor:n?"grab":"default",opacity:F.isDragging?.5:void 0};return u.jsxs("header",{ref:F.setNodeRef,className:"terminal-pane-header",style:he,"data-dragging":F.isDragging,...F.attributes,...F.listeners,children:[u.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),u.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),u.jsx("span",{className:"terminal-pane-spacer"}),b?u.jsx("button",{type:"button",className:"terminal-pane-code","data-state":_,"data-busy":w?"true":"false",disabled:!S||w,title:_==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":_==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),K()},children:u.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r||o?u.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r?.provider,title:"View transcript history","aria-label":"View transcript history",onPointerDown:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),z()},children:[u.jsx("span",{className:"pane-button-label-full",children:"View history"}),u.jsx("span",{className:"pane-button-label-short",children:"History"}),u.jsx("kbd",{children:l})]}):null,r?u.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.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,r?u.jsx(y6,{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,E&&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:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),P()},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:"Reload pane output",onPointerDown:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),Y()},children:"↻"}):null,t?u.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:Q=>Q.stopPropagation(),onMouseDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),I()},children:"x"}):null]})}function _6({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:l,onRefresh:d,onClose:f}){const m=e?.job??null,p=m?.status==="running",b=e?.installed===!0,_=e?.supported!==!1,w=e===null&&t,S=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:E=>E.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsxs("div",{children:[u.jsx("h2",{children:x}),u.jsx("p",{children:w?"Checking code-server status...":b?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),u.jsxs("div",{className:"code-server-dialog-scroll",children:[u.jsxs("div",{className:"code-server-dialog-body",children:[u.jsxs("p",{children:["NTerminal installs code-server under ",u.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?u.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),_?null:u.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?u.jsx("p",{className:"code-server-dialog-error",children:n}):null,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:[S?u.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!_,children:"Update"}):null,u.jsx("button",{type:"button",onClick:l,disabled:t||p,children:"Open"})]}):u.jsx("button",{type:"button",onClick:r,disabled:t||p||!_,children:p?"Installing...":"Install"})]})]})})}function b6({notice:e}){return u.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function y6({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=S2(e,t),l=f6(e,o),d=o===null?"?":p6(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(),r()},children:[u.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[u.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),u.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{children:d})]})}function S6({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const l=e.tone==="info"||e.tone==="warning";return u.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[u.jsxs("header",{children:[u.jsx("strong",{children:e.message}),u.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?u.jsx("p",{children:e.detail}):null,l?u.jsxs("div",{className:"cache-keepalive-toast-actions",children:[u.jsx("button",{type:"button",onClick:t,children:"Send now"}),u.jsx("button",{type:"button",onClick:n,children:"Skip once"}),u.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}function w6(e){const[t,n]=v.useState(null),[r,o]=v.useState(),[l,d]=v.useState(e.candidates),[f,m]=v.useState(e.source),[p,b]=v.useState(null),[_,w]=v.useState(!0),S=v.useRef(0);async function x(A=!1,K=!1){const P=++S.current;w(!0);try{const z=await e.serverApi.getTerminalTranscriptSource(e.terminalId);if(P!==S.current)return;if(d(z.candidates??[]),m(z.source),K&&!z.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=z.candidates?.find(F=>F.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)&&z.source)n(z.source),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);else if((A||!t)&&!Y&&z.candidates?.length===1){const I=z.candidates[0];n({provider:I.provider,sessionId:I.sessionId}),o(I.id)}b(null)}catch(z){if(P!==S.current)return;if(K&&e.source){n(e.source);return}b(z instanceof Error?z.message:"Could not load sessions.")}finally{P===S.current&&w(!1)}}v.useEffect(()=>(x(!1,!0),()=>{S.current+=1}),[]),v.useEffect(()=>{if(t)return;function A(K){K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),e.onClose())}return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[t,e.onClose]);const E=[];t&&E.push({id:r??"__pinned",title:l.find(A=>A.id===r)?.title||`${bo(t.provider)} · ${t.sessionId}`,detail:l.find(A=>A.id===r)?.cwd||t.sessionId}),f&&(!t||!pa(f,t))&&E.push({id:"__current",title:`Current session · ${bo(f.provider)}`,detail:f.sessionId});for(const A of l)t&&pa(t,A)||f&&pa(f,A)||E.push({id:A.id,title:A.title||A.sessionId,detail:`${bo(A.provider)} · ${A.cwd}${A.updatedAt?` · ${new Date(A.updatedAt).toLocaleString()}`:""}`});const L=t&&E.length<=1?null:u.jsxs("div",{className:"transcript-session-picker",children:[E.length>1?u.jsx(s5,{options:E,value:r??(t?"__pinned":void 0),onSelect:A=>{if(S.current+=1,w(!1),A==="__current"&&f){n(f),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);return}const K=l.find(P=>P.id===A);K&&(n({provider:K.provider,sessionId:K.sessionId}),o(K.id),e.rememberedSelection&&(e.rememberedSelection.current={terminalId:e.terminalId,candidateId:K.id}))}}):null,u.jsx("button",{type:"button","aria-label":"Refresh sessions",title:"Refresh sessions",disabled:_,onClick:()=>{x()},children:u.jsx(jc,{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(x6,{...e,key:`${t.provider}:${t.sessionId}:${r??""}`,source:t,...r?{candidateId:r}:{},sessionPicker:L,liveSourceChanged:!!(e.source&&!pa(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 x6=Ht.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:l,onReloadLatest:d,candidateId:f,sessionPicker:m,liveSourceChanged:p}){const b=v.useRef(null),_=v.useRef(null),w=v.useRef(null),S=v.useRef(null),x=v.useRef(!0),E=v.useRef(null),[L,A]=v.useState(!1),K=v.useRef(!1),P=v.useRef(null),z=v.useRef(!1),q=v.useRef(()=>{});q.current=Vt;const Y=v.useRef(0),I=v.useRef(!1),F=v.useRef(!1),he=v.useRef(null),Q=v.useRef(null),ee=v.useRef(null),[ie,J]=v.useState([]),[H,X]=v.useState(!1),[M,R]=v.useState(""),[B,oe]=v.useState(null),[ge,N]=v.useState(null),[V,re]=v.useState(!1),[Z,Te]=v.useState(!1),[ye,He]=v.useState(-1),[Ke,Ie]=v.useState(null),[_e,We]=v.useState(null),[Oe,j]=v.useState(!1),[me,Me]=v.useState(!0),[ze,W]=v.useState(!1),[pe,Ce]=v.useState(null),[Ne,Le]=v.useState(!1),ve=d5(n,t,r,f,H,M),Pe=v.useRef(0),$e=v.useRef(null),Be=v.useRef(null);function ut(){if(K.current)return!0;const ce=b.current,ke=window.getSelection();if(!ce||!ke||ke.isCollapsed)return!1;for(let Ve=0;Ve<ke.rangeCount;Ve++)if(ke.getRangeAt(Ve).intersectsNode(ce))return!0;return!1}v.useEffect(()=>{const ce=()=>{ut()||(P.current?P.current.resume():z.current&&(z.current=!1,q.current()))},ke=()=>{K.current=!1,ce()};return document.addEventListener("selectionchange",ce),document.addEventListener("pointerup",ke,!0),document.addEventListener("pointercancel",ke,!0),window.addEventListener("blur",ke),()=>{document.removeEventListener("selectionchange",ce),document.removeEventListener("pointerup",ke,!0),document.removeEventListener("pointercancel",ke,!0),window.removeEventListener("blur",ke),P.current?.cancel()}},[]);function ht(ce){return ce?.aborted?Promise.reject(new DOMException("Aborted","AbortError")):ut()?new Promise((ke,Ve)=>{const Xe=()=>{ce?.removeEventListener("abort",tt),P.current?.cancel===tt&&(P.current=null)},tt=()=>{Xe(),Ve(new DOMException("Aborted","AbortError"))};P.current={resume:()=>{Xe(),ke()},cancel:tt},ce?.addEventListener("abort",tt,{once:!0})}):Promise.resolve()}v.useEffect(()=>{Nn(),oe(null),N(null)},[M,H]),v.useEffect(()=>()=>{Pe.current+=1,Be.current?.abort()},[]),v.useEffect(()=>{function ce(ke){ke.key==="Escape"&&(ke.preventDefault(),ke.stopPropagation(),l())}return document.addEventListener("keydown",ce,!0),()=>document.removeEventListener("keydown",ce,!0)},[l]),v.useLayoutEffect(()=>{Y.current+=1;const ce=Y.current;I.current=!1,F.current=!0,he.current=null,Q.current=null,ee.current=null;const ke=c5(n,t,r,H);return _.current=ke,w.current=ke.snapshot,x.current=!0,E.current=null,A(!1),We(null),j(!1),Ce(null),Le(!1),oe(null),N(null),He(-1),Ie(null),ke.snapshot?(F.current=!1,E.current={top:ke.snapshot.scrollTop,atBottom:ke.snapshot.atBottom,...ke.snapshot.scrollAnchor},Ut(ke.snapshot),Me(!1),$t(ke.snapshot,ce)):(J([]),Me(!0),Wt(null,"initial",ce)),()=>{St(),ke.release(),_.current===ke&&(_.current=null),Y.current+=1,$e.current?.abort(),I.current=!1}},[n,H,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ce=b.current;if(!ce)return;const ke=E.current;if(ke&&!me&&S.current===ie){E.current=null;const Xe=ke.key?Array.from(ce.querySelectorAll("[data-transcript-entry-key]")).find(tt=>tt.dataset.transcriptEntryKey===ke.key):null;ce.scrollTop=ke.atBottom?ce.scrollHeight:Xe?ce.scrollTop+Xe.getBoundingClientRect().top-ce.getBoundingClientRect().top-(ke.offset??0):ke.top;return}if(F.current){if(me||ie.length===0)return;F.current=!1;const Xe=()=>{ce.scrollTop=ce.scrollHeight};Xe(),window.requestAnimationFrame?.(Xe);return}const Ve=he.current;Ve!==null&&(he.current=null,ce.scrollTop+=ce.scrollHeight-Ve)},[ie,me,H]);const vt=bo(r.provider),Rt=Ht.useMemo(()=>cp(ie,H),[ie,H]),cn=Ht.useMemo(()=>ib(Rt),[Rt]),at=Ht.useMemo(()=>C6(cn),[cn]),Wn=at.map(ce=>ce.key).join(""),kn=Ke?at.find(ce=>ce.key===Ke)?.entryIndex??null:null,_t=M.trim().length>0,jt=ve.result?.hits.length??0,Nt=ve.result?.hits.findIndex(ce=>ce.id===B?.id)??-1,pn=ge?.entryIndex??null,ui=_t?pn:kn,fn=_t?pn===null?null:"search":kn===null?null:"prompt",mn=Rt?Rt.split(`
|
|
54
|
+
`).length-1:0,ae=at.length>0&&ye>=0&&ye<at.length?ye:at.length-1,Fe=Ke??(ae>=0?at[ae]?.key??null:null),Qe=_t?jt>0?`${Nt+1}/${jt} ${jt===1?"match":"matches"} · ${mn} ${mn===1?"line":"lines"}`:`0 matches · ${mn} ${mn===1?"line":"lines"}`:at.length>0?`${ae+1}/${at.length} prompts · ${mn} ${mn===1?"line":"lines"}`:`0 prompts · ${mn} ${mn===1?"line":"lines"}`;v.useEffect(()=>{if(_t){Ie(null);return}Ke&&!at.some(ce=>ce.key===Ke)&&Ie(null),He(ce=>{if(at.length===0)return ee.current=null,-1;const ke=ee.current?at.findIndex(Xe=>Xe.key===ee.current):-1,Ve=ke>=0?ke:ce>=0&&ce<at.length?ce:at.length-1;return ee.current=at[Ve]?.key??null,Ve})},[Ke,_t,Wn]),v.useEffect(()=>{const ce=Q.current;if(!ce||at.length===0)return;Q.current=null;const ke=ce.anchorKey?at.findIndex(Xe=>Xe.key===ce.anchorKey):-1,Ve=ke>0?ke-1:0;lt(Ve)},[Wn]);function St(){const ce=w.current,ke=b.current;if(!ce||!ke||!x.current)return;const Ve=Array.from(ke.querySelectorAll("[data-transcript-entry-key]")).find(tt=>tt.getBoundingClientRect().bottom>ke.getBoundingClientRect().top),Xe={...ce,scrollTop:ke.scrollTop,atBottom:ke.scrollHeight-ke.clientHeight-ke.scrollTop<=4,...Ve?{scrollAnchor:{key:Ve.dataset.transcriptEntryKey,offset:Ve.getBoundingClientRect().top-ke.getBoundingClientRect().top}}:{}};w.current=Xe,_.current?.write(Xe)}function Ut(ce){w.current=ce,_.current?.write(ce);const ke=bc([ce.page.records.map(Xe=>Xe.block).join(`
|
|
55
|
+
|
|
56
|
+
`)],r.provider,{includeTools:H}),Ve=ke?[ke]:[];S.current=Ve,J(Ve),We(ce.cursor),j(ce.hasMore)}async function $t(ce,ke){$e.current?.abort();const Ve=new AbortController;$e.current=Ve,I.current=!0,Me(!1),W(!1),A(!0),Ce(null);let Xe=null;try{for(;;){const Yt=await n.getTerminalTranscriptHistory(t,{...Av(b.current,o,Mv),...Xe?.cursor?{cursor:Xe.cursor}:{ifSnapshot:ce.page.snapshot},includeTools:H,expectedSessionId:r.sessionId,...f?{candidateId:f}:{}},Ve.signal);if(Y.current!==ke||!_.current?.current())return;if(!Yt.source)throw new Error("Transcript source is temporarily unavailable. Retry loading newest.");if(!pa(r,Yt.source))throw Le(!0),_.current?.invalidate(),new Error("Transcript session changed. Load newest to refresh.");if(Le(!1),Yt.page?.unchanged)return;if(!Yt.page){if(await ht(Ve.signal),Y.current!==ke)return;w.current=null,_.current?.invalidate(),J([bc(Yt.output,r.provider,{includeTools:H})]),We(Yt.cursor),j(Yt.hasMore);return}if(Xe=Xe?Gx(Xe,Yt):sb(Yt),!Xe)throw new Error("Transcript changed while loading. Load newest to retry.");if(IE(ce,Xe)||!Xe.hasMore||!Xe.cursor)break;await new Promise(qi=>window.setTimeout(qi,0))}if(await ht(Ve.signal),Y.current!==ke||!_.current?.current())return;St();const tt=b.current,sn=w.current??ce,Vn=r5(sn,Xe),xi=tt?Array.from(tt.querySelectorAll("[data-transcript-entry-key]")).find(Yt=>Yt.getBoundingClientRect().bottom>tt.getBoundingClientRect().top):void 0;E.current={top:Vn.scrollTop,atBottom:Vn.atBottom,...xi&&tt&&Vn.page.identity===ce.page.identity?{key:xi.dataset.transcriptEntryKey,offset:xi.getBoundingClientRect().top-tt.getBoundingClientRect().top}:{}},Ut(Vn)}catch(tt){Y.current===ke&&!Ve.signal.aborted&&(Ce(tt instanceof Error?tt.message:"Could not check the latest history."),tt instanceof Fn&&tt.status===409&&(_.current?.invalidate(),Le(!0)))}finally{Y.current===ke&&(I.current=!1,A(!1))}}async function Wt(ce,ke,Ve=Y.current){if(!I.current){I.current=!0,$e.current?.abort(),$e.current=new AbortController,A(!1),Me(ke==="initial"),W(ke==="older"),ke==="older"&&(he.current=b.current?.scrollHeight??null),Ce(null);try{await un(ce,ke,Ve)}catch(Xe){if(Y.current!==Ve)return;Ce(Xe instanceof Error?Xe.message:"Failed to load transcript history."),Xe instanceof Fn&&Xe.status===409&&Le(!0)}finally{Y.current===Ve&&(I.current=!1,Me(!1),W(!1))}}}async function un(ce,ke,Ve){const Xe=$e.current?.signal;let tt=ce,sn=0,Vn=[];const xi=ke==="initial"&&r.provider!=="claude"?ZI:XI;for(;Y.current===Ve;){const Yt=await n.getTerminalTranscriptHistory(t,{...tt?{cursor:tt}:{},...Av(b.current,o,ke==="initial"?Mv:$I),includeTools:H,expectedSessionId:r.sessionId,...f?{candidateId:f}:{}},Xe);if(Y.current!==Ve||(ke==="older"&&await ht(Xe),Y.current!==Ve))return;if(!Yt.source){Ce("Transcript source is temporarily unavailable.");return}if(!pa(r,Yt.source)){_.current?.invalidate(),Le(!0),j(!1);return}const qi=bc(Yt.output,r.provider,{includeTools:H}),Yn=Bn(Yt,ke,Vn,qi);if(qi&&(Vn=[qi,...Vn],Yn))return;if(!Yt.hasMore||!Yt.cursor||sn>=xi){Vn.length>0&&J(ti=>ke==="older"?[...Vn,...ti]:Vn);return}tt=Yt.cursor,sn+=1}}function Bn(ce,ke,Ve,Xe=bc(ce.output,r.provider,{includeTools:H})){if(x.current&&ce.page&&!ce.page.unchanged){const sn=w.current,Vn=ke==="older"&&sn?Gx(sn,ce):sb(ce);if(!Vn)throw new Error("Transcript changed while loading. Load newest to retry.");return ke==="older"&&(he.current=b.current?.scrollHeight??null),Ut(Vn),!!Xe}if(We(ce.cursor),j(!!(ce.hasMore&&ce.cursor)),!Xe)return!1;const tt=[Xe,...Ve];return cp(tt,H)?(J(sn=>ke==="older"?[...tt,...sn]:tt),!0):!1}function Vt(){const ce=b.current;if(ce){if(ut()){z.current=!0;return}z.current=!1,Dn(),!(_t||ce.scrollTop>72||!Oe||!_e||I.current)&&Wt(_e,"older")}}function Kn(ce){if(jt===0)return;const ke=Nt>=0?Nt:ce>0?-1:0;qn((ke+ce+jt)%jt)}function Nn(){Pe.current+=1,Be.current?.abort(),Be.current=null,re(!1)}function en(){const ce=w.current;x.current||(x.current=!0,$e.current?.abort(),Y.current+=1,I.current=!1,W(!1),he.current=null,ce?(E.current={top:ce.scrollTop,atBottom:ce.atBottom,...ce.scrollAnchor},Ut(ce),$t(ce,Y.current)):(J([]),We(null),j(!1),F.current=!0,Wt(null,"initial")))}async function qn(ce){const ke=ve.result?.hits[ce];if(!ke)return;St(),x.current=!1,A(!1);const Ve=++Pe.current;Be.current?.abort(),$e.current?.abort();const Xe=new AbortController;Be.current=Xe,Y.current+=1,I.current=!1,F.current=!1,he.current=null,Me(!1),re(!0),W(!1),Ce(null),oe(ke),N(null);try{const tt=await n.getTerminalTranscriptHistory(t,{around:ke.cursor,expectedSessionId:r.sessionId,...f?{candidateId:f}:{},includeTools:H,...Av(b.current,o,Mv)},Xe.signal);if(Ve!==Pe.current)return;if(!tt.source||!pa(r,tt.source)){Le(!0);return}const sn=bc(tt.output,r.provider,{includeTools:H});J([sn]),N(u5(ib(sn),ke,M)),We(tt.cursor),j(!!(tt.hasMore&&tt.cursor)),b.current&&(b.current.scrollTop=0)}catch(tt){Ve===Pe.current&&(Ce(tt instanceof Error?tt.message:"Could not load search result."),tt instanceof Fn&&tt.status===409&&Le(!0))}finally{Ve===Pe.current&&re(!1)}}function lt(ce){const ke=at[ce];ke&&(ee.current=ke.key,He(ce),Ie(ke.key))}async function kt(ce){if(at.length===0){ce<0&&Oe&&_e&&!I.current&&(Q.current={anchorKey:null},await Wt(_e,"older"));return}const Ve=(ye>=0&&ye<at.length?ye:ce<0?at.length-1:-1)+ce;if(Ve>=0&&Ve<at.length){lt(Ve);return}ce<0&&Ve<0&&Oe&&_e&&!I.current&&(Q.current={anchorKey:at[0]?.key??null},await Wt(_e,"older"))}function Dn(){if(_t)return;const ce=b.current;if(!ce)return;const Ve=ce.getBoundingClientRect().top+Math.min(140,Math.max(48,ce.clientHeight*.28));let Xe=null;for(const tt of N6(ce)){const sn=D6(tt);if(sn!==null)if(tt.getBoundingClientRect().top<=Ve)Xe=sn;else break}if(Xe!==null){const tt=at[Xe]?.key??null;ee.current=tt,He(Xe),Ke&&Ke!==tt&&Ie(null)}}return u.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ce=>ce.stopPropagation(),onMouseDown:ce=>ce.stopPropagation(),onClick:ce=>{ce.stopPropagation(),l()},children:u.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ce=>ce.stopPropagation(),onMouseDown:ce=>ce.stopPropagation(),onClick:ce=>ce.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:[vt," JSONL"]}),u.jsx("span",{title:r.sessionId,children:r.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:H,onChange:ce=>X(ce.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:ce=>{ve.cancel(),Nn(),R(ce.currentTarget.value),ce.currentTarget.value.trim()||en()},onKeyDown:ce=>{ce.nativeEvent.isComposing||ce.key==="Enter"&&(ce.preventDefault(),_t?ve.result?.query===Wp(M)?jt>0?Kn(ce.shiftKey?-1:1):!ve.result.complete&&ve.result.cursor&&!ve.busy&&ve.search(!0):ve.busy||(Nn(),oe(null),N(null),ve.search()):kt(ce.shiftKey?-1:1))}})}),u.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":Z,"aria-label":"Toggle prompt list",title:"Toggle prompt list",onClick:()=>Te(ce=>!ce),disabled:at.length===0,children:u.jsx(LA,{size:16})}),u.jsxs("div",{className:"transcript-search-actions","aria-label":_t?"Search result navigation":"Prompt navigation",children:[u.jsx("button",{type:"button",onClick:()=>_t?Kn(-1):void kt(-1),disabled:_t?jt===0:at.length===0&&!Oe,"aria-label":_t?"Previous search match":"Previous user prompt",title:_t?"Previous search match":"Previous user prompt",children:u.jsx(EA,{size:16})}),u.jsx("button",{type:"button",onClick:()=>_t?Kn(1):void kt(1),disabled:_t?jt===0:at.length===0,"aria-label":_t?"Next search match":"Next user prompt",title:_t?"Next search match":"Next user prompt",children:u.jsx(CA,{size:16})})]}),u.jsx("span",{className:"transcript-result-count",children:Qe}),u.jsx("button",{type:"button",title:L?"Checking latest history...":"Load newest entries","aria-label":"Load newest entries","aria-busy":L,onClick:()=>{ve.cancel(),Nn(),$e.current?.abort(),Y.current+=1,I.current=!1,W(!1),he.current=null,Q.current=null,E.current=null,F.current=!0,oe(null),N(null),x.current=!0;const ce=w.current;ce?(F.current=!1,E.current={top:0,atBottom:!0},Ut({...ce,atBottom:!0}),$t(ce,Y.current)):Wt(null,"initial")},children:u.jsx(jc,{size:16})})]}),_t?u.jsxs("div",{className:"transcript-search-results","aria-label":"Search results","aria-busy":ve.busy,children:[u.jsxs("div",{className:"transcript-search-summary",role:"status",children:[ve.busy?"Searching...":ve.result?`${jt} ${jt>=200?"retained results":"results"}${ve.result.complete?" · Complete":" · More to scan"} · ${ve.result.scannedBytes.toLocaleString()} bytes scanned`:"Search history",ve.result&&!ve.result.complete&&ve.result.cursor?u.jsx("button",{type:"button",disabled:ve.busy,onClick:()=>{ve.search(!0)},children:"Search more"}):null]}),B&&Nt<0&&ve.result?u.jsx("div",{className:"transcript-dialog-status",children:"Selected result is outside the retained result window."}):null,ve.error?u.jsx("div",{className:"transcript-dialog-error",role:"alert",children:ve.error}):null,ve.result?.hits.map((ce,ke)=>u.jsxs("button",{type:"button",className:`transcript-prompt-index-item${B?.id===ce.id?" transcript-prompt-index-item-active":""}`,"aria-current":B?.id===ce.id?"true":void 0,onClick:()=>{qn(ke)},children:[u.jsxs("span",{children:[ce.timestamp?new Date(ce.timestamp).toLocaleString():""," · ",ce.role]}),u.jsx("strong",{children:ce.preview.slice(0,500)})]},ce.id))]}):null,Z?u.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:at.length>0?at.map((ce,ke)=>u.jsxs("button",{type:"button",className:Fe===ce.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>lt(ke),children:[u.jsx("span",{children:ce.timestampLabel}),u.jsx("strong",{children:ce.snippet})]},`${ce.key}:${ke}`)):u.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,Ne?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:Vt,onPointerDownCapture:()=>{K.current=!0},children:[ze?u.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!me&&Oe?u.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Rt?u.jsx(NE,{entries:cn,searchQuery:M,activeEntryIndex:ui,activeEntryMode:fn,activeSearchMatch:ge,fontSize:o}):null,me?u.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Ne&&!me&&!Rt&&!pe?Oe&&_e?u.jsxs("div",{className:"transcript-dialog-status",children:[H?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",u.jsx("button",{type:"button",onClick:()=>{Wt(_e,"older")},disabled:ze,children:"Search earlier entries"})]}):u.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null]})]})})});function C6(e){const t=[];for(let o=0;o<e.length;o+=1){const l=e[o];!l||l.kind!=="user"||t.push({contentKey:k6(l),entry:l,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const l=t[o];if(!l)continue;const d=n.get(l.contentKey)??0;n.set(l.contentKey,d+1),r.set(o,JSON.stringify([l.contentKey,d]))}return t.map((o,l)=>({entryIndex:o.entryIndex,key:r.get(l)??JSON.stringify([o.contentKey,0]),snippet:E6(o.entry.body),timestampLabel:R6(o.entry.header)}))}function k6(e){return JSON.stringify([e.header??"",e.body.length,T6(e.body)])}function T6(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 E6(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function R6(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function N6(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function D6(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 M6(e){return e.includes("\r")||e.includes(`
|
|
57
|
+
`)}function Lv(e){return e instanceof Fn&&e.status===404}function ol(e){return wb(e)||xb(e)}function wb(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function xb(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function kC(e){if(ol(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function A6(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function jv(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function L6(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 vs(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Ju(e,t){return!t||vs(e)}function EC(e){return vs(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function j6(e,t,n,r,o,l,d,f){const m=p=>{const b=B6(p);if(b!==0){if(d()){if(Cb(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(b);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),O6(t,b,n,r,o,l)}};return e.addEventListener("wheel",m,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",m,{capture:!0})}}function O6(e,t,n,r,o,l){const d=()=>{o();try{e.scrollLines(t)}finally{l()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};e.buffer.active.type!=="alternate"&&d()}function B6(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function I6(e,t,n,r,o,l,d,f,m,p,b){let _=null,w=0;const S=new AL,x={passive:!1};function E(K){_=Ov(K),w=0,S.reset()}function L(K){const P=Ov(K);if(P===null){_=null,w=0,S.reset();return}if(_===null){_=P;return}const z=P.clientY-_.clientY;if(_=P,K.cancelable&&K.preventDefault(),z===0)return;const q=p();if(f()&&Cb(t)&&q!==null){const I=S.consume(-z,n(),q);I!==0&&b(P,I),w=0;return}if(S.reset(),f()&&Cb(t)&&P6(t,P,-z)){w=0;return}w-=z/n();const Y=w<0?Math.ceil(w):Math.floor(w);if(Y!==0){if(w-=Y,f()){m(Y);return}if(t.buffer.active.type!=="alternate"){l();try{t.scrollLines(Y)}finally{d()}r(),Y<0&&t.buffer.active.viewportY<=3&&o(Y)}}}function A(K){if(S.reset(),K.touches.length>0){_=Ov(K);return}_=null,w=0}return e.addEventListener("touchstart",E,x),e.addEventListener("touchmove",L,x),e.addEventListener("touchend",A),e.addEventListener("touchcancel",A),()=>{e.removeEventListener("touchstart",E,x),e.removeEventListener("touchmove",L,x),e.removeEventListener("touchend",A),e.removeEventListener("touchcancel",A)}}function Ov(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function Cb(e){return e.modes.mouseTrackingMode!=="none"}function P6(e,t,n){const r=e.element;return r?(r.dispatchEvent(w2(t,n)),!0):!1}function w2(e,t,n=0){const r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:n}}),o}function kb({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l=!0,refreshCwdOnEnter:d=!1,tabId:f,codeServerContext:m,dropZoneActive:p=!1,draggingTerminalId:b=null,mobileFocusLeafKey:_=null,path:w=[],totalPanes:S,onSelect:x,onClose:E,onResize:L,onExit:A,onSnapshot:K,onCloseEditor:P,onAuthClose:z}){const q=S??Tb(e);if(w.length===0&&_){const he=Eb(e),Q=he.some(ee=>ee.key===_)?_:he[0]?.key;if(he.length>1&&Q)return u.jsx("div",{className:"mobile-focused-split",children:he.map(ee=>{const ie=ee.key===Q;if(ee.type==="editor"){const H=n[ee.editorId];return u.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:H?u.jsx(Q1,{api:r,editor:H,canClose:q>1,onClose:()=>P(ee.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ee.key)}const J=t[ee.terminalId];return J?u.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:u.jsx(yC,{terminal:J,serverApi:r,active:ie,visible:l&&ie,canClose:q>1,refreshCwdOnEnter:d&&ie,tabId:f,codeServerContext:m,onSelect:()=>x(ee.terminalId),onClose:()=>E(ee.terminalId),onExit:H=>A(ee.terminalId,H),onSnapshot:K,...z?{onAuthClose:z}:{}})},ee.key):u.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ee.key)})})}if(e.type==="pane"){const he=t[e.terminalId];if(!he)return u.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const Q=u.jsx(yC,{terminal:he,serverApi:r,active:e.terminalId===o,visible:l,canClose:q>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:f,codeServerContext:m,onSelect:()=>x(e.terminalId),onClose:()=>E(e.terminalId),onExit:ie=>A(e.terminalId,ie),onSnapshot:K,...z?{onAuthClose:z}:{}});return p&&b!==e.terminalId?u.jsxs("div",{className:"pane-drop-host",children:[Q,u.jsx(bf,{terminalId:e.terminalId,side:"top"}),u.jsx(bf,{terminalId:e.terminalId,side:"right"}),u.jsx(bf,{terminalId:e.terminalId,side:"bottom"}),u.jsx(bf,{terminalId:e.terminalId,side:"left"})]}):Q}if(e.type==="editor"){const he=n[e.editorId];return he?u.jsx(Q1,{api:r,editor:he,canClose:q>1,onClose:()=>P(e.editorId)}):u.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const Y=Math.max(.1,Math.min(.9,e.ratio)),I=1-Y,F=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:F,children:[u.jsx("div",{className:"split-cell",children:u.jsx(kb,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:m,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,0],totalPanes:q,onSelect:x,onClose:E,onResize:L,onExit:A,onSnapshot:K,onCloseEditor:P,...z?{onAuthClose:z}:{}})}),u.jsx(z6,{direction:e.direction,path:w,onResize:L}),u.jsx("div",{className:"split-cell",children:u.jsx(kb,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:l,refreshCwdOnEnter:d,tabId:f,codeServerContext:m,dropZoneActive:p,draggingTerminalId:b,mobileFocusLeafKey:_,path:[...w,1],totalPanes:q,onSelect:x,onClose:E,onResize:L,onExit:A,onSnapshot:K,onCloseEditor:P,...z?{onAuthClose:z}:{}})})]})}function bf({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=Ap({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return u.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function z6({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const l=o.currentTarget;l.setPointerCapture?.(o.pointerId),l.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=l.parentElement;if(!d)return;const f=d.getBoundingClientRect();function 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:r,role:"separator",children:u.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Tb(e){return e.type==="pane"||e.type==="editor"?1:Tb(e.first)+Tb(e.second)}function Eb(e){return e.type==="pane"?[{key:H6(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:U6(e.editorId),type:"editor",editorId:e.editorId}]:[...Eb(e.first),...Eb(e.second)]}function H6(e){return`terminal:${e}`}function U6(e){return`editor:${e}`}const Gp="workspace-default",$6="NTerminal";function F6(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function Sc(e,t){switch(t.type){case"workspace.hydrated":return yp(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return W6(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return Y6(e,t.workspaceId);case"workspace.selected":return x2(e,t.workspaceId);case"workspace.renamed":return K6(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return q6(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return V6(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return Yy(e,t.terminal);case"terminal.split":return X6(e,t.terminal,t.direction);case"terminal.updated":return aP(e,t.terminal);case"terminal.exited":return oP(e,t.terminalId,t.exitCode);case"terminal.closed":return E2(e,t.terminalId);case"terminal.detached":return lP(e,t.terminalId,t.workspaceId);case"terminal.revealed":return G6(e,t.terminalId);case"editor.split":return Z6(e,t.editorId,t.title,t.direction);case"editor.closed":return cP(e,t.editorId);case"pane.selected":return T2(e,t.terminalId);case"pane.resized":return rP(e,t.path,t.ratio);case"tab.selected":return J6(e,t.tabId);case"tab.renamed":return sP(e,t.tabId,t.title);case"tab.reordered":return Gy(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return eP(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 tP(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return Q6(e);default:return e}}function W6(e,t){if(e.workspaces.some(r=>r.id===t.id))return x2(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Qs(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 K6(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.title===r?d:(o=!0,{...d,title:r}));return o?{...e,workspaces:l}:e}function q6(e,t,n){const r=Qs(n);let o=!1;const l=e.workspaces.map(d=>d.id!==t||d.defaultCwd===r?d:(o=!0,{...d,defaultCwd:r}));return o?{...e,workspaces:l}:e}function V6(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(_=>_.id===t),l=e.workspaces.findIndex(_=>_.id===n);if(o<0||l<0)return e;const d=e.workspaces.slice(),[f]=d.splice(o,1);if(!f)return e;const m=d.findIndex(_=>_.id===n);if(m<0)return e;const p=r==="before"?m:m+1,b=d.slice();return b.splice(p,0,f),iP(e.workspaces,b)?e:{...e,workspaces:b}}function Y6(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const n=e.workspaces.find(f=>f.id===t),r=new Set(n?br(n):[]),o={...e.terminals};for(const f of r)delete o[f];const l=e.workspaces.filter(f=>f.id!==t),d=e.activeWorkspaceId===t?l[0]?.id??null:e.activeWorkspaceId;return{workspaces:l,activeWorkspaceId:d,terminals:o}}function Yy(e,t){const n=N2(e),r=xl(n)??Zp(),o=B2(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(l=>l.id===r.id?{...l,defaultCwd:l.defaultCwd??Qs(t.cwd),detachedTerminalIds:l.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...l.tabs,o],activeTabId:o.id}:O2(l,t.id))}}function G6(e,t){if(M2(e,t))return T2(e,t);const n=A2(e,t),r=e.terminals[t];return!n||!r?e:Yy({...e,activeWorkspaceId:n.id},r)}function X6(e,t,n){const r=xl(e),o=r?Xp(r):void 0;if(!r||!o)return Yy(e,t);const l=o.activeTerminalId,d=zd(o.root,l,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:l},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??Qs(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 Z6(e,t,n,r){const o=xl(e),l=o?Xp(o):void 0;if(!o||!l)return e;const d=l.activeTerminalId,f=zd(l.root,d,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(m=>m.id===o.id?{...m,tabs:m.tabs.map(p=>p.id===l.id?{...p,root:f,activeTerminalId:d}:p)}:m)}}function Q6(e){const t=xl(e),n=t?Xp(t):void 0;return n?E2(e,n.activeTerminalId):e}function J6(e,t){const n=xl(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function Gy(e,t,n){const r=e.workspaces.map(o=>{const l=o.tabs.findIndex(b=>b.id===t);if(l<0)return o;const d=o.tabs.slice(),[f]=d.splice(l,1);if(!f)return o;const m=Math.max(0,Math.min(d.length,n)),p=d.slice();return p.splice(m,0,f),nP(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,l)=>o===e.workspaces[l])?e:{...e,workspaces:r}}function eP(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])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 _=zc(b.root,n);if(!_){const x=m.tabs.filter((E,L)=>L!==p);return{...m,tabs:x}}const w={...b,root:_,activeTerminalId:Rn(_)[0]??b.activeTerminalId},S=m.tabs.slice();return S[p]=w,{...m,tabs:S}});const d=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return l=l.map(m=>{const p=m.tabs.findIndex(E=>Rn(E.root).includes(r));if(p<0)return m;const b=m.tabs[p];if(!b)return m;const _={type:"pane",terminalId:n},w={type:"split",direction:d,ratio:.5,first:f?_:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:_},S=zd(b.root,r,w),x=m.tabs.slice();return x[p]={...b,root:S,activeTerminalId:n},{...m,tabs:x,activeTabId:b.id}}),N2({...e,workspaces:l})}function C2(e,t,n,r){let o=-1,l=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(K=>K.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=Rn(f.root);if(!m.includes(n))return e;if(m.length===1)return Gy(e,t,r);const p=zc(f.root,n);if(!p)return e;const b={...f,root:p,activeTerminalId:Rn(p)[0]??f.activeTerminalId},_=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:_?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},S=d.tabs.slice();S[l]=b;const x=Math.max(0,Math.min(S.length,r));S.splice(x,0,w);const E=e.workspaces.slice();return E[o]={...d,tabs:S,activeTabId:w.id},{...e,workspaces:E}}function k2(e,t,n,r=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 r===Number.MAX_SAFE_INTEGER?e:Gy(e,t,r);const d=Rn(o.tab.root),f=d.map(p=>e.terminals[p]).find(Boolean),m=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Cl({...p,tabs:p.tabs.filter(b=>b.id!==t)});if(p.id===n){const b=p.tabs.slice(),_=Math.max(0,Math.min(b.length,r));return b.splice(_,0,o.tab),{...p,defaultCwd:p.defaultCwd??Qs(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!d.includes(w)),tabs:b,activeTabId:o.tab.id}}return p});return{...e,workspaces:m,activeWorkspaceId:n}}function tP(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const l=e.workspaces.find(S=>S.id===r),d=D2(e.workspaces,t);if(!l||!d||!e.terminals[n]||!Rn(d.tab.root).includes(n))return e;if(d.workspace.id===r)return C2(e,t,n,o);if(Rn(d.tab.root).length===1)return k2(e,t,r,o);const m=zc(d.tab.root,n);if(!m)return e;const p={...d.tab,root:m,activeTerminalId:Rn(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}},w=e.workspaces.map(S=>{if(S.id===d.workspace.id)return Cl({...S,tabs:S.tabs.map(x=>x.id===t?p:x)});if(S.id===r){const x=S.tabs.slice(),E=Math.max(0,Math.min(x.length,o));return x.splice(E,0,_),{...S,defaultCwd:S.defaultCwd??Qs(b.cwd),detachedTerminalIds:S.detachedTerminalIds.filter(L=>L!==n),tabs:x,activeTabId:_.id}}return S});return{...e,workspaces:w,activeWorkspaceId:r}}function nP(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 iP(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 sP(e,t,n){const r=n.trim();if(!r)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===r?p:(o=!0,f=!0,{...p,title:r}));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=>Hc(l.root,t))),r=n?.tabs.find(o=>Hc(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(l=>l.id===r.id?{...l,activeTerminalId:t}:l)}:o)}}function rP(e,t,n){const r=xl(e),o=r?Xp(r):void 0;if(!r||!o)return e;const l=Ab(o.root,t,z2(n));return l===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===r.id?{...d,tabs:d.tabs.map(f=>f.id===o.id?{...f,root:l}:f)}:d)}}function yp(e,t,n,r){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=uP(t,n,l,d);m.length===0&&(m=[Zp()]);const p=typeof r=="string"&&m.some(_=>_.id===r)?r:m[0]?.id??null,b=p??m[0]?.id??Gp;for(const _ of e)if(!d.has(_.id)){if(f)m=dP(m,b,_.id,_);else{const w=B2(_);m=fP(m,b,w,_)}d.add(_.id)}return{workspaces:m.map(_=>Cl(hP(_,o))),activeWorkspaceId:p,terminals:o}}function ul(e){return Rn(e.root)}function Sp(e){return Lb(e.root)}function br(e){return Xy([...e.tabs.flatMap(t=>Rn(t.root)),...e.detachedTerminalIds])}function mo(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const l=Db(o.root);return l?[{...o,root:l}]:[]});return Cl({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function aP(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>Hc(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function oP(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function E2(e,t){const n={...e.terminals};return delete n[t],R2(e,t,n)}function lP(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(l=>l.id===n)?n:null)??M2(e,t)?.id??A2(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Gp,o=e.workspaces.find(l=>l.id===r);return!o||!j2(o,t)?e:R2(e,t,{...e.terminals},{detachToWorkspaceId:r})}function R2(e,t,n,r={}){let o=e.workspaces.map(d=>{const f=[];for(const m of d.tabs){const p=zc(m.root,t);if(!p)continue;const b=Rn(p),_=b.includes(m.activeTerminalId)?m.activeTerminalId:b[0];_&&f.push({...m,root:p,activeTerminalId:_})}return Cl({...d,detachedTerminalIds:d.detachedTerminalIds.filter(m=>m!==t),tabs:f})});r.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===r.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 cP(e,t){const n=e.workspaces.map(o=>{const l=[];for(const d of o.tabs){const f=Rb(d.root,t);if(!f)continue;const m=Rn(f),p=m.includes(d.activeTerminalId)?d.activeTerminalId:m[0];p&&l.push({...d,root:f,activeTerminalId:p})}return Cl({...o,tabs:l})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function uP(e,t,n,r){if(t&&t.length>0){const o=[];for(const l of t)I2(l)&&o.push(RC(l,n,r));if(o.length>0)return o}return[RC({...Zp(),tabs:e??[]},n,r)]}function RC(e,t,n){const r=[];for(const l of e.tabs){if(!P2(l))continue;const d=Nb(l.root,t);if(!d)continue;const f=Rn(d);for(const p of f)n.add(p);const m=f.includes(l.activeTerminalId)?l.activeTerminalId:f[0];m&&r.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 Cl({...e,defaultCwd:Qs(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function N2(e){return xl(e)?e:{...e,workspaces:[Zp()],activeWorkspaceId:Gp}}function xl(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Xp(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function D2(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function M2(e,t){return e.workspaces.find(n=>n.tabs.some(r=>Hc(r.root,t)))}function A2(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function dP(e,t,n,r){return e.map(o=>o.id===t?L2(o,n,r):o)}function L2(e,t,n){return j2(e,t)?{...e,defaultCwd:e.defaultCwd??Qs(n?.cwd),detachedTerminalIds:Xy([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function j2(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Co}function O2(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function hP(e,t){if(e.defaultCwd)return e;const n=br(e).find(o=>!!t[o]),r=n?Qs(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Zp(){return{id:Gp,title:$6,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Cl(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Qs(e.defaultCwd),detachedTerminalIds:Xy(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function fP(e,t,n,r){const o=Rn(n.root);return e.map(l=>l.id===t?{...l,defaultCwd:l.defaultCwd??Qs(r?.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 zd(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:zd(e.first,t,n),second:zd(e.second,t,n)}}function zc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=zc(e.first,t),r=zc(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function Rb(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=Rb(e.first,t),r=Rb(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function Nb(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Nb(e.first,t),r=Nb(e.second,t);return n&&r?{...e,ratio:z2(e.ratio),first:n,second:r}:n??r}function Db(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Db(e.first),n=Db(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"&&Mb(t.root)}function Mb(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")&&Mb(t.first)&&Mb(t.second):!1}function Ab(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const l=Ab(e.first,o,n);return l===e.first?e:{...e,first:l}}if(r===1){const l=Ab(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 Qs(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Xy(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function Hc(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Hc(e.first,t)||Hc(e.second,t)}function Rn(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Rn(e.first),...Rn(e.second)]}function Lb(e){return e.type==="pane"||e.type==="editor"?1:Lb(e.first)+Lb(e.second)}function wp(e,t,n=!1){if(!e)return t;const r=e.agentStatus,o=t.agentStatus,l=Date.parse(e.updatedAt),d=Date.parse(t.updatedAt);return e.status===t.status&&r?.source==="hook"&&o?.source==="hook"&&r.epoch&&r.epoch===o.epoch&&r.revision!==void 0&&o.revision!==void 0&&r.revision!==o.revision?o.revision>r.revision?t:e:Number.isFinite(l)&&(!Number.isFinite(d)||d<l)?e:Number.isFinite(d)&&(!Number.isFinite(l)||d>l)?t:e.status!==t.status?e.status==="exited"?e:t:n?e:t}function pP(e,t){const n=[],r=l=>{l.type==="split"?(r(l.first),r(l.second)):l.type==="pane"?n.push({key:`terminal:${l.terminalId}`,terminalId:l.terminalId}):n.push({key:`editor:${l.editorId}`})};r(e);const o=t&&n.length>1?[n.find(l=>l.key===t)??n[0]]:n;return new Set(o.flatMap(l=>l.terminalId===void 0?[]:[l.terminalId]))}const ns=new Map,Hd=new Map,Ud=new Map,$d=new Map,Fd=new Map,cd=new Set;let da=null,mP=0;const jb=new Set;let H2=0;function bs(e){return e??"__local__"}function gP(e){return{agentId:e,generation:++mP,state:F6(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,hydration:{requestId:0,layoutSequence:0,metadataSequence:0,pending:null,mutations:new Map,overflow:!1},saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function mt(e){const t=bs(e);let n=ns.get(t);return n||(n=gP(e),ns.set(t,n)),n}function lo(e){return ns.get(bs(e))??null}function U2(e,t){const n=bs(e);let r=Hd.get(n);return r||(r=new Set,Hd.set(n,r)),r.add(t),()=>{r.delete(t)}}function vP(e){const t=bs(e),n=Hd.get(t);if(n)for(const r of Array.from(n))r()}function kl(e,t,n=!0){const r=ns.get(bs(e)),o=n&&NC(r)!==NC(t);ns.set(bs(e),t),vP(e),o&&Qy()}function Ob(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 Zy(e,t){const n=e.state.workspaces.find(d=>d.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const d of n.tabs)for(const f of Rn(d.root))r.add(f);let o=0,l=0;for(const d of r)Ob(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=Zy(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function $2(e){return!!(e&&e.state.workspaces.some(t=>{const n=Zy(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function Qy(){H2+=1;for(const e of Array.from(jb))e()}function _P(e){return jb.add(e),()=>{jb.delete(e)}}function DC(){return H2}function bP(e,t){return Zy(mt(e),t)}const Bb=new Set;function yP(e){return Bb.add(e),()=>{Bb.delete(e)}}function Jy(e,t,n=mt(e).state){const r=da;if(!r||r.agentId!==e||r.generation!==ns.get(bs(e))?.generation)return!1;const o=n.workspaces.find(d=>d.id===r.workspaceId),l=o?.tabs.find(d=>d.id===r.tabId);return!!(o?.id===n.activeWorkspaceId&&l?.id===o?.activeTabId&&l?.root===r.root&&n.terminals[t]&&r.terminalIds.has(t))}function yf(e,t=!0){let n=typeof e=="object"&&e!==null?e:null;if(e!==void 0&&!n&&t){const d=ns.get(bs(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(Rn(m.root))})}if(da=t&&n?{...n,terminalIds:new Set(Rn(n.root).filter(d=>n.terminalIds.has(d)))}:null,!da)return;const r=da.agentId,o=ns.get(bs(r));if(!o||o.generation!==da.generation){da=null;return}const l=new Set([...o.unreadCompletions].filter(d=>!Jy(r,d,o.state)));l.size!==o.unreadCompletions.size&&(kl(r,{...o,unreadCompletions:l}),Qp())}function ud(e,t){const n=mt(e),r=bs(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&&wp(b,t.terminal)===b&&t.terminal!==b)return}const o=wP(n.state,t);t.type==="workspace.hydrated"&&(Ud.delete(r),$d.delete(r),Fd.delete(r));const l=Sc(n.state,t);MP(n,t,l);let d=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const b=n.state.terminals[t.terminal.id],_=jP(r),w=OP(r),S=xP(r);if(t.terminal.agentStatus?.source==="hook"){_.delete(t.terminal.id),w.delete(t.terminal.id),S.delete(t.terminal.id);const x=t.terminal.agentStatus.completion;if(x){const E=`${r}:${x.id}`,L=cd.has(E)||b?.agentStatus?.completion?.id===x.id;W2(E),!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,E=t.terminal.agentStatus.sessionId,L=S.get(t.terminal.id),A=!!(b&&(b.currentCommand!==t.terminal.currentCommand||b.agentStatus?.provider!==t.terminal.agentStatus.provider||SP(L,E)));A&&(w.delete(t.terminal.id),_.delete(t.terminal.id),S.delete(t.terminal.id)),E&&S.set(t.terminal.id,E),t.notifyCompletion===!0&&(x==="working"?(w.add(t.terminal.id),_.delete(t.terminal.id)):x==="unknown"&&t.terminal.activity==="busy"&&_.add(t.terminal.id)),!A&&(x==="done"||x==="stopped")&&(w.has(t.terminal.id)||_.has(t.terminal.id))&&(f=LC(l,t.terminal.id,b?.currentCommand??null,x==="stopped"?"stopped":"finished"),w.delete(t.terminal.id),_.delete(t.terminal.id)),x==="idle"&&(w.delete(t.terminal.id),_.delete(t.terminal.id))}else b?.agentStatus&&(w.delete(t.terminal.id),S.delete(t.terminal.id)),_.delete(t.terminal.id);f&&!Jy(e,t.terminal.id,l)&&!d.has(t.terminal.id)&&(d=new Set(d),d.add(t.terminal.id)),t.terminal.status==="exited"&&(_.delete(t.terminal.id),w.delete(t.terminal.id),S.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)&&kl(e,{...n,state:l,unreadCompletions:d},o||p),p&&Qp(),f)for(const b of Array.from(Bb))b({agentId:e,...f})}function SP(e,t){return e!==void 0&&t!==void 0&&e!==t}function wP(e,t){switch(t.type){case"terminal.updated":return Ob(e.terminals[t.terminal.id])!==Ob(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 xP(e){let t=Fd.get(e);return t||(t=new Map,Fd.set(e,t)),t}function CP(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Rn(r.root).includes(t))return{workspace:n,tab:r};return null}const Ib=new Set;function kP(e){return Ib.add(e),()=>{Ib.delete(e)}}function TP(){let e=0;for(const t of ns.values())e+=t.unreadCompletions.size;return e}function Qp(){for(const e of Array.from(Ib))e()}function MC(e,t){const n=mt(e);if(t!==n.state){n.mutable.hydration.layoutSequence++;for(const r of new Set([...Object.keys(n.state.terminals),...Object.keys(t.terminals)]))n.state.terminals[r]!==t.terminals[r]&&wc(n,r,t.terminals[r]?t.terminals[r].status==="exited"?"exit":"upsert":"delete");kl(e,{...n,state:t})}}function EP(e){const t=mt(e),n=t.mutable.hydration,r={generation:t.generation,requestId:++n.requestId,layoutSequence:n.layoutSequence,metadataSequence:n.metadataSequence};return n.pending=r,n.mutations.clear(),n.overflow=!1,r}function Wd(e,t){const n=ns.get(bs(e));return n?.generation===t.generation&&n.mutable.hydration.pending===t}function AC(e,t){if(!Wd(e,t))return;const n=mt(e).mutable.hydration;n.pending=null,n.mutations.clear()}function F2(e,t,n){if(!Wd(e,t))return null;const r=mt(e),o=r.mutable.hydration;if(o.overflow)throw new Error("Workspace changed too much while loading. Retry loading it.");const l=new Map;if(o.layoutSequence!==t.layoutSequence||o.metadataSequence!==t.metadataSequence)for(const d of r.state.workspaces.flatMap(br)){const f=r.state.terminals[d];f&&l.set(d,f)}for(const d of n){const f=o.mutations.get(d.id);if(f==="delete")continue;const m=r.state.terminals[d.id];l.set(d.id,f==="exit"&&m?m:wp(m,d,!0))}for(const[d,f]of o.mutations)f==="delete"?l.delete(d):r.state.terminals[d]&&l.set(d,wp(l.get(d),r.state.terminals[d]));return[...l.values()]}function RP(e,t,n){if(!Wd(e,t)||n.length>0)return!1;const r=mt(e).mutable.hydration;return r.layoutSequence===t.layoutSequence&&r.metadataSequence===t.metadataSequence&&r.mutations.size===0}function NP(e,t,n){const r=F2(e,t,n.terminals);if(!r)return null;const o=mt(e),l=o.mutable.hydration,d=l.metadataSequence!==t.metadataSequence,f=l.layoutSequence!==t.layoutSequence||d,m=f?{...o.state,terminals:Object.fromEntries(r.map(_=>[_.id,_]))}:yp(r,n.savedTabs,n.savedWorkspaces,n.savedActiveWorkspaceId),p=DP(m,n.savedWorkspaces??n.persistedLayout?.workspaces),b=d?o.lastPersistedLayoutJson:f?n.persistedLayout?JSON.stringify(n.persistedLayout):o.lastPersistedLayoutJson:JSON.stringify(mo(p));l.pending=null,l.mutations.clear();for(const _ of r)_.agentStatus?.source==="hook"&&_.agentStatus.completion&&W2(`${bs(e)}:${_.agentStatus.completion.id}`);return kl(e,{...o,state:p,loaded:!0,error:null,layoutRevision:d?o.layoutRevision:n.revision,lastPersistedLayoutJson:b}),{state:p,layoutPreserved:f,metadataPreserved:d}}function DP(e,t=[]){const n=new Set(e.workspaces.flatMap(br)),r=Object.values(e.terminals).filter(_=>!n.has(_.id));if(r.length===0)return e;const o=e.workspaces.find(_=>_.id===e.activeWorkspaceId)??e.workspaces[0];if(!o)throw new Error("Loaded terminals have no workspace. Retry loading the workspace.");const l=new Set(e.workspaces.map(_=>_.id)),d=new Map;for(const _ of t)if(l.has(_.id))for(const w of br(_))d.has(w)||d.set(w,_.id);const f=e.workspaces.slice(),m=new Set(f.flatMap(_=>_.tabs.map(w=>w.id)));let p=!1;for(const _ of r){const w=f.findIndex(x=>x.id===(d.get(_.id)??o.id)),S=f[w];if(S.detachedTerminalIds.length<Co)f[w]={...S,detachedTerminalIds:[...S.detachedTerminalIds,_.id]};else{if(!S.tabs.some(L=>L.id===S.activeTabId))throw new Error(`This workspace already has ${Co} hidden terminal sessions and no selected tab. Re-open or delete hidden sessions before retrying.`);const x=`hydrated-${_.id}`;let E=x;for(let L=1;m.has(E);L++)E=`${x}-${L}`;m.add(E),f[w]={...S,tabs:[...S.tabs,{id:E,title:_.title||_.id,activeTerminalId:_.id,root:{type:"pane",terminalId:_.id}}]},p=!0}}const b={...e,workspaces:f};if(p&&!Lp(mo(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 wc(e,t,n){const r=e.mutable.hydration;if(r.pending){if(!r.mutations.has(t)&&r.mutations.size>=4096){r.overflow=!0;return}r.mutations.set(t,n)}}function MP(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&&wc(e,t.terminal.id,t.terminal.status==="exited"?"exit":"upsert");else if(t.type==="terminal.created"||t.type==="terminal.split")wc(e,t.terminal.id,"upsert");else if(t.type==="terminal.exited"&&n.terminals[t.terminalId])wc(e,t.terminalId,"exit");else if(t.type==="terminal.closed")wc(e,t.terminalId,"delete");else if(t.type==="workspace.closed")for(const r of Object.keys(e.state.terminals))n.terminals[r]||wc(e,r,"delete")}function Bv(e,t){const n=mt(e),r=t(n.editors);r!==n.editors&&kl(e,{...n,editors:r},!1)}function co(e,t,n){const r=mt(e);r.loaded===t&&r.error===n||kl(e,{...r,loaded:t,error:n},!1)}function Sf(e,t,n){const r=mt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||(r.mutable.hydration.metadataSequence++,kl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1))}function AP(e){const t=mt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function LP(e){const t=bs(e),n=ns.get(t);da?.agentId===e&&(da=null),n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=$2(n);ns.delete(t),Hd.delete(t),Ud.delete(t),$d.delete(t),Fd.delete(t),r&&Qp(),o&&Qy()}function Iv(){da=null;let e=!1,t=!1;for(const n of ns.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),$2(n)&&(t=!0)}ns.clear(),Hd.clear(),Ud.clear(),$d.clear(),Fd.clear(),e&&Qp(),t&&Qy()}function jP(e){let t=Ud.get(e);return t||(t=new Set,Ud.set(e,t)),t}function OP(e){let t=$d.get(e);return t||(t=new Set,$d.set(e,t)),t}function LC(e,t,n,r){const o=CP(e,t);return{terminalId:t,tabId:o?.tab.id??null,commandName:n,outcome:r}}function BP(e,t,n){const r=wp(e.terminals[t.id],t,!0);if(r.status!=="running")throw new Error("This terminal is no longer running.");let o=Sc(e,{type:"terminal.updated",terminal:r});if(o.workspaces.some(l=>br(l).includes(t.id)))o=Sc(o,{type:"terminal.revealed",terminalId:t.id});else{const l=n?.workspaces.find(d=>br(d).includes(t.id));l&&(o.workspaces.some(d=>d.id===l.id)?o=Sc(o,{type:"workspace.selected",workspaceId:l.id}):o=Sc(o,{type:"workspace.created",workspaceId:l.id,title:l.title,defaultCwd:l.defaultCwd})),o=Sc(o,{type:"terminal.created",terminal:r})}if(!Lp(mo(o)))throw new Error("This terminal cannot be opened because the workspace layout limit was reached.");return o}function Pb(e,t){let n=!1,r=!1,o=null,l=!1;for(const d of ul(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"?(r=!0,n=!0,!o&&f.currentCommand&&(o=f.currentCommand)):p==="idle"&&(n=!0)}return n?l?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function eS(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function zb(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function IP(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function PP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,onSelectTab:d,onCreateTab:f,onToggleWorkspaces:m,onCloseTerminals:p,onReattachTerminal:b,onDeleteTerminal:_,onSplitVertical:w,onSplitHorizontal:S,onRenameTab:x,onToggleFavorite:E,onOpenFavorites:L,activePaneAvailable:A}){const[K,P]=v.useState(null),[z,q]=v.useState(!1),[Y,I]=v.useState(null),F=v.useRef(null),he=e.findIndex(R=>R.id===t),Q=he>=0?e[he]:e[0]??null,ee=Q?Pb(Q,n):null,ie=Q?Sp(Q):0,J=Q?zb(Q,n):"No tab";v.useEffect(()=>{F.current?.focus(),F.current?.select()},[K?.tabId]),v.useEffect(()=>{if(!z)return;const R=B=>{B.key==="Escape"&&q(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[z]),v.useEffect(()=>{z&&e.length===0&&q(!1)},[z,e.length]);function H(R,B){P({tabId:R,title:B})}function X(){if(!K)return;const R=K.title.trim();R&&x(K.tabId,R),P(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 - ${WL()}`,onClick:w,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 - ${KL()}`,onClick:S,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:J,onClick:()=>q(!0),disabled:e.length===0,children:[ee?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":ee.state,"aria-hidden":"true",title:eS(ee)}):null,u.jsx("span",{children:J}),u.jsxs("small",{children:[he>=0?he+1:0,"/",e.length||0,ie>1?` / ${ie}`:""]})]}),u.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,B)=>{const oe=ul(R),ge=Sp(R),N=zb(R,n),V=R.id===t,re=K?.tabId===R.id,Z=Pb(R,n),Te=r?.has(R.id)??!1;return u.jsxs(Ht.Fragment,{children:[u.jsx(jC,{index:B}),u.jsx(zP,{tab:R,active:V,editing:re,title:N,paneCount:ge,terminalIds:oe,canClose:e.length>1,editValue:re?K.title:null,editInputRef:re?F:null,activity:Z,unread:Te,favorite:o?.has(R.id)??!1,onSelect:()=>d(R.id),onBeginRename:()=>H(R.id,N),onCloseAll:()=>p(oe),onCommitRename:X,onCancelRename:()=>P(null),onRenameChange:ye=>P({tabId:R.id,title:ye}),onToggleFavorite:()=>E?.(R)})]},R.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(R=>u.jsx(UP,{terminal:R,onReattach:()=>b?.(R.id),onDelete:()=>I(R)},R.id))}):null]}),u.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),A?M():null]}),z?u.jsx(HP,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,editingTab:K,editInputRef:F,onClose:()=>q(!1),onSelectTab:R=>{d(R),q(!1)},onCreateTab:()=>{f(),q(!1)},onBeginRename:H,onCloseTerminals:R=>{p(R),q(!1)},onCommitRename:X,onCancelRename:()=>P(null),onRenameChange:(R,B)=>P({tabId:R,title:B}),onToggleFavorite:E,onOpenFavorites:L,onReattachTerminal:R=>{b?.(R),q(!1)},onDeleteTerminal:R=>{I(R),q(!1)}}):null,Y?u.jsx($P,{terminal:Y,onCancel:()=>I(null),onConfirm:()=>{_?.(Y.id),I(null)}}):null]})}function zP({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:l,editValue:d,editInputRef:f,activity:m,unread:p,favorite:b,onSelect:_,onBeginRename:w,onCloseAll:S,onCommitRename:x,onCancelRename:E,onRenameChange:L,onToggleFavorite:A}){const{attributes:K,listeners:P,setNodeRef:z,transform:q,isDragging:Y}=sy({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),I={transform:va.Translate.toString(q),opacity:Y?.4:void 0,zIndex:Y?2:void 0};return u.jsxs("div",{ref:z,className:"terminal-tab","data-active":t,"data-dragging":Y,"data-unread":p?"true":void 0,style:I,...K,...P,children:[m?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":m.state,"aria-hidden":"true",title:eS(m)}):null,n&&f&&d!==null?u.jsxs("form",{className:"terminal-tab-editor",onSubmit:F=>{F.preventDefault(),x()},children:[u.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:d,onBlur:x,onChange:F=>L(F.target.value),onKeyDown:F=>{if(F.key==="Enter"){F.preventDefault(),x();return}F.key==="Escape"&&(F.preventDefault(),E())}}),u.jsx("small",{children:o})]}):u.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:_,onDoubleClick:F=>{F.preventDefault(),w()},children:[u.jsx("span",{children:r}),u.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:u.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":b?`Remove ${r} from favorites`:`Add ${r} to favorites`,title:b?"Remove from favorites":"Add to favorites",onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),A()},children:b?"★":"☆"}),l&&!n?u.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),S()},children:"x"}):null]})}function HP({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:l,editingTab:d,editInputRef:f,onClose:m,onSelectTab:p,onCreateTab:b,onBeginRename:_,onCloseTerminals:w,onCommitRename:S,onCancelRename:x,onRenameChange:E,onToggleFavorite:L,onOpenFavorites:A,onReattachTerminal:K,onDeleteTerminal:P}){const z=v.useRef(null);return v.useEffect(()=>{z.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=ul(q),F=Sp(q),he=zb(q,n),Q=q.id===t,ee=d?.tabId===q.id,ie=Pb(q,n),J=r?.has(q.id)??!1,H=o?.has(q.id)??!1;return u.jsxs("div",{ref:Q?z:null,className:"mobile-tab-sheet-row","data-active":Q,"data-unread":J?"true":void 0,children:[ee&&d?u.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:X=>{X.preventDefault(),S()},children:u.jsx("input",{ref:f,"aria-label":`Rename ${he}`,value:d.title,onBlur:S,onChange:X=>E(q.id,X.target.value),onKeyDown:X=>{if(X.key==="Enter"){X.preventDefault(),S();return}X.key==="Escape"&&(X.preventDefault(),x())}})}):u.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${he}`,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:he}),u.jsx("small",{children:IP(q,n,F,ie)})]}),u.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ie?u.jsx("span",{className:"terminal-tab-status-dot","data-activity":ie.state,"aria-hidden":"true",title:eS(ie)}):null,u.jsx("span",{children:F})]})]}),u.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ee?u.jsx("button",{type:"button","aria-label":`Done renaming ${he}`,onClick:S,children:"Done"}):u.jsx("button",{type:"button","aria-label":`Rename ${he}`,onClick:()=>_(q.id,he),children:"Rename"}),ee?null:u.jsx("button",{type:"button","aria-label":H?`Remove ${he} from favorites`:`Add ${he} to favorites`,title:H?"Remove from favorites":"Add to favorites",onClick:()=>L?.(q),children:H?"★":"☆"}),e.length>1?u.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${he}`,onClick:()=>w(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:()=>K(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:()=>P(q),children:"×"})})]},q.id)})]}):null]})]})})}function jC({index:e}){const{setNodeRef:t,isOver:n}=Ap({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 UP({terminal:e,onReattach:t,onDelete:n}){const r=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 ${r}`,onClick:t,children:r}),u.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:l=>{l.stopPropagation(),n()},children:"×"})]})}function $P({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:"Delete this terminal?"}),u.jsx("span",{children:r}),u.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}const FP="nonce-v1",OC=512,Pv=3e4,zv=1e4;function WP(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 KP=1024*1024,qP=1e3,VP=5e3,YP=1e3;function GP(e,t,n,r={...typeof document>"u"?{}:{document},...typeof window>"u"?{}:{window}},o){const l=r.now??Date.now,d=r.document,f=r.window;let m=!1,p=!1,b="",_=0,w=0,S=!1,x=d?.visibilityState==="hidden",E,L,A,K,P=0,z=0,q=0,Y,I=l(),F=-1/0;const he=[],Q=()=>!S&&d?.visibilityState!=="hidden",ee=_e=>!m&&E===_e,ie=(_e,We)=>!_e.ready&&We>=_e.handshakeUntil||_e.pending!==void 0&&We>=_e.pending.until,J=()=>{clearTimeout(A),A=void 0},H=()=>{clearTimeout(K),K=void 0},X=()=>{for(const _e of he.splice(0))_e()},M=_e=>Math.min(3e4,1e3*2**Math.min(_e,5)),R=()=>{m||p||L!==void 0||(L=setTimeout(()=>{L=void 0,He()},M(P++)))},B=_e=>{p&&(b=_e,w=l()+M(_++));try{o?.(_e)}catch{}},oe=(_e,We=1e3,Oe="activity reconnect",j=!1,me=!0)=>{if(E===_e){if(E=void 0,_e.pending=void 0,J(),H(),_e.socket.onmessage=null,_e.socket.onerror=null,_e.socket.onclose=null,j&&(m=!0,clearTimeout(L),L=void 0,X()),me)try{_e.socket.close(We,Oe)}catch{}j||R()}},ge=()=>{A!==void 0||m||!E||!Q()||(A=setTimeout(()=>{A=void 0,Z()},qP))},N=_e=>{if(!ee(_e)||!_e.ready||!_e.probes||_e.pending||!Q())return;if(_e.socket.readyState!==1||_e.socket.bufferedAmount>512){oe(_e);return}const We=`${_e.generation}-${++q}`;_e.pending={nonce:We,until:l()+zv},_e.nextProbeAt=l()+Pv;const Oe={type:"activity.ping",version:1,nonce:We};try{_e.socket.send(JSON.stringify(Oe))}catch{oe(_e)}},V=(_e=!1)=>{if(m||!Q())return;if(I=l(),F=I,p){B(b);return}const We=E;We&&(We.pending=void 0,We.ready?We.probes?N(We):oe(We):((_e||!Number.isFinite(We.handshakeUntil))&&(We.handshakeUntil=I+zv),We.resumeProbe=!0),ge())},re=()=>{const _e=l();return _e>=I&&_e-I<=VP?!1:(H(),V(!0),!0)},Z=()=>{if(m||!Q()||!E)return;re(),I=l();const _e=E;_e&&(ie(_e,I)?oe(_e):_e.ready&&I>=_e.nextProbeAt&&N(_e),ge())},Te=()=>{if(m||!Q()||K!==void 0||!p&&l()>=F&&l()-F<YP)return;const _e=p?Math.min(3e4,Math.max(0,w-l())):0;K=setTimeout(()=>{K=void 0,V()},_e)},ye=()=>{E&&(E.pending=void 0,E.ready||(E.handshakeUntil=1/0)),J(),H(),F=-1/0},He=()=>{if(m||p)return;const _e=Y;let We;try{const Me=new URL(e);_e&&Me.searchParams.set("cursor",_e),We=t(Me.toString())}catch{R();return}const Oe={socket:We,generation:++z,ready:!1,probes:!1,handshakeUntil:Q()?l()+zv:1/0,nextProbeAt:1/0,pending:void 0,resumeProbe:!1};E=Oe,I=l();let j=_e!==void 0,me=!1;We.onmessage=Me=>{if(ee(Oe)&&(Q()&&re(),!!ee(Oe))){if(Q()&&ie(Oe,l())){oe(Oe);return}try{if(typeof Me.data!="string"||Me.data.length>KP)throw new Error("invalid activity frame");const ze=JSON.parse(Me.data);if(ze?.type==="activity.pong"){const W=WP(Me.data);if(!Oe.ready||!Oe.probes||!W)throw new Error("invalid activity probe");Q()&&Oe.pending?.nonce===W.nonce&&(Oe.pending=void 0,Oe.nextProbeAt=l()+Pv);return}if(ze?.type==="activity.ready"){if(Oe.ready||ze.version!==1||!BC(ze.cursor)||!["snapshot","resume","gap"].includes(ze.mode)||(ze.mode==="resume"?!_e:!me))throw new Error("invalid activity acknowledgement");Y=ze.cursor,Oe.ready=!0,Oe.probes=ze.probe===FP,Oe.nextProbeAt=l()+Pv,j=!0,P=0,Oe.resumeProbe&&N(Oe),ge();return}if(!ZP(ze)||!j&&!ze.initial)throw new Error("invalid activity snapshot");if(ze.initial)me=!0;else if(!BC(ze.cursor))throw new Error("activity cursor required");j=!0,n(ze),(Oe.ready||!me&&_e)&&(Y=ze.cursor)}catch{oe(Oe,1e3,"invalid activity message",!0)}}},We.onerror=()=>{ee(Oe)&&(oe(Oe),Oe.ready||B("activity handshake failed"))},We.onclose=Me=>{if(!ee(Oe))return;const ze=Me.code===1008&&XP(Me.reason);ze&&(p=!0),oe(Oe,Me.code,"",Me.code===1008&&!ze,!1),ze?B(Me.reason):Me.code!==1008&&!Oe.ready&&B("activity handshake failed")},ge()},Ke=(_e,We,Oe)=>{_e?.addEventListener(We,Oe),he.push(()=>_e?.removeEventListener(We,Oe))};Ke(d,"visibilitychange",()=>{const _e=x;x=d?.visibilityState==="hidden",x?ye():_e&&Te()}),Ke(d,"freeze",()=>{S=!0,ye()}),Ke(d,"resume",()=>{S=!1,Te()}),Ke(f,"pagehide",()=>{S=!0,ye()}),Ke(f,"pageshow",_e=>{const We=S;S=!1,(We||_e.persisted)&&Te()}),Ke(f,"offline",()=>{F=-1/0}),Ke(f,"online",Te),He();const Ie=()=>{m=!0,clearTimeout(L),L=void 0,J(),H(),X(),E&&oe(E,1e3,"activity disposed",!0)};return Ie.reauthenticate=()=>{m||!p||(H(),p=!1,b="",_=0,w=0,R())},Ie}function XP(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 ZP(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,Pf;const Hb=new Set;let Kd;function QP(e){return Hb.add(e),Kd!==void 0&&e(Kd),()=>{Hb.delete(e)}}function JP(){Kd=void 0,Pf?.reauthenticate()}function ez(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:",Pf=nz(t.toString(),void 0,void 0,n=>{Kd=n;for(const r of Hb)r(n)})}return()=>{--IC===0&&(Pf?.(),Pf=void 0,Kd=void 0)}}},[e])}function tz(e){for(const t of e.terminals){const n=mt(e.agentId).state.terminals[t.id];e.initial&&n&&Date.parse(t.updatedAt)<Date.parse(n.updatedAt)||ud(e.agentId,{type:"terminal.updated",terminal:t,notifyCompletion:!e.initial})}}function nz(e,t=o=>new WebSocket(o),n=tz,r){return GP(e,t,n,void 0,r)}function K2(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function iz(e,t){return e.reduce((n,r,o)=>{const l=t.get(r);return l&&(n[o]=l),n},Array(e.length))}function wf(e){return e!==null&&e>=0}function sz(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 rz(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const tS=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const l=K2(t,r,n),d=t[o],f=l[o];return!f||!d?null:{x:f.left-d.left,y:f.top-d.top,scaleX:f.width/d.width,scaleY:f.height/d.height}},xf={scaleX:1,scaleY:1},az=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:l,overIndex:d}=e;const f=(t=l[n])!=null?t:r;if(!f)return null;if(o===n){const p=l[d];return p?{x:0,y:n<d?p.top+p.height-(f.top+f.height):p.top-f.top,...xf}:null}const m=oz(l,o,n);return o>n&&o<=d?{x:0,y:-f.height-m,...xf}:o<n&&o>=d?{x:0,y:f.height+m,...xf}:{x:0,y:0,...xf}};function oz(e,t,n){const r=e[t],o=e[t-1],l=e[t+1];return r?n<t?o?r.top-(o.top+o.height):l?l.top-(r.top+r.height):0:l?l.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const q2="Sortable",V2=Ht.createContext({activeIndex:-1,containerId:q2,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:tS,disabled:{draggable:!1,droppable:!1}});function lz(e){let{children:t,id:n,items:r,strategy:o=tS,disabled:l=!1}=e;const{active:d,dragOverlay:f,droppableRects:m,over:p,measureDroppableContainers:b}=Sk(),_=Yd(q2,n),w=f.rect!==null,S=v.useMemo(()=>r.map(Y=>typeof Y=="object"&&"id"in Y?Y.id:Y),[r]),x=d!=null,E=d?S.indexOf(d.id):-1,L=p?S.indexOf(p.id):-1,A=v.useRef(S),K=!sz(S,A.current),P=L!==-1&&E===-1||K,z=rz(l);Xs(()=>{K&&x&&b(S)},[K,S,x,b]),v.useEffect(()=>{A.current=S},[S]);const q=v.useMemo(()=>({activeIndex:E,containerId:_,disabled:z,disableTransforms:P,items:S,overIndex:L,useDragOverlay:w,sortedRects:iz(S,m),strategy:o}),[E,_,z.draggable,z.droppable,P,S,L,m,w,o]);return Ht.createElement(V2.Provider,{value:q},t)}const cz=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return K2(n,r,o).indexOf(t)},uz=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:l,newIndex:d,previousItems:f,previousContainerId:m,transition:p}=e;return!p||!r||f!==l&&o===d?!1:n?!0:d!==o&&t===m},dz={duration:200,easing:"ease"},Y2="transform",hz=va.Transition.toString({property:Y2,duration:0,easing:"linear"}),fz={roleDescription:"sortable"};function pz(e){let{disabled:t,index:n,node:r,rect:o}=e;const[l,d]=v.useState(null),f=v.useRef(n);return Xs(()=>{if(!t&&n!==f.current&&r.current){const m=o.current;if(m){const p=Fc(r.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,r,o]),v.useEffect(()=>{l&&d(null)},[l]),l}function mz(e){let{animateLayoutChanges:t=uz,attributes:n,disabled:r,data:o,getNewIndex:l=cz,id:d,strategy:f,resizeObserverConfig:m,transition:p=dz}=e;const{items:b,containerId:_,activeIndex:w,disabled:S,disableTransforms:x,sortedRects:E,overIndex:L,useDragOverlay:A,strategy:K}=v.useContext(V2),P=gz(r,S),z=b.indexOf(d),q=v.useMemo(()=>({sortable:{containerId:_,index:z,items:b},...o}),[_,o,z,b]),Y=v.useMemo(()=>b.slice(b.indexOf(d)),[b,d]),{rect:I,node:F,isOver:he,setNodeRef:Q}=Ap({id:d,data:q,disabled:P.droppable,resizeObserverConfig:{updateMeasurementsFor:Y,...m}}),{active:ee,activatorEvent:ie,activeNodeRect:J,attributes:H,setNodeRef:X,listeners:M,isDragging:R,over:B,setActivatorNodeRef:oe,transform:ge}=sy({id:d,data:q,attributes:{...fz,...n},disabled:P.draggable}),N=jN(Q,X),V=!!ee,re=V&&!x&&wf(w)&&wf(L),Z=!A&&R,Te=Z&&re?ge:null,He=re?Te??(f??K)({rects:E,activeNodeRect:J,activeIndex:w,overIndex:L,index:z}):null,Ke=wf(w)&&wf(L)?l({id:d,items:b,activeIndex:w,overIndex:L}):z,Ie=ee?.id,_e=v.useRef({activeId:Ie,items:b,newIndex:Ke,containerId:_}),We=b!==_e.current.items,Oe=t({active:ee,containerId:_,isDragging:R,isSorting:V,id:d,index:z,items:b,newIndex:_e.current.newIndex,previousItems:_e.current.items,previousContainerId:_e.current.containerId,transition:p,wasDragging:_e.current.activeId!=null}),j=pz({disabled:!Oe,index:z,node:F,rect:I});return v.useEffect(()=>{V&&_e.current.newIndex!==Ke&&(_e.current.newIndex=Ke),_!==_e.current.containerId&&(_e.current.containerId=_),b!==_e.current.items&&(_e.current.items=b)},[V,Ke,_,b]),v.useEffect(()=>{if(Ie===_e.current.activeId)return;if(Ie!=null&&_e.current.activeId==null){_e.current.activeId=Ie;return}const Me=setTimeout(()=>{_e.current.activeId=Ie},50);return()=>clearTimeout(Me)},[Ie]),{active:ee,activeIndex:w,attributes:H,data:q,rect:I,index:z,newIndex:Ke,items:b,isOver:he,isSorting:V,isDragging:R,listeners:M,node:F,overIndex:L,over:B,setNodeRef:N,setActivatorNodeRef:oe,setDroppableNodeRef:Q,setDraggableNodeRef:X,transform:j??He,transition:me()};function me(){if(j||We&&_e.current.newIndex===z)return hz;if(!(Z&&!Np(ie)||!p)&&(V||Oe))return va.Transition.toString({...p,property:Y2})}}function gz(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}Zt.Down,Zt.Right,Zt.Up,Zt.Left;function vz({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:r=null,getRuntimeStatus:o,onClose:l,onOpen:d,onRemove:f,onReorder:m}){const p=v.useRef(null),[b,_]=v.useState(()=>Date.now()),[w,S]=v.useState("grid"),[x,E]=v.useState(null),L=nk(Yf(ty,{activationConstraint:{distance:6}}),Yf(ny,{activationConstraint:{delay:180,tolerance:8}})),A=v.useMemo(()=>e.map(Ys),[e]),K=v.useMemo(()=>new Map(e.map(I=>[Ys(I),o?.(I)??null])),[e,o,b]);v.useEffect(()=>{const I=window.setInterval(()=>_(Date.now()),3e4);return()=>window.clearInterval(I)},[]),v.useEffect(()=>{const I=F=>{if(F.key==="Escape"){F.preventDefault(),F.stopImmediatePropagation(),l();return}const he=F.target;if((he instanceof HTMLInputElement||he instanceof HTMLTextAreaElement)&&p.current?.contains(he)||F.ctrlKey||F.altKey||F.metaKey)return;const Q=Number.parseInt(F.key,10)-1;Q>=0&&Q<Math.min(9,e.length)&&(F.preventDefault(),F.stopImmediatePropagation(),d(e[Q]))};return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[e,l,d]);const P=I=>{E(null);const F=String(I.active.id),he=I.over?String(I.over.id):null;if(!he||F===he)return;const Q=e.find(ie=>Ys(ie)===F),ee=e.find(ie=>Ys(ie)===he);Q&&ee&&m(Q,ee)},z=I=>E({activeId:String(I.active.id),overId:null}),q=I=>{const F=String(I.active.id),he=I.over?String(I.over.id):null;E(Q=>Q?.activeId===F&&Q.overId===he?Q:{activeId:F,overId:he})},Y=x?e.find(I=>Ys(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":w==="grid",onClick:()=>S("grid"),children:"▦"}),u.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":w==="list",onClick:()=>S("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:z,onDragOver:q,onDragEnd:P,onDragCancel:()=>E(null),children:[u.jsxs("div",{className:"favorite-tabs-list","data-view":w,children:[r?u.jsx("p",{className:"favorite-tabs-error",role:"alert",children:r}):null,e.length===0?u.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):u.jsx(lz,{items:A,strategy:w==="grid"?tS:az,children:e.map((I,F)=>u.jsx(_z,{favorite:I,index:F,busy:n,unavailable:t?.has(Ys(I))??!1,runtimeStatus:K.get(Ys(I))??null,now:b,isDropTarget:x?.overId===Ys(I)&&x.activeId!==Ys(I),onOpen:d,onRemove:f},Ys(I)))})]}),u.jsx(oM,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:Y?u.jsx(bz,{favorite:Y}):null})]})]})})}const _z=v.memo(function({favorite:t,index:n,busy:r,unavailable:o,runtimeStatus:l,now:d,isDropTarget:f,onOpen:m,onRemove:p}){const b=Ys(t),{attributes:_,listeners:w,setActivatorNodeRef:S,setNodeRef:x,transform:E,transition:L,isDragging:A}=mz({id:b,disabled:r,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),K={transform:va.Transform.toString(E),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:K,children:[u.jsx("button",{ref:S,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:P=>P.stopPropagation(),..._,...w,children:"⋮⋮"}),u.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>m(t),disabled:r||o,title:o?"Server is no longer registered":void 0,children:[u.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),u.jsxs("span",{className:"favorite-tab-copy",children:[u.jsx("strong",{children:t.tabName}),u.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),l&&!o?u.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${l.state}`,title:"Last observed terminal status",children:[u.jsx("i",{"aria-hidden":"true"}),yz(l.state),l.lastActivityAt?` · ${Sz(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(P=>u.jsx("img",{src:`/brand/${P}.webp`,alt:"","aria-hidden":"true"},P)),u.jsx("em",{children:t.paneCount})]})]}),u.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:r,onClick:()=>p(t),children:"×"})]})}),bz=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 Ys(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function yz(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function Sz(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"recently";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return"now";const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const l=Math.floor(o/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function wz({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,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-${Ez(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?zf(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(xz,{upload:m,compact:e.length>1,onDismiss:()=>t(m.id),onRetry:()=>r(m.id),onCancel:()=>o(m.id)},m.id))})]})}function xz({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const l="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return u.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":zf(e),children:[u.jsxs("div",{className:"upload-queue-item-header",children:[u.jsx("strong",{children:zf(e)}),u.jsxs("div",{className:"upload-queue-actions",children:[f?u.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?u.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,u.jsx("button",{type:"button","aria-label":`Dismiss ${zf(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?u.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?u.jsx(Cz,{toast:e}):null,l&&"message"in e&&e.message?u.jsx("p",{className:"upload-toast-muted",children:e.message}):null,l?u.jsx(kz,{response:l,compact:t}):null,e.status==="failed"&&!l&&e.message?u.jsx("p",{children:e.message}):null]})}function Cz({toast:e}){const t=e.percent===null?Rz(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 kz({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),r=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,l=[...n,...r].slice(0,o);return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),l.length>0?u.jsx("ul",{className:"upload-result-list",children:l.map((d,f)=>u.jsx(Tz,{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 Tz({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 zf(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 Ez(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 Rz(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function Nz({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",l=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function d(m){m.stopPropagation(),n()}function f(m){m.target===m.currentTarget&&(m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),t(r)))}return u.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:f,children:[u.jsxs("header",{className:"completion-toast-header",children:[u.jsxs("div",{className:"completion-toast-copy",children:[u.jsx("strong",{children:r.tabTitle}),u.jsx("span",{children:l})]}),u.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:m=>m.stopPropagation(),children:"x"})]}),u.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const Dz=hd(0,0,1,1),ca=1e-6;function Mz(e){return G2(e).map(t=>t.terminalId)}function G2(e){return dd(e,Dz).sort(Oz).map((t,n)=>({...t,index:n+1}))}function Az(e,t,n){const r=G2(e),o=r.find(d=>d.terminalId===t);return o?r.filter(d=>d.terminalId!==t).map(d=>jz(o,d,n)).filter(d=>d!==null).sort(Bz)[0]?.entry.terminalId??null:null}function Lz(e,t){return!Number.isInteger(t)||t<1?null:Mz(e)[t-1]??null}function dd(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=Iz(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...dd(e.first,hd(t.left,t.top,o,t.bottom)),...dd(e.second,hd(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...dd(e.first,hd(t.left,t.top,t.right,r)),...dd(e.second,hd(t.left,r,t.right,t.bottom))]}function jz(e,t,n){const r=e.bounds,o=t.bounds,l=PC(r.left,r.right,o.left,o.right),d=PC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-ca||d<=ca?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"right":return o.centerX<=r.centerX+ca||d<=ca?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"up":return o.centerY>=r.centerY-ca||l<=ca?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:l};case"down":return o.centerY<=r.centerY+ca||l<=ca?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:l};default:return null}}function Oz(e,t){return Ec(e.bounds.top,t.bounds.top)||Ec(e.bounds.left,t.bounds.left)}function Bz(e,t){return Ec(e.primaryDistance,t.primaryDistance)||Ec(e.perpendicularDistance,t.perpendicularDistance)||Ec(t.overlap,e.overlap)||Ec(e.entry.index,t.entry.index)}function Ec(e,t){const n=e-t;return Math.abs(n)<=ca?0:n}function PC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function hd(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function Iz(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const zC="nterminal.terminalWorkspaces.v2",X2="nterminal.sidebarCollapsed.v1",Pz=75,HC=xk.map(e=>e.url),zz=xk[0].url,Hz=6;function Uz({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:l=!1,onLogout:d=async()=>{},onSessionInvalid:f}){ez();const m=v.useMemo(()=>e??kp(),[e]),p=v.useMemo(()=>t??pr(null),[t]),b=v.useMemo(()=>l8(n),[n]),_=v.useMemo(()=>C=>U2(n,C),[n]),w=v.useMemo(()=>()=>mt(n),[n]),S=v.useSyncExternalStore(_,w,w),x=S.state,E=S.editors,L=!S.loaded,A=S.error,[K,P]=v.useState(!1),[z,q]=v.useState(()=>m8()),[Y,I]=v.useState("servers"),[F,he]=v.useState(!1),[Q,ee]=v.useState(!1),[ie,J]=v.useState([]),[H,X]=v.useState(!1),[M,R]=v.useState(null),[B,oe]=v.useState(null),[ge,N]=v.useState(null),V=v.useMemo(()=>pr(ge?.agentId??null),[ge?.agentId]),re=v.useMemo(()=>pr(B?.agentId??null),[B?.agentId]),Z=v.useSyncExternalStore(tj,V1,V1);v.useSyncExternalStore(_d,q1,q1);const[Te,ye]=v.useState(0),[He,Ke]=v.useState(null),[Ie,_e]=v.useState(()=>[null]),[We,Oe]=v.useState(()=>({[Jt]:"Local"})),j=v.useRef(new Set),[me,Me]=v.useState(0),[ze,W]=v.useState(()=>[n]),[pe,Ce]=v.useState(()=>new Set),[Ne,Le]=v.useState({}),[ve,Pe]=v.useState(null),$e=v.useRef(0),Be=v.useRef(0),[ut,ht]=v.useState(null),[vt,Rt]=v.useState(null),cn=v.useRef(null),at=v.useRef(0),Wn=v.useRef(null),kn=v.useRef(null),_t=v.useRef(null),jt=v.useRef(null),Nt=v.useRef([]),pn=v.useRef(0),ui=v.useRef(!1),fn=v.useRef(0),mn=v.useRef(0),ae=v.useRef([]),Fe=v.useRef(null),Qe=v.useRef(null),St=v.useRef(null),Ut=v.useRef(!0),[$t,Wt]=v.useState(0),un=v.useRef(()=>{});v.useEffect(()=>(Ut.current=!0,()=>{Ut.current=!1}),[]);const[Bn,Vt]=v.useState(null),Kn=nk(Yf(ty,{activationConstraint:{distance:8}}),Yf(ny,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>nj(m),[m]);function Nn(C){const T=C.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){Vt({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&Vt({tabId:T.sourceTabId,terminalId:T.terminalId})}}function en(C){Vt(null);const T=C.active.data.current,O=C.over?.data.current;if(!(!T||!O||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(O.kind==="tab-position"&&typeof O.index=="number"){ft({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:O.index});return}if(O.kind==="workspace"&&typeof O.workspaceId=="string"){ft({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:O.workspaceId});return}O.kind==="pane-zone"&&typeof O.terminalId=="string"&&(O.side==="top"||O.side==="right"||O.side==="bottom"||O.side==="left")&&ft({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:O.terminalId,side:O.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(O.kind==="tab-position"&&typeof O.index=="number"){ft({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:O.index});return}if(O.kind==="workspace"&&typeof O.workspaceId=="string"){ft({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:O.workspaceId});return}O.kind==="pane-zone"&&typeof O.terminalId=="string"&&(O.side==="top"||O.side==="right"||O.side==="bottom"||O.side==="left")&&ft({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:O.terminalId,side:O.side})}}}function qn(){Vt(null)}const lt=x.workspaces.find(C=>C.id===x.activeWorkspaceId)??x.workspaces[0],kt=lt?.tabs.find(C=>C.id===lt.activeTabId)??lt?.tabs[0],Dn=kt?.activeTerminalId??null,ce=Dn?x.terminals[Dn]:void 0,ke=s8("(max-width: 760px)"),Ve=v.useMemo(()=>kt?xp(kt.root):[],[kt]),Xe=lt&&kt?fd(n,lt.id,kt.id):null,tt=kt?Z2(Ve,kt.activeTerminalId,Xe?Ne[Xe]:void 0):null,sn=ke&&Ve.length>1;v.useLayoutEffect(()=>{Cr.current=n;const C=()=>{if(yf(void 0),document.visibilityState!=="visible"||!S.loaded||Ir()||!lt||!kt)return;const T=mt(n);T.generation!==S.generation||T.state!==x||yf({generation:S.generation,agentId:n,workspaceId:lt.id,tabId:kt.id,root:kt.root,terminalIds:pP(kt.root,sn?tt:null)})};return C(),document.addEventListener("visibilitychange",C),()=>{document.removeEventListener("visibilitychange",C),yf(void 0)}},[n,x,S.generation,S.loaded,S.error,lt?.id,kt?.id,kt?.root,kt?.activeTerminalId,ke,tt,$t]);const Vn=v.useMemo(()=>(lt?.detachedTerminalIds??[]).flatMap(C=>{const T=x.terminals[C];return T?[T]:[]}),[lt?.detachedTerminalIds,x.terminals]),xi=v.useMemo(()=>{const C=new Set;for(const T of lt?.tabs??[])ul(T).some(O=>S.unreadCompletions.has(O))&&C.add(T.id);return C},[lt?.tabs,S.unreadCompletions]);v.useSyncExternalStore(_P,DC,DC);const[Yt,qi]=v.useState([]),Yn=v.useRef([]),ti=v.useRef(null),[is,In]=v.useState(null),[Ft,wr]=v.useState(null),[ys,Ai]=v.useState([]),[zi,Js]=v.useState(()=>gl()),xr=v.useRef(0),Cr=v.useRef(n),Vi=v.useRef(HC),kr=v.useRef(zi),Ss=v.useRef(()=>{});Ss.current=Ma,un.current=Br;const Ci=v.useCallback(async()=>{try{const C=await m.listNotificationAssets();Ai(C.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Ai([])}},[m]),di=v.useCallback(C=>{for(const T of C)j.current.add(ll(T.agentId));Oe(T=>{const O={...T};for(const te of C)O[ll(te.agentId)]=te.label;return Uv(T,O)?T:O})},[]);v.useEffect(()=>{const C=mn.current+1;mn.current=C;const T=fn.current;m.getFavorites().then(O=>{C!==mn.current||T!==fn.current||(ji(O.favorites,O.revision),ws(O.favorites,n,x))}).catch(()=>{})},[m]),v.useEffect(()=>{ws(Nt.current,n,x)},[n,We]),v.useEffect(()=>{W(C=>C.some(T=>oi(T,n))?C:[...C,n])},[n]);const Tr=v.useCallback(C=>{const T=mt(C),O=pr(C);for(const te of Object.keys(T.state.terminals))ld(O.createWebSocketUrl(te)),mf(te),od(te);LP(C),W(te=>te.filter(se=>!oi(se,C))),Ce(te=>{const se=`${Uf(C)}:`;let le=!1;const we=new Set;for(const Ae of te){if(Ae.startsWith(se)){le=!0;continue}we.add(Ae)}return le?we:te}),Le(te=>{const se=`${Uf(C)}:`;let le=!1;const we={};for(const[Ae,qe]of Object.entries(te)){if(Ae.startsWith(se)){le=!0;continue}we[Ae]=qe}return le?we:te})},[]);v.useEffect(()=>{let C=!1;return m.getMainInfo().then(T=>{if(C)return;const O=T.name?.trim()||"Local";j.current.add(Jt),Oe(te=>{const se={...te,[Jt]:O};return Uv(te,se)?te:se})}).catch(()=>{}),m.listAgents().then(T=>{if(!C){const O=T.agents.map(le=>le.id),te=IA(T.serverOrder,T.agents);for(const le of T.agents)j.current.add(ll(le.id));Oe(le=>{const we={[Jt]:le[Jt]??"Local"};for(const Ae of T.agents)we[Ae.id]=Ae.name;return Uv(le,we)?le:we}),n!==null&&!O.includes(n)&&(Tr(n),r?.(null));const se=jt.current;se&&se.serverId!==Jt&&!O.includes(se.serverId)&&(jt.current=null,R(`${se.serverName} is no longer registered.`),ee(!0)),_e(te)}}).catch(()=>{}),()=>{C=!0}},[n,m,Tr,r,me]);const wa=v.useCallback(C=>{Tr(C),Me(T=>T+1),oi(C,Cr.current)&&r?.(null)},[Tr,r]);v.useEffect(()=>{_e(C=>C.some(T=>oi(T,n))?C:[...C,n])},[n]),v.useEffect(()=>{Ke(null)},[n]),v.useEffect(()=>{const C=Wn.current;if(!C)return;if(!oi(C.agentId,n)){Wn.current=null;return}if(!S.loaded||x.workspaces.length===0)return;Wn.current=null;const T=C.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];T&&T.id!==x.activeWorkspaceId&&ft({type:"workspace.selected",workspaceId:T.id})},[n,S.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const C=kn.current;if(C){if(!oi(C.agentId,n)){kn.current=null;return}S.loaded&&(kn.current=null,x.workspaces.some(T=>T.id===C.workspaceId)&&ft({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,S.loaded,x.workspaces]),v.useEffect(()=>{const C=_t.current;if(C){if(!oi(C.agentId,n)){_t.current=null;return}S.loaded&&(_t.current=null,S.error||Ao())}},[n,S.error,S.loaded]),v.useEffect(()=>{const C=jt.current;if(!(!C||!oi(C.serverId===Jt?null:C.serverId,n)||!S.loaded)){if(jt.current=null,S.error){R(`Could not reach ${C.serverName}.`),ee(!0);return}Dr(C)}},[n,S.loaded]),v.useEffect(()=>{const C=()=>{const te=a8();te&&un.current(te)},T=te=>{const se=o8(te.data);se&&un.current(se)},O=te=>{const se=jp(te.detail);se&&un.current(se)};return C(),window.addEventListener("hashchange",C),window.addEventListener(Gv,O),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(Gv,O),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{Ci()},[Ci]),v.useEffect(()=>Lk(()=>Js(gl())),[]),v.useEffect(()=>{const C=T=>{Ss.current(T)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{Vi.current=ys.length>0?ys:HC},[ys]),v.useEffect(()=>{kr.current=zi},[zi]),v.useEffect(()=>{if(!S.loaded||!lt||!kt)return;const C=fd(n,lt.id,kt.id);Ce(T=>{if(T.has(C))return T;const O=new Set(T);return O.add(C),O})},[n,S.loaded,lt?.id,kt?.id]),v.useEffect(()=>()=>{Pr()},[]),v.useEffect(()=>{const C=sA(m),T=oA(m);return()=>{C(),T()}},[m]),v.useEffect(()=>yP(C=>{const T=mt(C.agentId).state,O=T.workspaces.flatMap(we=>we.tabs).find(we=>we.id===C.tabId),te=T.terminals[C.terminalId],se=O?.title?.trim()||te?.title||C.commandName||"terminal",le=Jy(C.agentId,C.terminalId);if(le||QM({agentId:C.agentId,tabTitle:se,commandName:C.commandName,terminalId:C.terminalId,outcome:C.outcome}),!le&&document.visibilityState==="visible"&&kr.current.enabled){const we=xr.current+1;xr.current=we;const Ae=Vi.current;In({id:we,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:se,commandName:C.commandName,outcome:C.outcome,assetSrc:Ae[Math.floor(Math.random()*Ae.length)]??zz})}}),[]),v.useEffect(()=>{if(!is||zi.persistUntilDismissed)return;const C=window.setTimeout(()=>{In(T=>T?.id===is.id?null:T)},zi.durationSeconds*1e3);return()=>window.clearTimeout(C)},[is,zi]),v.useEffect(()=>{g8(z),z&&Rr()},[z]),v.useEffect(()=>{let C=!1,T;async function O(){if(!mt(n).loaded){T=EP(n),co(n,!1,null);try{let se=null,le=null;try{se=c8(b)}catch(qe){if(!(qe instanceof Cp))throw qe;le=qe}const[we,Ae]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]);if(!C&&Wd(n,T)){const qe=Ae.layout?$b(Ae.layout):null;if(!qe&&le)throw le;const Ye=qe??se??{};let pt=we.terminals;const gn=F2(n,T,pt);if(!gn)return;if(RP(n,T,gn)){const ls=await p.createTerminal({cols:80,rows:24});pt=[...pt,ls.terminal]}if(C)return;const wt=NP(n,T,{terminals:pt,...Ye,revision:Ae.revision,persistedLayout:Ae.layout});if(!wt)return;const dn=mo(wt.state),Ll=mt(n);(wt.layoutPreserved&&JSON.stringify(dn)!==Ll.lastPersistedLayoutJson||!wt.metadataPreserved&&!qe&&se)&&ja(dn,{},T.generation)}}catch(se){!C&&T&&Wd(n,T)&&!os(se)&&co(n,!0,oa(se))}finally{T&&AC(n,T)}}}return O(),()=>{C=!0,T&&AC(n,T)}},[n,p,Te]);function Er(){co(n,!1,null),ye(C=>C+1)}function Rr(){$e.current+=1,Be.current+=1,Pe(null)}function xa(C){$e.current+=1,Be.current+=1,Pe(T=>T&&{...T,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Ao(){$e.current+=1,Be.current+=1;const C=x.workspaces.length+1,T=Tl();Pe({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&ki(T)}function Li(C){if(oi(C,n)){Ao();return}_t.current={agentId:C},r?.(C)}function Nr(C){if(z&&!K)return;const T=x.workspaces.find(te=>te.id===C);if(!T)return;$e.current+=1,Be.current+=1;const O=T.defaultCwd??ce?.cwd??"";Pe({mode:"edit",workspaceId:C,title:T.title,cwd:O,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),O&&ki(O)}function Tl(){return lt?.defaultCwd??ce?.cwd??""}async function ki(C){const T=$e.current+1;$e.current=T;const O=C.trim();if(Pe(te=>te&&{...te,cwd:C,browseStatus:O?"loading":"idle",browseRoot:null,browseEntries:[],error:O?null:"Choose a default working directory."}),!!O)try{const te=await p.createFileRoot({path:O}),se=await p.listFiles({rootToken:te.rootToken,path:""});if($e.current!==T)return;Pe(le=>le&&{...le,cwd:te.rootPath,browseRoot:{rootToken:te.rootToken,rootPath:te.rootPath},browseEntries:se.entries.filter(we=>we.kind==="directory"),browseStatus:"idle",error:null})}catch(te){if($e.current!==T)return;Pe(se=>se&&{...se,browseStatus:"idle",error:oa(te)})}}async function er(){const C=ve;if(!C)return;const T=C.title.trim(),O=C.cwd.trim();if(!T||!O){Pe({...C,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const te=Be.current+1;Be.current=te,Pe({...C,submitStatus:"submitting",error:null});try{const se=await p.createFileRoot({path:O});if(Be.current!==te)return;if(C.mode==="create"){const le=x.workspaces.length+1;ft({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${le}`,title:T,defaultCwd:se.rootPath})}else C.workspaceId&&(ft({type:"workspace.renamed",workspaceId:C.workspaceId,title:T}),ft({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:se.rootPath}));Pe(null)}catch(se){if(Be.current!==te)return;Pe(le=>le&&{...le,submitStatus:"idle",error:oa(se)})}}function Ca(C){Be.current+=1,Pe(C)}function Lo(C,T,O){if(C===T)return;const te=x.workspaces.some(le=>le.id===C),se=x.workspaces.some(le=>le.id===T);!te||!se||ft({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:T,placement:O})}function tr(C,T){const O=x.workspaces.findIndex(se=>se.id===C),te=x.workspaces[O+T];O<0||!te||Lo(C,te.id,T<0?"before":"after")}function Pn(C,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),cn.current={sourceId:C,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function ka(C){const T=cn.current;if(!T||T.pointerId!==C.pointerId)return;const O=Math.hypot(C.clientX-T.startX,C.clientY-T.startY);if(!T.active){if(O<Hz)return;T.active=!0,ht(T.sourceId)}const se=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),le=se?.dataset.workspaceId??null;if(!se||!le||le===T.sourceId||!x.workspaces.some(qe=>qe.id===le)){T.targetId=null,Rt(null);return}const we=se.getBoundingClientRect(),Ae=C.clientY<we.top+we.height/2?"before":"after";T.targetId=le,T.placement=Ae,Rt({workspaceId:le,placement:Ae})}function jo(C){const T=cn.current;!T||T.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),cn.current=null,ht(null),Rt(null),T.active&&T.targetId&&Lo(T.sourceId,T.targetId,T.placement))}function Ta(C){const T=cn.current;T&&T.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),cn.current=null,ht(null),Rt(null)}async function Ea(){await Gt(async()=>{const C=lt?.defaultCwd?{cols:80,rows:24,cwd:lt.defaultCwd}:{cols:80,rows:24},T=await p.createTerminal(C);ft({type:"terminal.created",terminal:T.terminal})})}function Ti(C,T=lt,O=x,te=n){const se=O.terminals[C.activeTerminalId],le=Array.from(new Set(ul(C).flatMap(we=>{const Ae=O.terminals[we]?.agentStatus?.provider;return Ae==="codex"||Ae==="claude"?[Ae]:[]})));return{serverId:te??Jt,workspaceId:T.id,tabId:C.id,serverName:We[ll(te)]??(te===null?"Local":"Server"),workspaceName:T.title,tabName:C.title||se?.title||"Terminal",cwd:se?.cwd||T.defaultCwd,paneCount:Sp(C),providers:le}}function Ps(C){const T=C.serverId===Jt?null:C.serverId,O=lo(T);if(!O?.loaded||O.error)return null;const te=O.state,le=te.workspaces.find(Ye=>Ye.tabs.some(pt=>pt.id===C.tabId))?.tabs.find(Ye=>Ye.id===C.tabId);if(!le)return null;const we=ul(le).flatMap(Ye=>{const pt=te.terminals[Ye];return pt?[pt]:[]});if(we.length===0)return null;const Ae=we.reduce((Ye,pt)=>{const gn=pt.agentCache?.lastCallAt;return gn&&(!Ye||Date.parse(gn)>Date.parse(Ye))?gn:Ye},null),qe=we.some(Ye=>O.unreadCompletions.has(Ye.id));return we.some(Ye=>Ye.status==="running"&&(Ye.agentStatus?.state==="working"||Ye.agentStatus?.state==="finishing"||!Ye.agentStatus&&Ye.activity==="busy"))?{state:"working",lastActivityAt:Ae,unread:qe}:we.some(Ye=>Ye.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Ae,unread:qe}:we.some(Ye=>Ye.agentStatus?.state==="done")?{state:"done",lastActivityAt:Ae,unread:qe}:we.every(Ye=>Ye.status==="exited")?{state:"exited",lastActivityAt:Ae,unread:qe}:{state:"idle",lastActivityAt:Ae,unread:qe}}function ji(C,T){Nt.current=C,pn.current=T,J(C)}function Oi(C){fn.current+=1,ae.current.push(C),!ui.current&&(ui.current=!0,X(!0),R(null),(async()=>{try{for(;ae.current.length>0;){const T=ae.current.shift();let O=0;for(;O<2;){const te=T(Nt.current);if($C(te,Nt.current))break;ji(te,pn.current);try{const se=await m.saveFavorites({favorites:te,baseRevision:pn.current});ji(se.favorites,se.revision);break}catch(se){const le=await m.getFavorites().catch(()=>null);if(le&&ji(le.favorites,le.revision),se instanceof Fn&&se.status===409&&le){O+=1;continue}ae.current=[],R("Could not save favorites. Please try again.");return}}if(O>=2){ae.current=[],R("Favorites changed on another device. Please try again.");return}}}finally{ui.current=!1,X(!1)}})())}function ws(C,T,O){const te=T??Jt,se=le=>le.map(we=>{if(we.serverId!==te)return we;const Ae=O.workspaces.find(pt=>pt.tabs.some(gn=>gn.id===we.tabId)),qe=Ae?.tabs.find(pt=>pt.id===we.tabId);if(!Ae||!qe)return we;const Ye=Ti(qe,Ae,O,T);return j.current.has(ll(T))?Ye:{...Ye,serverName:we.serverName}});$C(C,se(C))||Oi(se)}function nr(C){const T=n??Jt,O=Nt.current.find(se=>se.serverId===T&&se.tabId===C.id);if(O){const se=As(O);Oi(le=>le.filter(we=>As(we)!==se));return}if(!lt||Nt.current.length>=100)return;const te=Ti(C);Oi(se=>se.length>=100?se:[...se,te])}function ss(C){const T=C.serverId===Jt?null:C.serverId;if(T!==null&&!Ie.some(O=>oi(O,T))){R(`${C.serverName} is no longer registered.`);return}if(R(null),ee(!1),!oi(T,n)){jt.current=C,r?.(T);return}Dr(C)}async function Dr(C){const T=mt(n).state,O=T.workspaces.find(se=>se.tabs.some(le=>le.id===C.tabId));if(O){ft({type:"workspace.selected",workspaceId:O.id}),ft({type:"tab.selected",tabId:C.tabId});return}let te=T.workspaces.find(se=>se.id===C.workspaceId);if(!te){const se=`workspace-favorite-${Date.now().toString(36)}`;ft({type:"workspace.created",workspaceId:se,title:C.workspaceName,defaultCwd:C.cwd}),te=mt(n).state.workspaces.find(le=>le.id===se)}te&&ft({type:"workspace.selected",workspaceId:te.id}),await Gt(async()=>{const se=await p.createTerminal(C.cwd?{cols:80,rows:24,cwd:C.cwd}:{cols:80,rows:24});ft({type:"terminal.created",terminal:se.terminal});const we=mt(n).state.workspaces.find(wt=>wt.tabs.some(dn=>dn.activeTerminalId===se.terminal.id)),Ae=we?.tabs.find(wt=>wt.activeTerminalId===se.terminal.id);if(!Ae||!we)return;Ae.title!==C.tabName&&ft({type:"tab.renamed",tabId:Ae.id,title:C.tabName});const qe=mt(n).state,Ye=qe.workspaces.find(wt=>wt.id===we.id)??we,pt=Ye.tabs.find(wt=>wt.id===Ae.id)??Ae,gn=Ti(pt,Ye,qe);Oi(wt=>wt.map(dn=>dn.serverId===C.serverId&&dn.workspaceId===C.workspaceId&&dn.tabId===C.tabId?gn:dn))})}async function xs(C){await Gt(async()=>{const T=Dn?{parentTerminalId:Dn,cols:80,rows:24}:lt?.defaultCwd?{cols:80,rows:24,cwd:lt.defaultCwd}:{cols:80,rows:24},O=await p.createTerminal(T);ft({type:"terminal.split",terminal:O.terminal,direction:C})})}async function Ra(C){let T=Dn,O=Xe;const te=lt?.defaultCwd?.trim();if(!T&&!te)throw new Error("No active pane is available.");const se=await p.readFile(C);if(!T&&te){const Ae=await p.createTerminal({cols:80,rows:24,cwd:te});T=Ae.terminal.id,ft({type:"terminal.created",terminal:Ae.terminal})}if(T){ft({type:"pane.selected",terminalId:T});const Ae=mt(n).state,qe=Ae.workspaces.find(pt=>pt.id===Ae.activeWorkspaceId)??Ae.workspaces[0],Ye=qe?.tabs.find(pt=>pt.id===qe.activeTabId)??qe?.tabs[0];O=qe&&Ye?fd(n,qe.id,Ye.id):null}const le=`editor-${Date.now().toString(36)}-${AP(n)}`,we=p8(se.path);Bv(n,Ae=>({...Ae,[le]:{id:le,title:we,rootToken:C.rootToken,path:se.path,read:se}})),O&&Le(Ae=>({...Ae,[O]:Q2(le)})),ft({type:"editor.split",editorId:le,title:we,direction:"vertical"})}function rs(C){Bv(n,T=>{const O={...T};return delete O[C],O}),ft({type:"editor.closed",editorId:C})}function Mn(C){zs([C])}function zs(C){const T=[...new Set(C)].filter(te=>x.terminals[te]);if(T.length===0)return;const O=T.length===1?x.terminals[T[0]]?.title||x.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;Ke(null),wr({terminalIds:T,label:O,workspaceId:lt?.id??x.activeWorkspaceId??null})}function Mr(C,T){const O=Bo(C,T);if(!O)return!1;const te=C.filter(se=>!O.detachedTerminalIds.includes(se));if(O.detachedTerminalIds.length+te.length>Co)return Ke(d8(O.detachedTerminalIds.length)),!1;Ke(null);for(const se of C)ft(O.id?{type:"terminal.detached",terminalId:se,workspaceId:O.id}:{type:"terminal.detached",terminalId:se});return!0}async function Yi(C){await Gt(async()=>{for(const T of C)await Us(T),ld(p.createWebSocketUrl(T)),mf(T),od(T),ft({type:"terminal.closed",terminalId:T})})}async function Na(C){const T=x.workspaces.find(O=>O.id===C);!T||x.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Gt(async()=>{const O=br(T),te=[];let se=null;for(const we of O)try{await Us(we)}catch(Ae){te.push(oa(Ae)),Ae instanceof Fn&&Ae.status===401&&!p.isAgent&&(se=Ae)}finally{ld(p.createWebSocketUrl(we)),mf(we),od(we)}const le=T.tabs.flatMap(we=>Ub(we.root));if(le.length>0){const we=new Set(le);Bv(n,Ae=>{const qe={...Ae};for(const Ye of we)delete qe[Ye];return qe})}if(ft({type:"workspace.closed",workspaceId:C}),se)throw se;if(te.length>0)throw new Error(`Workspace was removed, but ${te.length} terminal session${te.length===1?"":"s"} may still be running. ${te[0]}`)})}async function Hs(C){await Gt(async()=>{await Us(C),ld(p.createWebSocketUrl(C)),mf(C),od(C),ft({type:"terminal.closed",terminalId:C})})}async function El(C,T){const O=T.trim();if(!O)return;let te=null;for(const se of x.workspaces){const le=se.tabs.find(we=>we.id===C);if(le){te=le.activeTerminalId;break}}if(ft({type:"tab.renamed",tabId:C,title:O}),!!te)try{const se=await p.renameTerminal(te,O);ni({type:"terminal.updated",terminal:se.terminal})}catch(se){co(n,!0,oa(se))}}function as(C){const T=x.terminals[C];T&&ft({type:"terminal.created",terminal:T})}async function Us(C){try{await p.closeTerminal(C)}catch(T){if(T instanceof Fn&&T.status===404)return;throw T}}async function Oo(){await Gt(async()=>{await d()})}async function Gt(C){co(n,!0,null);try{await C()}catch(T){if(os(T))return;co(n,!0,oa(T))}}function os(C){return C instanceof Fn&&C.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function ft(C){ud(n,C);const T=mt(n),O=T.state;if(ws(Nt.current,n,O),!T.loaded||O.workspaces.length===0)return;const te=mo(O);JSON.stringify(te)!==T.lastPersistedLayoutJson&&zo(te)}function ni(C){ud(n,C),ws(Nt.current,n,mt(n).state)}function Da(C,T,O,te){const se=fd(C,T,O);Le(le=>({...le,[se]:te}))}function ir(C){Xe&&Le(T=>({...T,[Xe]:C}))}function Ar(C,T){const O=Rc(C);T?Da(n,T.workspaceId,T.tabId,O):ir(O),ft({type:"pane.selected",terminalId:C})}function sr(C){ir(C.key),C.type==="terminal"&&ft({type:"pane.selected",terminalId:C.terminalId})}function Ma(C){if(F||ge||Ft||C.isComposing||C.key==="Process"||Vz(C.target))return;const T=Fz(C);if(!T)return;if(C.preventDefault(),C.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){th(T.type==="server.next"?1:-1);return}if(T.type==="favorites.toggle"){ee(!0);return}const O=mt(n).state,te=O.workspaces.find(we=>we.id===O.activeWorkspaceId)??O.workspaces[0],se=te?.tabs.find(we=>we.id===te.activeTabId)??te?.tabs[0];if(T.type==="split"){if(!se)return;xs(T.direction);return}if(!te||!se)return;if(T.type==="tab.previous"||T.type==="tab.next"){const we=qz(te.tabs,se.id,T.type==="tab.next"?1:-1);we&&ft({type:"tab.selected",tabId:we.id});return}if(T.type==="tab.index"){const we=te.tabs[T.index-1];we&&ft({type:"tab.selected",tabId:we.id});return}const le=Wz(se.root,se.activeTerminalId,T);le&&Ar(le,{workspaceId:te.id,tabId:se.id})}function rr(C,T){if(!r||Ie.length===0)return;const O=Ie.findIndex(we=>oi(we,n)),se=((O===-1?0:O)+C+Ie.length)%Ie.length,le=Ie[se]??null;oi(le,n)||(T&&(Wn.current={agentId:le,edge:T}),r(le))}function th(C){const T=mt(n).state,O=T.workspaces;if(O.length===0){rr(C,C===1?"first":"last");return}const te=O.findIndex(we=>we.id===T.activeWorkspaceId),le=(te===-1?0:te)+C;if(le>=0&&le<O.length){ft({type:"workspace.selected",workspaceId:O[le].id});return}rr(C,C===1?"first":"last")}function hi(C,T){if(oi(C,n)){ft({type:"workspace.selected",workspaceId:T});return}kn.current={agentId:C,workspaceId:T},r?.(C)}function Bo(C,T){if(T)return x.workspaces.find(O=>O.id===T)??null;for(const O of C){const te=x.workspaces.find(le=>le.tabs.some(we=>ul(we).includes(O)));if(te)return te;const se=x.workspaces.find(le=>le.detachedTerminalIds.includes(O));if(se)return se}return x.workspaces.find(O=>O.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Aa(C){kc(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function $s(C){if(!kc(C.dataTransfer))return;C.preventDefault();const T=h8(mt(n).state),O=at.current+1;if(at.current=O,!T){Fs({id:O,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Fs({id:O,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Rl(O,T.id,C.dataTransfer)}async function Rl(C,T,O){try{const te=await QE(O);if(te.length===0)throw new Error("No files were found in the drop.");fi(C,{id:C,status:"queued",fileCount:te.length,message:"Queued"},{terminalId:T,files:te})}catch(te){fi(C,{id:C,status:"failed",fileCount:0,message:oa(te)},{terminalId:T})}finally{Lr()}}async function Io(C){const T=Yn.current.find(le=>le.id===C);if(!T?.terminalId||!T.files||T.files.length===0)return;const O=T.terminalId,te=T.files,se=new AbortController;ti.current=C,fi(C,{id:C,status:"uploading",fileCount:te.length,loaded:0,total:null,percent:null},{terminalId:O,files:te,abortController:se});try{const le=await VC({terminalId:O,files:te,signal:se.signal,onProgress:Ye=>{fi(C,{id:C,status:"uploading",fileCount:te.length,loaded:Ye.loaded,total:Ye.total,percent:Ye.percent},{terminalId:O,files:te,abortController:se})}}),we=le.failed>0?le.uploaded>0?"partial":"failed":"success",Ae=le.failed>0?f8(le):void 0,qe={id:C,status:we,fileCount:te.length,response:le};Ae&&(qe.message=Ae),fi(C,qe,{terminalId:O,files:te})}catch(le){fi(C,{id:C,status:"failed",fileCount:te.length,message:se.signal.aborted?"Upload canceled.":oa(le)},{terminalId:O,files:te})}finally{ti.current===C&&(ti.current=null),Lr()}}function Lr(){if(ti.current!==null)return;const C=Yn.current.find(T=>T.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&Io(C.id)}function Fs(C){jr(T=>[...T,C])}function fi(C,T,O={}){jr(te=>te.map(se=>{if(se.id!==C)return se;const le={...T},we=O.terminalId??se.terminalId,Ae=O.files??se.files;return we!==void 0&&(le.terminalId=we),Ae!==void 0&&(le.files=Ae),O.abortController!==void 0&&(le.abortController=O.abortController),le}))}function jr(C){const T=C(Yn.current);Yn.current=T,qi(T)}function Nl(C){Yn.current.find(O=>O.id===C)?.abortController?.abort(),ti.current===C&&(ti.current=null),jr(O=>O.filter(te=>te.id!==C)),Lr()}function Po(){for(const C of Yn.current)C.abortController?.abort();ti.current=null,jr(()=>[])}function La(C){const T=Yn.current.find(O=>O.id===C);if(T){if(T.status==="queued"){Nl(C);return}T.abortController?.abort()}}function Or(C){const T=Yn.current.find(te=>te.id===C);if(!T?.terminalId||!T.files||T.files.length===0)return;const O=Dl(T);if(O.length===0){fi(C,{id:C,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}fi(C,{id:C,status:"queued",fileCount:O.length,message:"Queued"},{terminalId:T.terminalId,files:O}),Lr()}function Dl(C){const T=C.files??[],O="response"in C?C.response:void 0;if(!O)return T;const te=O.results.filter(we=>we.status==="failed").map(we=>we.relativePath);if(te.length===0)return[];const se=new Map;for(const we of T){const Ae=se.get(we.relativePath)??[];Ae.push(we),se.set(we.relativePath,Ae)}const le=[];for(const we of te){const qe=se.get(we)?.shift();qe&&le.push(qe)}return le}function Ml(C){Br({kind:"terminal",agentId:C.agentId,terminalId:C.terminalId}),In(null)}function Br(C){if(Fe.current=C,Qe.current=null,St.current=null,Wt(T=>T+1),yf(void 0),!oi(C.agentId,n)){r?r(C.agentId):Fe.current=null;return}}function Ir(){const C=Fe.current;if(!C||!oi(C.agentId,n))return!1;if(!S.loaded||document.visibilityState!=="visible")return!0;if(St.current?.target===C){const te=St.current;return te.generation===S.generation&&(te.applying||te.layoutSequence===mt(C.agentId).mutable.hydration.layoutSequence)?!0:(St.current=null,Fe.current=null,Qe.current=null,!1)}if(Qe.current?.target!==C||Qe.current.generation!==S.generation){if(Qe.current={target:C,generation:S.generation},!mt(C.agentId).state.workspaces.some(le=>br(le).includes(C.terminalId)))return Yc(C),!0;ft({type:"terminal.revealed",terminalId:C.terminalId});const se=Hv(mt(C.agentId).state,C.terminalId);if(se)return Da(C.agentId,se.workspaceId,se.tabId,Rc(C.terminalId)),Wt(le=>le+1),!0}const T=mt(C.agentId),O=Hv(T.state,C.terminalId);return O&&(x!==T.state||lt?.id!==O.workspaceId||kt?.id!==O.tabId||sn&&tt!==Rc(C.terminalId))?!0:(Fe.current=null,Qe.current=null,!1)}async function Yc(C){const T=mt(C.agentId),O={target:C,generation:T.generation,layoutSequence:T.mutable.hydration.layoutSequence,applying:!1};St.current=O;let te=!1;const se=()=>Ut.current&&St.current===O&&Fe.current===C&&lo(C.agentId)?.generation===O.generation;try{const le=pr(C.agentId),[we,Ae]=await Promise.all([le.listTerminals(),le.getTerminalLayout()]);if(!se())return;const qe=mt(C.agentId);if(!oi(Cr.current,C.agentId)||!qe.loaded||qe.mutable.hydration.layoutSequence!==O.layoutSequence)return;const Ye=we.terminals.find(dn=>dn.id===C.terminalId);if(!Ye)throw new Error("This terminal is no longer available.");const pt=BP(qe.state,Ye,Ae.layout);O.applying=!0,MC(C.agentId,pt);const gn=mo(pt);Ae.revision===qe.layoutRevision?zo(gn):gc(gn,b);const wt=Hv(pt,C.terminalId);Da(C.agentId,wt.workspaceId,wt.tabId,Rc(C.terminalId)),Qe.current={target:C,generation:O.generation},te=!0}catch(le){se()&&!os(le)&&co(C.agentId,!0,oa(le))}finally{se()&&(St.current=null,te||(Fe.current=null,Qe.current=null),Wt(le=>le+1))}}function zo(C){const T=lo(n);if(T?.generation!==S.generation)return;const O=T.mutable.saveCoord;O.pendingLayoutSave=C,gc(C,b),O.saveTimer!==null&&window.clearTimeout(O.saveTimer),O.saveTimer=window.setTimeout(()=>{O.saveTimer=null;const te=O.pendingLayoutSave;O.pendingLayoutSave=null,te&&ja(te,{},T.generation)},Pz)}function Pr(){const C=lo(n);if(C?.generation!==S.generation)return;const T=C.mutable.saveCoord;T.saveTimer!==null&&(window.clearTimeout(T.saveTimer),T.saveTimer=null);const O=T.pendingLayoutSave;T.pendingLayoutSave=null,O&&(gc(O,b),ja(O,{},C.generation))}function ja(C,T={},O=S.generation){const te=lo(n);if(te?.generation!==O)return;const se=te.mutable.saveCoord;se.nextPersistLayout=C,T.baseRevision!==void 0&&(se.queuedBaseRevision=T.baseRevision),!se.nextPersistQueued&&(se.nextPersistQueued=!0,se.persistChain=se.persistChain.then(async()=>{if(lo(n)?.generation!==O)return;se.nextPersistQueued=!1;const le=se.nextPersistLayout,we=se.queuedBaseRevision;se.nextPersistLayout=null,se.queuedBaseRevision=void 0,le&&await Gc(le,we!==void 0?{baseRevision:we}:{},O)}))}async function Gc(C,T,O){const te=lo(n);if(te?.generation!==O||JSON.stringify(mo(te.state))!==JSON.stringify(C))return;const se=te.mutable.hydration.layoutSequence,le=()=>lo(n)?.generation===O,we=T.baseRevision??te.layoutRevision,Ae={layout:C,...typeof we=="number"?{baseRevision:we}:{}};try{const qe=await p.saveTerminalLayout(Ae);if(!le())return;const Ye=qe.layout??C;Sf(n,qe.revision,JSON.stringify(Ye)),gc(Ye,b);return}catch(qe){if(!le())return;if(qe instanceof Fn&&qe.status===400&&qe.message===uM){u8(n,b),co(n,!0,J2());return}if(qe instanceof Fn&&qe.status===409)try{const Ye=await p.getTerminalLayout();if(!le())return;const pt=mt(n).mutable.saveCoord;if(pt.nextPersistLayout||pt.pendingLayoutSave||mt(n).mutable.hydration.layoutSequence!==se){const gn=Ye.layout?JSON.stringify(Ye.layout):mt(n).lastPersistedLayoutJson;Sf(n,Ye.revision,gn);return}if(Ye.layout){const gn=mt(n).state,wt=yp(Object.values(gn.terminals),void 0,Ye.layout.workspaces,Ye.layout.activeWorkspaceId),dn=mo(wt);MC(n,wt),Sf(n,Ye.revision,JSON.stringify(dn)),gc(dn,b)}else Sf(n,Ye.revision,te.lastPersistedLayoutJson);return}catch{}le()&&gc(C,b)}}const Xc=v8(o),Cs=!z||K,zr=Cs?Y:"servers";function Al(C){const T=C.active?S:mt(C.agentId),O=C.active?x:T.state,te=C.active?S.loaded:T.loaded,se=C.active?A:T.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:()=>Li(C.agentId),children:"+"})]}),te?se?u.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(C.agentId),children:se}):u.jsx("div",{className:"workspace-list-items",children:O.workspaces.map(le=>{const we=C.active&&le.id===lt?.id,Ae=br(le).length,qe=bP(C.agentId,le.id),Ye=Qz(qe),pt=C.active&&O.workspaces.length>1,gn=vt?.workspaceId===le.id&&ut!==le.id?vt.placement:null;return u.jsxs(e8,{workspaceId:le.id,active:we,disabled:!C.active,reorderable:pt,dragging:ut===le.id,dropPlacement:gn,working:qe.workingTerminalCount>0,unread:qe.unreadCompletionCount>0,children:[pt?u.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":le.id,title:"Drag to reorder","aria-label":`Reorder ${le.title}`,"aria-grabbed":ut===le.id,onPointerDown:wt=>Pn(le.id,wt),onPointerMove:ka,onPointerUp:jo,onPointerCancel:Ta,onKeyDown:wt=>{(wt.key==="ArrowUp"||wt.key==="ArrowDown")&&(wt.preventDefault(),wt.stopPropagation(),tr(le.id,wt.key==="ArrowUp"?-1:1))},onClick:wt=>wt.stopPropagation(),children:"::"}):null,u.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":we?"page":void 0,title:le.defaultCwd??void 0,onClick:()=>hi(C.agentId,le.id),onDoubleClick:()=>{C.active&&Nr(le.id)},children:[u.jsxs("span",{className:"workspace-list-title-row",children:[u.jsx("span",{className:"workspace-list-name",children:le.title}),qe.workingTerminalCount>0||qe.unreadCompletionCount>0?u.jsxs("span",{className:"workspace-list-attention",title:Ye,"aria-label":Ye,children:[qe.workingTerminalCount>0?u.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,qe.unreadCompletionCount>0?u.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:Zz(qe.unreadCompletionCount)}):null]}):null]}),u.jsxs("small",{children:[le.defaultCwd??"No folder"," · ",Ae," ",Ae===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:()=>Nr(le.id),children:"..."}),u.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${le.title}`,title:"Delete workspace",disabled:O.workspaces.length<=1,onClick:()=>{Na(le.id)},children:"x"})]}):null]},le.id)})}):u.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(C.agentId),children:"Open server to load workspaces"})]})}function Ho(C,T){oe({...C,provider:T})}async function Hr(C){if(N(C),!mt(C.agentId).loaded)try{const T=pr(C.agentId),[O,te]=await Promise.all([T.listTerminals(),T.getTerminalLayout()]),se=te.layout?$b(te.layout):null,le=yp(O.terminals,void 0,se?.savedWorkspaces,se?.savedActiveWorkspaceId),we=le.workspaces.flatMap(Ae=>Ae.tabs.flatMap(qe=>Rn(qe.root).flatMap(Ye=>{const pt=le.terminals[Ye];return pt?[{terminalId:Ye,cwd:pt.cwd,label:`${Ae.title} / ${qe.title} / ${pt.title}`}]:[]})));N(Ae=>Ae===C?{...Ae,targets:we}:Ae)}catch{N(T=>T===C?{...T,targetError:"Could not retrieve open tabs."}:T)}}return u.jsx(yk,{sensors:Kn,onDragStart:Nn,onDragEnd:en,onDragCancel:qn,children:u.jsxs("main",{className:"terminal-shell","data-collapsed":z,"data-sidebar-open":K,onDragOver:Aa,onDrop:$s,children:[u.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>P(!1)}),u.jsxs("aside",{className:"workspace-sidebar",children:[u.jsxs("header",{className:"workspace-brand",children:[u.jsxs("div",{className:"workspace-brand-lockup",children:[Cs?u.jsx(QC,{height:20}):u.jsx(ZC,{size:24}),l&&Cs?u.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),u.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":z?"Expand sidebar":"Collapse sidebar",title:z?"Expand sidebar":"Collapse sidebar",onClick:()=>q(C=>!C),children:z?">":"<"}),u.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>P(!1),children:"x"})]}),u.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${zr==="files"?"files":"servers"}`,children:[Cs?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,zr==="servers"&&Cs?u.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:u.jsx(P1,{api:m,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:me,onServerLabelsChange:di,onManageAccounts:Ho,onServerInfo:C=>{Hr(C)},renderServerChildren:Al})}):null,Cs?null:u.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:u.jsx(P1,{api:m,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:me,onServerLabelsChange:di,compact:!0})}),zr==="files"?u.jsx(_j,{api:p,activeTerminalId:Dn,activeTerminalCwd:ce?.cwd??null,workspaceRootPath:Dn?null:lt?.defaultCwd??null,onOpenFile:Ra},`${n??"local"}:${lt?.id??"no-workspace"}`):null]}),u.jsxs("div",{className:"workspace-sidebar-footer",children:[Cs?u.jsx("span",{children:Xc}):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:()=>he(!0),children:[u.jsx(FC,{name:"settings"}),Z.hasUpdates?u.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Cs?u.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{Oo()},children:u.jsx(FC,{name:"logout"})}):null]})]})]}),F?u.jsx(hj,{api:m,onClose:()=>he(!1),updateAvailable:Z.hasUpdates,onNotificationAssetsChanged:()=>{Ci()},onAgentRemoved:wa}):null,B?u.jsx(cL,{provider:B.provider,serverLabel:B.label,api:re,onClose:()=>oe(null)}):null,ge&&u.jsx(TL,{api:V,label:ge.label,main:ge.agentId===null,getRuntimeStatus:Ps,favorites:ie.filter(C=>C.serverId===(ge.agentId??Jt)),targetStatus:ge.targetError??(!mt(ge.agentId).loaded&&!ge.targets?"Loading open tabs...":null),targets:ge.targets??mt(ge.agentId).state.workspaces.flatMap(C=>C.tabs.flatMap(T=>Rn(T.root).flatMap(O=>{const te=mt(ge.agentId).state.terminals[O];return te?[{terminalId:O,cwd:te.cwd,label:`${C.title} / ${T.title} / ${te.title}`}]:[]}))),onClose:()=>N(null),onFavorite:C=>{N(null),ss(C)},onTarget:C=>{Br({kind:"terminal",agentId:ge.agentId,terminalId:C.terminalId}),N(null)}},ge.agentId??Jt),ve?u.jsx(Yz,{dialog:ve,activePaneCwd:ce?.cwd??null,activeWorkspaceCwd:lt?.defaultCwd??null,onChange:Ca,onManualCwdChange:xa,onBrowse:ki,onCancel:Rr,onSubmit:()=>{er()}}):null,u.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":sn?"true":void 0,children:[u.jsx(PP,{tabs:lt?.tabs??[],activeTabId:lt?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:xi,favoriteTabIds:new Set(ie.filter(C=>C.serverId===(n??Jt)).map(C=>C.tabId)),detachedTerminals:Vn,onSelectTab:C=>ft({type:"tab.selected",tabId:C}),onCreateTab:()=>{Ea()},onToggleWorkspaces:()=>P(C=>!C),onCloseTerminals:C=>zs(C),onReattachTerminal:C=>as(C),onDeleteTerminal:C=>{Hs(C)},onSplitVertical:()=>{xs("vertical")},onSplitHorizontal:()=>{xs("horizontal")},onRenameTab:(C,T)=>{El(C,T)},onToggleFavorite:nr,onOpenFavorites:()=>ee(!0),activePaneAvailable:!!Dn}),Q?u.jsx(vz,{favorites:ie,unavailableFavoriteIds:new Set(ie.filter(C=>C.serverId!==Jt&&!Ie.some(T=>oi(T,C.serverId))).map(As)),busy:H,error:M,getRuntimeStatus:Ps,onClose:()=>{ee(!1),R(null)},onOpen:ss,onRemove:C=>{Oi(T=>T.filter(O=>As(O)!==As(C)))},onReorder:(C,T)=>{const O=As(C),te=As(T);Oi(se=>{const le=se.findIndex(pt=>As(pt)===O),we=se.findIndex(pt=>As(pt)===te);if(le<0||we<0||le===we)return se;const Ae=se.slice(),[qe]=Ae.splice(le,1),Ye=Ae.findIndex(pt=>As(pt)===te);return qe&&Ye>=0&&Ae.splice(Ye,0,qe),Ae})}}):null,sn?u.jsx(n8,{targets:Ve,activeLeafKey:tt,terminals:x.terminals,editors:E,onSelect:sr}):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:Er,children:"Retry"}),n!==null&&r?u.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,u.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?u.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!kt?u.jsx(Jz,{onCreate:()=>{Ea()}}):null,ze.map(C=>{const T=oi(C,n);return u.jsx($z,{agentId:C,serverName:We[ll(C)]??(C===null?"Local":"Server"),active:T,activeServerApi:T?p:void 0,visitedTabKeys:pe,refreshCwdOnEnter:T,draggingTab:T?Bn:null,mobileSplitFocus:ke,mobileFocusedLeafByTabKey:Ne,onSelect:O=>{T&&Ar(O)},onClose:O=>{T&&Mn(O)},onCloseEditor:O=>{T&&rs(O)},onResize:(O,te)=>{T&&ft({type:"pane.resized",path:O,ratio:te})},onExit:(O,te)=>{T?ni({type:"terminal.exited",terminalId:O,exitCode:te}):ud(C,{type:"terminal.exited",terminalId:O,exitCode:te})},onSnapshot:(O,te)=>{const se={type:"terminal.updated",terminal:O,notifyCompletion:te?.notifyCompletion===!0};T?ni(se):ud(C,se)},...f?{onAuthClose:O=>f({...O,source:O?.source??"terminal-ws-1008",activeAgentId:C})}:{}},Uf(C))})]}),Ft?u.jsx(t8,{label:Ft.label,count:Ft.terminalIds.length,warning:He,onCancel:()=>{Ke(null),wr(null)},onHide:()=>{Mr(Ft.terminalIds,Ft.workspaceId)&&wr(null)},onDelete:()=>{const C=Ft.terminalIds;Ke(null),wr(null),Yi(C)}}):null,u.jsx(Nz,{toast:is,onActivate:Ml,onDismiss:()=>In(null)}),u.jsx(wz,{uploads:Yt,onDismiss:Nl,onDismissAll:Po,onRetry:Or,onCancel:La})]})]})})}function $z({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:l,draggingTab:d,mobileSplitFocus:f,mobileFocusedLeafByTabKey:m,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:S,onSnapshot:x,onAuthClose:E}){const L=v.useMemo(()=>Q=>U2(e,Q),[e]),A=v.useMemo(()=>()=>mt(e),[e]),K=v.useSyncExternalStore(L,A,A),P=v.useMemo(()=>pr(e),[e]),z=r??P,q=K.state,Y=q.workspaces.find(Q=>Q.id===q.activeWorkspaceId)??q.workspaces[0],I=Y?.id??null,he=(Y?.tabs.find(Q=>Q.id===Y.activeTabId)??Y?.tabs[0])?.id??null;return!K.loaded||q.workspaces.length===0?null:u.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:q.workspaces.flatMap(Q=>Q.tabs.map(ee=>{const ie=n&&Q.id===I&&ee.id===he,J=fd(e,Q.id,ee.id),H=xp(ee.root),X=f&&H.length>1?Z2(H,ee.activeTerminalId,m[J]):null;return!ie&&!o.has(J)?null:u.jsx("div",{className:"workspace-tab-surface","data-active":ie,"aria-hidden":!ie,children:u.jsx(kb,{node:ee.root,terminals:q.terminals,editors:K.editors,api:z,activeTerminalId:ee.activeTerminalId,visible:ie,refreshCwdOnEnter:ie&&l,tabId:ee.id,codeServerContext:{serverKey:ll(e),serverName:t,tabName:ee.title||q.terminals[ee.activeTerminalId]?.title||"Terminal"},dropZoneActive:ie&&d!==null,draggingTerminalId:ie?d?.terminalId??null:null,mobileFocusLeafKey:X,onSelect:p,onClose:b,onCloseEditor:_,onResize:w,onExit:S,onSnapshot:x,...E?{onAuthClose:E}:{}})},ee.id)}))})}function Fz(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=Kz(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function Wz(e,t,n){switch(n.type){case"pane.direction":return Az(e,t,n.direction);case"pane.index":return Lz(e,n.index);default:return null}}function Kz(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function qz(e,t,n){if(e.length===0)return null;const r=e.findIndex(l=>l.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function xp(e){return e.type==="pane"?[{key:Rc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Q2(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...xp(e.first),...xp(e.second)]}function Ub(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Ub(e.first),...Ub(e.second)]}function Z2(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?Rc(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function Rc(e){return`terminal:${e}`}function Q2(e){return`editor:${e}`}function Vz(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 Yz({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:l,onCancel:d,onSubmit:f}){const m=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(S=>S.kind==="directory"),b=e.submitStatus==="submitting";function _(S){r(x=>x&&{...x,...S})}function w(S){S&&(_({cwd:S,error:null}),l(S))}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:S=>S.stopPropagation(),onSubmit:S=>{S.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:S=>_({title:S.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:S=>o(S.currentTarget.value),placeholder:"/home/user/project"}),u.jsx("button",{type:"button",onClick:()=>{l(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),u.jsxs("div",{className:"workspace-dialog-quick-actions",children:[u.jsx("button",{type:"button",onClick:()=>w(t),disabled:b||!t,children:"Use active pane"}),u.jsx("button",{type:"button",onClick:()=>w(n),disabled:b||!n,children:"Use current workspace"})]}),u.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[u.jsxs("div",{className:"workspace-dialog-browser-header",children:[u.jsx("span",{title:m,children:m||"No folder selected"}),u.jsx("button",{type:"button",onClick:()=>{l(Xz(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(S=>u.jsxs("button",{type:"button","aria-label":`Choose folder ${S.name}`,disabled:b,onClick:()=>{l(Gz(m,S.path))},children:[u.jsx("span",{children:S.name}),u.jsx("small",{children:S.path})]},S.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 Gz(e,t){return t?t.startsWith("/")?Hf(t):Hf(`${e||"/"}/${t}`):Hf(e)}function Xz(e){const t=Hf(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Hf(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function Zz(e){return e>99?"99+":String(e)}function Qz(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 Jz({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 e8({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:l=null,working:d=!1,unread:f=!1,children:m}){const{setNodeRef:p,isOver:b}=Ap({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),_=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",d?"workspace-list-item--working":"",f?"workspace-list-item--unread":"",l?"workspace-list-item--drop-target":"",l?`workspace-list-item--drop-${l}`:""].filter(Boolean).join(" ");return u.jsx("div",{ref:p,className:_,"data-workspace-id":e,"data-drop-over":b?"true":void 0,children:m})}function t8({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:l}){return u.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:u.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[u.jsxs("header",{className:"security-panel-header",children:[u.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),u.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),u.jsxs("section",{className:"terminal-delete-dialog-body",children:[u.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),u.jsx("span",{children:e}),u.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?u.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),u.jsxs("div",{className:"terminal-delete-dialog-actions",children:[u.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),u.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:l,children:"Delete"})]})]})})}function n8({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[l,d]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,m=f>=0?f:0,p=e[m]??e[0],b=UC(p,n,r);function _(w){const S=(m+w+e.length)%e.length,x=e[S];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:w=>w.stopPropagation(),children:[u.jsxs("header",{children:[u.jsx("strong",{children:"Panes"}),u.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),u.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,S)=>{const x=UC(w,n,r),E=i8(w,n,r),L=w.key===p.key;return u.jsxs("button",{type:"button","data-active":L,onClick:()=>{o(w),d(!1)},children:[u.jsx("span",{className:"mobile-pane-sheet-index",children:S+1}),u.jsxs("span",{className:"mobile-pane-sheet-copy",children:[u.jsx("strong",{children:x}),u.jsx("small",{children:E})]}),u.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function UC(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function i8(e,t,n){if(e.type==="editor"){const l=n[e.editorId];return l?.path?`editor | ${l.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function s8(e){const[t,n]=v.useState(()=>r8(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function r8(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function a8(){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 o8(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:jp(t.focus)}function Hv(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Rn(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function oi(e,t){return e===t}function As(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function $C(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o!==void 0&&As(n)===As(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 Uf(e){return e??"__local__"}function fd(e,t,n){return`${Uf(e)}:${t}:${n}`}class Cp extends Error{constructor(){super(J2())}}function l8(e){return e?{workspaceKey:`${zC}:${e}`}:{workspaceKey:zC}}function c8(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(wk(n))throw new Cp;const r=Lp(n);return r?$b(r):null}catch(n){if(n instanceof Cp)throw n;return null}}function $b(e){if(wk(e))throw new Cp;const t=Lp(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function gc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function u8(e,t){const n=mt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function d8(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Co}. Re-open or delete hidden sessions before hiding more.`}function J2(){return`A saved terminal layout has more than ${Co} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function h8(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function f8(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function p8(e){return e.split("/").filter(Boolean).pop()??e}function m8(){try{return localStorage.getItem(X2)==="true"}catch{return!1}}function g8(e){try{localStorage.setItem(X2,e?"true":"false")}catch{}}function ll(e){return e??Jt}function Uv(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function v8(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function 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 oa(e){return e instanceof Error?e.message:"Request failed"}function _8({api:e,onDone:t}){const[n,r]=v.useState(null),[o,l]=v.useState(null),[d,f]=v.useState(""),[m,p]=v.useState(!1),[b,_]=v.useState(null),[w,S]=v.useState(null);v.useEffect(()=>{let E=!1;return e.setupTotp().then(L=>{E||(r(L.qrDataUrl),l(L.secret))}).catch(L=>{E||S(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{E=!0}},[e]);async function x(E){if(E.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 w?u.jsx("p",{className:"form-error",children:w}):!n||!o?u.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):u.jsxs("div",{className:"totp-setup",children:[u.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),u.jsx("div",{className:"totp-qr-container",children:u.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),u.jsxs("details",{className:"totp-secret-details",children:[u.jsx("summary",{children:"Can't scan? Enter manually"}),u.jsx("p",{className:"totp-secret-text",children:o})]}),u.jsxs("form",{className:"auth-form",onSubmit:x,children:[u.jsxs("label",{children:["Verification code",u.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:E=>f(E.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 b8(e){return{source:$v(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:$v(e.terminalId)}:{},...e?.detail?{detail:$v(e.detail)}:{}}}function y8(e){return{invalidationSource:e.source}}function S8(e){Pi("auth.session_invalid.request",eR(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),ay("session-invalid-request").catch(()=>{}))}function w8(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}),ay("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 $v(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function x8({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??kp(),[e]),l=v.useMemo(()=>t??pr(null),[t]),[d,f]=v.useState(null),[m,p]=v.useState(null),b=v.useRef(null),_=v.useRef(0),w=v.useRef("loading"),S=v.useCallback(()=>{_.current++,b.current=null},[]);v.useEffect(()=>S,[S]),v.useEffect(()=>{let P=!1;return o.getSession().then(z=>{P||(f(z),p(null))}).catch(z=>{P||(p(ml(z)),f(null))}),()=>{P=!0}},[o]);const x=E8(d);v.useEffect(()=>{const P=w.current;Pi("auth.view",{view:x,previousView:P,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),P==="workspace"&&x!=="workspace"&&(_v(),ay(`auth-left-workspace-${x}`).catch(()=>{})),w.current=x},[d,x]);async function E(){const P=await o.getSession();f(P),p(null)}async function L(){S(),_v(),Nv(),Iv(),tC(),nC(),p(null),f(null);try{await E()}catch(P){p(ml(P))}}const A=v.useCallback(P=>{const z=b8(P);if(S8(z),b.current)return b.current;const q=_.current,Y=(async()=>{p(null);try{const I=await o.getSession(y8(z));if(q!==_.current)return;if(w8(z,I.authenticated),f(I),I.authenticated){JP(),iI();return}Nv(),Iv(),tC(),nC()}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 QP(P=>{A({source:"activity-auth-check",detail:P})})},[x,A]),x==="workspace")return u.jsx(Uz,{api:o,serverApi:l,activeAgentId:n,onSelectServer:r,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:P=>{A(P)},onLogout:async()=>{S(),_v(),Nv(),Iv();const P=await o.logout();f(P)}});const K={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:K[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(C8,{api:o,onSession:P=>{f(P)}}):null,x==="setup_totp"?u.jsx(_8,{api:o,onDone:()=>{E()}}):null,x==="login"?u.jsx(k8,{api:o,session:d,onSession:f,onRefresh:E}):null,x==="reauth"?u.jsx(T8,{api:o,session:d,onSession:f,onFullLogin:()=>f(P=>P&&{...P,deviceTrusted:!1})}):null]})]})}function C8({api:e,onSession:t}){const[n,r]=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(w){p(ml(w))}finally{f(!1)}}return u.jsxs("form",{className:"auth-form",onSubmit:b,children:[u.jsxs("label",{children:["Password",u.jsx("input",{autoFocus:!0,value:n,onChange:_=>r(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),u.jsxs("label",{children:["Confirm password",u.jsx("input",{value:o,onChange:_=>l(_.currentTarget.value),type:"password",minLength:8,required:!0})]}),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 k8({api:e,session:t,onSession:n,onRefresh:r}){const[o,l]=v.useState(""),[d,f]=v.useState(""),[m,p]=v.useState(!1),[b,_]=v.useState(!1),[w,S]=v.useState(null),x=t?.totpEnabled??!1,E=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),_(!0),S(null);try{n(await e.login({password:o,...x?{otp:d}:{},rememberNetwork:m}))}catch(K){S(ml(K))}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,E?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)"]}),w?u.jsx("p",{className:"form-error",children:w}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:b||o.length===0||x&&d.length!==6,children:"Unlock"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:b,children:"Refresh"})]})]})}function T8({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[l,d]=v.useState(""),[f,m]=v.useState(!1),[p,b]=v.useState(!1),[_,w]=v.useState(!1),[S,x]=v.useState(!1),[E,L]=v.useState(null),A=Ht.useCallback(async(P,z)=>{b(!0),L(null);try{n(await e.reauth({...P?{otp:P}:{},rememberNetwork:z}))}catch(q){L(ml(q))}finally{b(!1)}},[e,n]);v.useEffect(()=>{if(o){let P=!1;w(!0),x(!1),L(null);const z=window.setTimeout(()=>{P||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{P||n(q)}).catch(q=>{P||(L(ml(q)),x(!0))}).finally(()=>{window.clearTimeout(z),P||w(!1)}),()=>{P=!0,window.clearTimeout(z)}}},[e,o,n]);async function K(P){P.preventDefault(),await A(l,f)}return o&&_&&!S&&!E?u.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):u.jsxs("form",{className:"auth-form",onSubmit:K,children:[o&&S&&!E?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:P=>d(P.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),u.jsxs("label",{className:"auth-checkbox",children:[u.jsx("input",{type:"checkbox",checked:f,onChange:P=>m(P.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),E?u.jsx("p",{className:"form-error",children:E}):null,u.jsxs("div",{className:"button-row",children:[u.jsx("button",{type:"submit",disabled:p||l.length!==6,children:"Continue"}),u.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function E8(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",Fb="nterminal.activeAgentId";function R8(){const[e,t]=v.useState(()=>N8()),n=v.useMemo(()=>kp(),[]),r=v.useMemo(()=>pr(e),[e]);v.useEffect(()=>{const l=()=>{const d=TP();document.title=d>0?`(${d}) ${WC}`:WC};return l(),kP(l)},[]);function o(l){D8(l),t(l)}return u.jsx(x8,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function N8(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Fb);return e&&e.trim()?e:null}catch{return null}}function D8(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Fb,e);return}window.localStorage.removeItem(Fb)}catch{}}const KC=["gesturestart","gesturechange","gestureend"],M8=[".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 A8(e=window){if(!j8(e))return()=>{};const t={passive:!1},n=e.document;function r(l){l.cancelable&&l.preventDefault()}function o(l){if(l.defaultPrevented)return;const d=l.touches;!d||d.length===0||(d.length>1||!L8(l.target))&&r(l)}for(const l of KC)n.addEventListener(l,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const l of KC)n.removeEventListener(l,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function L8(e){return e instanceof Element&&e.closest(M8)!==null}function j8(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}EM();x5();A8();Yb();TN.createRoot(document.getElementById("root")).render(u.jsx(Ht.StrictMode,{children:u.jsx(R8,{})}));export{Ht as R,vN as g,u as j};
|