nterminal 1.2.58 → 1.2.60
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/dist/client/assets/MarkdownPreview-jgdUGtLt.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BDE5VmlN.js → TranscriptMarkdownBody-J4Bk7GDH.js} +1 -1
- package/dist/client/assets/index-BhvB-e5O.js +55 -0
- package/dist/client/assets/{index-BIczcK4f.css → index-CpqKK80t.css} +1 -1
- package/dist/client/assets/{index-DLVKSDlo.js → index-DuPhXutl.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/agent/agentRoutes.js +1 -0
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/auth/authService.d.ts +1 -0
- package/dist/server/auth/authService.js +10 -3
- package/dist/server/auth/authService.js.map +1 -1
- package/dist/server/auth/ipMatch.d.ts +2 -0
- package/dist/server/auth/ipMatch.js +36 -0
- package/dist/server/auth/ipMatch.js.map +1 -1
- package/dist/server/routes/terminalRoutes.js +1 -0
- package/dist/server/routes/terminalRoutes.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-D-oOD4FK.js +0 -1
- package/dist/client/assets/index-1p5j5ZUZ.js +0 -54
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-jgdUGtLt.js","assets/index-DuPhXutl.js","assets/TranscriptMarkdownBody-J4Bk7GDH.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 c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();function eE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nf={exports:{}},bo={};var oy;function tE(){if(oy)return bo;oy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,o,c){var h=null;if(c!==void 0&&(h=""+c),o.key!==void 0&&(h=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:h,ref:o!==void 0?o:null,props:c}}return bo.Fragment=t,bo.jsx=s,bo.jsxs=s,bo}var cy;function iE(){return cy||(cy=1,Nf.exports=tE()),Nf.exports}var m=iE(),Af={exports:{}},Ve={};var uy;function nE(){if(uy)return Ve;uy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function S(R){return R===null||typeof R!="object"?null:(R=w&&R[w]||R["@@iterator"],typeof R=="function"?R:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,A={};function O(R,H,Q){this.props=R,this.context=H,this.refs=A,this.updater=Q||E}O.prototype.isReactComponent={},O.prototype.setState=function(R,H){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,H,"setState")},O.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function L(){}L.prototype=O.prototype;function U(R,H,Q){this.props=R,this.context=H,this.refs=A,this.updater=Q||E}var I=U.prototype=new L;I.constructor=U,T(I,O.prototype),I.isPureReactComponent=!0;var te=Array.isArray;function ee(){}var ae={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function be(R,H,Q){var de=Q.ref;return{$$typeof:e,type:R,key:H,ref:de!==void 0?de:null,props:Q}}function we(R,H){return be(R.type,H,R.props)}function ne(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function ie(R){var H={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(Q){return H[Q]})}var Y=/\/+/g;function K(R,H){return typeof R=="object"&&R!==null&&R.key!=null?ie(""+R.key):H.toString(36)}function re(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(ee,ee):(R.status="pending",R.then(function(H){R.status==="pending"&&(R.status="fulfilled",R.value=H)},function(H){R.status==="pending"&&(R.status="rejected",R.reason=H)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function B(R,H,Q,de,ke){var xe=typeof R;(xe==="undefined"||xe==="boolean")&&(R=null);var Re=!1;if(R===null)Re=!0;else switch(xe){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(R.$$typeof){case e:case t:Re=!0;break;case y:return Re=R._init,B(Re(R._payload),H,Q,de,ke)}}if(Re)return ke=ke(R),Re=de===""?"."+K(R,0):de,te(ke)?(Q="",Re!=null&&(Q=Re.replace(Y,"$&/")+"/"),B(ke,H,Q,"",function(G){return G})):ke!=null&&(ne(ke)&&(ke=we(ke,Q+(ke.key==null||R&&R.key===ke.key?"":(""+ke.key).replace(Y,"$&/")+"/")+Re)),H.push(ke)),1;Re=0;var Xe=de===""?".":de+":";if(te(R))for(var ge=0;ge<R.length;ge++)de=R[ge],xe=Xe+K(de,ge),Re+=B(de,H,Q,xe,ke);else if(ge=S(R),typeof ge=="function")for(R=ge.call(R),ge=0;!(de=R.next()).done;)de=de.value,xe=Xe+K(de,ge++),Re+=B(de,H,Q,xe,ke);else if(xe==="object"){if(typeof R.then=="function")return B(re(R),H,Q,de,ke);throw H=String(R),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return Re}function $(R,H,Q){if(R==null)return R;var de=[],ke=0;return B(R,de,"","",function(xe){return H.call(Q,xe,ke++)}),de}function D(R){if(R._status===-1){var H=R._result;H=H(),H.then(function(Q){(R._status===0||R._status===-1)&&(R._status=1,R._result=Q)},function(Q){(R._status===0||R._status===-1)&&(R._status=2,R._result=Q)}),R._status===-1&&(R._status=0,R._result=H)}if(R._status===1)return R._result.default;throw R._result}var X=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},_e={map:$,forEach:function(R,H,Q){$(R,function(){H.apply(this,arguments)},Q)},count:function(R){var H=0;return $(R,function(){H++}),H},toArray:function(R){return $(R,function(H){return H})||[]},only:function(R){if(!ne(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ve.Activity=b,Ve.Children=_e,Ve.Component=O,Ve.Fragment=s,Ve.Profiler=o,Ve.PureComponent=U,Ve.StrictMode=r,Ve.Suspense=g,Ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ae,Ve.__COMPILER_RUNTIME={__proto__:null,c:function(R){return ae.H.useMemoCache(R)}},Ve.cache=function(R){return function(){return R.apply(null,arguments)}},Ve.cacheSignal=function(){return null},Ve.cloneElement=function(R,H,Q){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var de=T({},R.props),ke=R.key;if(H!=null)for(xe in H.key!==void 0&&(ke=""+H.key),H)!ue.call(H,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&H.ref===void 0||(de[xe]=H[xe]);var xe=arguments.length-2;if(xe===1)de.children=Q;else if(1<xe){for(var Re=Array(xe),Xe=0;Xe<xe;Xe++)Re[Xe]=arguments[Xe+2];de.children=Re}return be(R.type,ke,de)},Ve.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},Ve.createElement=function(R,H,Q){var de,ke={},xe=null;if(H!=null)for(de in H.key!==void 0&&(xe=""+H.key),H)ue.call(H,de)&&de!=="key"&&de!=="__self"&&de!=="__source"&&(ke[de]=H[de]);var Re=arguments.length-2;if(Re===1)ke.children=Q;else if(1<Re){for(var Xe=Array(Re),ge=0;ge<Re;ge++)Xe[ge]=arguments[ge+2];ke.children=Xe}if(R&&R.defaultProps)for(de in Re=R.defaultProps,Re)ke[de]===void 0&&(ke[de]=Re[de]);return be(R,xe,ke)},Ve.createRef=function(){return{current:null}},Ve.forwardRef=function(R){return{$$typeof:f,render:R}},Ve.isValidElement=ne,Ve.lazy=function(R){return{$$typeof:y,_payload:{_status:-1,_result:R},_init:D}},Ve.memo=function(R,H){return{$$typeof:p,type:R,compare:H===void 0?null:H}},Ve.startTransition=function(R){var H=ae.T,Q={};ae.T=Q;try{var de=R(),ke=ae.S;ke!==null&&ke(Q,de),typeof de=="object"&&de!==null&&typeof de.then=="function"&&de.then(ee,X)}catch(xe){X(xe)}finally{H!==null&&Q.types!==null&&(H.types=Q.types),ae.T=H}},Ve.unstable_useCacheRefresh=function(){return ae.H.useCacheRefresh()},Ve.use=function(R){return ae.H.use(R)},Ve.useActionState=function(R,H,Q){return ae.H.useActionState(R,H,Q)},Ve.useCallback=function(R,H){return ae.H.useCallback(R,H)},Ve.useContext=function(R){return ae.H.useContext(R)},Ve.useDebugValue=function(){},Ve.useDeferredValue=function(R,H){return ae.H.useDeferredValue(R,H)},Ve.useEffect=function(R,H){return ae.H.useEffect(R,H)},Ve.useEffectEvent=function(R){return ae.H.useEffectEvent(R)},Ve.useId=function(){return ae.H.useId()},Ve.useImperativeHandle=function(R,H,Q){return ae.H.useImperativeHandle(R,H,Q)},Ve.useInsertionEffect=function(R,H){return ae.H.useInsertionEffect(R,H)},Ve.useLayoutEffect=function(R,H){return ae.H.useLayoutEffect(R,H)},Ve.useMemo=function(R,H){return ae.H.useMemo(R,H)},Ve.useOptimistic=function(R,H){return ae.H.useOptimistic(R,H)},Ve.useReducer=function(R,H,Q){return ae.H.useReducer(R,H,Q)},Ve.useRef=function(R){return ae.H.useRef(R)},Ve.useState=function(R){return ae.H.useState(R)},Ve.useSyncExternalStore=function(R,H,Q){return ae.H.useSyncExternalStore(R,H,Q)},Ve.useTransition=function(){return ae.H.useTransition()},Ve.version="19.2.6",Ve}var hy;function Um(){return hy||(hy=1,Af.exports=nE()),Af.exports}var v=Um();const Si=eE(v);var Lf={exports:{}},yo={},Bf={exports:{}},Of={};var dy;function sE(){return dy||(dy=1,(function(e){function t(B,$){var D=B.length;B.push($);e:for(;0<D;){var X=D-1>>>1,_e=B[X];if(0<o(_e,$))B[X]=$,B[D]=_e,D=X;else break e}}function s(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var $=B[0],D=B.pop();if(D!==$){B[0]=D;e:for(var X=0,_e=B.length,R=_e>>>1;X<R;){var H=2*(X+1)-1,Q=B[H],de=H+1,ke=B[de];if(0>o(Q,D))de<_e&&0>o(ke,Q)?(B[X]=ke,B[de]=D,X=de):(B[X]=Q,B[H]=D,X=H);else if(de<_e&&0>o(ke,D))B[X]=ke,B[de]=D,X=de;else break e}}return $}function o(B,$){var D=B.sortIndex-$.sortIndex;return D!==0?D:B.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var h=Date,f=h.now();e.unstable_now=function(){return h.now()-f}}var g=[],p=[],y=1,b=null,w=3,S=!1,E=!1,T=!1,A=!1,O=typeof setTimeout=="function"?setTimeout:null,L=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(B){for(var $=s(p);$!==null;){if($.callback===null)r(p);else if($.startTime<=B)r(p),$.sortIndex=$.expirationTime,t(g,$);else break;$=s(p)}}function te(B){if(T=!1,I(B),!E)if(s(g)!==null)E=!0,ee||(ee=!0,ie());else{var $=s(p);$!==null&&re(te,$.startTime-B)}}var ee=!1,ae=-1,ue=5,be=-1;function we(){return A?!0:!(e.unstable_now()-be<ue)}function ne(){if(A=!1,ee){var B=e.unstable_now();be=B;var $=!0;try{e:{E=!1,T&&(T=!1,L(ae),ae=-1),S=!0;var D=w;try{t:{for(I(B),b=s(g);b!==null&&!(b.expirationTime>B&&we());){var X=b.callback;if(typeof X=="function"){b.callback=null,w=b.priorityLevel;var _e=X(b.expirationTime<=B);if(B=e.unstable_now(),typeof _e=="function"){b.callback=_e,I(B),$=!0;break t}b===s(g)&&r(g),I(B)}else r(g);b=s(g)}if(b!==null)$=!0;else{var R=s(p);R!==null&&re(te,R.startTime-B),$=!1}}break e}finally{b=null,w=D,S=!1}$=void 0}}finally{$?ie():ee=!1}}}var ie;if(typeof U=="function")ie=function(){U(ne)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,K=Y.port2;Y.port1.onmessage=ne,ie=function(){K.postMessage(null)}}else ie=function(){O(ne,0)};function re(B,$){ae=O(function(){B(e.unstable_now())},$)}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(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ue=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(B){switch(w){case 1:case 2:case 3:var $=3;break;default:$=w}var D=w;w=$;try{return B()}finally{w=D}},e.unstable_requestPaint=function(){A=!0},e.unstable_runWithPriority=function(B,$){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var D=w;w=B;try{return $()}finally{w=D}},e.unstable_scheduleCallback=function(B,$,D){var X=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?X+D:X):D=X,B){case 1:var _e=-1;break;case 2:_e=250;break;case 5:_e=1073741823;break;case 4:_e=1e4;break;default:_e=5e3}return _e=D+_e,B={id:y++,callback:$,priorityLevel:B,startTime:D,expirationTime:_e,sortIndex:-1},D>X?(B.sortIndex=D,t(p,B),s(g)===null&&B===s(p)&&(T?(L(ae),ae=-1):T=!0,re(te,D-X))):(B.sortIndex=_e,t(g,B),E||S||(E=!0,ee||(ee=!0,ie()))),B},e.unstable_shouldYield=we,e.unstable_wrapCallback=function(B){var $=w;return function(){var D=w;w=$;try{return B.apply(this,arguments)}finally{w=D}}}})(Of)),Of}var fy;function rE(){return fy||(fy=1,Bf.exports=sE()),Bf.exports}var zf={exports:{}},Xi={};var py;function aE(){if(py)return Xi;py=1;var e=Um();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var r={d:{f:s,r:function(){throw Error(t(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:y}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Xi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Xi.createPortal=function(g,p){var y=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 c(g,p,null,y)},Xi.flushSync=function(g){var p=h.T,y=r.p;try{if(h.T=null,r.p=2,g)return g()}finally{h.T=p,r.p=y,r.d.f()}},Xi.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},Xi.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Xi.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=f(y,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:S}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:S,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Xi.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=f(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},Xi.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=f(y,p.crossOrigin);r.d.L(g,y,{crossOrigin:b,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})}},Xi.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=f(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},Xi.requestFormReset=function(g){r.d.r(g)},Xi.unstable_batchedUpdates=function(g,p){return g(p)},Xi.useFormState=function(g,p,y){return h.H.useFormState(g,p,y)},Xi.useFormStatus=function(){return h.H.useHostTransitionStatus()},Xi.version="19.2.6",Xi}var my;function v0(){if(my)return zf.exports;my=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(),zf.exports=aE(),zf.exports}var gy;function lE(){if(gy)return yo;gy=1;var e=rE(),t=Um(),s=v0();function r(i){var n="https://react.dev/errors/"+i;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var n=i,a=i;if(i.alternate)for(;n.return;)n=n.return;else{i=n;do n=i,(n.flags&4098)!==0&&(a=n.return),i=n.return;while(i)}return n.tag===3?a:null}function h(i){if(i.tag===13){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function f(i){if(i.tag===31){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(r(188));return n!==i?null:i}for(var a=i,l=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===l)return g(u),n;d=d.sibling}throw Error(r(188))}if(a.return!==l.return)a=u,l=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,l=d;break}if(C===l){_=!0,l=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,l=u;break}if(C===l){_=!0,l=d,a=u;break}C=C.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:n}function y(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=y(i),n!==null)return n;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),U=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),be=Symbol.for("react.activity"),we=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=ne&&i[ne]||i["@@iterator"],typeof i=="function"?i:null)}var Y=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Y?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case O:return"Profiler";case A:return"StrictMode";case te:return"Suspense";case ee:return"SuspenseList";case be:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case E:return"Portal";case U:return i.displayName||"Context";case L:return(i._context.displayName||"Context")+".Consumer";case I:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ae:return n=i.displayName||null,n!==null?n:K(i.type)||"Memo";case ue:n=i._payload,i=i._init;try{return K(i(n))}catch{}}return null}var re=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},X=[],_e=-1;function R(i){return{current:i}}function H(i){0>_e||(i.current=X[_e],X[_e]=null,_e--)}function Q(i,n){_e++,X[_e]=i.current,i.current=n}var de=R(null),ke=R(null),xe=R(null),Re=R(null);function Xe(i,n){switch(Q(xe,n),Q(ke,i),Q(de,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?Nb(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=Nb(n),i=Ab(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}H(de),Q(de,i)}function ge(){H(de),H(ke),H(xe)}function G(i){i.memoizedState!==null&&Q(Re,i);var n=de.current,a=Ab(n,i.type);n!==a&&(Q(ke,i),Q(de,a))}function ce(i){ke.current===i&&(H(de),H(ke)),Re.current===i&&(H(Re),mo._currentValue=D)}var Ce,ye;function De(i){if(Ce===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Ce=n&&n[1]||"",ye=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Ce+i+ye}var Be=!1;function Ke(i,n){if(!i||Be)return"";Be=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(Z){var V=Z}Reflect.construct(i,[],fe)}else{try{fe.call()}catch(Z){V=Z}i.call(fe.prototype)}}else{try{throw Error()}catch(Z){V=Z}(fe=i())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(Z){if(Z&&V&&typeof Z.stack=="string")return[Z.stack,V.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=l.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var N=_.split(`
|
|
5
|
+
`),q=C.split(`
|
|
6
|
+
`);for(u=l=0;l<N.length&&!N[l].includes("DetermineComponentFrameRoot");)l++;for(;u<q.length&&!q[u].includes("DetermineComponentFrameRoot");)u++;if(l===N.length||u===q.length)for(l=N.length-1,u=q.length-1;1<=l&&0<=u&&N[l]!==q[u];)u--;for(;1<=l&&0<=u;l--,u--)if(N[l]!==q[u]){if(l!==1||u!==1)do if(l--,u--,0>u||N[l]!==q[u]){var oe=`
|
|
7
|
+
`+N[l].replace(" at new "," at ");return i.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",i.displayName)),oe}while(1<=l&&0<=u);break}}}finally{Be=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?De(a):""}function le(i,n){switch(i.tag){case 26:case 27:case 5:return De(i.type);case 16:return De("Lazy");case 13:return i.child!==n&&n!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Ke(i.type,!1);case 11:return Ke(i.type.render,!1);case 1:return Ke(i.type,!0);case 31:return De("Activity");default:return""}}function Ee(i){try{var n="",a=null;do n+=le(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var Le=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,He=e.unstable_cancelCallback,_t=e.unstable_shouldYield,Ye=e.unstable_requestPaint,rt=e.unstable_now,Oi=e.unstable_getCurrentPriorityLevel,$i=e.unstable_ImmediatePriority,Ci=e.unstable_UserBlockingPriority,ri=e.unstable_NormalPriority,zi=e.unstable_LowPriority,sn=e.unstable_IdlePriority,F=e.log,qe=e.unstable_setDisableYieldValue,dt=null,vt=null;function pi(i){if(typeof F=="function"&&qe(i),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(dt,i)}catch{}}var St=Math.clz32?Math.clz32:Jt,mn=Math.log,Ln=Math.LN2;function Jt(i){return i>>>=0,i===0?32:31-(mn(i)/Ln|0)|0}var ai=256,Zi=262144,gt=4194304;function Tt(i){var n=i&42;if(n!==0)return n;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Dt(i,n,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=l&134217727;return C!==0?(l=C&~d,l!==0?u=Tt(l):(_&=C,_!==0?u=Tt(_):a||(a=C&~i,a!==0&&(u=Tt(a))))):(C=l&~d,C!==0?u=Tt(C):_!==0?u=Tt(_):a||(a=l&~i,a!==0&&(u=Tt(a)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,a=n&-n,d>=a||d===32&&(a&4194048)!==0)?n:u}function mi(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function gi(i,n){switch(i){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ut(){var i=gt;return gt<<=1,(gt&62914560)===0&&(gt=4194304),i}function ei(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function ji(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Lt(i,n,a,l,u,d){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var C=i.entanglements,N=i.expirationTimes,q=i.hiddenUpdates;for(a=_&~a;0<a;){var oe=31-St(a),fe=1<<oe;C[oe]=0,N[oe]=-1;var V=q[oe];if(V!==null)for(q[oe]=null,oe=0;oe<V.length;oe++){var Z=V[oe];Z!==null&&(Z.lane&=-536870913)}a&=~fe}l!==0&&xi(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function xi(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-St(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function It(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-St(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function Yi(i,n){var a=n&-n;return a=(a&42)!==0?1:rn(a),(a&(i.suspendedLanes|n))!==0?0:a}function rn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function an(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Qi(){var i=$.p;return i!==0?i:(i=window.event,i===void 0?32:ty(i.type))}function gn(i,n){var a=$.p;try{return $.p=i,n()}finally{$.p=a}}var Hi=Math.random().toString(36).slice(2),Kt="__reactFiber$"+Hi,Ei="__reactProps$"+Hi,Bn="__reactContainer$"+Hi,ks="__reactEvents$"+Hi,Nl="__reactListeners$"+Hi,Da="__reactHandles$"+Hi,Qn="__reactResources$"+Hi,Jn="__reactMarker$"+Hi;function fs(i){delete i[Kt],delete i[Ei],delete i[ks],delete i[Nl],delete i[Da]}function At(i){var n=i[Kt];if(n)return n;for(var a=i.parentNode;a;){if(n=a[Bn]||a[Kt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=Pb(i);i!==null;){if(a=i[Kt])return a;i=Pb(i)}return n}i=a,a=i.parentNode}return null}function es(i){if(i=i[Kt]||i[Bn]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function ts(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(r(33))}function Vi(i){var n=i[Qn];return n||(n=i[Qn]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function ot(i){i[Jn]=!0}var Ra=new Set,Ur={};function _n(i,n){is(i,n),is(i+"Capture",n)}function is(i,n){for(Ur[i]=n,i=0;i<n.length;i++)Ra.add(n[i])}var Al=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]*$"),Ir={},On={};function Kr(i){return Le.call(On,i)?!0:Le.call(Ir,i)?!1:Al.test(i)?On[i]=!0:(Ir[i]=!0,!1)}function Qs(i,n,a){if(Kr(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function ns(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function vn(i,n,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+l)}}function Yt(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Ts(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function it(i,n,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,d=l.set;return Object.defineProperty(i,n,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,n,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function ss(i){if(!i._valueTracker){var n=Ts(i)?"checked":"value";i._valueTracker=it(i,n,""+i[n])}}function Fr(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=Ts(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function ps(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 Ma=/[\n"\\]/g;function Pi(i){return i.replace(Ma,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Wr(i,n,a,l,u,d,_,C){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),n!=null?_==="number"?(n===0&&i.value===""||i.value!=n)&&(i.value=""+Yt(n)):i.value!==""+Yt(n)&&(i.value=""+Yt(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?$r(i,_,Yt(n)):a!=null?$r(i,_,Yt(a)):l!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+Yt(C):i.removeAttribute("name")}function qr(i,n,a,l,u,d,_,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),n!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){ss(i);return}a=a!=null?""+Yt(a):"",n=n!=null?""+Yt(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=C?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),ss(i)}function $r(i,n,a){n==="number"&&ps(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function zn(i,n,a,l){if(i=i.options,n){n={};for(var u=0;u<a.length;u++)n["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=n.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Yt(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function rs(i,n,a){if(n!=null&&(n=""+Yt(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+Yt(a):""}function Na(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(r(92));if(re(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=Yt(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),ss(i)}function ms(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Ll=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 bn(i,n,a){var l=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":l?i.setProperty(n,a):typeof a!="number"||a===0||Ll.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Ds(i,n,a){if(n!=null&&typeof n!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in n)l=n[u],n.hasOwnProperty(u)&&a[u]!==l&&bn(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&bn(i,d,n[d])}function Js(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 yn=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"]]),er=/^[\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 M(i){return er.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function J(){}var je=null;function Fe(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ie=null,Ge=null;function Ft(i){var n=es(i);if(n&&(i=n.stateNode)){var a=i[Ei]||null;e:switch(i=n.stateNode,n.type){case"input":if(Wr(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Pi(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[Ei]||null;if(!u)throw Error(r(90));Wr(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)l=a[n],l.form===i.form&&Fr(l)}break e;case"textarea":rs(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&zn(i,!!a.multiple,n,!1)}}}var li=!1;function wt(i,n,a){if(li)return i(n,a);li=!0;try{var l=i(n);return l}finally{if(li=!1,(Ie!==null||Ge!==null)&&(eu(),Ie&&(n=Ie,i=Ge,Ge=Ie=null,Ft(n),i)))for(n=0;n<i.length;n++)Ft(i[n])}}function Bt(i,n){var a=i.stateNode;if(a===null)return null;var l=a[Ei]||null;if(l===null)return null;a=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,n,typeof a));return a}var Ui=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Wt=!1;if(Ui)try{var Sn={};Object.defineProperty(Sn,"passive",{get:function(){Wt=!0}}),window.addEventListener("test",Sn,Sn),window.removeEventListener("test",Sn,Sn)}catch{Wt=!1}var jn=null,x=null,k=null;function j(){if(k)return k;var i,n=x,a=n.length,l,u="value"in jn?jn.value:jn.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&n[a-l]===u[d-l];l++);return k=u.slice(i,1<l?1-l:void 0)}function se(i){var n=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&n===13&&(i=13)):i=n,i===10&&(i=13),32<=i||i===13?i:0}function ve(){return!0}function me(){return!1}function Se(i){function n(a,l,u,d,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(a=i[C],this[C]=a?a(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?ve:me,this.isPropagationStopped=me,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ve)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ve)},persist:function(){},isPersistent:ve}),n}var Pe={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nt=Se(Pe),Vt=b({},Pe,{view:0,detail:0}),ti=Se(Vt),Aa,Lh,Bl,vc=b({},Vt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Oh,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!==Bl&&(Bl&&i.type==="mousemove"?(Aa=i.screenX-Bl.screenX,Lh=i.screenY-Bl.screenY):Lh=Aa=0,Bl=i),Aa)},movementY:function(i){return"movementY"in i?i.movementY:Lh}}),Bg=Se(vc),J1=b({},vc,{dataTransfer:0}),eC=Se(J1),tC=b({},Vt,{relatedTarget:0}),Bh=Se(tC),iC=b({},Pe,{animationName:0,elapsedTime:0,pseudoElement:0}),nC=Se(iC),sC=b({},Pe,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),rC=Se(sC),aC=b({},Pe,{data:0}),Og=Se(aC),lC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oC={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"},cC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=cC[i])?!!n[i]:!1}function Oh(){return uC}var hC=b({},Vt,{key:function(i){if(i.key){var n=lC[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=se(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?oC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Oh,charCode:function(i){return i.type==="keypress"?se(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?se(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),dC=Se(hC),fC=b({},vc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zg=Se(fC),pC=b({},Vt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Oh}),mC=Se(pC),gC=b({},Pe,{propertyName:0,elapsedTime:0,pseudoElement:0}),_C=Se(gC),vC=b({},vc,{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}),bC=Se(vC),yC=b({},Pe,{newState:0,oldState:0}),SC=Se(yC),wC=[9,13,27,32],zh=Ui&&"CompositionEvent"in window,Ol=null;Ui&&"documentMode"in document&&(Ol=document.documentMode);var CC=Ui&&"TextEvent"in window&&!Ol,jg=Ui&&(!zh||Ol&&8<Ol&&11>=Ol),Hg=" ",Pg=!1;function Ug(i,n){switch(i){case"keyup":return wC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ig(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var La=!1;function xC(i,n){switch(i){case"compositionend":return Ig(n);case"keypress":return n.which!==32?null:(Pg=!0,Hg);case"textInput":return i=n.data,i===Hg&&Pg?null:i;default:return null}}function EC(i,n){if(La)return i==="compositionend"||!zh&&Ug(i,n)?(i=j(),k=x=jn=null,La=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return jg&&n.locale!=="ko"?null:n.data;default:return null}}var kC={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 Kg(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!kC[i.type]:n==="textarea"}function Fg(i,n,a,l){Ie?Ge?Ge.push(l):Ge=[l]:Ie=l,n=lu(n,"onChange"),0<n.length&&(a=new nt("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var zl=null,jl=null;function TC(i){Eb(i,0)}function bc(i){var n=ts(i);if(Fr(n))return i}function Wg(i,n){if(i==="change")return n}var qg=!1;if(Ui){var jh;if(Ui){var Hh="oninput"in document;if(!Hh){var $g=document.createElement("div");$g.setAttribute("oninput","return;"),Hh=typeof $g.oninput=="function"}jh=Hh}else jh=!1;qg=jh&&(!document.documentMode||9<document.documentMode)}function Yg(){zl&&(zl.detachEvent("onpropertychange",Vg),jl=zl=null)}function Vg(i){if(i.propertyName==="value"&&bc(jl)){var n=[];Fg(n,jl,i,Fe(i)),wt(TC,n)}}function DC(i,n,a){i==="focusin"?(Yg(),zl=n,jl=a,zl.attachEvent("onpropertychange",Vg)):i==="focusout"&&Yg()}function RC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return bc(jl)}function MC(i,n){if(i==="click")return bc(n)}function NC(i,n){if(i==="input"||i==="change")return bc(n)}function AC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var wn=typeof Object.is=="function"?Object.is:AC;function Hl(i,n){if(wn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),l=Object.keys(n);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!Le.call(n,u)||!wn(i[u],n[u]))return!1}return!0}function Xg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Gg(i,n){var a=Xg(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=n&&l>=n)return{node:a,offset:n-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Xg(a)}}function Zg(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?Zg(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function Qg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=ps(i.document);n instanceof i.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)i=n.contentWindow;else break;n=ps(i.document)}return n}function Ph(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n&&(n==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||n==="textarea"||i.contentEditable==="true")}var LC=Ui&&"documentMode"in document&&11>=document.documentMode,Ba=null,Uh=null,Pl=null,Ih=!1;function Jg(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ih||Ba==null||Ba!==ps(l)||(l=Ba,"selectionStart"in l&&Ph(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Pl&&Hl(Pl,l)||(Pl=l,l=lu(Uh,"onSelect"),0<l.length&&(n=new nt("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=Ba)))}function Yr(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var Oa={animationend:Yr("Animation","AnimationEnd"),animationiteration:Yr("Animation","AnimationIteration"),animationstart:Yr("Animation","AnimationStart"),transitionrun:Yr("Transition","TransitionRun"),transitionstart:Yr("Transition","TransitionStart"),transitioncancel:Yr("Transition","TransitionCancel"),transitionend:Yr("Transition","TransitionEnd")},Kh={},e_={};Ui&&(e_=document.createElement("div").style,"AnimationEvent"in window||(delete Oa.animationend.animation,delete Oa.animationiteration.animation,delete Oa.animationstart.animation),"TransitionEvent"in window||delete Oa.transitionend.transition);function Vr(i){if(Kh[i])return Kh[i];if(!Oa[i])return i;var n=Oa[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in e_)return Kh[i]=n[a];return i}var t_=Vr("animationend"),i_=Vr("animationiteration"),n_=Vr("animationstart"),BC=Vr("transitionrun"),OC=Vr("transitionstart"),zC=Vr("transitioncancel"),s_=Vr("transitionend"),r_=new Map,Fh="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(" ");Fh.push("scrollEnd");function as(i,n){r_.set(i,n),_n(n,[i])}var yc=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Hn=[],za=0,Wh=0;function Sc(){for(var i=za,n=Wh=za=0;n<i;){var a=Hn[n];Hn[n++]=null;var l=Hn[n];Hn[n++]=null;var u=Hn[n];Hn[n++]=null;var d=Hn[n];if(Hn[n++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}d!==0&&a_(a,u,d)}}function wc(i,n,a,l){Hn[za++]=i,Hn[za++]=n,Hn[za++]=a,Hn[za++]=l,Wh|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function qh(i,n,a,l){return wc(i,n,a,l),Cc(i)}function Xr(i,n){return wc(i,null,null,n),Cc(i)}function a_(i,n,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,l=d.alternate,l!==null&&(l.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&n!==null&&(u=31-St(a),i=d.hiddenUpdates,l=i[u],l===null?i[u]=[n]:l.push(n),n.lane=a|536870912),d):null}function Cc(i){if(50<lo)throw lo=0,ef=null,Error(r(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var ja={};function jC(i,n,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Cn(i,n,a,l){return new jC(i,n,a,l)}function $h(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Rs(i,n){var a=i.alternate;return a===null?(a=Cn(i.tag,n,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=n,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,n=i.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function l_(i,n){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=n,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,n=a.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),i}function xc(i,n,a,l,u,d){var _=0;if(l=i,typeof i=="function")$h(i)&&(_=1);else if(typeof i=="string")_=Kx(i,a,de.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case be:return i=Cn(31,a,n,u),i.elementType=be,i.lanes=d,i;case T:return Gr(a.children,u,d,n);case A:_=8,u|=24;break;case O:return i=Cn(12,a,n,u|2),i.elementType=O,i.lanes=d,i;case te:return i=Cn(13,a,n,u),i.elementType=te,i.lanes=d,i;case ee:return i=Cn(19,a,n,u),i.elementType=ee,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case U:_=10;break e;case L:_=9;break e;case I:_=11;break e;case ae:_=14;break e;case ue:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return n=Cn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function Gr(i,n,a,l){return i=Cn(7,i,l,n),i.lanes=a,i}function Yh(i,n,a){return i=Cn(6,i,null,n),i.lanes=a,i}function o_(i){var n=Cn(18,null,null,0);return n.stateNode=i,n}function Vh(i,n,a){return n=Cn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var c_=new WeakMap;function Pn(i,n){if(typeof i=="object"&&i!==null){var a=c_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:Ee(n)},c_.set(i,n),n)}return{value:i,source:n,stack:Ee(n)}}var Ha=[],Pa=0,Ec=null,Ul=0,Un=[],In=0,tr=null,gs=1,_s="";function Ms(i,n){Ha[Pa++]=Ul,Ha[Pa++]=Ec,Ec=i,Ul=n}function u_(i,n,a){Un[In++]=gs,Un[In++]=_s,Un[In++]=tr,tr=i;var l=gs;i=_s;var u=32-St(l)-1;l&=~(1<<u),a+=1;var d=32-St(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,gs=1<<32-St(n)+u|a<<u|l,_s=d+i}else gs=1<<d|a<<u|l,_s=i}function Xh(i){i.return!==null&&(Ms(i,1),u_(i,1,0))}function Gh(i){for(;i===Ec;)Ec=Ha[--Pa],Ha[Pa]=null,Ul=Ha[--Pa],Ha[Pa]=null;for(;i===tr;)tr=Un[--In],Un[In]=null,_s=Un[--In],Un[In]=null,gs=Un[--In],Un[In]=null}function h_(i,n){Un[In++]=gs,Un[In++]=_s,Un[In++]=tr,gs=n.id,_s=n.overflow,tr=i}var Ii=null,Ot=null,ht=!1,ir=null,Kn=!1,Zh=Error(r(519));function nr(i){var n=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Il(Pn(n,i)),Zh}function d_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[Kt]=i,n[Ei]=l,a){case"dialog":lt("cancel",n),lt("close",n);break;case"iframe":case"object":case"embed":lt("load",n);break;case"video":case"audio":for(a=0;a<co.length;a++)lt(co[a],n);break;case"source":lt("error",n);break;case"img":case"image":case"link":lt("error",n),lt("load",n);break;case"details":lt("toggle",n);break;case"input":lt("invalid",n),qr(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":lt("invalid",n);break;case"textarea":lt("invalid",n),Na(n,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||l.suppressHydrationWarning===!0||Rb(n.textContent,a)?(l.popover!=null&&(lt("beforetoggle",n),lt("toggle",n)),l.onScroll!=null&<("scroll",n),l.onScrollEnd!=null&<("scrollend",n),l.onClick!=null&&(n.onclick=J),n=!0):n=!1,n||nr(i,!0)}function f_(i){for(Ii=i.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:Kn=!1;return;case 27:case 3:Kn=!0;return;default:Ii=Ii.return}}function Ua(i){if(i!==Ii)return!1;if(!ht)return f_(i),ht=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||gf(i.type,i.memoizedProps)),a=!a),a&&Ot&&nr(i),f_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Hb(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Hb(i)}else n===27?(n=Ot,_r(i.type)?(i=Sf,Sf=null,Ot=i):Ot=n):Ot=Ii?Wn(i.stateNode.nextSibling):null;return!0}function Zr(){Ot=Ii=null,ht=!1}function Qh(){var i=ir;return i!==null&&(un===null?un=i:un.push.apply(un,i),ir=null),i}function Il(i){ir===null?ir=[i]:ir.push(i)}var Jh=R(null),Qr=null,Ns=null;function sr(i,n,a){Q(Jh,n._currentValue),n._currentValue=a}function As(i){i._currentValue=Jh.current,H(Jh)}function ed(i,n,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),i===a)break;i=i.return}}function td(i,n,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=u;for(var N=0;N<n.length;N++)if(C.context===n[N]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),ed(d.return,a,i),l||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(r(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),ed(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function Ia(i,n,a,l){i=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var C=u.type;wn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Re.current){if(_=u.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(mo):i=[mo])}u=u.return}i!==null&&td(n,i,a,l),n.flags|=262144}function kc(i){for(i=i.firstContext;i!==null;){if(!wn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Jr(i){Qr=i,Ns=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ki(i){return p_(Qr,i)}function Tc(i,n){return Qr===null&&Jr(i),p_(i,n)}function p_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Ns===null){if(i===null)throw Error(r(308));Ns=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Ns=Ns.next=n;return a}var HC=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},PC=e.unstable_scheduleCallback,UC=e.unstable_NormalPriority,oi={$$typeof:U,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function id(){return{controller:new HC,data:new Map,refCount:0}}function Kl(i){i.refCount--,i.refCount===0&&PC(UC,function(){i.controller.abort()})}var Fl=null,nd=0,Ka=0,Fa=null;function IC(i,n){if(Fl===null){var a=Fl=[];nd=0,Ka=lf(),Fa={status:"pending",value:void 0,then:function(l){a.push(l)}}}return nd++,n.then(m_,m_),n}function m_(){if(--nd===0&&Fl!==null){Fa!==null&&(Fa.status="fulfilled");var i=Fl;Fl=null,Ka=0,Fa=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function KC(i,n){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var g_=B.S;B.S=function(i,n){Jv=rt(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&IC(i,n),g_!==null&&g_(i,n)};var ea=R(null);function sd(){var i=ea.current;return i!==null?i:Rt.pooledCache}function Dc(i,n){n===null?Q(ea,ea.current):Q(ea,n.pool)}function __(){var i=sd();return i===null?null:{parent:oi._currentValue,pool:i}}var Wa=Error(r(460)),rd=Error(r(474)),Rc=Error(r(542)),Mc={then:function(){}};function v_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function b_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(J,J),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,S_(i),i;default:if(typeof n.status=="string")n.then(J,J);else{if(i=Rt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=n,i.status="pending",i.then(function(l){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=l}},function(l){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,S_(i),i}throw ia=n,Wa}}function ta(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ia=a,Wa):a}}var ia=null;function y_(){if(ia===null)throw Error(r(459));var i=ia;return ia=null,i}function S_(i){if(i===Wa||i===Rc)throw Error(r(483))}var qa=null,Wl=0;function Nc(i){var n=Wl;return Wl+=1,qa===null&&(qa=[]),b_(qa,i,n)}function ql(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Ac(i,n){throw n.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(n),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function w_(i){function n(P,z){if(i){var W=P.deletions;W===null?(P.deletions=[z],P.flags|=16):W.push(z)}}function a(P,z){if(!i)return null;for(;z!==null;)n(P,z),z=z.sibling;return null}function l(P){for(var z=new Map;P!==null;)P.key!==null?z.set(P.key,P):z.set(P.index,P),P=P.sibling;return z}function u(P,z){return P=Rs(P,z),P.index=0,P.sibling=null,P}function d(P,z,W){return P.index=W,i?(W=P.alternate,W!==null?(W=W.index,W<z?(P.flags|=67108866,z):W):(P.flags|=67108866,z)):(P.flags|=1048576,z)}function _(P){return i&&P.alternate===null&&(P.flags|=67108866),P}function C(P,z,W,he){return z===null||z.tag!==6?(z=Yh(W,P.mode,he),z.return=P,z):(z=u(z,W),z.return=P,z)}function N(P,z,W,he){var Ue=W.type;return Ue===T?oe(P,z,W.props.children,he,W.key):z!==null&&(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===ue&&ta(Ue)===z.type)?(z=u(z,W.props),ql(z,W),z.return=P,z):(z=xc(W.type,W.key,W.props,null,P.mode,he),ql(z,W),z.return=P,z)}function q(P,z,W,he){return z===null||z.tag!==4||z.stateNode.containerInfo!==W.containerInfo||z.stateNode.implementation!==W.implementation?(z=Vh(W,P.mode,he),z.return=P,z):(z=u(z,W.children||[]),z.return=P,z)}function oe(P,z,W,he,Ue){return z===null||z.tag!==7?(z=Gr(W,P.mode,he,Ue),z.return=P,z):(z=u(z,W),z.return=P,z)}function fe(P,z,W){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=Yh(""+z,P.mode,W),z.return=P,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case S:return W=xc(z.type,z.key,z.props,null,P.mode,W),ql(W,z),W.return=P,W;case E:return z=Vh(z,P.mode,W),z.return=P,z;case ue:return z=ta(z),fe(P,z,W)}if(re(z)||ie(z))return z=Gr(z,P.mode,W,null),z.return=P,z;if(typeof z.then=="function")return fe(P,Nc(z),W);if(z.$$typeof===U)return fe(P,Tc(P,z),W);Ac(P,z)}return null}function V(P,z,W,he){var Ue=z!==null?z.key:null;if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return Ue!==null?null:C(P,z,""+W,he);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return W.key===Ue?N(P,z,W,he):null;case E:return W.key===Ue?q(P,z,W,he):null;case ue:return W=ta(W),V(P,z,W,he)}if(re(W)||ie(W))return Ue!==null?null:oe(P,z,W,he,null);if(typeof W.then=="function")return V(P,z,Nc(W),he);if(W.$$typeof===U)return V(P,z,Tc(P,W),he);Ac(P,W)}return null}function Z(P,z,W,he,Ue){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return P=P.get(W)||null,C(z,P,""+he,Ue);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case S:return P=P.get(he.key===null?W:he.key)||null,N(z,P,he,Ue);case E:return P=P.get(he.key===null?W:he.key)||null,q(z,P,he,Ue);case ue:return he=ta(he),Z(P,z,W,he,Ue)}if(re(he)||ie(he))return P=P.get(W)||null,oe(z,P,he,Ue,null);if(typeof he.then=="function")return Z(P,z,W,Nc(he),Ue);if(he.$$typeof===U)return Z(P,z,W,Tc(z,he),Ue);Ac(z,he)}return null}function Ae(P,z,W,he){for(var Ue=null,ft=null,ze=z,Qe=z=0,ut=null;ze!==null&&Qe<W.length;Qe++){ze.index>Qe?(ut=ze,ze=null):ut=ze.sibling;var pt=V(P,ze,W[Qe],he);if(pt===null){ze===null&&(ze=ut);break}i&&ze&&pt.alternate===null&&n(P,ze),z=d(pt,z,Qe),ft===null?Ue=pt:ft.sibling=pt,ft=pt,ze=ut}if(Qe===W.length)return a(P,ze),ht&&Ms(P,Qe),Ue;if(ze===null){for(;Qe<W.length;Qe++)ze=fe(P,W[Qe],he),ze!==null&&(z=d(ze,z,Qe),ft===null?Ue=ze:ft.sibling=ze,ft=ze);return ht&&Ms(P,Qe),Ue}for(ze=l(ze);Qe<W.length;Qe++)ut=Z(ze,P,Qe,W[Qe],he),ut!==null&&(i&&ut.alternate!==null&&ze.delete(ut.key===null?Qe:ut.key),z=d(ut,z,Qe),ft===null?Ue=ut:ft.sibling=ut,ft=ut);return i&&ze.forEach(function(wr){return n(P,wr)}),ht&&Ms(P,Qe),Ue}function We(P,z,W,he){if(W==null)throw Error(r(151));for(var Ue=null,ft=null,ze=z,Qe=z=0,ut=null,pt=W.next();ze!==null&&!pt.done;Qe++,pt=W.next()){ze.index>Qe?(ut=ze,ze=null):ut=ze.sibling;var wr=V(P,ze,pt.value,he);if(wr===null){ze===null&&(ze=ut);break}i&&ze&&wr.alternate===null&&n(P,ze),z=d(wr,z,Qe),ft===null?Ue=wr:ft.sibling=wr,ft=wr,ze=ut}if(pt.done)return a(P,ze),ht&&Ms(P,Qe),Ue;if(ze===null){for(;!pt.done;Qe++,pt=W.next())pt=fe(P,pt.value,he),pt!==null&&(z=d(pt,z,Qe),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return ht&&Ms(P,Qe),Ue}for(ze=l(ze);!pt.done;Qe++,pt=W.next())pt=Z(ze,P,Qe,pt.value,he),pt!==null&&(i&&pt.alternate!==null&&ze.delete(pt.key===null?Qe:pt.key),z=d(pt,z,Qe),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return i&&ze.forEach(function(Jx){return n(P,Jx)}),ht&&Ms(P,Qe),Ue}function Et(P,z,W,he){if(typeof W=="object"&&W!==null&&W.type===T&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case S:e:{for(var Ue=W.key;z!==null;){if(z.key===Ue){if(Ue=W.type,Ue===T){if(z.tag===7){a(P,z.sibling),he=u(z,W.props.children),he.return=P,P=he;break e}}else if(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===ue&&ta(Ue)===z.type){a(P,z.sibling),he=u(z,W.props),ql(he,W),he.return=P,P=he;break e}a(P,z);break}else n(P,z);z=z.sibling}W.type===T?(he=Gr(W.props.children,P.mode,he,W.key),he.return=P,P=he):(he=xc(W.type,W.key,W.props,null,P.mode,he),ql(he,W),he.return=P,P=he)}return _(P);case E:e:{for(Ue=W.key;z!==null;){if(z.key===Ue)if(z.tag===4&&z.stateNode.containerInfo===W.containerInfo&&z.stateNode.implementation===W.implementation){a(P,z.sibling),he=u(z,W.children||[]),he.return=P,P=he;break e}else{a(P,z);break}else n(P,z);z=z.sibling}he=Vh(W,P.mode,he),he.return=P,P=he}return _(P);case ue:return W=ta(W),Et(P,z,W,he)}if(re(W))return Ae(P,z,W,he);if(ie(W)){if(Ue=ie(W),typeof Ue!="function")throw Error(r(150));return W=Ue.call(W),We(P,z,W,he)}if(typeof W.then=="function")return Et(P,z,Nc(W),he);if(W.$$typeof===U)return Et(P,z,Tc(P,W),he);Ac(P,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,z!==null&&z.tag===6?(a(P,z.sibling),he=u(z,W),he.return=P,P=he):(a(P,z),he=Yh(W,P.mode,he),he.return=P,P=he),_(P)):a(P,z)}return function(P,z,W,he){try{Wl=0;var Ue=Et(P,z,W,he);return qa=null,Ue}catch(ze){if(ze===Wa||ze===Rc)throw ze;var ft=Cn(29,ze,null,P.mode);return ft.lanes=he,ft.return=P,ft}}}var na=w_(!0),C_=w_(!1),rr=!1;function ad(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ld(i,n){i=i.updateQueue,n.updateQueue===i&&(n.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ar(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function lr(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(mt&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,n=Cc(i),a_(i,null,a),n}return wc(i,l,n,a),Cc(i)}function $l(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,It(i,a)}}function od(i,n){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=n:d=d.next=n}else u=d=n;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var cd=!1;function Yl(){if(cd){var i=Fa;if(i!==null)throw i}}function Vl(i,n,a,l){cd=!1;var u=i.updateQueue;rr=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var N=C,q=N.next;N.next=null,_===null?d=q:_.next=q,_=N;var oe=i.alternate;oe!==null&&(oe=oe.updateQueue,C=oe.lastBaseUpdate,C!==_&&(C===null?oe.firstBaseUpdate=q:C.next=q,oe.lastBaseUpdate=N))}if(d!==null){var fe=u.baseState;_=0,oe=q=N=null,C=d;do{var V=C.lane&-536870913,Z=V!==C.lane;if(Z?(ct&V)===V:(l&V)===V){V!==0&&V===Ka&&(cd=!0),oe!==null&&(oe=oe.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Ae=i,We=C;V=n;var Et=a;switch(We.tag){case 1:if(Ae=We.payload,typeof Ae=="function"){fe=Ae.call(Et,fe,V);break e}fe=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=We.payload,V=typeof Ae=="function"?Ae.call(Et,fe,V):Ae,V==null)break e;fe=b({},fe,V);break e;case 2:rr=!0}}V=C.callback,V!==null&&(i.flags|=64,Z&&(i.flags|=8192),Z=u.callbacks,Z===null?u.callbacks=[V]:Z.push(V))}else Z={lane:V,tag:C.tag,payload:C.payload,callback:C.callback,next:null},oe===null?(q=oe=Z,N=fe):oe=oe.next=Z,_|=V;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,u.lastBaseUpdate=Z,u.shared.pending=null}}while(!0);oe===null&&(N=fe),u.baseState=N,u.firstBaseUpdate=q,u.lastBaseUpdate=oe,d===null&&(u.shared.lanes=0),dr|=_,i.lanes=_,i.memoizedState=fe}}function x_(i,n){if(typeof i!="function")throw Error(r(191,i));i.call(n)}function E_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)x_(a[i],n)}var $a=R(null),Lc=R(0);function k_(i,n){i=Is,Q(Lc,i),Q($a,n),Is=i|n.baseLanes}function ud(){Q(Lc,Is),Q($a,$a.current)}function hd(){Is=Lc.current,H($a),H(Lc)}var xn=R(null),Fn=null;function or(i){var n=i.alternate;Q(ii,ii.current&1),Q(xn,i),Fn===null&&(n===null||$a.current!==null||n.memoizedState!==null)&&(Fn=i)}function dd(i){Q(ii,ii.current),Q(xn,i),Fn===null&&(Fn=i)}function T_(i){i.tag===22?(Q(ii,ii.current),Q(xn,i),Fn===null&&(Fn=i)):cr()}function cr(){Q(ii,ii.current),Q(xn,xn.current)}function En(i){H(xn),Fn===i&&(Fn=null),H(ii)}var ii=R(0);function Bc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||bf(a)||yf(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Ls=0,Ze=null,Ct=null,ci=null,Oc=!1,Ya=!1,sa=!1,zc=0,Xl=0,Va=null,FC=0;function Xt(){throw Error(r(321))}function fd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!wn(i[a],n[a]))return!1;return!0}function pd(i,n,a,l,u,d){return Ls=d,Ze=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,B.H=i===null||i.memoizedState===null?uv:Rd,sa=!1,d=a(l,u),sa=!1,Ya&&(d=R_(n,a,l,u)),D_(i),d}function D_(i){B.H=Ql;var n=Ct!==null&&Ct.next!==null;if(Ls=0,ci=Ct=Ze=null,Oc=!1,Xl=0,Va=null,n)throw Error(r(300));i===null||ui||(i=i.dependencies,i!==null&&kc(i)&&(ui=!0))}function R_(i,n,a,l){Ze=i;var u=0;do{if(Ya&&(Va=null),Xl=0,Ya=!1,25<=u)throw Error(r(301));if(u+=1,ci=Ct=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}B.H=hv,d=n(a,l)}while(Ya);return d}function WC(){var i=B.H,n=i.useState()[0];return n=typeof n.then=="function"?Gl(n):n,i=i.useState()[0],(Ct!==null?Ct.memoizedState:null)!==i&&(Ze.flags|=1024),n}function md(){var i=zc!==0;return zc=0,i}function gd(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function _d(i){if(Oc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Oc=!1}Ls=0,ci=Ct=Ze=null,Ya=!1,Xl=zc=0,Va=null}function Ji(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ci===null?Ze.memoizedState=ci=i:ci=ci.next=i,ci}function ni(){if(Ct===null){var i=Ze.alternate;i=i!==null?i.memoizedState:null}else i=Ct.next;var n=ci===null?Ze.memoizedState:ci.next;if(n!==null)ci=n,Ct=i;else{if(i===null)throw Ze.alternate===null?Error(r(467)):Error(r(310));Ct=i,i={memoizedState:Ct.memoizedState,baseState:Ct.baseState,baseQueue:Ct.baseQueue,queue:Ct.queue,next:null},ci===null?Ze.memoizedState=ci=i:ci=ci.next=i}return ci}function jc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Gl(i){var n=Xl;return Xl+=1,Va===null&&(Va=[]),i=b_(Va,i,n),n=Ze,(ci===null?n.memoizedState:ci.next)===null&&(n=n.alternate,B.H=n===null||n.memoizedState===null?uv:Rd),i}function Hc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Gl(i);if(i.$$typeof===U)return Ki(i)}throw Error(r(438,String(i)))}function vd(i){var n=null,a=Ze.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Ze.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=jc(),Ze.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),l=0;l<i;l++)a[l]=we;return n.index++,a}function Bs(i,n){return typeof n=="function"?n(i):n}function Pc(i){var n=ni();return bd(n,Ct,i)}function bd(i,n,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var u=i.baseQueue,d=l.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,l.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,N=null,q=n,oe=!1;do{var fe=q.lane&-536870913;if(fe!==q.lane?(ct&fe)===fe:(Ls&fe)===fe){var V=q.revertLane;if(V===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),fe===Ka&&(oe=!0);else if((Ls&V)===V){q=q.next,V===Ka&&(oe=!0);continue}else fe={lane:0,revertLane:q.revertLane,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},N===null?(C=N=fe,_=d):N=N.next=fe,Ze.lanes|=V,dr|=V;fe=q.action,sa&&a(d,fe),d=q.hasEagerState?q.eagerState:a(d,fe)}else V={lane:fe,revertLane:q.revertLane,gesture:q.gesture,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},N===null?(C=N=V,_=d):N=N.next=V,Ze.lanes|=fe,dr|=fe;q=q.next}while(q!==null&&q!==n);if(N===null?_=d:N.next=C,!wn(d,i.memoizedState)&&(ui=!0,oe&&(a=Fa,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,l.lastRenderedState=d}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function yd(i){var n=ni(),a=n.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,d=n.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);wn(d,n.memoizedState)||(ui=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function M_(i,n,a){var l=Ze,u=ni(),d=ht;if(d){if(a===void 0)throw Error(r(407));a=a()}else a=n();var _=!wn((Ct||u).memoizedState,a);if(_&&(u.memoizedState=a,ui=!0),u=u.queue,Cd(L_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||ci!==null&&ci.memoizedState.tag&1){if(l.flags|=2048,Xa(9,{destroy:void 0},A_.bind(null,l,u,a,n),null),Rt===null)throw Error(r(349));d||(Ls&127)!==0||N_(l,n,a)}return a}function N_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Ze.updateQueue,n===null?(n=jc(),Ze.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function A_(i,n,a,l){n.value=a,n.getSnapshot=l,B_(n)&&O_(i)}function L_(i,n,a){return a(function(){B_(n)&&O_(i)})}function B_(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!wn(i,a)}catch{return!0}}function O_(i){var n=Xr(i,2);n!==null&&hn(n,i,2)}function Sd(i){var n=Ji();if(typeof i=="function"){var a=i;if(i=a(),sa){pi(!0);try{a()}finally{pi(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:i},n}function z_(i,n,a,l){return i.baseState=a,bd(i,Ct,typeof l=="function"?l:Bs)}function qC(i,n,a,l,u){if(Kc(i))throw Error(r(485));if(i=n.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};B.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,j_(n,d)):(d.next=a.next,n.pending=a.next=d)}}function j_(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=B.T,_={};B.T=_;try{var C=a(u,l),N=B.S;N!==null&&N(_,C),H_(i,n,C)}catch(q){wd(i,n,q)}finally{d!==null&&_.types!==null&&(d.types=_.types),B.T=d}}else try{d=a(u,l),H_(i,n,d)}catch(q){wd(i,n,q)}}function H_(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){P_(i,n,l)},function(l){return wd(i,n,l)}):P_(i,n,a)}function P_(i,n,a){n.status="fulfilled",n.value=a,U_(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,j_(i,a)))}function wd(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,U_(n),n=n.next;while(n!==l)}i.action=null}function U_(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function I_(i,n){return n}function K_(i,n){if(ht){var a=Rt.formState;if(a!==null){e:{var l=Ze;if(ht){if(Ot){t:{for(var u=Ot,d=Kn;u.nodeType!==8;){if(!d){u=null;break t}if(u=Wn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){Ot=Wn(u.nextSibling),l=u.data==="F!";break e}}nr(l)}l=!1}l&&(n=a[0])}}return a=Ji(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:I_,lastRenderedState:n},a.queue=l,a=lv.bind(null,Ze,l),l.dispatch=a,l=Sd(!1),d=Dd.bind(null,Ze,!1,l.queue),l=Ji(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=qC.bind(null,Ze,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function F_(i){var n=ni();return W_(n,Ct,i)}function W_(i,n,a){if(n=bd(i,n,I_)[0],i=Pc(Bs)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=Gl(n)}catch(_){throw _===Wa?Rc:_}else l=n;n=ni();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Ze.flags|=2048,Xa(9,{destroy:void 0},$C.bind(null,u,a),null)),[l,d,i]}function $C(i,n){i.action=n}function q_(i){var n=ni(),a=Ct;if(a!==null)return W_(n,a,i);ni(),n=n.memoizedState,a=ni();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function Xa(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Ze.updateQueue,n===null&&(n=jc(),Ze.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,n.lastEffect=i),i}function $_(){return ni().memoizedState}function Uc(i,n,a,l){var u=Ji();Ze.flags|=i,u.memoizedState=Xa(1|n,{destroy:void 0},a,l===void 0?null:l)}function Ic(i,n,a,l){var u=ni();l=l===void 0?null:l;var d=u.memoizedState.inst;Ct!==null&&l!==null&&fd(l,Ct.memoizedState.deps)?u.memoizedState=Xa(n,d,a,l):(Ze.flags|=i,u.memoizedState=Xa(1|n,d,a,l))}function Y_(i,n){Uc(8390656,8,i,n)}function Cd(i,n){Ic(2048,8,i,n)}function YC(i){Ze.flags|=4;var n=Ze.updateQueue;if(n===null)n=jc(),Ze.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function V_(i){var n=ni().memoizedState;return YC({ref:n,nextImpl:i}),function(){if((mt&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}function X_(i,n){return Ic(4,2,i,n)}function G_(i,n){return Ic(4,4,i,n)}function Z_(i,n){if(typeof n=="function"){i=i();var a=n(i);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return i=i(),n.current=i,function(){n.current=null}}function Q_(i,n,a){a=a!=null?a.concat([i]):null,Ic(4,4,Z_.bind(null,n,i),a)}function xd(){}function J_(i,n){var a=ni();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&fd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function ev(i,n){var a=ni();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&fd(n,l[1]))return l[0];if(l=i(),sa){pi(!0);try{i()}finally{pi(!1)}}return a.memoizedState=[l,n],l}function Ed(i,n,a){return a===void 0||(Ls&1073741824)!==0&&(ct&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=tb(),Ze.lanes|=i,dr|=i,a)}function tv(i,n,a,l){return wn(a,n)?a:$a.current!==null?(i=Ed(i,a,l),wn(i,n)||(ui=!0),i):(Ls&42)===0||(Ls&1073741824)!==0&&(ct&261930)===0?(ui=!0,i.memoizedState=a):(i=tb(),Ze.lanes|=i,dr|=i,n)}function iv(i,n,a,l,u){var d=$.p;$.p=d!==0&&8>d?d:8;var _=B.T,C={};B.T=C,Dd(i,!1,n,a);try{var N=u(),q=B.S;if(q!==null&&q(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var oe=KC(N,l);Zl(i,n,oe,Dn(i))}else Zl(i,n,l,Dn(i))}catch(fe){Zl(i,n,{then:function(){},status:"rejected",reason:fe},Dn())}finally{$.p=d,_!==null&&C.types!==null&&(_.types=C.types),B.T=_}}function VC(){}function kd(i,n,a,l){if(i.tag!==5)throw Error(r(476));var u=nv(i).queue;iv(i,u,n,D,a===null?VC:function(){return sv(i),a(l)})}function nv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:D,baseState:D,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:D},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function sv(i){var n=nv(i);n.next===null&&(n=i.alternate.memoizedState),Zl(i,n.next.queue,{},Dn())}function Td(){return Ki(mo)}function rv(){return ni().memoizedState}function av(){return ni().memoizedState}function XC(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Dn();i=ar(a);var l=lr(n,i,a);l!==null&&(hn(l,n,a),$l(l,n,a)),n={cache:id()},i.payload=n;return}n=n.return}}function GC(i,n,a){var l=Dn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Kc(i)?ov(n,a):(a=qh(i,n,a,l),a!==null&&(hn(a,i,l),cv(a,n,l)))}function lv(i,n,a){var l=Dn();Zl(i,n,a,l)}function Zl(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Kc(i))ov(n,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var _=n.lastRenderedState,C=d(_,a);if(u.hasEagerState=!0,u.eagerState=C,wn(C,_))return wc(i,n,u,0),Rt===null&&Sc(),!1}catch{}if(a=qh(i,n,u,l),a!==null)return hn(a,i,l),cv(a,n,l),!0}return!1}function Dd(i,n,a,l){if(l={lane:2,revertLane:lf(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Kc(i)){if(n)throw Error(r(479))}else n=qh(i,a,l,2),n!==null&&hn(n,i,2)}function Kc(i){var n=i.alternate;return i===Ze||n!==null&&n===Ze}function ov(i,n){Ya=Oc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function cv(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,It(i,a)}}var Ql={readContext:Ki,use:Hc,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useLayoutEffect:Xt,useInsertionEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useSyncExternalStore:Xt,useId:Xt,useHostTransitionStatus:Xt,useFormState:Xt,useActionState:Xt,useOptimistic:Xt,useMemoCache:Xt,useCacheRefresh:Xt};Ql.useEffectEvent=Xt;var uv={readContext:Ki,use:Hc,useCallback:function(i,n){return Ji().memoizedState=[i,n===void 0?null:n],i},useContext:Ki,useEffect:Y_,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,Uc(4194308,4,Z_.bind(null,n,i),a)},useLayoutEffect:function(i,n){return Uc(4194308,4,i,n)},useInsertionEffect:function(i,n){Uc(4,2,i,n)},useMemo:function(i,n){var a=Ji();n=n===void 0?null:n;var l=i();if(sa){pi(!0);try{i()}finally{pi(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=Ji();if(a!==void 0){var u=a(n);if(sa){pi(!0);try{a(n)}finally{pi(!1)}}}else u=n;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=GC.bind(null,Ze,i),[l.memoizedState,i]},useRef:function(i){var n=Ji();return i={current:i},n.memoizedState=i},useState:function(i){i=Sd(i);var n=i.queue,a=lv.bind(null,Ze,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:xd,useDeferredValue:function(i,n){var a=Ji();return Ed(a,i,n)},useTransition:function(){var i=Sd(!1);return i=iv.bind(null,Ze,i.queue,!0,!1),Ji().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Ze,u=Ji();if(ht){if(a===void 0)throw Error(r(407));a=a()}else{if(a=n(),Rt===null)throw Error(r(349));(ct&127)!==0||N_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,Y_(L_.bind(null,l,d,i),[i]),l.flags|=2048,Xa(9,{destroy:void 0},A_.bind(null,l,d,a,n),null),a},useId:function(){var i=Ji(),n=Rt.identifierPrefix;if(ht){var a=_s,l=gs;a=(l&~(1<<32-St(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=zc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=FC++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Td,useFormState:K_,useActionState:K_,useOptimistic:function(i){var n=Ji();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Dd.bind(null,Ze,!0,a),a.dispatch=n,[i,n]},useMemoCache:vd,useCacheRefresh:function(){return Ji().memoizedState=XC.bind(null,Ze)},useEffectEvent:function(i){var n=Ji(),a={impl:i};return n.memoizedState=a,function(){if((mt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Rd={readContext:Ki,use:Hc,useCallback:J_,useContext:Ki,useEffect:Cd,useImperativeHandle:Q_,useInsertionEffect:X_,useLayoutEffect:G_,useMemo:ev,useReducer:Pc,useRef:$_,useState:function(){return Pc(Bs)},useDebugValue:xd,useDeferredValue:function(i,n){var a=ni();return tv(a,Ct.memoizedState,i,n)},useTransition:function(){var i=Pc(Bs)[0],n=ni().memoizedState;return[typeof i=="boolean"?i:Gl(i),n]},useSyncExternalStore:M_,useId:rv,useHostTransitionStatus:Td,useFormState:F_,useActionState:F_,useOptimistic:function(i,n){var a=ni();return z_(a,Ct,i,n)},useMemoCache:vd,useCacheRefresh:av};Rd.useEffectEvent=V_;var hv={readContext:Ki,use:Hc,useCallback:J_,useContext:Ki,useEffect:Cd,useImperativeHandle:Q_,useInsertionEffect:X_,useLayoutEffect:G_,useMemo:ev,useReducer:yd,useRef:$_,useState:function(){return yd(Bs)},useDebugValue:xd,useDeferredValue:function(i,n){var a=ni();return Ct===null?Ed(a,i,n):tv(a,Ct.memoizedState,i,n)},useTransition:function(){var i=yd(Bs)[0],n=ni().memoizedState;return[typeof i=="boolean"?i:Gl(i),n]},useSyncExternalStore:M_,useId:rv,useHostTransitionStatus:Td,useFormState:q_,useActionState:q_,useOptimistic:function(i,n){var a=ni();return Ct!==null?z_(a,Ct,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:vd,useCacheRefresh:av};hv.useEffectEvent=V_;function Md(i,n,a,l){n=i.memoizedState,a=a(l,n),a=a==null?n:b({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Nd={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=ar(l);u.payload=n,a!=null&&(u.callback=a),n=lr(i,u,l),n!==null&&(hn(n,i,l),$l(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=ar(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=lr(i,u,l),n!==null&&(hn(n,i,l),$l(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Dn(),l=ar(a);l.tag=2,n!=null&&(l.callback=n),n=lr(i,l,a),n!==null&&(hn(n,i,a),$l(n,i,a))}};function dv(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!Hl(a,l)||!Hl(u,d):!0}function fv(i,n,a,l){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,l),n.state!==i&&Nd.enqueueReplaceState(n,n.state,null)}function ra(i,n){var a=n;if("ref"in n){a={};for(var l in n)l!=="ref"&&(a[l]=n[l])}if(i=i.defaultProps){a===n&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function pv(i){yc(i)}function mv(i){console.error(i)}function gv(i){yc(i)}function Fc(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function _v(i,n,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Ad(i,n,a){return a=ar(a),a.tag=3,a.payload={element:null},a.callback=function(){Fc(i,n)},a}function vv(i){return i=ar(i),i.tag=3,i}function bv(i,n,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=l.value;i.payload=function(){return u(d)},i.callback=function(){_v(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){_v(n,a,l),typeof u!="function"&&(fr===null?fr=new Set([this]):fr.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function ZC(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&Ia(n,a,u,!0),a=xn.current,a!==null){switch(a.tag){case 31:case 13:return Fn===null?tu():a.alternate===null&&Gt===0&&(Gt=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Mc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([l]):n.add(l),sf(i,l,u)),!1;case 22:return a.flags|=65536,l===Mc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([l]):a.add(l)),sf(i,l,u)),!1}throw Error(r(435,a.tag))}return sf(i,l,u),tu(),!1}if(ht)return n=xn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==Zh&&(i=Error(r(422),{cause:l}),Il(Pn(i,a)))):(l!==Zh&&(n=Error(r(423),{cause:l}),Il(Pn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=Pn(l,a),u=Ad(i.stateNode,l,u),od(i,u),Gt!==4&&(Gt=2)),!1;var d=Error(r(520),{cause:l});if(d=Pn(d,a),ao===null?ao=[d]:ao.push(d),Gt!==4&&(Gt=2),n===null)return!0;l=Pn(l,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Ad(a.stateNode,l,i),od(a,i),!1;case 1:if(n=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(fr===null||!fr.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=vv(u),bv(u,i,a,l),od(a,u),!1}a=a.return}while(a!==null);return!1}var Ld=Error(r(461)),ui=!1;function Fi(i,n,a,l){n.child=i===null?C_(n,null,a,l):na(n,i.child,a,l)}function yv(i,n,a,l,u){a=a.render;var d=n.ref;if("ref"in l){var _={};for(var C in l)C!=="ref"&&(_[C]=l[C])}else _=l;return Jr(n),l=pd(i,n,a,_,d,u),C=md(),i!==null&&!ui?(gd(i,n,u),Os(i,n,u)):(ht&&C&&Xh(n),n.flags|=1,Fi(i,n,l,u),n.child)}function Sv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!$h(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,wv(i,n,d,l,u)):(i=xc(a.type,null,l,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!Id(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:Hl,a(_,l)&&i.ref===n.ref)return Os(i,n,u)}return n.flags|=1,i=Rs(d,l),i.ref=n.ref,i.return=n,n.child=i}function wv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(Hl(d,l)&&i.ref===n.ref)if(ui=!1,n.pendingProps=l=d,Id(i,u))(i.flags&131072)!==0&&(ui=!0);else return n.lanes=i.lanes,Os(i,n,u)}return Bd(i,n,a,l,u)}function Cv(i,n,a,l){var u=l.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(l=n.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~d}else l=0,n.child=null;return xv(i,n,d,a,l)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Dc(n,d!==null?d.cachePool:null),d!==null?k_(n,d):ud(),T_(n);else return l=n.lanes=536870912,xv(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Dc(n,d.cachePool),k_(n,d),cr(),n.memoizedState=null):(i!==null&&Dc(n,null),ud(),cr());return Fi(i,n,u,a),n.child}function Jl(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function xv(i,n,a,l,u){var d=sd();return d=d===null?null:{parent:oi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Dc(n,null),ud(),T_(n),i!==null&&Ia(i,n,l,!0),n.childLanes=u,null}function Wc(i,n){return n=$c({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function Ev(i,n,a){return na(n,i.child,null,a),i=Wc(n,n.pendingProps),i.flags|=2,En(n),n.memoizedState=null,i}function QC(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(ht){if(l.mode==="hidden")return i=Wc(n,l),n.lanes=536870912,Jl(null,i);if(dd(n),(i=Ot)?(i=jb(i,Kn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:tr!==null?{id:gs,overflow:_s}:null,retryLane:536870912,hydrationErrors:null},a=o_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw nr(n);return n.lanes=536870912,null}return Wc(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(dd(n),u)if(n.flags&256)n.flags&=-257,n=Ev(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(r(558));else if(ui||Ia(i,n,a,!1),u=(a&i.childLanes)!==0,ui||u){if(l=Rt,l!==null&&(_=Yi(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,Xr(i,_),hn(l,i,_),Ld;tu(),n=Ev(i,n,a)}else i=d.treeContext,Ot=Wn(_.nextSibling),Ii=n,ht=!0,ir=null,Kn=!1,i!==null&&h_(n,i),n=Wc(n,l),n.flags|=4096;return n}return i=Rs(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function qc(i,n){var a=n.ref;if(a===null)i!==null&&i.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function Bd(i,n,a,l,u){return Jr(n),a=pd(i,n,a,l,void 0,u),l=md(),i!==null&&!ui?(gd(i,n,u),Os(i,n,u)):(ht&&l&&Xh(n),n.flags|=1,Fi(i,n,a,u),n.child)}function kv(i,n,a,l,u,d){return Jr(n),n.updateQueue=null,a=R_(n,l,a,u),D_(i),l=md(),i!==null&&!ui?(gd(i,n,d),Os(i,n,d)):(ht&&l&&Xh(n),n.flags|=1,Fi(i,n,a,d),n.child)}function Tv(i,n,a,l,u){if(Jr(n),n.stateNode===null){var d=ja,_=a.contextType;typeof _=="object"&&_!==null&&(d=Ki(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Nd,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},ad(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Ki(_):ja,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Md(n,a,_,l),d.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&Nd.enqueueReplaceState(d,d.state,null),Vl(n,l,d,u),Yl(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,N=ra(a,C);d.props=N;var q=d.context,oe=a.contextType;_=ja,typeof oe=="object"&&oe!==null&&(_=Ki(oe));var fe=a.getDerivedStateFromProps;oe=typeof fe=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,oe||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||q!==_)&&fv(n,d,l,_),rr=!1;var V=n.memoizedState;d.state=V,Vl(n,l,d,u),Yl(),q=n.memoizedState,C||V!==q||rr?(typeof fe=="function"&&(Md(n,a,fe,l),q=n.memoizedState),(N=rr||dv(n,a,N,l,V,q,_))?(oe||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=q),d.props=l,d.state=q,d.context=_,l=N):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,ld(i,n),_=n.memoizedProps,oe=ra(a,_),d.props=oe,fe=n.pendingProps,V=d.context,q=a.contextType,N=ja,typeof q=="object"&&q!==null&&(N=Ki(q)),C=a.getDerivedStateFromProps,(q=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==fe||V!==N)&&fv(n,d,l,N),rr=!1,V=n.memoizedState,d.state=V,Vl(n,l,d,u),Yl();var Z=n.memoizedState;_!==fe||V!==Z||rr||i!==null&&i.dependencies!==null&&kc(i.dependencies)?(typeof C=="function"&&(Md(n,a,C,l),Z=n.memoizedState),(oe=rr||dv(n,a,oe,l,V,Z,N)||i!==null&&i.dependencies!==null&&kc(i.dependencies))?(q||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,Z,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,Z,N)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Z),d.props=l,d.state=Z,d.context=N,l=oe):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,qc(i,n),l=(n.flags&128)!==0,d||l?(d=n.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&l?(n.child=na(n,i.child,null,u),n.child=na(n,null,a,u)):Fi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Os(i,n,u),i}function Dv(i,n,a,l){return Zr(),n.flags|=256,Fi(i,n,a,l),n.child}var Od={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function zd(i){return{baseLanes:i,cachePool:__()}}function jd(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=Tn),i}function Rv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(ii.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(ht){if(u?or(n):cr(),(i=Ot)?(i=jb(i,Kn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:tr!==null?{id:gs,overflow:_s}:null,retryLane:536870912,hydrationErrors:null},a=o_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw nr(n);return yf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(cr(),u=n.mode,C=$c({mode:"hidden",children:C},u),l=Gr(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=zd(a),l.childLanes=jd(i,_,a),n.memoizedState=Od,Jl(null,l)):(or(n),Hd(n,C))}var N=i.memoizedState;if(N!==null&&(C=N.dehydrated,C!==null)){if(d)n.flags&256?(or(n),n.flags&=-257,n=Pd(i,n,a)):n.memoizedState!==null?(cr(),n.child=i.child,n.flags|=128,n=null):(cr(),C=l.fallback,u=n.mode,l=$c({mode:"visible",children:l.children},u),C=Gr(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,na(n,i.child,null,a),l=n.child,l.memoizedState=zd(a),l.childLanes=jd(i,_,a),n.memoizedState=Od,n=Jl(null,l));else if(or(n),yf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var q=_.dgst;_=q,l=Error(r(419)),l.stack="",l.digest=_,Il({value:l,source:null,stack:null}),n=Pd(i,n,a)}else if(ui||Ia(i,n,a,!1),_=(a&i.childLanes)!==0,ui||_){if(_=Rt,_!==null&&(l=Yi(_,a),l!==0&&l!==N.retryLane))throw N.retryLane=l,Xr(i,l),hn(_,i,l),Ld;bf(C)||tu(),n=Pd(i,n,a)}else bf(C)?(n.flags|=192,n.child=i.child,n=null):(i=N.treeContext,Ot=Wn(C.nextSibling),Ii=n,ht=!0,ir=null,Kn=!1,i!==null&&h_(n,i),n=Hd(n,l.children),n.flags|=4096);return n}return u?(cr(),C=l.fallback,u=n.mode,N=i.child,q=N.sibling,l=Rs(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,q!==null?C=Rs(q,C):(C=Gr(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,Jl(null,l),l=n.child,C=i.child.memoizedState,C===null?C=zd(a):(u=C.cachePool,u!==null?(N=oi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=__(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=jd(i,_,a),n.memoizedState=Od,Jl(i.child,l)):(or(n),a=i.child,i=a.sibling,a=Rs(a,{mode:"visible",children:l.children}),a.return=n,a.sibling=null,i!==null&&(_=n.deletions,_===null?(n.deletions=[i],n.flags|=16):_.push(i)),n.child=a,n.memoizedState=null,a)}function Hd(i,n){return n=$c({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function $c(i,n){return i=Cn(22,i,null,n),i.lanes=0,i}function Pd(i,n,a){return na(n,i.child,null,a),i=Hd(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Mv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),ed(i.return,n,a)}function Ud(i,n,a,l,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function Nv(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=ii.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,Q(ii,_),Fi(i,n,l,a),l=ht?Ul:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Mv(i,a,n);else if(i.tag===19)Mv(i,a,n);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break e;for(;i.sibling===null;){if(i.return===null||i.return===n)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=n.child,u=null;a!==null;)i=a.alternate,i!==null&&Bc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),Ud(n,!1,u,a,d,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Bc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Ud(n,!0,a,null,d,l);break;case"together":Ud(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Os(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),dr|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(Ia(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(r(153));if(n.child!==null){for(i=n.child,a=Rs(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Rs(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function Id(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&kc(i)))}function JC(i,n,a){switch(n.tag){case 3:Xe(n,n.stateNode.containerInfo),sr(n,oi,i.memoizedState.cache),Zr();break;case 27:case 5:G(n);break;case 4:Xe(n,n.stateNode.containerInfo);break;case 10:sr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,dd(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(or(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Rv(i,n,a):(or(n),i=Os(i,n,a),i!==null?i.sibling:null);or(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(Ia(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Nv(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),Q(ii,ii.current),l)break;return null;case 22:return n.lanes=0,Cv(i,n,a,n.pendingProps);case 24:sr(n,oi,i.memoizedState.cache)}return Os(i,n,a)}function Av(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)ui=!0;else{if(!Id(i,a)&&(n.flags&128)===0)return ui=!1,JC(i,n,a);ui=(i.flags&131072)!==0}else ui=!1,ht&&(n.flags&1048576)!==0&&u_(n,Ul,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=ta(n.elementType),n.type=i,typeof i=="function")$h(i)?(l=ra(i,l),n.tag=1,n=Tv(null,n,i,l,a)):(n.tag=0,n=Bd(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===I){n.tag=11,n=yv(null,n,i,l,a);break e}else if(u===ae){n.tag=14,n=Sv(null,n,i,l,a);break e}}throw n=K(i)||i,Error(r(306,n,""))}}return n;case 0:return Bd(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=ra(l,n.pendingProps),Tv(i,n,l,u,a);case 3:e:{if(Xe(n,n.stateNode.containerInfo),i===null)throw Error(r(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,ld(i,n),Vl(n,l,null,a);var _=n.memoizedState;if(l=_.cache,sr(n,oi,l),l!==d.cache&&td(n,[oi],a,!0),Yl(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Dv(i,n,l,a);break e}else if(l!==u){u=Pn(Error(r(424)),n),Il(u),n=Dv(i,n,l,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Ot=Wn(i.firstChild),Ii=n,ht=!0,ir=null,Kn=!0,a=C_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Zr(),l===u){n=Os(i,n,a);break e}Fi(i,n,l,a)}n=n.child}return n;case 26:return qc(i,n),i===null?(a=Fb(n.type,null,n.pendingProps,null))?n.memoizedState=a:ht||(a=n.type,i=n.pendingProps,l=ou(xe.current).createElement(a),l[Kt]=n,l[Ei]=i,Wi(l,a,i),ot(l),n.stateNode=l):n.memoizedState=Fb(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return G(n),i===null&&ht&&(l=n.stateNode=Ub(n.type,n.pendingProps,xe.current),Ii=n,Kn=!0,u=Ot,_r(n.type)?(Sf=u,Ot=Wn(l.firstChild)):Ot=u),Fi(i,n,n.pendingProps.children,a),qc(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&ht&&((u=l=Ot)&&(l=Rx(l,n.type,n.pendingProps,Kn),l!==null?(n.stateNode=l,Ii=n,Ot=Wn(l.firstChild),Kn=!1,u=!0):u=!1),u||nr(n)),G(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,gf(u,d)?l=null:_!==null&&gf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=pd(i,n,WC,null,null,a),mo._currentValue=u),qc(i,n),Fi(i,n,l,a),n.child;case 6:return i===null&&ht&&((i=a=Ot)&&(a=Mx(a,n.pendingProps,Kn),a!==null?(n.stateNode=a,Ii=n,Ot=null,i=!0):i=!1),i||nr(n)),null;case 13:return Rv(i,n,a);case 4:return Xe(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=na(n,null,l,a):Fi(i,n,l,a),n.child;case 11:return yv(i,n,n.type,n.pendingProps,a);case 7:return Fi(i,n,n.pendingProps,a),n.child;case 8:return Fi(i,n,n.pendingProps.children,a),n.child;case 12:return Fi(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,sr(n,n.type,l.value),Fi(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,Jr(n),u=Ki(u),l=l(u),n.flags|=1,Fi(i,n,l,a),n.child;case 14:return Sv(i,n,n.type,n.pendingProps,a);case 15:return wv(i,n,n.type,n.pendingProps,a);case 19:return Nv(i,n,a);case 31:return QC(i,n,a);case 22:return Cv(i,n,a,n.pendingProps);case 24:return Jr(n),l=Ki(oi),i===null?(u=sd(),u===null&&(u=Rt,d=id(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},ad(n),sr(n,oi,u)):((i.lanes&a)!==0&&(ld(i,n),Vl(n,null,null,a),Yl()),u=i.memoizedState,d=n.memoizedState,u.parent!==l?(u={parent:l,cache:l},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),sr(n,oi,l)):(l=d.cache,sr(n,oi,l),l!==u.cache&&td(n,[oi],a,!0))),Fi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(r(156,n.tag))}function zs(i){i.flags|=4}function Kd(i,n,a,l,u){if((n=(i.mode&32)!==0)&&(n=!1),n){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(rb())i.flags|=8192;else throw ia=Mc,rd}else i.flags&=-16777217}function Lv(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Vb(n))if(rb())i.flags|=8192;else throw ia=Mc,rd}function Yc(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?Ut():536870912,i.lanes|=n,Ja|=n)}function eo(i,n){if(!ht)switch(i.tailMode){case"hidden":n=i.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function zt(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,n}function ex(i,n,a){var l=n.pendingProps;switch(Gh(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zt(n),null;case 1:return zt(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),As(oi),ge(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ua(n)?zs(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Qh())),zt(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(zs(n),d!==null?(zt(n),Lv(n,d)):(zt(n),Kd(n,u,null,l,a))):d?d!==i.memoizedState?(zs(n),zt(n),Lv(n,d)):(zt(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&zs(n),zt(n),Kd(n,u,i,l,a)),null;case 27:if(ce(n),a=xe.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}i=de.current,Ua(n)?d_(n):(i=Ub(u,l,a),n.stateNode=i,zs(n))}return zt(n),null;case 5:if(ce(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}if(d=de.current,Ua(n))d_(n);else{var _=ou(xe.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?d.multiple=!0:l.size&&(d.size=l.size);break;default:d=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}d[Kt]=n,d[Ei]=l;e:for(_=n.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===n)break e;for(;_.sibling===null;){if(_.return===null||_.return===n)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}n.stateNode=d;e:switch(Wi(d,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&zs(n)}}return zt(n),Kd(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(r(166));if(i=xe.current,Ua(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Ii,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[Kt]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Rb(i.nodeValue,a)),i||nr(n,!0)}else i=ou(i).createTextNode(l),i[Kt]=n,n.stateNode=i}return zt(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Ua(n),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Kt]=n}else Zr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),i=!1}else a=Qh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(En(n),n):(En(n),null);if((n.flags&128)!==0)throw Error(r(558))}return zt(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Ua(n),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(r(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[Kt]=n}else Zr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),u=!1}else u=Qh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(En(n),n):(En(n),null)}return En(n),(n.flags&128)!==0?(n.lanes=a,n):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=n.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==u&&(l.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),Yc(n,n.updateQueue),zt(n),null);case 4:return ge(),i===null&&hf(n.stateNode.containerInfo),zt(n),null;case 10:return As(n.type),zt(n),null;case 19:if(H(ii),l=n.memoizedState,l===null)return zt(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)eo(l,!1);else{if(Gt!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Bc(i),d!==null){for(n.flags|=128,eo(l,!1),i=d.updateQueue,n.updateQueue=i,Yc(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)l_(a,i),a=a.sibling;return Q(ii,ii.current&1|2),ht&&Ms(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&rt()>Qc&&(n.flags|=128,u=!0,eo(l,!1),n.lanes=4194304)}else{if(!u)if(i=Bc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,Yc(n,i),eo(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!ht)return zt(n),null}else 2*rt()-l.renderingStartTime>Qc&&a!==536870912&&(n.flags|=128,u=!0,eo(l,!1),n.lanes=4194304);l.isBackwards?(d.sibling=n.child,n.child=d):(i=l.last,i!==null?i.sibling=d:n.child=d,l.last=d)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=rt(),i.sibling=null,a=ii.current,Q(ii,u?a&1|2:a&1),ht&&Ms(n,l.treeForkCount),i):(zt(n),null);case 22:case 23:return En(n),hd(),l=n.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(a&536870912)!==0&&(n.flags&128)===0&&(zt(n),n.subtreeFlags&6&&(n.flags|=8192)):zt(n),a=n.updateQueue,a!==null&&Yc(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==a&&(n.flags|=2048),i!==null&&H(ea),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),As(oi),zt(n),null;case 25:return null;case 30:return null}throw Error(r(156,n.tag))}function tx(i,n){switch(Gh(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return As(oi),ge(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return ce(n),null;case 31:if(n.memoizedState!==null){if(En(n),n.alternate===null)throw Error(r(340));Zr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(En(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(r(340));Zr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return H(ii),null;case 4:return ge(),null;case 10:return As(n.type),null;case 22:case 23:return En(n),hd(),i!==null&&H(ea),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return As(oi),null;case 25:return null;default:return null}}function Bv(i,n){switch(Gh(n),n.tag){case 3:As(oi),ge();break;case 26:case 27:case 5:ce(n);break;case 4:ge();break;case 31:n.memoizedState!==null&&En(n);break;case 13:En(n);break;case 19:H(ii);break;case 10:As(n.type);break;case 22:case 23:En(n),hd(),i!==null&&H(ea);break;case 24:As(oi)}}function to(i,n){try{var a=n.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var d=a.create,_=a.inst;l=d(),_.destroy=l}a=a.next}while(a!==u)}}catch(C){yt(n,n.return,C)}}function ur(i,n,a){try{var l=n.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){var _=l.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var N=a,q=C;try{q()}catch(oe){yt(u,N,oe)}}}l=l.next}while(l!==d)}}catch(oe){yt(n,n.return,oe)}}function Ov(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{E_(n,a)}catch(l){yt(i,i.return,l)}}}function zv(i,n,a){a.props=ra(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){yt(i,n,l)}}function io(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){yt(i,n,u)}}function vs(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){yt(i,n,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){yt(i,n,u)}else a.current=null}function jv(i){var n=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){yt(i,i.return,u)}}function Fd(i,n,a){try{var l=i.stateNode;Cx(l,i.type,a,n),l[Ei]=n}catch(u){yt(i,i.return,u)}}function Hv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&_r(i.type)||i.tag===4}function Wd(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Hv(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&&_r(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 qd(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(i),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=J));else if(l!==4&&(l===27&&_r(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(qd(i,n,a),i=i.sibling;i!==null;)qd(i,n,a),i=i.sibling}function Vc(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(l!==4&&(l===27&&_r(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vc(i,n,a),i=i.sibling;i!==null;)Vc(i,n,a),i=i.sibling}function Pv(i){var n=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Wi(n,l,a),n[Kt]=i,n[Ei]=a}catch(d){yt(i,i.return,d)}}var js=!1,hi=!1,$d=!1,Uv=typeof WeakSet=="function"?WeakSet:Set,ki=null;function ix(i,n){if(i=i.containerInfo,pf=mu,i=Qg(i),Ph(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,d=l.focusNode;l=l.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,N=-1,q=0,oe=0,fe=i,V=null;t:for(;;){for(var Z;fe!==a||u!==0&&fe.nodeType!==3||(C=_+u),fe!==d||l!==0&&fe.nodeType!==3||(N=_+l),fe.nodeType===3&&(_+=fe.nodeValue.length),(Z=fe.firstChild)!==null;)V=fe,fe=Z;for(;;){if(fe===i)break t;if(V===a&&++q===u&&(C=_),V===d&&++oe===l&&(N=_),(Z=fe.nextSibling)!==null)break;fe=V,V=fe.parentNode}fe=Z}a=C===-1||N===-1?null:{start:C,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(mf={focusedElem:i,selectionRange:a},mu=!1,ki=n;ki!==null;)if(n=ki,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,ki=i;else for(;ki!==null;){switch(n=ki,d=n.alternate,i=n.flags,n.tag){case 0:if((i&4)!==0&&(i=n.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&d!==null){i=void 0,a=n,u=d.memoizedProps,d=d.memoizedState,l=a.stateNode;try{var Ae=ra(a.type,u);i=l.getSnapshotBeforeUpdate(Ae,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(We){yt(a,a.return,We)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)vf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":vf(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=n.sibling,i!==null){i.return=n.return,ki=i;break}ki=n.return}}function Iv(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Ps(i,a),l&4&&to(5,a);break;case 1:if(Ps(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){yt(a,a.return,_)}else{var u=ra(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){yt(a,a.return,_)}}l&64&&Ov(a),l&512&&io(a,a.return);break;case 3:if(Ps(i,a),l&64&&(i=a.updateQueue,i!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{E_(i,n)}catch(_){yt(a,a.return,_)}}break;case 27:n===null&&l&4&&Pv(a);case 26:case 5:Ps(i,a),n===null&&l&4&&jv(a),l&512&&io(a,a.return);break;case 12:Ps(i,a);break;case 31:Ps(i,a),l&4&&Wv(i,a);break;case 13:Ps(i,a),l&4&&qv(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=hx.bind(null,a),Nx(i,a))));break;case 22:if(l=a.memoizedState!==null||js,!l){n=n!==null&&n.memoizedState!==null||hi,u=js;var d=hi;js=l,(hi=n)&&!d?Us(i,a,(a.subtreeFlags&8772)!==0):Ps(i,a),js=u,hi=d}break;case 30:break;default:Ps(i,a)}}function Kv(i){var n=i.alternate;n!==null&&(i.alternate=null,Kv(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&fs(n)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Ht=null,ln=!1;function Hs(i,n,a){for(a=a.child;a!==null;)Fv(i,n,a),a=a.sibling}function Fv(i,n,a){if(vt&&typeof vt.onCommitFiberUnmount=="function")try{vt.onCommitFiberUnmount(dt,a)}catch{}switch(a.tag){case 26:hi||vs(a,n),Hs(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:hi||vs(a,n);var l=Ht,u=ln;_r(a.type)&&(Ht=a.stateNode,ln=!1),Hs(i,n,a),ho(a.stateNode),Ht=l,ln=u;break;case 5:hi||vs(a,n);case 6:if(l=Ht,u=ln,Ht=null,Hs(i,n,a),Ht=l,ln=u,Ht!==null)if(ln)try{(Ht.nodeType===9?Ht.body:Ht.nodeName==="HTML"?Ht.ownerDocument.body:Ht).removeChild(a.stateNode)}catch(d){yt(a,n,d)}else try{Ht.removeChild(a.stateNode)}catch(d){yt(a,n,d)}break;case 18:Ht!==null&&(ln?(i=Ht,Ob(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),ll(i)):Ob(Ht,a.stateNode));break;case 4:l=Ht,u=ln,Ht=a.stateNode.containerInfo,ln=!0,Hs(i,n,a),Ht=l,ln=u;break;case 0:case 11:case 14:case 15:ur(2,a,n),hi||ur(4,a,n),Hs(i,n,a);break;case 1:hi||(vs(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&zv(a,n,l)),Hs(i,n,a);break;case 21:Hs(i,n,a);break;case 22:hi=(l=hi)||a.memoizedState!==null,Hs(i,n,a),hi=l;break;default:Hs(i,n,a)}}function Wv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{ll(i)}catch(a){yt(n,n.return,a)}}}function qv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{ll(i)}catch(a){yt(n,n.return,a)}}function nx(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new Uv),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new Uv),n;default:throw Error(r(435,i.tag))}}function Xc(i,n){var a=nx(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=dx.bind(null,i,l);l.then(u,u)}})}function on(i,n){var a=n.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(_r(C.type)){Ht=C.stateNode,ln=!1;break e}break;case 5:Ht=C.stateNode,ln=!1;break e;case 3:case 4:Ht=C.stateNode.containerInfo,ln=!0;break e}C=C.return}if(Ht===null)throw Error(r(160));Fv(d,_,u),Ht=null,ln=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)$v(n,i),n=n.sibling}var ls=null;function $v(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:on(n,i),cn(i),l&4&&(ur(3,i,i.return),to(3,i),ur(5,i,i.return));break;case 1:on(n,i),cn(i),l&512&&(hi||a===null||vs(a,a.return)),l&64&&js&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=ls;if(on(n,i),cn(i),l&512&&(hi||a===null||vs(a,a.return)),l&4){var d=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Jn]||d[Kt]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(l),u.head.insertBefore(d,u.querySelector("head > title"))),Wi(d,l,a),d[Kt]=i,ot(d),l=d;break e;case"link":var _=$b("link","href",u).get(l+(a.href||""));if(_){for(var C=0;C<_.length;C++)if(d=_[C],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(C,1);break t}}d=u.createElement(l),Wi(d,l,a),u.head.appendChild(d);break;case"meta":if(_=$b("meta","content",u).get(l+(a.content||""))){for(C=0;C<_.length;C++)if(d=_[C],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(C,1);break t}}d=u.createElement(l),Wi(d,l,a),u.head.appendChild(d);break;default:throw Error(r(468,l))}d[Kt]=i,ot(d),l=d}i.stateNode=l}else Yb(u,i.type,i.stateNode);else i.stateNode=qb(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?Yb(u,i.type,i.stateNode):qb(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Fd(i,i.memoizedProps,a.memoizedProps)}break;case 27:on(n,i),cn(i),l&512&&(hi||a===null||vs(a,a.return)),a!==null&&l&4&&Fd(i,i.memoizedProps,a.memoizedProps);break;case 5:if(on(n,i),cn(i),l&512&&(hi||a===null||vs(a,a.return)),i.flags&32){u=i.stateNode;try{ms(u,"")}catch(Ae){yt(i,i.return,Ae)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Fd(i,u,a!==null?a.memoizedProps:u)),l&1024&&($d=!0);break;case 6:if(on(n,i),cn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ae){yt(i,i.return,Ae)}}break;case 3:if(hu=null,u=ls,ls=cu(n.containerInfo),on(n,i),ls=u,cn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{ll(n.containerInfo)}catch(Ae){yt(i,i.return,Ae)}$d&&($d=!1,Yv(i));break;case 4:l=ls,ls=cu(i.stateNode.containerInfo),on(n,i),cn(i),ls=l;break;case 12:on(n,i),cn(i);break;case 31:on(n,i),cn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Xc(i,l)));break;case 13:on(n,i),cn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Zc=rt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Xc(i,l)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,q=js,oe=hi;if(js=q||u,hi=oe||N,on(n,i),hi=oe,js=q,cn(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||N||js||hi||aa(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){N=a=n;try{if(d=N.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=N.stateNode;var fe=N.memoizedProps.style,V=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;C.style.display=V==null||typeof V=="boolean"?"":(""+V).trim()}}catch(Ae){yt(N,N.return,Ae)}}}else if(n.tag===6){if(a===null){N=n;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Ae){yt(N,N.return,Ae)}}}else if(n.tag===18){if(a===null){N=n;try{var Z=N.stateNode;u?zb(Z,!0):zb(N.stateNode,!1)}catch(Ae){yt(N,N.return,Ae)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===i)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Xc(i,a))));break;case 19:on(n,i),cn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Xc(i,l)));break;case 30:break;case 21:break;default:on(n,i),cn(i)}}function cn(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(Hv(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var u=a.stateNode,d=Wd(i);Vc(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(ms(_,""),a.flags&=-33);var C=Wd(i);Vc(i,C,_);break;case 3:case 4:var N=a.stateNode.containerInfo,q=Wd(i);qd(i,q,N);break;default:throw Error(r(161))}}catch(oe){yt(i,i.return,oe)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function Yv(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;Yv(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Ps(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Iv(i,n.alternate,n),n=n.sibling}function aa(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:ur(4,n,n.return),aa(n);break;case 1:vs(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&zv(n,n.return,a),aa(n);break;case 27:ho(n.stateNode);case 26:case 5:vs(n,n.return),aa(n);break;case 22:n.memoizedState===null&&aa(n);break;case 30:aa(n);break;default:aa(n)}i=i.sibling}}function Us(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Us(u,d,a),to(4,d);break;case 1:if(Us(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(q){yt(l,l.return,q)}if(l=d,u=l.updateQueue,u!==null){var C=l.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)x_(N[u],C)}catch(q){yt(l,l.return,q)}}a&&_&64&&Ov(d),io(d,d.return);break;case 27:Pv(d);case 26:case 5:Us(u,d,a),a&&l===null&&_&4&&jv(d),io(d,d.return);break;case 12:Us(u,d,a);break;case 31:Us(u,d,a),a&&_&4&&Wv(u,d);break;case 13:Us(u,d,a),a&&_&4&&qv(u,d);break;case 22:d.memoizedState===null&&Us(u,d,a),io(d,d.return);break;case 30:break;default:Us(u,d,a)}n=n.sibling}}function Yd(i,n){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Kl(a))}function Vd(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Kl(i))}function os(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Vv(i,n,a,l),n=n.sibling}function Vv(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:os(i,n,a,l),u&2048&&to(9,n);break;case 1:os(i,n,a,l);break;case 3:os(i,n,a,l),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Kl(i)));break;case 12:if(u&2048){os(i,n,a,l),i=n.stateNode;try{var d=n.memoizedProps,_=d.id,C=d.onPostCommit;typeof C=="function"&&C(_,n.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){yt(n,n.return,N)}}else os(i,n,a,l);break;case 31:os(i,n,a,l);break;case 13:os(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?os(i,n,a,l):no(i,n):d._visibility&2?os(i,n,a,l):(d._visibility|=2,Ga(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&Yd(_,n);break;case 24:os(i,n,a,l),u&2048&&Vd(n.alternate,n);break;default:os(i,n,a,l)}}function Ga(i,n,a,l,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,N=l,q=_.flags;switch(_.tag){case 0:case 11:case 15:Ga(d,_,C,N,u),to(8,_);break;case 23:break;case 22:var oe=_.stateNode;_.memoizedState!==null?oe._visibility&2?Ga(d,_,C,N,u):no(d,_):(oe._visibility|=2,Ga(d,_,C,N,u)),u&&q&2048&&Yd(_.alternate,_);break;case 24:Ga(d,_,C,N,u),u&&q&2048&&Vd(_.alternate,_);break;default:Ga(d,_,C,N,u)}n=n.sibling}}function no(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,l=n,u=l.flags;switch(l.tag){case 22:no(a,l),u&2048&&Yd(l.alternate,l);break;case 24:no(a,l),u&2048&&Vd(l.alternate,l);break;default:no(a,l)}n=n.sibling}}var so=8192;function Za(i,n,a){if(i.subtreeFlags&so)for(i=i.child;i!==null;)Xv(i,n,a),i=i.sibling}function Xv(i,n,a){switch(i.tag){case 26:Za(i,n,a),i.flags&so&&i.memoizedState!==null&&Fx(a,ls,i.memoizedState,i.memoizedProps);break;case 5:Za(i,n,a);break;case 3:case 4:var l=ls;ls=cu(i.stateNode.containerInfo),Za(i,n,a),ls=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=so,so=16777216,Za(i,n,a),so=l):Za(i,n,a));break;default:Za(i,n,a)}}function Gv(i){var n=i.alternate;if(n!==null&&(i=n.child,i!==null)){n.child=null;do n=i.sibling,i.sibling=null,i=n;while(i!==null)}}function ro(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];ki=l,Qv(l,i)}Gv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Zv(i),i=i.sibling}function Zv(i){switch(i.tag){case 0:case 11:case 15:ro(i),i.flags&2048&&ur(9,i,i.return);break;case 3:ro(i);break;case 12:ro(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,Gc(i)):ro(i);break;default:ro(i)}}function Gc(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];ki=l,Qv(l,i)}Gv(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:ur(8,n,n.return),Gc(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Gc(n));break;default:Gc(n)}i=i.sibling}}function Qv(i,n){for(;ki!==null;){var a=ki;switch(a.tag){case 0:case 11:case 15:ur(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Kl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,ki=l;else e:for(a=i;ki!==null;){l=ki;var u=l.sibling,d=l.return;if(Kv(l),l===a){ki=null;break e}if(u!==null){u.return=d,ki=u;break e}ki=d}}}var sx={getCacheForType:function(i){var n=Ki(oi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Ki(oi).controller.signal}},rx=typeof WeakMap=="function"?WeakMap:Map,mt=0,Rt=null,at=null,ct=0,bt=0,kn=null,hr=!1,Qa=!1,Xd=!1,Is=0,Gt=0,dr=0,la=0,Gd=0,Tn=0,Ja=0,ao=null,un=null,Zd=!1,Zc=0,Jv=0,Qc=1/0,Jc=null,fr=null,_i=0,pr=null,el=null,Ks=0,Qd=0,Jd=null,eb=null,lo=0,ef=null;function Dn(){return(mt&2)!==0&&ct!==0?ct&-ct:B.T!==null?lf():Qi()}function tb(){if(Tn===0)if((ct&536870912)===0||ht){var i=Zi;Zi<<=1,(Zi&3932160)===0&&(Zi=262144),Tn=i}else Tn=536870912;return i=xn.current,i!==null&&(i.flags|=32),Tn}function hn(i,n,a){(i===Rt&&(bt===2||bt===9)||i.cancelPendingCommit!==null)&&(tl(i,0),mr(i,ct,Tn,!1)),ji(i,a),((mt&2)===0||i!==Rt)&&(i===Rt&&((mt&2)===0&&(la|=a),Gt===4&&mr(i,ct,Tn,!1)),bs(i))}function ib(i,n,a){if((mt&6)!==0)throw Error(r(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||mi(i,n),u=l?ox(i,n):nf(i,n,!0),d=l;do{if(u===0){Qa&&!l&&mr(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!ax(a)){u=nf(i,n,!1),d=!1;continue}if(u===2){if(d=n,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){n=_;e:{var C=i;u=ao;var N=C.current.memoizedState.isDehydrated;if(N&&(tl(C,_).flags|=256),_=nf(C,_,!1),_!==2){if(Xd&&!N){C.errorRecoveryDisabledLanes|=d,la|=d,u=4;break e}d=un,un=u,d!==null&&(un===null?un=d:un.push.apply(un,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){tl(i,0),mr(i,n,0,!0);break}e:{switch(l=i,d=u,d){case 0:case 1:throw Error(r(345));case 4:if((n&4194048)!==n)break;case 6:mr(l,n,Tn,!hr);break e;case 2:un=null;break;case 3:case 5:break;default:throw Error(r(329))}if((n&62914560)===n&&(u=Zc+300-rt(),10<u)){if(mr(l,n,Tn,!hr),Dt(l,0,!0)!==0)break e;Ks=n,l.timeoutHandle=Lb(nb.bind(null,l,a,un,Jc,Zd,n,Tn,la,Ja,hr,d,"Throttled",-0,0),u);break e}nb(l,a,un,Jc,Zd,n,Tn,la,Ja,hr,d,null,-0,0)}}break}while(!0);bs(i)}function nb(i,n,a,l,u,d,_,C,N,q,oe,fe,V,Z){if(i.timeoutHandle=-1,fe=n.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:J},Xv(n,d,fe);var Ae=(d&62914560)===d?Zc-rt():(d&4194048)===d?Jv-rt():0;if(Ae=Wx(fe,Ae),Ae!==null){Ks=d,i.cancelPendingCommit=Ae(hb.bind(null,i,n,d,a,l,u,_,C,N,oe,fe,null,V,Z)),mr(i,d,_,!q);return}}hb(i,n,d,a,l,u,_,C,N)}function ax(i){for(var n=i;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],d=u.getSnapshot;u=u.value;try{if(!wn(d(),u))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function mr(i,n,a,l){n&=~Gd,n&=~la,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-St(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&xi(i,a,n)}function eu(){return(mt&6)===0?(oo(0),!1):!0}function tf(){if(at!==null){if(bt===0)var i=at.return;else i=at,Ns=Qr=null,_d(i),qa=null,Wl=0,i=at;for(;i!==null;)Bv(i.alternate,i),i=i.return;at=null}}function tl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,kx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Ks=0,tf(),Rt=i,at=a=Rs(i.current,null),ct=n,bt=0,kn=null,hr=!1,Qa=mi(i,n),Xd=!1,Ja=Tn=Gd=la=dr=Gt=0,un=ao=null,Zd=!1,(n&8)!==0&&(n|=n&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=n;0<l;){var u=31-St(l),d=1<<u;n|=i[u],l&=~d}return Is=n,Sc(),a}function sb(i,n){Ze=null,B.H=Ql,n===Wa||n===Rc?(n=y_(),bt=3):n===rd?(n=y_(),bt=4):bt=n===Ld?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,at===null&&(Gt=1,Fc(i,Pn(n,i.current)))}function rb(){var i=xn.current;return i===null?!0:(ct&4194048)===ct?Fn===null:(ct&62914560)===ct||(ct&536870912)!==0?i===Fn:!1}function ab(){var i=B.H;return B.H=Ql,i===null?Ql:i}function lb(){var i=B.A;return B.A=sx,i}function tu(){Gt=4,hr||(ct&4194048)!==ct&&xn.current!==null||(Qa=!0),(dr&134217727)===0&&(la&134217727)===0||Rt===null||mr(Rt,ct,Tn,!1)}function nf(i,n,a){var l=mt;mt|=2;var u=ab(),d=lb();(Rt!==i||ct!==n)&&(Jc=null,tl(i,n)),n=!1;var _=Gt;e:do try{if(bt!==0&&at!==null){var C=at,N=kn;switch(bt){case 8:tf(),_=6;break e;case 3:case 2:case 9:case 6:xn.current===null&&(n=!0);var q=bt;if(bt=0,kn=null,il(i,C,N,q),a&&Qa){_=0;break e}break;default:q=bt,bt=0,kn=null,il(i,C,N,q)}}lx(),_=Gt;break}catch(oe){sb(i,oe)}while(!0);return n&&i.shellSuspendCounter++,Ns=Qr=null,mt=l,B.H=u,B.A=d,at===null&&(Rt=null,ct=0,Sc()),_}function lx(){for(;at!==null;)ob(at)}function ox(i,n){var a=mt;mt|=2;var l=ab(),u=lb();Rt!==i||ct!==n?(Jc=null,Qc=rt()+500,tl(i,n)):Qa=mi(i,n);e:do try{if(bt!==0&&at!==null){n=at;var d=kn;t:switch(bt){case 1:bt=0,kn=null,il(i,n,d,1);break;case 2:case 9:if(v_(d)){bt=0,kn=null,cb(n);break}n=function(){bt!==2&&bt!==9||Rt!==i||(bt=7),bs(i)},d.then(n,n);break e;case 3:bt=7;break e;case 4:bt=5;break e;case 7:v_(d)?(bt=0,kn=null,cb(n)):(bt=0,kn=null,il(i,n,d,7));break;case 5:var _=null;switch(at.tag){case 26:_=at.memoizedState;case 5:case 27:var C=at;if(_?Vb(_):C.stateNode.complete){bt=0,kn=null;var N=C.sibling;if(N!==null)at=N;else{var q=C.return;q!==null?(at=q,iu(q)):at=null}break t}}bt=0,kn=null,il(i,n,d,5);break;case 6:bt=0,kn=null,il(i,n,d,6);break;case 8:tf(),Gt=6;break e;default:throw Error(r(462))}}cx();break}catch(oe){sb(i,oe)}while(!0);return Ns=Qr=null,B.H=l,B.A=u,mt=a,at!==null?0:(Rt=null,ct=0,Sc(),Gt)}function cx(){for(;at!==null&&!_t();)ob(at)}function ob(i){var n=Av(i.alternate,i,Is);i.memoizedProps=i.pendingProps,n===null?iu(i):at=n}function cb(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=kv(a,n,n.pendingProps,n.type,void 0,ct);break;case 11:n=kv(a,n,n.pendingProps,n.type.render,n.ref,ct);break;case 5:_d(n);default:Bv(a,n),n=at=l_(n,Is),n=Av(a,n,Is)}i.memoizedProps=i.pendingProps,n===null?iu(i):at=n}function il(i,n,a,l){Ns=Qr=null,_d(n),qa=null,Wl=0;var u=n.return;try{if(ZC(i,u,n,a,ct)){Gt=1,Fc(i,Pn(a,i.current)),at=null;return}}catch(d){if(u!==null)throw at=u,d;Gt=1,Fc(i,Pn(a,i.current)),at=null;return}n.flags&32768?(ht||l===1?i=!0:Qa||(ct&536870912)!==0?i=!1:(hr=i=!0,(l===2||l===9||l===3||l===6)&&(l=xn.current,l!==null&&l.tag===13&&(l.flags|=16384))),ub(n,i)):iu(n)}function iu(i){var n=i;do{if((n.flags&32768)!==0){ub(n,hr);return}i=n.return;var a=ex(n.alternate,n,Is);if(a!==null){at=a;return}if(n=n.sibling,n!==null){at=n;return}at=n=i}while(n!==null);Gt===0&&(Gt=5)}function ub(i,n){do{var a=tx(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),!n&&(i=i.sibling,i!==null)){at=i;return}at=i=a}while(i!==null);Gt=6,at=null}function hb(i,n,a,l,u,d,_,C,N){i.cancelPendingCommit=null;do nu();while(_i!==0);if((mt&6)!==0)throw Error(r(327));if(n!==null){if(n===i.current)throw Error(r(177));if(d=n.lanes|n.childLanes,d|=Wh,Lt(i,a,d,_,C,N),i===Rt&&(at=Rt=null,ct=0),el=n,pr=i,Ks=a,Qd=d,Jd=u,eb=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,fx(ri,function(){return gb(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=B.T,B.T=null,u=$.p,$.p=2,_=mt,mt|=4;try{ix(i,n,a)}finally{mt=_,$.p=u,B.T=l}}_i=1,db(),fb(),pb()}}function db(){if(_i===1){_i=0;var i=pr,n=el,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=B.T,B.T=null;var l=$.p;$.p=2;var u=mt;mt|=4;try{$v(n,i);var d=mf,_=Qg(i.containerInfo),C=d.focusedElem,N=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&Zg(C.ownerDocument.documentElement,C)){if(N!==null&&Ph(C)){var q=N.start,oe=N.end;if(oe===void 0&&(oe=q),"selectionStart"in C)C.selectionStart=q,C.selectionEnd=Math.min(oe,C.value.length);else{var fe=C.ownerDocument||document,V=fe&&fe.defaultView||window;if(V.getSelection){var Z=V.getSelection(),Ae=C.textContent.length,We=Math.min(N.start,Ae),Et=N.end===void 0?We:Math.min(N.end,Ae);!Z.extend&&We>Et&&(_=Et,Et=We,We=_);var P=Gg(C,We),z=Gg(C,Et);if(P&&z&&(Z.rangeCount!==1||Z.anchorNode!==P.node||Z.anchorOffset!==P.offset||Z.focusNode!==z.node||Z.focusOffset!==z.offset)){var W=fe.createRange();W.setStart(P.node,P.offset),Z.removeAllRanges(),We>Et?(Z.addRange(W),Z.extend(z.node,z.offset)):(W.setEnd(z.node,z.offset),Z.addRange(W))}}}}for(fe=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&fe.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<fe.length;C++){var he=fe[C];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}mu=!!pf,mf=pf=null}finally{mt=u,$.p=l,B.T=a}}i.current=n,_i=2}}function fb(){if(_i===2){_i=0;var i=pr,n=el,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=B.T,B.T=null;var l=$.p;$.p=2;var u=mt;mt|=4;try{Iv(i,n.alternate,n)}finally{mt=u,$.p=l,B.T=a}}_i=3}}function pb(){if(_i===4||_i===3){_i=0,Ye();var i=pr,n=el,a=Ks,l=eb;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?_i=5:(_i=0,el=pr=null,mb(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(fr=null),an(a),n=n.stateNode,vt&&typeof vt.onCommitFiberRoot=="function")try{vt.onCommitFiberRoot(dt,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=B.T,u=$.p,$.p=2,B.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{B.T=n,$.p=u}}(Ks&3)!==0&&nu(),bs(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===ef?lo++:(lo=0,ef=i):lo=0,oo(0)}}function mb(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Kl(n)))}function nu(){return db(),fb(),pb(),gb()}function gb(){if(_i!==5)return!1;var i=pr,n=Qd;Qd=0;var a=an(Ks),l=B.T,u=$.p;try{$.p=32>a?32:a,B.T=null,a=Jd,Jd=null;var d=pr,_=Ks;if(_i=0,el=pr=null,Ks=0,(mt&6)!==0)throw Error(r(331));var C=mt;if(mt|=4,Zv(d.current),Vv(d,d.current,_,a),mt=C,oo(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(dt,d)}catch{}return!0}finally{$.p=u,B.T=l,mb(i,n)}}function _b(i,n,a){n=Pn(a,n),n=Ad(i.stateNode,n,2),i=lr(i,n,2),i!==null&&(ji(i,2),bs(i))}function yt(i,n,a){if(i.tag===3)_b(i,i,a);else for(;n!==null;){if(n.tag===3){_b(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(fr===null||!fr.has(l))){i=Pn(a,i),a=vv(2),l=lr(n,a,2),l!==null&&(bv(a,l,n,i),ji(l,2),bs(l));break}}n=n.return}}function sf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new rx;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(a)||(Xd=!0,u.add(a),i=ux.bind(null,i,n,a),n.then(i,i))}function ux(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Rt===i&&(ct&a)===a&&(Gt===4||Gt===3&&(ct&62914560)===ct&&300>rt()-Zc?(mt&2)===0&&tl(i,0):Gd|=a,Ja===ct&&(Ja=0)),bs(i)}function vb(i,n){n===0&&(n=Ut()),i=Xr(i,n),i!==null&&(ji(i,n),bs(i))}function hx(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),vb(i,a)}function dx(i,n){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(n),vb(i,a)}function fx(i,n){return Oe(i,n)}var su=null,nl=null,rf=!1,ru=!1,af=!1,gr=0;function bs(i){i!==nl&&i.next===null&&(nl===null?su=nl=i:nl=nl.next=i),ru=!0,rf||(rf=!0,mx())}function oo(i,n){if(!af&&ru){af=!0;do for(var a=!1,l=su;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var d=0;else{var _=l.suspendedLanes,C=l.pingedLanes;d=(1<<31-St(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,wb(l,d))}else d=ct,d=Dt(l,l===Rt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||mi(l,d)||(a=!0,wb(l,d));l=l.next}while(a);af=!1}}function px(){bb()}function bb(){ru=rf=!1;var i=0;gr!==0&&Ex()&&(i=gr);for(var n=rt(),a=null,l=su;l!==null;){var u=l.next,d=yb(l,n);d===0?(l.next=null,a===null?su=u:a.next=u,u===null&&(nl=a)):(a=l,(i!==0||(d&3)!==0)&&(ru=!0)),l=u}_i!==0&&_i!==5||oo(i),gr!==0&&(gr=0)}function yb(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-St(d),C=1<<_,N=u[_];N===-1?((C&a)===0||(C&l)!==0)&&(u[_]=gi(C,n)):N<=n&&(i.expiredLanes|=C),d&=~C}if(n=Rt,a=ct,a=Dt(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(bt===2||bt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&He(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||mi(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&He(l),an(a)){case 2:case 8:a=Ci;break;case 32:a=ri;break;case 268435456:a=sn;break;default:a=ri}return l=Sb.bind(null,i),a=Oe(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&He(l),i.callbackPriority=2,i.callbackNode=null,2}function Sb(i,n){if(_i!==0&&_i!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(nu()&&i.callbackNode!==a)return null;var l=ct;return l=Dt(i,i===Rt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(ib(i,l,n),yb(i,rt()),i.callbackNode!=null&&i.callbackNode===a?Sb.bind(null,i):null)}function wb(i,n){if(nu())return null;ib(i,n,!0)}function mx(){Tx(function(){(mt&6)!==0?Oe($i,px):bb()})}function lf(){if(gr===0){var i=Ka;i===0&&(i=ai,ai<<=1,(ai&261888)===0&&(ai=256)),gr=i}return gr}function Cb(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:M(""+i)}function xb(i,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,i.id&&a.setAttribute("form",i.id),n.parentNode.insertBefore(a,n),i=new FormData(i),a.parentNode.removeChild(a),i}function gx(i,n,a,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=Cb((u[Ei]||null).action),_=l.submitter;_&&(n=(n=_[Ei]||null)?Cb(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new nt("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(gr!==0){var N=_?xb(u,_):new FormData(u);kd(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(C.preventDefault(),N=_?xb(u,_):new FormData(u),kd(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var of=0;of<Fh.length;of++){var cf=Fh[of],_x=cf.toLowerCase(),vx=cf[0].toUpperCase()+cf.slice(1);as(_x,"on"+vx)}as(t_,"onAnimationEnd"),as(i_,"onAnimationIteration"),as(n_,"onAnimationStart"),as("dblclick","onDoubleClick"),as("focusin","onFocus"),as("focusout","onBlur"),as(BC,"onTransitionRun"),as(OC,"onTransitionStart"),as(zC,"onTransitionCancel"),as(s_,"onTransitionEnd"),is("onMouseEnter",["mouseout","mouseover"]),is("onMouseLeave",["mouseout","mouseover"]),is("onPointerEnter",["pointerout","pointerover"]),is("onPointerLeave",["pointerout","pointerover"]),_n("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),_n("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),_n("onBeforeInput",["compositionend","keypress","textInput","paste"]),_n("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),_n("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),_n("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var co="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(" "),bx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(co));function Eb(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var d=void 0;if(n)for(var _=l.length-1;0<=_;_--){var C=l[_],N=C.instance,q=C.currentTarget;if(C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=q;try{d(u)}catch(oe){yc(oe)}u.currentTarget=null,d=N}else for(_=0;_<l.length;_++){if(C=l[_],N=C.instance,q=C.currentTarget,C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=q;try{d(u)}catch(oe){yc(oe)}u.currentTarget=null,d=N}}}}function lt(i,n){var a=n[ks];a===void 0&&(a=n[ks]=new Set);var l=i+"__bubble";a.has(l)||(kb(n,i,2,!1),a.add(l))}function uf(i,n,a){var l=0;n&&(l|=4),kb(a,i,l,n)}var au="_reactListening"+Math.random().toString(36).slice(2);function hf(i){if(!i[au]){i[au]=!0,Ra.forEach(function(a){a!=="selectionchange"&&(bx.has(a)||uf(a,!1,i),uf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[au]||(n[au]=!0,uf("selectionchange",!1,n))}}function kb(i,n,a,l){switch(ty(n)){case 2:var u=Yx;break;case 8:u=Vx;break;default:u=kf}a=u.bind(null,n,a,i),u=void 0,!Wt||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(n,a,{capture:!0,passive:u}):i.addEventListener(n,a,!0):u!==void 0?i.addEventListener(n,a,{passive:u}):i.addEventListener(n,a,!1)}function df(i,n,a,l,u){var d=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var C=l.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=l.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=At(C),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){l=d=_;continue e}C=C.parentNode}}l=l.return}wt(function(){var q=d,oe=Fe(a),fe=[];e:{var V=r_.get(i);if(V!==void 0){var Z=nt,Ae=i;switch(i){case"keypress":if(se(a)===0)break e;case"keydown":case"keyup":Z=dC;break;case"focusin":Ae="focus",Z=Bh;break;case"focusout":Ae="blur",Z=Bh;break;case"beforeblur":case"afterblur":Z=Bh;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":Z=Bg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=eC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=mC;break;case t_:case i_:case n_:Z=nC;break;case s_:Z=_C;break;case"scroll":case"scrollend":Z=ti;break;case"wheel":Z=bC;break;case"copy":case"cut":case"paste":Z=rC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=zg;break;case"toggle":case"beforetoggle":Z=SC}var We=(n&4)!==0,Et=!We&&(i==="scroll"||i==="scrollend"),P=We?V!==null?V+"Capture":null:V;We=[];for(var z=q,W;z!==null;){var he=z;if(W=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||W===null||P===null||(he=Bt(z,P),he!=null&&We.push(uo(z,he,W))),Et)break;z=z.return}0<We.length&&(V=new Z(V,Ae,null,a,oe),fe.push({event:V,listeners:We}))}}if((n&7)===0){e:{if(V=i==="mouseover"||i==="pointerover",Z=i==="mouseout"||i==="pointerout",V&&a!==je&&(Ae=a.relatedTarget||a.fromElement)&&(At(Ae)||Ae[Bn]))break e;if((Z||V)&&(V=oe.window===oe?oe:(V=oe.ownerDocument)?V.defaultView||V.parentWindow:window,Z?(Ae=a.relatedTarget||a.toElement,Z=q,Ae=Ae?At(Ae):null,Ae!==null&&(Et=c(Ae),We=Ae.tag,Ae!==Et||We!==5&&We!==27&&We!==6)&&(Ae=null)):(Z=null,Ae=q),Z!==Ae)){if(We=Bg,he="onMouseLeave",P="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(We=zg,he="onPointerLeave",P="onPointerEnter",z="pointer"),Et=Z==null?V:ts(Z),W=Ae==null?V:ts(Ae),V=new We(he,z+"leave",Z,a,oe),V.target=Et,V.relatedTarget=W,he=null,At(oe)===q&&(We=new We(P,z+"enter",Ae,a,oe),We.target=W,We.relatedTarget=Et,he=We),Et=he,Z&&Ae)t:{for(We=yx,P=Z,z=Ae,W=0,he=P;he;he=We(he))W++;he=0;for(var Ue=z;Ue;Ue=We(Ue))he++;for(;0<W-he;)P=We(P),W--;for(;0<he-W;)z=We(z),he--;for(;W--;){if(P===z||z!==null&&P===z.alternate){We=P;break t}P=We(P),z=We(z)}We=null}else We=null;Z!==null&&Tb(fe,V,Z,We,!1),Ae!==null&&Et!==null&&Tb(fe,Et,Ae,We,!0)}}e:{if(V=q?ts(q):window,Z=V.nodeName&&V.nodeName.toLowerCase(),Z==="select"||Z==="input"&&V.type==="file")var ft=Wg;else if(Kg(V))if(qg)ft=NC;else{ft=RC;var ze=DC}else Z=V.nodeName,!Z||Z.toLowerCase()!=="input"||V.type!=="checkbox"&&V.type!=="radio"?q&&Js(q.elementType)&&(ft=Wg):ft=MC;if(ft&&(ft=ft(i,q))){Fg(fe,ft,a,oe);break e}ze&&ze(i,V,q),i==="focusout"&&q&&V.type==="number"&&q.memoizedProps.value!=null&&$r(V,"number",V.value)}switch(ze=q?ts(q):window,i){case"focusin":(Kg(ze)||ze.contentEditable==="true")&&(Ba=ze,Uh=q,Pl=null);break;case"focusout":Pl=Uh=Ba=null;break;case"mousedown":Ih=!0;break;case"contextmenu":case"mouseup":case"dragend":Ih=!1,Jg(fe,a,oe);break;case"selectionchange":if(LC)break;case"keydown":case"keyup":Jg(fe,a,oe)}var Qe;if(zh)e:{switch(i){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else La?Ug(i,a)&&(ut="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(ut="onCompositionStart");ut&&(jg&&a.locale!=="ko"&&(La||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&La&&(Qe=j()):(jn=oe,x="value"in jn?jn.value:jn.textContent,La=!0)),ze=lu(q,ut),0<ze.length&&(ut=new Og(ut,i,null,a,oe),fe.push({event:ut,listeners:ze}),Qe?ut.data=Qe:(Qe=Ig(a),Qe!==null&&(ut.data=Qe)))),(Qe=CC?xC(i,a):EC(i,a))&&(ut=lu(q,"onBeforeInput"),0<ut.length&&(ze=new Og("onBeforeInput","beforeinput",null,a,oe),fe.push({event:ze,listeners:ut}),ze.data=Qe)),gx(fe,i,q,a,oe)}Eb(fe,n)})}function uo(i,n,a){return{instance:i,listener:n,currentTarget:a}}function lu(i,n){for(var a=n+"Capture",l=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=Bt(i,a),u!=null&&l.unshift(uo(i,u,d)),u=Bt(i,n),u!=null&&l.push(uo(i,u,d))),i.tag===3)return l;i=i.return}return[]}function yx(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Tb(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,N=C.alternate,q=C.stateNode;if(C=C.tag,N!==null&&N===l)break;C!==5&&C!==26&&C!==27||q===null||(N=q,u?(q=Bt(a,d),q!=null&&_.unshift(uo(a,q,N))):u||(q=Bt(a,d),q!=null&&_.push(uo(a,q,N)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var Sx=/\r\n?/g,wx=/\u0000|\uFFFD/g;function Db(i){return(typeof i=="string"?i:""+i).replace(Sx,`
|
|
10
|
+
`).replace(wx,"")}function Rb(i,n){return n=Db(n),Db(i)===n}function xt(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||ms(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&ms(i,""+l);break;case"className":ns(i,"class",l);break;case"tabIndex":ns(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":ns(i,a,l);break;case"style":Ds(i,l,d);break;case"data":if(n!=="object"){ns(i,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=M(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="formAction"?(n!=="input"&&xt(i,n,"name",u.name,u,null),xt(i,n,"formEncType",u.formEncType,u,null),xt(i,n,"formMethod",u.formMethod,u,null),xt(i,n,"formTarget",u.formTarget,u,null)):(xt(i,n,"encType",u.encType,u,null),xt(i,n,"method",u.method,u,null),xt(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=M(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=J);break;case"onScroll":l!=null&<("scroll",i);break;case"onScrollEnd":l!=null&<("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=M(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":lt("beforetoggle",i),lt("toggle",i),Qs(i,"popover",l);break;case"xlinkActuate":vn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":vn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":vn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":vn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":vn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":vn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":vn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":vn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":vn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Qs(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=yn.get(a)||a,Qs(i,a,l))}}function ff(i,n,a,l,u,d){switch(a){case"style":Ds(i,l,d);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?ms(i,l):(typeof l=="number"||typeof l=="bigint")&&ms(i,""+l);break;case"onScroll":l!=null&<("scroll",i);break;case"onScrollEnd":l!=null&<("scrollend",i);break;case"onClick":l!=null&&(i.onclick=J);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ur.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),n=a.slice(2,u?a.length-7:void 0),d=i[Ei]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof l=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Qs(i,a,l)}}}function Wi(i,n,a){switch(n){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 l=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:xt(i,n,d,_,a,null)}}u&&xt(i,n,"srcSet",a.srcSet,a,null),l&&xt(i,n,"src",a.src,a,null);return;case"input":lt("invalid",i);var C=d=_=u=null,N=null,q=null;for(l in a)if(a.hasOwnProperty(l)){var oe=a[l];if(oe!=null)switch(l){case"name":u=oe;break;case"type":_=oe;break;case"checked":N=oe;break;case"defaultChecked":q=oe;break;case"value":d=oe;break;case"defaultValue":C=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,n));break;default:xt(i,n,l,oe,a,null)}}qr(i,d,C,N,q,_,u,!1);return;case"select":lt("invalid",i),l=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(C=a[u],C!=null))switch(u){case"value":d=C;break;case"defaultValue":_=C;break;case"multiple":l=C;default:xt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?zn(i,!!l,n,!1):a!=null&&zn(i,!!l,a,!0);return;case"textarea":lt("invalid",i),d=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":l=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(r(91));break;default:xt(i,n,_,C,a,null)}Na(i,l,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(l=a[N],l!=null)&&(N==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":xt(i,n,N,l,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(l=0;l<co.length;l++)lt(co[l],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(q in a)if(a.hasOwnProperty(q)&&(l=a[q],l!=null))switch(q){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:xt(i,n,q,l,a,null)}return;default:if(Js(n)){for(oe in a)a.hasOwnProperty(oe)&&(l=a[oe],l!==void 0&&ff(i,n,oe,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&xt(i,n,C,l,a,null))}function Cx(i,n,a,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,C=null,N=null,q=null,oe=null;for(Z in a){var fe=a[Z];if(a.hasOwnProperty(Z)&&fe!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":N=fe;default:l.hasOwnProperty(Z)||xt(i,n,Z,null,l,fe)}}for(var V in l){var Z=l[V];if(fe=a[V],l.hasOwnProperty(V)&&(Z!=null||fe!=null))switch(V){case"type":d=Z;break;case"name":u=Z;break;case"checked":q=Z;break;case"defaultChecked":oe=Z;break;case"value":_=Z;break;case"defaultValue":C=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(r(137,n));break;default:Z!==fe&&xt(i,n,V,Z,l,fe)}}Wr(i,_,C,N,q,oe,d,u);return;case"select":Z=_=C=V=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":Z=N;default:l.hasOwnProperty(d)||xt(i,n,d,null,l,N)}for(u in l)if(d=l[u],N=a[u],l.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":V=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==N&&xt(i,n,u,d,l,N)}n=C,a=_,l=Z,V!=null?zn(i,!!a,V,!1):!!l!=!!a&&(n!=null?zn(i,!!a,n,!0):zn(i,!!a,a?[]:"",!1));return;case"textarea":Z=V=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!l.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:xt(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":V=u;break;case"defaultValue":Z=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==d&&xt(i,n,_,u,l,d)}rs(i,V,Z);return;case"option":for(var Ae in a)V=a[Ae],a.hasOwnProperty(Ae)&&V!=null&&!l.hasOwnProperty(Ae)&&(Ae==="selected"?i.selected=!1:xt(i,n,Ae,null,l,V));for(N in l)V=l[N],Z=a[N],l.hasOwnProperty(N)&&V!==Z&&(V!=null||Z!=null)&&(N==="selected"?i.selected=V&&typeof V!="function"&&typeof V!="symbol":xt(i,n,N,V,l,Z));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 We in a)V=a[We],a.hasOwnProperty(We)&&V!=null&&!l.hasOwnProperty(We)&&xt(i,n,We,null,l,V);for(q in l)if(V=l[q],Z=a[q],l.hasOwnProperty(q)&&V!==Z&&(V!=null||Z!=null))switch(q){case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(r(137,n));break;default:xt(i,n,q,V,l,Z)}return;default:if(Js(n)){for(var Et in a)V=a[Et],a.hasOwnProperty(Et)&&V!==void 0&&!l.hasOwnProperty(Et)&&ff(i,n,Et,void 0,l,V);for(oe in l)V=l[oe],Z=a[oe],!l.hasOwnProperty(oe)||V===Z||V===void 0&&Z===void 0||ff(i,n,oe,V,l,Z);return}}for(var P in a)V=a[P],a.hasOwnProperty(P)&&V!=null&&!l.hasOwnProperty(P)&&xt(i,n,P,null,l,V);for(fe in l)V=l[fe],Z=a[fe],!l.hasOwnProperty(fe)||V===Z||V==null&&Z==null||xt(i,n,fe,V,l,Z)}function Mb(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function xx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&Mb(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var N=a[l],q=N.startTime;if(q>C)break;var oe=N.transferSize,fe=N.initiatorType;oe&&Mb(fe)&&(N=N.responseEnd,_+=oe*(N<C?1:(C-q)/(N-q)))}if(--l,n+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return n/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var pf=null,mf=null;function ou(i){return i.nodeType===9?i:i.ownerDocument}function Nb(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 Ab(i,n){if(i===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&n==="foreignObject"?0:i}function gf(i,n){return i==="textarea"||i==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var _f=null;function Ex(){var i=window.event;return i&&i.type==="popstate"?i===_f?!1:(_f=i,!0):(_f=null,!1)}var Lb=typeof setTimeout=="function"?setTimeout:void 0,kx=typeof clearTimeout=="function"?clearTimeout:void 0,Bb=typeof Promise=="function"?Promise:void 0,Tx=typeof queueMicrotask=="function"?queueMicrotask:typeof Bb<"u"?function(i){return Bb.resolve(null).then(i).catch(Dx)}:Lb;function Dx(i){setTimeout(function(){throw i})}function _r(i){return i==="head"}function Ob(i,n){var a=n,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),ll(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")ho(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,ho(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[Jn]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&ho(i.ownerDocument.body);a=u}while(a);ll(n)}function zb(i,n){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function vf(i){var n=i.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":vf(a),fs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Rx(i,n,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Jn])switch(n){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(n==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=Wn(i.nextSibling),i===null)break}return null}function Mx(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Wn(i.nextSibling),i===null))return null;return i}function jb(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=Wn(i.nextSibling),i===null))return null;return i}function bf(i){return i.data==="$?"||i.data==="$~"}function yf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Nx(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var l=function(){n(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function Wn(i){for(;i!=null;i=i.nextSibling){var n=i.nodeType;if(n===1||n===3)break;if(n===8){if(n=i.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return i}var Sf=null;function Hb(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return Wn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function Pb(i){i=i.previousSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return i;n--}else a!=="/$"&&a!=="/&"||n++}i=i.previousSibling}return null}function Ub(i,n,a){switch(n=ou(a),i){case"html":if(i=n.documentElement,!i)throw Error(r(452));return i;case"head":if(i=n.head,!i)throw Error(r(453));return i;case"body":if(i=n.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function ho(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);fs(i)}var qn=new Map,Ib=new Set;function cu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Fs=$.d;$.d={f:Ax,r:Lx,D:Bx,C:Ox,L:zx,m:jx,X:Px,S:Hx,M:Ux};function Ax(){var i=Fs.f(),n=eu();return i||n}function Lx(i){var n=es(i);n!==null&&n.tag===5&&n.type==="form"?sv(n):Fs.r(i)}var sl=typeof document>"u"?null:document;function Kb(i,n,a){var l=sl;if(l&&typeof n=="string"&&n){var u=Pi(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),Ib.has(u)||(Ib.add(u),i={rel:i,crossOrigin:a,href:n},l.querySelector(u)===null&&(n=l.createElement("link"),Wi(n,"link",i),ot(n),l.head.appendChild(n)))}}function Bx(i){Fs.D(i),Kb("dns-prefetch",i,null)}function Ox(i,n){Fs.C(i,n),Kb("preconnect",i,n)}function zx(i,n,a){Fs.L(i,n,a);var l=sl;if(l&&i&&n){var u='link[rel="preload"][as="'+Pi(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Pi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Pi(a.imageSizes)+'"]')):u+='[href="'+Pi(i)+'"]';var d=u;switch(n){case"style":d=rl(i);break;case"script":d=al(i)}qn.has(d)||(i=b({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),qn.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(fo(d))||n==="script"&&l.querySelector(po(d))||(n=l.createElement("link"),Wi(n,"link",i),ot(n),l.head.appendChild(n)))}}function jx(i,n){Fs.m(i,n);var a=sl;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Pi(l)+'"][href="'+Pi(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=al(i)}if(!qn.has(d)&&(i=b({rel:"modulepreload",href:i},n),qn.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(po(d)))return}l=a.createElement("link"),Wi(l,"link",i),ot(l),a.head.appendChild(l)}}}function Hx(i,n,a){Fs.S(i,n,a);var l=sl;if(l&&i){var u=Vi(l).hoistableStyles,d=rl(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(fo(d)))C.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":n},a),(a=qn.get(d))&&wf(i,a);var N=_=l.createElement("link");ot(N),Wi(N,"link",i),N._p=new Promise(function(q,oe){N.onload=q,N.onerror=oe}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,uu(_,n,l)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function Px(i,n){Fs.X(i,n);var a=sl;if(a&&i){var l=Vi(a).hoistableScripts,u=al(i),d=l.get(u);d||(d=a.querySelector(po(u)),d||(i=b({src:i,async:!0},n),(n=qn.get(u))&&Cf(i,n),d=a.createElement("script"),ot(d),Wi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Ux(i,n){Fs.M(i,n);var a=sl;if(a&&i){var l=Vi(a).hoistableScripts,u=al(i),d=l.get(u);d||(d=a.querySelector(po(u)),d||(i=b({src:i,async:!0,type:"module"},n),(n=qn.get(u))&&Cf(i,n),d=a.createElement("script"),ot(d),Wi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Fb(i,n,a,l){var u=(u=xe.current)?cu(u):null;if(!u)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=rl(a.href),a=Vi(u).hoistableStyles,l=a.get(n),l||(l={type:"style",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=rl(a.href);var d=Vi(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(fo(i)))&&!d._p&&(_.instance=d,_.state.loading=5),qn.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},qn.set(i,a),d||Ix(u,i,a,_.state))),n&&l===null)throw Error(r(528,""));return _}if(n&&l!==null)throw Error(r(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=al(a),a=Vi(u).hoistableScripts,l=a.get(n),l||(l={type:"script",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function rl(i){return'href="'+Pi(i)+'"'}function fo(i){return'link[rel="stylesheet"]['+i+"]"}function Wb(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function Ix(i,n,a,l){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=i.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Wi(n,"link",a),ot(n),i.head.appendChild(n))}function al(i){return'[src="'+Pi(i)+'"]'}function po(i){return"script[async]"+i}function qb(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+Pi(a.href)+'"]');if(l)return n.instance=l,ot(l),l;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),ot(l),Wi(l,"style",u),uu(l,a.precedence,i),n.instance=l;case"stylesheet":u=rl(a.href);var d=i.querySelector(fo(u));if(d)return n.state.loading|=4,n.instance=d,ot(d),d;l=Wb(a),(u=qn.get(u))&&wf(l,u),d=(i.ownerDocument||i).createElement("link"),ot(d);var _=d;return _._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Wi(d,"link",l),n.state.loading|=4,uu(d,a.precedence,i),n.instance=d;case"script":return d=al(a.src),(u=i.querySelector(po(d)))?(n.instance=u,ot(u),u):(l=a,(u=qn.get(d))&&(l=b({},a),Cf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),ot(u),Wi(u,"link",l),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(r(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,uu(l,a.precedence,i));return n.instance}function uu(i,n,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,d=u,_=0;_<l.length;_++){var C=l[_];if(C.dataset.precedence===n)d=C;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(i,n.firstChild))}function wf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function Cf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var hu=null;function $b(i,n,a){if(hu===null){var l=new Map,u=hu=new Map;u.set(a,l)}else u=hu,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Jn]||d[Kt]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=l.get(_);C?C.push(d):l.set(_,[d])}}return l}function Yb(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function Kx(i,n,a){if(a===1||n.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(i=n.disabled,typeof n.precedence=="string"&&i==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Vb(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Fx(i,n,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=rl(l.href),d=n.querySelector(fo(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=du.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,ot(d);return}d=n.ownerDocument||n,l=Wb(l),(u=qn.get(u))&&wf(l,u),d=d.createElement("link"),ot(d);var _=d;_._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Wi(d,"link",l),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=du.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var xf=0;function Wx(i,n){return i.stylesheets&&i.count===0&&pu(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&pu(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&xf===0&&(xf=62500*xx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&pu(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>xf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function du(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)pu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var fu=null;function pu(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,fu=new Map,n.forEach(qx,i),fu=null,du.call(i))}function qx(i,n){if(!(n.state.loading&4)){var a=fu.get(i);if(a)var l=a.get(null);else{a=new Map,fu.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||l,d===l&&a.set(null,u),a.set(_,u),this.count++,l=du.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var mo={$$typeof:U,Provider:null,Consumer:null,_currentValue:D,_currentValue2:D,_threadCount:0};function $x(i,n,a,l,u,d,_,C,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ei(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ei(0),this.hiddenUpdates=ei(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function Xb(i,n,a,l,u,d,_,C,N,q,oe,fe){return i=new $x(i,n,a,_,N,q,oe,fe,C),n=1,d===!0&&(n|=24),d=Cn(3,null,null,n),i.current=d,d.stateNode=i,n=id(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},ad(d),i}function Gb(i){return i?(i=ja,i):ja}function Zb(i,n,a,l,u,d){u=Gb(u),l.context===null?l.context=u:l.pendingContext=u,l=ar(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=lr(i,l,n),a!==null&&(hn(a,i,n),$l(a,i,n))}function Qb(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function Ef(i,n){Qb(i,n),(i=i.alternate)&&Qb(i,n)}function Jb(i){if(i.tag===13||i.tag===31){var n=Xr(i,67108864);n!==null&&hn(n,i,67108864),Ef(i,67108864)}}function ey(i){if(i.tag===13||i.tag===31){var n=Dn();n=rn(n);var a=Xr(i,n);a!==null&&hn(a,i,n),Ef(i,n)}}var mu=!0;function Yx(i,n,a,l){var u=B.T;B.T=null;var d=$.p;try{$.p=2,kf(i,n,a,l)}finally{$.p=d,B.T=u}}function Vx(i,n,a,l){var u=B.T;B.T=null;var d=$.p;try{$.p=8,kf(i,n,a,l)}finally{$.p=d,B.T=u}}function kf(i,n,a,l){if(mu){var u=Tf(l);if(u===null)df(i,n,l,gu,a),iy(i,l);else if(Gx(u,i,n,a,l))l.stopPropagation();else if(iy(i,l),n&4&&-1<Xx.indexOf(i)){for(;u!==null;){var d=es(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=Tt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var N=1<<31-St(_);C.entanglements[1]|=N,_&=~N}bs(d),(mt&6)===0&&(Qc=rt()+500,oo(0))}}break;case 31:case 13:C=Xr(d,2),C!==null&&hn(C,d,2),eu(),Ef(d,2)}if(d=Tf(l),d===null&&df(i,n,l,gu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else df(i,n,l,null,a)}}function Tf(i){return i=Fe(i),Df(i)}var gu=null;function Df(i){if(gu=null,i=At(i),i!==null){var n=c(i);if(n===null)i=null;else{var a=n.tag;if(a===13){if(i=h(n),i!==null)return i;i=null}else if(a===31){if(i=f(n),i!==null)return i;i=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;i=null}else n!==i&&(i=null)}}return gu=i,null}function ty(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(Oi()){case $i:return 2;case Ci:return 8;case ri:case zi:return 32;case sn:return 268435456;default:return 32}default:return 32}}var Rf=!1,vr=null,br=null,yr=null,go=new Map,_o=new Map,Sr=[],Xx="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 iy(i,n){switch(i){case"focusin":case"focusout":vr=null;break;case"dragenter":case"dragleave":br=null;break;case"mouseover":case"mouseout":yr=null;break;case"pointerover":case"pointerout":go.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":_o.delete(n.pointerId)}}function vo(i,n,a,l,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:l,nativeEvent:d,targetContainers:[u]},n!==null&&(n=es(n),n!==null&&Jb(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function Gx(i,n,a,l,u){switch(n){case"focusin":return vr=vo(vr,i,n,a,l,u),!0;case"dragenter":return br=vo(br,i,n,a,l,u),!0;case"mouseover":return yr=vo(yr,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return go.set(d,vo(go.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,_o.set(d,vo(_o.get(d)||null,i,n,a,l,u)),!0}return!1}function ny(i){var n=At(i.target);if(n!==null){var a=c(n);if(a!==null){if(n=a.tag,n===13){if(n=h(a),n!==null){i.blockedOn=n,gn(i.priority,function(){ey(a)});return}}else if(n===31){if(n=f(a),n!==null){i.blockedOn=n,gn(i.priority,function(){ey(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function _u(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=Tf(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);je=l,a.target.dispatchEvent(l),je=null}else return n=es(a),n!==null&&Jb(n),i.blockedOn=a,!1;n.shift()}return!0}function sy(i,n,a){_u(i)&&a.delete(n)}function Zx(){Rf=!1,vr!==null&&_u(vr)&&(vr=null),br!==null&&_u(br)&&(br=null),yr!==null&&_u(yr)&&(yr=null),go.forEach(sy),_o.forEach(sy)}function vu(i,n){i.blockedOn===n&&(i.blockedOn=null,Rf||(Rf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Zx)))}var bu=null;function ry(i){bu!==i&&(bu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){bu===i&&(bu=null);for(var n=0;n<i.length;n+=3){var a=i[n],l=i[n+1],u=i[n+2];if(typeof l!="function"){if(Df(l||a)===null)continue;break}var d=es(a);d!==null&&(i.splice(n,3),n-=3,kd(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function ll(i){function n(N){return vu(N,i)}vr!==null&&vu(vr,i),br!==null&&vu(br,i),yr!==null&&vu(yr,i),go.forEach(n),_o.forEach(n);for(var a=0;a<Sr.length;a++){var l=Sr[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Sr.length&&(a=Sr[0],a.blockedOn===null);)ny(a),a.blockedOn===null&&Sr.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],d=a[l+1],_=u[Ei]||null;if(typeof d=="function")_||ry(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[Ei]||null)C=_.formAction;else if(Df(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),ry(a)}}}function ay(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Mf(i){this._internalRoot=i}yu.prototype.render=Mf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(r(409));var a=n.current,l=Dn();Zb(a,l,i,n,null,null)},yu.prototype.unmount=Mf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Zb(i.current,2,null,i,null,null),eu(),n[Bn]=null}};function yu(i){this._internalRoot=i}yu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Qi();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Sr.length&&n!==0&&n<Sr[a].priority;a++);Sr.splice(a,0,i),a===0&&ny(i)}};var ly=t.version;if(ly!=="19.2.6")throw Error(r(527,ly,"19.2.6"));$.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(n),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var Qx={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{dt=Su.inject(Qx),vt=Su}catch{}}return yo.createRoot=function(i,n){if(!o(i))throw Error(r(299));var a=!1,l="",u=pv,d=mv,_=gv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=Xb(i,1,!1,null,null,a,l,null,u,d,_,ay),i[Bn]=n.current,hf(i),new Mf(n)},yo.hydrateRoot=function(i,n,a){if(!o(i))throw Error(r(299));var l=!1,u="",d=pv,_=mv,C=gv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(C=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),n=Xb(i,1,!0,n,a??null,l,u,N,d,_,C,ay),n.context=Gb(null),a=n.current,l=Dn(),l=rn(l),u=ar(l),u.callback=null,lr(a,u,l),a=l,n.current.lanes=a,ji(n,a),bs(n),i[Bn]=n.current,hf(i),new yu(n)},yo.version="19.2.6",yo}var _y;function oE(){if(_y)return Lf.exports;_y=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(),Lf.exports=lE(),Lf.exports}var cE=oE();class us extends Error{constructor(t,s){super(s),this.status=t,this.name="ApiError"}status}function fh(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Ko(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",st("POST",t)),login:t=>Ne(e,"/api/auth/login",st("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",st("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",st("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",st("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await hl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",st("POST",t)),removeNetwork:async t=>{await hl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),getDistributedCallSettings:()=>Ne(e,"/api/distcalls/settings"),updateDistributedCallSettings:t=>Ne(e,"/api/distcalls/settings",st("PUT",t)),addAgent:t=>Ne(e,"/api/agents",st("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",st("PUT",{serverIds:t})),renameAgent:(t,s)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,st("PATCH",{name:s})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",st("PATCH",{name:t})),removeAgent:async t=>{await hl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ne(e,"/api/stats"),getAgentStats:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ne(e,"/api/version"),checkUpdate:()=>Ne(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ne(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ne(e,"/api/terminals"),getTerminalLayout:()=>Ne(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ne(e,"/api/terminal-layout",st("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",st("POST",t)),listFiles:t=>Ne(e,"/api/files/list",st("POST",t)),readFile:t=>Ne(e,"/api/files/read",st("POST",t)),writeFile:t=>Ne(e,"/api/files/write",st("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",st("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",st("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",st("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",st("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",st("POST",t)),previewFile:t=>b0(e,"/api/files/preview",st("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",st("POST",t)),closeTerminal:async t=>{await hl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,s)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,st("PATCH",{title:s})),getTerminalHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Ko(s)}`),getTerminalTranscriptHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Ko(s)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const s=new FormData;return s.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:s})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",st("PUT",t)),deleteNotificationAsset:async t=>{await hl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function Go(e,t=fetch){const s=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,s("terminals")),createTerminal:(r={})=>Ne(t,s("terminals"),st("POST",r)),closeTerminal:async r=>{await hl(t,s(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ne(t,s(`terminals/${encodeURIComponent(r)}`),st("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/history`)}${Ko(o)}`),getTerminalTranscriptHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Ko(o)}`),getTerminalTranscriptSource:r=>Ne(t,s(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalLayout:()=>Ne(t,s("terminal-layout")),saveTerminalLayout:r=>Ne(t,s("terminal-layout"),st("PUT",r)),createFileRoot:r=>Ne(t,s("files/root"),st("POST",r)),listFiles:r=>Ne(t,s("files/list"),st("POST",r)),readFile:r=>Ne(t,s("files/read"),st("POST",r)),writeFile:r=>Ne(t,s("files/write"),st("POST",r)),createFileEntry:r=>Ne(t,s("files/create"),st("POST",r)),moveFileEntry:r=>Ne(t,s("files/move"),st("POST",r)),previewDeleteFileEntry:r=>Ne(t,s("files/delete-preview"),st("POST",r)),deleteFileEntry:r=>Ne(t,s("files/delete"),st("POST",r)),openFileInTerminal:r=>Ne(t,s("files/open"),st("POST",r)),previewFile:r=>b0(t,s("files/preview"),st("POST",r)),createWebSocketUrl:(r,o=window.location.href)=>uE(s(`terminals/${encodeURIComponent(r)}/ws`),o)}}function uE(e,t){const s=new URL(t);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.pathname=e,s.search="",s.hash="",s.toString()}function st(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Ko(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource);const s=t.toString();return s?`?${s}`:""}async function Ne(e,t,s){const r=await e(t,s??{credentials:"same-origin"});await Im(r);try{return await r.json()}catch{throw new us(r.status,"invalid_json_response")}}async function hl(e,t,s){const r=await e(t,s);await Im(r)}async function b0(e,t,s){const r=await e(t,s);return await Im(r),r.blob()}async function Im(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const s=await e.json(),r=typeof s.error=="string"?s.error:s.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new us(e.status,t)}const Km="nterminal.theme.id",y0="nterminal.theme.accent",pp="nterminal:theme",Yu=[{id:"midnight",label:"Midnight",description:"Current dark terminal look with aqua focus.",mode:"dark",tokens:{bg:"#0a0d10",bg2:"#0d1216",bgSidebar:"#08090b",line:"#1a2128",line2:"#2a3340",fg:"#e2e8ee",fg2:"#8896a3",fg3:"#54616d",fg4:"#3f4a54",accent:"#5eead4",accentSoft:"rgba(94, 234, 212, 0.10)",accentGlow:"rgba(94, 234, 212, 0.55)",onAccent:"#062423",ok:"#34d399",danger:"#f87171",onDanger:"#190607",dangerSoft:"rgba(248, 113, 113, 0.08)",dangerLine:"rgba(248, 113, 113, 0.30)",warning:"#fbbf24",warningSoft:"rgba(247, 217, 119, 0.075)",warningGlow:"rgba(245, 158, 11, 0.55)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.35)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(10, 13, 16, 0.86)",floatingBgStrong:"rgba(10, 13, 16, 0.96)",floatingBgHover:"rgba(15, 23, 27, 0.94)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.015)",scrollbarThumb:"rgba(148, 163, 184, 0.50)",scrollbarThumbHover:"rgba(148, 163, 184, 0.70)",transcriptUser:"#f7d977",transcriptAssistant:"#5eead4",transcriptTool:"#9aa7b4",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f7d977",transcriptOnSearch:"#121417",qrBg:"#ffffff"},xterm:{background:"#0a0d10",foreground:"#e2e8ee",cursor:"#5eead4",selectionBackground:"#1f3f45"}},{id:"daylight",label:"Daylight",description:"Light workspace with dark terminal contrast.",mode:"light",tokens:{bg:"#f7f9fc",bg2:"#ffffff",bgSidebar:"#eef2f7",line:"#dbe3ec",line2:"#c3cedb",fg:"#17212b",fg2:"#526170",fg3:"#7b8794",fg4:"#a1acb8",accent:"#0f8f83",accentSoft:"rgba(15, 143, 131, 0.11)",accentGlow:"rgba(15, 143, 131, 0.24)",onAccent:"#021918",ok:"#16835c",danger:"#c03545",onDanger:"#fff7f8",dangerSoft:"rgba(192, 53, 69, 0.10)",dangerLine:"rgba(192, 53, 69, 0.30)",warning:"#b7791f",warningSoft:"rgba(183, 121, 31, 0.12)",warningGlow:"rgba(183, 121, 31, 0.26)",scrim:"rgba(15, 23, 42, 0.34)",scrimSoft:"rgba(15, 23, 42, 0.20)",shadow:"rgba(15, 23, 42, 0.18)",shadowStrong:"rgba(15, 23, 42, 0.28)",floatingBg:"rgba(255, 255, 255, 0.92)",floatingBgStrong:"rgba(255, 255, 255, 0.98)",floatingBgHover:"rgba(239, 246, 249, 0.96)",subtleFill:"rgba(15, 23, 42, 0.025)",hoverFill:"rgba(15, 23, 42, 0.035)",scrollbarThumb:"rgba(82, 97, 112, 0.38)",scrollbarThumbHover:"rgba(82, 97, 112, 0.58)",transcriptUser:"#8b3f75",transcriptAssistant:"#0f8f83",transcriptTool:"#66717d",transcriptCommand:"#0b6fa4",transcriptCode:"#075985",transcriptSearch:"#f0c14b",transcriptOnSearch:"#1f1a10",qrBg:"#ffffff"},xterm:{background:"#ffffff",foreground:"#17212b",cursor:"#0f8f83",selectionBackground:"#cdeee9",...vy({foreground:"#17212b",foregroundMuted:"#526170",line:"#dbe3ec",red:"#b4232f",green:"#16794f",yellow:"#9a6700",blue:"#0b6fa4",magenta:"#8f3f85",cyan:"#0f766e"})}},{id:"signal-red",label:"Signal",description:"Dark control-room surface with red alerts.",mode:"dark",tokens:{bg:"#100d0f",bg2:"#171113",bgSidebar:"#0b080a",line:"#2a1b20",line2:"#452b32",fg:"#f1e7e9",fg2:"#a58d93",fg3:"#765f66",fg4:"#55434a",accent:"#ff2a3d",accentSoft:"rgba(255, 42, 61, 0.12)",accentGlow:"rgba(255, 42, 61, 0.52)",onAccent:"#210407",ok:"#34d399",danger:"#ff4d5f",onDanger:"#210407",dangerSoft:"rgba(255, 77, 95, 0.10)",dangerLine:"rgba(255, 77, 95, 0.32)",warning:"#fbbf24",warningSoft:"rgba(251, 191, 36, 0.10)",warningGlow:"rgba(245, 158, 11, 0.50)",scrim:"rgba(0, 0, 0, 0.58)",scrimSoft:"rgba(0, 0, 0, 0.30)",shadow:"rgba(0, 0, 0, 0.36)",shadowStrong:"rgba(0, 0, 0, 0.52)",floatingBg:"rgba(16, 13, 15, 0.88)",floatingBgStrong:"rgba(16, 13, 15, 0.96)",floatingBgHover:"rgba(25, 16, 19, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(165, 141, 147, 0.45)",scrollbarThumbHover:"rgba(165, 141, 147, 0.65)",transcriptUser:"#f8d36f",transcriptAssistant:"#ff2a3d",transcriptTool:"#ad9ca2",transcriptCommand:"#ff9ca6",transcriptCode:"#ffd1d6",transcriptSearch:"#f8d36f",transcriptOnSearch:"#1b0e10",qrBg:"#ffffff"},xterm:{background:"#100d0f",foreground:"#f1e7e9",cursor:"#ff2a3d",selectionBackground:"#4a1b22"}},{id:"graphite",label:"Graphite",description:"Neutral dark theme with blue command focus.",mode:"dark",tokens:{bg:"#101214",bg2:"#171a1d",bgSidebar:"#0c0e10",line:"#262b30",line2:"#39414a",fg:"#eceff3",fg2:"#9aa4af",fg3:"#6c7680",fg4:"#4d5660",accent:"#7dd3fc",accentSoft:"rgba(125, 211, 252, 0.11)",accentGlow:"rgba(125, 211, 252, 0.38)",onAccent:"#071c26",ok:"#4ade80",danger:"#fb7185",onDanger:"#26070d",dangerSoft:"rgba(251, 113, 133, 0.09)",dangerLine:"rgba(251, 113, 133, 0.30)",warning:"#facc15",warningSoft:"rgba(250, 204, 21, 0.09)",warningGlow:"rgba(250, 204, 21, 0.42)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.34)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(16, 18, 20, 0.88)",floatingBgStrong:"rgba(16, 18, 20, 0.96)",floatingBgHover:"rgba(22, 28, 33, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(154, 164, 175, 0.45)",scrollbarThumbHover:"rgba(154, 164, 175, 0.65)",transcriptUser:"#f2d675",transcriptAssistant:"#7dd3fc",transcriptTool:"#aab4bf",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f2d675",transcriptOnSearch:"#141513",qrBg:"#ffffff"},xterm:{background:"#101214",foreground:"#eceff3",cursor:"#7dd3fc",selectionBackground:"#263d4b"}},{id:"paper",label:"Paper",description:"Warm light surface with restrained amber accent.",mode:"light",tokens:{bg:"#fbfaf7",bg2:"#ffffff",bgSidebar:"#f2f0ea",line:"#e2ddd4",line2:"#cbc3b6",fg:"#25211d",fg2:"#62584e",fg3:"#8d8275",fg4:"#afa69b",accent:"#a35d00",accentSoft:"rgba(163, 93, 0, 0.11)",accentGlow:"rgba(163, 93, 0, 0.24)",onAccent:"#fffaf2",ok:"#26744d",danger:"#b23a48",onDanger:"#fff8f8",dangerSoft:"rgba(178, 58, 72, 0.10)",dangerLine:"rgba(178, 58, 72, 0.30)",warning:"#a35d00",warningSoft:"rgba(163, 93, 0, 0.12)",warningGlow:"rgba(163, 93, 0, 0.26)",scrim:"rgba(37, 33, 29, 0.32)",scrimSoft:"rgba(37, 33, 29, 0.18)",shadow:"rgba(37, 33, 29, 0.18)",shadowStrong:"rgba(37, 33, 29, 0.28)",floatingBg:"rgba(255, 253, 249, 0.92)",floatingBgStrong:"rgba(255, 253, 249, 0.98)",floatingBgHover:"rgba(250, 247, 240, 0.96)",subtleFill:"rgba(37, 33, 29, 0.025)",hoverFill:"rgba(37, 33, 29, 0.035)",scrollbarThumb:"rgba(98, 88, 78, 0.35)",scrollbarThumbHover:"rgba(98, 88, 78, 0.55)",transcriptUser:"#7b3f8c",transcriptAssistant:"#a35d00",transcriptTool:"#776d63",transcriptCommand:"#176a94",transcriptCode:"#6f4b00",transcriptSearch:"#e9c46a",transcriptOnSearch:"#241b0a",qrBg:"#ffffff"},xterm:{background:"#fffdf9",foreground:"#25211d",cursor:"#a35d00",selectionBackground:"#f2dfc5",...vy({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],vl="midnight";function ph(e){return Yu.some(t=>t.id===e)?e:vl}function Fm(e){return Yu.find(t=>t.id===e)??Yu[0]}function Or(){if(typeof window>"u")return vl;try{const e=window.localStorage.getItem(Km);return e?ph(e):mE(window.localStorage.getItem(y0))}catch{return vl}}function hE(e){const t=ph(e);if(typeof window<"u"){try{window.localStorage.setItem(Km,t)}catch{}Wm(t),window.dispatchEvent(new CustomEvent(pp,{detail:t}))}return t}function Wm(e=Or()){if(typeof document>"u")return;const t=Fm(ph(e)),s=document.documentElement;s.dataset.ntTheme=t.id,s.style.setProperty("color-scheme",t.mode),Je(s,"--nt-bg",t.tokens.bg),Je(s,"--nt-bg-2",t.tokens.bg2),Je(s,"--nt-bg-sidebar",t.tokens.bgSidebar),Je(s,"--nt-line",t.tokens.line),Je(s,"--nt-line-2",t.tokens.line2),Je(s,"--nt-fg",t.tokens.fg),Je(s,"--nt-fg-2",t.tokens.fg2),Je(s,"--nt-fg-3",t.tokens.fg3),Je(s,"--nt-fg-4",t.tokens.fg4),Je(s,"--nt-accent",t.tokens.accent),Je(s,"--nt-accent-soft",t.tokens.accentSoft),Je(s,"--nt-accent-glow",t.tokens.accentGlow),Je(s,"--nt-on-accent",t.tokens.onAccent),Je(s,"--nt-ok",t.tokens.ok),Je(s,"--nt-danger",t.tokens.danger),Je(s,"--nt-on-danger",t.tokens.onDanger),Je(s,"--nt-danger-soft",t.tokens.dangerSoft),Je(s,"--nt-danger-line",t.tokens.dangerLine),Je(s,"--nt-warning",t.tokens.warning),Je(s,"--nt-warn",t.tokens.warning),Je(s,"--nt-warning-soft",t.tokens.warningSoft),Je(s,"--nt-warning-glow",t.tokens.warningGlow),Je(s,"--nt-scrim",t.tokens.scrim),Je(s,"--nt-scrim-soft",t.tokens.scrimSoft),Je(s,"--nt-shadow",t.tokens.shadow),Je(s,"--nt-shadow-strong",t.tokens.shadowStrong),Je(s,"--nt-floating-bg",t.tokens.floatingBg),Je(s,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),Je(s,"--nt-floating-bg-hover",t.tokens.floatingBgHover),Je(s,"--nt-subtle-fill",t.tokens.subtleFill),Je(s,"--nt-hover-fill",t.tokens.hoverFill),Je(s,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),Je(s,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),Je(s,"--nt-transcript-user",t.tokens.transcriptUser),Je(s,"--nt-transcript-assistant",t.tokens.transcriptAssistant),Je(s,"--nt-transcript-tool",t.tokens.transcriptTool),Je(s,"--nt-transcript-command",t.tokens.transcriptCommand),Je(s,"--nt-transcript-code",t.tokens.transcriptCode),Je(s,"--nt-transcript-search",t.tokens.transcriptSearch),Je(s,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),Je(s,"--nt-qr-bg",t.tokens.qrBg)}function dE(e=Or()){return Fm(ph(e)).xterm}function qm(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===Km||s.key===y0)&&(Wm(Or()),e())};return window.addEventListener(pp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(pp,e),window.removeEventListener("storage",t)}}function Je(e,t,s){e.style.setProperty(t,s)}function vy(e){const t=fE(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 fE(e){const t=[];for(let s=16;s<=e;s+=1)t.push(pE(s));return t}function pE(e){if(e>=16&&e<=231){const t=e-16,s=[0,95,135,175,215,255],r=s[Math.floor(t/36)%6],o=s[Math.floor(t/6)%6],c=s[t%6];return by(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return by(t,t,t)}return"#000000"}function by(e,t,s){return`#${jf(e)}${jf(t)}${jf(s)}`}function jf(e){return e.toString(16).padStart(2,"0")}function mE(e){return e==="signal-red"?"signal-red":vl}function S0(){const e=v.useSyncExternalStore(qm,Or,()=>vl);return Fm(e).mode==="light"?"-light":""}function w0({size:e=22}){const t=S0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function C0({height:e=18}){const t=S0(),s=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:s,height:e,alt:"NTerminal"})}var Ao=v0();const mh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function $m(e){return"nodeType"in e}function pn(e){var t,s;return e?xl(e)?e:$m(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Ym(e){const{Document:t}=pn(e);return e instanceof t}function cc(e){return xl(e)?!1:e instanceof pn(e).HTMLElement}function x0(e){return e instanceof pn(e).SVGElement}function El(e){return e?xl(e)?e.document:$m(e)?Ym(e)?e:cc(e)||x0(e)?e.ownerDocument:document:document:document}const zr=mh?v.useLayoutEffect:v.useEffect;function Vm(e){const t=v.useRef(e);return zr(()=>{t.current=e}),v.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function gE(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),s=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Zo(e,t){t===void 0&&(t=[e]);const s=v.useRef(e);return zr(()=>{s.current!==e&&(s.current=e)},t),s}function uc(e,t){const s=v.useRef();return v.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...t])}function Vu(e){const t=Vm(e),s=v.useRef(null),r=v.useCallback(o=>{o!==s.current&&t?.(o,s.current),s.current=o},[]);return[s,r]}function mp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Hf={};function gh(e,t){return v.useMemo(()=>{if(t)return t;const s=Hf[e]==null?0:Hf[e]+1;return Hf[e]=s,e+"-"+s},[e,t])}function E0(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return r.reduce((c,h)=>{const f=Object.entries(h);for(const[g,p]of f){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const gl=E0(1),Xu=E0(-1);function _E(e){return"clientX"in e&&"clientY"in e}function k0(e){if(!e)return!1;const{KeyboardEvent:t}=pn(e.target);return t&&e instanceof t}function vE(e){if(!e)return!1;const{TouchEvent:t}=pn(e.target);return t&&e instanceof t}function gp(e){if(vE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return _E(e)?{x:e.clientX,y:e.clientY}:null}const _p=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[_p.Translate.toString(e),_p.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:r}=e;return t+" "+s+"ms "+r}}}),yy="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function bE(e){return e.matches(yy)?e:e.querySelector(yy)}const yE={display:"none"};function SE(e){let{id:t,value:s}=e;return Si.createElement("div",{id:t,style:yE},s)}function wE(e){let{id:t,announcement:s,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 Si.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},s)}function CE(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const T0=v.createContext(null);function xE(e){const t=v.useContext(T0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function EE(){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:c}=r;e.forEach(h=>{var f;return(f=h[o])==null?void 0:f.call(h,c)})},[e]),t]}const kE={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
|
+
`},TE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function DE(e){let{announcements:t=TE,container:s,hiddenTextDescribedById:r,screenReaderInstructions:o=kE}=e;const{announce:c,announcement:h}=CE(),f=gh("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),xE(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:S}=b;t.onDragMove&&c(t.onDragMove({active:w,over:S}))},onDragOver(b){let{active:w,over:S}=b;c(t.onDragOver({active:w,over:S}))},onDragEnd(b){let{active:w,over:S}=b;c(t.onDragEnd({active:w,over:S}))},onDragCancel(b){let{active:w,over:S}=b;c(t.onDragCancel({active:w,over:S}))}}),[c,t])),!g)return null;const y=Si.createElement(Si.Fragment,null,Si.createElement(SE,{id:r,value:o.draggable}),Si.createElement(wE,{id:f,announcement:h}));return s?Ao.createPortal(y,s):y}var yi;(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"})(yi||(yi={}));function Gu(){}function Sy(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function RE(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const hs=Object.freeze({x:0,y:0});function ME(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return r-s}function NE(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function AE(e,t){const s=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=o-r,f=c-s;if(r<o&&s<c){const g=t.width*t.height,p=e.width*e.height,y=h*f,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const LE=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const o=[];for(const c of r){const{id:h}=c,f=s.get(h);if(f){const g=AE(f,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(ME)};function BE(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function D0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:hs}function OE(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((h,f)=>({...h,top:h.top+e*f.y,bottom:h.bottom+e*f.y,left:h.left+e*f.x,right:h.right+e*f.x}),{...s})}}const zE=OE(1);function jE(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 HE(e,t,s){const r=jE(t);if(!r)return e;const{scaleX:o,scaleY:c,x:h,y:f}=r,g=e.left-h-(1-o)*parseFloat(s),p=e.top-f-(1-c)*parseFloat(s.slice(s.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:p,right:g+y,bottom:p+b,left:g}}const PE={ignoreTransform:!1};function hc(e,t){t===void 0&&(t=PE);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=pn(e).getComputedStyle(e);p&&(s=HE(s,p,y))}const{top:r,left:o,width:c,height:h,bottom:f,right:g}=s;return{top:r,left:o,width:c,height:h,bottom:f,right:g}}function wy(e){return hc(e,{ignoreTransform:!0})}function UE(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function IE(e,t){return t===void 0&&(t=pn(e).getComputedStyle(e)),t.position==="fixed"}function KE(e,t){t===void 0&&(t=pn(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?s.test(c):!1})}function Xm(e,t){const s=[];function r(o){if(t!=null&&s.length>=t||!o)return s;if(Ym(o)&&o.scrollingElement!=null&&!s.includes(o.scrollingElement))return s.push(o.scrollingElement),s;if(!cc(o)||x0(o)||s.includes(o))return s;const c=pn(e).getComputedStyle(o);return o!==e&&KE(o,c)&&s.push(o),IE(o,c)?s:r(o.parentNode)}return e?r(e):s}function R0(e){const[t]=Xm(e,1);return t??null}function Pf(e){return!mh||!e?null:xl(e)?e:$m(e)?Ym(e)||e===El(e).scrollingElement?window:cc(e)?e:null:null}function M0(e){return xl(e)?e.scrollX:e.scrollLeft}function N0(e){return xl(e)?e.scrollY:e.scrollTop}function vp(e){return{x:M0(e),y:N0(e)}}var Ri;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ri||(Ri={}));function A0(e){return!mh||!e?!1:e===document.scrollingElement}function L0(e){const t={x:0,y:0},s=A0(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:h,isRight:f,maxScroll:r,minScroll:t}}const FE={x:.2,y:.2};function WE(e,t,s,r,o){let{top:c,left:h,right:f,bottom:g}=s;r===void 0&&(r=10),o===void 0&&(o=FE);const{isTop:p,isBottom:y,isLeft:b,isRight:w}=L0(e),S={x:0,y:0},E={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+T.height?(S.y=Ri.Backward,E.y=r*Math.abs((t.top+T.height-c)/T.height)):!y&&g>=t.bottom-T.height&&(S.y=Ri.Forward,E.y=r*Math.abs((t.bottom-T.height-g)/T.height)),!w&&f>=t.right-T.width?(S.x=Ri.Forward,E.x=r*Math.abs((t.right-T.width-f)/T.width)):!b&&h<=t.left+T.width&&(S.x=Ri.Backward,E.x=r*Math.abs((t.left+T.width-h)/T.width)),{direction:S,speed:E}}function qE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:s,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:s,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function B0(e){return e.reduce((t,s)=>gl(t,vp(s)),hs)}function $E(e){return e.reduce((t,s)=>t+M0(s),0)}function YE(e){return e.reduce((t,s)=>t+N0(s),0)}function VE(e,t){if(t===void 0&&(t=hc),!e)return;const{top:s,left:r,bottom:o,right:c}=t(e);R0(e)&&(o<=0||c<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const XE=[["x",["left","right"],$E],["y",["top","bottom"],YE]];class Gm{constructor(t,s){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=Xm(s),o=B0(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,f]of XE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const p=f(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Fo{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=t}add(t,s,r){var o;(o=this.target)==null||o.addEventListener(t,s,r),this.listeners.push([t,s,r])}}function GE(e){const{EventTarget:t}=pn(e);return e instanceof t?e:El(e)}function Uf(e,t){const s=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+r**2)>t:"x"in t&&"y"in t?s>t.x&&r>t.y:"x"in t?s>t.x:"y"in t?r>t.y:!1}var Vn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Vn||(Vn={}));function Cy(e){e.preventDefault()}function ZE(e){e.stopPropagation()}var Nt;(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"})(Nt||(Nt={}));const O0={start:[Nt.Space,Nt.Enter],cancel:[Nt.Esc],end:[Nt.Space,Nt.Enter,Nt.Tab]},QE=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case Nt.Right:return{...s,x:s.x+25};case Nt.Left:return{...s,x:s.x-25};case Nt.Down:return{...s,y:s.y+25};case Nt.Up:return{...s,y:s.y-25}}};class z0{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:s}}=t;this.props=t,this.listeners=new Fo(El(s)),this.windowListeners=new Fo(pn(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Vn.Resize,this.handleCancel),this.windowListeners.add(Vn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Vn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,r=t.node.current;r&&VE(r),s(hs)}handleKeyDown(t){if(k0(t)){const{active:s,context:r,options:o}=this.props,{keyboardCodes:c=O0,coordinateGetter:h=QE,scrollBehavior:f="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,y=p?{x:p.left,y:p.top}:hs;this.referenceCoordinates||(this.referenceCoordinates=y);const b=h(t,{active:s,context:r.current,currentCoordinates:y});if(b){const w=Xu(b,y),S={x:0,y:0},{scrollableAncestors:E}=r.current;for(const T of E){const A=t.code,{isTop:O,isRight:L,isLeft:U,isBottom:I,maxScroll:te,minScroll:ee}=L0(T),ae=qE(T),ue={x:Math.min(A===Nt.Right?ae.right-ae.width/2:ae.right,Math.max(A===Nt.Right?ae.left:ae.left+ae.width/2,b.x)),y:Math.min(A===Nt.Down?ae.bottom-ae.height/2:ae.bottom,Math.max(A===Nt.Down?ae.top:ae.top+ae.height/2,b.y))},be=A===Nt.Right&&!L||A===Nt.Left&&!U,we=A===Nt.Down&&!I||A===Nt.Up&&!O;if(be&&ue.x!==b.x){const ne=T.scrollLeft+w.x,ie=A===Nt.Right&&ne<=te.x||A===Nt.Left&&ne>=ee.x;if(ie&&!w.y){T.scrollTo({left:ne,behavior:f});return}ie?S.x=T.scrollLeft-ne:S.x=A===Nt.Right?T.scrollLeft-te.x:T.scrollLeft-ee.x,S.x&&T.scrollBy({left:-S.x,behavior:f});break}else if(we&&ue.y!==b.y){const ne=T.scrollTop+w.y,ie=A===Nt.Down&&ne<=te.y||A===Nt.Up&&ne>=ee.y;if(ie&&!w.x){T.scrollTo({top:ne,behavior:f});return}ie?S.y=T.scrollTop-ne:S.y=A===Nt.Down?T.scrollTop-te.y:T.scrollTop-ee.y,S.y&&T.scrollBy({top:-S.y,behavior:f});break}}this.handleMove(t,gl(Xu(b,this.referenceCoordinates),S))}}}handleMove(t,s){const{onMove:r}=this.props;t.preventDefault(),r(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}z0.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:r=O0,onActivation:o}=t,{active:c}=s;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function xy(e){return!!(e&&"distance"in e)}function Ey(e){return!!(e&&"delay"in e)}class Zm{constructor(t,s,r){var o;r===void 0&&(r=GE(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=s;const{event:c}=t,{target:h}=c;this.props=t,this.events=s,this.document=El(h),this.documentListeners=new Fo(this.document),this.listeners=new Fo(r),this.windowListeners=new Fo(pn(h)),this.initialCoordinates=(o=gp(c))!=null?o:hs,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:s,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(Vn.Resize,this.handleCancel),this.windowListeners.add(Vn.DragStart,Cy),this.windowListeners.add(Vn.VisibilityChange,this.handleCancel),this.windowListeners.add(Vn.ContextMenu,Cy),this.documentListeners.add(Vn.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ey(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(xy(s)){this.handlePending(s);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,s){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(Vn.Click,ZE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Vn.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:h,options:{activationConstraint:f}}=c;if(!o)return;const g=(s=gp(t))!=null?s:hs,p=Xu(o,g);if(!r&&f){if(xy(f)){if(f.tolerance!=null&&Uf(p,f.tolerance))return this.handleCancel();if(Uf(p,f.distance))return this.handleStart()}if(Ey(f)&&Uf(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===Nt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const JE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class j0 extends Zm{constructor(t){const{event:s}=t,r=El(s.target);super(t,JE,r)}}j0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return!s.isPrimary||s.button!==0?!1:(r?.({event:s}),!0)}}];const e2={move:{name:"mousemove"},end:{name:"mouseup"}};var bp;(function(e){e[e.RightClick=2]="RightClick"})(bp||(bp={}));class H0 extends Zm{constructor(t){super(t,e2,El(t.event.target))}}H0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return s.button===bp.RightClick?!1:(r?.({event:s}),!0)}}];const If={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class P0 extends Zm{constructor(t){super(t,If)}static setup(){return window.addEventListener(If.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(If.move.name,t)};function t(){}}}P0.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;const{touches:o}=s;return o.length>1?!1:(r?.({event:s}),!0)}}];var Wo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Wo||(Wo={}));var Zu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Zu||(Zu={}));function t2(e){let{acceleration:t,activator:s=Wo.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:h=5,order:f=Zu.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:w}=e;const S=n2({delta:b,disabled:!c}),[E,T]=gE(),A=v.useRef({x:0,y:0}),O=v.useRef({x:0,y:0}),L=v.useMemo(()=>{switch(s){case Wo.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Wo.DraggableRect:return o}},[s,o,g]),U=v.useRef(null),I=v.useCallback(()=>{const ee=U.current;if(!ee)return;const ae=A.current.x*O.current.x,ue=A.current.y*O.current.y;ee.scrollBy(ae,ue)},[]),te=v.useMemo(()=>f===Zu.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!c||!p.length||!L){T();return}for(const ee of te){if(r?.(ee)===!1)continue;const ae=p.indexOf(ee),ue=y[ae];if(!ue)continue;const{direction:be,speed:we}=WE(ee,ue,L,t,w);for(const ne of["x","y"])S[ne][be[ne]]||(we[ne]=0,be[ne]=0);if(we.x>0||we.y>0){T(),U.current=ee,E(I,h),A.current=we,O.current=be;return}}A.current={x:0,y:0},O.current={x:0,y:0},T()},[t,I,r,T,c,h,JSON.stringify(L),JSON.stringify(S),E,p,te,y,JSON.stringify(w)])}const i2={x:{[Ri.Backward]:!1,[Ri.Forward]:!1},y:{[Ri.Backward]:!1,[Ri.Forward]:!1}};function n2(e){let{delta:t,disabled:s}=e;const r=mp(t);return uc(o=>{if(s||!r||!o)return i2;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Ri.Backward]:o.x[Ri.Backward]||c.x===-1,[Ri.Forward]:o.x[Ri.Forward]||c.x===1},y:{[Ri.Backward]:o.y[Ri.Backward]||c.y===-1,[Ri.Forward]:o.y[Ri.Forward]||c.y===1}}},[s,t,r])}function s2(e,t){const s=t!=null?e.get(t):void 0,r=s?s.node.current:null;return uc(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function r2(e,t){return v.useMemo(()=>e.reduce((s,r)=>{const{sensor:o}=r,c=o.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,r)}));return[...s,...c]},[]),[e,t])}var Qo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Qo||(Qo={}));var yp;(function(e){e.Optimized="optimized"})(yp||(yp={}));const ky=new Map;function a2(e,t){let{dragging:s,dependencies:r,config:o}=t;const[c,h]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,y=v.useRef(e),b=A(),w=Zo(b),S=v.useCallback(function(O){O===void 0&&(O=[]),!w.current&&h(L=>L===null?O:L.concat(O.filter(U=>!L.includes(U))))},[w]),E=v.useRef(null),T=uc(O=>{if(b&&!s)return ky;if(!O||O===ky||y.current!==e||c!=null){const L=new Map;for(let U of e){if(!U)continue;if(c&&c.length>0&&!c.includes(U.id)&&U.rect.current){L.set(U.id,U.rect.current);continue}const I=U.node.current,te=I?new Gm(g(I),I):null;U.rect.current=te,te&&L.set(U.id,te)}return L}return O},[e,c,s,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||S()},[s,b]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof f!="number"||E.current!==null||(E.current=setTimeout(()=>{S(),E.current=null},f))},[f,b,S,...r]),{droppableRects:T,measureDroppableContainers:S,measuringScheduled:c!=null};function A(){switch(p){case Qo.Always:return!1;case Qo.BeforeDragging:return s;default:return!s}}}function U0(e,t){return uc(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function l2(e,t){return U0(e,t)}function o2(e){let{callback:t,disabled:s}=e;const r=Vm(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function _h(e){let{callback:t,disabled:s}=e;const r=Vm(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function c2(e){return new Gm(hc(e),e)}function Ty(e,t,s){t===void 0&&(t=c2);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??s)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const h=o2({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),f=_h({callback:c});return zr(()=>{c(),e?(f?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),h?.disconnect())},[e]),r}function u2(e){const t=U0(e);return D0(e,t)}const Dy=[];function h2(e){const t=v.useRef(e),s=uc(r=>e?r&&r!==Dy&&e&&t.current&&e.parentNode===t.current.parentNode?r:Xm(e):Dy,[e]);return v.useEffect(()=>{t.current=e},[e]),s}function d2(e){const[t,s]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const h=Pf(c.target);h&&s(f=>f?(f.set(h,vp(h)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){h(c);const f=e.map(g=>{const p=Pf(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,vp(p)]):null}).filter(g=>g!=null);s(f.length?new Map(f):null),r.current=e}return()=>{h(e),h(c)};function h(f){f.forEach(g=>{const p=Pf(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>gl(c,h),hs):B0(e):hs,[e,t])}function Ry(e,t){t===void 0&&(t=[]);const s=v.useRef(null);return v.useEffect(()=>{s.current=null},t),v.useEffect(()=>{const r=e!==hs;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Xu(e,s.current):hs}function f2(e){v.useEffect(()=>{if(!mh)return;const t=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function p2(e,t){return v.useMemo(()=>e.reduce((s,r)=>{let{eventName:o,handler:c}=r;return s[o]=h=>{c(h,t)},s},{}),[e,t])}function I0(e){return v.useMemo(()=>e?UE(e):null,[e])}const My=[];function m2(e,t){t===void 0&&(t=hc);const[s]=e,r=I0(s?pn(s):null),[o,c]=v.useState(My);function h(){c(()=>e.length?e.map(g=>A0(g)?r:new Gm(t(g),g)):My)}const f=_h({callback:h});return zr(()=>{f?.disconnect(),h(),e.forEach(g=>f?.observe(g))},[e]),o}function g2(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return cc(t)?t:e}function _2(e){let{measure:t}=e;const[s,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if(cc(y)){r(b=>{const w=t(y);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=_h({callback:o}),h=v.useCallback(p=>{const y=g2(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[f,g]=Vu(h);return v.useMemo(()=>({nodeRef:f,rect:s,setRef:g}),[s,f,g])}const v2=[{sensor:j0,options:{}},{sensor:z0,options:{}}],b2={current:{}},Ou={draggable:{measure:wy},droppable:{measure:wy,strategy:Qo.WhileDragging,frequency:yp.Optimized},dragOverlay:{measure:hc}};class qo extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,r;return(s=(r=this.get(t))==null?void 0:r.node.current)!=null?s:void 0}}const y2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ou,measureDroppableContainers:Gu,windowRect:null,measuringScheduled:!1},S2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Gu,draggableNodes:new Map,over:null,measureDroppableContainers:Gu},vh=v.createContext(S2),w2=v.createContext(y2);function C2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qo}}}function x2(e,t){switch(t.type){case yi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case yi.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 yi.DragEnd:case yi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case yi.RegisterDroppable:{const{element:s}=t,{id:r}=s,o=new qo(e.droppable.containers);return o.set(r,s),{...e,droppable:{...e.droppable,containers:o}}}case yi.SetDroppableDisabled:{const{id:s,key:r,disabled:o}=t,c=e.droppable.containers.get(s);if(!c||r!==c.key)return e;const h=new qo(e.droppable.containers);return h.set(s,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case yi.UnregisterDroppable:{const{id:s,key:r}=t,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const c=new qo(e.droppable.containers);return c.delete(s),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function E2(e){let{disabled:t}=e;const{active:s,activatorEvent:r,draggableNodes:o}=v.useContext(vh),c=mp(r),h=mp(s?.id);return v.useEffect(()=>{if(!t&&!r&&c&&h!=null){if(!k0(c)||document.activeElement===c.target)return;const f=o.get(h);if(!f)return;const{activatorNode:g,node:p}=f;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=bE(y);if(b){b.focus();break}}})}},[r,t,o,h,c]),null}function k2(e,t){let{transform:s,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),s):s}function T2(e){return v.useMemo(()=>({draggable:{...Ou.draggable,...e?.draggable},droppable:{...Ou.droppable,...e?.droppable},dragOverlay:{...Ou.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function D2(e){let{activeNode:t,measure:s,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:f}=typeof o=="boolean"?{x:o,y:o}:o;zr(()=>{if(!h&&!f||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=s(p),b=D0(y,r);if(h||(b.x=0),f||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=R0(p);w&&w.scrollBy({top:b.y,left:b.x})}},[t,h,f,r,s])}const K0=v.createContext({...hs,scaleX:1,scaleY:1});var Rr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Rr||(Rr={}));const R2=v.memo(function(t){var s,r,o,c;let{id:h,accessibility:f,autoScroll:g=!0,children:p,sensors:y=v2,collisionDetection:b=LE,measuring:w,modifiers:S,...E}=t;const T=v.useReducer(x2,void 0,C2),[A,O]=T,[L,U]=EE(),[I,te]=v.useState(Rr.Uninitialized),ee=I===Rr.Initialized,{draggable:{active:ae,nodes:ue,translate:be},droppable:{containers:we}}=A,ne=ae!=null?ue.get(ae):null,ie=v.useRef({initial:null,translated:null}),Y=v.useMemo(()=>{var gt;return ae!=null?{id:ae,data:(gt=ne?.data)!=null?gt:b2,rect:ie}:null},[ae,ne]),K=v.useRef(null),[re,B]=v.useState(null),[$,D]=v.useState(null),X=Zo(E,Object.values(E)),_e=gh("DndDescribedBy",h),R=v.useMemo(()=>we.getEnabled(),[we]),H=T2(w),{droppableRects:Q,measureDroppableContainers:de,measuringScheduled:ke}=a2(R,{dragging:ee,dependencies:[be.x,be.y],config:H.droppable}),xe=s2(ue,ae),Re=v.useMemo(()=>$?gp($):null,[$]),Xe=Zi(),ge=l2(xe,H.draggable.measure);D2({activeNode:ae!=null?ue.get(ae):null,config:Xe.layoutShiftCompensation,initialRect:ge,measure:H.draggable.measure});const G=Ty(xe,H.draggable.measure,ge),ce=Ty(xe?xe.parentElement:null),Ce=v.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:Q,draggableNodes:ue,draggingNode:null,draggingNodeRect:null,droppableContainers:we,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ye=we.getNodeFor((s=Ce.current.over)==null?void 0:s.id),De=_2({measure:H.dragOverlay.measure}),Be=(r=De.nodeRef.current)!=null?r:xe,Ke=ee?(o=De.rect)!=null?o:G:null,le=!!(De.nodeRef.current&&De.rect),Ee=u2(le?null:G),Le=I0(Be?pn(Be):null),Oe=h2(ee?ye??xe:null),He=m2(Oe),_t=k2(S,{transform:{x:be.x-Ee.x,y:be.y-Ee.y,scaleX:1,scaleY:1},activatorEvent:$,active:Y,activeNodeRect:G,containerNodeRect:ce,draggingNodeRect:Ke,over:Ce.current.over,overlayNodeRect:De.rect,scrollableAncestors:Oe,scrollableAncestorRects:He,windowRect:Le}),Ye=Re?gl(Re,be):null,rt=d2(Oe),Oi=Ry(rt),$i=Ry(rt,[G]),Ci=gl(_t,Oi),ri=Ke?zE(Ke,_t):null,zi=Y&&ri?b({active:Y,collisionRect:ri,droppableRects:Q,droppableContainers:R,pointerCoordinates:Ye}):null,sn=NE(zi,"id"),[F,qe]=v.useState(null),dt=le?_t:gl(_t,$i),vt=BE(dt,(c=F?.rect)!=null?c:null,G),pi=v.useRef(null),St=v.useCallback((gt,Tt)=>{let{sensor:Dt,options:mi}=Tt;if(K.current==null)return;const gi=ue.get(K.current);if(!gi)return;const Ut=gt.nativeEvent,ei=new Dt({active:K.current,activeNode:gi,event:Ut,options:mi,context:Ce,onAbort(Lt){if(!ue.get(Lt))return;const{onDragAbort:It}=X.current,Yi={id:Lt};It?.(Yi),L({type:"onDragAbort",event:Yi})},onPending(Lt,xi,It,Yi){if(!ue.get(Lt))return;const{onDragPending:an}=X.current,Qi={id:Lt,constraint:xi,initialCoordinates:It,offset:Yi};an?.(Qi),L({type:"onDragPending",event:Qi})},onStart(Lt){const xi=K.current;if(xi==null)return;const It=ue.get(xi);if(!It)return;const{onDragStart:Yi}=X.current,rn={activatorEvent:Ut,active:{id:xi,data:It.data,rect:ie}};Ao.unstable_batchedUpdates(()=>{Yi?.(rn),te(Rr.Initializing),O({type:yi.DragStart,initialCoordinates:Lt,active:xi}),L({type:"onDragStart",event:rn}),B(pi.current),D(Ut)})},onMove(Lt){O({type:yi.DragMove,coordinates:Lt})},onEnd:ji(yi.DragEnd),onCancel:ji(yi.DragCancel)});pi.current=ei;function ji(Lt){return async function(){const{active:It,collisions:Yi,over:rn,scrollAdjustedTranslate:an}=Ce.current;let Qi=null;if(It&&an){const{cancelDrop:gn}=X.current;Qi={activatorEvent:Ut,active:It,collisions:Yi,delta:an,over:rn},Lt===yi.DragEnd&&typeof gn=="function"&&await Promise.resolve(gn(Qi))&&(Lt=yi.DragCancel)}K.current=null,Ao.unstable_batchedUpdates(()=>{O({type:Lt}),te(Rr.Uninitialized),qe(null),B(null),D(null),pi.current=null;const gn=Lt===yi.DragEnd?"onDragEnd":"onDragCancel";if(Qi){const Hi=X.current[gn];Hi?.(Qi),L({type:gn,event:Qi})}})}}},[ue]),mn=v.useCallback((gt,Tt)=>(Dt,mi)=>{const gi=Dt.nativeEvent,Ut=ue.get(mi);if(K.current!==null||!Ut||gi.dndKit||gi.defaultPrevented)return;const ei={active:Ut};gt(Dt,Tt.options,ei)===!0&&(gi.dndKit={capturedBy:Tt.sensor},K.current=mi,St(Dt,Tt))},[ue,St]),Ln=r2(y,mn);f2(y),zr(()=>{G&&I===Rr.Initializing&&te(Rr.Initialized)},[G,I]),v.useEffect(()=>{const{onDragMove:gt}=X.current,{active:Tt,activatorEvent:Dt,collisions:mi,over:gi}=Ce.current;if(!Tt||!Dt)return;const Ut={active:Tt,activatorEvent:Dt,collisions:mi,delta:{x:Ci.x,y:Ci.y},over:gi};Ao.unstable_batchedUpdates(()=>{gt?.(Ut),L({type:"onDragMove",event:Ut})})},[Ci.x,Ci.y]),v.useEffect(()=>{const{active:gt,activatorEvent:Tt,collisions:Dt,droppableContainers:mi,scrollAdjustedTranslate:gi}=Ce.current;if(!gt||K.current==null||!Tt||!gi)return;const{onDragOver:Ut}=X.current,ei=mi.get(sn),ji=ei&&ei.rect.current?{id:ei.id,rect:ei.rect.current,data:ei.data,disabled:ei.disabled}:null,Lt={active:gt,activatorEvent:Tt,collisions:Dt,delta:{x:gi.x,y:gi.y},over:ji};Ao.unstable_batchedUpdates(()=>{qe(ji),Ut?.(Lt),L({type:"onDragOver",event:Lt})})},[sn]),zr(()=>{Ce.current={activatorEvent:$,active:Y,activeNode:xe,collisionRect:ri,collisions:zi,droppableRects:Q,draggableNodes:ue,draggingNode:Be,draggingNodeRect:Ke,droppableContainers:we,over:F,scrollableAncestors:Oe,scrollAdjustedTranslate:Ci},ie.current={initial:Ke,translated:ri}},[Y,xe,zi,ri,ue,Be,Ke,Q,we,F,Oe,Ci]),t2({...Xe,delta:be,draggingRect:ri,pointerCoordinates:Ye,scrollableAncestors:Oe,scrollableAncestorRects:He});const Jt=v.useMemo(()=>({active:Y,activeNode:xe,activeNodeRect:G,activatorEvent:$,collisions:zi,containerNodeRect:ce,dragOverlay:De,draggableNodes:ue,droppableContainers:we,droppableRects:Q,over:F,measureDroppableContainers:de,scrollableAncestors:Oe,scrollableAncestorRects:He,measuringConfiguration:H,measuringScheduled:ke,windowRect:Le}),[Y,xe,G,$,zi,ce,De,ue,we,Q,F,de,Oe,He,H,ke,Le]),ai=v.useMemo(()=>({activatorEvent:$,activators:Ln,active:Y,activeNodeRect:G,ariaDescribedById:{draggable:_e},dispatch:O,draggableNodes:ue,over:F,measureDroppableContainers:de}),[$,Ln,Y,G,O,_e,ue,F,de]);return Si.createElement(T0.Provider,{value:U},Si.createElement(vh.Provider,{value:ai},Si.createElement(w2.Provider,{value:Jt},Si.createElement(K0.Provider,{value:vt},p)),Si.createElement(E2,{disabled:f?.restoreFocus===!1})),Si.createElement(DE,{...f,hiddenTextDescribedById:_e}));function Zi(){const gt=re?.autoScrollEnabled===!1,Tt=typeof g=="object"?g.enabled===!1:g===!1,Dt=ee&&!gt&&!Tt;return typeof g=="object"?{...g,enabled:Dt}:{enabled:Dt}}}),M2=v.createContext(null),Ny="button",N2="Draggable";function F0(e){let{id:t,data:s,disabled:r=!1,attributes:o}=e;const c=gh(N2),{activators:h,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:w}=v.useContext(vh),{role:S=Ny,roleDescription:E="draggable",tabIndex:T=0}=o??{},A=g?.id===t,O=v.useContext(A?K0:M2),[L,U]=Vu(),[I,te]=Vu(),ee=p2(h,t),ae=Zo(s);zr(()=>(b.set(t,{id:t,key:c,node:L,activatorNode:I,data:ae}),()=>{const be=b.get(t);be&&be.key===c&&b.delete(t)}),[b,t]);const ue=v.useMemo(()=>({role:S,tabIndex:T,"aria-disabled":r,"aria-pressed":A&&S===Ny?!0:void 0,"aria-roledescription":E,"aria-describedby":y.draggable}),[r,S,T,A,E,y.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:ue,isDragging:A,listeners:r?void 0:ee,node:L,over:w,setNodeRef:U,setActivatorNodeRef:te,transform:O}}const A2="Droppable",L2={timeout:25};function Qm(e){let{data:t,disabled:s=!1,id:r,resizeObserverConfig:o}=e;const c=gh(A2),{active:h,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(vh),y=v.useRef({disabled:s}),b=v.useRef(!1),w=v.useRef(null),S=v.useRef(null),{disabled:E,updateMeasurementsFor:T,timeout:A}={...L2,...o},O=Zo(T??r),L=v.useCallback(()=>{if(!b.current){b.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{p(Array.isArray(O.current)?O.current:[O.current]),S.current=null},A)},[A]),U=_h({callback:L,disabled:E||!h}),I=v.useCallback((ue,be)=>{U&&(be&&(U.unobserve(be),b.current=!1),ue&&U.observe(ue))},[U]),[te,ee]=Vu(I),ae=Zo(t);return v.useEffect(()=>{!U||!te.current||(U.disconnect(),b.current=!1,U.observe(te.current))},[te,U]),v.useEffect(()=>(f({type:yi.RegisterDroppable,element:{id:r,key:c,disabled:s,node:te,rect:w,data:ae}}),()=>f({type:yi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{s!==y.current.disabled&&(f({type:yi.SetDroppableDisabled,id:r,key:c,disabled:s}),y.current.disabled=s)},[r,c,s,f]),{active:h,rect:w,isOver:g?.id===r,node:te,over:g,setNodeRef:ee}}const B2=128,O2=512,kl=100,z2="too_many_detached_terminals",j2=64,H2=4096;function W0(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>B2)return null;const s=t.workspaces.map(P2);return s.some(r=>r===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}function q0(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(s=>{if(!s||typeof s!="object")return!1;const r=s.detachedTerminalIds;return Array.isArray(r)&&r.length>kl}):!1}function P2(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>O2)return null;const s=t.tabs.map(U2);if(s.some(o=>o===null))return null;const r=W2(t.detachedTerminalIds,kl);return r===null?null:{id:t.id,title:t.title,defaultCwd:F2(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:s}}function U2(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 s=I2(t.root);return s?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:s}:null}function I2(e){if(!e||typeof e!="object")return null;let t=0;return Sp(e,1,()=>(t+=1,t<=H2))}function Sp(e,t,s){if(!e||typeof e!="object"||t>j2||!s())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=Sp(r.first,t+1,s),c=Sp(r.second,t+1,s);return!o||!c?null:{type:"split",direction:r.direction,ratio:K2(r.ratio),first:o,second:c}}function K2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function F2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function W2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const s=new Set,r=[];for(const o of e)typeof o!="string"||!o||s.has(o)||(s.add(o),r.push(o));return r}const $0=[{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"}],Nr="__main__";function q2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function $2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Ay="Local",Y2=3e4,V2=2,X2=6,Y0="nterminal.serverList.viewMode.v1";function G2(){try{return window.localStorage.getItem(Y0)==="list"?"list":"stats"}catch{return"stats"}}function Z2(e){try{window.localStorage.setItem(Y0,e)}catch{}}function ha(e,t){const s=[Nr,...t.map(h=>h.id)],r=new Set(s),o=new Set,c=[];for(const h of e??[])!r.has(h)||o.has(h)||(o.add(h),c.push(h));for(const h of s)o.has(h)||c.push(h);return c}function Q2(e,t){const s=new Map(e.map(r=>[r.id,r]));return ha(t,e).flatMap(r=>{if(r===Nr)return[{kind:"main",id:Nr}];const o=s.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Ly(e,t){return e.length===t.length&&e.every((s,r)=>s===t[r])}function V0(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Gn(e.cpuPercent)} ${Jm(e)}`,`MEM ${Gn(e.memoryPercent)} ${Xs(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Gn(e.diskPercent)} ${Xs(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Gn(e.swapPercent)} ${Xs(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function J2(e){if(!(e===void 0||e==="error"))return[`CPU ${Gn(e.cpuPercent)} (${Jm(e)})`,`RAM ${Gn(e.memoryPercent)} (${Xs(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Gn(e.diskPercent)} (${Xs(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Gn(e.swapPercent)} (${Xs(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function ek(e,t){const s=V0(t);return`${e}${s?` — ${s}`:""}. Double-click to rename.`}function Gn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Jm(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`:`${wp(e.cpuPercent/100*t)}/${t} cores`}function Xs(e,t){return!By(e)||!By(t)?"–/–":tk(e,t)}function tk(e,t){const s=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=s==="GB"?1024**3:s==="MB"?1024**2:1024;return`${wp(e/r)}/${wp(t/r)} ${s}`}function wp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function By(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function wu(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function ik(e){return[{label:"CPU",percent:Gn(e.cpuPercent),detail:Jm(e),tone:wu(e.cpuPercent)},{label:"MEM",percent:Gn(e.memoryPercent),detail:Xs(e.memoryUsedBytes,e.memoryTotalBytes),tone:wu(e.memoryPercent)},{label:"DISK",percent:Gn(e.diskPercent),detail:Xs(e.diskUsedBytes,e.diskTotalBytes),tone:wu(e.diskPercent)},{label:"SWAP",percent:Gn(e.swapPercent),detail:Xs(e.swapUsedBytes,e.swapTotalBytes),tone:wu(e.swapPercent)}]}function nk({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:J2(e),children:ik(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function Oy({api:e,activeAgentId:t,onSelectServer:s,onSessionInvalid:r,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[f,g]=v.useState([]),[p,y]=v.useState([Nr]),[b,w]=v.useState(null),[S,E]=v.useState(null),[T,A]=v.useState(""),O=v.useRef(null),[L,U]=v.useState(()=>G2()),[I,te]=v.useState(null),[ee,ae]=v.useState(null),[ue,be]=v.useState({}),we=v.useRef({}),ne=v.useRef(0),ie=v.useRef([]),Y=v.useRef([Nr]),K=v.useRef(null);v.useEffect(()=>{ie.current=f},[f]),v.useEffect(()=>{const G=ha(p,f);Y.current=G,Ly(G,p)||y(G)},[f,p]),v.useEffect(()=>{let G=!1;return e.listAgents().then(ce=>{G||(g(ce.agents),y(ha(ce.serverOrder,ce.agents)))}).catch(()=>{}),e.getMainInfo().then(ce=>{G||w(ce.name)}).catch(()=>{}),()=>{G=!0}},[e,o]),v.useEffect(()=>{S&&(O.current?.focus(),O.current?.select())},[S]),v.useEffect(()=>{let G=!1;function ce(){const ye=[{key:"__main__",load:()=>e.getMainStats()},...f.map(Be=>({key:Be.id,load:()=>e.getAgentStats(Be.id)}))],De=new Set(ye.map(Be=>Be.key));for(const Be of Object.keys(we.current))De.has(Be)||delete we.current[Be];be(Be=>{const Ke={};for(const le of De)le in Be&&(Ke[le]=Be[le]);return Ke});for(const Be of ye)Be.load().then(Ke=>{G||(we.current[Be.key]=0,be(le=>De.has(Be.key)?{...le,[Be.key]:Ke}:le))}).catch(Ke=>{if(G)return;if(Ke instanceof us&&Ke.status===401&&Be.key==="__main__"){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}const le=(we.current[Be.key]??0)+1;we.current[Be.key]=le,le>=V2&&be(Ee=>De.has(Be.key)?{...Ee,[Be.key]:"error"}:Ee)})}ce();const Ce=window.setInterval(ce,Y2);return()=>{G=!0,window.clearInterval(Ce)}},[e,f,r]);function re(G){G==="main"?(A(b??""),E({kind:"main"})):(A(G.name),E({kind:"agent",id:G.id}))}async function B(){if(!S)return;const G=T.trim(),ce=S;if(E(null),ce.kind==="main"){const Ce=G||"";try{const ye=await e.renameMain(Ce);w(ye.name)}catch{}}else{if(!G)return;const Ce=f.find(ye=>ye.id===ce.id)?.name;g(ye=>ye.map(De=>De.id===ce.id?{...De,name:G}:De));try{await e.renameAgent(ce.id,G)}catch{Ce!==void 0&&g(ye=>ye.map(De=>De.id===ce.id?{...De,name:Ce}:De))}}}function $(){E(null)}function D(G){U(G),Z2(G)}function X(G,ce,Ce){if(G===ce)return;const ye=ha(Y.current,ie.current),De=ye.findIndex(He=>He===G),Be=ye.findIndex(He=>He===ce);if(De<0||Be<0)return;const Ke=[...ye],[le]=Ke.splice(De,1);if(!le)return;const Ee=Ke.findIndex(He=>He===ce);if(Ee<0)return;const Le=Ce==="before"?Ee:Ee+1;if(Ke.splice(Le,0,le),Ly(Ke,ye))return;const Oe=ne.current+1;ne.current=Oe,Y.current=Ke,y(Ke),e.reorderAgents(Ke).then(He=>{if(ne.current===Oe){ie.current=He.agents;const _t=ha(He.serverOrder,He.agents);Y.current=_t,g(He.agents),y(_t)}}).catch(async()=>{if(ne.current===Oe)try{const He=await e.listAgents();if(ne.current===Oe){ie.current=He.agents;const _t=ha(He.serverOrder,He.agents);Y.current=_t,g(He.agents),y(_t)}}catch{ne.current===Oe&&(Y.current=ye,y(ye))}})}function _e(G,ce){const Ce=ha(Y.current,ie.current),ye=Ce.findIndex(Be=>Be===G),De=Ce[ye+ce];ye<0||!De||X(G,De,ce<0?"before":"after")}function R(G,ce){ce.pointerType==="mouse"&&ce.button!==0||(ce.stopPropagation(),K.current={sourceId:G,pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,active:!1,targetId:null,placement:"after"},ce.currentTarget.setPointerCapture?.(ce.pointerId))}function H(G){const ce=K.current;if(!ce||ce.pointerId!==G.pointerId)return;const Ce=Math.hypot(G.clientX-ce.startX,G.clientY-ce.startY);if(!ce.active){if(Ce<X2)return;ce.active=!0,te(ce.sourceId)}const De=document.elementFromPoint(G.clientX,G.clientY)?.closest("[data-server-id]"),Be=De?.dataset.serverId??null;if(!De||!Be||Be===ce.sourceId){ce.targetId=null,ae(null);return}const Ke=De.getBoundingClientRect(),le=G.clientY<Ke.top+Ke.height/2?"before":"after";ce.targetId=Be,ce.placement=le,ae({serverId:Be,placement:le})}function Q(G){const ce=K.current;!ce||ce.pointerId!==G.pointerId||(G.stopPropagation(),G.currentTarget.releasePointerCapture?.(G.pointerId),K.current=null,te(null),ae(null),ce.active&&ce.targetId&&X(ce.sourceId,ce.targetId,ce.placement))}function de(G){const ce=K.current;ce&&ce.pointerId===G.pointerId&&G.currentTarget.releasePointerCapture?.(G.pointerId),K.current=null,te(null),ae(null)}const ke=b?.trim()||Ay,xe=S?.kind==="main",Re=L==="stats",Xe=Q2(f,p),ge=Xe.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:Xe.map(G=>{const ce=G.kind==="main",Ce=ce?ke:G.agent.name,ye=ce?Nr:G.id,De=ue[ye],Be=V0(De);return m.jsxs("button",{type:"button",className:`server-list-chip${(ce?t===null:t===G.id)?" server-list-chip--active":""}`,onClick:()=>s(ce?null:G.id),"aria-label":Ce,title:`${Ce}${Be?` — ${Be}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:$2(Ce)}),m.jsx("span",{className:"server-list-chip-pip","data-status":q2(De)})]},G.id)})}):m.jsxs("div",{className:`server-list server-list--${L}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":L==="list",onClick:()=>D("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":L==="stats",onClick:()=>D("stats"),title:"Show resource usage",children:"Stats"})]}),Xe.map(G=>{const ce=G.kind==="main",Ce=ce?ke:G.agent.name,ye=ce?Nr:G.id,De=ce?t===null:t===G.id,Be=ce?xe:S?.kind==="agent"&&S.id===G.id,Ke=c?.({agentId:ce?null:G.id,serverId:G.id,label:Ce,active:De}),le=ee?.serverId===G.id&&I!==G.id?` server-list-section--drop-target server-list-section--drop-${ee.placement}`:"";return m.jsxs("section",{className:`server-list-section${le}`,"aria-label":`${Ce} server`,children:[m.jsx("div",{className:["server-list-row",I===G.id?"server-list-row--dragging":"",ee?.serverId===G.id&&I!==G.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":G.id,children:Be?m.jsxs(m.Fragment,{children:[ge?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:Ee=>{Ee.preventDefault(),B()},children:m.jsx("input",{ref:O,"aria-label":ce?"Rename main server":`Rename ${Ce}`,value:T,onChange:Ee=>A(Ee.target.value),onBlur:()=>{B()},onKeyDown:Ee=>{Ee.key==="Escape"&&(Ee.preventDefault(),$())},placeholder:ce?Ay:void 0})})]}):m.jsxs(m.Fragment,{children:[ge?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":G.id,title:"Drag to reorder","aria-label":`Reorder ${Ce}`,"aria-grabbed":I===G.id,onPointerDown:Ee=>R(G.id,Ee),onPointerMove:H,onPointerUp:Q,onPointerCancel:de,onKeyDown:Ee=>{(Ee.key==="ArrowUp"||Ee.key==="ArrowDown")&&(Ee.preventDefault(),Ee.stopPropagation(),_e(G.id,Ee.key==="ArrowUp"?-1:1))},onClick:Ee=>Ee.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${De?" server-list-item--active":""}`,onClick:()=>s(ce?null:G.id),onDoubleClick:Ee=>{Ee.preventDefault(),re(ce?"main":{id:G.id,name:Ce})},title:ek(Ce,ue[ye]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:ce?void 0:G.agent.url,children:Ce})]}),Re?m.jsx(nk,{entry:ue[ye]}):null]})]})}),Ke?m.jsx("div",{className:"server-list-children",children:Ke}):null]},G.id)})]})}function sk({api:e}){const[t,s]=v.useState([]),[r,o]=v.useState([]),[c,h]=v.useState(!1),[f,g]=v.useState(null),[p,y]=v.useState(""),[b,w]=v.useState("");async function S(){try{const[O,L,U]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);s(O.devices),o(L.networks),h(U.totpEnabled),g(null)}catch(O){g(O instanceof Error?O.message:"Failed to load")}}v.useEffect(()=>{S()},[]);async function E(O){await e.revokeDevice(O),await S()}async function T(O){await e.removeNetwork(O),await S()}async function A(O){O.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),w(""),await S()}catch(L){g(L instanceof Error?L.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[f?m.jsx("p",{className:"form-error",children:f}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(O=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[O.label,O.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(O.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{E(O.id)},children:"revoke"})]},O.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:r.map(O=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:O.value}),O.label!==O.value?m.jsx("span",{className:"security-item-meta",children:O.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(O.id)},children:"remove"})]},O.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:A,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:O=>y(O.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:O=>w(O.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await S()},children:"Disable 2FA"})]}):null]})}const eg="nterminal.clientDiagnostics.v1",X0=150,rk=24,ak=160;let zy=!1,So=null;function lk(){zy||typeof window>"u"||(zy=!0,Nn("page.load",{navigation:yk(),visibility:document.visibilityState,online:navigator.onLine,viewport:Z0(),standalone:bk()}),document.addEventListener("visibilitychange",()=>{Nn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Nn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Nn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Nn("network.online")),window.addEventListener("offline",()=>Nn("network.offline")),window.addEventListener("focus",()=>Nn("window.focus")),window.addEventListener("blur",()=>Nn("window.blur")),window.addEventListener("error",e=>{Nn("runtime.error",{message:e.message,source:Sk(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Nn("runtime.unhandledrejection",{reason:wk(e.reason)})}))}function Nn(e,t={}){const s={at:new Date().toISOString(),event:yh(e,80),data:G0({...t,visibility:t.visibility??_k(),online:t.online??vk(),viewport:t.viewport??Z0()})},r=ma();return r.push(s),hk(r.slice(-X0)),s}function ma(){try{const e=window.localStorage.getItem(eg);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(dk).filter(s=>s!==null).slice(-X0):[]}catch{return[]}}function ok(){try{window.localStorage.removeItem(eg)}catch{}}function ck(){const e=ma();return JSON.stringify({generatedAt:new Date().toISOString(),eventCount:e.length,events:e},null,2)}async function uk(){const e=ck();return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):Ck(e)}async function bh(e,t=fetch){if(So)return So;const s=ma(),r={reason:yh(e,80),events:s},o=JSON.stringify(r);So=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await So}finally{So=null}}function hk(e){try{window.localStorage.setItem(eg,JSON.stringify(e))}catch{}}function dk(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:yh(t.event,80),...t.data&&typeof t.data=="object"?{data:G0(t.data)}:{}}}function G0(e){const t={};for(const[s,r]of Object.entries(e).slice(0,rk)){const o=yh(s,64);if(!o||fk(o))continue;const c=pk(r);c!==void 0&&(t[o]=c)}return t}function fk(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function pk(e){if(typeof e=="string")return mk(e,ak);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function yh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function mk(e,t){return gk(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function gk(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 _k(){return typeof document>"u"?void 0:document.visibilityState}function vk(){return typeof navigator>"u"?void 0:navigator.onLine}function Z0(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function bk(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function yk(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function Sk(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 wk(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function Ck(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();let s=!1;try{s=document.execCommand("copy")}finally{document.body.removeChild(t)}return s}const Q0="nterminal.notifications.completionEnabled",tg="nterminal.notifications.completionToastEnabled",ig="nterminal.notifications.completionToastDurationSeconds",ng="nterminal.notifications.completionToastPersistent",Cp="nterminal:completion-toast-display",$o=6.5,xp=2,Ep=60;function Sh(){return typeof window<"u"&&"Notification"in window}function J0(){try{return window.localStorage.getItem(Q0)==="true"}catch{return!1}}function jy(e){try{window.localStorage.setItem(Q0,e?"true":"false")}catch{}}function ya(){return{enabled:Tk(),durationSeconds:kk(),persistUntilDismissed:Dk()}}function xk(e){if(typeof window<"u"){try{window.localStorage.setItem(tg,e?"true":"false")}catch{}rg()}return ya()}function Hy(e){const t=tw(e);if(typeof window<"u"){try{window.localStorage.setItem(ig,String(t))}catch{}rg()}return ya()}function Ek(e){if(typeof window<"u"){try{window.localStorage.setItem(ng,e?"true":"false")}catch{}rg()}return ya()}function ew(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===tg||s.key===ig||s.key===ng)&&e()};return window.addEventListener(Cp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Cp,e),window.removeEventListener("storage",t)}}function sg(){return Sh()?window.Notification.permission:"unsupported"}function kk(){if(typeof window>"u")return $o;try{const e=window.localStorage.getItem(ig);return e===null?$o:tw(Number(e))}catch{return $o}}function Tk(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tg)!=="false"}catch{return!0}}function Dk(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ng)==="true"}catch{return!1}}function tw(e){if(!Number.isFinite(e))return $o;const t=Math.round(e*2)/2;return Math.max(xp,Math.min(Ep,t))}function rg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Cp))}async function Rk(){if(!Sh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return sg()}}function Mk(e){if(!Sh()||sg()!=="granted"||!J0()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const Nk=1500,ag="nterminal.terminal.fontSize",lg="nterminal.terminal.fontFamily",kp="nterminal:terminal-font-size",Tp="nterminal:terminal-font-family",Dp=11,Rp=20,_a=14,Qu=[{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:[]}],bl="meslo";Mp(bl);async function Kf(e=_a,t=bl){if(typeof document>"u"||!document.fonts)return;const s=sw(t).webFontFamilies;if(s.length===0)return;const r=Promise.all(s.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,Nk)})])}function iw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return _a;const s=Math.round(t);return Math.max(Dp,Math.min(Rp,s))}function nw(e){return Qu.some(t=>t.id===e)?e:bl}function Mp(e){return sw(e).cssFamily}function sw(e){return Qu.find(t=>t.id===e)??Qu[0]}function Np(){if(typeof window>"u")return _a;try{const e=window.localStorage.getItem(ag);return e?iw(e):_a}catch{return _a}}function Ap(){if(typeof window>"u")return bl;try{return nw(window.localStorage.getItem(lg))}catch{return bl}}function Cu(e){const t=iw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ag,String(t))}catch{}return window.dispatchEvent(new CustomEvent(kp,{detail:t})),t}function Ak(e){const t=nw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lg,t)}catch{}return window.dispatchEvent(new CustomEvent(Tp,{detail:t})),t}function rw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===ag&&e()};return window.addEventListener(kp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(kp,e),window.removeEventListener("storage",t)}}function aw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===lg&&e()};return window.addEventListener(Tp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Tp,e),window.removeEventListener("storage",t)}}const og="nterminal.terminal.showScrollProgress",Lp="nterminal:terminal-scroll-progress";function Bp(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(og)!=="false"}catch{return!0}}function Lk(e){if(typeof window<"u"){try{window.localStorage.setItem(og,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Lp,{detail:e}))}return e}function lw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===og&&e()};return window.addEventListener(Lp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Lp,e),window.removeEventListener("storage",t)}}const cg="nterminal.shortcuts.workspace.v1",Op="nterminal:workspace-shortcuts",Jo=[{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}],wh={"server.previous":Di("ArrowUp",{ctrlKey:!0}),"server.next":Di("ArrowDown",{ctrlKey:!0}),"tab.previous":Di("ArrowLeft",{ctrlKey:!0}),"tab.next":Di("ArrowRight",{ctrlKey:!0}),"tab.index":Di("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Di("KeyH",{altKey:!0})},Bk={"server.previous":Di("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Di("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Di("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Di("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Di("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Di("KeyH",{altKey:!0})};function Sa(){const e=uw(wh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cg);if(!t)return e;const s=JSON.parse(t);for(const r of Jo){const o=s[r.id];if(Kk(o)){const c=hw(o,r);Ik(c,Bk[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Py(){return JSON.stringify(Sa())}function Ok(e,t){const s=Sa(),r=Jo.find(o=>o.id===e);return r&&(s[e]=hw(t,r),dg(s)),s}function zk(e){const t=Sa();return t[e]={...wh[e]},dg(t),t}function jk(){const e=uw(wh);return dg(e),e}function ug(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===cg&&e()};return window.addEventListener(Op,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Op,e),window.removeEventListener("storage",t)}}function Hk(e,t){const s=pw(e);return!s||Wk(s)||t.indexed&&fw(e)===null||t.requiresPrimaryModifier&&!dw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":s}}function ow(e){const t=Sa();for(const s of Jo){const r=t[s.id];if(!(!r||!Fk(e,r))){if(s.indexed){if(r.code!=="Digit")continue;const o=fw(e);if(o!==null)return{id:s.id,index:o};continue}if(pw(e)===r.code)return{id:s.id,index:null}}}return null}function hg(e){return cw(Sa()[e])}function cw(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(qk(e.code)),t.join("+")}const Pk=()=>hg("split.right"),Uk=()=>hg("split.down");function Di(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function uw(e){return Object.fromEntries(Object.entries(e).map(([t,s])=>[t,{...s}]))}function Ik(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function dg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Op))}}function hw(e,t){return t.requiresPrimaryModifier&&!dw(e)?{...wh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function dw(e){return e.ctrlKey||e.altKey||e.metaKey}function Kk(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 Fk(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function fw(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 pw(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 Wk(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function qk(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const s=/^Key([A-Z])$/.exec(e);if(s?.[1])return s[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 $k="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 Yk(e="nterminal",t=new Date){return{reason:"permission",message:$k,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function Vk(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 mw=3600*1e3,Xk="local",zp=new Set,Lr=new Map;let jr={checking:!1,hasUpdates:!1,lastCheckedAt:null},fg=null,Yo=null,Ju=0,Dr=null;function Gk(e){return zp.add(e),()=>{zp.delete(e)}}function Uy(){return jr}function Zk(e){const t=iT();fg=e,pg(),jp(e,t);const s=()=>{if(document.visibilityState!=="visible"||!Hr(e,t))return;const r=jr.lastCheckedAt;(r===null||Date.now()-r>=mw)&&jp(e,t)};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),Hr(e,t)&&tT()}}function Qk(e,t){Lr.set(e,gw(t)),yl({...jr,hasUpdates:mg(),lastCheckedAt:Date.now()})}function Ff(e){e===void 0?Lr.clear():Lr.set(e,!1),yl({...jr,hasUpdates:mg()})}async function jp(e,t){if(!Hr(e,t))return;if(Dr&&Dr.api===e&&Dr.runId===t)return Dr.promise;yl({...jr,checking:!0});const s=Jk(e,t).finally(()=>{Dr?.promise===s&&(Dr=null),Hr(e,t)&&(yl({...jr,checking:!1,lastCheckedAt:Date.now()}),eT(e,t))});return Dr={api:e,runId:t,promise:s},s}async function Jk(e,t){try{const s=await e.listAgents();if(!Hr(e,t))return;const r=[{key:Xk,check:()=>e.checkUpdate()},...s.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const h=await c.check();o.set(c.key,gw(h))}catch{o.set(c.key,Lr.get(c.key)??!1)}})),!Hr(e,t))return;Lr.clear();for(const[c,h]of o)Lr.set(c,h);yl({...jr,hasUpdates:mg()})}catch{}}function eT(e,t){Hr(e,t)&&(pg(),Yo=window.setTimeout(()=>{Yo=null,Hr(e,t)&&jp(e,t)},mw))}function tT(){Ju+=1,pg(),fg=null,Dr=null,Lr.clear(),yl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function pg(){Yo!==null&&(window.clearTimeout(Yo),Yo=null)}function iT(){return Ju+=1,Ju}function Hr(e,t){return fg===e&&Ju===t}function gw(e){return e.updateAvailable===!0}function mg(){return Array.from(Lr.values()).some(Boolean)}function yl(e){jr=e;for(const t of Array.from(zp))t()}const nT=e=>new Promise(t=>setTimeout(t,e));function sT({api:e,onAgentRemoved:t}){const[s,r]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,f]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[w,S]=v.useState(null),[E,T]=v.useState(!1),[A,O]=v.useState(null);function L(D,X){c(_e=>({..._e,[D]:{..._e[D],...X}}))}const U=D=>D.id===null?e.getVersion():e.getAgentVersion(D.id),I=D=>D.id===null?e.checkUpdate():e.checkAgentUpdate(D.id),te=D=>D.id===null?e.runUpdate():e.runAgentUpdate(D.id);v.useEffect(()=>{let D=!1;e.listAgents().then(_e=>{if(D)return;const R=[{key:"local",id:null,name:"Local (main)"},..._e.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];r(R);for(const H of R)U(H).then(Q=>L(H.key,{version:Q,manualUpdate:Q.manualUpdate??null})).catch(Q=>L(H.key,{error:Q instanceof Error?Q.message:"unreachable"}))}).catch(()=>{});const X=e.getDistributedCallSettings;return typeof X=="function"&&X().then(_e=>{D||S(_e)}).catch(_e=>{D||O(_e instanceof Error?_e.message:"failed to load distributed call settings")}),()=>{D=!0}},[]);async function ee(D){L(D.key,{busy:!0,status:"checking…",error:void 0});try{const X=await I(D);Qk(D.key,X),L(D.key,{latestVersion:X.latestVersion,updateAvailable:X.updateAvailable,status:Y(X),...X.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(X){L(D.key,{busy:!1,error:X instanceof Error?X.message:"check failed"})}}async function ae(){f(!0),await Promise.all(s.map(D=>ee(D))),f(!1)}async function ue(D,X){const _e=Date.now()+18e4;for(;Date.now()<_e;){await nT(3e3);try{const R=await U(D);if(X&&R.runningVersion!==X.runningVersion)return R}catch{}}return null}async function be(D){let X=o[D.key]?.version;if(!X)try{X=await U(D),L(D.key,{version:X,manualUpdate:X.manualUpdate??null})}catch(H){return L(D.key,{busy:!1,error:H instanceof Error?H.message:"version check failed"}),"failed"}L(D.key,{busy:!0,status:"updating…",error:void 0});let _e;try{_e=await te(D)}catch(H){return L(D.key,{busy:!1,error:H instanceof Error?H.message:"update failed"}),"failed"}if(!_e.ok){const H=_e.manualUpdate??(Vk(_e.message)?Yk():null);return H?(L(D.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:H}),"manual"):(L(D.key,{busy:!1,status:void 0,error:_e.message}),"failed")}if(!_e.changed)return L(D.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Ff(D.key),"unchanged";L(D.key,{status:"restarting…"});const R=await ue(D,X);return R?(L(D.key,{busy:!1,version:R,updateAvailable:!1,status:"updated",manualUpdate:R.manualUpdate??null}),Ff(D.key),D.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(L(D.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function we(D){if(!(D.id===null||!window.confirm([`Delete secondary server "${D.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){L(D.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const _e=await e.uninstallAgent(D.id);r(R=>R.filter(H=>H.key!==D.key)),c(R=>{const H={...R};return delete H[D.key],H}),Ff(D.key),t?.(D.id),p(_e.message)}catch(_e){L(D.key,{busy:!1,status:void 0,error:_e instanceof Error?_e.message:"delete failed"})}}}async function ne(){f(!0),p(null);const D=s.filter(de=>de.id!==null),X=s.find(de=>de.id===null),_e=await Promise.all(D.map(de=>be(de))),R=_e.filter(de=>de==="failed").length;let H=_e.filter(de=>de==="manual").length,Q=null;if(X&&(Q=await be(X),Q==="manual"&&(H+=1),Q==="updated")){R>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}R>0&&H>0?p("Some servers failed and some need manual update. Check each marked row."):R>0?p("Some secondary servers failed to update. Check their rows and retry."):H>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function ie(D){return D?D.error?D.error:D.status?D.status:D.manualUpdate?"manual update required":D.version?`v${D.version.version}`:"…":"…"}function Y(D){return D.error?D.error:typeof D.updateAvailable=="boolean"?D.updateAvailable?`latest v${D.latestVersion??"available"}`:"up to date":"unknown"}function K(D){const X=D?.version;return X?`npm package v${X.runningVersion}`:""}async function re(D,X){try{await rT(X),L(D,{copiedCommand:!0}),window.setTimeout(()=>L(D,{copiedCommand:!1}),1800)}catch(_e){L(D,{error:_e instanceof Error?_e.message:"copy failed"})}}async function B(D){if(!(!w||E)){T(!0),O(null);try{const X=await e.updateDistributedCallSettings(D);S(X)}catch(X){O(X instanceof Error?X.message:"failed to save distributed call settings")}finally{T(!1)}}}function $(D,X){if(!w)return;const _e=new Set(w.settings.workerIds);X?_e.add(D):_e.delete(D),B({workerIds:Array.from(_e)})}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ae()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{ne()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,y?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsxs("div",{className:"server-addon-panel",children:[m.jsxs("div",{className:"server-addon-header",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:"Distributed calls"}),m.jsx("span",{className:"security-item-meta",children:"Programmatic worker fan-out for trusted NTerminal servers."})]}),m.jsxs("label",{className:"auth-checkbox server-addon-toggle",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.enabled??!1,disabled:!w||E,onChange:D=>{B({enabled:D.currentTarget.checked})}}),"Enabled"]})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.allowPrivateTargets??!1,disabled:!w||E||!(w?.settings.enabled??!1),onChange:D=>{B({allowPrivateTargets:D.currentTarget.checked})}}),"Allow private network targets when the CLI also requests it"]}),w?m.jsx("div",{className:"server-addon-workers","aria-label":"Distributed call workers",children:w.workers.map(D=>m.jsxs("label",{className:"auth-checkbox server-addon-worker",children:[m.jsx("input",{type:"checkbox",checked:D.enabled,disabled:E||!w.settings.enabled,onChange:X=>$(D.id,X.currentTarget.checked)}),m.jsx("span",{children:D.id===Nr?"Local (main)":D.name})]},D.id))}):null,A?m.jsx("p",{className:"settings-status settings-status-error",children:A}):null]}),m.jsx("ul",{className:"security-list",children:s.map(D=>{const X=o[D.key],_e=K(X),R=X?.manualUpdate??null,H=X?.version!==void 0&&X?.updateAvailable!==!1&&!X?.busy&&!h,Q=D.id!==null&&!X?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:D.name}),m.jsxs("span",{className:"security-item-meta",children:[_e?`${_e} — `:"",ie(X)]})]}),R?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:R.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:R.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{re(D.key,R.command)},children:X?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{be(D)},disabled:!H,children:X?.busy?"…":"Update"}),D.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{we(D)},disabled:!Q,children:"Delete"}):null]})]},D.key)})})]})}async function rT(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 xu=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"diagnostics",label:"Diagnostics"},{id:"servers",label:"Servers"}];function aT({onClose:e,api:t,updateAvailable:s=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??fh(),[t]),[h,f]=v.useState(()=>Np()),[g,p]=v.useState(()=>Ap()),[y,b]=v.useState(()=>Bp()),[w,S]=v.useState(()=>Or()),[E,T]=v.useState(()=>Sa()),[A,O]=v.useState(null),[L,U]=v.useState(null),[I,te]=v.useState("appearance"),[ee,ae]=v.useState(()=>J0()),[ue,be]=v.useState(()=>ya()),[we,ne]=v.useState(()=>sg()),[ie,Y]=v.useState([]),[K,re]=v.useState([]),[B,$]=v.useState([]),[D,X]=v.useState(5*1024*1024),[_e,R]=v.useState(!1),[H,Q]=v.useState(null),[de,ke]=v.useState(()=>ma()),[xe,Re]=v.useState(!1),[Xe,ge]=v.useState(null),G=v.useRef(null),ce=v.useRef(null),Ce=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,diagnostics:null,servers:null}),ye=v.useMemo(()=>new Set(K),[K]),De=!uT(K,B);v.useEffect(()=>rw(()=>f(Np())),[]),v.useEffect(()=>aw(()=>p(Ap())),[]),v.useEffect(()=>lw(()=>b(Bp())),[]),v.useEffect(()=>qm(()=>S(Or())),[]),v.useEffect(()=>ug(()=>T(Sa())),[]),v.useEffect(()=>ew(()=>be(ya())),[]),v.useEffect(()=>{const F=()=>ke(ma());F();const qe=window.setInterval(F,1500);return()=>window.clearInterval(qe)},[]),v.useEffect(()=>{if(!A)return;const F=Jo.find(dt=>dt.id===A);if(!F)return;const qe=dt=>{if(dt.preventDefault(),dt.stopPropagation(),dt.key==="Escape"){O(null),U(null);return}const vt=Hk(dt,F);if(!vt){U(cT(F));return}T(Ok(A,vt)),O(null),U(null)};return window.addEventListener("keydown",qe,!0),()=>window.removeEventListener("keydown",qe,!0)},[A]),v.useEffect(()=>{let F=!1;return c.listNotificationAssets().then(qe=>{F||He(qe)}).catch(qe=>{F||Q(ol(qe))}),()=>{F=!0}},[c]);function Be(F){f(Cu(Number(F)))}function Ke(F){be(Hy(Number(F)))}function le(F){te(F);const qe=ce.current,dt=Ce.current[F];if(!qe||!dt)return;const vt=Math.max(0,Iy(dt,qe)-12);typeof qe.scrollTo=="function"?qe.scrollTo({top:vt,behavior:"smooth"}):qe.scrollTop=vt}function Ee(){const F=ce.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){te(xu[xu.length-1].id);return}let qe="appearance";const dt=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const vt of xu){const pi=Ce.current[vt.id];pi&&Iy(pi,F)<=dt&&(qe=vt.id)}te(qe)}function Le(F){T(zk(F)),O(null),U(null)}function Oe(){T(jk()),O(null),U(null)}function He(F){const qe=F.assets.filter(dt=>dt.enabled).map(dt=>dt.id);Y(F.assets),re(qe),$(qe),X(F.maxFileBytes),Q(null)}async function _t(){if(ee){jy(!1),ae(!1);return}let F=we;F==="default"&&(F=await Rk(),ne(F)),F==="granted"&&(jy(!0),ae(!0))}async function Ye(F){const qe=F?.[0];if(qe){if(qe.size>D){Q(`File must be ${Wf(D)} or smaller.`),Oi();return}if(qe.type!=="video/mp4"&&qe.type!=="video/webm"){Q("Upload an MP4 or WebM video."),Oi();return}R(!0),Q(null);try{await c.uploadNotificationAsset(qe),He(await c.listNotificationAssets()),r?.()}catch(dt){Q(ol(dt))}finally{R(!1),Oi()}}}async function rt(F){R(!0),Q(null);try{await c.deleteNotificationAsset(F),He(await c.listNotificationAssets()),r?.()}catch(qe){Q(ol(qe))}finally{R(!1)}}function Oi(){G.current&&(G.current.value="")}function $i(F,qe){const dt=new Set(K);if(qe?dt.add(F):dt.delete(F),dt.size===0){Q("Keep at least one toast video selected.");return}Q(null),re(Array.from(dt))}async function Ci(){if(K.length===0){Q("Keep at least one toast video selected.");return}R(!0),Q(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:K});He(F),r?.()}catch(F){Q(ol(F))}finally{R(!1)}}async function ri(){ge(null),Re(!0);try{const F=await uk();ge(F?"Diagnostics copied.":"Copy failed in this browser."),ke(ma())}catch(F){ge(ol(F))}finally{Re(!1)}}async function zi(){ge(null),Re(!0);try{const F=await bh("manual-settings");ge(`Sent ${F.accepted} diagnostic events.`),ke(ma())}catch(F){ge(ol(F))}finally{Re(!1)}}function sn(){ok(),ke([]),ge("Diagnostics cleared.")}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:F=>F.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:xu.map(F=>m.jsxs("button",{type:"button","data-active":I===F.id?"true":"false","aria-current":I===F.id?"true":void 0,onClick:()=>le(F.id),children:[F.label,F.id==="servers"&&s?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),m.jsxs("div",{ref:ce,className:"settings-content",onScroll:Ee,children:[m.jsxs("section",{id:"settings-appearance",ref:F=>{Ce.current.appearance=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Yu.map(F=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":w===F.id,"data-active":w===F.id?"true":"false",onClick:()=>S(hE(F.id)),style:{"--settings-theme-bg":F.tokens.bg,"--settings-theme-bg-2":F.tokens.bg2,"--settings-theme-sidebar":F.tokens.bgSidebar,"--settings-theme-line":F.tokens.line,"--settings-theme-fg":F.tokens.fg,"--settings-theme-fg-2":F.tokens.fg2,"--settings-theme-accent":F.tokens.accent,"--settings-theme-xterm-bg":F.xterm.background,"--settings-theme-xterm-fg":F.xterm.foreground,"--settings-theme-xterm-selection":F.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:F.label}),m.jsx("small",{children:F.description})]})]},F.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Dp,max:Rp,step:1,value:h,"aria-label":"Terminal font size",onChange:F=>Be(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Cu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Dp,max:Rp,step:1,value:h,"aria-label":"Terminal font size value",onChange:F=>Be(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Cu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Cu(_a)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:F=>p(Ak(F.currentTarget.value)),children:Qu.map(F=>m.jsx("option",{value:F.id,children:F.label},F.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:y,onChange:F=>b(Lk(F.currentTarget.checked))}),"Show scroll progress"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:F=>{Ce.current.shortcuts=F},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:Oe,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),L?m.jsx("p",{className:"settings-error",children:L}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Jo.map(F=>{const qe=A===F.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:F.label}),m.jsx("span",{className:"settings-shortcut-group",children:F.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":qe?"true":"false",onClick:()=>{O(F.id),U(null)},children:qe?"Press keys…":cw(E[F.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Le(F.id),children:"Reset"})]})]},F.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:F=>{Ce.current.notifications=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),Sh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ee&&we==="granted",onChange:()=>{_t()},disabled:we==="denied"}),"System notification when page is hidden"]}),we==="denied"?m.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ue.enabled,onChange:F=>be(xk(F.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:ue.persistUntilDismissed?"Until closed":`${ue.durationSeconds}s`}),m.jsx("input",{type:"range",min:xp,max:Ep,step:.5,value:ue.durationSeconds,disabled:!ue.enabled||ue.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>Ke(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:xp,max:Ep,step:.5,value:ue.durationSeconds,disabled:!ue.enabled||ue.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>Ke(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ue.enabled||ue.persistUntilDismissed,onClick:()=>be(Hy($o)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ue.persistUntilDismissed,disabled:!ue.enabled,onChange:F=>be(Ek(F.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[Wf(D)," max"]})]}),m.jsx("input",{ref:G,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{Ye(F.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:_e,onClick:()=>G.current?.click(),children:"Upload video"}),H?m.jsx("p",{className:"settings-error",children:H}):null,ie.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:ie.map(F=>m.jsxs("li",{"data-enabled":ye.has(F.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:ye.has(F.id),disabled:_e,"aria-label":`Use ${F.filename}`,onChange:qe=>$i(F.id,qe.currentTarget.checked)}),m.jsx("video",{src:F.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:F.filename}),m.jsx("small",{children:F.source==="built-in"?"Built-in":Wf(F.size)})]})]}),F.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:_e,"aria-label":`Delete ${F.filename}`,onClick:()=>{rt(F.id)},children:"x"}):null]},F.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:_e||ie.length===0||!De,onClick:()=>{Ci()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:F=>{Ce.current.security=F},className:"settings-section-group",children:m.jsx(sk,{api:c})}),m.jsxs("section",{id:"settings-diagnostics",ref:F=>{Ce.current.diagnostics=F},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsxs("div",{children:[m.jsx("h3",{children:"Diagnostics"}),m.jsx("p",{className:"muted settings-control-description",children:"Recent browser lifecycle and auth transition events for troubleshooting."})]}),m.jsx("span",{className:"settings-diagnostics-count",children:de.length})]}),m.jsxs("div",{className:"settings-diagnostics-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||de.length===0,onClick:()=>{ri()},children:"Copy"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||de.length===0,onClick:()=>{zi()},children:"Send"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||de.length===0,onClick:sn,children:"Clear"})]}),Xe?m.jsx("p",{className:"settings-status",children:Xe}):null,de.length>0?m.jsx("ol",{className:"settings-diagnostics-list","aria-label":"Recent diagnostics",children:de.slice(-8).reverse().map((F,qe)=>m.jsxs("li",{children:[m.jsx("span",{children:lT(F.at)}),m.jsx("strong",{children:F.event}),F.data?m.jsx("code",{children:oT(F.data)}):null]},`${F.at}:${F.event}:${qe}`))}):m.jsx("p",{className:"muted",children:"No diagnostics recorded yet."})]}),m.jsx("div",{id:"settings-servers",ref:F=>{Ce.current.servers=F},className:"settings-section-group",children:m.jsx(sT,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Iy(e,t){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();return s.top-r.top+t.scrollTop}function Wf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function ol(e){return e instanceof Error?e.message:"Request failed."}function lT(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function oT(e){return Object.entries(e).slice(0,5).map(([t,s])=>`${t}=${String(s)}`).join(" ")}function cT(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 uT(e,t){if(e.length!==t.length)return!1;const s=new Set(t);return e.every(r=>s.has(r))}class oa extends Error{constructor(t,s){super(s),this.status=t,this.name="UploadClientError"}status}function hT(e){const t=e.createXhr?.()??new XMLHttpRequest,s=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));s.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())s.append(`file${o}`,c.file);return new Promise((o,c)=>{let h=!1;const f=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{h||(h=!0,f(),o(b))},p=b=>{h||(h=!0,f(),c(b))},y=()=>{t.abort(),p(new oa(0,"Upload aborted."))};if(e.signal?.aborted){p(new oa(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{p(new oa(t.status,"Invalid upload response."))}return}p(new oa(t.status,dT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new oa(0,"Upload failed.")),t.onabort=()=>p(new oa(0,"Upload aborted.")),t.ontimeout=()=>p(new oa(0,"Upload timed out.")),t.send(s)})}function dT(e,t){try{const s=JSON.parse(e),r=typeof s.error=="string"?s.error:s.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}const fT="modulepreload",pT=function(e){return"/"+e},Ky={},gg=function(t,s,r){let o=Promise.resolve();if(s&&s.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=h?.nonce||h?.getAttribute("nonce");o=g(s.map(p=>{if(p=pT(p),p in Ky)return;Ky[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":fT,y||(w.as="script"),w.crossOrigin="",w.href=p,f&&w.setAttribute("nonce",f),document.head.appendChild(w),y)return new Promise((S,E)=>{w.addEventListener("load",S),w.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(h){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=h,window.dispatchEvent(f),!f.defaultPrevented)throw h}return o.then(h=>{for(const f of h||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},mT=v.lazy(()=>gg(()=>import("./MarkdownPreview-jgdUGtLt.js"),__vite__mapDeps([0,1])));function gT({api:e,activeTerminalId:t,activeTerminalCwd:s,workspaceRootPath:r=null,onOpenFile:o}){const[c,h]=v.useState(null),[f,g]=v.useState(""),[p,y]=v.useState({}),[b,w]=v.useState(()=>new Set),[S,E]=v.useState(null),[T,A]=v.useState({type:"empty"}),[O,L]=v.useState("idle"),[U,I]=v.useState(null),te=v.useRef(null),ee=v.useRef(null),ae=v.useRef(!1),ue=v.useRef(0),be=v.useRef(null);be.current===null&&t&&(be.current=t);const we=be.current,ne=r?vT(r):t?Fy(t,s):null,ie=c?[c.rootPath,f].filter(Boolean).join("/"):"",Y=S?.path??null;v.useEffect(()=>(ae.current=!0,()=>{ae.current=!1,ue.current+=1,ce()}),[]),v.useEffect(()=>{be.current=t,ee.current=null,K(ne)},[e]),v.useEffect(()=>{r&&ne!==ee.current&&re(r,ne)},[r,ne]),v.useEffect(()=>{if(r||!we||t!==we)return;const le=Fy(we,s);le!==ee.current&&B(we,le)},[we,t,s,r]);async function K(le=ne){if(r){await re(r,le);return}await B(t,le)}async function re(le,Ee=ne){const Le=Ce();if(ee.current=Ee,ce(),h(null),g(""),y({}),w(new Set),E(null),A({type:"empty"}),I(null),!le){L("idle");return}L("loading");try{const Oe=await e.createFileRoot({path:le});if(!ye(Le))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const He=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!ye(Le))return;X(He),L("idle")}catch(Oe){ye(Le)&&(I(Ws(Oe)),L("idle"))}}async function B(le,Ee=ne){const Le=Ce();if(ee.current=Ee,ce(),h(null),g(""),y({}),w(new Set),E(null),A({type:"empty"}),I(null),!le){L("idle");return}L("loading");try{const Oe=await e.createFileRoot({terminalId:le});if(!ye(Le))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const He=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!ye(Le))return;X(He),L("idle")}catch(Oe){if(await De(Oe,Le))return;ye(Le)&&(I(Ws(Oe)),L("idle"))}}async function $(le=f,Ee=c){if(!Ee)return;const Le=Ce();L("loading"),I(null);try{const Oe=await e.listFiles({rootToken:Ee.rootToken,path:le});if(!ye(Le))return;X(Oe),L("idle")}catch(Oe){if(await De(Oe,Le))return;ye(Le)&&(I(Ws(Oe)),L("idle"))}}async function D(){if(r){await re(r,ne);return}be.current=t,await B(t,ne)}function X(le){y(Ee=>({...Ee,[le.path]:bT(le.entries)}))}async function _e(le){if(!(!qf(le)||!c)){if(E(le),I(null),le.kind==="directory"){g(le.path),G(),await H(le);return}if(g(ca(le.path)),le.editable){await de(le);return}le.previewKind!=="none"&&await xe(le,le.previewKind)}}async function R(le){if(!(!qf(le)||!c)){if(E(le),I(null),le.kind==="directory"){g(le.path),G(),await H(le);return}if(g(ca(le.path)),le.editable){await ke(le);return}le.previewKind!=="none"&&await xe(le,le.previewKind)}}async function H(le){if(b.has(le.path)){w(Ee=>{const Le=new Set(Ee);return Le.delete(le.path),Le});return}w(Ee=>new Set(Ee).add(le.path)),await $(le.path)}function Q(le,Ee){le.key==="Enter"&&(le.preventDefault(),R(Ee))}async function de(le){if(!c)return;const Ee=Ce();L("loading"),ce();try{const Le=await e.readFile({rootToken:c.rootToken,path:le.path});if(!ye(Ee))return;A({type:"text-preview",file:le,read:Le}),L("idle")}catch(Le){if(await De(Le,Ee))return;ye(Ee)&&(I(Ws(Le)),L("idle"))}}async function ke(le){if(!c)return;const Ee=Ce();L("loading");try{await o({rootToken:c.rootToken,path:le.path,...t?{terminalId:t}:{}}),ye(Ee)&&L("idle")}catch(Le){if(await De(Le,Ee))return;ye(Ee)&&(I(Ws(Le)),L("idle"))}}async function xe(le,Ee){if(!c)return;const Le=Ce();L("loading"),ce();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:le.path});if(!ye(Le))return;const He=URL.createObjectURL(Oe);if(!ye(Le)){URL.revokeObjectURL(He);return}te.current=He,A({type:"preview",file:le,previewKind:Ee,url:He}),L("idle")}catch(Oe){if(await De(Oe,Le))return;ye(Le)&&(I(Ws(Oe)),L("idle"))}}async function Re(le){if(!c)return;const Ee=le==="file"?"New file":"New folder",Le=window.prompt(Ee,""),Oe=S?S.kind==="directory"?S.path:ca(S.path):f,He=Wy(Le,Oe);if(He){I(null);try{const _t=await e.createFileEntry({rootToken:c.rootToken,path:He,kind:le});E(_t.entry),await $(Oe)}catch(_t){if(await De(_t))return;I(Ws(_t))}}}async function Xe(){if(!c||!S)return;const le=window.prompt("Move selected entry",S.path),Ee=Wy(le,"");if(!Ee||Ee===S.path)return;const Le=ca(S.path),Oe=ca(Ee);I(null);try{const He=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:S.path,destinationPath:Ee});E(He.entry),g(He.entry.kind==="directory"?He.entry.path:ca(He.entry.path)),G(),await $(Le),Oe!==Le&&await $(Oe)}catch(He){if(await De(He))return;I(Ws(He))}}async function ge(){if(!c||!S)return;const le=S.path,Ee=ca(le);I(null);try{const Le=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:S.path}),Oe=Le.descendantCount>0?` and ${Le.descendantCount} nested item${Le.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Le.path}${Oe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:S.path,previewToken:Le.previewToken}),E(null),g(Ee),w(He=>{const _t=new Set(He);for(const Ye of He)(Ye===le||Ye.startsWith(`${le}/`))&&_t.delete(Ye);return _t}),G(),await $(Ee)}catch(Le){if(await De(Le))return;I(Ws(Le))}}function G(){ue.current+=1,ce(),A({type:"empty"})}function ce(){te.current&&(URL.revokeObjectURL(te.current),te.current=null)}function Ce(){return ue.current+=1,ue.current}function ye(le){return ae.current&&le===ue.current}async function De(le,Ee){return yT(le)?(Ee!==void 0&&!ye(Ee)||await K(ne),!0):!1}function Be(le,Ee){const Le=qf(le),Oe=le.kind==="directory"&&b.has(le.path),He=p[le.path]??[],_t={"--file-tree-depth":Ee};return m.jsxs(Si.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":le.kind,"data-expanded":Oe,"data-active":Y===le.path,disabled:!Le,style:_t,"aria-expanded":le.kind==="directory"?Oe:void 0,"aria-label":`${le.kind==="directory"?"Open folder":"Open file"} ${le.name}`,title:le.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{_e(le)},onDoubleClick:()=>{R(le)},onKeyDown:Ye=>Q(Ye,le),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:le.kind==="directory"?Oe?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:le.name}),m.jsx("small",{children:_T(le)})]}),Oe?m.jsx("div",{className:"file-tree-children",role:"group",children:He.map(Ye=>Be(Ye,Ee+1))}):null]},le.path)}const Ke=p[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":O==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:ie,children:ie||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{D()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Re("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Re("directory")},children:"▣"})]})]}),U?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:U}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":ie?`Files in ${ie}`:"Files",children:Ke.map(le=>Be(le,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:S?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{Xe()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{ge()},children:"Delete"})]})]}),O==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&O!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?m.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?m.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(mT,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function qf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function _T(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Fy(e,t){return`${e}\0${t??""}`}function vT(e){return`workspace\0${e}`}function bT(e){return[...e].sort((t,s)=>t.kind==="directory"&&s.kind!=="directory"?-1:t.kind!=="directory"&&s.kind==="directory"?1:t.name.localeCompare(s.name))}function ca(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Wy(e,t){if(e===null)return null;const s=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return s?!t||s.includes("/")?s:`${t}/${s}`:null}function Ws(e){return e instanceof Error?e.message:"Request failed"}function yT(e){return e instanceof us&&e.status===409&&e.message==="terminal_cwd_changed"}const ST=v.lazy(()=>gg(()=>import("./MarkdownPreview-jgdUGtLt.js"),__vite__mapDeps([0,1])));function qy({api:e,editor:t,canClose:s,onClose:r}){const[o,c]=v.useState(t.read),[h,f]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[w,S]=v.useState(!1),[E,T]=v.useState("edit"),A=v.useRef(t),O=v.useRef(t.read),L=v.useRef(t.read.content),U=v.useRef(!1),I=v.useRef(!1),te=v.useRef(0),ee=h!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(I.current=!0,()=>{I.current=!1,te.current+=1}),[]),v.useEffect(()=>{te.current+=1,U.current=!1,A.current=t,O.current=t.read,L.current=t.read.content,c(t.read),f(t.read.content),p("idle"),b(null),S(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{A.current=t},[t]),v.useEffect(()=>{O.current=o},[o]),v.useEffect(()=>{L.current=h},[h]),v.useEffect(()=>{if(h===o.content||w)return;const ne=window.setInterval(()=>{!U.current&&L.current!==O.current.content&&ae()},1e3);return()=>window.clearInterval(ne)},[h===o.content,w,t.id]);async function ae(){if(U.current)return;const ne=L.current,ie=O.current;if(ne===ie.content)return;const Y=A.current,K=te.current;U.current=!0,p("saving"),b(null),S(!1);try{const re=await e.writeFile({rootToken:Y.rootToken,path:Y.path,content:ne,expectedVersion:ie.version});if(!I.current||K!==te.current)return;const B={...ie,content:ne,version:re.version};O.current=B,c(B),p(L.current===ne?"saved":"idle")}catch(re){if(!I.current||K!==te.current)return;if(re instanceof us&&re.status===409){S(!0),p("idle");return}b(wT(re)),p("idle")}finally{K===te.current&&(U.current=!1)}}const ue=g==="saving"?"saving":g==="saved"?"saved":o.language,be=o.language==="markdown",we=be&&E==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:ue}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ee,onClick:()=>{ae()},children:"Save"}),be?m.jsx("button",{type:"button","aria-label":`${we?"Edit":"Preview"} ${t.title}`,onClick:()=>T(ne=>ne==="preview"?"edit":"preview"),children:we?"Edit":"Preview"}):null,s?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,w?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,we?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(ST,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:ne=>{const ie=ne.target.value;L.current=ie,f(ie),p("idle"),b(null),S(!1)}})]})}function wT(e){return e instanceof Error?e.message:"Request failed"}var CT=2,xT=1,ET=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,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},f=h.top+h.bottom,g=h.right+h.left,p=r-f,y=o-g-t;return{cols:Math.max(CT,Math.floor(y/e.css.cell.width)),rows:Math.max(xT,Math.floor(p/e.css.cell.height))}}};var _w=Object.defineProperty,kT=Object.getOwnPropertyDescriptor,TT=(e,t)=>{for(var s in t)_w(e,s,{get:t[s],enumerable:!0})},Qt=(e,t,s,r)=>{for(var o=r>1?void 0:r?kT(t,s):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(o=(r?h(t,s,o):h(o))||o);return r&&o&&_w(t,s,o),o},Me=(e,t)=>(s,r)=>t(s,r,e),$y="Terminal input",Hp={get:()=>$y,set:e=>$y=e},Yy="Too much output to announce, navigate to rows manually to read",Pp={get:()=>Yy,set:e=>Yy=e};function DT(e){return e.replace(/\r?\n/g,"\r")}function RT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function MT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function NT(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");vw(o,t,s,r)}}function vw(e,t,s,r){e=DT(e),e=RT(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function bw(e,t,s){let r=s.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Vy(e,t,s,r,o){bw(e,t,s),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Mr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ch(e,t=0,s=e.length){let r="";for(let o=t;o<s;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var AT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<s;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=s)return this._interim=h,r;let f=e.charCodeAt(c);56320<=f&&f<=57343?t[r++]=(h-55296)*1024+f-56320+65536:(t[r++]=h,t[r++]=f);continue}h!==65279&&(t[r++]=h)}return r}},LT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o,c,h,f,g=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 E=0,T;for(;(T=this.interim[++E]&63)&&E<4;)S<<=6,S|=T;let A=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,O=A-E;for(;p<O;){if(p>=s)return 0;if(T=e[p++],(T&192)!==128){p--,w=!0;break}else this.interim[E++]=T,S<<=6,S|=T&63}w||(A===2?S<128?p--:t[r++]=S:A===3?S<2048||S>=55296&&S<=57343||S===65279||(t[r++]=S):S<65536||S>1114111||(t[r++]=S)),this.interim.fill(0)}let y=s-4,b=p;for(;b<s;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((h=e[b+2])&128)&&!((f=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=h,t[r++]=f,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[b++],(h&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[b++],(h&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=h,r;if(f=e[b++],(f&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|f&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},yw="",Ar=" ",dc=class Sw{constructor(){this.fg=0,this.bg=0,this.extended=new eh}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 Sw;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}},eh=class ww{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 ww(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Zn=class Cw extends dc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new eh,this.combinedData=""}static fromCharData(t){let s=new Cw;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Mr(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 s=!1;if(t[1].length>2)s=!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:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xy="di$target",Up="di$dependencies",$f=new Map;function BT(e){return e[Up]||[]}function Bi(e){if($f.has(e))return $f.get(e);let t=function(s,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");OT(t,s,o)};return t._id=e,$f.set(e,t),t}function OT(e,t,s){t[Xy]===t?t[Up].push({id:e,index:s}):(t[Up]=[{id:e,index:s}],t[Xy]=t)}var tn=Bi("BufferService"),xw=Bi("CoreMouseService"),Ea=Bi("CoreService"),zT=Bi("CharsetService"),_g=Bi("InstantiationService"),Ew=Bi("LogService"),nn=Bi("OptionsService"),kw=Bi("OscLinkService"),jT=Bi("UnicodeService"),fc=Bi("DecorationService"),Ip=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new Zn,h=s.getTrimmedLength(),f=-1,g=-1,p=!1;for(let y=0;y<h;y++)if(!(g===-1&&!s.hasContent(y))){if(s.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,f=c.extended.urlId;continue}else p=c.extended.urlId!==f;else g!==-1&&(p=!0);if(p||g!==-1&&y===h-1){let b=this._oscLinkService.getLinkData(f)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:y+(!p&&y===h-1?1:0),y:e}},S=!1;if(!o?.allowNonHttpProtocols)try{let E=new URL(b);["http:","https:"].includes(E.protocol)||(S=!0)}catch{S=!0}S||r.push({text:b,range:w,activate:(E,T)=>o?o.activate(E,T,w):HT(E,T),hover:(E,T)=>o?.hover?.(E,T,w),leave:(E,T)=>o?.leave?.(E,T,w)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};Ip=Qt([Me(0,tn),Me(1,nn),Me(2,kw)],Ip);function HT(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var xh=Bi("CharSizeService"),Gs=Bi("CoreBrowserService"),vg=Bi("MouseService"),Zs=Bi("RenderService"),PT=Bi("SelectionService"),Tw=Bi("CharacterJoinerService"),Tl=Bi("ThemeService"),Dw=Bi("LinkProviderService"),UT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Gy.isErrorNoTelemetry(e)?new Gy(e.message+`
|
|
18
|
+
|
|
19
|
+
`+e.stack):new Error(e.message+`
|
|
20
|
+
|
|
21
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},IT=new UT;function zu(e){KT(e)||IT.onUnexpectedError(e)}var Kp="Canceled";function KT(e){return e instanceof FT?!0:e instanceof Error&&e.name===Kp&&e.message===Kp}var FT=class extends Error{constructor(){super(Kp),this.name=this.message}};function WT(e){return new Error(`Illegal argument: ${e}`)}var Gy=class Fp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Fp)return t;let s=new Fp;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Wp=class Rw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Rw.prototype)}};function Rn(e,t=0){return e[e.length-(1+t)]}var qT;(e=>{function t(c){return c<0}e.isLessThan=t;function s(c){return c<=0}e.isLessThanOrEqual=s;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(qT||={});function $T(e,t){let s=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(s,arguments))),o}}var Mw;(e=>{function t(I){return I&&typeof I=="object"&&typeof I[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*o(I){yield I}e.single=o;function c(I){return t(I)?I:o(I)}e.wrap=c;function h(I){return I||s}e.from=h;function*f(I){for(let te=I.length-1;te>=0;te--)yield I[te]}e.reverse=f;function g(I){return!I||I[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(I){return I[Symbol.iterator]().next().value}e.first=p;function y(I,te){let ee=0;for(let ae of I)if(te(ae,ee++))return!0;return!1}e.some=y;function b(I,te){for(let ee of I)if(te(ee))return ee}e.find=b;function*w(I,te){for(let ee of I)te(ee)&&(yield ee)}e.filter=w;function*S(I,te){let ee=0;for(let ae of I)yield te(ae,ee++)}e.map=S;function*E(I,te){let ee=0;for(let ae of I)yield*te(ae,ee++)}e.flatMap=E;function*T(...I){for(let te of I)yield*te}e.concat=T;function A(I,te,ee){let ae=ee;for(let ue of I)ae=te(ae,ue);return ae}e.reduce=A;function*O(I,te,ee=I.length){for(te<0&&(te+=I.length),ee<0?ee+=I.length:ee>I.length&&(ee=I.length);te<ee;te++)yield I[te]}e.slice=O;function L(I,te=Number.POSITIVE_INFINITY){let ee=[];if(te===0)return[ee,I];let ae=I[Symbol.iterator]();for(let ue=0;ue<te;ue++){let be=ae.next();if(be.done)return[ee,e.empty()];ee.push(be.value)}return[ee,{[Symbol.iterator](){return ae}}]}e.consume=L;async function U(I){let te=[];for await(let ee of I)te.push(ee);return Promise.resolve(te)}e.asyncToArray=U})(Mw||={});function wa(e){if(Mw.is(e)){let t=[];for(let s of e)if(s)try{s.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 YT(...e){return Pt(()=>wa(e))}function Pt(e){return{dispose:$T(()=>{e()})}}var Nw=class Aw{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{wa(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Aw.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)}};Nw.DISABLE_DISPOSED_WARNING=!1;var Br=Nw,tt=class{constructor(){this._store=new Br,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};tt.None=Object.freeze({dispose(){}});var Sl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Vs=typeof window=="object"?window:globalThis,qp=class $p{constructor(t){this.element=t,this.next=$p.Undefined,this.prev=$p.Undefined}};qp.Undefined=new qp(void 0);var qt=qp,Zy=class{constructor(){this._first=qt.Undefined,this._last=qt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===qt.Undefined}clear(){let e=this._first;for(;e!==qt.Undefined;){let t=e.next;e.prev=qt.Undefined,e.next=qt.Undefined,e=t}this._first=qt.Undefined,this._last=qt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new qt(e);if(this._first===qt.Undefined)this._first=s,this._last=s;else if(t){let o=this._last;this._last=s,s.prev=o,o.next=s}else{let o=this._first;this._first=s,s.next=o,o.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==qt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==qt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==qt.Undefined&&e.next!==qt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===qt.Undefined&&e.next===qt.Undefined?(this._first=qt.Undefined,this._last=qt.Undefined):e.next===qt.Undefined?(this._last=this._last.prev,this._last.next=qt.Undefined):e.prev===qt.Undefined&&(this._first=this._first.next,this._first.prev=qt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==qt.Undefined;)yield e.element,e=e.next}},VT=globalThis.performance&&typeof globalThis.performance.now=="function",XT=class Lw{static create(t){return new Lw(t)}constructor(t){this._now=VT&&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}},qi;(e=>{e.None=()=>tt.None;function t(ie,Y){return b(ie,()=>{},0,void 0,!0,void 0,Y)}e.defer=t;function s(ie){return(Y,K=null,re)=>{let B=!1,$;return $=ie(D=>{if(!B)return $?$.dispose():B=!0,Y.call(K,D)},null,re),B&&$.dispose(),$}}e.once=s;function r(ie,Y,K){return p((re,B=null,$)=>ie(D=>re.call(B,Y(D)),null,$),K)}e.map=r;function o(ie,Y,K){return p((re,B=null,$)=>ie(D=>{Y(D),re.call(B,D)},null,$),K)}e.forEach=o;function c(ie,Y,K){return p((re,B=null,$)=>ie(D=>Y(D)&&re.call(B,D),null,$),K)}e.filter=c;function h(ie){return ie}e.signal=h;function f(...ie){return(Y,K=null,re)=>{let B=YT(...ie.map($=>$(D=>Y.call(K,D))));return y(B,re)}}e.any=f;function g(ie,Y,K,re){let B=K;return r(ie,$=>(B=Y(B,$),B),re)}e.reduce=g;function p(ie,Y){let K,re={onWillAddFirstListener(){K=ie(B.fire,B)},onDidRemoveLastListener(){K?.dispose()}},B=new Te(re);return Y?.add(B),B.event}function y(ie,Y){return Y instanceof Array?Y.push(ie):Y&&Y.add(ie),ie}function b(ie,Y,K=100,re=!1,B=!1,$,D){let X,_e,R,H=0,Q,de={leakWarningThreshold:$,onWillAddFirstListener(){X=ie(xe=>{H++,_e=Y(_e,xe),re&&!R&&(ke.fire(_e),_e=void 0),Q=()=>{let Re=_e;_e=void 0,R=void 0,(!re||H>1)&&ke.fire(Re),H=0},typeof K=="number"?(clearTimeout(R),R=setTimeout(Q,K)):R===void 0&&(R=0,queueMicrotask(Q))})},onWillRemoveListener(){B&&H>0&&Q?.()},onDidRemoveLastListener(){Q=void 0,X.dispose()}},ke=new Te(de);return D?.add(ke),ke.event}e.debounce=b;function w(ie,Y=0,K){return e.debounce(ie,(re,B)=>re?(re.push(B),re):[B],Y,void 0,!0,void 0,K)}e.accumulate=w;function S(ie,Y=(re,B)=>re===B,K){let re=!0,B;return c(ie,$=>{let D=re||!Y($,B);return re=!1,B=$,D},K)}e.latch=S;function E(ie,Y,K){return[e.filter(ie,Y,K),e.filter(ie,re=>!Y(re),K)]}e.split=E;function T(ie,Y=!1,K=[],re){let B=K.slice(),$=ie(_e=>{B?B.push(_e):X.fire(_e)});re&&re.add($);let D=()=>{B?.forEach(_e=>X.fire(_e)),B=null},X=new Te({onWillAddFirstListener(){$||($=ie(_e=>X.fire(_e)),re&&re.add($))},onDidAddFirstListener(){B&&(Y?setTimeout(D):D())},onDidRemoveLastListener(){$&&$.dispose(),$=null}});return re&&re.add(X),X.event}e.buffer=T;function A(ie,Y){return(K,re,B)=>{let $=Y(new L);return ie(function(D){let X=$.evaluate(D);X!==O&&K.call(re,X)},void 0,B)}}e.chain=A;let O=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(Y){return this.steps.push(Y),this}forEach(Y){return this.steps.push(K=>(Y(K),K)),this}filter(Y){return this.steps.push(K=>Y(K)?K:O),this}reduce(Y,K){let re=K;return this.steps.push(B=>(re=Y(re,B),re)),this}latch(Y=(K,re)=>K===re){let K=!0,re;return this.steps.push(B=>{let $=K||!Y(B,re);return K=!1,re=B,$?B:O}),this}evaluate(Y){for(let K of this.steps)if(Y=K(Y),Y===O)break;return Y}}function U(ie,Y,K=re=>re){let re=(...X)=>D.fire(K(...X)),B=()=>ie.on(Y,re),$=()=>ie.removeListener(Y,re),D=new Te({onWillAddFirstListener:B,onDidRemoveLastListener:$});return D.event}e.fromNodeEventEmitter=U;function I(ie,Y,K=re=>re){let re=(...X)=>D.fire(K(...X)),B=()=>ie.addEventListener(Y,re),$=()=>ie.removeEventListener(Y,re),D=new Te({onWillAddFirstListener:B,onDidRemoveLastListener:$});return D.event}e.fromDOMEventEmitter=I;function te(ie){return new Promise(Y=>s(ie)(Y))}e.toPromise=te;function ee(ie){let Y=new Te;return ie.then(K=>{Y.fire(K)},()=>{Y.fire(void 0)}).finally(()=>{Y.dispose()}),Y.event}e.fromPromise=ee;function ae(ie,Y){return ie(K=>Y.fire(K))}e.forward=ae;function ue(ie,Y,K){return Y(K),ie(re=>Y(re))}e.runAndSubscribe=ue;class be{constructor(Y,K){this._observable=Y,this._counter=0,this._hasChanged=!1;let re={onWillAddFirstListener:()=>{Y.addObserver(this)},onDidRemoveLastListener:()=>{Y.removeObserver(this)}};this.emitter=new Te(re),K&&K.add(this.emitter)}beginUpdate(Y){this._counter++}handlePossibleChange(Y){}handleChange(Y,K){this._hasChanged=!0}endUpdate(Y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function we(ie,Y){return new be(ie,Y).emitter.event}e.fromObservable=we;function ne(ie){return(Y,K,re)=>{let B=0,$=!1,D={beginUpdate(){B++},endUpdate(){B--,B===0&&(ie.reportChanges(),$&&($=!1,Y.call(K)))},handlePossibleChange(){},handleChange(){$=!0}};ie.addObserver(D),ie.reportChanges();let X={dispose(){ie.removeObserver(D)}};return re instanceof Br?re.add(X):Array.isArray(re)&&re.push(X),X}}e.fromObservableLight=ne})(qi||={});var Yp=class Vp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vp._idPool++}`,Vp.all.add(this)}start(t){this._stopWatch=new XT,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}}};Yp.all=new Set,Yp._idPool=0;var GT=Yp,ZT=-1,Bw=class Ow{constructor(t,s,r=(Ow._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let r=this.threshold;if(r<=0||s<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[c,h]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${h}):`;console.warn(f),console.warn(c);let g=new eD(f,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,o]of this._stacks)(!t||s<o)&&(t=[r,o],s=o);return t}};Bw._idPool=1;var QT=Bw,JT=class zw{constructor(t){this.value=t}static create(){let t=new Error;return new zw(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},eD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},tD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},iD=0,Yf=class{constructor(e){this.value=e,this.id=iD++}},nD=2,sD,Te=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new QT(e?.onListenerError??zu,this._options?.leakWarningThreshold??ZT):void 0,this._perfMon=this._options?._profName?new GT(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,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new tD(`${h}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||zu)(g),tt.None}if(this._disposed)return tt.None;t&&(e=e.bind(t));let r=new Yf(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=JT.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Yf?(this._deliveryQueue??=new rD,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Pt(()=>{o?.(),this._removeListener(r)});return s instanceof Br?s.add(c):Array.isArray(s)&&s.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-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[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*nD<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||zu;if(!s){e.value(t);return}try{e.value(t)}catch(r){s(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 Yf)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}},rD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Xp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Xp.INSTANCE=new Xp;var bg=Xp;function aD(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}bg.INSTANCE.onDidChangeZoomLevel;function lD(e){return bg.INSTANCE.getZoomFactor(e)}bg.INSTANCE.onDidChangeFullscreen;var Dl=typeof navigator=="object"?navigator.userAgent:"",Gp=Dl.indexOf("Firefox")>=0,oD=Dl.indexOf("AppleWebKit")>=0,yg=Dl.indexOf("Chrome")>=0,cD=!yg&&Dl.indexOf("Safari")>=0;Dl.indexOf("Electron/")>=0;Dl.indexOf("Android")>=0;var Vf=!1;if(typeof Vs.matchMedia=="function"){let e=Vs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Vs.matchMedia("(display-mode: fullscreen)");Vf=e.matches,aD(Vs,e,({matches:s})=>{Vf&&t.matches||(Vf=s)})}var dl="en",Zp=!1,Qp=!1,ju=!1,jw=!1,Eu,Hu=dl,Qy=dl,uD,$s,va=globalThis,An;typeof va.vscode<"u"&&typeof va.vscode.process<"u"?An=va.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(An=process);var hD=typeof An?.versions?.electron=="string",dD=hD&&An?.type==="renderer";if(typeof An=="object"){Zp=An.platform==="win32",Qp=An.platform==="darwin",ju=An.platform==="linux",ju&&An.env.SNAP&&An.env.SNAP_REVISION,An.env.CI||An.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Eu=dl,Hu=dl;let e=An.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Eu=t.userLocale,Qy=t.osLocale,Hu=t.resolvedLanguage||dl,uD=t.languagePack?.translationsConfigFile}catch{}jw=!0}else typeof navigator=="object"&&!dD?($s=navigator.userAgent,Zp=$s.indexOf("Windows")>=0,Qp=$s.indexOf("Macintosh")>=0,($s.indexOf("Macintosh")>=0||$s.indexOf("iPad")>=0||$s.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ju=$s.indexOf("Linux")>=0,$s?.indexOf("Mobi")>=0,Hu=globalThis._VSCODE_NLS_LANGUAGE||dl,Eu=navigator.language.toLowerCase(),Qy=Eu):console.error("Unable to resolve platform.");var Hw=Zp,xs=Qp,fD=ju,Jy=jw,Es=$s,Cr=Hu,pD;(e=>{function t(){return Cr}e.value=t;function s(){return Cr.length===2?Cr==="en":Cr.length>=3?Cr[0]==="e"&&Cr[1]==="n"&&Cr[2]==="-":!1}e.isDefaultVariant=s;function r(){return Cr==="en"}e.isDefault=r})(pD||={});var mD=typeof va.postMessage=="function"&&!va.importScripts;(()=>{if(mD){let e=[];va.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===s.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return s=>{let r=++t;e.push({id:r,callback:s}),va.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var gD=!!(Es&&Es.indexOf("Chrome")>=0);Es&&Es.indexOf("Firefox")>=0;!gD&&Es&&Es.indexOf("Safari")>=0;Es&&Es.indexOf("Edg/")>=0;Es&&Es.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Jy||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Jy||cl&&cl.clipboard&&cl.clipboard.readText;var Sg=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}},Xf=new Sg,eS=new Sg,tS=new Sg,_D=new Array(230),Pw;(e=>{function t(f){return Xf.keyCodeToStr(f)}e.toString=t;function s(f){return Xf.strToKeyCode(f)}e.fromString=s;function r(f){return eS.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return tS.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return eS.strToKeyCode(f)||tS.strToKeyCode(f)}e.fromUserSettings=c;function h(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 Xf.keyCodeToStr(f)}e.toElectronAccelerator=h})(Pw||={});var vD=class Uw{constructor(t,s,r,o,c){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Uw&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${s}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bD=class{constructor(e){if(e.length===0)throw WT("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;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 yD(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Pw.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Gp)switch(t){case 59:return 85;case 60:if(fD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(xs)return 57;break}else if(oD&&(xs&&t===93||!xs&&t===92))return 57;return _D[t]||0}var SD=xs?256:2048,wD=512,CD=1024,xD=xs?2048:256,iS=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=yD(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=SD),this.altKey&&(t|=wD),this.shiftKey&&(t|=CD),this.metaKey&&(t|=xD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new vD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},nS=new WeakMap;function ED(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var kD=class{static getSameOriginWindowChain(e){let t=nS.get(e);if(!t){t=[],nS.set(e,t);let s=e,r;do r=ED(s),r?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=r;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let h=c.window.deref();if(s+=h?.scrollY??0,r+=h?.scrollX??0,h===t||!c.iframeElement)break;let f=c.iframeElement.getBoundingClientRect();s+=f.top,r+=f.left}return{top:s,left:r}}},ku=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 s=kD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},sS=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let r=!1;if(yg){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Gp&&!xs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")cD&&Hw?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Gp&&!xs?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*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Iw=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),TD;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof DD?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Iw})})(TD||={});var DD=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Iw:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},wg=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Wp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Wp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},RD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Wp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Pt(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},MD;(e=>{async function t(r){let o,c=await Promise.all(r.map(h=>h.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return c}e.settled=t;function s(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(h){c(h)}})}e.withAsyncBody=s})(MD||={});var rS=class Yn{static fromArray(t){return new Yn(s=>{s.emitMany(t)})}static fromPromise(t){return new Yn(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Yn(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new Yn(async s=>{await Promise.all(t.map(async r=>{for await(let o of r)s.emitOne(o)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new Te,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 qi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Yn(async r=>{for await(let o of t)r.emitOne(s(o))})}map(t){return Yn.map(this,t)}static filter(t,s){return new Yn(async r=>{for await(let o of t)s(o)&&r.emitOne(o)})}filter(t){return Yn.filter(this,t)}static coalesce(t){return Yn.filter(t,s=>!!s)}coalesce(){return Yn.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return Yn.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())}};rS.EMPTY=rS.fromArray([]);var{getWindow:Cs,getWindowId:ND,onDidRegisterWindow:AD}=(function(){let e=new Map,t={window:Vs,disposables:new Br};e.set(Vs.vscodeWindowId,t);let s=new Te,r=new Te,o=new Te;function c(h,f){return(typeof h=="number"?e.get(h):void 0)??(f?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(h){if(e.has(h.vscodeWindowId))return tt.None;let f=new Br,g={window:h,disposables:f.add(new Br)};return e.set(h.vscodeWindowId,g),f.add(Pt(()=>{e.delete(h.vscodeWindowId),r.fire(h)})),f.add($e(h,Ti.BEFORE_UNLOAD,()=>{o.fire(h)})),s.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let f=h;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:Vs},getDocument(h){return Cs(h).document}}})(),LD=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,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 $e(e,t,s,r){return new LD(e,t,s,r)}var aS=function(e,t,s,r){return $e(e,t,s,r)},Cg,BD=class extends RD{constructor(e){super(),this.defaultTarget=e&&Cs(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},lS=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){zu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,o=c=>{s.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),r.set(c,!0);h.length>0;)h.sort(lS.sort),h.shift().execute();r.set(c,!1)};Cg=(c,h,f=0)=>{let g=ND(c),p=new lS(h,f),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),s.get(g)||(s.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function OD(e){let t=e.getBoundingClientRect(),s=Cs(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ti={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"},zD=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=dn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=dn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=dn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=dn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=dn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=dn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=dn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=dn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=dn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=dn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=dn(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=dn(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=dn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=dn(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 dn(e){return typeof e=="number"?`${e}px`:e}function Vo(e){return new zD(e)}var Kw=class{constructor(){this._hooks=new Br,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(Pt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Cs(e)}this._hooks.add($e(c,Ti.POINTER_MOVE,h=>{if(h.buttons!==s){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add($e(c,Ti.POINTER_UP,h=>this.stopMonitoring(!0)))}};function jD(e,t,s){let r=null,o=null;if(typeof s.value=="function"?(r="value",o=s.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",o=s.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;s[r]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,h)}),this[c]}}var ws;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ws||={});var Lo=class Gi extends tt{constructor(){super(),this.dispatched=!1,this.targets=new Zy,this.ignoreTargets=new Zy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qi.runAndSubscribe(AD,({window:t,disposables:s})=>{s.add($e(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add($e(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add($e(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Vs,disposables:this._store}))}static addTarget(t){if(!Gi.isTouchDevice())return tt.None;Gi.INSTANCE||(Gi.INSTANCE=new Gi);let s=Gi.INSTANCE.targets.push(t);return Pt(s)}static ignoreTarget(t){if(!Gi.isTouchDevice())return tt.None;Gi.INSTANCE||(Gi.INSTANCE=new Gi);let s=Gi.INSTANCE.ignoreTargets.push(t);return Pt(s)}static isTouchDevice(){return"ontouchstart"in Vs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:s,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[s],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(ws.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,h=s.changedTouches.length;c<h;c++){let f=s.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let g=this.activeTouches[f.identifier],p=Date.now()-g.initialTimeStamp;if(p<Gi.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let y=this.newGestureEvent(ws.Tap,g.initialTarget);y.pageX=Rn(g.rollingPageX),y.pageY=Rn(g.rollingPageY),this.dispatchEvent(y)}else if(p>=Gi.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let y=this.newGestureEvent(ws.Contextmenu,g.initialTarget);y.pageX=Rn(g.rollingPageX),y.pageY=Rn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Rn(g.rollingPageX),b=Rn(g.rollingPageY),w=Rn(g.rollingTimestamps)-g.rollingTimestamps[0],S=y-g.rollingPageX[0],E=b-g.rollingPageY[0],T=[...this.targets].filter(A=>g.initialTarget instanceof Node&&A.contains(g.initialTarget));this.inertia(t,T,r,Math.abs(S)/w,S>0?1:-1,y,Math.abs(E)/w,E>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(ws.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===ws.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Gi.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===ws.Change||t.type===ws.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;s.push([o,r])}s.sort((r,o)=>r[0]-o[0]);for(let[r,o]of s)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,o,c,h,f,g,p){this.handle=Cg(t,()=>{let y=Date.now(),b=y-r,w=0,S=0,E=!0;o+=Gi.SCROLL_FRICTION*b,f+=Gi.SCROLL_FRICTION*b,o>0&&(E=!1,w=c*o*b),f>0&&(E=!1,S=g*f*b);let T=this.newGestureEvent(ws.Change);T.translationX=w,T.translationY=S,s.forEach(A=>A.dispatchEvent(T)),E||this.inertia(t,s,y,o,c,h+w,f,g,p+S)})}onTouchMove(t){let s=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],f=this.newGestureEvent(ws.Change,h.initialTarget);f.translationX=c.pageX-Rn(h.rollingPageX),f.translationY=c.pageY-Rn(h.rollingPageY),f.pageX=c.pageX,f.pageY=c.pageY,this.dispatchEvent(f),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Lo.SCROLL_FRICTION=-.005,Lo.HOLD_DELAY=700,Lo.CLEAR_TAP_COUNT_TIME=400,Qt([jD],Lo,"isTouchDevice",1);var HD=Lo,xg=class extends tt{onclick(e,t){this._register($e(e,Ti.CLICK,s=>t(new ku(Cs(e),s))))}onmousedown(e,t){this._register($e(e,Ti.MOUSE_DOWN,s=>t(new ku(Cs(e),s))))}onmouseover(e,t){this._register($e(e,Ti.MOUSE_OVER,s=>t(new ku(Cs(e),s))))}onmouseleave(e,t){this._register($e(e,Ti.MOUSE_LEAVE,s=>t(new ku(Cs(e),s))))}onkeydown(e,t){this._register($e(e,Ti.KEY_DOWN,s=>t(new iS(s))))}onkeyup(e,t){this._register($e(e,Ti.KEY_UP,s=>t(new iS(s))))}oninput(e,t){this._register($e(e,Ti.INPUT,t))}onblur(e,t){this._register($e(e,Ti.BLUR,t))}onfocus(e,t){this._register($e(e,Ti.FOCUS,t))}onchange(e,t){this._register($e(e,Ti.CHANGE,t))}ignoreGesture(e){return HD.ignoreTarget(e)}},oS=11,PD=class extends xg{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=oS+"px",this.domNode.style.height=oS+"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 Kw),this._register(aS(this.bgDomNode,Ti.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(aS(this.domNode,Ti.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new BD),this._pointerdownScheduleRepeatTimer=this._register(new wg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Cs(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},UD=class Jp{constructor(t,s,r,o,c,h,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,o=o|0,c=c|0,h=h|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,s<0&&(s=0),o+s>r&&(o=r-s),o<0&&(o=0),c<0&&(c=0),f+c>h&&(f=h-c),f<0&&(f=0),this.width=s,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=h,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,s){return new Jp(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Jp(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,s){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:c,heightChanged:h,scrollHeightChanged:f,scrollTopChanged:g}}},ID=class extends tt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new UD(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 s=this._state.withScrollDimensions(e,t);this._setState(s,!!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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new uS(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=uS.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},cS=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Gf(e,t){let s=t-e;return function(r){return e+s*WD(r)}}function KD(e,t,s){return function(r){return r<s?e(r/s):t((r-s)/(1-s))}}var uS=class em{constructor(t,s,r,o){this.from=t,this.to=s,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,s,r){if(Math.abs(t-s)>2.5*r){let o,c;return t<s?(o=t+.75*r,c=s-.75*r):(o=t-.75*r,c=s+.75*r),KD(Gf(t,o),Gf(c,s),.33)}return Gf(t,s)}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 s=(t-this.startTime)/this.duration;if(s<1){let r=this.scrollLeft(s),o=this.scrollTop(s);return new cS(r,o,!1)}return new cS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,r){return em.start(t,s,r)}static start(t,s,r){r=r+10;let o=Date.now()-10;return new em(t,s,o,r)}};function FD(e){return Math.pow(e,3)}function WD(e){return 1-FD(1-e)}var qD=class extends tt{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new wg)}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":"")))}},$D=140,Fw=class extends xg{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 qD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Kw),this._shouldRender=!0,this.domNode=Vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register($e(this.domNode.domNode,Ti.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new PD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register($e(this.slider.domNode,Ti.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,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);s<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let o=OD(this.domNode.domNode);t=e.pageX-o.left,s=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,s);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),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),h=Math.abs(c-s);if(Hw&&h>$D){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()}},Ww=class tm{constructor(t,s,r,o,c,h){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new tm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,o,c){let h=Math.max(0,r-t),f=Math.max(0,h-2*s),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*f/o))),y=(f-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=tm._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},YD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Ww(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}},VD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Ww(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}},XD=500,hS=50,GD=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},im=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,s=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,s+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(yg){let s=Cs(t.browserEvent),r=lD(s);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,r){let o=null,c=new GD(t,s,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,s){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),s){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(s.deltaX),f=Math.abs(s.deltaY),g=Math.max(Math.min(o,h),1),p=Math.max(Math.min(c,f),1),y=Math.max(o,h),b=Math.max(c,f);y%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};im.INSTANCE=new im;var ZD=im,QD=class extends xg{constructor(e,t,s){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=eR(t),this._scrollable=s,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 VD(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new YD(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=Vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Vo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new wg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=wa(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,xs&&(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 sS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=wa(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new sS(s))};this._mouseWheelToDispose.push($e(this._listenOnDomNode,Ti.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=ZD.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!xs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=hS*o,y=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=hS*c,y=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(f.scrollLeft!==g.scrollLeft||f.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),s=!0)}let r=s;!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,s=e.scrollLeft>0,r=s?" left":"",o=t?" top":"",c=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${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(),XD)}},JD=class extends QD{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function eR(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,xs&&(t.className+=" mac"),t}var nm=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._bufferService=s,this._optionsService=h,this._renderService=f,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new ID({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Cg(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new JD(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(qi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Pt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Pt(()=>this._styleElement.remove())),this._register(qi.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
24
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};nm=Qt([Me(2,tn),Me(3,Gs),Me(4,xw),Me(5,Tl),Me(6,nn),Me(7,Zs)],nm);var sm=class extends tt{constructor(e,t,s,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,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(c=>this._removeDecoration(c))),this._register(Pt(()=>{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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};sm=Qt([Me(1,tn),Me(2,Gs),Me(3,fc),Me(4,Zs)],sm);var tR=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ys={full:0,left:0,center:0,right:0},xr={full:0,left:0,center:0,right:0},wo={full:0,left:0,center:0,right:0},th=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=f,this._colorZoneStore=new tR,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(Pt(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);xr.full=this._canvas.width,xr.left=e,xr.center=t,xr.right=e,this._refreshDrawHeightConstants(),wo.full=1,wo.left=1,wo.center=1+xr.left,wo.right=1+xr.left+xr.center}_refreshDrawHeightConstants(){ys.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);ys.left=t,ys.center=t,ys.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.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(wo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ys[e.position||"full"]/2),xr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ys[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}))}};th=Qt([Me(2,tn),Me(3,fc),Me(4,Zs),Me(5,nn),Me(6,Tl),Me(7,Gs)],th);var pe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
25
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(pe||={});var Pu;(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=""))(Pu||={});var qw;(e=>e.ST=`${pe.ESC}\\`)(qw||={});var rm=class{constructor(e,t,s,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.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),s=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=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};rm=Qt([Me(2,tn),Me(3,nn),Me(4,Ea),Me(5,Zs)],rm);var Mi=0,Ni=0,Ai=0,Zt=0,dS={css:"#00000000",rgba:0},fi;(e=>{function t(o,c,h,f){return f!==void 0?`#${ua(o)}${ua(c)}${ua(h)}${ua(f)}`:`#${ua(o)}${ua(c)}${ua(h)}`}e.toCss=t;function s(o,c,h,f=255){return(o<<24|c<<16|h<<8|f)>>>0}e.toRgba=s;function r(o,c,h,f){return{css:e.toCss(o,c,h,f),rgba:e.toRgba(o,c,h,f)}}e.toColor=r})(fi||={});var jt;(e=>{function t(g,p){if(Zt=(p.rgba&255)/255,Zt===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,w=p.rgba>>8&255,S=g.rgba>>24&255,E=g.rgba>>16&255,T=g.rgba>>8&255;Mi=S+Math.round((y-S)*Zt),Ni=E+Math.round((b-E)*Zt),Ai=T+Math.round((w-T)*Zt);let A=fi.toCss(Mi,Ni,Ai),O=fi.toRgba(Mi,Ni,Ai);return{css:A,rgba:O}}e.blend=t;function s(g){return(g.rgba&255)===255}e.isOpaque=s;function r(g,p,y){let b=Uu.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return fi.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Mi,Ni,Ai]=Uu.toChannels(p),{css:fi.toCss(Mi,Ni,Ai),rgba:p}}e.opaque=o;function c(g,p){return Zt=Math.round(p*255),[Mi,Ni,Ai]=Uu.toChannels(g.rgba),{css:fi.toCss(Mi,Ni,Ai,Zt),rgba:fi.toRgba(Mi,Ni,Ai,Zt)}}e.opacity=c;function h(g,p){return Zt=g.rgba&255,c(g,Zt*p/255)}e.multiplyOpacity=h;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(jt||={});var $t;(e=>{let t,s;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Mi=parseInt(o.slice(1,2).repeat(2),16),Ni=parseInt(o.slice(2,3).repeat(2),16),Ai=parseInt(o.slice(3,4).repeat(2),16),fi.toColor(Mi,Ni,Ai);case 5:return Mi=parseInt(o.slice(1,2).repeat(2),16),Ni=parseInt(o.slice(2,3).repeat(2),16),Ai=parseInt(o.slice(3,4).repeat(2),16),Zt=parseInt(o.slice(4,5).repeat(2),16),fi.toColor(Mi,Ni,Ai,Zt);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Mi=parseInt(c[1]),Ni=parseInt(c[2]),Ai=parseInt(c[3]),Zt=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),fi.toColor(Mi,Ni,Ai,Zt);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Mi,Ni,Ai,Zt]=t.getImageData(0,0,1,1).data,Zt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:fi.toRgba(Mi,Ni,Ai,Zt),css:o}}e.toColor=r})($t||={});var en;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,o,c){let h=r/255,f=o/255,g=c/255,p=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+y*.7152+b*.0722}e.relativeLuminance2=s})(en||={});var Uu;(e=>{function t(h,f){if(Zt=(f&255)/255,Zt===1)return f;let g=f>>24&255,p=f>>16&255,y=f>>8&255,b=h>>24&255,w=h>>16&255,S=h>>8&255;return Mi=b+Math.round((g-b)*Zt),Ni=w+Math.round((p-w)*Zt),Ai=S+Math.round((y-S)*Zt),fi.toRgba(Mi,Ni,Ai)}e.blend=t;function s(h,f,g){let p=en.relativeLuminance(h>>8),y=en.relativeLuminance(f>>8);if(qs(p,y)<g){if(y<p){let S=r(h,f,g),E=qs(p,en.relativeLuminance(S>>8));if(E<g){let T=o(h,f,g),A=qs(p,en.relativeLuminance(T>>8));return E>A?S:T}return S}let b=o(h,f,g),w=qs(p,en.relativeLuminance(b>>8));if(w<g){let S=r(h,f,g),E=qs(p,en.relativeLuminance(S>>8));return w>E?b:S}return b}}e.ensureContrastRatio=s;function r(h,f,g){let p=h>>24&255,y=h>>16&255,b=h>>8&255,w=f>>24&255,S=f>>16&255,E=f>>8&255,T=qs(en.relativeLuminance2(w,S,E),en.relativeLuminance2(p,y,b));for(;T<g&&(w>0||S>0||E>0);)w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),E-=Math.max(0,Math.ceil(E*.1)),T=qs(en.relativeLuminance2(w,S,E),en.relativeLuminance2(p,y,b));return(w<<24|S<<16|E<<8|255)>>>0}e.reduceLuminance=r;function o(h,f,g){let p=h>>24&255,y=h>>16&255,b=h>>8&255,w=f>>24&255,S=f>>16&255,E=f>>8&255,T=qs(en.relativeLuminance2(w,S,E),en.relativeLuminance2(p,y,b));for(;T<g&&(w<255||S<255||E<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),E=Math.min(255,E+Math.ceil((255-E)*.1)),T=qs(en.relativeLuminance2(w,S,E),en.relativeLuminance2(p,y,b));return(w<<24|S<<16|E<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(Uu||={});function ua(e){let t=e.toString(16);return t.length<2?"0"+t:t}function qs(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var iR=class extends dc{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}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()]}},ih=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Zn}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],r=t.translateToString(!0),o=0,c=0,h=0,f=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,h,c,t,o);for(let b=0;b<y.length;b++)s.push(y[b])}o=p,h=c,f=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ar.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,h,c,t,o);for(let y=0;y<p.length;y++)s.push(p[y])}return s}_getJoinedRanges(e,t,s,r,o){let c=e.substring(t,s),h=[];try{h=this._characterJoiners[0].handler(c)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let g=this._characterJoiners[f].handler(c);for(let p=0;p<g.length;p++)ih._mergeRanges(h,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,r,o),h}_stringRangesToCellRanges(e,t,s){let r=0,o=!1,c=0,h=e[r];if(h){for(let f=s;f<this._bufferService.cols;f++){let g=t.getWidth(f),p=t.getString(f).length||Ar.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=f,o=!0),h[1]<=c){if(h[1]=f,h=e[++r],!h)break;h[0]<=c?(h[0]=f,o=!0):o=!1}c+=p}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let r=0;r<e.length;r++){let o=e[r];if(s){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]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};ih=Qt([Me(0,tn)],ih);function nR(e){return 57508<=e&&e<=57558}function sR(e){return 9472<=e&&e<=9631}function rR(e){return nR(e)||sR(e)}function aR(){return{css:{canvas:Tu(),cell:Tu()},device:{canvas:Tu(),cell:Tu(),char:{width:0,height:0,left:0,top:0}}}}function Tu(){return{width:0,height:0}}var am=class{constructor(e,t,s,r,o,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=h,this._workCell=new Zn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,r,o,c,h,f,g,p,y){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,E=e.getNoBgTrimmedLength();s&&E<c+1&&(E=c+1);let T,A=0,O="",L=0,U=0,I=0,te=0,ee=!1,ae=0,ue=!1,be=0,we=0,ne=[],ie=p!==-1&&y!==-1;for(let Y=0;Y<E;Y++){e.loadCell(Y,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let re=!1,B=Y>=we,$=Y,D=this._workCell;if(w.length>0&&Y===w[0][0]&&B){let ye=w.shift(),De=this._isCellInSelection(ye[0],t);for(L=ye[0]+1;L<ye[1];L++)B&&=De===this._isCellInSelection(L,t);B&&=!s||c<ye[0]||c>=ye[1],B?(re=!0,D=new iR(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),$=ye[1]-1,K=D.getWidth()):we=ye[1]}let X=this._isCellInSelection(Y,t),_e=s&&Y===c,R=ie&&Y>=p&&Y<=y,H=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,ye=>{H=!0});let Q=D.getChars()||Ar;if(Q===" "&&(D.isUnderline()||D.isOverline())&&(Q=" "),be=K*f-g.get(Q,D.isBold(),D.isItalic()),!T)T=this._document.createElement("span");else if(A&&(X&&ue||!X&&!ue&&D.bg===U)&&(X&&ue&&S.selectionForeground||D.fg===I)&&D.extended.ext===te&&R===ee&&be===ae&&!_e&&!re&&!H&&B){D.isInvisible()?O+=Ar:O+=Q,A++;continue}else A&&(T.textContent=O),T=this._document.createElement("span"),A=0,O="";if(U=D.bg,I=D.fg,te=D.extended.ext,ee=R,ae=be,ue=X,re&&c>=Y&&c<=$&&(c=Y),!this._coreService.isCursorHidden&&_e&&this._coreService.isCursorInitialized){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&ne.push("xterm-cursor-blink"),ne.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline");break}}if(D.isBold()&&ne.push("xterm-bold"),D.isItalic()&&ne.push("xterm-italic"),D.isDim()&&ne.push("xterm-dim"),D.isInvisible()?O=Ar:O=D.getChars()||Ar,D.isUnderline()&&(ne.push(`xterm-underline-${D.extended.underlineStyle}`),O===" "&&(O=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${dc.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let ye=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&ye<8&&(ye+=8),T.style.textDecorationColor=S.ansi[ye].css}D.isOverline()&&(ne.push("xterm-overline"),O===" "&&(O=" ")),D.isStrikethrough()&&ne.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let de=D.getFgColor(),ke=D.getFgColorMode(),xe=D.getBgColor(),Re=D.getBgColorMode(),Xe=!!D.isInverse();if(Xe){let ye=de;de=xe,xe=ye;let De=ke;ke=Re,Re=De}let ge,G,ce=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,ye=>{ye.options.layer!=="top"&&ce||(ye.backgroundColorRGB&&(Re=50331648,xe=ye.backgroundColorRGB.rgba>>8&16777215,ge=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ke=50331648,de=ye.foregroundColorRGB.rgba>>8&16777215,G=ye.foregroundColorRGB),ce=ye.options.layer==="top")}),!ce&&X&&(ge=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,xe=ge.rgba>>8&16777215,Re=50331648,ce=!0,S.selectionForeground&&(ke=50331648,de=S.selectionForeground.rgba>>8&16777215,G=S.selectionForeground)),ce&&ne.push("xterm-decoration-top");let Ce;switch(Re){case 16777216:case 33554432:Ce=S.ansi[xe],ne.push(`xterm-bg-${xe}`);break;case 50331648:Ce=fi.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(T,`background-color:#${fS((xe>>>0).toString(16),"0",6)}`);break;default:Xe?(Ce=S.foreground,ne.push("xterm-bg-257")):Ce=S.background}switch(ge||D.isDim()&&(ge=jt.multiplyOpacity(Ce,.5)),ke){case 16777216:case 33554432:D.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(T,Ce,S.ansi[de],D,ge,void 0)||ne.push(`xterm-fg-${de}`);break;case 50331648:let ye=fi.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(T,Ce,ye,D,ge,G)||this._addStyle(T,`color:#${fS(de.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Ce,S.foreground,D,ge,G)||Xe&&ne.push("xterm-fg-257")}ne.length&&(T.className=ne.join(" "),ne.length=0),!_e&&!re&&!H&&B?A++:T.textContent=O,be!==this.defaultSpacing&&(T.style.letterSpacing=`${be}px`),b.push(T),Y=$}return T&&A&&(T.textContent=O),b}_applyMinimumContrast(e,t,s,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||rR(r.getCode()))return!1;let h=this._getContrastCache(r),f;if(!o&&!c&&(f=h.getColor(t.rgba,s.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=jt.ensureContrastRatio(o||t,c||s,g),h.setColor((o||t).rgba,(c||s).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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e<r[0]&&t<=r[1]:e<s[0]&&t>=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t<r[1]||s[1]===r[1]&&t===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&t===r[1]&&e<r[0]||s[1]<r[1]&&t===s[1]&&e>=s[0]}};am=Qt([Me(1,Tw),Me(2,nn),Me(3,Gs),Me(4,Ea),Me(5,fc),Me(6,Tl)],am);function fS(e,t,s){for(;e.length<s;)e=t+e;return e}var lR=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 s=e.createElement("span");s.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 c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,r,o,c],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,r){e===this._font&&t===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,s){let r=0;if(!t&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let h=this._measure(e,0);return h>0&&(this._flat[r]=h),h}let o=e;t&&(o+="B"),s&&(o+="I");let c=this._holey.get(o);if(c===void 0){let h=0;t&&(h|=1),s&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},oR=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,h=s[1]-o,f=Math.max(c,0),g=Math.min(h,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=f,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function cR(){return new oR}var Zf="xterm-dom-renderer-owner-",$n="xterm-rows",Du="xterm-fg-",pS="xterm-bg-",Co="xterm-focus",Ru="xterm-selection",uR=1,lm=class extends tt{constructor(e,t,s,r,o,c,h,f,g,p,y,b,w,S){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=w,this._themeService=S,this._terminalClass=uR++,this._rowElements=[],this._selectionRenderModel=cR(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add($n),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ru),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=aR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(E=>this._injectCss(E))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(am,document),this._element.classList.add(Zf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(E=>this._handleLinkHover(E))),this._register(this._linkifier2.onHideLinkUnderline(E=>this._handleLinkLeave(E))),this._register(Pt(()=>{this._element.classList.remove(Zf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new lR(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${$n} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${$n} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${$n} .xterm-dim { color: ${jt.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 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} .${$n}.${Co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${$n}.${Co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${$n}.${Co} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${$n} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ru} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ru} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ru} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Du}${c} { color: ${h.css}; }${this._terminalSelector} .${Du}${c}.xterm-dim { color: ${jt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${pS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Du}257 { color: ${jt.opaque(e.background).css}; }${this._terminalSelector} .${Du}257.xterm-dim { color: ${jt.multiplyOpacity(jt.opaque(e.background),.5).css}; }${this._terminalSelector} .${pS}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 s=this._rowElements.length;s<=t;s++){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(Co),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Co),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(s){let g=e[0]>t[0];f.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,g,p));let y=h-c-1;if(f.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==h){let b=o===h?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(h,0,b))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,s,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(s-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${h}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,r=s.ybase+s.y,o=Math.min(s.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+s.ydisp,y=this._rowElements[g],b=s.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,h,f,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Zf}${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,s,r,o,c){s<0&&(e=0),r<0&&(t=0);let h=this._bufferService.rows-1;s=Math.max(Math.min(s,h),0),r=Math.max(Math.min(r,h),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,g=f.ybase+f.y,p=Math.min(f.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=s;S<=r;++S){let E=S+f.ydisp,T=this._rowElements[S],A=f.lines.get(E);if(!T||!A)break;T.replaceChildren(...this._rowFactory.createRow(A,E,E===g,b,w,p,y,this.dimensions.css.cell.width,this._widthCache,c?S===s?e:0:-1,c?(S===r?t:o)-1:-1))}}};lm=Qt([Me(7,_g),Me(8,xh),Me(9,nn),Me(10,tn),Me(11,Ea),Me(12,Gs),Me(13,Tl)],lm);var om=class extends tt{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new dR(this._optionsService))}catch{this._measureStrategy=this._register(new hR(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())}};om=Qt([Me(2,nn)],om);var $w=class extends tt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},hR=class extends $w{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},dR=class extends $w{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}},fR=class extends tt{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new pR(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(qi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($e(this._textarea,"focus",()=>this._isFocused=!0)),this._register($e(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}},pR=class extends tt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sl),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Pt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$e(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)}},mR=class extends tt{constructor(){super(),this.linkProviders=[],this._register(Pt(()=>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 Eg(e,t,s){let r=s.getBoundingClientRect(),o=e.getComputedStyle(s),c=parseInt(o.getPropertyValue("padding-left")),h=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-h]}function gR(e,t,s,r,o,c,h,f,g){if(!c)return;let p=Eg(e,t,s);if(p)return p[0]=Math.ceil((p[0]+(g?h/2:0))/h),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var cm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,o){return gR(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let s=Eg(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};cm=Qt([Me(0,Zs),Me(1,xh)],cm);var _R=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,s){this._rowCount=s,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=[]}},Yw={};TT(Yw,{getSafariVersion:()=>bR,isChromeOS:()=>Zw,isFirefox:()=>Vw,isIpad:()=>yR,isIphone:()=>SR,isLegacyEdge:()=>vR,isLinux:()=>kg,isMac:()=>nh,isNode:()=>Eh,isSafari:()=>Xw,isWindows:()=>Gw});var Eh=typeof process<"u"&&"title"in process,pc=Eh?"node":navigator.userAgent,mc=Eh?"node":navigator.platform,Vw=pc.includes("Firefox"),vR=pc.includes("Edge"),Xw=/^((?!chrome|android).)*safari/i.test(pc);function bR(){if(!Xw)return 0;let e=pc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var nh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mc),yR=mc==="iPad",SR=mc==="iPhone",Gw=["Windows","Win16","Win32","WinCE"].includes(mc),kg=mc.indexOf("Linux")>=0,Zw=/\bCrOS\b/.test(pc),Qw=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,s=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),s=Math.max(t,s),o=e.timeRemaining(),s*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()}},wR=class extends Qw{_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())}}},CR=class extends Qw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sh=!Eh&&"requestIdleCallback"in window?CR:wR,xR=class{constructor(){this._queue=new sh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},um=class extends tt{constructor(e,t,s,r,o,c,h,f,g){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Sl),this._pausedResizeTask=new xR,this._observerDisposable=this._register(new Sl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new _R((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ER(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Pt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Pt(()=>s.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,s=!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)),s||(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,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};um=Qt([Me(2,nn),Me(3,xh),Me(4,Ea),Me(5,fc),Me(6,tn),Me(7,Gs),Me(8,Tl)],um);var ER=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 kR(e,t,s,r){let o=s.buffer.x,c=s.buffer.y;if(!s.buffer.hasScrollback)return RR(o,c,e,t,s,r)+kh(c,t,s,r)+MR(o,c,e,t,s,r);let h;if(c===t)return h=o>e?"D":"C",tc(Math.abs(o-e),ec(h,r));h=c>t?"D":"C";let f=Math.abs(c-t),g=DR(c>t?e:o,s)+(f-1)*s.cols+1+TR(c>t?o:e);return tc(g,ec(h,r))}function TR(e,t){return e-1}function DR(e,t){return t.cols-e}function RR(e,t,s,r,o,c){return kh(t,r,o,c).length===0?"":tc(e1(e,t,e,t-Ca(t,o),!1,o).length,ec("D",c))}function kh(e,t,s,r){let o=e-Ca(e,s),c=t-Ca(t,s),h=Math.abs(o-c)-NR(e,t,s);return tc(h,ec(Jw(e,t),r))}function MR(e,t,s,r,o,c){let h;kh(t,r,o,c).length>0?h=r-Ca(r,o):h=t;let f=r,g=AR(e,t,s,r,o,c);return tc(e1(e,h,s,f,g==="C",o).length,ec(g,c))}function NR(e,t,s){let r=0,o=e-Ca(e,s),c=t-Ca(t,s);for(let h=0;h<Math.abs(o-c);h++){let f=Jw(e,t)==="A"?-1:1;s.buffer.lines.get(o+f*h)?.isWrapped&&r++}return r}function Ca(e,t){let s=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)s++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return s}function AR(e,t,s,r,o,c){let h;return kh(s,r,o,c).length>0?h=r-Ca(r,o):h=t,e<s&&h<=r||e>=s&&h<r?"C":"D"}function Jw(e,t){return e>t?"A":"B"}function e1(e,t,s,r,o,c){let h=e,f=t,g="";for(;(h!==s||f!==r)&&f>=0&&f<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(f,!1,e,h),h=0,e=0,f++):!o&&h<0&&(g+=c.buffer.translateBufferLineToString(f,!1,0,e+1),h=c.cols-1,e=h,f--);return g+c.buffer.translateBufferLineToString(f,!1,e,h)}function ec(e,t){let s=t?"O":"[";return pe.ESC+s+e}function tc(e,t){e=Math.floor(e);let s="";for(let r=0;r<e;r++)s+=t;return s}var LR=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 mS(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 Qf=50,BR=15,OR=50,zR=500,jR=" ",HR=new RegExp(jR,"g"),hm=class extends tt{constructor(e,t,s,r,o,c,h,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=h,this._renderService=f,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Zn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),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 LR(this._bufferService),this._activeSelectionMode=0,this._register(Pt(()=>{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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let f=s.translateBufferLineToString(h,!0,o,c);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let h=s.lines.get(c),f=s.translateBufferLineToString(c,!0);h?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let c=s.lines.get(t[1]),h=s.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=h:r.push(h)}}return r.map(o=>o.replace(HR," ")).join(Gw?`\r
|
|
26
|
+
`:`
|
|
27
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),kg&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=mS(s,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=Eg(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Qf),Qf),t/=Qf,t/Math.abs(t)+Math.round(t*(BR-1)))}shouldForceSelection(e){return nh?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(),OR)}_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&&!(nh&&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 s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let r=s.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<zR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let r=kR(s[0]-1,s[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,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);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,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:o>1&&t!==r&&(s+=o-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let h=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(c,e[0]),g=f,p=e[0]-f,y=0,b=0,w=0,S=0;if(h.charAt(f)===" "){for(;f>0&&h.charAt(f-1)===" ";)f--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let A=e[0],O=e[0];c.getWidth(A)===0&&(y++,A--),c.getWidth(O)===2&&(b++,O++);let L=c.getString(O).length;for(L>1&&(S+=L-1,g+=L-1);A>0&&f>0&&!this._isCharWordSeparator(c.loadCell(A-1,this._workCell));){c.loadCell(A-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,A--):U>1&&(w+=U-1,f-=U-1),f--,A--}for(;O<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(O+1,this._workCell));){c.loadCell(O+1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,O++):U>1&&(S+=U-1,g+=U-1),g++,O++}}g++;let E=f+p-y+w,T=Math.min(this._bufferService.cols,g-f+y+b-w-S);if(!(!t&&h.slice(f,g).trim()==="")){if(s&&E===0&&c.getCodePoint(0)!==32){let A=o.lines.get(e[1]-1);if(A&&c.isWrapped&&A.getCodePoint(this._bufferService.cols-1)!==32){let O=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(O){let L=this._bufferService.cols-O.start;E-=L,T+=L}}}if(r&&E+T===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let A=o.lines.get(e[1]+1);if(A?.isWrapped&&A.getCodePoint(0)!==32){let O=this._getWordAt([0,e[1]+1],!1,!1,!0);O&&(T+=O.length)}}return{start:E,length:T}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=mS(s,this._bufferService.cols)}};hm=Qt([Me(3,tn),Me(4,Ea),Me(5,vg),Me(6,nn),Me(7,Zs),Me(8,Gs)],hm);var gS=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},_S=class{constructor(){this._color=new gS,this._css=new gS}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},vi=Object.freeze((()=>{let e=[$t.toColor("#2e3436"),$t.toColor("#cc0000"),$t.toColor("#4e9a06"),$t.toColor("#c4a000"),$t.toColor("#3465a4"),$t.toColor("#75507b"),$t.toColor("#06989a"),$t.toColor("#d3d7cf"),$t.toColor("#555753"),$t.toColor("#ef2929"),$t.toColor("#8ae234"),$t.toColor("#fce94f"),$t.toColor("#729fcf"),$t.toColor("#ad7fa8"),$t.toColor("#34e2e2"),$t.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],o=t[s/6%6|0],c=t[s%6];e.push({css:fi.toCss(r,o,c),rgba:fi.toRgba(r,o,c)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:fi.toCss(r,r,r),rgba:fi.toRgba(r,r,r)})}return e})()),da=$t.toColor("#ffffff"),Bo=$t.toColor("#000000"),vS=$t.toColor("#ffffff"),bS=Bo,xo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},PR=da,dm=class extends tt{constructor(e){super(),this._optionsService=e,this._contrastCache=new _S,this._halfContrastCache=new _S,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:da,background:Bo,cursor:vS,cursorAccent:bS,selectionForeground:void 0,selectionBackgroundTransparent:xo,selectionBackgroundOpaque:jt.blend(Bo,xo),selectionInactiveBackgroundTransparent:xo,selectionInactiveBackgroundOpaque:jt.blend(Bo,xo),scrollbarSliderBackground:jt.opacity(da,.2),scrollbarSliderHoverBackground:jt.opacity(da,.4),scrollbarSliderActiveBackground:jt.opacity(da,.5),overviewRulerBorder:da,ansi:vi.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=kt(e.foreground,da),t.background=kt(e.background,Bo),t.cursor=jt.blend(t.background,kt(e.cursor,vS)),t.cursorAccent=jt.blend(t.background,kt(e.cursorAccent,bS)),t.selectionBackgroundTransparent=kt(e.selectionBackground,xo),t.selectionBackgroundOpaque=jt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=jt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?kt(e.selectionForeground,dS):void 0,t.selectionForeground===dS&&(t.selectionForeground=void 0),jt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=jt.opacity(t.selectionBackgroundTransparent,.3)),jt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=jt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=kt(e.scrollbarSliderBackground,jt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=kt(e.scrollbarSliderHoverBackground,jt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=kt(e.scrollbarSliderActiveBackground,jt.opacity(t.foreground,.5)),t.overviewRulerBorder=kt(e.overviewRulerBorder,PR),t.ansi=vi.slice(),t.ansi[0]=kt(e.black,vi[0]),t.ansi[1]=kt(e.red,vi[1]),t.ansi[2]=kt(e.green,vi[2]),t.ansi[3]=kt(e.yellow,vi[3]),t.ansi[4]=kt(e.blue,vi[4]),t.ansi[5]=kt(e.magenta,vi[5]),t.ansi[6]=kt(e.cyan,vi[6]),t.ansi[7]=kt(e.white,vi[7]),t.ansi[8]=kt(e.brightBlack,vi[8]),t.ansi[9]=kt(e.brightRed,vi[9]),t.ansi[10]=kt(e.brightGreen,vi[10]),t.ansi[11]=kt(e.brightYellow,vi[11]),t.ansi[12]=kt(e.brightBlue,vi[12]),t.ansi[13]=kt(e.brightMagenta,vi[13]),t.ansi[14]=kt(e.brightCyan,vi[14]),t.ansi[15]=kt(e.brightWhite,vi[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)t.ansi[r+16]=kt(e.extendedAnsi[r],vi[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()}}};dm=Qt([Me(0,nn)],dm);function kt(e,t){if(e!==void 0)try{return $t.toColor(e)}catch{}return t}var UR=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},IR=class{constructor(){this._services=new UR,this._services.set(_g,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=BT(e).sort((c,h)=>c.index-h.index),r=[];for(let c of s){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(h)}let o=s.length>0?s[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)}},KR={trace:0,debug:1,info:2,warn:3,error:4,off:5},FR="xterm.js: ",fm=class extends tt{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=KR[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":FR)+t,...s)}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)}};fm=Qt([Me(0,nn)],fm);var yS=class extends tt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),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 s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];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,...s){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+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let o=t-1;o>=0;o--)this.set(e+o+s,this.get(e+o));let r=e+t+s-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+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},et=3,di=Object.freeze(new dc),Mu=0,Jf=2,Oo=class t1{constructor(t,s,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*et);let o=s||Zn.fromCharData([0,yw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let s=this._data[t*et+0],r=s&2097151;return[this._data[t*et+1],s&2097152?this._combined[t]:r?Mr(r):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*et+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*et+0]=t|2097152|s[2]<<22):this._data[t*et+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*et+0]>>22}hasWidth(t){return this._data[t*et+0]&12582912}getFg(t){return this._data[t*et+1]}getBg(t){return this._data[t*et+2]}hasContent(t){return this._data[t*et+0]&4194303}getCodePoint(t){let s=this._data[t*et+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*et+0]&2097152}getString(t){let s=this._data[t*et+0];return s&2097152?this._combined[t]:s&2097151?Mr(s&2097151):""}isProtected(t){return this._data[t*et+2]&536870912}loadCell(t,s){return Mu=t*et,s.content=this._data[Mu+0],s.fg=this._data[Mu+1],s.bg=this._data[Mu+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*et+0]=s.content,this._data[t*et+1]=s.fg,this._data[t*et+2]=s.bg}setCellFromCodepoint(t,s,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*et+0]=s|r<<22,this._data[t*et+1]=o.fg,this._data[t*et+2]=o.bg}addCodepointToCell(t,s,r){let o=this._data[t*et+0];o&2097152?this._combined[t]+=Mr(s):o&2097151?(this._combined[t]=Mr(o&2097151)+Mr(s),o&=-2097152,o|=2097152):o=s|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*et+0]=o}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length-t){let o=new Zn;for(let c=this.length-t-s-1;c>=0;--c)this.setCell(t+s+c,this.loadCell(t+c,o));for(let c=0;c<s;++c)this.setCell(t+c,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,s,r){if(t%=this.length,s<this.length-t){let o=new Zn;for(let c=0;c<this.length-t-s;++c)this.setCell(t+c,this.loadCell(t+s+c,o));for(let c=this.length-s;c<this.length;++c)this.setCell(c,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,s,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,r);t<s&&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),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,r);t<s&&t<this.length;)this.setCell(t++,r)}resize(t,s){if(t===this.length)return this._data.length*4*Jf<this._data.buffer.byteLength;let r=t*et;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,s)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let h=0;h<o.length;h++){let f=parseInt(o[h],10);f>=t&&delete this._combined[f]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let f=parseInt(c[h],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*Jf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Jf<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){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 s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new t1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*et+0]&4194303)return t+(this._data[t*et+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*et+0]&4194303||this._data[t*et+2]&50331648)return t+(this._data[t*et+0]>>22);return 0}copyCellsFrom(t,s,r,o,c){let h=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}else for(let g=0;g<o;g++){for(let p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let p=parseInt(f[g],10);p>=s&&(this._combined[p-s+r]=t._combined[p])}}translateToString(t,s,r,o){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;s<r;){let h=this._data[s*et+0],f=h&2097151,g=h&2097152?this._combined[s]:f?Mr(f):Ar;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(s);s+=h>>22||1}return o&&o.push(s),c}};function WR(e,t,s,r,o,c){let h=[];for(let f=0;f<e.length-1;f++){let g=f,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(f)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=f&&r<g){f+=y.length-1;continue}let b=0,w=ic(y,b,t),S=1,E=0;for(;S<y.length;){let A=ic(y,S,t),O=A-E,L=s-w,U=Math.min(O,L);y[b].copyCellsFrom(y[S],E,w,U,!1),w+=U,w===s&&(b++,w=0),E+=U,E===A&&(S++,E=0),w===0&&b!==0&&y[b-1].getWidth(s-1)===2&&(y[b].copyCellsFrom(y[b-1],s-1,w++,1,!1),y[b-1].setCell(s-1,o))}y[b].replaceCells(w,s,o);let T=0;for(let A=y.length-1;A>0&&(A>b||y[A].getTrimmedLength()===0);A--)T++;T>0&&(h.push(f+y.length-T),h.push(T)),f+=y.length-1}return h}function qR(e,t){let s=[],r=0,o=t[r],c=0;for(let h=0;h<e.length;h++)if(o===h){let f=t[++r];e.onDeleteEmitter.fire({index:h-c,amount:f}),h+=f-1,c+=f,o=t[++r]}else s.push(h);return{layout:s,countRemoved:c}}function $R(e,t){let s=[];for(let r=0;r<t.length;r++)s.push(e.get(t[r]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=t.length}function YR(e,t,s){let r=[],o=e.map((g,p)=>ic(e,p,t)).reduce((g,p)=>g+p),c=0,h=0,f=0;for(;f<o;){if(o-f<s){r.push(o-f);break}c+=s;let g=ic(e,h,t);c>g&&(c-=g,h++);let p=e[h].getWidth(c-1)===2;p&&c--;let y=p?s-1:s;r.push(y),f+=y}return r}function ic(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?s-1:s}var i1=class n1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=n1._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),wa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};i1._nextId=1;var VR=i1,wi={},fa=wi.B;wi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};wi.A={"#":"£"};wi.B=void 0;wi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};wi.C=wi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};wi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};wi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};wi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};wi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};wi.E=wi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};wi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};wi.H=wi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};wi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var SS=4294967295,wS=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=di.clone(),this.savedCharset=fa,this.markers=[],this._nullCell=Zn.fromCharData([0,yw,1,0]),this._whitespaceCell=Zn.fromCharData([0,Ar,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new yS(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 eh),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 eh),this._whitespaceCell}getBlankLine(e,t){return new Oo(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>SS?SS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=di);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 yS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(di),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 h=0;h<this.lines.length;h++)r+=+this.lines.get(h).resize(e,s);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Oo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Oo(e,s)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let h=this.lines.length-o;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,s);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 s=this._optionsService.rawOptions.reflowCursorLine,r=WR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(di),s);if(r.length>0){let o=qR(this.lines,r);$R(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(di),o=s;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Oo(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(di),o=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let f=this.lines.get(h);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&h>0;)f=this.lines.get(--h),g.unshift(f);if(!s){let U=this.ybase+this.y;if(U>=h&&U<h+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=YR(g,this._cols,e),b=y.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let S=[];for(let U=0;U<b;U++){let I=this.getBlankLine(di,!0);S.push(I)}S.length>0&&(o.push({start:h+g.length+c,newLines:S}),c+=S.length),g.push(...S);let E=y.length-1,T=y[E];T===0&&(E--,T=y[E]);let A=g.length-b-1,O=p;for(;A>=0;){let U=Math.min(O,T);if(g[E]===void 0)break;if(g[E].copyCellsFrom(g[A],O-U,T-U,U,!0),T-=U,T===0&&(E--,T=y[E]),O-=U,O===0){A--;let I=Math.max(A,0);O=ic(g,I,this._cols)}}for(let U=0;U<g.length;U++)y[U]<e&&g[U].setCell(y[U],r);let L=b-w;for(;L-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let h=[],f=[];for(let T=0;T<this.lines.length;T++)f.push(this.lines.get(T));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(b&&b.start>p+w){for(let A=b.newLines.length-1;A>=0;A--)this.lines.set(T--,b.newLines[A]);T++,h.push({index:p+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++y]}else this.lines.set(T,f[p--]);let S=0;for(let T=h.length-1;T>=0;T--)h[T].index+=S,this.lines.onInsertEmitter.fire(h[T]),S+=h[T].amount;let E=Math.max(0,g+c-this.lines.maxLength);E>0&&this.lines.onTrimEmitter.fire(E)}}translateBufferLineToString(e,t,s=0,r){let o=this.lines.get(e);return o?o.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}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 VR(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},XR=class extends tt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Te),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 wS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new wS(!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)}},s1=2,r1=1,pm=class extends tt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,s1),this.rows=Math.max(e.rawOptions.rows||0,r1),this.buffers=this._register(new XR(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=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:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=s.ybase+s.scrollTop,c=s.ybase+s.scrollBottom;if(s.scrollTop===0){let h=s.lines.isFull;c===s.lines.length-1?h?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(c+1,0,r.clone()),h?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let h=c-o+1;s.lines.shiftElements(o+1,h-1,-1),s.lines.set(c,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};pm=Qt([Me(0,nn)],pm);var ul={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:nh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},GR=["normal","bold","100","200","300","400","500","600","700","800","900"],ZR=class extends tt{constructor(e){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let t={...ul};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Pt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in ul))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in ul))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=ul[e]),!QR(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=GR.includes(t)?t:ul[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function QR(e){return e==="block"||e==="underline"||e==="bar"}function zo(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&zo(e[r],t-1);return s}var CS=Object.freeze({insertMode:!1}),xS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),mm=class extends tt{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=zo(CS),this.decPrivateModes=zo(xS)}reset(){this.modes=zo(CS),this.decPrivateModes=zo(xS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.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))}};mm=Qt([Me(0,tn),Me(1,Ew),Me(2,nn)],mm);var ES={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 ep(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var tp=String.fromCharCode,kS={DEFAULT:e=>{let t=[ep(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${tp(t[0])}${tp(t[1])}${tp(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ep(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ep(e,!0)};${e.x};${e.y}${t}`}},gm=class extends tt{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(ES))this.addProtocol(r,ES[r]);for(let r of Object.keys(kS))this.addEncoding(r,kS[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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,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,s){if(s){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)}};gm=Qt([Me(0,tn),Me(1,Ea),Me(2,nn)],gm);var ip=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],JR=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],bi;function eM(e,t){let s=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(o=s+r>>1,e>t[o][1])s=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var tM=class{constructor(){if(this.version="6",!bi){bi=new Uint8Array(65536),bi.fill(1),bi[0]=0,bi.fill(0,1,32),bi.fill(0,127,160),bi.fill(2,4352,4448),bi[9001]=2,bi[9002]=2,bi.fill(2,11904,42192),bi[12351]=1,bi.fill(2,44032,55204),bi.fill(2,63744,64256),bi.fill(2,65040,65050),bi.fill(2,65072,65136),bi.fill(2,65280,65377),bi.fill(2,65504,65511);for(let e=0;e<ip.length;++e)bi.fill(0,ip[e][0],ip[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bi[e]:eM(e,JR)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let o=ga.extractWidth(t);o===0?r=!1:o>s&&(s=o)}return ga.createPropertyValue(0,s,r)}},ga=class Iu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let t=new tM;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,s,r=!1){return(t&16777215)<<3|(s&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 s=0,r=0,o=t.length;for(let c=0;c<o;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=o)return s+this.wcwidth(h);let p=t.charCodeAt(c);56320<=p&&p<=57343?h=(h-55296)*1024+p-56320+65536:s+=this.wcwidth(p)}let f=this.charProperties(h,r),g=Iu.extractWidth(f);Iu.extractShouldJoin(f)&&(g-=Iu.extractWidth(r)),s+=g,r=f}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},iM=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 TS(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Eo=2147483647,nM=256,a1=class _m{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>nM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new _m;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)s.addSubParam(o[c]);else s.addParam(o)}return s}clone(){let t=new _m(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 s=0;s<this.length;++s){t.push(this.params[s]);let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&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>Eo?Eo: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>Eo?Eo:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&255;o-r>0&&(t[s]=this._subParams.slice(r,o))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[s-1];r[s-1]=~o?Math.min(o*10+t,Eo):t}},ko=[],sM=class{constructor(){this._state=0,this._active=ko,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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=ko}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=ko,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ko,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Ch(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){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&&s-t>0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=ko,this._id=-1,this._state=0}}},Mn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Ch(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},To=[],rM=class{constructor(){this._handlers=Object.create(null),this._active=To,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=To}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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=To,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||To,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ch(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=To,this._ident=0}},jo=new a1;jo.addParam(0);var DS=class{constructor(e){this._handler=e,this._data="",this._params=jo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():jo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Ch(e,t,s),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(s=>(this._params=jo,this._data="",this._hitLimit=!1,s));return this._params=jo,this._data="",this._hitLimit=!1,t}},aM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=s<<4|r}},Xn=160,lM=(function(){let e=new aM(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),s=(f,g)=>t.slice(f,g),r=s(32,127),o=s(0,24);o.push(25),o.push.apply(o,s(28,32));let c=s(0,14),h;e.setDefault(1,0),e.addMany(r,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(s(128,144),h,3,0),e.addMany(s(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(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(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(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(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(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(Xn,0,2,0),e.add(Xn,8,5,8),e.add(Xn,6,0,6),e.add(Xn,11,0,11),e.add(Xn,13,13,13),e})(),oM=class extends tt{constructor(e=lM){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 a1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Pt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new sM),this._dcsParser=this._register(new rM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}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 s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];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,s,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,s){let r=0,o=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&g>-1){for(;g>=0&&(h=f[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(s===!1&&g>-1){for(;g>=0&&(h=f[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(r!==24&&r!==26,s),h)return h;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],h=this._oscParser.end(r!==24&&r!==26,s),h)return h;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=c;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:Xn)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<Xn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Xn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Xn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Xn){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(h=g[p](this._params),h!==!0);p--)if(h instanceof Promise)return this._preserveStack(3,g,p,o,f),h;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 y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(h=y[b](),h!==!0);b--)if(h instanceof Promise)return this._preserveStack(4,y,b,o,f),h;b<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<Xn){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(h=this._dcsParser.unhook(r!==24&&r!==26),h)return this._preserveStack(6,[],0,o,f),h;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<Xn){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(h=this._oscParser.end(r!==24&&r!==26),h)return this._preserveStack(5,[],0,o,f),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},cM=/^([\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})$/,uM=/^[\da-f]+$/;function RS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=cM.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),uM.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(s*o,s*o+s),16);r[o]=s===1?c<<4:s===2?c:s===3?c>>4:c>>8}return r}}function np(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function hM(e,t=16){let[s,r,o]=e;return`rgb:${np(s,t)}/${np(r,t)}/${np(o,t)}`}var dM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Er=131072,MS=10;function NS(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 AS=5e3,LS=0,fM=class extends tt{constructor(e,t,s,r,o,c,h,f,g=new oM){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new AT,this._utf8Decoder=new LT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=di.clone(),this._eraseAttrDataInternal=di.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),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 vm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.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,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,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(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Pu.IND,()=>this.index()),this._parser.setExecuteHandler(Pu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Pu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Mn(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new Mn(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new Mn(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new Mn(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new Mn(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new Mn(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new Mn(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new Mn(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new Mn(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new Mn(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new Mn(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new Mn(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 wi)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 DS((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),AS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${AS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Er&&(c=this._parseStack.position+Er)}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<Er&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Er))),h||this._dirtyRowTracker.clearRange(),e.length>Er)for(let p=c;p<e.length;p+=Er){let y=p+Er<e.length?p+Er:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(s),s}else if(!h){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(f,this._bufferService.rows-1)})}print(e,t,s){let r,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let w=this._parser.precedingJoinState;for(let S=t;S<s;++S){if(r=e[S],r<127&&c){let O=c[String.fromCharCode(r)];O&&(r=O.charCodeAt(0))}let E=this._unicodeService.charProperties(r,w);o=ga.extractWidth(E);let T=ga.extractShouldJoin(E),A=T?ga.extractWidth(w):0;if(w=E,h&&this._onA11yChar.fire(Mr(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-A>f){if(g){let O=b,L=this._activeBuffer.x-A;for(this._activeBuffer.x=A,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),A>0&&b instanceof Oo&&b.copyCellsFrom(O,L,0,A,!1);L<f;)O.setCellFromCodepoint(L++,0,1,y)}else if(this._activeBuffer.x=f-1,o===2)continue}if(T&&this._activeBuffer.x){let O=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-O,r,o);for(let L=o-A;--L>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-A,this._activeBuffer.getNullCell(y)),b.getWidth(f-1)===2&&b.setCellFromCodepoint(f-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&s-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>NS(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new DS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Mn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,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 s=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(s,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 s=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(s,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(di));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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);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 s=e.params[0]||1,r=ga.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),h=new Uint32Array(c.length*s),f=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;h[f++]=y,p+=y>65535?2:1}let g=f;for(let p=1;p<s;++p)h.copyWithin(g,0,f),g+=f;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.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,fa),this._charsetService.setgCharset(1,fa),this._charsetService.setgCharset(2,fa),this._charsetService.setgCharset(3,fa);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 s;(T=>(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:f,cols:g}=this._bufferService,{active:p,alt:y}=f,b=this._optionsService.rawOptions,w=(T,A)=>(h.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${T};${A}$y`),!0),S=T=>T?1:2,E=e.params[0];return t?E===2?w(E,4):E===4?w(E,S(h.modes.insertMode)):E===12?w(E,3):E===20?w(E,S(b.convertEol)):w(E,0):E===1?w(E,S(r.applicationCursorKeys)):E===3?w(E,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):E===6?w(E,S(r.origin)):E===7?w(E,S(r.wraparound)):E===8?w(E,3):E===9?w(E,S(o==="X10")):E===12?w(E,S(b.cursorBlink)):E===25?w(E,S(!h.isCursorHidden)):E===45?w(E,S(r.reverseWraparound)):E===66?w(E,S(r.applicationKeypad)):E===67?w(E,4):E===1e3?w(E,S(o==="VT200")):E===1002?w(E,S(o==="DRAG")):E===1003?w(E,S(o==="ANY")):E===1004?w(E,S(r.sendFocus)):E===1005?w(E,4):E===1006?w(E,S(c==="SGR")):E===1015?w(E,4):E===1016?w(E,S(c==="SGR_PIXELS")):E===1048?w(E,1):E===47||E===1047||E===1049?w(E,S(p===y)):E===2004?w(E,S(r.bracketedPasteMode)):E===2026?w(E,S(r.synchronizedOutput)):w(E,0)}_updateAttrColor(e,t,s,r,o){return t===2?(e|=50331648,e&=-16777216,e|=dc.fromColorRGB([s,r,o])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),f=0;do r[1]===5&&(o=1),r[c+f+1+o]=h[f];while(++f<h.length&&f+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let h=2;h<r.length;++h)r[h]===-1&&(r[h]=0);switch(r[0]){case 38:s.fg=this._updateAttrColor(s.fg,r[1],r[3],r[4],r[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,r[1],r[3],r[4],r[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=di.fg,e.bg=di.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,s,r=this._curAttrData;for(let o=0;o<t;o++)s=e.params[o],s>=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=di.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=di.bg&16777215):s===38||s===48||s===58?o+=this._extractColor(e,o,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=di.fg&16777215,r.bg&=-67108864,r.bg|=di.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${s}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=di.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!NS(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(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>MS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>MS&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),o=s.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(BS(c))if(o==="?")t.push({type:0,index:c});else{let h=RS(o);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,o=s.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=s[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 s=e.split(";");for(let r=0;r<s.length&&!(t>=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=RS(s[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=[],s=e.split(";");for(let r=0;r<s.length;++r)if(/^\d+$/.exec(s[r])){let o=parseInt(s[r]);BS(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,fa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(dM[e[0]],wi[e[1]]||fa),!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=di.clone(),this._eraseAttrDataInternal=di.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Zn;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(s);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=h=>(this._coreService.triggerDataEvent(`${pe.ESC}${h}${pe.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return s(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)}},vm=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&&(LS=e,e=t,t=LS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};vm=Qt([Me(0,tn)],vm);function BS(e){return 0<=e&&e<256}var pM=5e7,OS=12,mM=50,gM=class extends tt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Te),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 s;for(;s=this._writeBuffer.shift();){this._action(s);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>pM)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let h=f=>performance.now()-s>=OS?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(s,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=OS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>mM&&(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()}},bm=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(g,f)),this._dataByLinkId.set(g.id,g),g.id}let s=e,r=this._getEntryIdKey(s),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};bm=Qt([Me(0,tn)],bm);var zS=!1,_M=class extends tt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sl),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new IR,this.optionsService=this._register(new ZR(e)),this._instantiationService.setService(nn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(pm)),this._instantiationService.setService(tn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(fm)),this._instantiationService.setService(Ew,this._logService),this.coreService=this._register(this._instantiationService.createInstance(mm)),this._instantiationService.setService(Ea,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(gm)),this._instantiationService.setService(xw,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ga)),this._instantiationService.setService(jT,this.unicodeService),this._charsetService=this._instantiationService.createInstance(iM),this._instantiationService.setService(zT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bm),this._instantiationService.setService(kw,this._oscLinkService),this._inputHandler=this._register(new fM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qi.forward(this._bufferService.onResize,this._onResize)),this._register(qi.forward(this.coreService.onData,this._onData)),this._register(qi.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 gM((t,s)=>this._inputHandler.parse(t,s))),this._register(qi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),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&&!zS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),zS=!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,s1),t=Math.max(t,r1),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(TS.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(TS(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Pt(()=>{for(let t of e)t.dispose()})}}},vM={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 bM(e,t,s,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(o.key=pe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=pe.ESC+"[Z";break}o.key=pe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?pe.ESC+pe.CR:pe.CR,o.cancel=!0;break;case 27:o.key=pe.ESC,e.altKey&&(o.key=pe.ESC+pe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"D":t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"C":t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"A":t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"B":t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=pe.ESC+"[2~");break;case 46:c?o.key=pe.ESC+"[3;"+(c+1)+"~":o.key=pe.ESC+"[3~";break;case 36:c?o.key=pe.ESC+"[1;"+(c+1)+"H":t?o.key=pe.ESC+"OH":o.key=pe.ESC+"[H";break;case 35:c?o.key=pe.ESC+"[1;"+(c+1)+"F":t?o.key=pe.ESC+"OF":o.key=pe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=pe.ESC+"[5;"+(c+1)+"~":o.key=pe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=pe.ESC+"[6;"+(c+1)+"~":o.key=pe.ESC+"[6~";break;case 112:c?o.key=pe.ESC+"[1;"+(c+1)+"P":o.key=pe.ESC+"OP";break;case 113:c?o.key=pe.ESC+"[1;"+(c+1)+"Q":o.key=pe.ESC+"OQ";break;case 114:c?o.key=pe.ESC+"[1;"+(c+1)+"R":o.key=pe.ESC+"OR";break;case 115:c?o.key=pe.ESC+"[1;"+(c+1)+"S":o.key=pe.ESC+"OS";break;case 116:c?o.key=pe.ESC+"[15;"+(c+1)+"~":o.key=pe.ESC+"[15~";break;case 117:c?o.key=pe.ESC+"[17;"+(c+1)+"~":o.key=pe.ESC+"[17~";break;case 118:c?o.key=pe.ESC+"[18;"+(c+1)+"~":o.key=pe.ESC+"[18~";break;case 119:c?o.key=pe.ESC+"[19;"+(c+1)+"~":o.key=pe.ESC+"[19~";break;case 120:c?o.key=pe.ESC+"[20;"+(c+1)+"~":o.key=pe.ESC+"[20~";break;case 121:c?o.key=pe.ESC+"[21;"+(c+1)+"~":o.key=pe.ESC+"[21~";break;case 122:c?o.key=pe.ESC+"[23;"+(c+1)+"~":o.key=pe.ESC+"[23~";break;case 123:c?o.key=pe.ESC+"[24;"+(c+1)+"~":o.key=pe.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=pe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=pe.DEL:e.keyCode===219?o.key=pe.ESC:e.keyCode===220?o.key=pe.FS:e.keyCode===221&&(o.key=pe.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let h=vM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(f);e.shiftKey&&(g=g.toUpperCase()),o.key=pe.ESC+g}else if(e.keyCode===32)o.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=pe.ESC+f,o.cancel=!0}}else s&&!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=pe.US),e.key==="@"&&(o.key=pe.NUL));break}return o}var si=0,yM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[o]=e[t],t++):r[o]=this._array[s++];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||(si=this._search(t),si===-1)||this._getKey(this._array[si])!==t)return!1;do if(this._array[si]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(si),!0;while(++si<this._array.length&&this._getKey(this._array[si])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,s=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:s[r++]=this._array[o];this._array=s,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&&(si=this._search(e),!(si<0||si>=this._array.length)&&this._getKey(this._array[si])===e))do yield this._array[si];while(++si<this._array.length&&this._getKey(this._array[si])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(si=this._search(e),!(si<0||si>=this._array.length)&&this._getKey(this._array[si])===e))do t(this._array[si]);while(++si<this._array.length&&this._getKey(this._array[si])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let r=t+s>>1,o=this._getKey(this._array[r]);if(o>e)s=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}},sp=0,jS=0,SM=class extends tt{constructor(){super(),this._decorations=new yM(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Pt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new wM(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!s||(c.options.layer??"bottom")===s)&&(yield c)}forEachDecorationAtCell(e,t,s,r){this._decorations.forEachByKey(t,o=>{sp=o.options.x??0,jS=sp+(o.options.width??1),e>=sp&&e<jS&&(!s||(o.options.layer??"bottom")===s)&&r(o)})}},wM=class extends Br{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),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=$t.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=$t.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},CM=1e3,xM=class{constructor(e,t=CM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,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,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},HS=20,rh=class extends tt{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,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 c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new xM(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
28
|
+
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register($e(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Pt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<HS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===HS+1&&(this._liveRegion.textContent+=Pp.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let o=e;o<=t;o++){let c=s.lines.get(s.ydisp+o),h=[],f=c?.translateToString(!0,void 0,void 0,h)||"",g=(s.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,h)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=s.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let h,f;if(t===0?(h=s,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(h=this._rowElements.shift(),f=s,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let o=({node:f,offset:g})=>{let p=f instanceof Text?f.parentNode:f,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++y,w=0),{row:y,column:w}},c=o(t),h=o(s);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};rh=Qt([Me(1,_g),Me(2,Gs),Me(3,Zs)],rh);var ym=class extends tt{constructor(e,t,s,r,o){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Pt(()=>{wa(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register($e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register($e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($e(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 s=e.composedPath();for(let r=0;r<s.length;r++){let o=s[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 s=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(f=>({link:f}));this._activeProviderReplies?.set(r,h),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let h=o[c],f=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let p=f;p<=g;p++){if(s.has(p)){o.splice(c--,1);break}s.add(p)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(h=>this._linkAtPosition(h.link,t));c&&(s=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(f=>this._linkAtPosition(f.link,t));if(h){s=!0,this._handleNewLink(h);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&EM(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,wa(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,s){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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,s){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(s,t.text)}_linkAtPosition(e,t){let s=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 s<=o&&o<=r}_positionFromMouseEvent(e,t,s){let r=s.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,s,r,o){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:o}}};ym=Qt([Me(1,vg),Me(2,Zs),Me(3,tn),Me(4,Dw)],ym);function EM(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 kM=class extends _M{constructor(e={}){super(e),this._linkifier=this._register(new Sl),this.browser=Yw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sl),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(SM),this._instantiationService.setService(fc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(mR),this._instantiationService.setService(Dw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ip)),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(qi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Pt(()=>{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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let o=jt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${pe.ESC}]${r};${hM(o)}${qw.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=fi.toColor(...t.color));else{let c=s;this._themeService.modifyColors(h=>h[c]=fi.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.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(pe.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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(s),c=this._renderService.dimensions.css.cell.width*o,h=this.buffer.y*this._renderService.dimensions.css.cell.height,f=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($e(this.element,"copy",t=>{this.hasSelection()&&MT(t,this._selectionService)}));let e=t=>NT(t,this.textarea,this.coreService,this.optionsService);this._register($e(this.textarea,"paste",e)),this._register($e(this.element,"paste",e)),Vw?this._register($e(this.element,"mousedown",t=>{t.button===2&&Vy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register($e(this.element,"contextmenu",t=>{Vy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),kg&&this._register($e(this.element,"auxclick",t=>{t.button===1&&bw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register($e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register($e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register($e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register($e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register($e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register($e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register($e(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($e(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 s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Hp.get()),Zw||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(fR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Gs,this._coreBrowserService),this._register($e(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register($e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(om,this._document,this._helperContainer),this._instantiationService.setService(xh,this._charSizeService),this._themeService=this._instantiationService.createInstance(dm),this._instantiationService.setService(Tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ih),this._instantiationService.setService(Tw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(um,this.rows,this.screenElement)),this._instantiationService.setService(Zs,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(rm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(cm),this._instantiationService.setService(vg,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(ym,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(nm,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(hm,this.element,this.screenElement,r)),this._instantiationService.setService(PT,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(qi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(sm,this.screenElement)),this._register($e(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(lm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let f,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(f=3,c.button!==void 0&&(f=c.button<3?c.button:3)):f=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,f=c.button<3?c.button:3;break;case"mousedown":g=1,f=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,f=4;break;default:return!1}return g===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:f,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($e(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register($e(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let h=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){vw(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,s){this._selectionService.setSelection(e,t,s)}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 s=bM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===pe.ETX||s.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(TM(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(di));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(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${s};${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(`${pe.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function TM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var DM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;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)}},RM=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Zn)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},PS=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 RM(t)}getNullCell(){return new Zn}},MM=class extends tt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new PS(this._core.buffers.normal,"normal"),this._alternate=new PS(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)}},NM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,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)}},AM=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}},LM=["cols","rows"],Ss=0,BM=class extends tt{constructor(e){super(),this._core=this._register(new kM(e)),this._addonManager=this._register(new DM),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(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:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(LM.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 NM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new AM(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 MM(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
30
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Hp.get()},set promptLabel(e){Hp.set(e)},get tooMuchOutput(){return Pp.get()},set tooMuchOutput(e){Pp.set(e)}}}_verifyIntegers(...e){for(Ss of e)if(Ss===1/0||isNaN(Ss)||Ss%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ss of e)if(Ss&&(Ss===1/0||isNaN(Ss)||Ss%1!==0||Ss<0))throw new Error("This API only accepts positive integers")}};class OM{pending=null;accept(t){let s="";for(const r of t)s+=this.acceptChar(r);return s}acceptChar(t){return t===""?this.acceptBackspace():u1.has(t)?this.acceptConsonant(t):h1.has(t)?this.acceptVowel(t):PM(t)&&this.canReplacePendingWith(t)?(this.pending=IS(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(d1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const s=HM.get(`${this.pending.final}${t}`);if(s)return this.pending.final=s,"";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 c=jM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const s=US.get(this.pending.final);if(s){this.pending.final=s[0];const c=this.flushPending();return this.pending={initial:s[1],vowel:t},c}const r=this.pending.final,o=KS({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=US.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 s=IS(t);return s.initial===this.pending.initial&&(!this.pending.vowel||s.vowel===this.pending.vowel)&&(!this.pending.final||s.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=KS(this.pending);return this.pending=null,t}}const ah=44032,lh=21,fl=28,zM=19*lh*fl,l1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],o1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],c1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],u1=Tg(l1),h1=Tg(o1),d1=Tg(c1),jM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),f1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],HM=new Map(f1),US=new Map(f1.map(([e,t])=>[t,[e[0],e[1]]]));function Tg(e){return new Map(e.map((t,s)=>[t,s]))}function PM(e){const t=e.codePointAt(0);return t!==void 0&&t>=ah&&t<ah+zM}function IS(e){const t=e.codePointAt(0)-ah,s=Math.floor(t/(lh*fl)),r=Math.floor(t%(lh*fl)/fl),o=t%fl,c={initial:l1[s],vowel:o1[r]};return o===0?c:{...c,final:c1[o]}}function KS(e){if(!e.vowel)return e.initial;const t=u1.get(e.initial),s=h1.get(e.vowel),r=e.final?d1.get(e.final):0;return t===void 0||s===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(ah+(t*lh+s)*fl+r)}const UM=[{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 IM({ctrlActive:e,onCtrl:t,onStandaloneKey:s,onPreserveFocus:r,onHide:o}){function c(h){h.stopPropagation(),r()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),UM.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>s(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const KM={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function FM(e){return KM[e]}function WM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const FS="--nterminal-viewport-height",WS="--nterminal-keyboard-inset-bottom",qS="data-nterminal-keyboard-visible",Th="data-nterminal-compose-open",nc="nterminal:viewport-refresh",qM=120;function $M(e=window){const t=e.document.documentElement,s=e.visualViewport;function r(){const o=YM(e);o!==null&&t.style.setProperty(FS,`${o}px`),t.style.setProperty(WS,`${p1(e)}px`),t.setAttribute(qS,String(VM(e)))}return r(),s?.addEventListener("resize",r),s?.addEventListener("scroll",r),e.addEventListener("resize",r),e.addEventListener(nc,r),e.addEventListener("orientationchange",r),e.addEventListener("pageshow",r),e.document.addEventListener("visibilitychange",r),()=>{s?.removeEventListener("resize",r),s?.removeEventListener("scroll",r),e.removeEventListener("resize",r),e.removeEventListener(nc,r),e.removeEventListener("orientationchange",r),e.removeEventListener("pageshow",r),e.document.removeEventListener("visibilitychange",r),t.style.removeProperty(FS),t.style.removeProperty(WS),t.removeAttribute(qS)}}function YM(e){if(e.document.documentElement.hasAttribute(Th)&&Xo(e.innerHeight))return e.innerHeight;const t=e.visualViewport?.height;return Xo(t)?t:Xo(e.innerHeight)?e.innerHeight:null}function Xo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function VM(e){return p1(e)>qM}function p1(e){const t=e.visualViewport?.height;if(!Xo(t)||!Xo(e.innerHeight))return 0;const s=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-s))}const gc=new Map,sc=new Map,XM=Object.freeze({open:!1,text:""});function GM(e){let t=sc.get(e);return t||(t=new Set,sc.set(e,t)),t}function m1(e){const t=sc.get(e);if(t)for(const s of Array.from(t))s()}function Dg(e){return gc.get(e)??XM}function ZM(e,t){const s=GM(e);return s.add(t),()=>{s.delete(t)}}function QM(e,t){const s=Dg(e);s.open!==t&&(gc.set(e,{...s,open:t}),m1(e))}function JM(e,t){const s=Dg(e);s.text!==t&&(gc.set(e,{...s,text:t}),m1(e))}function Nu(e){gc.delete(e),sc.delete(e)}function $S(){gc.clear(),sc.clear()}const g1=120,eN="\x1B[200~",tN="\x1B[201~";function YS(e,t){const s=t.stripTrailingLineBreaks===!1?e:Rg(e),r=nN(s);return r?t.bracketedPasteMode?`${eN}${r}${tN}`:r:""}function iN(e){return e==="queue"?" ":"\r"}function Rg(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function nN(e){return e.replace(/\r\n/g,`
|
|
31
|
+
`).replace(/\r/g,`
|
|
32
|
+
`).replace(/\n/g,"\r")}const sN=420,Ku=new Set;let _l=null;function rN({terminalId:e,onSubmit:t,queueAvailable:s=!1,disabled:r=!1}){const o=v.useMemo(()=>A=>ZM(e,A),[e]),c=v.useMemo(()=>()=>Dg(e),[e]),h=v.useSyncExternalStore(o,c,c),{open:f,text:g}=h,p=v.useRef(null),y=v.useRef(null),b=v.useRef(null);v.useLayoutEffect(()=>{if(!(!f||!Sm()))return lN(e),()=>oN(e)},[f,e]),v.useLayoutEffect(()=>{const A=p.current?.closest(".terminal-pane");if(!A)return;function O(){A?.removeAttribute("data-compose-open"),A?.style.removeProperty("--compose-drawer-panel-height")}if(!f){O();return}const L=y.current;A.setAttribute("data-compose-open","true");function U(){const ae=L?.getBoundingClientRect().height??0;ae>0&&A?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ae)}px`)}U();const I=[window.setTimeout(U,0),window.setTimeout(U,180),window.setTimeout(U,260)],te=window.requestAnimationFrame?.(U)??null,ee=typeof ResizeObserver=="function"&&L?new ResizeObserver(U):null;return ee&&L&&ee.observe(L),()=>{for(const ae of I)window.clearTimeout(ae);te!==null&&window.cancelAnimationFrame?.(te),ee?.disconnect(),O()}},[f]),v.useEffect(()=>{f&&b.current?.focus()},[f]);function w(A){QM(e,A)}function S(A){JM(e,A)}function E(){aN(p.current),w(!1),VS()}function T(A="send"){if(!(r||!g)){if(t(g,A),S(""),Sm()){b.current?.blur(),VS();return}window.setTimeout(()=>b.current?.focus(),g1+20)}}return m.jsxs("div",{ref:p,className:"compose-drawer","data-open":f?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":f?"true":void 0,tabIndex:f?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":f?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:f?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:E,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:s?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:f?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:A=>S(A.target.value),onKeyDown:A=>{if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)){if(A.preventDefault(),A.shiftKey){s&&T("queue");return}T("send");return}A.key==="Escape"&&(A.preventDefault(),E())},placeholder:s?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:f?0:-1,onClick:()=>{S(""),b.current?.focus()},disabled:!g,children:"Clear"}),s?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:f?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>T("queue"),disabled:r||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:f?0:-1,onClick:()=>T("send"),disabled:r||!g,children:"Send"})]})]})]})}function aN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Sm(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function VS(){if(!Sm())return;const e=()=>{window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,pl()};e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function lN(e){_l!==null&&(window.clearTimeout(_l),_l=null),Ku.add(e),document.documentElement.setAttribute(Th,"true"),pl()}function oN(e){if(Ku.delete(e),Ku.size>0||_l!==null){pl();return}_l=window.setTimeout(()=>{if(_l=null,Ku.size>0){pl();return}document.documentElement.removeAttribute(Th),pl()},sN),pl()}function pl(){window.dispatchEvent(new Event(nc))}function cN(e,t){e.attachCustomKeyEventHandler(c=>{if(uN(c)){const h=XS(e);return h?(c.preventDefault(),c.stopPropagation(),GS(h),!1):!0}return hN(c)?(c.preventDefault(),c.stopPropagation(),dN(e,t),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const r=c=>{const h=XS(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),GS(h)}},o=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const f=Rg(h);c.preventDefault(),c.stopImmediatePropagation(),_1(e,f,t)};return s.addEventListener("copy",r,!0),s.addEventListener("paste",o,!0),{dispose(){s.removeEventListener("copy",r,!0),s.removeEventListener("paste",o,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function uN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function hN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function dN(e,t){if(navigator.clipboard?.readText)try{const s=await navigator.clipboard.readText();if(!s)return;_1(e,Rg(s),t)}catch{}}function _1(e,t,s){if(t){if(s){s(t);return}e.paste(t)}}function XS(e){return e.hasSelection()?e.getSelection():""}async function GS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}fN(e)}function fN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.left="-9999px",s.style.top="0",s.style.opacity="0",document.body.appendChild(s),s.focus({preventScroll:!0}),s.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{s.remove(),t?.focus({preventScroll:!0})}}const pN=[4,10,11,12];function mN(e,t){const s=[e.parser.registerCsiHandler({final:"c"},r=>ZS(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>ZS(r)),e.parser.registerCsiHandler({final:"n"},r=>gN(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>_N(r)),e.parser.registerCsiHandler({final:"t"},r=>vN(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...pN.map(r=>e.parser.registerOscHandler(r,o=>bN(o)))];return{dispose(){for(const r of s)r.dispose()}}}function ZS(e){return Dh(e)===0}function gN(e){const t=Dh(e);return t===5||t===6}function _N(e){return Dh(e)===6}function vN(e){const t=Dh(e);return t===14||t===16||t===18}function bN(e){return e.split(";").some(t=>t==="?")}function Dh(e){const t=e[0];return typeof t=="number"?t:0}const xa=new Map,yN=2*1024*1024,SN=1500,wN=25e3;function CN(e,t){let s=xa.get(e);s||(s=kN(e),xa.set(e,s),Rh(s)),s.listeners.add(t);const r=c=>AN(s,c),o=()=>{s.listeners.delete(t)};return{status:s.status,snapshot:s.snapshot,output:s.output.slice(),history:s.history,send:r,detach:o}}function Ho(e){const t=xa.get(e);t&&(LN(t),xa.delete(e))}function xN(e,t={}){const s=xa.get(e);if(!s)return!1;s.exited=!1,s.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(s.preserveCachedOutputOnNextSnapshot=!0),s.reconnectTimer!==null&&(window.clearTimeout(s.reconnectTimer),s.reconnectTimer=null),_c(s);const r=s.socket;return s.socket=null,pa(s,"reconnecting"),r&&(r.readyState===WebSocket.OPEN||r.readyState===WebSocket.CONNECTING)&&r.close(),Rh(s),!0}function EN(){for(const e of xa.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),_c(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,pa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Rh(e)}}function rp(){for(const e of Array.from(xa.keys()))Ho(e)}function kN(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function Rh(e){if(!e.reconnectEnabled)return;pa(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){pa(e,"connected");for(const s of e.pendingOut)t.send(JSON.stringify(s));e.pendingOut.length=0,e.isAlive=!0,TN(e)}}),t.addEventListener("message",s=>{if(e.socket!==t)return;const r=typeof s.data=="string"?s.data:"";if(!r)return;let o=null;try{o=JSON.parse(r)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;return}const c=RN(e,o);v1(e,{type:"message",message:c})}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,_c(e),s.code===1008){e.reconnectEnabled=!1,pa(e,DN(s.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){pa(e,"closed");return}pa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Rh(e)},SN)}}),t.addEventListener("error",()=>{})}function TN(e){_c(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},wN)}function _c(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function DN(e){return e.trim().toLowerCase()==="unauthorized"}function RN(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,MN(e,t.output),ap(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((s,r)=>s+r.length,0),ap(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,ap(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function MN(e,t){const s=NN(e.output,t);if(s===0)return;const r=t.slice(s);for(const o of r)e.output.push(o),e.outputBytes+=o.length}function NN(e,t){const s=Math.min(e.length,t.length);for(let r=s;r>0;r-=1){let o=!0;for(let c=0;c<r;c+=1)if(e[e.length-r+c]!==t[c]){o=!1;break}if(o)return r}return 0}function ap(e){for(;e.outputBytes>yN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function pa(e,t){e.status!==t&&(e.status=t,v1(e,{type:"status",status:t}))}function v1(e,t){for(const s of Array.from(e.listeners))s(t)}function AN(e,t){const s=e.socket;return s&&s.readyState===WebSocket.OPEN?(s.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function LN(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),_c(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const BN=[0,50,150,350],ON=120,zN=2,jN=[300,1200,2500],HN=1e3,PN=1e5,wm="\x1B[?1049l\x1B[?1047l\x1B[?47l",UN=new Set(["47","1047","1049"]),IN=400,KN=3,FN=3,WN=32,qN=1.42,$N=2,YN=24,VN=240,XN=60,GN=420,ZN=6,QN=2,QS=[500,1500,3e3,5e3,8e3],JS=15e3,JN=Si.lazy(()=>gg(()=>import("./TranscriptMarkdownBody-J4Bk7GDH.js"),__vite__mapDeps([2,1])));function e0({terminal:e,serverApi:t,active:s,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:f,onClose:g,onExit:p,onSnapshot:y,onAuthClose:b}){const w=v.useSyncExternalStore(rw,Np,()=>_a),S=v.useSyncExternalStore(aw,Ap,()=>bl),E=v.useSyncExternalStore(lw,Bp,()=>!0),T=v.useSyncExternalStore(qm,Or,()=>vl),A=v.useSyncExternalStore(ug,()=>hg("history.toggle"),()=>"Alt+H"),O=v.useRef(null),L=v.useRef(null),U=v.useRef(null),I=v.useRef(null),te=v.useRef({onExit:p,onSnapshot:y}),ee=v.useRef(t.createWebSocketUrl),ae=v.useRef(b),ue=v.useRef(null),be=v.useRef(null),we=v.useRef(!1),ne=v.useRef(new Map),ie=v.useRef([]),Y=v.useRef([]),K=v.useRef([]),re=v.useRef(0),B=v.useRef(!1),$=v.useRef(null),D=v.useRef(0),X=v.useRef(null),_e=v.useRef(null),R=v.useRef(!1),H=v.useRef(!1),Q=v.useRef(!1),de=v.useRef(!1),ke=v.useRef(null),xe=v.useRef(null),Re=v.useRef(!1),Xe=v.useRef(!1),ge=v.useRef(!1),G=v.useRef(!1),ce=v.useRef(!1),Ce=v.useRef(!1),ye=v.useRef(!1),De=v.useRef(s),Be=v.useRef(r),Ke=v.useRef(c),le=v.useRef(w),Ee=v.useRef(S),Le=v.useRef(!1),Oe=v.useRef(null),He=v.useRef(null),_t=v.useRef(!1),Ye=v.useRef(null),[,rt]=v.useState("connecting"),[Oi,$i]=v.useState(!1),[Ci,ri]=v.useState(null),[zi,sn]=v.useState(!1),[F,qe]=v.useState(null),[dt,vt]=v.useState(!1),[pi,St]=v.useState(!1),[mn,Ln]=v.useState(!1),[Jt,ai]=v.useState(null),[Zi,gt]=v.useState(!1),Tt=!!Jt||Fu(e.currentCommand),[Dt,mi]=v.useState(!1);v.useLayoutEffect(()=>{De.current=s},[s]),v.useLayoutEffect(()=>{Be.current=r},[r]),v.useLayoutEffect(()=>{Ke.current=c},[c]),v.useLayoutEffect(()=>{le.current=w},[w]),v.useLayoutEffect(()=>{Ee.current=S},[S]),v.useLayoutEffect(()=>{Le.current=Zi},[Zi]),v.useLayoutEffect(()=>{Oe.current=Jt},[Jt]),v.useLayoutEffect(()=>{_t.current=Tt},[Tt]),v.useEffect(()=>{r&&s&&e.status==="running"&&(At(),bn())},[s,r,e.status]),v.useEffect(()=>{te.current={onExit:p,onSnapshot:y}},[p,y]),v.useEffect(()=>{ee.current=t.createWebSocketUrl,ae.current=b},[t,b]),v.useEffect(()=>{let M=!1,J=null,je=0;const Fe=p3(e.currentCommand),Ie=Fu(e.currentCommand);function Ge(){J!==null&&(window.clearTimeout(J),J=null)}function Ft(wt){if(M)return;let Bt;if(wt){if(!Ie)return;Bt=JS}else if(je<QS.length){if(!Fe)return;Bt=QS[je++]}else{if(!Ie)return;Bt=JS}J=window.setTimeout(()=>{J=null,li()},Bt)}async function li(){try{const wt=await t.getTerminalTranscriptSource(e.id);if(M)return;ai(Bt=>Bt&&wt.source&&Bt.provider===wt.source.provider&&Bt.sessionId===wt.source.sessionId?Bt:wt.source),Ft(!!wt.source)}catch(wt){if(M)return;lp(wt)&&ai(null),Ft(!1)}}return ai(null),e.status!=="running"?()=>{M=!0,Ge()}:(li(),()=>{M=!0,Ge()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const M=Jt?`${e.id}:${Jt.provider}:${Jt.sessionId}`:null,J=He.current;J!==null&&M!==null&&J!==M&&Le.current&>(!1),He.current=M},[e.id,Jt?.provider,Jt?.sessionId]),v.useEffect(()=>{function M(J){!De.current||!Be.current||!Oe.current||J.isComposing||J.key==="Process"||i3(J.target)||ow(J)?.id!=="history.toggle"||(J.preventDefault(),J.stopPropagation(),gt(Fe=>!Fe))}return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[]),v.useEffect(()=>{const M=L.current;M&&(M.options.disableStdin=e.status==="exited"),e.status==="exited"&&rt("closed")},[e.status]),v.useEffect(()=>{const M=L.current;M&&(M.options.fontSize=w,Kf(w,Ee.current).then(()=>{le.current===w&&At()}))},[w]),v.useEffect(()=>{const M=L.current;M&&(M.options.fontFamily=Mp(S),Kf(le.current,S).then(()=>{Ee.current===S&&At()}))},[S]),v.useEffect(()=>{const M=L.current;M&&(M.options.theme=t0(T))},[T]),v.useEffect(()=>{const M=O.current;if(!M)return;let J=!1,je=null,Fe=null,Ie=null,Ge=null,Ft=null,li=null,wt=null;ue.current=null,ce.current=!1,Ce.current=!1,de.current=!1,es(),Ut();const Bt=le.current,Ui=Ee.current,Wt=new BM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Mp(Ui),fontSize:Bt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:PN,theme:{...t0(Or())}}),Sn=new ET;return Wt.loadAddon(Sn),Ge=mN(Wt),L.current=Wt,U.current=Sn,Kf(Bt,Ui).then(()=>{if(J)return;Wt.open(M),ce.current=!0,je=cN(Wt,Na),Be.current&&De.current&&e.status==="running"&&bn(),At(),Ft=C3(M,Wt,()=>le.current*1.2,Vi,x=>{It(x)},Ts,it),li=y3(M,Wt,Vi,x=>{It(x)},Ts,it);const jn=new OM;Fe=Wt.onData(x=>{if(ye.current){const j=WM(x);if(j){yn(!1),rs(j);return}}const k=jn.accept(x);k&&rs(k)}),Ie=Wt.onScroll(x=>{if(Xe.current||G.current||ge.current){ot();return}_n(),cs(Wt)&&On({scrollToBottom:!0}),Vi(),x<=3&&It()}),wt=new ResizeObserver(()=>{Hi()}),wt.observe(M),Ce.current&&(Lt(),Ce.current=!1,At()),fs()}),()=>{J=!0,ce.current=!1,Ce.current=!1,es(),be.current=null,we.current=!1,ts(),Ur(),ge.current=!1,Ft?.(),li?.(),wt?.disconnect(),je?.dispose(),Fe?.dispose(),Ie?.dispose(),Ge?.dispose(),Wt.dispose(),L.current=null,U.current=null}},[e.id]),v.useEffect(()=>{const M=ee.current(e.id),J=CN(M,gi);return I.current=J.send,rt(J.status),J.status==="connected"&&At(),J.snapshot&&(te.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),L.current&&(At(),ei(J.output,J.history),At())),()=>{J.detach(),I.current=null}},[e.id,e.status]);function gi(M){if(M.type==="status"){rt(M.status),M.status==="unauthorized"&&ae.current?.({source:"terminal-ws-1008",terminalId:e.id}),M.status==="connected"&&At();return}Qi(M.message)}function Ut(M=[],J=null){Y.current=[],K.current=Au(M),re.current=0,B.current=!1,$.current=null,ge.current=!1,D.current+=1,X.current=J,_e.current=null,R.current=!1,H.current=!1,Q.current=!1,Ce.current=!1,Ye.current=null,ke.current=null,Re.current=!1,$i(!1),ri(null),sn(!1),qe(null),vt(!1),St(!1)}function ei(M=[],J=null){Ut(M,J),ji()}function ji(){if(!L.current||!ce.current){Ce.current=!0;return}Ce.current=!1,Lt()}async function Lt(){const M=L.current;if(!M)return;const J=Lu(M,Re.current),je=J?K.current.length:re.current;await xi(M,{liveOutputLimit:je,scrollToBottom:J}),L.current===M&&ot()}function xi(M,J={}){return new Promise(je=>{ge.current=!0,B.current=!1;const Fe=D.current+1;D.current=Fe;const Ie=Math.max(0,Math.min(J.liveOutputLimit??K.current.length,K.current.length)),Ge=J.historyPages??Y.current,Ft=()=>{if(L.current!==M||D.current!==Fe){je(!1);return}try{re.current=Ie,J.scrollToBottom&&ss(M)}finally{ge.current=!1;const wt=Ir();wt?On(wt):J.applyDeferredSnapshot!==!1&&Yt(),je(!0)}},li=()=>{if(L.current!==M||D.current!==Fe){je(!1);return}M.clear();const wt=Au([...Ge,...K.current.slice(0,Ie)]);if(wt.length===0){Ft();return}for(let Bt=0;Bt<wt.length;Bt+=1){const Ui=wt[Bt];Bt===wt.length-1?M.write(Ui,Ft):M.write(Ui)}};if(M.buffer.active.type==="alternate"){M.write(wm,li);return}li()})}async function It(M=0){const J=L.current;if(Q.current||!J)return;if(Kr(J)){ot();return}const je=X.current;Q.current=!0,$i(!0);const Fe=J.buffer.active.viewportY;try{let Ie=!!(je&&!je.hasMore);if(!Ie)try{const Ge=await t.getTerminalHistory(e.id,{beforeLine:je?.startLine??0,limit:HN}),Ft={startLine:Ge.startLine,endLine:Ge.endLine,hasMore:Ge.hasMore};if(Ge.output.length>0){await rn(J,Ge.output,Fe,M)&&(X.current=Ft);return}X.current=Ft,Ie=!Ge.hasMore}catch(Ge){Ie=lp(Ge)}if(Ie){if(Kr(J)){ot();return}await Yi(J,Fe,M)}}catch{}finally{Q.current=!1,$i(!1)}}async function Yi(M,J,je){if(!(R.current||H.current))try{const Fe=_e.current,Ie=await t.getTerminalTranscriptHistory(e.id,{...Fe?{cursor:Fe}:{},limit:IN}),Ge=Ie.output.map(S1);if(!Ie.source)return;if(Ge.length===0){ai(Ie.source),_e.current=Ie.cursor,H.current=!Ie.hasMore||!Ie.cursor;return}await rn(M,Ge,J,je)&&(ai(Ie.source),_e.current=Ie.cursor,H.current=!Ie.hasMore||!Ie.cursor)}catch(Fe){lp(Fe)&&(R.current=!0)}}async function rn(M,J,je,Fe){if(Kr(M))return ot(),!1;const Ie=[...J,...Y.current],Ge=v3(J);return!await xi(M,{liveOutputLimit:re.current,scrollToBottom:!1,historyPages:Ie,applyDeferredSnapshot:!1})||L.current!==M?!1:(Y.current=Ie,Fr(M,Math.max(0,je+Ge+Math.min(0,Fe))),Re.current=!cs(M),Vi(),!0)}v.useEffect(()=>{const M=window.visualViewport;function J(){document.visibilityState==="visible"&&At()}function je(){At()}function Fe(){Hi()}function Ie(){Ei()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",je),window.addEventListener("resize",Fe),window.addEventListener(nc,Ie),M?.addEventListener("resize",Fe),M?.addEventListener("scroll",Fe),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",je),window.removeEventListener("resize",Fe),window.removeEventListener(nc,Ie),M?.removeEventListener("resize",Fe),M?.removeEventListener("scroll",Fe)}},[e.id]);function an(){const M=ee.current(e.id);de.current=!0,Ye.current=null,rt("reconnecting"),At(),xN(M,{preserveCachedOutputOnNextSnapshot:!0})}function Qi(M){if(M.type==="snapshot"&&M.terminal.id===e.id){te.current.onSnapshot(M.terminal,{notifyCompletion:!1});const je=L.current;if(!je)return;At();const Fe=de.current;if(de.current=!1,Fe){X.current=M.history??X.current,ot(),At();return}if(Qs(je,M.terminal)){vn(M.output,M.history??null),ot(),At();return}ei(M.output,M.history??null),At();return}if(M.type==="terminal_updated"&&M.terminal.id===e.id){te.current.onSnapshot(M.terminal,{notifyCompletion:!0});return}if(M.type==="output"&&M.terminalId===e.id){const je=x1(M.data);if(!je)return;K.current.push(je),L.current&&ce.current?On({scrollToBottom:!0}):Ce.current=!0;return}const J=L.current;if(J){if(M.type==="exit"&&M.terminalId===e.id){te.current.onExit(M.exitCode),rt("closed");return}M.type==="error"&&J.writeln(`\r
|
|
33
|
+
[nterminal] ${M.message}`)}}function gn(M=25){if(document.visibilityState==="hidden"||!Be.current||ne.current.has(M))return;const J=window.setTimeout(()=>{ne.current.delete(M),!Kt()&&$r()},M);ne.current.set(M,J)}function Hi(){Kt()||fs()}function Kt(){const M=ks();return M&&Bn(M)?(we.current=!0,!0):((!M||!M.composeOpen&&!M.keyboardVisible)&&(we.current=!1),!1)}function Ei(){if(!we.current)return;const M=ks();M&&(M.composeOpen||M.keyboardVisible)||(we.current=!1,fs())}function Bn(M){if(!M.mobileLike||!M.composeOpen&&!M.keyboardVisible)return!1;const J=be.current;return J?Jn(M.windowWidth,J.windowWidth)&&Jn(M.visualViewportWidth,J.visualViewportWidth)&&Jn(M.containerWidth,J.containerWidth):!1}function ks(){const M=O.current;if(!M||M.isConnected===!1)return null;const J=M.getBoundingClientRect(),je=Qn(window.innerWidth)??0,Fe=Qn(window.visualViewport?.width)??je,Ie=Qn(J.width)??Qn(M.clientWidth)??je;if(je<=0||Fe<=0||Ie<=0)return null;const Ge=Nl()>ON,Ft=document.documentElement.hasAttribute(Th),li=Da()||Ge;return{windowWidth:je,visualViewportWidth:Fe,containerWidth:Ie,composeOpen:Ft,keyboardVisible:Ge,mobileLike:li}}function Nl(){const M=Qn(window.visualViewport?.height),J=Qn(window.innerHeight);if(M===null||J===null)return 0;const je=typeof window.visualViewport?.offsetTop=="number"?window.visualViewport.offsetTop:0;return Math.max(0,Math.round(J-M-je))}function Da(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Qn(M){return typeof M=="number"&&Number.isFinite(M)&&M>0?M:null}function Jn(M,J){return Math.abs(M-J)<=zN}function fs(){for(const M of BN)gn(M)}function At(){ue.current=null,fs()}function es(){for(const M of ne.current.values())window.clearTimeout(M);ne.current.clear()}function ts(){for(const M of ie.current)window.clearTimeout(M);ie.current=[]}function Vi(){if(ot(),!ke.current){sn(!1);return}sn(!0),Ur(),xe.current=window.setTimeout(()=>{xe.current=null,sn(!1)},1200)}function ot(){const M=L.current,J=M?b3(M):null;if(ke.current=J,ri(J),St(!!(M&&J)),vt(!!(M&&J&&!cs(M))),J||!M||!Ra()){qe(null);return}qe({alternate:M.buffer.active.type==="alternate"})}function Ra(){const M=X.current;return Y.current.length>0||!!M?.hasMore}function Ur(){xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)}function _n(){const M=L.current;M&&(Re.current=!cs(M),ot())}function is(M){$.current=op($.current,M)}function Al(M){const J=$.current;return $.current=null,op(J,M)}function Ir(){const M=$.current;return $.current=null,M}function On(M={}){const J=L.current;if(!J||!ce.current){Ce.current=!0;return}if(ge.current){is(M);return}if(B.current){is(M);return}const je=Al(M);if(!je.force&&!Lu(J,Re.current)){ot();return}B.current=!0;const Fe=D.current,Ie=()=>{if(L.current!==J||D.current!==Fe){B.current=!1;return}if(!je.force&&!Lu(J,Re.current)){B.current=!1,ot();return}const Ge=re.current,Ft=K.current[Ge];if(Ft===void 0){B.current=!1,je.scrollToBottom&&ss(J),ot();const li=Ir();li?On(op(je,li)):Yt();return}J.write(Ft,()=>{if(L.current!==J||D.current!==Fe){B.current=!1;return}re.current=Ge+1,Ie()})};Ie()}function Kr(M){return!cs(M)&&(ns()||B.current||ge.current)}function Qs(M,J){return(_t.current||Fu(J?.currentCommand))&&!cs(M)}function ns(){return re.current<K.current.length}function vn(M,J){Ye.current={output:M,history:J,appendFromLiveOutputIndex:re.current}}function Yt(){const M=L.current,J=Ye.current;if(!M||!J||!cs(M)||ns()||B.current||ge.current)return;const je=Au(J.output),Fe=Au(K.current.slice(J.appendFromLiveOutputIndex));Ye.current=null,ei(_3(je,Fe),J.history),At()}function Ts(){G.current=!0}function it(){_n(),G.current=!1;const M=L.current;M&&cs(M)&&On({scrollToBottom:!0})}function ss(M){ps(()=>a0(M))&&(Re.current=!1)}function Fr(M,J){ps(()=>(M.scrollToLine(J),!0))}function ps(M){Xe.current=!0;try{return M()}finally{Xe.current=!1}}function Ma(){const M=L.current;if(!M)return;const J=()=>{a0(M),Re.current=!1,ot(),On({force:!0,scrollToBottom:!0}),bn()};if(M.buffer.active.type==="alternate"){M.write(wm,J);return}J()}function Pi(M){const J=L.current,je=O.current;if(!J||!je)return;const Fe=je.getBoundingClientRect();if(Fe.height<=0)return;const Ie=Math.max(0,Math.min(1,(M-Fe.top)/Fe.height)),Ge=Math.round(J.buffer.active.baseY*Ie);Ts();try{J.scrollToLine(Ge)}finally{it()}Re.current=!cs(J),ot(),Vi(),Ge<=3&&It()}function Wr(M){M.preventDefault(),M.stopPropagation(),M.currentTarget.setPointerCapture?.(M.pointerId),Pi(M.clientY)}function qr(M){(M.buttons&1)!==0&&(M.preventDefault(),M.stopPropagation(),Pi(M.clientY))}function $r(){const M=L.current,J=U.current;if(!(!M||!J)&&!(document.visibilityState==="hidden"||!Be.current||O.current?.isConnected===!1))try{const je=Lu(M,Re.current),Fe=ks();J.fit(),Fe&&(be.current=Fe),je&&ss(M),M.refresh(0,Math.max(0,M.rows-1)),ot();const Ie={cols:M.cols,rows:M.rows},Ge=ue.current;if(Ge&&Ge.cols===Ie.cols&&Ge.rows===Ie.rows)return;zn({type:"resize",terminalId:e.id,cols:Ie.cols,rows:Ie.rows})&&(ue.current=Ie)}catch{}}function zn(M){const J=I.current;return J?J(M):!1}function rs(M){On({force:!0,scrollToBottom:!0}),zn({type:"input",terminalId:e.id,data:M})&&d3(M)&&Ll()}function Na(M){const J=YS(M,{bracketedPasteMode:L.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&rs(J)}function ms(M,J){const je=YS(M,{bracketedPasteMode:L.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});je&&rs(je),window.setTimeout(()=>rs(iN(J)),g1)}function Ll(){!Ke.current||!De.current||(ts(),ie.current=jN.map(M=>{const J=window.setTimeout(()=>{ie.current=ie.current.filter(je=>je!==J),Ke.current&&De.current&&zn({type:"refresh_cwd",terminalId:e.id})},M);return J}))}function bn(){Le.current||L.current?.focus()}const Ds=v.useCallback(()=>{gt(!1)},[]);function Js(){Ln(M=>{const J=!M;return ye.current=J,J}),bn()}function yn(M){ye.current=M,Ln(M)}function er(M){ye.current&&yn(!1),rs(FM(M)),bn()}return m.jsxs("section",{className:"terminal-pane","data-active":s,onMouseDown:()=>{s||f()},children:[m.jsx(n3,{terminal:e,canClose:o,tabId:h,transcriptSource:Jt,transcriptShortcutLabel:A,onOpenTranscript:()=>gt(!0),onReload:an,onClose:g}),m.jsx("div",{className:"xterm-container",ref:O}),Oi?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,E&&Ci?m.jsxs("div",{className:"terminal-scroll-progress","data-active":zi,"aria-hidden":"true",children:[Ci.current,"/",Ci.total]}):E&&F?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":F.alternate?"alternate":"normal","aria-hidden":"true",children:[F.alternate?"alt ":"","0/?"]}):null,dt?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),onClick:M=>{M.stopPropagation(),Ma()},children:"↓"}):null,pi?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Wr,onPointerMove:qr,children:m.jsx("span",{"aria-hidden":"true"})}):null,s&&e.status==="running"?Dt?m.jsx(IM,{ctrlActive:mn,onCtrl:Js,onStandaloneKey:er,onPreserveFocus:bn,onHide:()=>mi(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:M=>{M.stopPropagation(),bn()},onPointerDown:M=>{M.stopPropagation(),bn()},onClick:()=>mi(!0),children:"⌨"}):null,m.jsx(rN,{terminalId:e.id,onSubmit:ms,queueAvailable:Jt?.provider==="codex"||y1(e.currentCommand),disabled:e.status!=="running"}),Zi&&Jt?m.jsx(s3,{terminalId:e.id,serverApi:t,source:Jt,fontSize:w,onClose:Ds}):null]})}function t0(e){return dE(e)}function e3(e,t,s){const r=t3(e,t),o=i0(r*Math.max(1,s),XN,GN);return{limit:i0(Math.ceil(o/$N),YN,VN),maxLines:o}}function t3(e,t){const s=e?.clientHeight??0;if(s<=0)return WN;const r=Math.max(10,t*qN);return Math.max(1,Math.floor(s/r))}function i0(e,t,s){return Math.max(t,Math.min(s,Math.floor(e)))}function i3(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function n3({terminal:e,canClose:t,tabId:s,transcriptSource:r,transcriptShortcutLabel:o,onOpenTranscript:c,onReload:h,onClose:f}){const g=F0({id:`pane-${e.id}`,disabled:!s,...s?{data:{kind:"pane",sourceTabId:s,terminalId:e.id}}:{}}),p={cursor:s?"grab":"default",opacity:g.isDragging?.5:void 0};return m.jsxs("header",{ref:g.setNodeRef,className:"terminal-pane-header",style:p,"data-dragging":g.isDragging,...g.attributes,...g.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),r?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${oh(r.provider)} transcript history`,"aria-label":`View ${oh(r.provider)} transcript history`,onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),c()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:o})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),h()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),f()},children:"x"}):null]})}const s3=Si.memo(function({terminalId:t,serverApi:s,source:r,fontSize:o,onClose:c}){const h=v.useRef(null),f=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(""),[w,S]=v.useState([]),[E,T]=v.useState(!1),[A,O]=v.useState(""),[L,U]=v.useState(-1),[I,te]=v.useState(null),[ee,ae]=v.useState(!1),[ue,be]=v.useState(!0),[we,ne]=v.useState(!1),[ie,Y]=v.useState(null);v.useEffect(()=>{function ge(G){G.key==="Escape"&&(G.preventDefault(),G.stopPropagation(),c())}return document.addEventListener("keydown",ge,!0),()=>document.removeEventListener("keydown",ge,!0)},[c]),v.useEffect(()=>{f.current+=1;const ge=f.current;return g.current=!1,p.current=!0,y.current=null,S([]),te(null),ae(!1),Y(null),de(null,"initial",ge),()=>{f.current===ge&&(f.current+=1)}},[s,E,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ge=h.current;if(!ge)return;if(p.current){if(ue||w.length===0)return;p.current=!1;const ce=()=>{ge.scrollTop=ge.scrollHeight};ce(),window.requestAnimationFrame?.(ce);return}const G=y.current;G!==null&&(y.current=null,ge.scrollTop+=ge.scrollHeight-G)},[w,ue,E]);const K=oh(r.provider),re=r0(w,E),B=l3(re),$=u3(B,A),D=$.length,X=D>0?L>=0&&L<D?L:0:-1,_e=X>=0?$[X]?.entryIndex??null:null,R=X>=0?$[X]??null:null,H=re?re.split(`
|
|
34
|
+
`).length-1:0,Q=A.trim()?D>0?`${X+1}/${D} ${D===1?"match":"matches"} · ${H} ${H===1?"line":"lines"}`:`0 matches · ${H} ${H===1?"line":"lines"}`:H>0?`${H} lines`:"0 lines";v.useEffect(()=>{const ge=A.trim().toLowerCase();U(G=>!ge||D===0?-1:b.current!==ge?0:G>=0&&G<D?G:0),b.current=ge},[A,D]);async function de(ge,G,ce=f.current){if(!g.current){g.current=!0,G==="initial"?be(!0):(ne(!0),y.current=h.current?.scrollHeight??null),Y(null);try{await ke(ge,G,ce)}catch(Ce){if(f.current!==ce)return;Y(Ce instanceof Error?Ce.message:"Failed to load transcript history.")}finally{f.current===ce&&(g.current=!1,be(!1),ne(!1))}}}async function ke(ge,G,ce){let Ce=ge,ye=0,De=[];const Be=G==="initial"&&r.provider!=="claude"?QN:ZN;for(;f.current===ce;){const Ke=await s.getTerminalTranscriptHistory(t,{...Ce?{cursor:Ce}:{},...e3(h.current,o,G==="initial"?KN:FN),includeTools:E});if(f.current!==ce)return;const le=s0(Ke.output,r.provider,{includeTools:E}),Ee=xe(Ke,G,De,le);if(le&&(De=[le,...De],Ee))return;if(!Ke.hasMore||!Ke.cursor||ye>=Be){De.length>0&&S(Le=>G==="older"?[...De,...Le]:De);return}Ce=Ke.cursor,ye+=1}}function xe(ge,G,ce,Ce=s0(ge.output,r.provider,{includeTools:E})){if(te(ge.cursor),ae(!!(ge.hasMore&&ge.cursor)),!Ce)return!1;const ye=[Ce,...ce];return r0(ye,E)?(S(De=>G==="older"?[...ye,...De]:ye),!0):!1}function Re(){const ge=h.current;!ge||ge.scrollTop>72||!ee||!I||g.current||de(I,"older")}function Xe(ge){D!==0&&U(G=>{const ce=X>=0?X:ge>0?-1:0;return((G>=0&&G<D?G:ce)+ge+D)%D})}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>{ge.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[K," JSONL"]}),m.jsx("span",{title:r.sessionId,children:r.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:E,onChange:ge=>T(ge.currentTarget.checked)}),"Show tool output"]}),m.jsxs("label",{className:"transcript-search",children:[m.jsx("span",{children:"Search"}),m.jsx("input",{type:"search",value:A,"aria-label":"Search JSONL transcript",placeholder:"Find in history",onChange:ge=>O(ge.currentTarget.value),onKeyDown:ge=>{ge.key==="Enter"&&(ge.preventDefault(),Xe(ge.shiftKey?-1:1))}})]}),m.jsxs("div",{className:"transcript-search-actions","aria-label":"Search result navigation",children:[m.jsx("button",{type:"button",onClick:()=>Xe(-1),disabled:D===0,children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>Xe(1),disabled:D===0,children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:Q})]}),m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Re,children:[we?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ue&&ee?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,re?m.jsx(r3,{entries:B,searchQuery:A,activeEntryIndex:_e,activeSearchMatch:R,fontSize:o}):null,ue?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!ue&&!re&&!ie?ee&&I?m.jsxs("div",{className:"transcript-dialog-status",children:[E?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{de(I,"older")},disabled:we,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,ie?m.jsx("div",{className:"transcript-dialog-error",children:ie}):null]})]})})});function r3({entries:e,searchQuery:t,activeEntryIndex:s,activeSearchMatch:r,fontSize:o}){const c=v.useRef(new Map);return v.useEffect(()=>{if(s===null)return;const h=c.current.get(s);if(!h||typeof h.scrollIntoView!="function")return;const f=h.querySelectorAll(".transcript-search-hit");((r?.entryIndex===s?f[r.matchIndexInEntry]:null)??h).scrollIntoView({block:"center",inline:"nearest"})},[s,r,t]),m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:o},children:e.map((h,f)=>m.jsxs("section",{ref:g=>{g?c.current.set(f,g):c.current.delete(f)},className:`transcript-entry transcript-entry-${h.kind}${s===f?" transcript-entry-search-active":""}`,children:[h.header?m.jsx("div",{className:"transcript-entry-header",children:b1(h.header,t)}):null,h.body?m.jsx("div",{className:"transcript-entry-body",children:h.kind==="tool"?m.jsx(n0,{text:h.body,searchQuery:t}):m.jsx(Si.Suspense,{fallback:m.jsx(n0,{text:h.body,searchQuery:t}),children:m.jsx(JN,{text:h.body,searchQuery:t})})}):null]},`${h.header??"plain"}-${f}`))})}function n0({text:e,searchQuery:t}){const s=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1).split(`
|
|
36
|
+
`):e.split(`
|
|
37
|
+
`);return m.jsx("pre",{className:"transcript-entry-pre",children:s.map((r,o)=>m.jsx("span",{className:`transcript-line transcript-line-${h3(r,o===0||s[o-1]?.trim()==="")}`,children:b1(r,t)},o))})}function b1(e,t){const s=t.trim();if(!s)return e||" ";const r=e.toLowerCase(),o=s.toLowerCase(),c=[];let h=0,f=r.indexOf(o);for(;f!==-1;){f>h&&c.push(e.slice(h,f));const g=f+s.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),h=g,f=r.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function a3(e,t){const s=t.trim().toLowerCase();if(!s)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(s);for(;c!==-1;)o+=1,c=r.indexOf(s,c+s.length);return o}function l3(e){const t=e.endsWith(`
|
|
38
|
+
`)?e.slice(0,-1):e;if(!t)return[];const s=[];let r=null,o="plain",c=[];function h(){const f=o3(c).join(`
|
|
39
|
+
`);(r||f)&&s.push({header:r,body:f,kind:o}),r=null,o="plain",c=[]}for(const f of t.split(`
|
|
40
|
+
`)){const g=c3(f);g?(h(),r=f,o=g):c.push(f)}return h(),s}function o3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function c3(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const s=t[1]??"";return s==="User"?"user":s==="Codex"||s==="Claude"?"assistant":s==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(s)?"tool":null}function u3(e,t){const s=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
41
|
+
${o.body}`:o.body,h=a3(c,t);for(let f=0;f<h;f+=1)s.push({entryIndex:r,matchIndexInEntry:f})}return s}function h3(e,t){const s=e.trim();if(!s)return"blank";const r=s.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(s);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)||C1(s))?"tool":/^(?:\$|>|❯|➜)\s+/.test(s)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(s)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(s)?"error":/^\[[^\]]+\]/.test(s)||/^(?:info|debug|warn)\b/i.test(s)?"dim":"plain"}function d3(e){return e.includes("\r")||e.includes(`
|
|
42
|
+
`)}function lp(e){return e instanceof us&&e.status===404}function Fu(e){return y1(e)||f3(e)}function y1(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function f3(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function p3(e){if(Fu(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function oh(e){return e==="codex"?"Codex":"Claude"}function s0(e,t,s={}){const r=`[nterminal] ${oh(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
43
|
+
`).replace(/\r/g,`
|
|
44
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
45
|
+
|
|
46
|
+
`).trimEnd(),c=S1(o),h=s.includeTools?c:w1(c);return h?`${h}
|
|
47
|
+
`:""}function S1(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,s)=>{const r=m3(s);return r?`[${r}]`:t})}function m3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const s=t.getFullYear(),r=Do(t.getMonth()+1),o=Do(t.getDate()),c=Do(t.getHours()),h=Do(t.getMinutes()),f=Do(t.getSeconds());return`${s}-${r}-${o} ${c}:${h}:${f}`}function Do(e){return e.toString().padStart(2,"0")}function r0(e,t){return e.map(s=>t?s:w1(s)).filter(Boolean).map(s=>s.endsWith(`
|
|
48
|
+
`)?s:`${s}
|
|
49
|
+
`).join("")}function w1(e){if(!e)return"";const t=e.split(`
|
|
50
|
+
`),s=[];let r=!1,o=!1,c=!0;for(const h of t){const f=h.trim()==="",g=c?g3(h):null;if(g&&(r=g==="tool",o=!1),C1(h)){o=!0,c=!1;continue}if(o){f?(o=!1,r||s.push(h),c=!0):c=!1;continue}r||s.push(h),c=f}return s.join(`
|
|
51
|
+
`).replace(/\n{3,}/g,`
|
|
52
|
+
|
|
53
|
+
`).trimEnd()}function g3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function C1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function _3(e,t){if(t.length===0)return e;let s=0;const r=Math.min(e.length,t.length);for(let o=r;o>0;o-=1){let c=!0;for(let h=0;h<o;h+=1)if(e[e.length-o+h]!==t[h]){c=!1;break}if(c){s=o;break}}return[...e,...t.slice(s)]}function v3(e){let t=0;for(const s of e){if(!s)continue;const r=s.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Au(e){const t=[];for(const s of e){const r=x1(s);r&&t.push(r)}return t}function x1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,s,r)=>{const o=s.split(";").filter(Boolean).filter(c=>!UN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function op(e,t={}){const s={};return(e?.force||t.force)&&(s.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(s.scrollToBottom=!0),s}function b3(e){const t=e.buffer.active,s=t.baseY+e.rows;return s<=e.rows?null:{current:Math.max(1,Math.min(s,t.viewportY+1)),total:s}}function cs(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Lu(e,t){return!t||cs(e)}function a0(e){return cs(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function y3(e,t,s,r,o,c){const h=f=>{const g=w3(f);g!==0&&(f.cancelable&&f.preventDefault(),f.stopPropagation(),S3(t,g,s,r,o,c))};return e.addEventListener("wheel",h,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",h,{capture:!0})}}function S3(e,t,s,r,o,c){const h=()=>{o();try{e.scrollLines(t)}finally{c()}s(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(wm,h);return}h()}function w3(e){const s=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(s===0)return 0;const r=s<0?Math.floor(s):Math.ceil(s);return Math.max(-30,Math.min(30,r))}function C3(e,t,s,r,o,c,h){let f=null,g=0;const p={passive:!1};function y(S){f=cp(S),g=0}function b(S){const E=cp(S);if(E===null){f=null,g=0;return}if(f===null){f=E;return}const T=E.clientY-f.clientY;if(f=E,S.cancelable&&S.preventDefault(),T===0)return;if(x3(t)&&E3(t,E,-T)){g=0;return}g-=T/s();const A=g<0?Math.ceil(g):Math.floor(g);if(A!==0){g-=A,c();try{t.scrollLines(A)}finally{h()}r(),A<0&&t.buffer.active.viewportY<=3&&o(A)}}function w(S){if(S.touches.length>0){f=cp(S);return}f=null,g=0}return e.addEventListener("touchstart",y,p),e.addEventListener("touchmove",b,p),e.addEventListener("touchend",w),e.addEventListener("touchcancel",w),()=>{e.removeEventListener("touchstart",y,p),e.removeEventListener("touchmove",b,p),e.removeEventListener("touchend",w),e.removeEventListener("touchcancel",w)}}function cp(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function x3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function E3(e,t,s){const r=e.element;return r?(r.dispatchEvent(k3(t,s)),!0):!1}function k3(e,t){const s=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:s};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function Cm({node:e,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:f,dropZoneActive:g=!1,draggingTerminalId:p=null,mobileFocusLeafKey:y=null,path:b=[],totalPanes:w,onSelect:S,onClose:E,onResize:T,onExit:A,onSnapshot:O,onCloseEditor:L,onAuthClose:U}){const I=w??xm(e);if(b.length===0&&y){const ue=Em(e),be=ue.some(we=>we.key===y)?y:ue[0]?.key;if(ue.length>1&&be)return m.jsx("div",{className:"mobile-focused-split",children:ue.map(we=>{const ne=we.key===be;if(we.type==="editor"){const Y=s[we.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:Y?m.jsx(qy,{api:r,editor:Y,canClose:I>1,onClose:()=>L(we.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},we.key)}const ie=t[we.terminalId];return ie?m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:m.jsx(e0,{terminal:ie,serverApi:r,active:ne,visible:c&&ne,canClose:I>1,refreshCwdOnEnter:h&&ne,tabId:f,onSelect:()=>S(we.terminalId),onClose:()=>E(we.terminalId),onExit:Y=>A(we.terminalId,Y),onSnapshot:O,...U?{onAuthClose:U}:{}})},we.key):m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},we.key)})})}if(e.type==="pane"){const ue=t[e.terminalId];if(!ue)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const be=m.jsx(e0,{terminal:ue,serverApi:r,active:e.terminalId===o,visible:c,canClose:I>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:f,onSelect:()=>S(e.terminalId),onClose:()=>E(e.terminalId),onExit:ne=>A(e.terminalId,ne),onSnapshot:O,...U?{onAuthClose:U}:{}});return g&&p!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[be,m.jsx(Bu,{terminalId:e.terminalId,side:"top"}),m.jsx(Bu,{terminalId:e.terminalId,side:"right"}),m.jsx(Bu,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Bu,{terminalId:e.terminalId,side:"left"})]}):be}if(e.type==="editor"){const ue=s[e.editorId];return ue?m.jsx(qy,{api:r,editor:ue,canClose:I>1,onClose:()=>L(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const te=Math.max(.1,Math.min(.9,e.ratio)),ee=1-te,ae=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${te}fr) 1px minmax(0, ${ee}fr)`}:{gridTemplateRows:`minmax(0, ${te}fr) 1px minmax(0, ${ee}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ae,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.first,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:y,path:[...b,0],totalPanes:I,onSelect:S,onClose:E,onResize:T,onExit:A,onSnapshot:O,onCloseEditor:L,...U?{onAuthClose:U}:{}})}),m.jsx(T3,{direction:e.direction,path:b,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.second,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:y,path:[...b,1],totalPanes:I,onSelect:S,onClose:E,onResize:T,onExit:A,onSnapshot:O,onCloseEditor:L,...U?{onAuthClose:U}:{}})})]})}function Bu({terminalId:e,side:t}){const{setNodeRef:s,isOver:r}=Qm({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:s,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function T3({direction:e,path:t,onResize:s}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const f=h.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-f.left)/f.width:(y.clientY-f.top)/f.height;s(t,Math.min(.9,Math.max(.1,b)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function xm(e){return e.type==="pane"||e.type==="editor"?1:xm(e.first)+xm(e.second)}function Em(e){return e.type==="pane"?[{key:D3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:R3(e.editorId),type:"editor",editorId:e.editorId}]:[...Em(e.first),...Em(e.second)]}function D3(e){return`terminal:${e}`}function R3(e){return`editor:${e}`}const Mh="workspace-default",M3="NTerminal";function N3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function A3(e,t){switch(t.type){case"workspace.hydrated":return km(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return L3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return j3(e,t.workspaceId);case"workspace.selected":return E1(e,t.workspaceId);case"workspace.renamed":return B3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return O3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return z3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return k1(e,t.terminal);case"terminal.split":return H3(e,t.terminal,t.direction);case"terminal.updated":return X3(e,t.terminal);case"terminal.exited":return G3(e,t.terminalId,t.exitCode);case"terminal.closed":return R1(e,t.terminalId);case"terminal.detached":return Z3(e,t.terminalId,t.workspaceId);case"editor.split":return P3(e,t.editorId,t.title,t.direction);case"editor.closed":return Q3(e,t.editorId);case"pane.selected":return Y3(e,t.terminalId);case"pane.resized":return V3(e,t.path,t.ratio);case"tab.selected":return I3(e,t.tabId);case"tab.renamed":return $3(e,t.tabId,t.title);case"tab.reordered":return Mg(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return K3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return T1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return D1(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return F3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return U3(e);default:return e}}function L3(e,t){if(e.workspaces.some(r=>r.id===t.id))return E1(e,t.id);const s={id:t.id,title:t.title,defaultCwd:ds(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,s],activeWorkspaceId:s.id}}function E1(e,t){return e.workspaces.some(s=>s.id===t)?{...e,activeWorkspaceId:t}:e}function B3(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===r?h:(o=!0,{...h,title:r}));return o?{...e,workspaces:c}:e}function O3(e,t,s){const r=ds(s);let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===r?h:(o=!0,{...h,defaultCwd:r}));return o?{...e,workspaces:c}:e}function z3(e,t,s,r){if(t===s)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===s);if(o<0||c<0)return e;const h=e.workspaces.slice(),[f]=h.splice(o,1);if(!f)return e;const g=h.findIndex(b=>b.id===s);if(g<0)return e;const p=r==="before"?g:g+1,y=h.slice();return y.splice(p,0,f),q3(e.workspaces,y)?e:{...e,workspaces:y}}function j3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const s=e.workspaces.find(f=>f.id===t),r=new Set(s?ch(s):[]),o={...e.terminals};for(const f of r)delete o[f];const c=e.workspaces.filter(f=>f.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:o}}function k1(e,t){const s=N1(e),r=ka(s)??Ah(),o=z1(t);return{...s,activeWorkspaceId:r.id,terminals:{...s.terminals,[t.id]:t},workspaces:s.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??ds(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:O1(c,t.id))}}function H3(e,t,s){const r=ka(e),o=r?Nh(r):void 0;if(!r||!o)return k1(e,t);const c=o.activeTerminalId,h=ac(o.root,c,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??ds(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:O1(f,t.id))}}function P3(e,t,s,r){const o=ka(e),c=o?Nh(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,f=ac(c.root,h,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:s}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:f,activeTerminalId:h}:p)}:g)}}function U3(e){const t=ka(e),s=t?Nh(t):void 0;return s?R1(e,s.activeTerminalId):e}function I3(e,t){const s=ka(e);return!s||!s.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===s.id?{...r,activeTabId:t}:r)}}function Mg(e,t,s){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const h=o.tabs.slice(),[f]=h.splice(c,1);if(!f)return o;const g=Math.max(0,Math.min(h.length,s)),p=h.slice();return p.splice(g,0,f),W3(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function K3(e,t,s,r,o){if(s===r||!e.terminals[s]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(E=>E.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=wl(y.root,s);if(!b){const E=g.tabs.filter((T,A)=>A!==p);return{...g,tabs:E}}const w={...y,root:b,activeTerminalId:Li(b)[0]??y.activeTerminalId},S=g.tabs.slice();return S[p]=w,{...g,tabs:S}});const h=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(T=>Li(T.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:s},w={type:"split",direction:h,ratio:.5,first:f?b:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:b},S=ac(y.root,r,w),E=g.tabs.slice();return E[p]={...y,root:S,activeTerminalId:s},{...g,tabs:E,activeTabId:y.id}}),N1({...e,workspaces:c})}function T1(e,t,s,r){let o=-1,c=-1;for(let A=0;A<e.workspaces.length;A+=1){const O=e.workspaces[A].tabs.findIndex(L=>L.id===t);if(O>=0){o=A,c=O;break}}if(o<0)return e;const h=e.workspaces[o],f=h.tabs[c],g=Li(f.root);if(!g.includes(s))return e;if(g.length===1)return Mg(e,t,r);const p=wl(f.root,s);if(!p)return e;const y={...f,root:p,activeTerminalId:Li(p)[0]??f.activeTerminalId},b=e.terminals[s],w={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:b?.title??"",activeTerminalId:s,root:{type:"pane",terminalId:s}},S=h.tabs.slice();S[c]=y;const E=Math.max(0,Math.min(S.length,r));S.splice(E,0,w);const T=e.workspaces.slice();return T[o]={...h,tabs:S,activeTabId:w.id},{...e,workspaces:T}}function D1(e,t,s,r=Number.MAX_SAFE_INTEGER){const o=A1(e.workspaces,t),c=e.workspaces.find(p=>p.id===s);if(!o||!c)return e;if(o.workspace.id===s)return r===Number.MAX_SAFE_INTEGER?e:Mg(e,t,r);const h=Li(o.tab.root),f=h.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Ta({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===s){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??ds(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!h.includes(w)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:s}}function F3(e,t,s,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(S=>S.id===r),h=A1(e.workspaces,t);if(!c||!h||!e.terminals[s]||!Li(h.tab.root).includes(s))return e;if(h.workspace.id===r)return T1(e,t,s,o);if(Li(h.tab.root).length===1)return D1(e,t,r,o);const g=wl(h.tab.root,s);if(!g)return e;const p={...h.tab,root:g,activeTerminalId:Li(g)[0]??h.tab.activeTerminalId},y=e.terminals[s],b={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:y.title??s,activeTerminalId:s,root:{type:"pane",terminalId:s}},w=e.workspaces.map(S=>{if(S.id===h.workspace.id)return Ta({...S,tabs:S.tabs.map(E=>E.id===t?p:E)});if(S.id===r){const E=S.tabs.slice(),T=Math.max(0,Math.min(E.length,o));return E.splice(T,0,b),{...S,defaultCwd:S.defaultCwd??ds(y.cwd),detachedTerminalIds:S.detachedTerminalIds.filter(A=>A!==s),tabs:E,activeTabId:b.id}}return S});return{...e,workspaces:w,activeWorkspaceId:r}}function W3(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function q3(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function $3(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>{let f=!1;const g=h.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,f=!0,{...p,title:r}));return f?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function Y3(e,t){const s=e.workspaces.find(o=>o.tabs.some(c=>Cl(c.root,t))),r=s?.tabs.find(o=>Cl(o.root,t));return!s||!r?e:{...e,activeWorkspaceId:s.id,workspaces:e.workspaces.map(o=>o.id===s.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function V3(e,t,s){const r=ka(e),o=r?Nh(r):void 0;if(!r||!o)return e;const c=Am(o.root,t,P1(s));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===r.id?{...h,tabs:h.tabs.map(f=>f.id===o.id?{...f,root:c}:f)}:h)}}function km(e,t,s,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),h=new Set,f=!!(s&&s.some(b=>j1(b))||t&&t.some(b=>H1(b)));let g=J3(t,s,c,h);g.length===0&&(g=[Ah()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??Mh;for(const b of e)if(!h.has(b.id)){if(f)g=iA(g,y,b.id,b);else{const w=z1(b);g=sA(g,y,w,b)}h.add(b.id)}return{workspaces:g.map(b=>Ta(nA(b,o))),activeWorkspaceId:p,terminals:o}}function rc(e){return Li(e.root)}function Tm(e){return Lm(e.root)}function ch(e){return Ng([...e.tabs.flatMap(t=>Li(t.root)),...e.detachedTerminalIds])}function up(e){const t=e.workspaces.map(s=>{const r=s.tabs.flatMap(o=>{const c=Mm(o.root);return c?[{...o,root:c}]:[]});return Ta({...s,tabs:r})});return{activeWorkspaceId:t.some(s=>s.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function X3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(s=>({...s,tabs:s.tabs.map(r=>Cl(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function G3(e,t,s){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:s}}}:e}function R1(e,t){const s={...e.terminals};return delete s[t],M1(e,t,s)}function Z3(e,t,s){if(!e.terminals[t])return e;const r=(s&&e.workspaces.some(c=>c.id===s)?s:null)??eA(e,t)?.id??tA(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Mh,o=e.workspaces.find(c=>c.id===r);return!o||!B1(o,t)?e:M1(e,t,{...e.terminals},{detachToWorkspaceId:r})}function M1(e,t,s,r={}){let o=e.workspaces.map(h=>{const f=[];for(const g of h.tabs){const p=wl(g.root,t);if(!p)continue;const y=Li(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&f.push({...g,root:p,activeTerminalId:b})}return Ta({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&s[t]&&(o=o.map(h=>h.id===r.detachToWorkspaceId?L1(h,t,s[t]):h));const c=o.some(h=>h.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:s}}function Q3(e,t){const s=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const f=Dm(h.root,t);if(!f)continue;const g=Li(f),p=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];p&&c.push({...h,root:f,activeTerminalId:p})}return Ta({...o,tabs:c})}),r=s.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:s,activeWorkspaceId:r?e.activeWorkspaceId:s[0]?.id??null}}function J3(e,t,s,r){if(t&&t.length>0){const o=[];for(const c of t)j1(c)&&o.push(l0(c,s,r));if(o.length>0)return o}return[l0({...Ah(),tabs:e??[]},s,r)]}function l0(e,t,s){const r=[];for(const c of e.tabs){if(!H1(c))continue;const h=Rm(c.root,t);if(!h)continue;const f=Li(h);for(const p of f)s.add(p);const g=f.includes(c.activeTerminalId)?c.activeTerminalId:f[0];g&&r.push({...c,root:h,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||s.has(c)||(s.add(c),o.push(c));return Ta({...e,defaultCwd:ds(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function N1(e){return ka(e)?e:{...e,workspaces:[Ah()],activeWorkspaceId:Mh}}function ka(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Nh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function A1(e,t){for(const s of e){const r=s.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:s,tab:s.tabs[r],tabIndex:r}}return null}function eA(e,t){return e.workspaces.find(s=>s.tabs.some(r=>Cl(r.root,t)))}function tA(e,t){return e.workspaces.find(s=>s.detachedTerminalIds.includes(t))}function iA(e,t,s,r){return e.map(o=>o.id===t?L1(o,s,r):o)}function L1(e,t,s){return B1(e,t)?{...e,defaultCwd:e.defaultCwd??ds(s?.cwd),detachedTerminalIds:Ng([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function B1(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<kl}function O1(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(s=>s!==t)}:e}function nA(e,t){if(e.defaultCwd)return e;const s=ch(e).find(o=>!!t[o]),r=s?ds(t[s]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Ah(){return{id:Mh,title:M3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ta(e){const t=e.tabs.some(s=>s.id===e.activeTabId);return{...e,defaultCwd:ds(e.defaultCwd),detachedTerminalIds:Ng(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function sA(e,t,s,r){const o=Li(s.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??ds(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,s],activeTabId:c.activeTabId??s.id}:c)}function z1(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function ac(e,t,s){return e.type==="pane"?e.terminalId===t?s:e:e.type==="editor"?e:{...e,first:ac(e.first,t,s),second:ac(e.second,t,s)}}function wl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const s=wl(e.first,t),r=wl(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Dm(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const s=Dm(e.first,t),r=Dm(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Rm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const s=Rm(e.first,t),r=Rm(e.second,t);return s&&r?{...e,ratio:P1(e.ratio),first:s,second:r}:s??r}function Mm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Mm(e.first),s=Mm(e.second);return t&&s?{...e,first:t,second:s}:t??s}function j1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function H1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Nm(t.root)}function Nm(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")&&Nm(t.first)&&Nm(t.second):!1}function Am(e,t,s){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===s?e:{...e,ratio:s};const[r,...o]=t;if(r===0){const c=Am(e.first,o,s);return c===e.first?e:{...e,first:c}}if(r===1){const c=Am(e.second,o,s);return c===e.second?e:{...e,second:c}}return e}function P1(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ds(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Ng(e){const t=new Set,s=[];for(const r of e)!r||t.has(r)||(t.add(r),s.push(r));return s}function Cl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Cl(e.first,t)||Cl(e.second,t)}function Li(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Li(e.first),...Li(e.second)]}function Lm(e){return e.type==="pane"||e.type==="editor"?1:Lm(e.first)+Lm(e.second)}const Pr=new Map,lc=new Map,oc=new Map;function Rl(e){return e??"__local__"}function rA(e){return{agentId:e,state:N3(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Mt(e){const t=Rl(e);let s=Pr.get(t);return s||(s=rA(e),Pr.set(t,s)),s}function U1(e,t){const s=Rl(e);let r=lc.get(s);return r||(r=new Set,lc.set(s,r)),r.add(t),()=>{r.delete(t)}}function aA(e){const t=Rl(e),s=lc.get(t);if(s)for(const r of Array.from(s))r()}function Ml(e,t){Pr.set(Rl(e),t),aA(e)}const Bm=new Set;function lA(e){return Bm.add(e),()=>{Bm.delete(e)}}function Ro(e,t){const s=Mt(e),r=Rl(e);t.type==="workspace.hydrated"&&oc.delete(r);const o=A3(s.state,t);let c=s.unreadCompletions,h=null;if(t.type==="terminal.updated"){const p=s.state.terminals[t.terminal.id],y=p?.activity==="busy",b=t.terminal.activity==="busy",w=t.terminal.activity==="idle",S=mA(r);if(t.notifyCompletion===!0&&b&&S.add(t.terminal.id),t.notifyCompletion===!0&&y&&w&&S.has(t.terminal.id)){const E=oA(o,t.terminal.id);E&&(h={terminalId:t.terminal.id,tabId:E.tab.id,commandName:p?.currentCommand??null},(E.workspace.activeTabId!==E.tab.id||E.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id))))}(w||t.terminal.status==="exited")&&S.delete(t.terminal.id)}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=cA(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(w=>w.id===t.workspaceId);p=b?.tabs.find(w=>w.id===b.activeTabId)??null}const y=p?Li(p.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const w of y)b.delete(w);c=b}}const f=o!==s.state,g=c!==s.unreadCompletions;if((f||g)&&Ml(e,{...s,state:o,unreadCompletions:c}),g&&Ag(),h)for(const p of Array.from(Bm))p({agentId:e,...h})}function oA(e,t){for(const s of e.workspaces)for(const r of s.tabs)if(Li(r.root).includes(t))return{workspace:s,tab:r};return null}function cA(e,t){for(const s of e.workspaces){const r=s.tabs.find(o=>o.id===t);if(r)return{workspace:s,tab:r}}return null}const Om=new Set;function uA(e){return Om.add(e),()=>{Om.delete(e)}}function hA(){let e=0;for(const t of Pr.values())e+=t.unreadCompletions.size;return e}function Ag(){for(const e of Array.from(Om))e()}function dA(e,t){const s=Mt(e);if(!s.unreadCompletions.has(t))return;const r=new Set(s.unreadCompletions);r.delete(t),Ml(e,{...s,unreadCompletions:r}),Ag()}function o0(e,t){const s=Mt(e);t!==s.state&&Ml(e,{...s,state:t})}function hp(e,t){const s=Mt(e),r=t(s.editors);r!==s.editors&&Ml(e,{...s,editors:r})}function kr(e,t,s){const r=Mt(e);r.loaded===t&&r.error===s||Ml(e,{...r,loaded:t,error:s})}function Mo(e,t,s){const r=Mt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===s||Ml(e,{...r,layoutRevision:t,lastPersistedLayoutJson:s})}function fA(e){const t=Mt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function pA(e){const t=Rl(e),s=Pr.get(t);s&&s.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(s.mutable.saveCoord.saveTimer);const r=s?s.unreadCompletions.size>0:!1;Pr.delete(t),lc.delete(t),oc.delete(t),r&&Ag()}function dp(){for(const e of Pr.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Pr.clear(),lc.clear(),oc.clear()}function mA(e){let t=oc.get(e);return t||(t=new Set,oc.set(e,t)),t}function zm(e,t){let s=!1,r=!1,o=null,c=!1;for(const h of rc(e)){const f=t[h];if(f){if(f.status==="exited"){c=!0,s=!0;continue}f.activity==="busy"?(r=!0,s=!0,!o&&f.currentCommand&&(o=f.currentCommand)):f.activity==="idle"&&(s=!0)}}return s?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Lg(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function jm(e,t){const s=t[e.activeTerminalId];return e.title||s?.title||e.activeTerminalId}function gA(e,t,s,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${s} pane${s===1?"":"s"}`}function _A({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:f,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:w,onRenameTab:S,activePaneAvailable:E}){const[T,A]=v.useState(null),[O,L]=v.useState(!1),[U,I]=v.useState(null),te=v.useRef(null),ee=e.findIndex(K=>K.id===t),ae=ee>=0?e[ee]:e[0]??null,ue=ae?zm(ae,s):null,be=ae?Tm(ae):0,we=ae?jm(ae,s):"No tab";v.useEffect(()=>{te.current?.focus(),te.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!O)return;const K=re=>{re.key==="Escape"&&L(!1)};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[O]),v.useEffect(()=>{O&&e.length===0&&L(!1)},[O,e.length]);function ne(K,re){A({tabId:K,title:re})}function ie(){if(!T)return;const K=T.title.trim();K&&S(T.tabId,K),A(null)}function Y(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${Pk()}`,onClick:b,disabled:!E,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${Uk()}`,onClick:w,disabled:!E,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:f,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:we,onClick:()=>L(!0),disabled:e.length===0,children:[ue?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ue.state,"aria-hidden":"true",title:Lg(ue)}):null,m.jsx("span",{children:we}),m.jsxs("small",{children:[ee>=0?ee+1:0,"/",e.length||0,be>1?` / ${be}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((K,re)=>{const B=rc(K),$=Tm(K),D=jm(K,s),X=K.id===t,_e=T?.tabId===K.id,R=zm(K,s),H=r?.has(K.id)??!1;return m.jsxs(Si.Fragment,{children:[m.jsx(c0,{index:re}),m.jsx(vA,{tab:K,active:X,editing:_e,title:D,paneCount:$,terminalIds:B,canClose:e.length>1,editValue:_e?T.title:null,editInputRef:_e?te:null,activity:R,unread:H,onSelect:()=>c(K.id),onBeginRename:()=>ne(K.id,D),onCloseAll:()=>g(B),onCommitRename:ie,onCancelRename:()=>A(null),onRenameChange:Q=>A({tabId:K.id,title:Q})})]},K.id)}),m.jsx(c0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(o?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(K=>m.jsx(yA,{terminal:K,onReattach:()=>p?.(K.id),onDelete:()=>I(K)},K.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),E?Y():null]}),O?m.jsx(bA,{tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:T,editInputRef:te,onClose:()=>L(!1),onSelectTab:K=>{c(K),L(!1)},onCreateTab:()=>{h(),L(!1)},onBeginRename:ne,onCloseTerminals:K=>{g(K),L(!1)},onCommitRename:ie,onCancelRename:()=>A(null),onRenameChange:(K,re)=>A({tabId:K,title:re}),onReattachTerminal:K=>{p?.(K),L(!1)},onDeleteTerminal:K=>{I(K),L(!1)}}):null,U?m.jsx(SA,{terminal:U,onCancel:()=>I(null),onConfirm:()=>{y?.(U.id),I(null)}}):null]})}function vA({tab:e,active:t,editing:s,title:r,paneCount:o,canClose:c,editValue:h,editInputRef:f,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:w,onCommitRename:S,onCancelRename:E,onRenameChange:T}){const{attributes:A,listeners:O,setNodeRef:L,transform:U,isDragging:I}=F0({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:s}),te={transform:_p.Translate.toString(U),opacity:I?.4:void 0,zIndex:I?2:void 0};return m.jsxs("div",{ref:L,className:"terminal-tab","data-active":t,"data-dragging":I,"data-unread":p?"true":void 0,style:te,...A,...O,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Lg(g)}):null,s&&f&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:ee=>{ee.preventDefault(),S()},children:[m.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:h,onBlur:S,onChange:ee=>T(ee.target.value),onKeyDown:ee=>{if(ee.key==="Enter"){ee.preventDefault(),S();return}ee.key==="Escape"&&(ee.preventDefault(),E())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:ee=>{ee.preventDefault(),b()},children:[m.jsx("span",{children:r}),m.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!s?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:ee=>ee.stopPropagation(),onClick:ee=>{ee.stopPropagation(),w()},children:"x"}):null]})}function bA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:f,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:w,onCancelRename:S,onRenameChange:E,onReattachTerminal:T,onDeleteTerminal:A}){const O=v.useRef(null);return v.useEffect(()=>{O.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:f,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:L=>L.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:f,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((L,U)=>{const I=rc(L),te=Tm(L),ee=jm(L,s),ae=L.id===t,ue=c?.tabId===L.id,be=zm(L,s),we=r?.has(L.id)??!1;return m.jsxs("div",{ref:ae?O:null,className:"mobile-tab-sheet-row","data-active":ae,"data-unread":we?"true":void 0,children:[ue&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ne=>{ne.preventDefault(),w()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${ee}`,value:c.title,onBlur:w,onChange:ne=>E(L.id,ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),w();return}ne.key==="Escape"&&(ne.preventDefault(),S())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${ee}`,onClick:()=>g(L.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:U+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:ee}),m.jsx("small",{children:gA(L,s,te,be)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[be?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":be.state,"aria-hidden":"true",title:Lg(be)}):null,m.jsx("span",{children:te})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ue?m.jsx("button",{type:"button","aria-label":`Done renaming ${ee}`,onClick:w,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${ee}`,onClick:()=>y(L.id,ee),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${ee}`,onClick:()=>b(I),children:"×"}):null]})]},L.id)}),(o?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(o??[]).map(L=>{const U=L.title||L.cwd||L.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${U}`,onClick:()=>T(L.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:U}),m.jsx("small",{children:L.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${U}`,onClick:()=>A(L),children:"×"})})]},L.id)})]}):null]})]})})}function c0({index:e}){const{setNodeRef:t,isOver:s}=Qm({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":s,"aria-hidden":"true"})}function yA({terminal:e,onReattach:t,onDelete:s}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
54
|
+
${e.cwd}
|
|
55
|
+
(detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:o,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),s()},children:"×"})]})}function SA({terminal:e,onCancel:t,onConfirm:s}){const r=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:r}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:s,children:"Delete"})]})]})})}function wA({uploads:e,onDismiss:t,onDismissAll:s,onRetry:r,onCancel:o}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${TA(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?Wu(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:s,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(CA,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function CA({upload:e,compact:t,onDismiss:s,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Wu(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:Wu(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[f?m.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${Wu(e)}`,onClick:s,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(xA,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(EA,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function xA({toast:e}){const t=e.percent===null?DA(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function EA({response:e,compact:t}){const s=e.results.filter(h=>h.status==="failed"),r=e.results.filter(h=>h.status==="uploaded"),o=t?3:6,c=[...s,...r].slice(0,o);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,f)=>m.jsx(kA,{result:h},`${h.relativePath}-${f}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function kA({result:e}){const t=e.savedRelativePath??e.relativePath,s=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),s?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Wu(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,s=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${s} files`}return"Upload failed"}function TA(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 DA(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function RA({toast:e,onActivate:t,onDismiss:s}){if(!e)return null;const r=e,o=r.commandName?`${r.commandName} finished`:"Command finished";function c(f){f.stopPropagation(),s()}function h(f){f.target===f.currentTarget&&(f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),t(r)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:r.tabTitle}),m.jsx("span",{children:o})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:f=>f.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const MA=Uo(0,0,1,1),Ys=1e-6;function NA(e){return I1(e).map(t=>t.terminalId)}function I1(e){return Po(e,MA).sort(OA).map((t,s)=>({...t,index:s+1}))}function AA(e,t,s){const r=I1(e),o=r.find(h=>h.terminalId===t);return o?r.filter(h=>h.terminalId!==t).map(h=>BA(o,h,s)).filter(h=>h!==null).sort(zA)[0]?.entry.terminalId??null:null}function LA(e,t){return!Number.isInteger(t)||t<1?null:NA(e)[t-1]??null}function Po(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const s=jA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*s;return[...Po(e.first,Uo(t.left,t.top,o,t.bottom)),...Po(e.second,Uo(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*s;return[...Po(e.first,Uo(t.left,t.top,t.right,r)),...Po(e.second,Uo(t.left,r,t.right,t.bottom))]}function BA(e,t,s){const r=e.bounds,o=t.bounds,c=u0(r.left,r.right,o.left,o.right),h=u0(r.top,r.bottom,o.top,o.bottom);switch(s){case"left":return o.centerX>=r.centerX-Ys||h<=Ys?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"right":return o.centerX<=r.centerX+Ys||h<=Ys?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"up":return o.centerY>=r.centerY-Ys||c<=Ys?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Ys||c<=Ys?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function OA(e,t){return ml(e.bounds.top,t.bounds.top)||ml(e.bounds.left,t.bounds.left)}function zA(e,t){return ml(e.primaryDistance,t.primaryDistance)||ml(e.perpendicularDistance,t.perpendicularDistance)||ml(t.overlap,e.overlap)||ml(e.entry.index,t.entry.index)}function ml(e,t){const s=e-t;return Math.abs(s)<=Ys?0:s}function u0(e,t,s,r){return Math.max(0,Math.min(t,r)-Math.max(e,s))}function Uo(e,t,s,r){return{left:e,top:t,right:s,bottom:r,centerX:e+(s-e)/2,centerY:t+(r-t)/2}}function jA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class HA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function h0(e){return e?Array.from(e.types??[]).includes("Files")||q1(e.items).some(s=>s.kind==="file")?!0:$1(e.files).length>0:!1}async function PA(e){const t=q1(e.items).filter(s=>s.kind==="file");return t.length>0?UA(t):IA(e.files)}async function UA(e){const t=[];for(const s of e){const r=qA(s);if(r){await K1(r,"",t);continue}const o=s.getAsFile();if(o){t.push({relativePath:F1(o),file:o});continue}throw new HA("Folder upload is not supported by this browser.")}return t}function IA(e){return $1(e).map(t=>({relativePath:F1(t),file:t}))}async function K1(e,t,s){const r=YA(t,e.name);if(e.isFile){const h=await KA(e);s.push({relativePath:r,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await FA(o);for(const h of c)await K1(h,r,s)}function KA(e){return new Promise((t,s)=>{e.file(t,r=>s(r))})}async function FA(e){const t=[];for(;;){const s=await WA(e);if(s.length===0)return t;t.push(...s)}}function WA(e){return new Promise((t,s)=>{e.readEntries(t,r=>s(r))})}function F1(e){const t=e.webkitRelativePath;return W1(typeof t=="string"&&t?t:e.name)}function qA(e){const t=e.webkitGetAsEntry?.();return $A(t)?t:null}function $A(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 YA(e,t){return W1(e?`${e}/${t}`:t)}function W1(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function q1(e){return e?Array.from(e):[]}function $1(e){return e?Array.from(e):[]}const d0="nterminal.terminalWorkspaces.v2",Y1="nterminal.sidebarCollapsed.v1",VA=75,f0=$0.map(e=>e.url),XA=$0[0].url,GA=6;function ZA({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:h}){const f=v.useMemo(()=>e??fh(),[e]),g=v.useMemo(()=>t??Go(null),[t]),p=v.useMemo(()=>m5(s),[s]),y=v.useMemo(()=>x=>U1(s,x),[s]),b=v.useMemo(()=>()=>Mt(s),[s]),w=v.useSyncExternalStore(y,b,b),S=w.state,E=w.editors,T=!w.loaded,A=w.error,[O,L]=v.useState(!1),[U,I]=v.useState(()=>w5()),[te,ee]=v.useState("servers"),[ae,ue]=v.useState(!1),be=v.useSyncExternalStore(Gk,Uy,Uy);v.useSyncExternalStore(ug,Py,Py);const[we,ne]=v.useState(0),[ie,Y]=v.useState(null),[K,re]=v.useState(()=>[null]),[B,$]=v.useState(0),[D,X]=v.useState(()=>[s]),[_e,R]=v.useState(()=>new Set),[H,Q]=v.useState({}),[de,ke]=v.useState(null),xe=v.useRef(0),Re=v.useRef(0),[Xe,ge]=v.useState(null),[G,ce]=v.useState(null),Ce=v.useRef(null),ye=v.useRef(0),De=v.useRef(null),Be=v.useRef(null),Ke=v.useRef(null),[le,Ee]=v.useState(null),Le=RE(Sy(H0,{activationConstraint:{distance:8}}),Sy(P0,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>Zk(f),[f]);function Oe(x){const k=x.active.data.current;if(k){if(k.kind==="tab"&&typeof k.tabId=="string"&&typeof k.terminalId=="string"){Ee({tabId:k.tabId,terminalId:k.terminalId});return}k.kind==="pane"&&typeof k.sourceTabId=="string"&&typeof k.terminalId=="string"&&Ee({tabId:k.sourceTabId,terminalId:k.terminalId})}}function He(x){Ee(null);const k=x.active.data.current,j=x.over?.data.current;if(!(!k||!j||typeof k.terminalId!="string")){if(k.kind==="tab"&&typeof k.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){it({type:"tab.reordered",sourceTabId:k.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){it({type:"tab.moved_to_workspace",sourceTabId:k.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&it({type:"tab.dropped_into_pane",sourceTabId:k.tabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(k.kind==="pane"&&typeof k.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){it({type:"terminal.extracted_to_tab",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){it({type:"terminal.extracted_to_workspace",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&it({type:"tab.dropped_into_pane",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function _t(){Ee(null)}const Ye=S.workspaces.find(x=>x.id===S.activeWorkspaceId)??S.workspaces[0],rt=Ye?.tabs.find(x=>x.id===Ye.activeTabId)??Ye?.tabs[0],Oi=rt?.activeTerminalId??null,$i=Oi?S.terminals[Oi]:void 0,Ci=d5("(max-width: 760px)"),ri=v.useMemo(()=>rt?uh(rt.root):[],[rt]),zi=Ye&&rt?Io(s,Ye.id,rt.id):null,sn=rt?V1(ri,rt.activeTerminalId,zi?H[zi]:void 0):null,F=Ci&&ri.length>1,qe=v.useMemo(()=>(Ye?.detachedTerminalIds??[]).flatMap(x=>{const k=S.terminals[x];return k?[k]:[]}),[Ye?.detachedTerminalIds,S.terminals]),dt=v.useMemo(()=>{const x=new Set;for(const k of Ye?.tabs??[])rc(k).some(j=>w.unreadCompletions.has(j))&&x.add(k.id);return x},[Ye?.tabs,w.unreadCompletions]),[vt,pi]=v.useState([]),St=v.useRef([]),mn=v.useRef(null),[Ln,Jt]=v.useState(null),[ai,Zi]=v.useState(null),[gt,Tt]=v.useState([]),[Dt,mi]=v.useState(()=>ya()),gi=v.useRef(0),Ut=v.useRef(s),ei=v.useRef(f0),ji=v.useRef(Dt),Lt=v.useRef(()=>{});Lt.current=Wr;const xi=v.useCallback(async()=>{try{const x=await f.listNotificationAssets();Tt(x.assets.filter(k=>k.enabled).map(k=>k.url))}catch{Tt([])}},[f]);v.useEffect(()=>{X(x=>x.some(k=>fn(k,s))?x:[...x,s])},[s]);const It=v.useCallback(x=>{const k=Mt(x),j=Go(x);for(const se of Object.keys(k.state.terminals))Ho(j.createWebSocketUrl(se)),Nu(se);pA(x),X(se=>se.filter(ve=>!fn(ve,x))),R(se=>{const ve=`${$u(x)}:`;let me=!1;const Se=new Set;for(const Pe of se){if(Pe.startsWith(ve)){me=!0;continue}Se.add(Pe)}return me?Se:se}),Q(se=>{const ve=`${$u(x)}:`;let me=!1;const Se={};for(const[Pe,nt]of Object.entries(se)){if(Pe.startsWith(ve)){me=!0;continue}Se[Pe]=nt}return me?Se:se})},[]);v.useEffect(()=>{let x=!1;return f.listAgents().then(k=>{if(!x){const j=k.agents.map(ve=>ve.id),se=[null,...j];s!==null&&!j.includes(s)&&(It(s),r?.(null)),re(se)}}).catch(()=>{}),()=>{x=!0}},[s,f,It,r,B]);const Yi=v.useCallback(x=>{It(x),$(k=>k+1),fn(x,Ut.current)&&r?.(null)},[It,r]);v.useEffect(()=>{re(x=>x.some(k=>fn(k,s))?x:[...x,s])},[s]),v.useEffect(()=>{Ut.current=s},[s]),v.useEffect(()=>{Y(null)},[s]),v.useEffect(()=>{const x=De.current;if(!x)return;if(!fn(x.agentId,s)){De.current=null;return}if(!w.loaded||S.workspaces.length===0)return;De.current=null;const k=x.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];k&&k.id!==S.activeWorkspaceId&&it({type:"workspace.selected",workspaceId:k.id})},[s,w.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const x=Be.current;if(x){if(!fn(x.agentId,s)){Be.current=null;return}w.loaded&&(Be.current=null,S.workspaces.some(k=>k.id===x.workspaceId)&&it({type:"workspace.selected",workspaceId:x.workspaceId}))}},[s,w.loaded,S.workspaces]),v.useEffect(()=>{const x=Ke.current;if(x){if(!fn(x.agentId,s)){Ke.current=null;return}w.loaded&&(Ke.current=null,w.error||gn())}},[s,w.error,w.loaded]),v.useEffect(()=>{xi()},[xi]),v.useEffect(()=>ew(()=>mi(ya())),[]),v.useEffect(()=>{const x=k=>{Lt.current(k)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{ei.current=gt.length>0?gt:f0},[gt]),v.useEffect(()=>{ji.current=Dt},[Dt]),v.useEffect(()=>{if(!w.loaded||!Ye||!rt)return;const x=Io(s,Ye.id,rt.id);R(k=>{if(k.has(x))return k;const j=new Set(k);return j.add(x),j})},[s,w.loaded,Ye?.id,rt?.id]),v.useEffect(()=>()=>{li()},[]),v.useEffect(()=>lA(x=>{const k=Mt(x.agentId).state,j=k.workspaces.flatMap(Se=>Se.tabs).find(Se=>Se.id===x.tabId),se=k.terminals[x.terminalId],ve=j?.title?.trim()||se?.title||x.commandName||"terminal",me=document.visibilityState==="visible"&&fn(x.agentId,Ut.current)&&x.tabId===p5(k);if(me||Mk({tabTitle:ve,commandName:x.commandName,terminalId:x.terminalId}),!me&&document.visibilityState==="visible"&&ji.current.enabled){const Se=gi.current+1;gi.current=Se;const Pe=ei.current;Jt({id:Se,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:ve,commandName:x.commandName,assetSrc:Pe[Math.floor(Math.random()*Pe.length)]??XA})}}),[]),v.useEffect(()=>{if(!Ln||Dt.persistUntilDismissed)return;const x=window.setTimeout(()=>{Jt(k=>k?.id===Ln.id?null:k)},Dt.durationSeconds*1e3);return()=>window.clearTimeout(x)},[Ln,Dt]),v.useEffect(()=>{C5(U),U&&an()},[U]),v.useEffect(()=>{let x=!1;async function k(){if(!Mt(s).loaded){kr(s,!1,null);try{let se=null,ve=null;try{se=g5(p)}catch(nt){if(!(nt instanceof dh))throw nt;ve=nt}const[me,Se]=await Promise.all([g.listTerminals(),g.getTerminalLayout()]),Pe=me.terminals.length>0?me.terminals:[(await g.createTerminal({cols:80,rows:24})).terminal];if(!x){const nt=Se.layout?G1(Se.layout):null;if(!nt&&ve)throw ve;const Vt=nt??se??{},ti=km(Pe,void 0,Vt.savedWorkspaces,Vt.savedActiveWorkspaceId),Aa=up(ti);o0(s,ti),Mo(s,Se.revision,JSON.stringify(Aa)),kr(s,!0,null),!nt&&se&&wt(Aa,{baseRevision:Se.revision})}}catch(se){!x&&!Ts(se)&&kr(s,!0,Tr(se))}}}return k(),()=>{x=!0}},[s,g,we]);function rn(){kr(s,!1,null),ne(x=>x+1)}function an(){xe.current+=1,Re.current+=1,ke(null)}function Qi(x){xe.current+=1,Re.current+=1,ke(k=>k&&{...k,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function gn(){xe.current+=1,Re.current+=1;const x=S.workspaces.length+1,k=Ei();ke({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),k&&Bn(k)}function Hi(x){if(fn(x,s)){gn();return}Ke.current={agentId:x},r?.(x)}function Kt(x){if(U&&!O)return;const k=S.workspaces.find(se=>se.id===x);if(!k)return;xe.current+=1,Re.current+=1;const j=k.defaultCwd??$i?.cwd??"";ke({mode:"edit",workspaceId:x,title:k.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&Bn(j)}function Ei(){return Ye?.defaultCwd??$i?.cwd??""}async function Bn(x){const k=xe.current+1;xe.current=k;const j=x.trim();if(ke(se=>se&&{...se,cwd:x,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const se=await g.createFileRoot({path:j}),ve=await g.listFiles({rootToken:se.rootToken,path:""});if(xe.current!==k)return;ke(me=>me&&{...me,cwd:se.rootPath,browseRoot:{rootToken:se.rootToken,rootPath:se.rootPath},browseEntries:ve.entries.filter(Se=>Se.kind==="directory"),browseStatus:"idle",error:null})}catch(se){if(xe.current!==k)return;ke(ve=>ve&&{...ve,browseStatus:"idle",error:Tr(se)})}}async function ks(){const x=de;if(!x)return;const k=x.title.trim(),j=x.cwd.trim();if(!k||!j){ke({...x,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const se=Re.current+1;Re.current=se,ke({...x,submitStatus:"submitting",error:null});try{const ve=await g.createFileRoot({path:j});if(Re.current!==se)return;if(x.mode==="create"){const me=S.workspaces.length+1;it({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${me}`,title:k,defaultCwd:ve.rootPath})}else x.workspaceId&&(it({type:"workspace.renamed",workspaceId:x.workspaceId,title:k}),it({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:ve.rootPath}));ke(null)}catch(ve){if(Re.current!==se)return;ke(me=>me&&{...me,submitStatus:"idle",error:Tr(ve)})}}function Nl(x){Re.current+=1,ke(x)}function Da(x,k,j){if(x===k)return;const se=S.workspaces.some(me=>me.id===x),ve=S.workspaces.some(me=>me.id===k);!se||!ve||it({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:k,placement:j})}function Qn(x,k){const j=S.workspaces.findIndex(ve=>ve.id===x),se=S.workspaces[j+k];j<0||!se||Da(x,se.id,k<0?"before":"after")}function Jn(x,k){k.pointerType==="mouse"&&k.button!==0||(k.preventDefault(),k.stopPropagation(),Ce.current={sourceId:x,pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,active:!1,targetId:null,placement:"after"},k.currentTarget.setPointerCapture?.(k.pointerId))}function fs(x){const k=Ce.current;if(!k||k.pointerId!==x.pointerId)return;const j=Math.hypot(x.clientX-k.startX,x.clientY-k.startY);if(!k.active){if(j<GA)return;k.active=!0,ge(k.sourceId)}const ve=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),me=ve?.dataset.workspaceId??null;if(!ve||!me||me===k.sourceId||!S.workspaces.some(nt=>nt.id===me)){k.targetId=null,ce(null);return}const Se=ve.getBoundingClientRect(),Pe=x.clientY<Se.top+Se.height/2?"before":"after";k.targetId=me,k.placement=Pe,ce({workspaceId:me,placement:Pe})}function At(x){const k=Ce.current;!k||k.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),Ce.current=null,ge(null),ce(null),k.active&&k.targetId&&Da(k.sourceId,k.targetId,k.placement))}function es(x){const k=Ce.current;k&&k.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),Ce.current=null,ge(null),ce(null)}async function ts(){await Yt(async()=>{const x=Ye?.defaultCwd?{cols:80,rows:24,cwd:Ye.defaultCwd}:{cols:80,rows:24},k=await g.createTerminal(x);it({type:"terminal.created",terminal:k.terminal})})}async function Vi(x){await Yt(async()=>{const k=Oi?{parentTerminalId:Oi,cols:80,rows:24}:Ye?.defaultCwd?{cols:80,rows:24,cwd:Ye.defaultCwd}:{cols:80,rows:24},j=await g.createTerminal(k);it({type:"terminal.split",terminal:j.terminal,direction:x})})}async function ot(x){let k=Oi,j=zi;const se=Ye?.defaultCwd?.trim();if(!k&&!se)throw new Error("No active pane is available.");const ve=await g.readFile(x);if(!k&&se){const Pe=await g.createTerminal({cols:80,rows:24,cwd:se});k=Pe.terminal.id,it({type:"terminal.created",terminal:Pe.terminal})}if(k){it({type:"pane.selected",terminalId:k});const Pe=Mt(s).state,nt=Pe.workspaces.find(ti=>ti.id===Pe.activeWorkspaceId)??Pe.workspaces[0],Vt=nt?.tabs.find(ti=>ti.id===nt.activeTabId)??nt?.tabs[0];j=nt&&Vt?Io(s,nt.id,Vt.id):null}const me=`editor-${Date.now().toString(36)}-${fA(s)}`,Se=S5(ve.path);hp(s,Pe=>({...Pe,[me]:{id:me,title:Se,rootToken:x.rootToken,path:ve.path,read:ve}})),j&&Q(Pe=>({...Pe,[j]:X1(me)})),it({type:"editor.split",editorId:me,title:Se,direction:"vertical"})}function Ra(x){hp(s,k=>{const j={...k};return delete j[x],j}),it({type:"editor.closed",editorId:x})}function Ur(x){_n([x])}function _n(x){const k=[...new Set(x)].filter(se=>S.terminals[se]);if(k.length===0)return;const j=k.length===1?S.terminals[k[0]]?.title||S.terminals[k[0]]?.cwd||k[0]:`${k.length} panes`;Y(null),Zi({terminalIds:k,label:j,workspaceId:Ye?.id??S.activeWorkspaceId??null})}function is(x,k){const j=rs(x,k);if(!j)return!1;const se=x.filter(ve=>!j.detachedTerminalIds.includes(ve));if(j.detachedTerminalIds.length+se.length>kl)return Y(v5(j.detachedTerminalIds.length)),!1;Y(null);for(const ve of x)it(j.id?{type:"terminal.detached",terminalId:ve,workspaceId:j.id}:{type:"terminal.detached",terminalId:ve});return!0}async function Al(x){await Yt(async()=>{for(const k of x)await ns(k),Ho(g.createWebSocketUrl(k)),Nu(k),it({type:"terminal.closed",terminalId:k})})}async function Ir(x){const k=S.workspaces.find(j=>j.id===x);!k||S.workspaces.length<=1||window.confirm(`Delete workspace "${k.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Yt(async()=>{const j=ch(k),se=[];let ve=null;for(const Se of j)try{await ns(Se)}catch(Pe){se.push(Tr(Pe)),Pe instanceof us&&Pe.status===401&&!g.isAgent&&(ve=Pe)}finally{Ho(g.createWebSocketUrl(Se)),Nu(Se)}const me=k.tabs.flatMap(Se=>Hm(Se.root));if(me.length>0){const Se=new Set(me);hp(s,Pe=>{const nt={...Pe};for(const Vt of Se)delete nt[Vt];return nt})}if(it({type:"workspace.closed",workspaceId:x}),ve)throw ve;if(se.length>0)throw new Error(`Workspace was removed, but ${se.length} terminal session${se.length===1?"":"s"} may still be running. ${se[0]}`)})}async function On(x){await Yt(async()=>{await ns(x),Ho(g.createWebSocketUrl(x)),Nu(x),it({type:"terminal.closed",terminalId:x})})}async function Kr(x,k){const j=k.trim();if(!j)return;let se=null;for(const ve of S.workspaces){const me=ve.tabs.find(Se=>Se.id===x);if(me){se=me.activeTerminalId;break}}if(it({type:"tab.renamed",tabId:x,title:j}),!!se)try{const ve=await g.renameTerminal(se,j);ss({type:"terminal.updated",terminal:ve.terminal})}catch(ve){kr(s,!0,Tr(ve))}}function Qs(x){const k=S.terminals[x];k&&it({type:"terminal.created",terminal:k})}async function ns(x){try{await g.closeTerminal(x)}catch(k){if(k instanceof us&&k.status===404)return;throw k}}async function vn(){await Yt(async()=>{await c()})}async function Yt(x){kr(s,!0,null);try{await x()}catch(k){if(Ts(k))return;kr(s,!0,Tr(k))}}function Ts(x){return x instanceof us&&x.status===401&&!g.isAgent&&h?(h({source:"workspace-api-401",status:401,activeAgentId:s}),!0):!1}function it(x){Ro(s,x);const k=Mt(s),j=k.state;if(!k.loaded||j.workspaces.length===0)return;const se=up(j);JSON.stringify(se)!==k.lastPersistedLayoutJson&&Ft(se)}function ss(x){Ro(s,x)}function Fr(x,k,j,se){const ve=Io(x,k,j);Q(me=>({...me,[ve]:se}))}function ps(x){zi&&Q(k=>({...k,[zi]:x}))}function Ma(x,k){const j=hh(x);k?Fr(s,k.workspaceId,k.tabId,j):ps(j),it({type:"pane.selected",terminalId:x})}function Pi(x){ps(x.key),x.type==="terminal"&&it({type:"pane.selected",terminalId:x.terminalId})}function Wr(x){if(ae||ai||x.isComposing||x.key==="Process"||n5(x.target))return;const k=JA(x);if(!k)return;if(x.preventDefault(),x.stopPropagation(),k.type==="server.previous"||k.type==="server.next"){$r(k.type==="server.next"?1:-1);return}const j=Mt(s).state,se=j.workspaces.find(Se=>Se.id===j.activeWorkspaceId)??j.workspaces[0],ve=se?.tabs.find(Se=>Se.id===se.activeTabId)??se?.tabs[0];if(k.type==="split"){if(!ve)return;Vi(k.direction);return}if(!se||!ve)return;if(k.type==="tab.previous"||k.type==="tab.next"){const Se=i5(se.tabs,ve.id,k.type==="tab.next"?1:-1);Se&&it({type:"tab.selected",tabId:Se.id});return}if(k.type==="tab.index"){const Se=se.tabs[k.index-1];Se&&it({type:"tab.selected",tabId:Se.id});return}const me=e5(ve.root,ve.activeTerminalId,k);me&&Ma(me,{workspaceId:se.id,tabId:ve.id})}function qr(x,k){if(!r||K.length===0)return;const j=K.findIndex(Se=>fn(Se,s)),ve=((j===-1?0:j)+x+K.length)%K.length,me=K[ve]??null;fn(me,s)||(k&&(De.current={agentId:me,edge:k}),r(me))}function $r(x){const k=Mt(s).state,j=k.workspaces;if(j.length===0){qr(x,x===1?"first":"last");return}const se=j.findIndex(Se=>Se.id===k.activeWorkspaceId),me=(se===-1?0:se)+x;if(me>=0&&me<j.length){it({type:"workspace.selected",workspaceId:j[me].id});return}qr(x,x===1?"first":"last")}function zn(x,k){if(fn(x,s)){it({type:"workspace.selected",workspaceId:k});return}Be.current={agentId:x,workspaceId:k},r?.(x)}function rs(x,k){if(k)return S.workspaces.find(j=>j.id===k)??null;for(const j of x){const se=S.workspaces.find(me=>me.tabs.some(Se=>rc(Se).includes(j)));if(se)return se;const ve=S.workspaces.find(me=>me.detachedTerminalIds.includes(j));if(ve)return ve}return S.workspaces.find(j=>j.id===S.activeWorkspaceId)??S.workspaces[0]??null}function Na(x){h0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function ms(x){if(!h0(x.dataTransfer))return;x.preventDefault();const k=b5(Mt(s).state),j=ye.current+1;if(ye.current=j,!k){Js({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Js({id:j,status:"queued",fileCount:0,terminalId:k.id,message:"Preparing upload..."}),Ll(j,k.id,x.dataTransfer)}async function Ll(x,k,j){try{const se=await PA(j);if(se.length===0)throw new Error("No files were found in the drop.");yn(x,{id:x,status:"queued",fileCount:se.length,message:"Queued"},{terminalId:k,files:se})}catch(se){yn(x,{id:x,status:"failed",fileCount:0,message:Tr(se)},{terminalId:k})}finally{Ds()}}async function bn(x){const k=St.current.find(me=>me.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=k.terminalId,se=k.files,ve=new AbortController;mn.current=x,yn(x,{id:x,status:"uploading",fileCount:se.length,loaded:0,total:null,percent:null},{terminalId:j,files:se,abortController:ve});try{const me=await hT({terminalId:j,files:se,signal:ve.signal,onProgress:Vt=>{yn(x,{id:x,status:"uploading",fileCount:se.length,loaded:Vt.loaded,total:Vt.total,percent:Vt.percent},{terminalId:j,files:se,abortController:ve})}}),Se=me.failed>0?me.uploaded>0?"partial":"failed":"success",Pe=me.failed>0?y5(me):void 0,nt={id:x,status:Se,fileCount:se.length,response:me};Pe&&(nt.message=Pe),yn(x,nt,{terminalId:j,files:se})}catch(me){yn(x,{id:x,status:"failed",fileCount:se.length,message:ve.signal.aborted?"Upload canceled.":Tr(me)},{terminalId:j,files:se})}finally{mn.current===x&&(mn.current=null),Ds()}}function Ds(){if(mn.current!==null)return;const x=St.current.find(k=>k.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&bn(x.id)}function Js(x){er(k=>[...k,x])}function yn(x,k,j={}){er(se=>se.map(ve=>{if(ve.id!==x)return ve;const me={...k},Se=j.terminalId??ve.terminalId,Pe=j.files??ve.files;return Se!==void 0&&(me.terminalId=Se),Pe!==void 0&&(me.files=Pe),j.abortController!==void 0&&(me.abortController=j.abortController),me}))}function er(x){const k=x(St.current);St.current=k,pi(k)}function M(x){St.current.find(j=>j.id===x)?.abortController?.abort(),mn.current===x&&(mn.current=null),er(j=>j.filter(se=>se.id!==x)),Ds()}function J(){for(const x of St.current)x.abortController?.abort();mn.current=null,er(()=>[])}function je(x){const k=St.current.find(j=>j.id===x);if(k){if(k.status==="queued"){M(x);return}k.abortController?.abort()}}function Fe(x){const k=St.current.find(se=>se.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=Ie(k);if(j.length===0){yn(x,{id:x,status:"failed",fileCount:k.fileCount,message:"No failed files are available to retry."},{terminalId:k.terminalId,files:k.files});return}yn(x,{id:x,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:k.terminalId,files:j}),Ds()}function Ie(x){const k=x.files??[],j="response"in x?x.response:void 0;if(!j)return k;const se=j.results.filter(Se=>Se.status==="failed").map(Se=>Se.relativePath);if(se.length===0)return[];const ve=new Map;for(const Se of k){const Pe=ve.get(Se.relativePath)??[];Pe.push(Se),ve.set(Se.relativePath,Pe)}const me=[];for(const Se of se){const nt=ve.get(Se)?.shift();nt&&me.push(nt)}return me}function Ge(x){const j=Mt(x.agentId).state.workspaces.find(se=>se.tabs.some(ve=>ve.id===x.tabId));j&&Fr(x.agentId,j.id,x.tabId,hh(x.terminalId)),Ro(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),dA(x.agentId,x.terminalId),fn(x.agentId,s)||r?.(x.agentId),Jt(null)}function Ft(x){const k=Mt(s).mutable.saveCoord;k.pendingLayoutSave=x,No(x,p),k.saveTimer!==null&&window.clearTimeout(k.saveTimer),k.saveTimer=window.setTimeout(()=>{k.saveTimer=null;const j=k.pendingLayoutSave;k.pendingLayoutSave=null,j&&wt(j)},VA)}function li(){const x=Mt(s).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const k=x.pendingLayoutSave;x.pendingLayoutSave=null,k&&(No(k,p),wt(k))}function wt(x,k={}){const j=Mt(s).mutable.saveCoord;j.nextPersistLayout=x,k.baseRevision!==void 0&&(j.queuedBaseRevision=k.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const se=j.nextPersistLayout,ve=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,se&&await Bt(se,ve!==void 0?{baseRevision:ve}:{})}))}async function Bt(x,k={}){const j=Mt(s),se=k.baseRevision??j.layoutRevision,ve={layout:x,...typeof se=="number"?{baseRevision:se}:{}};try{const me=await g.saveTerminalLayout(ve),Se=me.layout??x;Mo(s,me.revision,JSON.stringify(Se)),No(Se,p);return}catch(me){if(me instanceof us&&me.status===400&&me.message===z2){_5(s,p),kr(s,!0,Z1());return}if(me instanceof us&&me.status===409)try{const Se=await g.getTerminalLayout(),Pe=Mt(s).mutable.saveCoord;if(Pe.nextPersistLayout||Pe.pendingLayoutSave){const nt=Se.layout?JSON.stringify(Se.layout):Mt(s).lastPersistedLayoutJson;Mo(s,Se.revision,nt);return}if(Se.layout){const nt=Mt(s).state,Vt=km(Object.values(nt.terminals),void 0,Se.layout.workspaces,Se.layout.activeWorkspaceId),ti=up(Vt);o0(s,Vt),Mo(s,Se.revision,JSON.stringify(ti)),No(ti,p)}else Mo(s,Se.revision,j.lastPersistedLayoutJson);return}catch{}No(x,p)}}const Ui=x5(o),Wt=!U||O,Sn=Wt?te:"servers";function jn(x){const k=x.active?w:Mt(x.agentId),j=x.active?S:k.state,se=x.active?w.loaded:k.loaded,ve=x.active?A:k.error;return m.jsxs("div",{className:`workspace-list-panel${x.active?" workspace-list-panel--active-server":""}`,"aria-label":`${x.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${x.label}`,title:"New workspace",onClick:()=>Hi(x.agentId),children:"+"})]}),se?ve?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(x.agentId),children:ve}):m.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(me=>{const Se=x.active&&me.id===Ye?.id,Pe=ch(me).length,nt=x.active&&j.workspaces.length>1,Vt=G?.workspaceId===me.id&&Xe!==me.id?G.placement:null;return m.jsxs(o5,{workspaceId:me.id,active:Se,disabled:!x.active,reorderable:nt,dragging:Xe===me.id,dropPlacement:Vt,children:[nt?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":me.id,title:"Drag to reorder","aria-label":`Reorder ${me.title}`,"aria-grabbed":Xe===me.id,onPointerDown:ti=>Jn(me.id,ti),onPointerMove:fs,onPointerUp:At,onPointerCancel:es,onKeyDown:ti=>{(ti.key==="ArrowUp"||ti.key==="ArrowDown")&&(ti.preventDefault(),ti.stopPropagation(),Qn(me.id,ti.key==="ArrowUp"?-1:1))},onClick:ti=>ti.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Se?"page":void 0,title:me.defaultCwd??void 0,onClick:()=>zn(x.agentId,me.id),onDoubleClick:()=>{x.active&&Kt(me.id)},children:[m.jsx("span",{className:"workspace-list-name",children:me.title}),m.jsxs("small",{children:[me.defaultCwd??"No folder"," · ",Pe," ",Pe===1?"session":"sessions"]})]}),x.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${me.title}`,title:"Edit workspace",onClick:()=>Kt(me.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${me.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{Ir(me.id)},children:"x"})]}):null]},me.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(R2,{sensors:Le,onDragStart:Oe,onDragEnd:He,onDragCancel:_t,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":U,"data-sidebar-open":O,onDragOver:Na,onDrop:ms,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>L(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[Wt?m.jsx(C0,{height:20}):m.jsx(w0,{size:24}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":U?"Expand sidebar":"Collapse sidebar",title:U?"Expand sidebar":"Collapse sidebar",onClick:()=>I(x=>!x),children:U?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>L(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Sn==="files"?"files":"servers"}`,children:[Wt?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":te==="servers",onClick:()=>{ee("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":te==="files",onClick:()=>{ee("files")},children:"Files"})]}):null,Sn==="servers"&&Wt?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(Oy,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:B,renderServerChildren:jn})}):null,Wt?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(Oy,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:B,compact:!0})}),Sn==="files"?m.jsx(gT,{api:g,activeTerminalId:Oi,activeTerminalCwd:$i?.cwd??null,workspaceRootPath:Ye?.defaultCwd??$i?.cwd??null,onOpenFile:ot}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[Wt?m.jsx("span",{children:Ui}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ue(!0),children:[m.jsx(m0,{name:"settings"}),be.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Wt?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{vn()},children:m.jsx(m0,{name:"logout"})}):null]})]})]}),ae?m.jsx(aT,{api:f,onClose:()=>ue(!1),updateAvailable:be.hasUpdates,onNotificationAssetsChanged:()=>{xi()},onAgentRemoved:Yi}):null,de?m.jsx(s5,{dialog:de,activePaneCwd:$i?.cwd??null,activeWorkspaceCwd:Ye?.defaultCwd??null,onChange:Nl,onManualCwdChange:Qi,onBrowse:Bn,onCancel:an,onSubmit:()=>{ks()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":F?"true":void 0,children:[m.jsx(_A,{tabs:Ye?.tabs??[],activeTabId:Ye?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:dt,detachedTerminals:qe,onSelectTab:x=>it({type:"tab.selected",tabId:x}),onCreateTab:()=>{ts()},onToggleWorkspaces:()=>L(x=>!x),onCloseTerminals:x=>_n(x),onReattachTerminal:x=>Qs(x),onDeleteTerminal:x=>{On(x)},onSplitVertical:()=>{Vi("vertical")},onSplitHorizontal:()=>{Vi("horizontal")},onRenameTab:(x,k)=>{Kr(x,k)},activePaneAvailable:!!Oi}),F?m.jsx(u5,{targets:ri,activeLeafKey:sn,terminals:S.terminals,editors:E,onSelect:Pi}):null,A?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:A}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:rn,children:"Retry"}),s!==null&&r?m.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":T,children:[T?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!T&&!rt?m.jsx(l5,{onCreate:()=>{ts()}}):null,D.map(x=>{const k=fn(x,s);return m.jsx(QA,{agentId:x,active:k,activeServerApi:k?g:void 0,visitedTabKeys:_e,refreshCwdOnEnter:k&&Sn==="files",draggingTab:k?le:null,mobileSplitFocus:Ci,mobileFocusedLeafByTabKey:H,onSelect:j=>{k&&Ma(j)},onClose:j=>{k&&Ur(j)},onCloseEditor:j=>{k&&Ra(j)},onResize:(j,se)=>{k&&it({type:"pane.resized",path:j,ratio:se})},onExit:(j,se)=>{k?ss({type:"terminal.exited",terminalId:j,exitCode:se}):Ro(x,{type:"terminal.exited",terminalId:j,exitCode:se})},onSnapshot:(j,se)=>{const ve={type:"terminal.updated",terminal:j,notifyCompletion:se?.notifyCompletion===!0};k?ss(ve):Ro(x,ve)},...x===null&&h?{onAuthClose:j=>h({...j,source:j?.source??"terminal-ws-1008",activeAgentId:x})}:{}},$u(x))})]}),ai?m.jsx(c5,{label:ai.label,count:ai.terminalIds.length,warning:ie,onCancel:()=>{Y(null),Zi(null)},onHide:()=>{is(ai.terminalIds,ai.workspaceId)&&Zi(null)},onDelete:()=>{const x=ai.terminalIds;Y(null),Zi(null),Al(x)}}):null,m.jsx(RA,{toast:Ln,onActivate:Ge,onDismiss:()=>Jt(null)}),m.jsx(wA,{uploads:vt,onDismiss:M,onDismissAll:J,onRetry:Fe,onCancel:je})]})]})})}function QA({agentId:e,active:t,activeServerApi:s,visitedTabKeys:r,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:f,onSelect:g,onClose:p,onCloseEditor:y,onResize:b,onExit:w,onSnapshot:S,onAuthClose:E}){const T=v.useMemo(()=>be=>U1(e,be),[e]),A=v.useMemo(()=>()=>Mt(e),[e]),O=v.useSyncExternalStore(T,A,A),L=v.useMemo(()=>Go(e),[e]),U=s??L,I=O.state,te=I.workspaces.find(be=>be.id===I.activeWorkspaceId)??I.workspaces[0],ee=te?.id??null,ue=(te?.tabs.find(be=>be.id===te.activeTabId)??te?.tabs[0])?.id??null;return!O.loaded||I.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:I.workspaces.flatMap(be=>be.tabs.map(we=>{const ne=t&&be.id===ee&&we.id===ue,ie=Io(e,be.id,we.id),Y=uh(we.root),K=h&&Y.length>1?V1(Y,we.activeTerminalId,f[ie]):null;return!ne&&!r.has(ie)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":ne,"aria-hidden":!ne,children:m.jsx(Cm,{node:we.root,terminals:I.terminals,editors:O.editors,api:U,activeTerminalId:we.activeTerminalId,visible:ne,refreshCwdOnEnter:ne&&o,tabId:we.id,dropZoneActive:ne&&c!==null,draggingTerminalId:ne?c?.terminalId??null:null,mobileFocusLeafKey:K,onSelect:g,onClose:p,onCloseEditor:y,onResize:b,onExit:w,onSnapshot:S,...E?{onAuthClose:E}:{}})},`${be.id}:${we.id}`)}))})}function JA(e){const t=ow(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const s=t5(e.key);return s?{type:"pane.direction",direction:s}:null}return null}function e5(e,t,s){switch(s.type){case"pane.direction":return AA(e,t,s.direction);case"pane.index":return LA(e,s.index);default:return null}}function t5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function i5(e,t,s){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+s+e.length)%e.length]??null}function uh(e){return e.type==="pane"?[{key:hh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:X1(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...uh(e.first),...uh(e.second)]}function Hm(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Hm(e.first),...Hm(e.second)]}function V1(e,t,s){if(s&&e.some(o=>o.key===s))return s;const r=t?hh(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function hh(e){return`terminal:${e}`}function X1(e){return`editor:${e}`}function n5(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 s5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:s,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(S=>S.kind==="directory"),y=e.submitStatus==="submitting";function b(S){r(E=>E&&{...E,...S})}function w(S){S&&(b({cwd:S,error:null}),c(S))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:S=>S.stopPropagation(),onSubmit:S=>{S.preventDefault(),y||f()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:S=>b({title:S.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:y,onChange:S=>o(S.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>w(t),disabled:y||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>w(s),disabled:y||!s,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(a5(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(S=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${S.name}`,disabled:y,onClick:()=>{c(r5(g,S.path))},children:[m.jsx("span",{children:S.name}),m.jsx("small",{children:S.path})]},S.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function r5(e,t){return t?t.startsWith("/")?qu(t):qu(`${e||"/"}/${t}`):qu(e)}function a5(e){const t=qu(e);if(!t||t==="/")return"/";const s=t.lastIndexOf("/");return s<=0?"/":t.slice(0,s)}function qu(e){const t=e.trim();if(!t)return"";const s=t.replace(/\/+/g,"/");return s==="/"?"/":s.endsWith("/")?s.slice(0,-1):s}function l5({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function o5({workspaceId:e,active:t,disabled:s=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:f,isOver:g}=Qm({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:s}),p=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:f,className:p,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function c5({label:e,count:t,warning:s,onCancel:r,onHide:o,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),s?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:s}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function u5({targets:e,activeLeafKey:t,terminals:s,editors:r,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],y=p0(p,s,r);function b(w){const S=(g+w+e.length)%e.length,E=e[S];E&&o(E)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,S)=>{const E=p0(w,s,r),T=h5(w,s,r),A=w.key===p.key;return m.jsxs("button",{type:"button","data-active":A,onClick:()=>{o(w),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:S+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:E}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function p0(e,t,s){if(e.type==="editor")return s[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function h5(e,t,s){if(e.type==="editor"){const c=s[e.editorId];return c?.path?`editor | ${c.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 d5(e){const[t,s]=v.useState(()=>f5(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){s(!1);return}const r=window.matchMedia(e),o=()=>s(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 f5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function fn(e,t){return e===t}function p5(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function $u(e){return e??"__local__"}function Io(e,t,s){return`${$u(e)}:${t}:${s}`}class dh extends Error{constructor(){super(Z1())}}function m5(e){return e?{workspaceKey:`${d0}:${e}`}:{workspaceKey:d0}}function g5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const s=JSON.parse(t);if(q0(s))throw new dh;const r=W0(s);return r?G1(r):null}catch(s){if(s instanceof dh)throw s;return null}}function G1(e){if(q0(e))throw new dh;const t=W0(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function No(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function _5(e,t){const s=Mt(e).lastPersistedLayoutJson;if(s){localStorage.setItem(t.workspaceKey,s);return}localStorage.removeItem(t.workspaceKey)}function v5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${kl}. Re-open or delete hidden sessions before hiding more.`}function Z1(){return`A saved terminal layout has more than ${kl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function b5(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],s=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=s?e.terminals[s.activeTerminalId]:void 0;return r?.status==="running"?r:null}function y5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function S5(e){return e.split("/").filter(Boolean).pop()??e}function w5(){try{return localStorage.getItem(Y1)==="true"}catch{return!1}}function C5(e){try{localStorage.setItem(Y1,e?"true":"false")}catch{}}function x5(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const s=t-Date.now();if(s<=0)return"session · expired";const r=Math.max(1,Math.floor(s/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function m0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function Tr(e){return e instanceof Error?e.message:"Request failed"}function E5({api:e,onDone:t}){const[s,r]=v.useState(null),[o,c]=v.useState(null),[h,f]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[w,S]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(A=>{T||(r(A.qrDataUrl),c(A.secret))}).catch(A=>{T||S(A instanceof Error?A.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function E(T){if(T.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(A){b(A instanceof Error?A.message:"Verification failed")}finally{p(!1)}}}return w?m.jsx("p",{className:"form-error",children:w}):!s||!o?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:s,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:o})]}),m.jsxs("form",{className:"auth-form",onSubmit:E,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>f(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?m.jsx("p",{className:"form-error",children:y}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}function k5(e){return{source:fp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:fp(e.terminalId)}:{},...e?.detail?{detail:fp(e.detail)}:{}}}function T5(e){return{invalidationSource:e.source}}function D5(e){Nn("auth.session_invalid.request",Q1(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),bh("session-invalid-request").catch(()=>{}))}function R5(e,t){Nn("auth.session_invalid.result",{...Q1(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),bh("session-invalid-result").catch(()=>{}))}function Q1(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 fp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function M5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r}){const o=v.useMemo(()=>e??fh(),[e]),c=v.useMemo(()=>t??Go(null),[t]),[h,f]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let O=!1;return o.getSession().then(L=>{O||(f(L),p(null))}).catch(L=>{O||(p(ba(L)),f(null))}),()=>{O=!0}},[o]);const w=B5(h);v.useEffect(()=>{const O=b.current;Nn("auth.view",{view:w,previousView:O,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),O==="workspace"&&w!=="workspace"&&bh(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[h,w]);async function S(){const O=await o.getSession();f(O),p(null)}async function E(){rp(),dp(),$S(),p(null),f(null);try{await S()}catch(O){p(ba(O))}}function T(O){const L=k5(O);if(D5(L),y.current)return y.current;const U=(async()=>{p(null);try{const I=await o.getSession(T5(L));if(R5(L,I.authenticated),f(I),I.authenticated){EN();return}rp(),dp(),$S()}catch(I){p(ba(I))}finally{y.current=null}})();return y.current=U,U}if(w==="workspace")return m.jsx(ZA,{api:o,serverApi:c,activeAgentId:s,onSelectServer:r,sessionExpiresAt:h?.expiresAt??null,onSessionInvalid:O=>{T(O)},onLogout:async()=>{rp(),dp();const O=await o.logout();f(O)}});const A={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(w0,{size:26}),m.jsxs("div",{children:[m.jsx(C0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:A[w]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,w==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{E()},children:"Retry"}):null,w==="setup_password"?m.jsx(N5,{api:o,onSession:O=>{f(O)}}):null,w==="setup_totp"?m.jsx(E5,{api:o,onDone:()=>{S()}}):null,w==="login"?m.jsx(A5,{api:o,session:h,onSession:f,onRefresh:S}):null,w==="reauth"?m.jsx(L5,{api:o,session:h,onSession:f,onFullLogin:()=>f(O=>O&&{...O,deviceTrusted:!1})}):null]})]})}function N5({api:e,onSession:t}){const[s,r]=v.useState(""),[o,c]=v.useState(""),[h,f]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),f(!0),p(null);try{if(s!==o){p("Passwords do not match");return}t(await e.setupPassword({password:s}))}catch(w){p(ba(w))}finally{f(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:y,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:s,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||s.length<8||o.length<8,children:"Set password"})]})}function A5({api:e,session:t,onSession:s,onRefresh:r}){const[o,c]=v.useState(""),[h,f]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[w,S]=v.useState(null),E=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function A(O){O.preventDefault(),b(!0),S(null);try{s(await e.login({password:o,...E?{otp:h}:{},rememberNetwork:g}))}catch(L){S(ba(L))}finally{b(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:A,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:O=>c(O.currentTarget.value),required:!0})]}),E?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:O=>f(O.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:O=>p(O.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?m.jsx("p",{className:"form-error",children:w}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:y||o.length===0||E&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function L5({api:e,session:t,onSession:s,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[f,g]=v.useState(!1),[p,y]=v.useState(!1),[b,w]=v.useState(!1),[S,E]=v.useState(!1),[T,A]=v.useState(null),O=Si.useCallback(async(U,I)=>{y(!0),A(null);try{s(await e.reauth({...U?{otp:U}:{},rememberNetwork:I}))}catch(te){A(ba(te))}finally{y(!1)}},[e,s]);v.useEffect(()=>{if(o){let U=!1;w(!0),E(!1),A(null);const I=window.setTimeout(()=>{U||E(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(te=>{U||s(te)}).catch(te=>{U||(A(ba(te)),E(!0))}).finally(()=>{window.clearTimeout(I),U||w(!1)}),()=>{U=!0,window.clearTimeout(I)}}},[e,o,s]);async function L(U){U.preventDefault(),await O(c,f)}return o&&b&&!S&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:L,children:[o&&S&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:U=>h(U.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:f,onChange:U=>g(U.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?m.jsx("p",{className:"form-error",children:T}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function B5(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ba(e){return e instanceof Error?e.message:"Request failed"}const g0="NTerminal",Pm="nterminal.activeAgentId";function O5(){const[e,t]=v.useState(()=>z5()),s=v.useMemo(()=>fh(),[]),r=v.useMemo(()=>Go(e),[e]);v.useEffect(()=>{const c=()=>{const h=hA();document.title=h>0?`(${h}) ${g0}`:g0};return c(),uA(c)},[]);function o(c){j5(c),t(c)}return m.jsx(M5,{api:s,activeAgentId:e,serverApi:r,onSelectServer:o})}function z5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Pm);return e&&e.trim()?e:null}catch{return null}}function j5(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Pm,e);return}window.localStorage.removeItem(Pm)}catch{}}const _0=["gesturestart","gesturechange","gestureend"],H5=[".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 P5(e=window){if(!I5(e))return()=>{};const t={passive:!1},s=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!U5(c.target))&&r(c)}for(const c of _0)s.addEventListener(c,r,t);return s.addEventListener("touchmove",o,t),s.addEventListener("dblclick",r,t),()=>{for(const c of _0)s.removeEventListener(c,r,t);s.removeEventListener("touchmove",o,t),s.removeEventListener("dblclick",r,t)}}function U5(e){return e instanceof Element&&e.closest(H5)!==null}function I5(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}lk();$M();P5();Wm();cE.createRoot(document.getElementById("root")).render(m.jsx(Si.StrictMode,{children:m.jsx(O5,{})}));export{Si as R,eE as g,m as j};
|