nterminal 1.2.70 → 1.2.71
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-Cvaxdco_.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BCX4YRz8.js → TranscriptMarkdownBody-BVLvv1bb.js} +1 -1
- package/dist/client/assets/{index-Dd5r0ChL.js → index-BnpZco89.js} +1 -1
- package/dist/client/assets/index-Cz0ghFhb.js +55 -0
- package/dist/client/index.html +1 -1
- package/dist/client/sw.js +36 -3
- package/dist/server/notifications/completionNotificationRouter.js +11 -1
- package/dist/server/notifications/completionNotificationRouter.js.map +1 -1
- package/dist/server/notifications/pushNotificationService.d.ts +2 -0
- package/dist/server/notifications/pushNotificationService.js +5 -1
- package/dist/server/notifications/pushNotificationService.js.map +1 -1
- package/dist/shared/notificationFocus.d.ts +8 -0
- package/dist/shared/notificationFocus.js +49 -0
- package/dist/shared/notificationFocus.js.map +1 -0
- package/package.json +1 -1
- package/public/sw.js +36 -3
- package/dist/client/assets/MarkdownPreview-CkGAM69L.js +0 -1
- package/dist/client/assets/index-E-kkOjos.js +0 -55
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CkGAM69L.js","assets/index-Dd5r0ChL.js","assets/TranscriptMarkdownBody-BCX4YRz8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();function Rk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ep={exports:{}},zo={};var Hb;function Mk(){if(Hb)return zo;Hb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,l,c){var h=null;if(c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),"key"in l){c={};for(var p in l)p!=="key"&&(c[p]=l[p])}else c=l;return l=c.ref,{$$typeof:e,type:s,key:h,ref:l!==void 0?l:null,props:c}}return zo.Fragment=t,zo.jsx=r,zo.jsxs=r,zo}var Ib;function Nk(){return Ib||(Ib=1,ep.exports=Mk()),ep.exports}var m=Nk(),tp={exports:{}},Ze={};var Ub;function Ak(){if(Ub)return Ze;Ub=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,L={};function A(M,Q,de){this.props=M,this.context=Q,this.refs=L,this.updater=de||k}A.prototype.isReactComponent={},A.prototype.setState=function(M,Q){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,Q,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function B(){}B.prototype=A.prototype;function Y(M,Q,de){this.props=M,this.context=Q,this.refs=L,this.updater=de||k}var P=Y.prototype=new B;P.constructor=Y,E(P,A.prototype),P.isPureReactComponent=!0;var q=Array.isArray;function re(){}var ie={H:null,A:null,T:null,S:null},he=Object.prototype.hasOwnProperty;function ve(M,Q,de){var me=de.ref;return{$$typeof:e,type:M,key:Q,ref:me!==void 0?me:null,props:de}}function U(M,Q){return ve(M.type,Q,M.props)}function K(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function W(M){var Q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(de){return Q[de]})}var H=/\/+/g;function j(M,Q){return typeof M=="object"&&M!==null&&M.key!=null?W(""+M.key):Q.toString(36)}function le(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(re,re):(M.status="pending",M.then(function(Q){M.status==="pending"&&(M.status="fulfilled",M.value=Q)},function(Q){M.status==="pending"&&(M.status="rejected",M.reason=Q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function R(M,Q,de,me,ge){var Se=typeof M;(Se==="undefined"||Se==="boolean")&&(M=null);var Ee=!1;if(M===null)Ee=!0;else switch(Se){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(M.$$typeof){case e:case t:Ee=!0;break;case b:return Ee=M._init,R(Ee(M._payload),Q,de,me,ge)}}if(Ee)return ge=ge(M),Ee=me===""?"."+j(M,0):me,q(ge)?(de="",Ee!=null&&(de=Ee.replace(H,"$&/")+"/"),R(ge,Q,de,"",function(se){return se})):ge!=null&&(K(ge)&&(ge=U(ge,de+(ge.key==null||M&&M.key===ge.key?"":(""+ge.key).replace(H,"$&/")+"/")+Ee)),Q.push(ge)),1;Ee=0;var De=me===""?".":me+":";if(q(M))for(var Ue=0;Ue<M.length;Ue++)me=M[Ue],Se=De+j(me,Ue),Ee+=R(me,Q,de,Se,ge);else if(Ue=w(M),typeof Ue=="function")for(M=Ue.call(M),Ue=0;!(me=M.next()).done;)me=me.value,Se=De+j(me,Ue++),Ee+=R(me,Q,de,Se,ge);else if(Se==="object"){if(typeof M.then=="function")return R(le(M),Q,de,me,ge);throw Q=String(M),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.")}return Ee}function X(M,Q,de){if(M==null)return M;var me=[],ge=0;return R(M,me,"","",function(Se){return Q.call(de,Se,ge++)}),me}function Z(M){if(M._status===-1){var Q=M._result;Q=Q(),Q.then(function(de){(M._status===0||M._status===-1)&&(M._status=1,M._result=de)},function(de){(M._status===0||M._status===-1)&&(M._status=2,M._result=de)}),M._status===-1&&(M._status=0,M._result=Q)}if(M._status===1)return M._result.default;throw M._result}var Ce=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},Te={map:X,forEach:function(M,Q,de){X(M,function(){Q.apply(this,arguments)},de)},count:function(M){var Q=0;return X(M,function(){Q++}),Q},toArray:function(M){return X(M,function(Q){return Q})||[]},only:function(M){if(!K(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ze.Activity=y,Ze.Children=Te,Ze.Component=A,Ze.Fragment=r,Ze.Profiler=l,Ze.PureComponent=Y,Ze.StrictMode=s,Ze.Suspense=g,Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ie,Ze.__COMPILER_RUNTIME={__proto__:null,c:function(M){return ie.H.useMemoCache(M)}},Ze.cache=function(M){return function(){return M.apply(null,arguments)}},Ze.cacheSignal=function(){return null},Ze.cloneElement=function(M,Q,de){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var me=E({},M.props),ge=M.key;if(Q!=null)for(Se in Q.key!==void 0&&(ge=""+Q.key),Q)!he.call(Q,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Q.ref===void 0||(me[Se]=Q[Se]);var Se=arguments.length-2;if(Se===1)me.children=de;else if(1<Se){for(var Ee=Array(Se),De=0;De<Se;De++)Ee[De]=arguments[De+2];me.children=Ee}return ve(M.type,ge,me)},Ze.createContext=function(M){return M={$$typeof:h,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Ze.createElement=function(M,Q,de){var me,ge={},Se=null;if(Q!=null)for(me in Q.key!==void 0&&(Se=""+Q.key),Q)he.call(Q,me)&&me!=="key"&&me!=="__self"&&me!=="__source"&&(ge[me]=Q[me]);var Ee=arguments.length-2;if(Ee===1)ge.children=de;else if(1<Ee){for(var De=Array(Ee),Ue=0;Ue<Ee;Ue++)De[Ue]=arguments[Ue+2];ge.children=De}if(M&&M.defaultProps)for(me in Ee=M.defaultProps,Ee)ge[me]===void 0&&(ge[me]=Ee[me]);return ve(M,Se,ge)},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(M){return{$$typeof:p,render:M}},Ze.isValidElement=K,Ze.lazy=function(M){return{$$typeof:b,_payload:{_status:-1,_result:M},_init:Z}},Ze.memo=function(M,Q){return{$$typeof:f,type:M,compare:Q===void 0?null:Q}},Ze.startTransition=function(M){var Q=ie.T,de={};ie.T=de;try{var me=M(),ge=ie.S;ge!==null&&ge(de,me),typeof me=="object"&&me!==null&&typeof me.then=="function"&&me.then(re,Ce)}catch(Se){Ce(Se)}finally{Q!==null&&de.types!==null&&(Q.types=de.types),ie.T=Q}},Ze.unstable_useCacheRefresh=function(){return ie.H.useCacheRefresh()},Ze.use=function(M){return ie.H.use(M)},Ze.useActionState=function(M,Q,de){return ie.H.useActionState(M,Q,de)},Ze.useCallback=function(M,Q){return ie.H.useCallback(M,Q)},Ze.useContext=function(M){return ie.H.useContext(M)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(M,Q){return ie.H.useDeferredValue(M,Q)},Ze.useEffect=function(M,Q){return ie.H.useEffect(M,Q)},Ze.useEffectEvent=function(M){return ie.H.useEffectEvent(M)},Ze.useId=function(){return ie.H.useId()},Ze.useImperativeHandle=function(M,Q,de){return ie.H.useImperativeHandle(M,Q,de)},Ze.useInsertionEffect=function(M,Q){return ie.H.useInsertionEffect(M,Q)},Ze.useLayoutEffect=function(M,Q){return ie.H.useLayoutEffect(M,Q)},Ze.useMemo=function(M,Q){return ie.H.useMemo(M,Q)},Ze.useOptimistic=function(M,Q){return ie.H.useOptimistic(M,Q)},Ze.useReducer=function(M,Q,de){return ie.H.useReducer(M,Q,de)},Ze.useRef=function(M){return ie.H.useRef(M)},Ze.useState=function(M){return ie.H.useState(M)},Ze.useSyncExternalStore=function(M,Q,de){return ie.H.useSyncExternalStore(M,Q,de)},Ze.useTransition=function(){return ie.H.useTransition()},Ze.version="19.2.6",Ze}var Kb;function gg(){return Kb||(Kb=1,tp.exports=Ak()),tp.exports}var v=gg();const Mi=Rk(v);var ip={exports:{}},jo={},np={exports:{}},rp={};var Wb;function Lk(){return Wb||(Wb=1,(function(e){function t(R,X){var Z=R.length;R.push(X);e:for(;0<Z;){var Ce=Z-1>>>1,Te=R[Ce];if(0<l(Te,X))R[Ce]=X,R[Z]=Te,Z=Ce;else break e}}function r(R){return R.length===0?null:R[0]}function s(R){if(R.length===0)return null;var X=R[0],Z=R.pop();if(Z!==X){R[0]=Z;e:for(var Ce=0,Te=R.length,M=Te>>>1;Ce<M;){var Q=2*(Ce+1)-1,de=R[Q],me=Q+1,ge=R[me];if(0>l(de,Z))me<Te&&0>l(ge,de)?(R[Ce]=ge,R[me]=Z,Ce=me):(R[Ce]=de,R[Q]=Z,Ce=Q);else if(me<Te&&0>l(ge,Z))R[Ce]=ge,R[me]=Z,Ce=me;else break e}}return X}function l(R,X){var Z=R.sortIndex-X.sortIndex;return Z!==0?Z:R.id-X.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,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],b=1,y=null,S=3,w=!1,k=!1,E=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function P(R){for(var X=r(f);X!==null;){if(X.callback===null)s(f);else if(X.startTime<=R)s(f),X.sortIndex=X.expirationTime,t(g,X);else break;X=r(f)}}function q(R){if(E=!1,P(R),!k)if(r(g)!==null)k=!0,re||(re=!0,W());else{var X=r(f);X!==null&&le(q,X.startTime-R)}}var re=!1,ie=-1,he=5,ve=-1;function U(){return L?!0:!(e.unstable_now()-ve<he)}function K(){if(L=!1,re){var R=e.unstable_now();ve=R;var X=!0;try{e:{k=!1,E&&(E=!1,B(ie),ie=-1),w=!0;var Z=S;try{t:{for(P(R),y=r(g);y!==null&&!(y.expirationTime>R&&U());){var Ce=y.callback;if(typeof Ce=="function"){y.callback=null,S=y.priorityLevel;var Te=Ce(y.expirationTime<=R);if(R=e.unstable_now(),typeof Te=="function"){y.callback=Te,P(R),X=!0;break t}y===r(g)&&s(g),P(R)}else s(g);y=r(g)}if(y!==null)X=!0;else{var M=r(f);M!==null&&le(q,M.startTime-R),X=!1}}break e}finally{y=null,S=Z,w=!1}X=void 0}}finally{X?W():re=!1}}}var W;if(typeof Y=="function")W=function(){Y(K)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=K,W=function(){j.postMessage(null)}}else W=function(){A(K,0)};function le(R,X){ie=A(function(){R(e.unstable_now())},X)}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(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):he=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(R){switch(S){case 1:case 2:case 3:var X=3;break;default:X=S}var Z=S;S=X;try{return R()}finally{S=Z}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(R,X){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var Z=S;S=R;try{return X()}finally{S=Z}},e.unstable_scheduleCallback=function(R,X,Z){var Ce=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Ce+Z:Ce):Z=Ce,R){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=Z+Te,R={id:b++,callback:X,priorityLevel:R,startTime:Z,expirationTime:Te,sortIndex:-1},Z>Ce?(R.sortIndex=Z,t(f,R),r(g)===null&&R===r(f)&&(E?(B(ie),ie=-1):E=!0,le(q,Z-Ce))):(R.sortIndex=Te,t(g,R),k||w||(k=!0,re||(re=!0,W()))),R},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(R){var X=S;return function(){var Z=S;S=X;try{return R.apply(this,arguments)}finally{S=Z}}}})(rp)),rp}var Fb;function Bk(){return Fb||(Fb=1,np.exports=Lk()),np.exports}var sp={exports:{}},sn={};var qb;function Ok(){if(qb)return sn;qb=1;var e=gg();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var s={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(g,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:y==null?null:""+y,children:g,containerInfo:f,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return sn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,sn.createPortal=function(g,f){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,b)},sn.flushSync=function(g){var f=h.T,b=s.p;try{if(h.T=null,s.p=2,g)return g()}finally{h.T=f,s.p=b,s.d.f()}},sn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},sn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},sn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:w}):b==="script"&&s.d.X(g,{crossOrigin:y,integrity:S,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},sn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},sn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);s.d.L(g,b,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},sn.preloadModule=function(g,f){if(typeof g=="string")if(f){var b=p(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},sn.requestFormReset=function(g){s.d.r(g)},sn.unstable_batchedUpdates=function(g,f){return g(f)},sn.useFormState=function(g,f,b){return h.H.useFormState(g,f,b)},sn.useFormStatus=function(){return h.H.useHostTransitionStatus()},sn.version="19.2.6",sn}var $b;function Z0(){if($b)return sp.exports;$b=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(),sp.exports=Ok(),sp.exports}var Vb;function zk(){if(Vb)return jo;Vb=1;var e=Bk(),t=gg(),r=Z0();function s(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 l(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 p(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(s(188))}function f(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(s(188));return n!==i?null:i}for(var a=i,o=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(o=u.return,o!==null){a=o;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===o)return g(u),n;d=d.sibling}throw Error(s(188))}if(a.return!==o.return)a=u,o=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,o=d;break}if(C===o){_=!0,o=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,o=u;break}if(C===o){_=!0,o=d,a=u;break}C=C.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==o)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:n}function b(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=b(i),n!==null)return n;i=i.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),he=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function W(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===H?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case E:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case q:return"Suspense";case re:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case k:return"Portal";case Y:return i.displayName||"Context";case B:return(i._context.displayName||"Context")+".Consumer";case P:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ie:return n=i.displayName||null,n!==null?n:j(i.type)||"Memo";case he:n=i._payload,i=i._init;try{return j(i(n))}catch{}}return null}var le=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Ce=[],Te=-1;function M(i){return{current:i}}function Q(i){0>Te||(i.current=Ce[Te],Ce[Te]=null,Te--)}function de(i,n){Te++,Ce[Te]=i.current,i.current=n}var me=M(null),ge=M(null),Se=M(null),Ee=M(null);function De(i,n){switch(de(Se,n),de(ge,i),de(me,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?ob(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=ob(n),i=cb(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Q(me),de(me,i)}function Ue(){Q(me),Q(ge),Q(Se)}function se(i){i.memoizedState!==null&&de(Ee,i);var n=me.current,a=cb(n,i.type);n!==a&&(de(ge,i),de(me,a))}function pe(i){ge.current===i&&(Q(me),Q(ge)),Ee.current===i&&(Q(Ee),Ao._currentValue=Z)}var Le,ye;function Me(i){if(Le===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Le=n&&n[1]||"",ye=-1<a.stack.indexOf(`
|
|
3
|
-
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+Le+i+ye}var Pe=!1;function ze(i,n){if(!i||Pe)return"";Pe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(ee){var G=ee}Reflect.construct(i,[],ue)}else{try{ue.call()}catch(ee){G=ee}i.call(ue.prototype)}}else{try{throw Error()}catch(ee){G=ee}(ue=i())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(ee){if(ee&&G&&typeof ee.stack=="string")return[ee.stack,G.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=o.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var N=_.split(`
|
|
5
|
-
`),V=C.split(`
|
|
6
|
-
`);for(u=o=0;o<N.length&&!N[o].includes("DetermineComponentFrameRoot");)o++;for(;u<V.length&&!V[u].includes("DetermineComponentFrameRoot");)u++;if(o===N.length||u===V.length)for(o=N.length-1,u=V.length-1;1<=o&&0<=u&&N[o]!==V[u];)u--;for(;1<=o&&0<=u;o--,u--)if(N[o]!==V[u]){if(o!==1||u!==1)do if(o--,u--,0>u||N[o]!==V[u]){var oe=`
|
|
7
|
-
`+N[o].replace(" at new "," at ");return i.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",i.displayName)),oe}while(1<=o&&0<=u);break}}}finally{Pe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Me(a):""}function te(i,n){switch(i.tag){case 26:case 27:case 5:return Me(i.type);case 16:return Me("Lazy");case 13:return i.child!==n&&n!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return ze(i.type,!1);case 11:return ze(i.type.render,!1);case 1:return ze(i.type,!0);case 31:return Me("Activity");default:return""}}function ke(i){try{var n="",a=null;do n+=te(i,a),a=i,i=i.return;while(i);return n}catch(o){return`
|
|
8
|
-
Error generating stack: `+o.message+`
|
|
9
|
-
`+o.stack}}var Re=Object.prototype.hasOwnProperty,Be=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,at=e.unstable_shouldYield,Wt=e.unstable_requestPaint,$e=e.unstable_now,kt=e.unstable_getCurrentPriorityLevel,ei=e.unstable_ImmediatePriority,Et=e.unstable_UserBlockingPriority,_e=e.unstable_NormalPriority,We=e.unstable_LowPriority,Je=e.unstable_IdlePriority,ct=e.log,Pt=e.unstable_setDisableYieldValue,Tt=null,Lt=null;function Dt(i){if(typeof ct=="function"&&Pt(i),Lt&&typeof Lt.setStrictMode=="function")try{Lt.setStrictMode(Tt,i)}catch{}}var F=Math.clz32?Math.clz32:hi,Ie=Math.log,it=Math.LN2;function hi(i){return i>>>=0,i===0?32:31-(Ie(i)/it|0)|0}var Gi=256,Ci=262144,St=4194304;function wt(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 Yt(i,n,a){var o=i.pendingLanes;if(o===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=o&134217727;return C!==0?(o=C&~d,o!==0?u=wt(o):(_&=C,_!==0?u=wt(_):a||(a=C&~i,a!==0&&(u=wt(a))))):(C=o&~d,C!==0?u=wt(C):_!==0?u=wt(_):a||(a=o&~i,a!==0&&(u=wt(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 Ft(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function Ai(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 ti(){var i=St;return St<<=1,(St&62914560)===0&&(St=4194304),i}function di(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function Xt(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function qt(i,n,a,o,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,V=i.hiddenUpdates;for(a=_&~a;0<a;){var oe=31-F(a),ue=1<<oe;C[oe]=0,N[oe]=-1;var G=V[oe];if(G!==null)for(V[oe]=null,oe=0;oe<G.length;oe++){var ee=G[oe];ee!==null&&(ee.lane&=-536870913)}a&=~ue}o!==0&&Wi(i,o,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function Wi(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var o=31-F(n);i.entangledLanes|=n,i.entanglements[o]=i.entanglements[o]|1073741824|a&261930}function gt(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var o=31-F(a),u=1<<o;u&n|i[o]&n&&(i[o]|=n),a&=~u}}function Gt(i,n){var a=n&-n;return a=(a&42)!==0?1:ln(a),(a&(i.suspendedLanes|n))!==0?0:a}function ln(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 Zi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Qi(){var i=X.p;return i!==0?i:(i=window.event,i===void 0?32:Ab(i.type))}function dn(i,n){var a=X.p;try{return X.p=i,n()}finally{X.p=a}}var Li=Math.random().toString(36).slice(2),ii="__reactFiber$"+Li,xi="__reactProps$"+Li,Sn="__reactContainer$"+Li,ss="__reactEvents$"+Li,Ji="__reactListeners$"+Li,Xl="__reactHandles$"+Li,as="__reactResources$"+Li,Lr="__reactMarker$"+Li;function ls(i){delete i[ii],delete i[xi],delete i[ss],delete i[Ji],delete i[Xl]}function On(i){var n=i[ii];if(n)return n;for(var a=i.parentNode;a;){if(n=a[Sn]||a[ii]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=gb(i);i!==null;){if(a=i[ii])return a;i=gb(i)}return n}i=a,a=i.parentNode}return null}function mr(i){if(i=i[ii]||i[Sn]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function gr(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(s(33))}function zn(i){var n=i[as];return n||(n=i[as]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Bt(i){i[Lr]=!0}var $a=new Set,ea={};function tr(i,n){ir(i,n),ir(i+"Capture",n)}function ir(i,n){for(ea[i]=n,i=0;i<n.length;i++)$a.add(n[i])}var Gl=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]*$"),ta={},ia={};function Zl(i){return Re.call(ia,i)?!0:Re.call(ta,i)?!1:Gl.test(i)?ia[i]=!0:(ta[i]=!0,!1)}function os(i,n,a){if(Zl(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function cs(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 Fi(i,n,a,o){if(o===null)i.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+o)}}function en(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function nr(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Br(i,n,a){var o=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,d=o.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:o.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function Qe(i){if(!i._valueTracker){var n=nr(i)?"checked":"value";i._valueTracker=Br(i,n,""+i[n])}}function _r(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),o="";return i&&(o=nr(i)?i.checked?"true":"false":i.value),i=o,i!==a?(n.setValue(i),!0):!1}function Ht(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 na=/[\n"\\]/g;function Bi(i){return i.replace(na,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rr(i,n,a,o,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=""+en(n)):i.value!==""+en(n)&&(i.value=""+en(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?us(i,_,en(n)):a!=null?us(i,_,en(a)):o!=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=""+en(C):i.removeAttribute("name")}function li(i,n,a,o,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)){Qe(i);return}a=a!=null?""+en(a):"",n=n!=null?""+en(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,i.checked=C?i.checked:!!o,i.defaultChecked=!!o,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),Qe(i)}function us(i,n,a){n==="number"&&Ht(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function sr(i,n,a,o){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&&o&&(i[a].defaultSelected=!0)}else{for(a=""+en(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,o&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function ra(i,n,a){if(n!=null&&(n=""+en(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+en(a):""}function sa(i,n,a,o){if(n==null){if(o!=null){if(a!=null)throw Error(s(92));if(le(o)){if(1<o.length)throw Error(s(93));o=o[0]}a=o}a==null&&(a=""),n=a}a=en(n),i.defaultValue=a,o=i.textContent,o===a&&o!==""&&o!==null&&(i.value=o),Qe(i)}function vr(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Va=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 jn(i,n,a){var o=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?o?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":o?i.setProperty(n,a):typeof a!="number"||a===0||Va.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function hs(i,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(i=i.style,a!=null){for(var o in a)!a.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="");for(var u in n)o=n[u],n.hasOwnProperty(u)&&a[u]!==o&&jn(i,u,o)}else for(var d in n)n.hasOwnProperty(d)&&jn(i,d,n[d])}function yr(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 aa=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"]]),Pn=/^[\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 Hn(i){return Pn.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function tn(){}var Or=null;function br(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Sr=null,ar=null;function Ya(i){var n=mr(i);if(n&&(i=n.stateNode)){var a=i[xi]||null;e:switch(i=n.stateNode,n.type){case"input":if(rr(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="'+Bi(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var o=a[n];if(o!==i&&o.form===i.form){var u=o[xi]||null;if(!u)throw Error(s(90));rr(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)o=a[n],o.form===i.form&&_r(o)}break e;case"textarea":ra(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&sr(i,!!a.multiple,n,!1)}}}var ds=!1;function Xa(i,n,a){if(ds)return i(n,a);ds=!0;try{var o=i(n);return o}finally{if(ds=!1,(Sr!==null||ar!==null)&&(Su(),Sr&&(n=Sr,i=ar,ar=Sr=null,Ya(n),i)))for(n=0;n<i.length;n++)Ya(i[n])}}function lr(i,n){var a=i.stateNode;if(a===null)return null;var o=a[xi]||null;if(o===null)return null;a=o[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":(o=!o.disabled)||(i=i.type,o=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!o;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var wn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wr=!1;if(wn)try{var ki={};Object.defineProperty(ki,"passive",{get:function(){wr=!0}}),window.addEventListener("test",ki,ki),window.removeEventListener("test",ki,ki)}catch{wr=!1}var nn=null,fs=null,x=null;function T(){if(x)return x;var i,n=fs,a=n.length,o,u="value"in nn?nn.value:nn.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(o=1;o<=_&&n[a-o]===u[d-o];o++);return x=u.slice(i,1<o?1-o:void 0)}function z(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 ne(){return!0}function be(){return!1}function ae(i){function n(a,o,u,d,_){this._reactName=a,this._targetInst=u,this.type=o,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)?ne:be,this.isPropagationStopped=be,this}return y(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=ne)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ne)},persist:function(){},isPersistent:ne}),n}var we={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qe=ae(we),nt=y({},we,{view:0,detail:0}),fi=ae(nt),_t,ps,la,ms=y({},nt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:In,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!==la&&(la&&i.type==="mousemove"?(_t=i.screenX-la.screenX,ps=i.screenY-la.screenY):ps=_t=0,la=i),_t)},movementY:function(i){return"movementY"in i?i.movementY:ps}}),zc=ae(ms),D=y({},ms,{dataTransfer:0}),J=ae(D),Ke=y({},nt,{relatedTarget:0}),Ye=ae(Ke),Ge=y({},we,{animationName:0,elapsedTime:0,pseudoElement:0}),dt=ae(Ge),pi=y({},we,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),rn=ae(pi),Zt=y({},we,{data:0}),mi=ae(Zt),oa={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cn={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"},jc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rd(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=jc[i])?!!n[i]:!1}function In(){return rd}var Pc=y({},nt,{key:function(i){if(i.key){var n=oa[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=z(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Cn[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:In,charCode:function(i){return i.type==="keypress"?z(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?z(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Hc=ae(Pc),KC=y({},ms,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),f_=ae(KC),WC=y({},nt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:In}),FC=ae(WC),qC=y({},we,{propertyName:0,elapsedTime:0,pseudoElement:0}),$C=ae(qC),VC=y({},ms,{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}),YC=ae(VC),XC=y({},we,{newState:0,oldState:0}),GC=ae(XC),ZC=[9,13,27,32],sd=wn&&"CompositionEvent"in window,Ql=null;wn&&"documentMode"in document&&(Ql=document.documentMode);var QC=wn&&"TextEvent"in window&&!Ql,p_=wn&&(!sd||Ql&&8<Ql&&11>=Ql),m_=" ",g_=!1;function __(i,n){switch(i){case"keyup":return ZC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function v_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ga=!1;function JC(i,n){switch(i){case"compositionend":return v_(n);case"keypress":return n.which!==32?null:(g_=!0,m_);case"textInput":return i=n.data,i===m_&&g_?null:i;default:return null}}function ex(i,n){if(Ga)return i==="compositionend"||!sd&&__(i,n)?(i=T(),x=fs=nn=null,Ga=!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 p_&&n.locale!=="ko"?null:n.data;default:return null}}var tx={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 y_(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!tx[i.type]:n==="textarea"}function b_(i,n,a,o){Sr?ar?ar.push(o):ar=[o]:Sr=o,n=Du(n,"onChange"),0<n.length&&(a=new qe("onChange","change",null,a,o),i.push({event:a,listeners:n}))}var Jl=null,eo=null;function ix(i){ib(i,0)}function Ic(i){var n=gr(i);if(_r(n))return i}function S_(i,n){if(i==="change")return n}var w_=!1;if(wn){var ad;if(wn){var ld="oninput"in document;if(!ld){var C_=document.createElement("div");C_.setAttribute("oninput","return;"),ld=typeof C_.oninput=="function"}ad=ld}else ad=!1;w_=ad&&(!document.documentMode||9<document.documentMode)}function x_(){Jl&&(Jl.detachEvent("onpropertychange",k_),eo=Jl=null)}function k_(i){if(i.propertyName==="value"&&Ic(eo)){var n=[];b_(n,eo,i,br(i)),Xa(ix,n)}}function nx(i,n,a){i==="focusin"?(x_(),Jl=n,eo=a,Jl.attachEvent("onpropertychange",k_)):i==="focusout"&&x_()}function rx(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ic(eo)}function sx(i,n){if(i==="click")return Ic(n)}function ax(i,n){if(i==="input"||i==="change")return Ic(n)}function lx(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var xn=typeof Object.is=="function"?Object.is:lx;function to(i,n){if(xn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),o=Object.keys(n);if(a.length!==o.length)return!1;for(o=0;o<a.length;o++){var u=a[o];if(!Re.call(n,u)||!xn(i[u],n[u]))return!1}return!0}function E_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function T_(i,n){var a=E_(i);i=0;for(var o;a;){if(a.nodeType===3){if(o=i+a.textContent.length,i<=n&&o>=n)return{node:a,offset:n-i};i=o}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=E_(a)}}function D_(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?D_(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function R_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=Ht(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=Ht(i.document)}return n}function od(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 ox=wn&&"documentMode"in document&&11>=document.documentMode,Za=null,cd=null,io=null,ud=!1;function M_(i,n,a){var o=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;ud||Za==null||Za!==Ht(o)||(o=Za,"selectionStart"in o&&od(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),io&&to(io,o)||(io=o,o=Du(cd,"onSelect"),0<o.length&&(n=new qe("onSelect","select",null,n,a),i.push({event:n,listeners:o}),n.target=Za)))}function ca(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var Qa={animationend:ca("Animation","AnimationEnd"),animationiteration:ca("Animation","AnimationIteration"),animationstart:ca("Animation","AnimationStart"),transitionrun:ca("Transition","TransitionRun"),transitionstart:ca("Transition","TransitionStart"),transitioncancel:ca("Transition","TransitionCancel"),transitionend:ca("Transition","TransitionEnd")},hd={},N_={};wn&&(N_=document.createElement("div").style,"AnimationEvent"in window||(delete Qa.animationend.animation,delete Qa.animationiteration.animation,delete Qa.animationstart.animation),"TransitionEvent"in window||delete Qa.transitionend.transition);function ua(i){if(hd[i])return hd[i];if(!Qa[i])return i;var n=Qa[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in N_)return hd[i]=n[a];return i}var A_=ua("animationend"),L_=ua("animationiteration"),B_=ua("animationstart"),cx=ua("transitionrun"),ux=ua("transitionstart"),hx=ua("transitioncancel"),O_=ua("transitionend"),z_=new Map,dd="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(" ");dd.push("scrollEnd");function or(i,n){z_.set(i,n),tr(n,[i])}var Uc=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)},Un=[],Ja=0,fd=0;function Kc(){for(var i=Ja,n=fd=Ja=0;n<i;){var a=Un[n];Un[n++]=null;var o=Un[n];Un[n++]=null;var u=Un[n];Un[n++]=null;var d=Un[n];if(Un[n++]=null,o!==null&&u!==null){var _=o.pending;_===null?u.next=u:(u.next=_.next,_.next=u),o.pending=u}d!==0&&j_(a,u,d)}}function Wc(i,n,a,o){Un[Ja++]=i,Un[Ja++]=n,Un[Ja++]=a,Un[Ja++]=o,fd|=o,i.lanes|=o,i=i.alternate,i!==null&&(i.lanes|=o)}function pd(i,n,a,o){return Wc(i,n,a,o),Fc(i)}function ha(i,n){return Wc(i,null,null,n),Fc(i)}function j_(i,n,a){i.lanes|=a;var o=i.alternate;o!==null&&(o.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,o=d.alternate,o!==null&&(o.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-F(a),i=d.hiddenUpdates,o=i[u],o===null?i[u]=[n]:o.push(n),n.lane=a|536870912),d):null}function Fc(i){if(50<ko)throw ko=0,xf=null,Error(s(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var el={};function dx(i,n,a,o){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=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function kn(i,n,a,o){return new dx(i,n,a,o)}function md(i){return i=i.prototype,!(!i||!i.isReactComponent)}function zr(i,n){var a=i.alternate;return a===null?(a=kn(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 P_(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 qc(i,n,a,o,u,d){var _=0;if(o=i,typeof i=="function")md(i)&&(_=1);else if(typeof i=="string")_=_k(i,a,me.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=kn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case E:return da(a.children,u,d,n);case L:_=8,u|=24;break;case A:return i=kn(12,a,n,u|2),i.elementType=A,i.lanes=d,i;case q:return i=kn(13,a,n,u),i.elementType=q,i.lanes=d,i;case re:return i=kn(19,a,n,u),i.elementType=re,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case B:_=9;break e;case P:_=11;break e;case ie:_=14;break e;case he:_=16,o=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),o=null}return n=kn(_,a,n,u),n.elementType=i,n.type=o,n.lanes=d,n}function da(i,n,a,o){return i=kn(7,i,o,n),i.lanes=a,i}function gd(i,n,a){return i=kn(6,i,null,n),i.lanes=a,i}function H_(i){var n=kn(18,null,null,0);return n.stateNode=i,n}function _d(i,n,a){return n=kn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var I_=new WeakMap;function Kn(i,n){if(typeof i=="object"&&i!==null){var a=I_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:ke(n)},I_.set(i,n),n)}return{value:i,source:n,stack:ke(n)}}var tl=[],il=0,$c=null,no=0,Wn=[],Fn=0,gs=null,Cr=1,xr="";function jr(i,n){tl[il++]=no,tl[il++]=$c,$c=i,no=n}function U_(i,n,a){Wn[Fn++]=Cr,Wn[Fn++]=xr,Wn[Fn++]=gs,gs=i;var o=Cr;i=xr;var u=32-F(o)-1;o&=~(1<<u),a+=1;var d=32-F(n)+u;if(30<d){var _=u-u%5;d=(o&(1<<_)-1).toString(32),o>>=_,u-=_,Cr=1<<32-F(n)+u|a<<u|o,xr=d+i}else Cr=1<<d|a<<u|o,xr=i}function vd(i){i.return!==null&&(jr(i,1),U_(i,1,0))}function yd(i){for(;i===$c;)$c=tl[--il],tl[il]=null,no=tl[--il],tl[il]=null;for(;i===gs;)gs=Wn[--Fn],Wn[Fn]=null,xr=Wn[--Fn],Wn[Fn]=null,Cr=Wn[--Fn],Wn[Fn]=null}function K_(i,n){Wn[Fn++]=Cr,Wn[Fn++]=xr,Wn[Fn++]=gs,Cr=n.id,xr=n.overflow,gs=i}var qi=null,It=null,mt=!1,_s=null,qn=!1,bd=Error(s(519));function vs(i){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ro(Kn(n,i)),bd}function W_(i){var n=i.stateNode,a=i.type,o=i.memoizedProps;switch(n[ii]=i,n[xi]=o,a){case"dialog":ht("cancel",n),ht("close",n);break;case"iframe":case"object":case"embed":ht("load",n);break;case"video":case"audio":for(a=0;a<To.length;a++)ht(To[a],n);break;case"source":ht("error",n);break;case"img":case"image":case"link":ht("error",n),ht("load",n);break;case"details":ht("toggle",n);break;case"input":ht("invalid",n),li(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ht("invalid",n);break;case"textarea":ht("invalid",n),sa(n,o.value,o.defaultValue,o.children)}a=o.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||o.suppressHydrationWarning===!0||ab(n.textContent,a)?(o.popover!=null&&(ht("beforetoggle",n),ht("toggle",n)),o.onScroll!=null&&ht("scroll",n),o.onScrollEnd!=null&&ht("scrollend",n),o.onClick!=null&&(n.onclick=tn),n=!0):n=!1,n||vs(i,!0)}function F_(i){for(qi=i.return;qi;)switch(qi.tag){case 5:case 31:case 13:qn=!1;return;case 27:case 3:qn=!0;return;default:qi=qi.return}}function nl(i){if(i!==qi)return!1;if(!mt)return F_(i),mt=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Hf(i.type,i.memoizedProps)),a=!a),a&&It&&vs(i),F_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));It=mb(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));It=mb(i)}else n===27?(n=It,As(i.type)?(i=Ff,Ff=null,It=i):It=n):It=qi?Vn(i.stateNode.nextSibling):null;return!0}function fa(){It=qi=null,mt=!1}function Sd(){var i=_s;return i!==null&&(gn===null?gn=i:gn.push.apply(gn,i),_s=null),i}function ro(i){_s===null?_s=[i]:_s.push(i)}var wd=M(null),pa=null,Pr=null;function ys(i,n,a){de(wd,n._currentValue),n._currentValue=a}function Hr(i){i._currentValue=wd.current,Q(wd)}function Cd(i,n,a){for(;i!==null;){var o=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),i===a)break;i=i.return}}function xd(i,n,a,o){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),Cd(d.return,a,i),o||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),Cd(_,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 rl(i,n,a,o){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(s(387));if(_=_.memoizedProps,_!==null){var C=u.type;xn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Ee.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(Ao):i=[Ao])}u=u.return}i!==null&&xd(n,i,a,o),n.flags|=262144}function Vc(i){for(i=i.firstContext;i!==null;){if(!xn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ma(i){pa=i,Pr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function $i(i){return q_(pa,i)}function Yc(i,n){return pa===null&&ma(i),q_(i,n)}function q_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Pr===null){if(i===null)throw Error(s(308));Pr=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Pr=Pr.next=n;return a}var fx=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,o){i.push(o)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},px=e.unstable_scheduleCallback,mx=e.unstable_NormalPriority,gi={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function kd(){return{controller:new fx,data:new Map,refCount:0}}function so(i){i.refCount--,i.refCount===0&&px(mx,function(){i.controller.abort()})}var ao=null,Ed=0,sl=0,al=null;function gx(i,n){if(ao===null){var a=ao=[];Ed=0,sl=Mf(),al={status:"pending",value:void 0,then:function(o){a.push(o)}}}return Ed++,n.then($_,$_),n}function $_(){if(--Ed===0&&ao!==null){al!==null&&(al.status="fulfilled");var i=ao;ao=null,sl=0,al=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function _x(i,n){var a=[],o={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){o.status="fulfilled",o.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(o.status="rejected",o.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),o}var V_=R.S;R.S=function(i,n){My=$e(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&gx(i,n),V_!==null&&V_(i,n)};var ga=M(null);function Td(){var i=ga.current;return i!==null?i:Ot.pooledCache}function Xc(i,n){n===null?de(ga,ga.current):de(ga,n.pool)}function Y_(){var i=Td();return i===null?null:{parent:gi._currentValue,pool:i}}var ll=Error(s(460)),Dd=Error(s(474)),Gc=Error(s(542)),Zc={then:function(){}};function X_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function G_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(tn,tn),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,Q_(i),i;default:if(typeof n.status=="string")n.then(tn,tn);else{if(i=Ot,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=n,i.status="pending",i.then(function(o){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=o}},function(o){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,Q_(i),i}throw va=n,ll}}function _a(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(va=a,ll):a}}var va=null;function Z_(){if(va===null)throw Error(s(459));var i=va;return va=null,i}function Q_(i){if(i===ll||i===Gc)throw Error(s(483))}var ol=null,lo=0;function Qc(i){var n=lo;return lo+=1,ol===null&&(ol=[]),G_(ol,i,n)}function oo(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Jc(i,n){throw n.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(n),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function J_(i){function n(I,O){if(i){var $=I.deletions;$===null?(I.deletions=[O],I.flags|=16):$.push(O)}}function a(I,O){if(!i)return null;for(;O!==null;)n(I,O),O=O.sibling;return null}function o(I){for(var O=new Map;I!==null;)I.key!==null?O.set(I.key,I):O.set(I.index,I),I=I.sibling;return O}function u(I,O){return I=zr(I,O),I.index=0,I.sibling=null,I}function d(I,O,$){return I.index=$,i?($=I.alternate,$!==null?($=$.index,$<O?(I.flags|=67108866,O):$):(I.flags|=67108866,O)):(I.flags|=1048576,O)}function _(I){return i&&I.alternate===null&&(I.flags|=67108866),I}function C(I,O,$,ce){return O===null||O.tag!==6?(O=gd($,I.mode,ce),O.return=I,O):(O=u(O,$),O.return=I,O)}function N(I,O,$,ce){var Fe=$.type;return Fe===E?oe(I,O,$.props.children,ce,$.key):O!==null&&(O.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===he&&_a(Fe)===O.type)?(O=u(O,$.props),oo(O,$),O.return=I,O):(O=qc($.type,$.key,$.props,null,I.mode,ce),oo(O,$),O.return=I,O)}function V(I,O,$,ce){return O===null||O.tag!==4||O.stateNode.containerInfo!==$.containerInfo||O.stateNode.implementation!==$.implementation?(O=_d($,I.mode,ce),O.return=I,O):(O=u(O,$.children||[]),O.return=I,O)}function oe(I,O,$,ce,Fe){return O===null||O.tag!==7?(O=da($,I.mode,ce,Fe),O.return=I,O):(O=u(O,$),O.return=I,O)}function ue(I,O,$){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=gd(""+O,I.mode,$),O.return=I,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case w:return $=qc(O.type,O.key,O.props,null,I.mode,$),oo($,O),$.return=I,$;case k:return O=_d(O,I.mode,$),O.return=I,O;case he:return O=_a(O),ue(I,O,$)}if(le(O)||W(O))return O=da(O,I.mode,$,null),O.return=I,O;if(typeof O.then=="function")return ue(I,Qc(O),$);if(O.$$typeof===Y)return ue(I,Yc(I,O),$);Jc(I,O)}return null}function G(I,O,$,ce){var Fe=O!==null?O.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return Fe!==null?null:C(I,O,""+$,ce);if(typeof $=="object"&&$!==null){switch($.$$typeof){case w:return $.key===Fe?N(I,O,$,ce):null;case k:return $.key===Fe?V(I,O,$,ce):null;case he:return $=_a($),G(I,O,$,ce)}if(le($)||W($))return Fe!==null?null:oe(I,O,$,ce,null);if(typeof $.then=="function")return G(I,O,Qc($),ce);if($.$$typeof===Y)return G(I,O,Yc(I,$),ce);Jc(I,$)}return null}function ee(I,O,$,ce,Fe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return I=I.get($)||null,C(O,I,""+ce,Fe);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return I=I.get(ce.key===null?$:ce.key)||null,N(O,I,ce,Fe);case k:return I=I.get(ce.key===null?$:ce.key)||null,V(O,I,ce,Fe);case he:return ce=_a(ce),ee(I,O,$,ce,Fe)}if(le(ce)||W(ce))return I=I.get($)||null,oe(O,I,ce,Fe,null);if(typeof ce.then=="function")return ee(I,O,$,Qc(ce),Fe);if(ce.$$typeof===Y)return ee(I,O,$,Yc(O,ce),Fe);Jc(O,ce)}return null}function Oe(I,O,$,ce){for(var Fe=null,vt=null,He=O,rt=O=0,pt=null;He!==null&&rt<$.length;rt++){He.index>rt?(pt=He,He=null):pt=He.sibling;var yt=G(I,He,$[rt],ce);if(yt===null){He===null&&(He=pt);break}i&&He&&yt.alternate===null&&n(I,He),O=d(yt,O,rt),vt===null?Fe=yt:vt.sibling=yt,vt=yt,He=pt}if(rt===$.length)return a(I,He),mt&&jr(I,rt),Fe;if(He===null){for(;rt<$.length;rt++)He=ue(I,$[rt],ce),He!==null&&(O=d(He,O,rt),vt===null?Fe=He:vt.sibling=He,vt=He);return mt&&jr(I,rt),Fe}for(He=o(He);rt<$.length;rt++)pt=ee(He,I,rt,$[rt],ce),pt!==null&&(i&&pt.alternate!==null&&He.delete(pt.key===null?rt:pt.key),O=d(pt,O,rt),vt===null?Fe=pt:vt.sibling=pt,vt=pt);return i&&He.forEach(function(js){return n(I,js)}),mt&&jr(I,rt),Fe}function Ve(I,O,$,ce){if($==null)throw Error(s(151));for(var Fe=null,vt=null,He=O,rt=O=0,pt=null,yt=$.next();He!==null&&!yt.done;rt++,yt=$.next()){He.index>rt?(pt=He,He=null):pt=He.sibling;var js=G(I,He,yt.value,ce);if(js===null){He===null&&(He=pt);break}i&&He&&js.alternate===null&&n(I,He),O=d(js,O,rt),vt===null?Fe=js:vt.sibling=js,vt=js,He=pt}if(yt.done)return a(I,He),mt&&jr(I,rt),Fe;if(He===null){for(;!yt.done;rt++,yt=$.next())yt=ue(I,yt.value,ce),yt!==null&&(O=d(yt,O,rt),vt===null?Fe=yt:vt.sibling=yt,vt=yt);return mt&&jr(I,rt),Fe}for(He=o(He);!yt.done;rt++,yt=$.next())yt=ee(He,I,rt,yt.value,ce),yt!==null&&(i&&yt.alternate!==null&&He.delete(yt.key===null?rt:yt.key),O=d(yt,O,rt),vt===null?Fe=yt:vt.sibling=yt,vt=yt);return i&&He.forEach(function(Dk){return n(I,Dk)}),mt&&jr(I,rt),Fe}function Nt(I,O,$,ce){if(typeof $=="object"&&$!==null&&$.type===E&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case w:e:{for(var Fe=$.key;O!==null;){if(O.key===Fe){if(Fe=$.type,Fe===E){if(O.tag===7){a(I,O.sibling),ce=u(O,$.props.children),ce.return=I,I=ce;break e}}else if(O.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===he&&_a(Fe)===O.type){a(I,O.sibling),ce=u(O,$.props),oo(ce,$),ce.return=I,I=ce;break e}a(I,O);break}else n(I,O);O=O.sibling}$.type===E?(ce=da($.props.children,I.mode,ce,$.key),ce.return=I,I=ce):(ce=qc($.type,$.key,$.props,null,I.mode,ce),oo(ce,$),ce.return=I,I=ce)}return _(I);case k:e:{for(Fe=$.key;O!==null;){if(O.key===Fe)if(O.tag===4&&O.stateNode.containerInfo===$.containerInfo&&O.stateNode.implementation===$.implementation){a(I,O.sibling),ce=u(O,$.children||[]),ce.return=I,I=ce;break e}else{a(I,O);break}else n(I,O);O=O.sibling}ce=_d($,I.mode,ce),ce.return=I,I=ce}return _(I);case he:return $=_a($),Nt(I,O,$,ce)}if(le($))return Oe(I,O,$,ce);if(W($)){if(Fe=W($),typeof Fe!="function")throw Error(s(150));return $=Fe.call($),Ve(I,O,$,ce)}if(typeof $.then=="function")return Nt(I,O,Qc($),ce);if($.$$typeof===Y)return Nt(I,O,Yc(I,$),ce);Jc(I,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,O!==null&&O.tag===6?(a(I,O.sibling),ce=u(O,$),ce.return=I,I=ce):(a(I,O),ce=gd($,I.mode,ce),ce.return=I,I=ce),_(I)):a(I,O)}return function(I,O,$,ce){try{lo=0;var Fe=Nt(I,O,$,ce);return ol=null,Fe}catch(He){if(He===ll||He===Gc)throw He;var vt=kn(29,He,null,I.mode);return vt.lanes=ce,vt.return=I,vt}}}var ya=J_(!0),ev=J_(!1),bs=!1;function Rd(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Md(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 Ss(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ws(i,n,a){var o=i.updateQueue;if(o===null)return null;if(o=o.shared,(bt&2)!==0){var u=o.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),o.pending=n,n=Fc(i),j_(i,null,a),n}return Wc(i,o,n,a),Fc(i)}function co(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var o=n.lanes;o&=i.pendingLanes,a|=o,n.lanes=a,gt(i,a)}}function Nd(i,n){var a=i.updateQueue,o=i.alternate;if(o!==null&&(o=o.updateQueue,a===o)){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:o.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:o.shared,callbacks:o.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var Ad=!1;function uo(){if(Ad){var i=al;if(i!==null)throw i}}function ho(i,n,a,o){Ad=!1;var u=i.updateQueue;bs=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var N=C,V=N.next;N.next=null,_===null?d=V:_.next=V,_=N;var oe=i.alternate;oe!==null&&(oe=oe.updateQueue,C=oe.lastBaseUpdate,C!==_&&(C===null?oe.firstBaseUpdate=V:C.next=V,oe.lastBaseUpdate=N))}if(d!==null){var ue=u.baseState;_=0,oe=V=N=null,C=d;do{var G=C.lane&-536870913,ee=G!==C.lane;if(ee?(ft&G)===G:(o&G)===G){G!==0&&G===sl&&(Ad=!0),oe!==null&&(oe=oe.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Oe=i,Ve=C;G=n;var Nt=a;switch(Ve.tag){case 1:if(Oe=Ve.payload,typeof Oe=="function"){ue=Oe.call(Nt,ue,G);break e}ue=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Ve.payload,G=typeof Oe=="function"?Oe.call(Nt,ue,G):Oe,G==null)break e;ue=y({},ue,G);break e;case 2:bs=!0}}G=C.callback,G!==null&&(i.flags|=64,ee&&(i.flags|=8192),ee=u.callbacks,ee===null?u.callbacks=[G]:ee.push(G))}else ee={lane:G,tag:C.tag,payload:C.payload,callback:C.callback,next:null},oe===null?(V=oe=ee,N=ue):oe=oe.next=ee,_|=G;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;ee=C,C=ee.next,ee.next=null,u.lastBaseUpdate=ee,u.shared.pending=null}}while(!0);oe===null&&(N=ue),u.baseState=N,u.firstBaseUpdate=V,u.lastBaseUpdate=oe,d===null&&(u.shared.lanes=0),Ts|=_,i.lanes=_,i.memoizedState=ue}}function tv(i,n){if(typeof i!="function")throw Error(s(191,i));i.call(n)}function iv(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)tv(a[i],n)}var cl=M(null),eu=M(0);function nv(i,n){i=Yr,de(eu,i),de(cl,n),Yr=i|n.baseLanes}function Ld(){de(eu,Yr),de(cl,cl.current)}function Bd(){Yr=eu.current,Q(cl),Q(eu)}var En=M(null),$n=null;function Cs(i){var n=i.alternate;de(oi,oi.current&1),de(En,i),$n===null&&(n===null||cl.current!==null||n.memoizedState!==null)&&($n=i)}function Od(i){de(oi,oi.current),de(En,i),$n===null&&($n=i)}function rv(i){i.tag===22?(de(oi,oi.current),de(En,i),$n===null&&($n=i)):xs()}function xs(){de(oi,oi.current),de(En,En.current)}function Tn(i){Q(En),$n===i&&($n=null),Q(oi)}var oi=M(0);function tu(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Kf(a)||Wf(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 Ir=0,et=null,Rt=null,_i=null,iu=!1,ul=!1,ba=!1,nu=0,fo=0,hl=null,vx=0;function ni(){throw Error(s(321))}function zd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!xn(i[a],n[a]))return!1;return!0}function jd(i,n,a,o,u,d){return Ir=d,et=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,R.H=i===null||i.memoizedState===null?Uv:Qd,ba=!1,d=a(o,u),ba=!1,ul&&(d=av(n,a,o,u)),sv(i),d}function sv(i){R.H=go;var n=Rt!==null&&Rt.next!==null;if(Ir=0,_i=Rt=et=null,iu=!1,fo=0,hl=null,n)throw Error(s(300));i===null||vi||(i=i.dependencies,i!==null&&Vc(i)&&(vi=!0))}function av(i,n,a,o){et=i;var u=0;do{if(ul&&(hl=null),fo=0,ul=!1,25<=u)throw Error(s(301));if(u+=1,_i=Rt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}R.H=Kv,d=n(a,o)}while(ul);return d}function yx(){var i=R.H,n=i.useState()[0];return n=typeof n.then=="function"?po(n):n,i=i.useState()[0],(Rt!==null?Rt.memoizedState:null)!==i&&(et.flags|=1024),n}function Pd(){var i=nu!==0;return nu=0,i}function Hd(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function Id(i){if(iu){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}iu=!1}Ir=0,_i=Rt=et=null,ul=!1,fo=nu=0,hl=null}function on(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _i===null?et.memoizedState=_i=i:_i=_i.next=i,_i}function ci(){if(Rt===null){var i=et.alternate;i=i!==null?i.memoizedState:null}else i=Rt.next;var n=_i===null?et.memoizedState:_i.next;if(n!==null)_i=n,Rt=i;else{if(i===null)throw et.alternate===null?Error(s(467)):Error(s(310));Rt=i,i={memoizedState:Rt.memoizedState,baseState:Rt.baseState,baseQueue:Rt.baseQueue,queue:Rt.queue,next:null},_i===null?et.memoizedState=_i=i:_i=_i.next=i}return _i}function ru(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function po(i){var n=fo;return fo+=1,hl===null&&(hl=[]),i=G_(hl,i,n),n=et,(_i===null?n.memoizedState:_i.next)===null&&(n=n.alternate,R.H=n===null||n.memoizedState===null?Uv:Qd),i}function su(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return po(i);if(i.$$typeof===Y)return $i(i)}throw Error(s(438,String(i)))}function Ud(i){var n=null,a=et.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var o=et.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=ru(),et.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),o=0;o<i;o++)a[o]=U;return n.index++,a}function Ur(i,n){return typeof n=="function"?n(i):n}function au(i){var n=ci();return Kd(n,Rt,i)}function Kd(i,n,a){var o=i.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=a;var u=i.baseQueue,d=o.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,o.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,N=null,V=n,oe=!1;do{var ue=V.lane&-536870913;if(ue!==V.lane?(ft&ue)===ue:(Ir&ue)===ue){var G=V.revertLane;if(G===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ue===sl&&(oe=!0);else if((Ir&G)===G){V=V.next,G===sl&&(oe=!0);continue}else ue={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(C=N=ue,_=d):N=N.next=ue,et.lanes|=G,Ts|=G;ue=V.action,ba&&a(d,ue),d=V.hasEagerState?V.eagerState:a(d,ue)}else G={lane:ue,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(C=N=G,_=d):N=N.next=G,et.lanes|=ue,Ts|=ue;V=V.next}while(V!==null&&V!==n);if(N===null?_=d:N.next=C,!xn(d,i.memoizedState)&&(vi=!0,oe&&(a=al,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,o.lastRenderedState=d}return u===null&&(o.lanes=0),[i.memoizedState,o.dispatch]}function Wd(i){var n=ci(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var o=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);xn(d,n.memoizedState)||(vi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,o]}function lv(i,n,a){var o=et,u=ci(),d=mt;if(d){if(a===void 0)throw Error(s(407));a=a()}else a=n();var _=!xn((Rt||u).memoizedState,a);if(_&&(u.memoizedState=a,vi=!0),u=u.queue,$d(uv.bind(null,o,u,i),[i]),u.getSnapshot!==n||_||_i!==null&&_i.memoizedState.tag&1){if(o.flags|=2048,dl(9,{destroy:void 0},cv.bind(null,o,u,a,n),null),Ot===null)throw Error(s(349));d||(Ir&127)!==0||ov(o,n,a)}return a}function ov(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=et.updateQueue,n===null?(n=ru(),et.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function cv(i,n,a,o){n.value=a,n.getSnapshot=o,hv(n)&&dv(i)}function uv(i,n,a){return a(function(){hv(n)&&dv(i)})}function hv(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!xn(i,a)}catch{return!0}}function dv(i){var n=ha(i,2);n!==null&&_n(n,i,2)}function Fd(i){var n=on();if(typeof i=="function"){var a=i;if(i=a(),ba){Dt(!0);try{a()}finally{Dt(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:i},n}function fv(i,n,a,o){return i.baseState=a,Kd(i,Rt,typeof o=="function"?o:Ur)}function bx(i,n,a,o,u){if(cu(i))throw Error(s(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(_)}};R.T!==null?a(!0):d.isTransition=!1,o(d),a=n.pending,a===null?(d.next=n.pending=d,pv(n,d)):(d.next=a.next,n.pending=a.next=d)}}function pv(i,n){var a=n.action,o=n.payload,u=i.state;if(n.isTransition){var d=R.T,_={};R.T=_;try{var C=a(u,o),N=R.S;N!==null&&N(_,C),mv(i,n,C)}catch(V){qd(i,n,V)}finally{d!==null&&_.types!==null&&(d.types=_.types),R.T=d}}else try{d=a(u,o),mv(i,n,d)}catch(V){qd(i,n,V)}}function mv(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(o){gv(i,n,o)},function(o){return qd(i,n,o)}):gv(i,n,a)}function gv(i,n,a){n.status="fulfilled",n.value=a,_v(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,pv(i,a)))}function qd(i,n,a){var o=i.pending;if(i.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=a,_v(n),n=n.next;while(n!==o)}i.action=null}function _v(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function vv(i,n){return n}function yv(i,n){if(mt){var a=Ot.formState;if(a!==null){e:{var o=et;if(mt){if(It){t:{for(var u=It,d=qn;u.nodeType!==8;){if(!d){u=null;break t}if(u=Vn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){It=Vn(u.nextSibling),o=u.data==="F!";break e}}vs(o)}o=!1}o&&(n=a[0])}}return a=on(),a.memoizedState=a.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vv,lastRenderedState:n},a.queue=o,a=Pv.bind(null,et,o),o.dispatch=a,o=Fd(!1),d=Zd.bind(null,et,!1,o.queue),o=on(),u={state:n,dispatch:null,action:i,pending:null},o.queue=u,a=bx.bind(null,et,u,d,a),u.dispatch=a,o.memoizedState=i,[n,a,!1]}function bv(i){var n=ci();return Sv(n,Rt,i)}function Sv(i,n,a){if(n=Kd(i,n,vv)[0],i=au(Ur)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=po(n)}catch(_){throw _===ll?Gc:_}else o=n;n=ci();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(et.flags|=2048,dl(9,{destroy:void 0},Sx.bind(null,u,a),null)),[o,d,i]}function Sx(i,n){i.action=n}function wv(i){var n=ci(),a=Rt;if(a!==null)return Sv(n,a,i);ci(),n=n.memoizedState,a=ci();var o=a.queue.dispatch;return a.memoizedState=i,[n,o,!1]}function dl(i,n,a,o){return i={tag:i,create:a,deps:o,inst:n,next:null},n=et.updateQueue,n===null&&(n=ru(),et.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(o=a.next,a.next=i,i.next=o,n.lastEffect=i),i}function Cv(){return ci().memoizedState}function lu(i,n,a,o){var u=on();et.flags|=i,u.memoizedState=dl(1|n,{destroy:void 0},a,o===void 0?null:o)}function ou(i,n,a,o){var u=ci();o=o===void 0?null:o;var d=u.memoizedState.inst;Rt!==null&&o!==null&&zd(o,Rt.memoizedState.deps)?u.memoizedState=dl(n,d,a,o):(et.flags|=i,u.memoizedState=dl(1|n,d,a,o))}function xv(i,n){lu(8390656,8,i,n)}function $d(i,n){ou(2048,8,i,n)}function wx(i){et.flags|=4;var n=et.updateQueue;if(n===null)n=ru(),et.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function kv(i){var n=ci().memoizedState;return wx({ref:n,nextImpl:i}),function(){if((bt&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function Ev(i,n){return ou(4,2,i,n)}function Tv(i,n){return ou(4,4,i,n)}function Dv(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 Rv(i,n,a){a=a!=null?a.concat([i]):null,ou(4,4,Dv.bind(null,n,i),a)}function Vd(){}function Mv(i,n){var a=ci();n=n===void 0?null:n;var o=a.memoizedState;return n!==null&&zd(n,o[1])?o[0]:(a.memoizedState=[i,n],i)}function Nv(i,n){var a=ci();n=n===void 0?null:n;var o=a.memoizedState;if(n!==null&&zd(n,o[1]))return o[0];if(o=i(),ba){Dt(!0);try{i()}finally{Dt(!1)}}return a.memoizedState=[o,n],o}function Yd(i,n,a){return a===void 0||(Ir&1073741824)!==0&&(ft&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=Ay(),et.lanes|=i,Ts|=i,a)}function Av(i,n,a,o){return xn(a,n)?a:cl.current!==null?(i=Yd(i,a,o),xn(i,n)||(vi=!0),i):(Ir&42)===0||(Ir&1073741824)!==0&&(ft&261930)===0?(vi=!0,i.memoizedState=a):(i=Ay(),et.lanes|=i,Ts|=i,n)}function Lv(i,n,a,o,u){var d=X.p;X.p=d!==0&&8>d?d:8;var _=R.T,C={};R.T=C,Zd(i,!1,n,a);try{var N=u(),V=R.S;if(V!==null&&V(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var oe=_x(N,o);mo(i,n,oe,Mn(i))}else mo(i,n,o,Mn(i))}catch(ue){mo(i,n,{then:function(){},status:"rejected",reason:ue},Mn())}finally{X.p=d,_!==null&&C.types!==null&&(_.types=C.types),R.T=_}}function Cx(){}function Xd(i,n,a,o){if(i.tag!==5)throw Error(s(476));var u=Bv(i).queue;Lv(i,u,n,Z,a===null?Cx:function(){return Ov(i),a(o)})}function Bv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:Z},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ur,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function Ov(i){var n=Bv(i);n.next===null&&(n=i.alternate.memoizedState),mo(i,n.next.queue,{},Mn())}function Gd(){return $i(Ao)}function zv(){return ci().memoizedState}function jv(){return ci().memoizedState}function xx(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Mn();i=Ss(a);var o=ws(n,i,a);o!==null&&(_n(o,n,a),co(o,n,a)),n={cache:kd()},i.payload=n;return}n=n.return}}function kx(i,n,a){var o=Mn();a={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},cu(i)?Hv(n,a):(a=pd(i,n,a,o),a!==null&&(_n(a,i,o),Iv(a,n,o)))}function Pv(i,n,a){var o=Mn();mo(i,n,a,o)}function mo(i,n,a,o){var u={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(cu(i))Hv(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,xn(C,_))return Wc(i,n,u,0),Ot===null&&Kc(),!1}catch{}if(a=pd(i,n,u,o),a!==null)return _n(a,i,o),Iv(a,n,o),!0}return!1}function Zd(i,n,a,o){if(o={lane:2,revertLane:Mf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},cu(i)){if(n)throw Error(s(479))}else n=pd(i,a,o,2),n!==null&&_n(n,i,2)}function cu(i){var n=i.alternate;return i===et||n!==null&&n===et}function Hv(i,n){ul=iu=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function Iv(i,n,a){if((a&4194048)!==0){var o=n.lanes;o&=i.pendingLanes,a|=o,n.lanes=a,gt(i,a)}}var go={readContext:$i,use:su,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};go.useEffectEvent=ni;var Uv={readContext:$i,use:su,useCallback:function(i,n){return on().memoizedState=[i,n===void 0?null:n],i},useContext:$i,useEffect:xv,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,lu(4194308,4,Dv.bind(null,n,i),a)},useLayoutEffect:function(i,n){return lu(4194308,4,i,n)},useInsertionEffect:function(i,n){lu(4,2,i,n)},useMemo:function(i,n){var a=on();n=n===void 0?null:n;var o=i();if(ba){Dt(!0);try{i()}finally{Dt(!1)}}return a.memoizedState=[o,n],o},useReducer:function(i,n,a){var o=on();if(a!==void 0){var u=a(n);if(ba){Dt(!0);try{a(n)}finally{Dt(!1)}}}else u=n;return o.memoizedState=o.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},o.queue=i,i=i.dispatch=kx.bind(null,et,i),[o.memoizedState,i]},useRef:function(i){var n=on();return i={current:i},n.memoizedState=i},useState:function(i){i=Fd(i);var n=i.queue,a=Pv.bind(null,et,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:Vd,useDeferredValue:function(i,n){var a=on();return Yd(a,i,n)},useTransition:function(){var i=Fd(!1);return i=Lv.bind(null,et,i.queue,!0,!1),on().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var o=et,u=on();if(mt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),Ot===null)throw Error(s(349));(ft&127)!==0||ov(o,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,xv(uv.bind(null,o,d,i),[i]),o.flags|=2048,dl(9,{destroy:void 0},cv.bind(null,o,d,a,n),null),a},useId:function(){var i=on(),n=Ot.identifierPrefix;if(mt){var a=xr,o=Cr;a=(o&~(1<<32-F(o)-1)).toString(32)+a,n="_"+n+"R_"+a,a=nu++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=vx++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Gd,useFormState:yv,useActionState:yv,useOptimistic:function(i){var n=on();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Zd.bind(null,et,!0,a),a.dispatch=n,[i,n]},useMemoCache:Ud,useCacheRefresh:function(){return on().memoizedState=xx.bind(null,et)},useEffectEvent:function(i){var n=on(),a={impl:i};return n.memoizedState=a,function(){if((bt&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Qd={readContext:$i,use:su,useCallback:Mv,useContext:$i,useEffect:$d,useImperativeHandle:Rv,useInsertionEffect:Ev,useLayoutEffect:Tv,useMemo:Nv,useReducer:au,useRef:Cv,useState:function(){return au(Ur)},useDebugValue:Vd,useDeferredValue:function(i,n){var a=ci();return Av(a,Rt.memoizedState,i,n)},useTransition:function(){var i=au(Ur)[0],n=ci().memoizedState;return[typeof i=="boolean"?i:po(i),n]},useSyncExternalStore:lv,useId:zv,useHostTransitionStatus:Gd,useFormState:bv,useActionState:bv,useOptimistic:function(i,n){var a=ci();return fv(a,Rt,i,n)},useMemoCache:Ud,useCacheRefresh:jv};Qd.useEffectEvent=kv;var Kv={readContext:$i,use:su,useCallback:Mv,useContext:$i,useEffect:$d,useImperativeHandle:Rv,useInsertionEffect:Ev,useLayoutEffect:Tv,useMemo:Nv,useReducer:Wd,useRef:Cv,useState:function(){return Wd(Ur)},useDebugValue:Vd,useDeferredValue:function(i,n){var a=ci();return Rt===null?Yd(a,i,n):Av(a,Rt.memoizedState,i,n)},useTransition:function(){var i=Wd(Ur)[0],n=ci().memoizedState;return[typeof i=="boolean"?i:po(i),n]},useSyncExternalStore:lv,useId:zv,useHostTransitionStatus:Gd,useFormState:wv,useActionState:wv,useOptimistic:function(i,n){var a=ci();return Rt!==null?fv(a,Rt,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Ud,useCacheRefresh:jv};Kv.useEffectEvent=kv;function Jd(i,n,a,o){n=i.memoizedState,a=a(o,n),a=a==null?n:y({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var ef={enqueueSetState:function(i,n,a){i=i._reactInternals;var o=Mn(),u=Ss(o);u.payload=n,a!=null&&(u.callback=a),n=ws(i,u,o),n!==null&&(_n(n,i,o),co(n,i,o))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var o=Mn(),u=Ss(o);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=ws(i,u,o),n!==null&&(_n(n,i,o),co(n,i,o))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Mn(),o=Ss(a);o.tag=2,n!=null&&(o.callback=n),n=ws(i,o,a),n!==null&&(_n(n,i,a),co(n,i,a))}};function Wv(i,n,a,o,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(o,d,_):n.prototype&&n.prototype.isPureReactComponent?!to(a,o)||!to(u,d):!0}function Fv(i,n,a,o){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,o),n.state!==i&&ef.enqueueReplaceState(n,n.state,null)}function Sa(i,n){var a=n;if("ref"in n){a={};for(var o in n)o!=="ref"&&(a[o]=n[o])}if(i=i.defaultProps){a===n&&(a=y({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function qv(i){Uc(i)}function $v(i){console.error(i)}function Vv(i){Uc(i)}function uu(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Yv(i,n,a){try{var o=i.onCaughtError;o(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function tf(i,n,a){return a=Ss(a),a.tag=3,a.payload={element:null},a.callback=function(){uu(i,n)},a}function Xv(i){return i=Ss(i),i.tag=3,i}function Gv(i,n,a,o){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=o.value;i.payload=function(){return u(d)},i.callback=function(){Yv(n,a,o)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Yv(n,a,o),typeof u!="function"&&(Ds===null?Ds=new Set([this]):Ds.add(this));var C=o.stack;this.componentDidCatch(o.value,{componentStack:C!==null?C:""})})}function Ex(i,n,a,o,u){if(a.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=a.alternate,n!==null&&rl(n,a,u,!0),a=En.current,a!==null){switch(a.tag){case 31:case 13:return $n===null?wu():a.alternate===null&&ri===0&&(ri=3),a.flags&=-257,a.flags|=65536,a.lanes=u,o===Zc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([o]):n.add(o),Tf(i,o,u)),!1;case 22:return a.flags|=65536,o===Zc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([o]):a.add(o)),Tf(i,o,u)),!1}throw Error(s(435,a.tag))}return Tf(i,o,u),wu(),!1}if(mt)return n=En.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,o!==bd&&(i=Error(s(422),{cause:o}),ro(Kn(i,a)))):(o!==bd&&(n=Error(s(423),{cause:o}),ro(Kn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,o=Kn(o,a),u=tf(i.stateNode,o,u),Nd(i,u),ri!==4&&(ri=2)),!1;var d=Error(s(520),{cause:o});if(d=Kn(d,a),xo===null?xo=[d]:xo.push(d),ri!==4&&(ri=2),n===null)return!0;o=Kn(o,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=tf(a.stateNode,o,i),Nd(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"&&(Ds===null||!Ds.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Xv(u),Gv(u,i,a,o),Nd(a,u),!1}a=a.return}while(a!==null);return!1}var nf=Error(s(461)),vi=!1;function Vi(i,n,a,o){n.child=i===null?ev(n,null,a,o):ya(n,i.child,a,o)}function Zv(i,n,a,o,u){a=a.render;var d=n.ref;if("ref"in o){var _={};for(var C in o)C!=="ref"&&(_[C]=o[C])}else _=o;return ma(n),o=jd(i,n,a,_,d,u),C=Pd(),i!==null&&!vi?(Hd(i,n,u),Kr(i,n,u)):(mt&&C&&vd(n),n.flags|=1,Vi(i,n,o,u),n.child)}function Qv(i,n,a,o,u){if(i===null){var d=a.type;return typeof d=="function"&&!md(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Jv(i,n,d,o,u)):(i=qc(a.type,null,o,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!hf(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:to,a(_,o)&&i.ref===n.ref)return Kr(i,n,u)}return n.flags|=1,i=zr(d,o),i.ref=n.ref,i.return=n,n.child=i}function Jv(i,n,a,o,u){if(i!==null){var d=i.memoizedProps;if(to(d,o)&&i.ref===n.ref)if(vi=!1,n.pendingProps=o=d,hf(i,u))(i.flags&131072)!==0&&(vi=!0);else return n.lanes=i.lanes,Kr(i,n,u)}return rf(i,n,a,o,u)}function ey(i,n,a,o){var u=o.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(o=n.child=i.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~d}else o=0,n.child=null;return ty(i,n,d,a,o)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Xc(n,d!==null?d.cachePool:null),d!==null?nv(n,d):Ld(),rv(n);else return o=n.lanes=536870912,ty(i,n,d!==null?d.baseLanes|a:a,a,o)}else d!==null?(Xc(n,d.cachePool),nv(n,d),xs(),n.memoizedState=null):(i!==null&&Xc(n,null),Ld(),xs());return Vi(i,n,u,a),n.child}function _o(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function ty(i,n,a,o,u){var d=Td();return d=d===null?null:{parent:gi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Xc(n,null),Ld(),rv(n),i!==null&&rl(i,n,o,!0),n.childLanes=u,null}function hu(i,n){return n=fu({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function iy(i,n,a){return ya(n,i.child,null,a),i=hu(n,n.pendingProps),i.flags|=2,Tn(n),n.memoizedState=null,i}function Tx(i,n,a){var o=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(mt){if(o.mode==="hidden")return i=hu(n,o),n.lanes=536870912,_o(null,i);if(Od(n),(i=It)?(i=pb(i,qn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:gs!==null?{id:Cr,overflow:xr}:null,retryLane:536870912,hydrationErrors:null},a=H_(i),a.return=n,n.child=a,qi=n,It=null)):i=null,i===null)throw vs(n);return n.lanes=536870912,null}return hu(n,o)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(Od(n),u)if(n.flags&256)n.flags&=-257,n=iy(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(s(558));else if(vi||rl(i,n,a,!1),u=(a&i.childLanes)!==0,vi||u){if(o=Ot,o!==null&&(_=Gt(o,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,ha(i,_),_n(o,i,_),nf;wu(),n=iy(i,n,a)}else i=d.treeContext,It=Vn(_.nextSibling),qi=n,mt=!0,_s=null,qn=!1,i!==null&&K_(n,i),n=hu(n,o),n.flags|=4096;return n}return i=zr(i.child,{mode:o.mode,children:o.children}),i.ref=n.ref,n.child=i,i.return=n,i}function du(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(s(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function rf(i,n,a,o,u){return ma(n),a=jd(i,n,a,o,void 0,u),o=Pd(),i!==null&&!vi?(Hd(i,n,u),Kr(i,n,u)):(mt&&o&&vd(n),n.flags|=1,Vi(i,n,a,u),n.child)}function ny(i,n,a,o,u,d){return ma(n),n.updateQueue=null,a=av(n,o,a,u),sv(i),o=Pd(),i!==null&&!vi?(Hd(i,n,d),Kr(i,n,d)):(mt&&o&&vd(n),n.flags|=1,Vi(i,n,a,d),n.child)}function ry(i,n,a,o,u){if(ma(n),n.stateNode===null){var d=el,_=a.contextType;typeof _=="object"&&_!==null&&(d=$i(_)),d=new a(o,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=ef,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=o,d.state=n.memoizedState,d.refs={},Rd(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?$i(_):el,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Jd(n,a,_,o),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&&ef.enqueueReplaceState(d,d.state,null),ho(n,o,d,u),uo(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,N=Sa(a,C);d.props=N;var V=d.context,oe=a.contextType;_=el,typeof oe=="object"&&oe!==null&&(_=$i(oe));var ue=a.getDerivedStateFromProps;oe=typeof ue=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,oe||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||V!==_)&&Fv(n,d,o,_),bs=!1;var G=n.memoizedState;d.state=G,ho(n,o,d,u),uo(),V=n.memoizedState,C||G!==V||bs?(typeof ue=="function"&&(Jd(n,a,ue,o),V=n.memoizedState),(N=bs||Wv(n,a,N,o,G,V,_))?(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=o,n.memoizedState=V),d.props=o,d.state=V,d.context=_,o=N):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{d=n.stateNode,Md(i,n),_=n.memoizedProps,oe=Sa(a,_),d.props=oe,ue=n.pendingProps,G=d.context,V=a.contextType,N=el,typeof V=="object"&&V!==null&&(N=$i(V)),C=a.getDerivedStateFromProps,(V=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==ue||G!==N)&&Fv(n,d,o,N),bs=!1,G=n.memoizedState,d.state=G,ho(n,o,d,u),uo();var ee=n.memoizedState;_!==ue||G!==ee||bs||i!==null&&i.dependencies!==null&&Vc(i.dependencies)?(typeof C=="function"&&(Jd(n,a,C,o),ee=n.memoizedState),(oe=bs||Wv(n,a,oe,o,G,ee,N)||i!==null&&i.dependencies!==null&&Vc(i.dependencies))?(V||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(o,ee,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(o,ee,N)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=ee),d.props=o,d.state=ee,d.context=N,o=oe):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=1024),o=!1)}return d=o,du(i,n),o=(n.flags&128)!==0,d||o?(d=n.stateNode,a=o&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&o?(n.child=ya(n,i.child,null,u),n.child=ya(n,null,a,u)):Vi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Kr(i,n,u),i}function sy(i,n,a,o){return fa(),n.flags|=256,Vi(i,n,a,o),n.child}var sf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function af(i){return{baseLanes:i,cachePool:Y_()}}function lf(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=Rn),i}function ay(i,n,a){var o=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(oi.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(mt){if(u?Cs(n):xs(),(i=It)?(i=pb(i,qn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:gs!==null?{id:Cr,overflow:xr}:null,retryLane:536870912,hydrationErrors:null},a=H_(i),a.return=n,n.child=a,qi=n,It=null)):i=null,i===null)throw vs(n);return Wf(i)?n.lanes=32:n.lanes=536870912,null}var C=o.children;return o=o.fallback,u?(xs(),u=n.mode,C=fu({mode:"hidden",children:C},u),o=da(o,u,a,null),C.return=n,o.return=n,C.sibling=o,n.child=C,o=n.child,o.memoizedState=af(a),o.childLanes=lf(i,_,a),n.memoizedState=sf,_o(null,o)):(Cs(n),of(n,C))}var N=i.memoizedState;if(N!==null&&(C=N.dehydrated,C!==null)){if(d)n.flags&256?(Cs(n),n.flags&=-257,n=cf(i,n,a)):n.memoizedState!==null?(xs(),n.child=i.child,n.flags|=128,n=null):(xs(),C=o.fallback,u=n.mode,o=fu({mode:"visible",children:o.children},u),C=da(C,u,a,null),C.flags|=2,o.return=n,C.return=n,o.sibling=C,n.child=o,ya(n,i.child,null,a),o=n.child,o.memoizedState=af(a),o.childLanes=lf(i,_,a),n.memoizedState=sf,n=_o(null,o));else if(Cs(n),Wf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var V=_.dgst;_=V,o=Error(s(419)),o.stack="",o.digest=_,ro({value:o,source:null,stack:null}),n=cf(i,n,a)}else if(vi||rl(i,n,a,!1),_=(a&i.childLanes)!==0,vi||_){if(_=Ot,_!==null&&(o=Gt(_,a),o!==0&&o!==N.retryLane))throw N.retryLane=o,ha(i,o),_n(_,i,o),nf;Kf(C)||wu(),n=cf(i,n,a)}else Kf(C)?(n.flags|=192,n.child=i.child,n=null):(i=N.treeContext,It=Vn(C.nextSibling),qi=n,mt=!0,_s=null,qn=!1,i!==null&&K_(n,i),n=of(n,o.children),n.flags|=4096);return n}return u?(xs(),C=o.fallback,u=n.mode,N=i.child,V=N.sibling,o=zr(N,{mode:"hidden",children:o.children}),o.subtreeFlags=N.subtreeFlags&65011712,V!==null?C=zr(V,C):(C=da(C,u,a,null),C.flags|=2),C.return=n,o.return=n,o.sibling=C,n.child=o,_o(null,o),o=n.child,C=i.child.memoizedState,C===null?C=af(a):(u=C.cachePool,u!==null?(N=gi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=Y_(),C={baseLanes:C.baseLanes|a,cachePool:u}),o.memoizedState=C,o.childLanes=lf(i,_,a),n.memoizedState=sf,_o(i.child,o)):(Cs(n),a=i.child,i=a.sibling,a=zr(a,{mode:"visible",children:o.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 of(i,n){return n=fu({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function fu(i,n){return i=kn(22,i,null,n),i.lanes=0,i}function cf(i,n,a){return ya(n,i.child,null,a),i=of(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function ly(i,n,a){i.lanes|=n;var o=i.alternate;o!==null&&(o.lanes|=n),Cd(i.return,n,a)}function uf(i,n,a,o,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=o,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function oy(i,n,a){var o=n.pendingProps,u=o.revealOrder,d=o.tail;o=o.children;var _=oi.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,de(oi,_),Vi(i,n,o,a),o=mt?no:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&ly(i,a,n);else if(i.tag===19)ly(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&&tu(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),uf(n,!1,u,a,d,o);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&tu(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}uf(n,!0,a,null,d,o);break;case"together":uf(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function Kr(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),Ts|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(rl(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(s(153));if(n.child!==null){for(i=n.child,a=zr(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=zr(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function hf(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Vc(i)))}function Dx(i,n,a){switch(n.tag){case 3:De(n,n.stateNode.containerInfo),ys(n,gi,i.memoizedState.cache),fa();break;case 27:case 5:se(n);break;case 4:De(n,n.stateNode.containerInfo);break;case 10:ys(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Od(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Cs(n),n.flags|=128,null):(a&n.child.childLanes)!==0?ay(i,n,a):(Cs(n),i=Kr(i,n,a),i!==null?i.sibling:null);Cs(n);break;case 19:var u=(i.flags&128)!==0;if(o=(a&n.childLanes)!==0,o||(rl(i,n,a,!1),o=(a&n.childLanes)!==0),u){if(o)return oy(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),de(oi,oi.current),o)break;return null;case 22:return n.lanes=0,ey(i,n,a,n.pendingProps);case 24:ys(n,gi,i.memoizedState.cache)}return Kr(i,n,a)}function cy(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)vi=!0;else{if(!hf(i,a)&&(n.flags&128)===0)return vi=!1,Dx(i,n,a);vi=(i.flags&131072)!==0}else vi=!1,mt&&(n.flags&1048576)!==0&&U_(n,no,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(i=_a(n.elementType),n.type=i,typeof i=="function")md(i)?(o=Sa(i,o),n.tag=1,n=ry(null,n,i,o,a)):(n.tag=0,n=rf(null,n,i,o,a));else{if(i!=null){var u=i.$$typeof;if(u===P){n.tag=11,n=Zv(null,n,i,o,a);break e}else if(u===ie){n.tag=14,n=Qv(null,n,i,o,a);break e}}throw n=j(i)||i,Error(s(306,n,""))}}return n;case 0:return rf(i,n,n.type,n.pendingProps,a);case 1:return o=n.type,u=Sa(o,n.pendingProps),ry(i,n,o,u,a);case 3:e:{if(De(n,n.stateNode.containerInfo),i===null)throw Error(s(387));o=n.pendingProps;var d=n.memoizedState;u=d.element,Md(i,n),ho(n,o,null,a);var _=n.memoizedState;if(o=_.cache,ys(n,gi,o),o!==d.cache&&xd(n,[gi],a,!0),uo(),o=_.element,d.isDehydrated)if(d={element:o,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=sy(i,n,o,a);break e}else if(o!==u){u=Kn(Error(s(424)),n),ro(u),n=sy(i,n,o,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,It=Vn(i.firstChild),qi=n,mt=!0,_s=null,qn=!0,a=ev(n,null,o,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(fa(),o===u){n=Kr(i,n,a);break e}Vi(i,n,o,a)}n=n.child}return n;case 26:return du(i,n),i===null?(a=bb(n.type,null,n.pendingProps,null))?n.memoizedState=a:mt||(a=n.type,i=n.pendingProps,o=Ru(Se.current).createElement(a),o[ii]=n,o[xi]=i,Yi(o,a,i),Bt(o),n.stateNode=o):n.memoizedState=bb(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return se(n),i===null&&mt&&(o=n.stateNode=_b(n.type,n.pendingProps,Se.current),qi=n,qn=!0,u=It,As(n.type)?(Ff=u,It=Vn(o.firstChild)):It=u),Vi(i,n,n.pendingProps.children,a),du(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&mt&&((u=o=It)&&(o=rk(o,n.type,n.pendingProps,qn),o!==null?(n.stateNode=o,qi=n,It=Vn(o.firstChild),qn=!1,u=!0):u=!1),u||vs(n)),se(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,o=d.children,Hf(u,d)?o=null:_!==null&&Hf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=jd(i,n,yx,null,null,a),Ao._currentValue=u),du(i,n),Vi(i,n,o,a),n.child;case 6:return i===null&&mt&&((i=a=It)&&(a=sk(a,n.pendingProps,qn),a!==null?(n.stateNode=a,qi=n,It=null,i=!0):i=!1),i||vs(n)),null;case 13:return ay(i,n,a);case 4:return De(n,n.stateNode.containerInfo),o=n.pendingProps,i===null?n.child=ya(n,null,o,a):Vi(i,n,o,a),n.child;case 11:return Zv(i,n,n.type,n.pendingProps,a);case 7:return Vi(i,n,n.pendingProps,a),n.child;case 8:return Vi(i,n,n.pendingProps.children,a),n.child;case 12:return Vi(i,n,n.pendingProps.children,a),n.child;case 10:return o=n.pendingProps,ys(n,n.type,o.value),Vi(i,n,o.children,a),n.child;case 9:return u=n.type._context,o=n.pendingProps.children,ma(n),u=$i(u),o=o(u),n.flags|=1,Vi(i,n,o,a),n.child;case 14:return Qv(i,n,n.type,n.pendingProps,a);case 15:return Jv(i,n,n.type,n.pendingProps,a);case 19:return oy(i,n,a);case 31:return Tx(i,n,a);case 22:return ey(i,n,a,n.pendingProps);case 24:return ma(n),o=$i(gi),i===null?(u=Td(),u===null&&(u=Ot,d=kd(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:o,cache:u},Rd(n),ys(n,gi,u)):((i.lanes&a)!==0&&(Md(i,n),ho(n,null,null,a),uo()),u=i.memoizedState,d=n.memoizedState,u.parent!==o?(u={parent:o,cache:o},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),ys(n,gi,o)):(o=d.cache,ys(n,gi,o),o!==u.cache&&xd(n,[gi],a,!0))),Vi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function Wr(i){i.flags|=4}function df(i,n,a,o,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(zy())i.flags|=8192;else throw va=Zc,Dd}else i.flags&=-16777217}function uy(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!kb(n))if(zy())i.flags|=8192;else throw va=Zc,Dd}function pu(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?ti():536870912,i.lanes|=n,gl|=n)}function vo(i,n){if(!mt)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 o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:o.sibling=null}}function Ut(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,o=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=o,i.childLanes=a,n}function Rx(i,n,a){var o=n.pendingProps;switch(yd(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ut(n),null;case 1:return Ut(n),null;case 3:return a=n.stateNode,o=null,i!==null&&(o=i.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),Hr(gi),Ue(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(nl(n)?Wr(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Sd())),Ut(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(Wr(n),d!==null?(Ut(n),uy(n,d)):(Ut(n),df(n,u,null,o,a))):d?d!==i.memoizedState?(Wr(n),Ut(n),uy(n,d)):(Ut(n),n.flags&=-16777217):(i=i.memoizedProps,i!==o&&Wr(n),Ut(n),df(n,u,i,o,a)),null;case 27:if(pe(n),a=Se.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==o&&Wr(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return Ut(n),null}i=me.current,nl(n)?W_(n):(i=_b(u,o,a),n.stateNode=i,Wr(n))}return Ut(n),null;case 5:if(pe(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==o&&Wr(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return Ut(n),null}if(d=me.current,nl(n))W_(n);else{var _=Ru(Se.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 o.is=="string"?_.createElement("select",{is:o.is}):_.createElement("select"),o.multiple?d.multiple=!0:o.size&&(d.size=o.size);break;default:d=typeof o.is=="string"?_.createElement(u,{is:o.is}):_.createElement(u)}}d[ii]=n,d[xi]=o;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(Yi(d,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Wr(n)}}return Ut(n),df(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==o&&Wr(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(s(166));if(i=Se.current,nl(n)){if(i=n.stateNode,a=n.memoizedProps,o=null,u=qi,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}i[ii]=n,i=!!(i.nodeValue===a||o!==null&&o.suppressHydrationWarning===!0||ab(i.nodeValue,a)),i||vs(n,!0)}else i=Ru(i).createTextNode(o),i[ii]=n,n.stateNode=i}return Ut(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(o=nl(n),a!==null){if(i===null){if(!o)throw Error(s(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[ii]=n}else fa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ut(n),i=!1}else a=Sd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(Tn(n),n):(Tn(n),null);if((n.flags&128)!==0)throw Error(s(558))}return Ut(n),null;case 13:if(o=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=nl(n),o!==null&&o.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[ii]=n}else fa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ut(n),u=!1}else u=Sd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(Tn(n),n):(Tn(n),null)}return Tn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=o!==null,i=i!==null&&i.memoizedState!==null,a&&(o=n.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),pu(n,n.updateQueue),Ut(n),null);case 4:return Ue(),i===null&&Bf(n.stateNode.containerInfo),Ut(n),null;case 10:return Hr(n.type),Ut(n),null;case 19:if(Q(oi),o=n.memoizedState,o===null)return Ut(n),null;if(u=(n.flags&128)!==0,d=o.rendering,d===null)if(u)vo(o,!1);else{if(ri!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=tu(i),d!==null){for(n.flags|=128,vo(o,!1),i=d.updateQueue,n.updateQueue=i,pu(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)P_(a,i),a=a.sibling;return de(oi,oi.current&1|2),mt&&jr(n,o.treeForkCount),n.child}i=i.sibling}o.tail!==null&&$e()>yu&&(n.flags|=128,u=!0,vo(o,!1),n.lanes=4194304)}else{if(!u)if(i=tu(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,pu(n,i),vo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!d.alternate&&!mt)return Ut(n),null}else 2*$e()-o.renderingStartTime>yu&&a!==536870912&&(n.flags|=128,u=!0,vo(o,!1),n.lanes=4194304);o.isBackwards?(d.sibling=n.child,n.child=d):(i=o.last,i!==null?i.sibling=d:n.child=d,o.last=d)}return o.tail!==null?(i=o.tail,o.rendering=i,o.tail=i.sibling,o.renderingStartTime=$e(),i.sibling=null,a=oi.current,de(oi,u?a&1|2:a&1),mt&&jr(n,o.treeForkCount),i):(Ut(n),null);case 22:case 23:return Tn(n),Bd(),o=n.memoizedState!==null,i!==null?i.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(a&536870912)!==0&&(n.flags&128)===0&&(Ut(n),n.subtreeFlags&6&&(n.flags|=8192)):Ut(n),a=n.updateQueue,a!==null&&pu(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==a&&(n.flags|=2048),i!==null&&Q(ga),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Hr(gi),Ut(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function Mx(i,n){switch(yd(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Hr(gi),Ue(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return pe(n),null;case 31:if(n.memoizedState!==null){if(Tn(n),n.alternate===null)throw Error(s(340));fa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(Tn(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(s(340));fa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return Q(oi),null;case 4:return Ue(),null;case 10:return Hr(n.type),null;case 22:case 23:return Tn(n),Bd(),i!==null&&Q(ga),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Hr(gi),null;case 25:return null;default:return null}}function hy(i,n){switch(yd(n),n.tag){case 3:Hr(gi),Ue();break;case 26:case 27:case 5:pe(n);break;case 4:Ue();break;case 31:n.memoizedState!==null&&Tn(n);break;case 13:Tn(n);break;case 19:Q(oi);break;case 10:Hr(n.type);break;case 22:case 23:Tn(n),Bd(),i!==null&&Q(ga);break;case 24:Hr(gi)}}function yo(i,n){try{var a=n.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&i)===i){o=void 0;var d=a.create,_=a.inst;o=d(),_.destroy=o}a=a.next}while(a!==u)}}catch(C){xt(n,n.return,C)}}function ks(i,n,a){try{var o=n.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var d=u.next;o=d;do{if((o.tag&i)===i){var _=o.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var N=a,V=C;try{V()}catch(oe){xt(u,N,oe)}}}o=o.next}while(o!==d)}}catch(oe){xt(n,n.return,oe)}}function dy(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{iv(n,a)}catch(o){xt(i,i.return,o)}}}function fy(i,n,a){a.props=Sa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(o){xt(i,n,o)}}function bo(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var o=i.stateNode;break;case 30:o=i.stateNode;break;default:o=i.stateNode}typeof a=="function"?i.refCleanup=a(o):a.current=o}}catch(u){xt(i,n,u)}}function kr(i,n){var a=i.ref,o=i.refCleanup;if(a!==null)if(typeof o=="function")try{o()}catch(u){xt(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){xt(i,n,u)}else a.current=null}function py(i){var n=i.type,a=i.memoizedProps,o=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&o.focus();break e;case"img":a.src?o.src=a.src:a.srcSet&&(o.srcset=a.srcSet)}}catch(u){xt(i,i.return,u)}}function ff(i,n,a){try{var o=i.stateNode;Qx(o,i.type,a,n),o[xi]=n}catch(u){xt(i,i.return,u)}}function my(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&As(i.type)||i.tag===4}function pf(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||my(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&&As(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 mf(i,n,a){var o=i.tag;if(o===5||o===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=tn));else if(o!==4&&(o===27&&As(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(mf(i,n,a),i=i.sibling;i!==null;)mf(i,n,a),i=i.sibling}function mu(i,n,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(o!==4&&(o===27&&As(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(mu(i,n,a),i=i.sibling;i!==null;)mu(i,n,a),i=i.sibling}function gy(i){var n=i.stateNode,a=i.memoizedProps;try{for(var o=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Yi(n,o,a),n[ii]=i,n[xi]=a}catch(d){xt(i,i.return,d)}}var Fr=!1,yi=!1,gf=!1,_y=typeof WeakSet=="function"?WeakSet:Set,Oi=null;function Nx(i,n){if(i=i.containerInfo,jf=zu,i=R_(i),od(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var o=a.getSelection&&a.getSelection();if(o&&o.rangeCount!==0){a=o.anchorNode;var u=o.anchorOffset,d=o.focusNode;o=o.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,N=-1,V=0,oe=0,ue=i,G=null;t:for(;;){for(var ee;ue!==a||u!==0&&ue.nodeType!==3||(C=_+u),ue!==d||o!==0&&ue.nodeType!==3||(N=_+o),ue.nodeType===3&&(_+=ue.nodeValue.length),(ee=ue.firstChild)!==null;)G=ue,ue=ee;for(;;){if(ue===i)break t;if(G===a&&++V===u&&(C=_),G===d&&++oe===o&&(N=_),(ee=ue.nextSibling)!==null)break;ue=G,G=ue.parentNode}ue=ee}a=C===-1||N===-1?null:{start:C,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(Pf={focusedElem:i,selectionRange:a},zu=!1,Oi=n;Oi!==null;)if(n=Oi,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Oi=i;else for(;Oi!==null;){switch(n=Oi,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,o=a.stateNode;try{var Oe=Sa(a.type,u);i=o.getSnapshotBeforeUpdate(Oe,d),o.__reactInternalSnapshotBeforeUpdate=i}catch(Ve){xt(a,a.return,Ve)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)Uf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Uf(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=n.sibling,i!==null){i.return=n.return,Oi=i;break}Oi=n.return}}function vy(i,n,a){var o=a.flags;switch(a.tag){case 0:case 11:case 15:$r(i,a),o&4&&yo(5,a);break;case 1:if($r(i,a),o&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){xt(a,a.return,_)}else{var u=Sa(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){xt(a,a.return,_)}}o&64&&dy(a),o&512&&bo(a,a.return);break;case 3:if($r(i,a),o&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{iv(i,n)}catch(_){xt(a,a.return,_)}}break;case 27:n===null&&o&4&&gy(a);case 26:case 5:$r(i,a),n===null&&o&4&&py(a),o&512&&bo(a,a.return);break;case 12:$r(i,a);break;case 31:$r(i,a),o&4&&Sy(i,a);break;case 13:$r(i,a),o&4&&wy(i,a),o&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Ix.bind(null,a),ak(i,a))));break;case 22:if(o=a.memoizedState!==null||Fr,!o){n=n!==null&&n.memoizedState!==null||yi,u=Fr;var d=yi;Fr=o,(yi=n)&&!d?Vr(i,a,(a.subtreeFlags&8772)!==0):$r(i,a),Fr=u,yi=d}break;case 30:break;default:$r(i,a)}}function yy(i){var n=i.alternate;n!==null&&(i.alternate=null,yy(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&ls(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 $t=null,fn=!1;function qr(i,n,a){for(a=a.child;a!==null;)by(i,n,a),a=a.sibling}function by(i,n,a){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Tt,a)}catch{}switch(a.tag){case 26:yi||kr(a,n),qr(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:yi||kr(a,n);var o=$t,u=fn;As(a.type)&&($t=a.stateNode,fn=!1),qr(i,n,a),Ro(a.stateNode),$t=o,fn=u;break;case 5:yi||kr(a,n);case 6:if(o=$t,u=fn,$t=null,qr(i,n,a),$t=o,fn=u,$t!==null)if(fn)try{($t.nodeType===9?$t.body:$t.nodeName==="HTML"?$t.ownerDocument.body:$t).removeChild(a.stateNode)}catch(d){xt(a,n,d)}else try{$t.removeChild(a.stateNode)}catch(d){xt(a,n,d)}break;case 18:$t!==null&&(fn?(i=$t,db(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),xl(i)):db($t,a.stateNode));break;case 4:o=$t,u=fn,$t=a.stateNode.containerInfo,fn=!0,qr(i,n,a),$t=o,fn=u;break;case 0:case 11:case 14:case 15:ks(2,a,n),yi||ks(4,a,n),qr(i,n,a);break;case 1:yi||(kr(a,n),o=a.stateNode,typeof o.componentWillUnmount=="function"&&fy(a,n,o)),qr(i,n,a);break;case 21:qr(i,n,a);break;case 22:yi=(o=yi)||a.memoizedState!==null,qr(i,n,a),yi=o;break;default:qr(i,n,a)}}function Sy(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{xl(i)}catch(a){xt(n,n.return,a)}}}function wy(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{xl(i)}catch(a){xt(n,n.return,a)}}function Ax(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new _y),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new _y),n;default:throw Error(s(435,i.tag))}}function gu(i,n){var a=Ax(i);n.forEach(function(o){if(!a.has(o)){a.add(o);var u=Ux.bind(null,i,o);o.then(u,u)}})}function pn(i,n){var a=n.deletions;if(a!==null)for(var o=0;o<a.length;o++){var u=a[o],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(As(C.type)){$t=C.stateNode,fn=!1;break e}break;case 5:$t=C.stateNode,fn=!1;break e;case 3:case 4:$t=C.stateNode.containerInfo,fn=!0;break e}C=C.return}if($t===null)throw Error(s(160));by(d,_,u),$t=null,fn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Cy(n,i),n=n.sibling}var cr=null;function Cy(i,n){var a=i.alternate,o=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:pn(n,i),mn(i),o&4&&(ks(3,i,i.return),yo(3,i),ks(5,i,i.return));break;case 1:pn(n,i),mn(i),o&512&&(yi||a===null||kr(a,a.return)),o&64&&Fr&&(i=i.updateQueue,i!==null&&(o=i.callbacks,o!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?o:a.concat(o))));break;case 26:var u=cr;if(pn(n,i),mn(i),o&512&&(yi||a===null||kr(a,a.return)),o&4){var d=a!==null?a.memoizedState:null;if(o=i.memoizedState,a===null)if(o===null)if(i.stateNode===null){e:{o=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Lr]||d[ii]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(o),u.head.insertBefore(d,u.querySelector("head > title"))),Yi(d,o,a),d[ii]=i,Bt(d),o=d;break e;case"link":var _=Cb("link","href",u).get(o+(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(o),Yi(d,o,a),u.head.appendChild(d);break;case"meta":if(_=Cb("meta","content",u).get(o+(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(o),Yi(d,o,a),u.head.appendChild(d);break;default:throw Error(s(468,o))}d[ii]=i,Bt(d),o=d}i.stateNode=o}else xb(u,i.type,i.stateNode);else i.stateNode=wb(u,o,i.memoizedProps);else d!==o?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,o===null?xb(u,i.type,i.stateNode):wb(u,o,i.memoizedProps)):o===null&&i.stateNode!==null&&ff(i,i.memoizedProps,a.memoizedProps)}break;case 27:pn(n,i),mn(i),o&512&&(yi||a===null||kr(a,a.return)),a!==null&&o&4&&ff(i,i.memoizedProps,a.memoizedProps);break;case 5:if(pn(n,i),mn(i),o&512&&(yi||a===null||kr(a,a.return)),i.flags&32){u=i.stateNode;try{vr(u,"")}catch(Oe){xt(i,i.return,Oe)}}o&4&&i.stateNode!=null&&(u=i.memoizedProps,ff(i,u,a!==null?a.memoizedProps:u)),o&1024&&(gf=!0);break;case 6:if(pn(n,i),mn(i),o&4){if(i.stateNode===null)throw Error(s(162));o=i.memoizedProps,a=i.stateNode;try{a.nodeValue=o}catch(Oe){xt(i,i.return,Oe)}}break;case 3:if(Au=null,u=cr,cr=Mu(n.containerInfo),pn(n,i),cr=u,mn(i),o&4&&a!==null&&a.memoizedState.isDehydrated)try{xl(n.containerInfo)}catch(Oe){xt(i,i.return,Oe)}gf&&(gf=!1,xy(i));break;case 4:o=cr,cr=Mu(i.stateNode.containerInfo),pn(n,i),mn(i),cr=o;break;case 12:pn(n,i),mn(i);break;case 31:pn(n,i),mn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,gu(i,o)));break;case 13:pn(n,i),mn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(vu=$e()),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,gu(i,o)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,V=Fr,oe=yi;if(Fr=V||u,yi=oe||N,pn(n,i),yi=oe,Fr=V,mn(i),o&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||N||Fr||yi||wa(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 ue=N.memoizedProps.style,G=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;C.style.display=G==null||typeof G=="boolean"?"":(""+G).trim()}}catch(Oe){xt(N,N.return,Oe)}}}else if(n.tag===6){if(a===null){N=n;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Oe){xt(N,N.return,Oe)}}}else if(n.tag===18){if(a===null){N=n;try{var ee=N.stateNode;u?fb(ee,!0):fb(N.stateNode,!1)}catch(Oe){xt(N,N.return,Oe)}}}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}o&4&&(o=i.updateQueue,o!==null&&(a=o.retryQueue,a!==null&&(o.retryQueue=null,gu(i,a))));break;case 19:pn(n,i),mn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,gu(i,o)));break;case 30:break;case 21:break;default:pn(n,i),mn(i)}}function mn(i){var n=i.flags;if(n&2){try{for(var a,o=i.return;o!==null;){if(my(o)){a=o;break}o=o.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,d=pf(i);mu(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(vr(_,""),a.flags&=-33);var C=pf(i);mu(i,C,_);break;case 3:case 4:var N=a.stateNode.containerInfo,V=pf(i);mf(i,V,N);break;default:throw Error(s(161))}}catch(oe){xt(i,i.return,oe)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function xy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;xy(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function $r(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)vy(i,n.alternate,n),n=n.sibling}function wa(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:ks(4,n,n.return),wa(n);break;case 1:kr(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&fy(n,n.return,a),wa(n);break;case 27:Ro(n.stateNode);case 26:case 5:kr(n,n.return),wa(n);break;case 22:n.memoizedState===null&&wa(n);break;case 30:wa(n);break;default:wa(n)}i=i.sibling}}function Vr(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Vr(u,d,a),yo(4,d);break;case 1:if(Vr(u,d,a),o=d,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(V){xt(o,o.return,V)}if(o=d,u=o.updateQueue,u!==null){var C=o.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)tv(N[u],C)}catch(V){xt(o,o.return,V)}}a&&_&64&&dy(d),bo(d,d.return);break;case 27:gy(d);case 26:case 5:Vr(u,d,a),a&&o===null&&_&4&&py(d),bo(d,d.return);break;case 12:Vr(u,d,a);break;case 31:Vr(u,d,a),a&&_&4&&Sy(u,d);break;case 13:Vr(u,d,a),a&&_&4&&wy(u,d);break;case 22:d.memoizedState===null&&Vr(u,d,a),bo(d,d.return);break;case 30:break;default:Vr(u,d,a)}n=n.sibling}}function _f(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&&so(a))}function vf(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&so(i))}function ur(i,n,a,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)ky(i,n,a,o),n=n.sibling}function ky(i,n,a,o){var u=n.flags;switch(n.tag){case 0:case 11:case 15:ur(i,n,a,o),u&2048&&yo(9,n);break;case 1:ur(i,n,a,o);break;case 3:ur(i,n,a,o),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&so(i)));break;case 12:if(u&2048){ur(i,n,a,o),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){xt(n,n.return,N)}}else ur(i,n,a,o);break;case 31:ur(i,n,a,o);break;case 13:ur(i,n,a,o);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?ur(i,n,a,o):So(i,n):d._visibility&2?ur(i,n,a,o):(d._visibility|=2,fl(i,n,a,o,(n.subtreeFlags&10256)!==0||!1)),u&2048&&_f(_,n);break;case 24:ur(i,n,a,o),u&2048&&vf(n.alternate,n);break;default:ur(i,n,a,o)}}function fl(i,n,a,o,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,N=o,V=_.flags;switch(_.tag){case 0:case 11:case 15:fl(d,_,C,N,u),yo(8,_);break;case 23:break;case 22:var oe=_.stateNode;_.memoizedState!==null?oe._visibility&2?fl(d,_,C,N,u):So(d,_):(oe._visibility|=2,fl(d,_,C,N,u)),u&&V&2048&&_f(_.alternate,_);break;case 24:fl(d,_,C,N,u),u&&V&2048&&vf(_.alternate,_);break;default:fl(d,_,C,N,u)}n=n.sibling}}function So(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,o=n,u=o.flags;switch(o.tag){case 22:So(a,o),u&2048&&_f(o.alternate,o);break;case 24:So(a,o),u&2048&&vf(o.alternate,o);break;default:So(a,o)}n=n.sibling}}var wo=8192;function pl(i,n,a){if(i.subtreeFlags&wo)for(i=i.child;i!==null;)Ey(i,n,a),i=i.sibling}function Ey(i,n,a){switch(i.tag){case 26:pl(i,n,a),i.flags&wo&&i.memoizedState!==null&&vk(a,cr,i.memoizedState,i.memoizedProps);break;case 5:pl(i,n,a);break;case 3:case 4:var o=cr;cr=Mu(i.stateNode.containerInfo),pl(i,n,a),cr=o;break;case 22:i.memoizedState===null&&(o=i.alternate,o!==null&&o.memoizedState!==null?(o=wo,wo=16777216,pl(i,n,a),wo=o):pl(i,n,a));break;default:pl(i,n,a)}}function Ty(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 Co(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var o=n[a];Oi=o,Ry(o,i)}Ty(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Dy(i),i=i.sibling}function Dy(i){switch(i.tag){case 0:case 11:case 15:Co(i),i.flags&2048&&ks(9,i,i.return);break;case 3:Co(i);break;case 12:Co(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,_u(i)):Co(i);break;default:Co(i)}}function _u(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var o=n[a];Oi=o,Ry(o,i)}Ty(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:ks(8,n,n.return),_u(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,_u(n));break;default:_u(n)}i=i.sibling}}function Ry(i,n){for(;Oi!==null;){var a=Oi;switch(a.tag){case 0:case 11:case 15:ks(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var o=a.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:so(a.memoizedState.cache)}if(o=a.child,o!==null)o.return=a,Oi=o;else e:for(a=i;Oi!==null;){o=Oi;var u=o.sibling,d=o.return;if(yy(o),o===a){Oi=null;break e}if(u!==null){u.return=d,Oi=u;break e}Oi=d}}}var Lx={getCacheForType:function(i){var n=$i(gi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return $i(gi).controller.signal}},Bx=typeof WeakMap=="function"?WeakMap:Map,bt=0,Ot=null,ut=null,ft=0,Ct=0,Dn=null,Es=!1,ml=!1,yf=!1,Yr=0,ri=0,Ts=0,Ca=0,bf=0,Rn=0,gl=0,xo=null,gn=null,Sf=!1,vu=0,My=0,yu=1/0,bu=null,Ds=null,Ei=0,Rs=null,_l=null,Xr=0,wf=0,Cf=null,Ny=null,ko=0,xf=null;function Mn(){return(bt&2)!==0&&ft!==0?ft&-ft:R.T!==null?Mf():Qi()}function Ay(){if(Rn===0)if((ft&536870912)===0||mt){var i=Ci;Ci<<=1,(Ci&3932160)===0&&(Ci=262144),Rn=i}else Rn=536870912;return i=En.current,i!==null&&(i.flags|=32),Rn}function _n(i,n,a){(i===Ot&&(Ct===2||Ct===9)||i.cancelPendingCommit!==null)&&(vl(i,0),Ms(i,ft,Rn,!1)),Xt(i,a),((bt&2)===0||i!==Ot)&&(i===Ot&&((bt&2)===0&&(Ca|=a),ri===4&&Ms(i,ft,Rn,!1)),Er(i))}function Ly(i,n,a){if((bt&6)!==0)throw Error(s(327));var o=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Ft(i,n),u=o?jx(i,n):Ef(i,n,!0),d=o;do{if(u===0){ml&&!o&&Ms(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!Ox(a)){u=Ef(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=xo;var N=C.current.memoizedState.isDehydrated;if(N&&(vl(C,_).flags|=256),_=Ef(C,_,!1),_!==2){if(yf&&!N){C.errorRecoveryDisabledLanes|=d,Ca|=d,u=4;break e}d=gn,gn=u,d!==null&&(gn===null?gn=d:gn.push.apply(gn,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){vl(i,0),Ms(i,n,0,!0);break}e:{switch(o=i,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:Ms(o,n,Rn,!Es);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(u=vu+300-$e(),10<u)){if(Ms(o,n,Rn,!Es),Yt(o,0,!0)!==0)break e;Xr=n,o.timeoutHandle=ub(By.bind(null,o,a,gn,bu,Sf,n,Rn,Ca,gl,Es,d,"Throttled",-0,0),u);break e}By(o,a,gn,bu,Sf,n,Rn,Ca,gl,Es,d,null,-0,0)}}break}while(!0);Er(i)}function By(i,n,a,o,u,d,_,C,N,V,oe,ue,G,ee){if(i.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:tn},Ey(n,d,ue);var Oe=(d&62914560)===d?vu-$e():(d&4194048)===d?My-$e():0;if(Oe=yk(ue,Oe),Oe!==null){Xr=d,i.cancelPendingCommit=Oe(Ky.bind(null,i,n,d,a,o,u,_,C,N,oe,ue,null,G,ee)),Ms(i,d,_,!V);return}}Ky(i,n,d,a,o,u,_,C,N)}function Ox(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 o=0;o<a.length;o++){var u=a[o],d=u.getSnapshot;u=u.value;try{if(!xn(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 Ms(i,n,a,o){n&=~bf,n&=~Ca,i.suspendedLanes|=n,i.pingedLanes&=~n,o&&(i.warmLanes|=n),o=i.expirationTimes;for(var u=n;0<u;){var d=31-F(u),_=1<<d;o[d]=-1,u&=~_}a!==0&&Wi(i,a,n)}function Su(){return(bt&6)===0?(Eo(0),!1):!0}function kf(){if(ut!==null){if(Ct===0)var i=ut.return;else i=ut,Pr=pa=null,Id(i),ol=null,lo=0,i=ut;for(;i!==null;)hy(i.alternate,i),i=i.return;ut=null}}function vl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,tk(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Xr=0,kf(),Ot=i,ut=a=zr(i.current,null),ft=n,Ct=0,Dn=null,Es=!1,ml=Ft(i,n),yf=!1,gl=Rn=bf=Ca=Ts=ri=0,gn=xo=null,Sf=!1,(n&8)!==0&&(n|=n&32);var o=i.entangledLanes;if(o!==0)for(i=i.entanglements,o&=n;0<o;){var u=31-F(o),d=1<<u;n|=i[u],o&=~d}return Yr=n,Kc(),a}function Oy(i,n){et=null,R.H=go,n===ll||n===Gc?(n=Z_(),Ct=3):n===Dd?(n=Z_(),Ct=4):Ct=n===nf?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Dn=n,ut===null&&(ri=1,uu(i,Kn(n,i.current)))}function zy(){var i=En.current;return i===null?!0:(ft&4194048)===ft?$n===null:(ft&62914560)===ft||(ft&536870912)!==0?i===$n:!1}function jy(){var i=R.H;return R.H=go,i===null?go:i}function Py(){var i=R.A;return R.A=Lx,i}function wu(){ri=4,Es||(ft&4194048)!==ft&&En.current!==null||(ml=!0),(Ts&134217727)===0&&(Ca&134217727)===0||Ot===null||Ms(Ot,ft,Rn,!1)}function Ef(i,n,a){var o=bt;bt|=2;var u=jy(),d=Py();(Ot!==i||ft!==n)&&(bu=null,vl(i,n)),n=!1;var _=ri;e:do try{if(Ct!==0&&ut!==null){var C=ut,N=Dn;switch(Ct){case 8:kf(),_=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(n=!0);var V=Ct;if(Ct=0,Dn=null,yl(i,C,N,V),a&&ml){_=0;break e}break;default:V=Ct,Ct=0,Dn=null,yl(i,C,N,V)}}zx(),_=ri;break}catch(oe){Oy(i,oe)}while(!0);return n&&i.shellSuspendCounter++,Pr=pa=null,bt=o,R.H=u,R.A=d,ut===null&&(Ot=null,ft=0,Kc()),_}function zx(){for(;ut!==null;)Hy(ut)}function jx(i,n){var a=bt;bt|=2;var o=jy(),u=Py();Ot!==i||ft!==n?(bu=null,yu=$e()+500,vl(i,n)):ml=Ft(i,n);e:do try{if(Ct!==0&&ut!==null){n=ut;var d=Dn;t:switch(Ct){case 1:Ct=0,Dn=null,yl(i,n,d,1);break;case 2:case 9:if(X_(d)){Ct=0,Dn=null,Iy(n);break}n=function(){Ct!==2&&Ct!==9||Ot!==i||(Ct=7),Er(i)},d.then(n,n);break e;case 3:Ct=7;break e;case 4:Ct=5;break e;case 7:X_(d)?(Ct=0,Dn=null,Iy(n)):(Ct=0,Dn=null,yl(i,n,d,7));break;case 5:var _=null;switch(ut.tag){case 26:_=ut.memoizedState;case 5:case 27:var C=ut;if(_?kb(_):C.stateNode.complete){Ct=0,Dn=null;var N=C.sibling;if(N!==null)ut=N;else{var V=C.return;V!==null?(ut=V,Cu(V)):ut=null}break t}}Ct=0,Dn=null,yl(i,n,d,5);break;case 6:Ct=0,Dn=null,yl(i,n,d,6);break;case 8:kf(),ri=6;break e;default:throw Error(s(462))}}Px();break}catch(oe){Oy(i,oe)}while(!0);return Pr=pa=null,R.H=o,R.A=u,bt=a,ut!==null?0:(Ot=null,ft=0,Kc(),ri)}function Px(){for(;ut!==null&&!at();)Hy(ut)}function Hy(i){var n=cy(i.alternate,i,Yr);i.memoizedProps=i.pendingProps,n===null?Cu(i):ut=n}function Iy(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=ny(a,n,n.pendingProps,n.type,void 0,ft);break;case 11:n=ny(a,n,n.pendingProps,n.type.render,n.ref,ft);break;case 5:Id(n);default:hy(a,n),n=ut=P_(n,Yr),n=cy(a,n,Yr)}i.memoizedProps=i.pendingProps,n===null?Cu(i):ut=n}function yl(i,n,a,o){Pr=pa=null,Id(n),ol=null,lo=0;var u=n.return;try{if(Ex(i,u,n,a,ft)){ri=1,uu(i,Kn(a,i.current)),ut=null;return}}catch(d){if(u!==null)throw ut=u,d;ri=1,uu(i,Kn(a,i.current)),ut=null;return}n.flags&32768?(mt||o===1?i=!0:ml||(ft&536870912)!==0?i=!1:(Es=i=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),Uy(n,i)):Cu(n)}function Cu(i){var n=i;do{if((n.flags&32768)!==0){Uy(n,Es);return}i=n.return;var a=Rx(n.alternate,n,Yr);if(a!==null){ut=a;return}if(n=n.sibling,n!==null){ut=n;return}ut=n=i}while(n!==null);ri===0&&(ri=5)}function Uy(i,n){do{var a=Mx(i.alternate,i);if(a!==null){a.flags&=32767,ut=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){ut=i;return}ut=i=a}while(i!==null);ri=6,ut=null}function Ky(i,n,a,o,u,d,_,C,N){i.cancelPendingCommit=null;do xu();while(Ei!==0);if((bt&6)!==0)throw Error(s(327));if(n!==null){if(n===i.current)throw Error(s(177));if(d=n.lanes|n.childLanes,d|=fd,qt(i,a,d,_,C,N),i===Ot&&(ut=Ot=null,ft=0),_l=n,Rs=i,Xr=a,wf=d,Cf=u,Ny=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Kx(_e,function(){return Vy(),null})):(i.callbackNode=null,i.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=R.T,R.T=null,u=X.p,X.p=2,_=bt,bt|=4;try{Nx(i,n,a)}finally{bt=_,X.p=u,R.T=o}}Ei=1,Wy(),Fy(),qy()}}function Wy(){if(Ei===1){Ei=0;var i=Rs,n=_l,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=bt;bt|=4;try{Cy(n,i);var d=Pf,_=R_(i.containerInfo),C=d.focusedElem,N=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&D_(C.ownerDocument.documentElement,C)){if(N!==null&&od(C)){var V=N.start,oe=N.end;if(oe===void 0&&(oe=V),"selectionStart"in C)C.selectionStart=V,C.selectionEnd=Math.min(oe,C.value.length);else{var ue=C.ownerDocument||document,G=ue&&ue.defaultView||window;if(G.getSelection){var ee=G.getSelection(),Oe=C.textContent.length,Ve=Math.min(N.start,Oe),Nt=N.end===void 0?Ve:Math.min(N.end,Oe);!ee.extend&&Ve>Nt&&(_=Nt,Nt=Ve,Ve=_);var I=T_(C,Ve),O=T_(C,Nt);if(I&&O&&(ee.rangeCount!==1||ee.anchorNode!==I.node||ee.anchorOffset!==I.offset||ee.focusNode!==O.node||ee.focusOffset!==O.offset)){var $=ue.createRange();$.setStart(I.node,I.offset),ee.removeAllRanges(),Ve>Nt?(ee.addRange($),ee.extend(O.node,O.offset)):($.setEnd(O.node,O.offset),ee.addRange($))}}}}for(ue=[],ee=C;ee=ee.parentNode;)ee.nodeType===1&&ue.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<ue.length;C++){var ce=ue[C];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}zu=!!jf,Pf=jf=null}finally{bt=u,X.p=o,R.T=a}}i.current=n,Ei=2}}function Fy(){if(Ei===2){Ei=0;var i=Rs,n=_l,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=bt;bt|=4;try{vy(i,n.alternate,n)}finally{bt=u,X.p=o,R.T=a}}Ei=3}}function qy(){if(Ei===4||Ei===3){Ei=0,Wt();var i=Rs,n=_l,a=Xr,o=Ny;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ei=5:(Ei=0,_l=Rs=null,$y(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(Ds=null),Zi(a),n=n.stateNode,Lt&&typeof Lt.onCommitFiberRoot=="function")try{Lt.onCommitFiberRoot(Tt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=R.T,u=X.p,X.p=2,R.T=null;try{for(var d=i.onRecoverableError,_=0;_<o.length;_++){var C=o[_];d(C.value,{componentStack:C.stack})}}finally{R.T=n,X.p=u}}(Xr&3)!==0&&xu(),Er(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===xf?ko++:(ko=0,xf=i):ko=0,Eo(0)}}function $y(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,so(n)))}function xu(){return Wy(),Fy(),qy(),Vy()}function Vy(){if(Ei!==5)return!1;var i=Rs,n=wf;wf=0;var a=Zi(Xr),o=R.T,u=X.p;try{X.p=32>a?32:a,R.T=null,a=Cf,Cf=null;var d=Rs,_=Xr;if(Ei=0,_l=Rs=null,Xr=0,(bt&6)!==0)throw Error(s(331));var C=bt;if(bt|=4,Dy(d.current),ky(d,d.current,_,a),bt=C,Eo(0,!1),Lt&&typeof Lt.onPostCommitFiberRoot=="function")try{Lt.onPostCommitFiberRoot(Tt,d)}catch{}return!0}finally{X.p=u,R.T=o,$y(i,n)}}function Yy(i,n,a){n=Kn(a,n),n=tf(i.stateNode,n,2),i=ws(i,n,2),i!==null&&(Xt(i,2),Er(i))}function xt(i,n,a){if(i.tag===3)Yy(i,i,a);else for(;n!==null;){if(n.tag===3){Yy(n,i,a);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ds===null||!Ds.has(o))){i=Kn(a,i),a=Xv(2),o=ws(n,a,2),o!==null&&(Gv(a,o,n,i),Xt(o,2),Er(o));break}}n=n.return}}function Tf(i,n,a){var o=i.pingCache;if(o===null){o=i.pingCache=new Bx;var u=new Set;o.set(n,u)}else u=o.get(n),u===void 0&&(u=new Set,o.set(n,u));u.has(a)||(yf=!0,u.add(a),i=Hx.bind(null,i,n,a),n.then(i,i))}function Hx(i,n,a){var o=i.pingCache;o!==null&&o.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Ot===i&&(ft&a)===a&&(ri===4||ri===3&&(ft&62914560)===ft&&300>$e()-vu?(bt&2)===0&&vl(i,0):bf|=a,gl===ft&&(gl=0)),Er(i)}function Xy(i,n){n===0&&(n=ti()),i=ha(i,n),i!==null&&(Xt(i,n),Er(i))}function Ix(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),Xy(i,a)}function Ux(i,n){var a=0;switch(i.tag){case 31:case 13:var o=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:o=i.stateNode;break;case 22:o=i.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(n),Xy(i,a)}function Kx(i,n){return Be(i,n)}var ku=null,bl=null,Df=!1,Eu=!1,Rf=!1,Ns=0;function Er(i){i!==bl&&i.next===null&&(bl===null?ku=bl=i:bl=bl.next=i),Eu=!0,Df||(Df=!0,Fx())}function Eo(i,n){if(!Rf&&Eu){Rf=!0;do for(var a=!1,o=ku;o!==null;){if(i!==0){var u=o.pendingLanes;if(u===0)var d=0;else{var _=o.suspendedLanes,C=o.pingedLanes;d=(1<<31-F(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Jy(o,d))}else d=ft,d=Yt(o,o===Ot?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(d&3)===0||Ft(o,d)||(a=!0,Jy(o,d));o=o.next}while(a);Rf=!1}}function Wx(){Gy()}function Gy(){Eu=Df=!1;var i=0;Ns!==0&&ek()&&(i=Ns);for(var n=$e(),a=null,o=ku;o!==null;){var u=o.next,d=Zy(o,n);d===0?(o.next=null,a===null?ku=u:a.next=u,u===null&&(bl=a)):(a=o,(i!==0||(d&3)!==0)&&(Eu=!0)),o=u}Ei!==0&&Ei!==5||Eo(i),Ns!==0&&(Ns=0)}function Zy(i,n){for(var a=i.suspendedLanes,o=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-F(d),C=1<<_,N=u[_];N===-1?((C&a)===0||(C&o)!==0)&&(u[_]=Ai(C,n)):N<=n&&(i.expiredLanes|=C),d&=~C}if(n=Ot,a=ft,a=Yt(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o=i.callbackNode,a===0||i===n&&(Ct===2||Ct===9)||i.cancelPendingCommit!==null)return o!==null&&o!==null&&je(o),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Ft(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(o!==null&&je(o),Zi(a)){case 2:case 8:a=Et;break;case 32:a=_e;break;case 268435456:a=Je;break;default:a=_e}return o=Qy.bind(null,i),a=Be(a,o),i.callbackPriority=n,i.callbackNode=a,n}return o!==null&&o!==null&&je(o),i.callbackPriority=2,i.callbackNode=null,2}function Qy(i,n){if(Ei!==0&&Ei!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(xu()&&i.callbackNode!==a)return null;var o=ft;return o=Yt(i,i===Ot?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o===0?null:(Ly(i,o,n),Zy(i,$e()),i.callbackNode!=null&&i.callbackNode===a?Qy.bind(null,i):null)}function Jy(i,n){if(xu())return null;Ly(i,n,!0)}function Fx(){ik(function(){(bt&6)!==0?Be(ei,Wx):Gy()})}function Mf(){if(Ns===0){var i=sl;i===0&&(i=Gi,Gi<<=1,(Gi&261888)===0&&(Gi=256)),Ns=i}return Ns}function eb(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Hn(""+i)}function tb(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 qx(i,n,a,o,u){if(n==="submit"&&a&&a.stateNode===u){var d=eb((u[xi]||null).action),_=o.submitter;_&&(n=(n=_[xi]||null)?eb(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new qe("action","action",null,o,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Ns!==0){var N=_?tb(u,_):new FormData(u);Xd(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(C.preventDefault(),N=_?tb(u,_):new FormData(u),Xd(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var Nf=0;Nf<dd.length;Nf++){var Af=dd[Nf],$x=Af.toLowerCase(),Vx=Af[0].toUpperCase()+Af.slice(1);or($x,"on"+Vx)}or(A_,"onAnimationEnd"),or(L_,"onAnimationIteration"),or(B_,"onAnimationStart"),or("dblclick","onDoubleClick"),or("focusin","onFocus"),or("focusout","onBlur"),or(cx,"onTransitionRun"),or(ux,"onTransitionStart"),or(hx,"onTransitionCancel"),or(O_,"onTransitionEnd"),ir("onMouseEnter",["mouseout","mouseover"]),ir("onMouseLeave",["mouseout","mouseover"]),ir("onPointerEnter",["pointerout","pointerover"]),ir("onPointerLeave",["pointerout","pointerover"]),tr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tr("onBeforeInput",["compositionend","keypress","textInput","paste"]),tr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var To="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(" "),Yx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(To));function ib(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var o=i[a],u=o.event;o=o.listeners;e:{var d=void 0;if(n)for(var _=o.length-1;0<=_;_--){var C=o[_],N=C.instance,V=C.currentTarget;if(C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(oe){Uc(oe)}u.currentTarget=null,d=N}else for(_=0;_<o.length;_++){if(C=o[_],N=C.instance,V=C.currentTarget,C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(oe){Uc(oe)}u.currentTarget=null,d=N}}}}function ht(i,n){var a=n[ss];a===void 0&&(a=n[ss]=new Set);var o=i+"__bubble";a.has(o)||(nb(n,i,2,!1),a.add(o))}function Lf(i,n,a){var o=0;n&&(o|=4),nb(a,i,o,n)}var Tu="_reactListening"+Math.random().toString(36).slice(2);function Bf(i){if(!i[Tu]){i[Tu]=!0,$a.forEach(function(a){a!=="selectionchange"&&(Yx.has(a)||Lf(a,!1,i),Lf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[Tu]||(n[Tu]=!0,Lf("selectionchange",!1,n))}}function nb(i,n,a,o){switch(Ab(n)){case 2:var u=wk;break;case 8:u=Ck;break;default:u=Xf}a=u.bind(null,n,a,i),u=void 0,!wr||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),o?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 Of(i,n,a,o,u){var d=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var _=o.tag;if(_===3||_===4){var C=o.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=o.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=On(C),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){o=d=_;continue e}C=C.parentNode}}o=o.return}Xa(function(){var V=d,oe=br(a),ue=[];e:{var G=z_.get(i);if(G!==void 0){var ee=qe,Oe=i;switch(i){case"keypress":if(z(a)===0)break e;case"keydown":case"keyup":ee=Hc;break;case"focusin":Oe="focus",ee=Ye;break;case"focusout":Oe="blur",ee=Ye;break;case"beforeblur":case"afterblur":ee=Ye;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":ee=zc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=J;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=FC;break;case A_:case L_:case B_:ee=dt;break;case O_:ee=$C;break;case"scroll":case"scrollend":ee=fi;break;case"wheel":ee=YC;break;case"copy":case"cut":case"paste":ee=rn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=f_;break;case"toggle":case"beforetoggle":ee=GC}var Ve=(n&4)!==0,Nt=!Ve&&(i==="scroll"||i==="scrollend"),I=Ve?G!==null?G+"Capture":null:G;Ve=[];for(var O=V,$;O!==null;){var ce=O;if($=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||$===null||I===null||(ce=lr(O,I),ce!=null&&Ve.push(Do(O,ce,$))),Nt)break;O=O.return}0<Ve.length&&(G=new ee(G,Oe,null,a,oe),ue.push({event:G,listeners:Ve}))}}if((n&7)===0){e:{if(G=i==="mouseover"||i==="pointerover",ee=i==="mouseout"||i==="pointerout",G&&a!==Or&&(Oe=a.relatedTarget||a.fromElement)&&(On(Oe)||Oe[Sn]))break e;if((ee||G)&&(G=oe.window===oe?oe:(G=oe.ownerDocument)?G.defaultView||G.parentWindow:window,ee?(Oe=a.relatedTarget||a.toElement,ee=V,Oe=Oe?On(Oe):null,Oe!==null&&(Nt=c(Oe),Ve=Oe.tag,Oe!==Nt||Ve!==5&&Ve!==27&&Ve!==6)&&(Oe=null)):(ee=null,Oe=V),ee!==Oe)){if(Ve=zc,ce="onMouseLeave",I="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(Ve=f_,ce="onPointerLeave",I="onPointerEnter",O="pointer"),Nt=ee==null?G:gr(ee),$=Oe==null?G:gr(Oe),G=new Ve(ce,O+"leave",ee,a,oe),G.target=Nt,G.relatedTarget=$,ce=null,On(oe)===V&&(Ve=new Ve(I,O+"enter",Oe,a,oe),Ve.target=$,Ve.relatedTarget=Nt,ce=Ve),Nt=ce,ee&&Oe)t:{for(Ve=Xx,I=ee,O=Oe,$=0,ce=I;ce;ce=Ve(ce))$++;ce=0;for(var Fe=O;Fe;Fe=Ve(Fe))ce++;for(;0<$-ce;)I=Ve(I),$--;for(;0<ce-$;)O=Ve(O),ce--;for(;$--;){if(I===O||O!==null&&I===O.alternate){Ve=I;break t}I=Ve(I),O=Ve(O)}Ve=null}else Ve=null;ee!==null&&rb(ue,G,ee,Ve,!1),Oe!==null&&Nt!==null&&rb(ue,Nt,Oe,Ve,!0)}}e:{if(G=V?gr(V):window,ee=G.nodeName&&G.nodeName.toLowerCase(),ee==="select"||ee==="input"&&G.type==="file")var vt=S_;else if(y_(G))if(w_)vt=ax;else{vt=rx;var He=nx}else ee=G.nodeName,!ee||ee.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?V&&yr(V.elementType)&&(vt=S_):vt=sx;if(vt&&(vt=vt(i,V))){b_(ue,vt,a,oe);break e}He&&He(i,G,V),i==="focusout"&&V&&G.type==="number"&&V.memoizedProps.value!=null&&us(G,"number",G.value)}switch(He=V?gr(V):window,i){case"focusin":(y_(He)||He.contentEditable==="true")&&(Za=He,cd=V,io=null);break;case"focusout":io=cd=Za=null;break;case"mousedown":ud=!0;break;case"contextmenu":case"mouseup":case"dragend":ud=!1,M_(ue,a,oe);break;case"selectionchange":if(ox)break;case"keydown":case"keyup":M_(ue,a,oe)}var rt;if(sd)e:{switch(i){case"compositionstart":var pt="onCompositionStart";break e;case"compositionend":pt="onCompositionEnd";break e;case"compositionupdate":pt="onCompositionUpdate";break e}pt=void 0}else Ga?__(i,a)&&(pt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(pt="onCompositionStart");pt&&(p_&&a.locale!=="ko"&&(Ga||pt!=="onCompositionStart"?pt==="onCompositionEnd"&&Ga&&(rt=T()):(nn=oe,fs="value"in nn?nn.value:nn.textContent,Ga=!0)),He=Du(V,pt),0<He.length&&(pt=new mi(pt,i,null,a,oe),ue.push({event:pt,listeners:He}),rt?pt.data=rt:(rt=v_(a),rt!==null&&(pt.data=rt)))),(rt=QC?JC(i,a):ex(i,a))&&(pt=Du(V,"onBeforeInput"),0<pt.length&&(He=new mi("onBeforeInput","beforeinput",null,a,oe),ue.push({event:He,listeners:pt}),He.data=rt)),qx(ue,i,V,a,oe)}ib(ue,n)})}function Do(i,n,a){return{instance:i,listener:n,currentTarget:a}}function Du(i,n){for(var a=n+"Capture",o=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=lr(i,a),u!=null&&o.unshift(Do(i,u,d)),u=lr(i,n),u!=null&&o.push(Do(i,u,d))),i.tag===3)return o;i=i.return}return[]}function Xx(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function rb(i,n,a,o,u){for(var d=n._reactName,_=[];a!==null&&a!==o;){var C=a,N=C.alternate,V=C.stateNode;if(C=C.tag,N!==null&&N===o)break;C!==5&&C!==26&&C!==27||V===null||(N=V,u?(V=lr(a,d),V!=null&&_.unshift(Do(a,V,N))):u||(V=lr(a,d),V!=null&&_.push(Do(a,V,N)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var Gx=/\r\n?/g,Zx=/\u0000|\uFFFD/g;function sb(i){return(typeof i=="string"?i:""+i).replace(Gx,`
|
|
10
|
-
`).replace(Zx,"")}function ab(i,n){return n=sb(n),sb(i)===n}function Mt(i,n,a,o,u,d){switch(a){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||vr(i,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&vr(i,""+o);break;case"className":cs(i,"class",o);break;case"tabIndex":cs(i,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":cs(i,a,o);break;case"style":hs(i,o,d);break;case"data":if(n!=="object"){cs(i,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Hn(""+o),i.setAttribute(a,o);break;case"action":case"formAction":if(typeof o=="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"&&Mt(i,n,"name",u.name,u,null),Mt(i,n,"formEncType",u.formEncType,u,null),Mt(i,n,"formMethod",u.formMethod,u,null),Mt(i,n,"formTarget",u.formTarget,u,null)):(Mt(i,n,"encType",u.encType,u,null),Mt(i,n,"method",u.method,u,null),Mt(i,n,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=Hn(""+o),i.setAttribute(a,o);break;case"onClick":o!=null&&(i.onclick=tn);break;case"onScroll":o!=null&&ht("scroll",i);break;case"onScrollEnd":o!=null&&ht("scrollend",i);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":i.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){i.removeAttribute("xlink:href");break}a=Hn(""+o),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":o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""+o):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":o&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":o===!0?i.setAttribute(a,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,o):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?i.setAttribute(a,o):i.removeAttribute(a);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?i.removeAttribute(a):i.setAttribute(a,o);break;case"popover":ht("beforetoggle",i),ht("toggle",i),os(i,"popover",o);break;case"xlinkActuate":Fi(i,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Fi(i,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Fi(i,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Fi(i,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Fi(i,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Fi(i,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Fi(i,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Fi(i,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Fi(i,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":os(i,"is",o);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=aa.get(a)||a,os(i,a,o))}}function zf(i,n,a,o,u,d){switch(a){case"style":hs(i,o,d);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof o=="string"?vr(i,o):(typeof o=="number"||typeof o=="bigint")&&vr(i,""+o);break;case"onScroll":o!=null&&ht("scroll",i);break;case"onScrollEnd":o!=null&&ht("scrollend",i);break;case"onClick":o!=null&&(i.onclick=tn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ea.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[xi]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof o=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,o,u);break e}a in i?i[a]=o:o===!0?i.setAttribute(a,""):os(i,a,o)}}}function Yi(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ht("error",i),ht("load",i);var o=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Mt(i,n,d,_,a,null)}}u&&Mt(i,n,"srcSet",a.srcSet,a,null),o&&Mt(i,n,"src",a.src,a,null);return;case"input":ht("invalid",i);var C=d=_=u=null,N=null,V=null;for(o in a)if(a.hasOwnProperty(o)){var oe=a[o];if(oe!=null)switch(o){case"name":u=oe;break;case"type":_=oe;break;case"checked":N=oe;break;case"defaultChecked":V=oe;break;case"value":d=oe;break;case"defaultValue":C=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(s(137,n));break;default:Mt(i,n,o,oe,a,null)}}li(i,d,C,N,V,_,u,!1);return;case"select":ht("invalid",i),o=_=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":o=C;default:Mt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!o,n!=null?sr(i,!!o,n,!1):a!=null&&sr(i,!!o,a,!0);return;case"textarea":ht("invalid",i),d=u=o=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":o=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:Mt(i,n,_,C,a,null)}sa(i,o,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(o=a[N],o!=null)&&(N==="selected"?i.selected=o&&typeof o!="function"&&typeof o!="symbol":Mt(i,n,N,o,a,null));return;case"dialog":ht("beforetoggle",i),ht("toggle",i),ht("cancel",i),ht("close",i);break;case"iframe":case"object":ht("load",i);break;case"video":case"audio":for(o=0;o<To.length;o++)ht(To[o],i);break;case"image":ht("error",i),ht("load",i);break;case"details":ht("toggle",i);break;case"embed":case"source":case"link":ht("error",i),ht("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(V in a)if(a.hasOwnProperty(V)&&(o=a[V],o!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Mt(i,n,V,o,a,null)}return;default:if(yr(n)){for(oe in a)a.hasOwnProperty(oe)&&(o=a[oe],o!==void 0&&zf(i,n,oe,o,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(o=a[C],o!=null&&Mt(i,n,C,o,a,null))}function Qx(i,n,a,o){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,V=null,oe=null;for(ee in a){var ue=a[ee];if(a.hasOwnProperty(ee)&&ue!=null)switch(ee){case"checked":break;case"value":break;case"defaultValue":N=ue;default:o.hasOwnProperty(ee)||Mt(i,n,ee,null,o,ue)}}for(var G in o){var ee=o[G];if(ue=a[G],o.hasOwnProperty(G)&&(ee!=null||ue!=null))switch(G){case"type":d=ee;break;case"name":u=ee;break;case"checked":V=ee;break;case"defaultChecked":oe=ee;break;case"value":_=ee;break;case"defaultValue":C=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,n));break;default:ee!==ue&&Mt(i,n,G,ee,o,ue)}}rr(i,_,C,N,V,oe,d,u);return;case"select":ee=_=C=G=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":ee=N;default:o.hasOwnProperty(d)||Mt(i,n,d,null,o,N)}for(u in o)if(d=o[u],N=a[u],o.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":G=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==N&&Mt(i,n,u,d,o,N)}n=C,a=_,o=ee,G!=null?sr(i,!!a,G,!1):!!o!=!!a&&(n!=null?sr(i,!!a,n,!0):sr(i,!!a,a?[]:"",!1));return;case"textarea":ee=G=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!o.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Mt(i,n,C,null,o,u)}for(_ in o)if(u=o[_],d=a[_],o.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":G=u;break;case"defaultValue":ee=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&Mt(i,n,_,u,o,d)}ra(i,G,ee);return;case"option":for(var Oe in a)G=a[Oe],a.hasOwnProperty(Oe)&&G!=null&&!o.hasOwnProperty(Oe)&&(Oe==="selected"?i.selected=!1:Mt(i,n,Oe,null,o,G));for(N in o)G=o[N],ee=a[N],o.hasOwnProperty(N)&&G!==ee&&(G!=null||ee!=null)&&(N==="selected"?i.selected=G&&typeof G!="function"&&typeof G!="symbol":Mt(i,n,N,G,o,ee));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 Ve in a)G=a[Ve],a.hasOwnProperty(Ve)&&G!=null&&!o.hasOwnProperty(Ve)&&Mt(i,n,Ve,null,o,G);for(V in o)if(G=o[V],ee=a[V],o.hasOwnProperty(V)&&G!==ee&&(G!=null||ee!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(s(137,n));break;default:Mt(i,n,V,G,o,ee)}return;default:if(yr(n)){for(var Nt in a)G=a[Nt],a.hasOwnProperty(Nt)&&G!==void 0&&!o.hasOwnProperty(Nt)&&zf(i,n,Nt,void 0,o,G);for(oe in o)G=o[oe],ee=a[oe],!o.hasOwnProperty(oe)||G===ee||G===void 0&&ee===void 0||zf(i,n,oe,G,o,ee);return}}for(var I in a)G=a[I],a.hasOwnProperty(I)&&G!=null&&!o.hasOwnProperty(I)&&Mt(i,n,I,null,o,G);for(ue in o)G=o[ue],ee=a[ue],!o.hasOwnProperty(ue)||G===ee||G==null&&ee==null||Mt(i,n,ue,G,o,ee)}function lb(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Jx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),o=0;o<a.length;o++){var u=a[o],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&lb(_)){for(_=0,C=u.responseEnd,o+=1;o<a.length;o++){var N=a[o],V=N.startTime;if(V>C)break;var oe=N.transferSize,ue=N.initiatorType;oe&&lb(ue)&&(N=N.responseEnd,_+=oe*(N<C?1:(C-V)/(N-V)))}if(--o,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 jf=null,Pf=null;function Ru(i){return i.nodeType===9?i:i.ownerDocument}function ob(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 cb(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 Hf(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 If=null;function ek(){var i=window.event;return i&&i.type==="popstate"?i===If?!1:(If=i,!0):(If=null,!1)}var ub=typeof setTimeout=="function"?setTimeout:void 0,tk=typeof clearTimeout=="function"?clearTimeout:void 0,hb=typeof Promise=="function"?Promise:void 0,ik=typeof queueMicrotask=="function"?queueMicrotask:typeof hb<"u"?function(i){return hb.resolve(null).then(i).catch(nk)}:ub;function nk(i){setTimeout(function(){throw i})}function As(i){return i==="head"}function db(i,n){var a=n,o=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(o===0){i.removeChild(u),xl(n);return}o--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")o++;else if(a==="html")Ro(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Ro(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[Lr]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&Ro(i.ownerDocument.body);a=u}while(a);xl(n)}function fb(i,n){var a=i;i=0;do{var o=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||""),o&&o.nodeType===8)if(a=o.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=o}while(a)}function Uf(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":Uf(a),ls(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function rk(i,n,a,o){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(o){if(!i[Lr])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=Vn(i.nextSibling),i===null)break}return null}function sk(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Vn(i.nextSibling),i===null))return null;return i}function pb(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=Vn(i.nextSibling),i===null))return null;return i}function Kf(i){return i.data==="$?"||i.data==="$~"}function Wf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function ak(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var o=function(){n(),a.removeEventListener("DOMContentLoaded",o)};a.addEventListener("DOMContentLoaded",o),i._reactRetry=o}}function Vn(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 Ff=null;function mb(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return Vn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function gb(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 _b(i,n,a){switch(n=Ru(a),i){case"html":if(i=n.documentElement,!i)throw Error(s(452));return i;case"head":if(i=n.head,!i)throw Error(s(453));return i;case"body":if(i=n.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function Ro(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);ls(i)}var Yn=new Map,vb=new Set;function Mu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Gr=X.d;X.d={f:lk,r:ok,D:ck,C:uk,L:hk,m:dk,X:pk,S:fk,M:mk};function lk(){var i=Gr.f(),n=Su();return i||n}function ok(i){var n=mr(i);n!==null&&n.tag===5&&n.type==="form"?Ov(n):Gr.r(i)}var Sl=typeof document>"u"?null:document;function yb(i,n,a){var o=Sl;if(o&&typeof n=="string"&&n){var u=Bi(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),vb.has(u)||(vb.add(u),i={rel:i,crossOrigin:a,href:n},o.querySelector(u)===null&&(n=o.createElement("link"),Yi(n,"link",i),Bt(n),o.head.appendChild(n)))}}function ck(i){Gr.D(i),yb("dns-prefetch",i,null)}function uk(i,n){Gr.C(i,n),yb("preconnect",i,n)}function hk(i,n,a){Gr.L(i,n,a);var o=Sl;if(o&&i&&n){var u='link[rel="preload"][as="'+Bi(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Bi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Bi(a.imageSizes)+'"]')):u+='[href="'+Bi(i)+'"]';var d=u;switch(n){case"style":d=wl(i);break;case"script":d=Cl(i)}Yn.has(d)||(i=y({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),Yn.set(d,i),o.querySelector(u)!==null||n==="style"&&o.querySelector(Mo(d))||n==="script"&&o.querySelector(No(d))||(n=o.createElement("link"),Yi(n,"link",i),Bt(n),o.head.appendChild(n)))}}function dk(i,n){Gr.m(i,n);var a=Sl;if(a&&i){var o=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Bi(o)+'"][href="'+Bi(i)+'"]',d=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Cl(i)}if(!Yn.has(d)&&(i=y({rel:"modulepreload",href:i},n),Yn.set(d,i),a.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(No(d)))return}o=a.createElement("link"),Yi(o,"link",i),Bt(o),a.head.appendChild(o)}}}function fk(i,n,a){Gr.S(i,n,a);var o=Sl;if(o&&i){var u=zn(o).hoistableStyles,d=wl(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=o.querySelector(Mo(d)))C.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":n},a),(a=Yn.get(d))&&qf(i,a);var N=_=o.createElement("link");Bt(N),Yi(N,"link",i),N._p=new Promise(function(V,oe){N.onload=V,N.onerror=oe}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Nu(_,n,o)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function pk(i,n){Gr.X(i,n);var a=Sl;if(a&&i){var o=zn(a).hoistableScripts,u=Cl(i),d=o.get(u);d||(d=a.querySelector(No(u)),d||(i=y({src:i,async:!0},n),(n=Yn.get(u))&&$f(i,n),d=a.createElement("script"),Bt(d),Yi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function mk(i,n){Gr.M(i,n);var a=Sl;if(a&&i){var o=zn(a).hoistableScripts,u=Cl(i),d=o.get(u);d||(d=a.querySelector(No(u)),d||(i=y({src:i,async:!0,type:"module"},n),(n=Yn.get(u))&&$f(i,n),d=a.createElement("script"),Bt(d),Yi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function bb(i,n,a,o){var u=(u=Se.current)?Mu(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=wl(a.href),a=zn(u).hoistableStyles,o=a.get(n),o||(o={type:"style",instance:null,count:0,state:null},a.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=wl(a.href);var d=zn(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(Mo(i)))&&!d._p&&(_.instance=d,_.state.loading=5),Yn.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},Yn.set(i,a),d||gk(u,i,a,_.state))),n&&o===null)throw Error(s(528,""));return _}if(n&&o!==null)throw Error(s(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Cl(a),a=zn(u).hoistableScripts,o=a.get(n),o||(o={type:"script",instance:null,count:0,state:null},a.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function wl(i){return'href="'+Bi(i)+'"'}function Mo(i){return'link[rel="stylesheet"]['+i+"]"}function Sb(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function gk(i,n,a,o){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=i.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),Yi(n,"link",a),Bt(n),i.head.appendChild(n))}function Cl(i){return'[src="'+Bi(i)+'"]'}function No(i){return"script[async]"+i}function wb(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var o=i.querySelector('style[data-href~="'+Bi(a.href)+'"]');if(o)return n.instance=o,Bt(o),o;var u=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return o=(i.ownerDocument||i).createElement("style"),Bt(o),Yi(o,"style",u),Nu(o,a.precedence,i),n.instance=o;case"stylesheet":u=wl(a.href);var d=i.querySelector(Mo(u));if(d)return n.state.loading|=4,n.instance=d,Bt(d),d;o=Sb(a),(u=Yn.get(u))&&qf(o,u),d=(i.ownerDocument||i).createElement("link"),Bt(d);var _=d;return _._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Yi(d,"link",o),n.state.loading|=4,Nu(d,a.precedence,i),n.instance=d;case"script":return d=Cl(a.src),(u=i.querySelector(No(d)))?(n.instance=u,Bt(u),u):(o=a,(u=Yn.get(d))&&(o=y({},a),$f(o,u)),i=i.ownerDocument||i,u=i.createElement("script"),Bt(u),Yi(u,"link",o),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,Nu(o,a.precedence,i));return n.instance}function Nu(i,n,a){for(var o=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,d=u,_=0;_<o.length;_++){var C=o[_];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 qf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function $f(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var Au=null;function Cb(i,n,a){if(Au===null){var o=new Map,u=Au=new Map;u.set(a,o)}else u=Au,o=u.get(a),o||(o=new Map,u.set(a,o));if(o.has(i))return o;for(o.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Lr]||d[ii]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=o.get(_);C?C.push(d):o.set(_,[d])}}return o}function xb(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function _k(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 kb(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function vk(i,n,a,o){if(a.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=wl(o.href),d=n.querySelector(Mo(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=Lu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,Bt(d);return}d=n.ownerDocument||n,o=Sb(o),(u=Yn.get(u))&&qf(o,u),d=d.createElement("link"),Bt(d);var _=d;_._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Yi(d,"link",o),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=Lu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var Vf=0;function yk(i,n){return i.stylesheets&&i.count===0&&Ou(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var o=setTimeout(function(){if(i.stylesheets&&Ou(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&Vf===0&&(Vf=62500*Jx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ou(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>Vf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Lu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ou(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Bu=null;function Ou(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Bu=new Map,n.forEach(bk,i),Bu=null,Lu.call(i))}function bk(i,n){if(!(n.state.loading&4)){var a=Bu.get(i);if(a)var o=a.get(null);else{a=new Map,Bu.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,_),o=_)}o&&a.set(null,o)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||o,d===o&&a.set(null,u),a.set(_,u),this.count++,o=Lu.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var Ao={$$typeof:Y,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function Sk(i,n,a,o,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=di(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=di(0),this.hiddenUpdates=di(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function Eb(i,n,a,o,u,d,_,C,N,V,oe,ue){return i=new Sk(i,n,a,_,N,V,oe,ue,C),n=1,d===!0&&(n|=24),d=kn(3,null,null,n),i.current=d,d.stateNode=i,n=kd(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:o,isDehydrated:a,cache:n},Rd(d),i}function Tb(i){return i?(i=el,i):el}function Db(i,n,a,o,u,d){u=Tb(u),o.context===null?o.context=u:o.pendingContext=u,o=Ss(n),o.payload={element:a},d=d===void 0?null:d,d!==null&&(o.callback=d),a=ws(i,o,n),a!==null&&(_n(a,i,n),co(a,i,n))}function Rb(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function Yf(i,n){Rb(i,n),(i=i.alternate)&&Rb(i,n)}function Mb(i){if(i.tag===13||i.tag===31){var n=ha(i,67108864);n!==null&&_n(n,i,67108864),Yf(i,67108864)}}function Nb(i){if(i.tag===13||i.tag===31){var n=Mn();n=ln(n);var a=ha(i,n);a!==null&&_n(a,i,n),Yf(i,n)}}var zu=!0;function wk(i,n,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=2,Xf(i,n,a,o)}finally{X.p=d,R.T=u}}function Ck(i,n,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=8,Xf(i,n,a,o)}finally{X.p=d,R.T=u}}function Xf(i,n,a,o){if(zu){var u=Gf(o);if(u===null)Of(i,n,o,ju,a),Lb(i,o);else if(kk(u,i,n,a,o))o.stopPropagation();else if(Lb(i,o),n&4&&-1<xk.indexOf(i)){for(;u!==null;){var d=mr(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=wt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var N=1<<31-F(_);C.entanglements[1]|=N,_&=~N}Er(d),(bt&6)===0&&(yu=$e()+500,Eo(0))}}break;case 31:case 13:C=ha(d,2),C!==null&&_n(C,d,2),Su(),Yf(d,2)}if(d=Gf(o),d===null&&Of(i,n,o,ju,a),d===u)break;u=d}u!==null&&o.stopPropagation()}else Of(i,n,o,null,a)}}function Gf(i){return i=br(i),Zf(i)}var ju=null;function Zf(i){if(ju=null,i=On(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=p(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 ju=i,null}function Ab(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(kt()){case ei:return 2;case Et:return 8;case _e:case We:return 32;case Je:return 268435456;default:return 32}default:return 32}}var Qf=!1,Ls=null,Bs=null,Os=null,Lo=new Map,Bo=new Map,zs=[],xk="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 Lb(i,n){switch(i){case"focusin":case"focusout":Ls=null;break;case"dragenter":case"dragleave":Bs=null;break;case"mouseover":case"mouseout":Os=null;break;case"pointerover":case"pointerout":Lo.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bo.delete(n.pointerId)}}function Oo(i,n,a,o,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:o,nativeEvent:d,targetContainers:[u]},n!==null&&(n=mr(n),n!==null&&Mb(n)),i):(i.eventSystemFlags|=o,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function kk(i,n,a,o,u){switch(n){case"focusin":return Ls=Oo(Ls,i,n,a,o,u),!0;case"dragenter":return Bs=Oo(Bs,i,n,a,o,u),!0;case"mouseover":return Os=Oo(Os,i,n,a,o,u),!0;case"pointerover":var d=u.pointerId;return Lo.set(d,Oo(Lo.get(d)||null,i,n,a,o,u)),!0;case"gotpointercapture":return d=u.pointerId,Bo.set(d,Oo(Bo.get(d)||null,i,n,a,o,u)),!0}return!1}function Bb(i){var n=On(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,dn(i.priority,function(){Nb(a)});return}}else if(n===31){if(n=p(a),n!==null){i.blockedOn=n,dn(i.priority,function(){Nb(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 Pu(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=Gf(i.nativeEvent);if(a===null){a=i.nativeEvent;var o=new a.constructor(a.type,a);Or=o,a.target.dispatchEvent(o),Or=null}else return n=mr(a),n!==null&&Mb(n),i.blockedOn=a,!1;n.shift()}return!0}function Ob(i,n,a){Pu(i)&&a.delete(n)}function Ek(){Qf=!1,Ls!==null&&Pu(Ls)&&(Ls=null),Bs!==null&&Pu(Bs)&&(Bs=null),Os!==null&&Pu(Os)&&(Os=null),Lo.forEach(Ob),Bo.forEach(Ob)}function Hu(i,n){i.blockedOn===n&&(i.blockedOn=null,Qf||(Qf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Ek)))}var Iu=null;function zb(i){Iu!==i&&(Iu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Iu===i&&(Iu=null);for(var n=0;n<i.length;n+=3){var a=i[n],o=i[n+1],u=i[n+2];if(typeof o!="function"){if(Zf(o||a)===null)continue;break}var d=mr(a);d!==null&&(i.splice(n,3),n-=3,Xd(d,{pending:!0,data:u,method:a.method,action:o},o,u))}}))}function xl(i){function n(N){return Hu(N,i)}Ls!==null&&Hu(Ls,i),Bs!==null&&Hu(Bs,i),Os!==null&&Hu(Os,i),Lo.forEach(n),Bo.forEach(n);for(var a=0;a<zs.length;a++){var o=zs[a];o.blockedOn===i&&(o.blockedOn=null)}for(;0<zs.length&&(a=zs[0],a.blockedOn===null);)Bb(a),a.blockedOn===null&&zs.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(o=0;o<a.length;o+=3){var u=a[o],d=a[o+1],_=u[xi]||null;if(typeof d=="function")_||zb(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[xi]||null)C=_.formAction;else if(Zf(u)!==null)continue}else C=_.action;typeof C=="function"?a[o+1]=C:(a.splice(o,3),o-=3),zb(a)}}}function jb(){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),o||setTimeout(a,20)}function a(){if(!o&&!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 o=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){o=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Jf(i){this._internalRoot=i}Uu.prototype.render=Jf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(s(409));var a=n.current,o=Mn();Db(a,o,i,n,null,null)},Uu.prototype.unmount=Jf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Db(i.current,2,null,i,null,null),Su(),n[Sn]=null}};function Uu(i){this._internalRoot=i}Uu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Qi();i={blockedOn:null,target:i,priority:n};for(var a=0;a<zs.length&&n!==0&&n<zs[a].priority;a++);zs.splice(a,0,i),a===0&&Bb(i)}};var Pb=t.version;if(Pb!=="19.2.6")throw Error(s(527,Pb,"19.2.6"));X.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(n),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var Tk={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ku=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ku.isDisabled&&Ku.supportsFiber)try{Tt=Ku.inject(Tk),Lt=Ku}catch{}}return jo.createRoot=function(i,n){if(!l(i))throw Error(s(299));var a=!1,o="",u=qv,d=$v,_=Vv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=Eb(i,1,!1,null,null,a,o,null,u,d,_,jb),i[Sn]=n.current,Bf(i),new Jf(n)},jo.hydrateRoot=function(i,n,a){if(!l(i))throw Error(s(299));var o=!1,u="",d=qv,_=$v,C=Vv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(o=!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=Eb(i,1,!0,n,a??null,o,u,N,d,_,C,jb),n.context=Tb(null),a=n.current,o=Mn(),o=ln(o),u=Ss(o),u.callback=null,ws(a,u,o),a=o,n.current.lanes=a,Xt(n,a),Er(n),i[Sn]=n.current,Bf(i),new Uu(n)},jo.version="19.2.6",jo}var Yb;function jk(){if(Yb)return ip.exports;Yb=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(),ip.exports=zk(),ip.exports}var Pk=jk();class dr extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}status}function Hh(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Rl(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",tt("POST",t)),login:t=>Ne(e,"/api/auth/login",tt("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",tt("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",tt("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",tt("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await Tl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",tt("POST",t)),removeNetwork:async t=>{await Tl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),addAgent:t=>Ne(e,"/api/agents",tt("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",tt("PUT",{serverIds:t})),renameAgent:(t,r)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,tt("PATCH",{name:r})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",tt("PATCH",{name:t})),removeAgent:async t=>{await Tl(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",tt("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",tt("POST",t)),listFiles:t=>Ne(e,"/api/files/list",tt("POST",t)),readFile:t=>Ne(e,"/api/files/read",tt("POST",t)),writeFile:t=>Ne(e,"/api/files/write",tt("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",tt("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",tt("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",tt("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",tt("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",tt("POST",t)),previewFile:t=>Q0(e,"/api/files/preview",tt("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",tt("POST",t)),closeTerminal:async t=>{await Tl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,r)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,tt("PATCH",{title:r})),getTerminalHistory:(t,r={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Rl(r)}`),getTerminalTranscriptHistory:(t,r={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Rl(r)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const r=new FormData;return r.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:r})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",tt("PUT",t)),deleteNotificationAsset:async t=>{await Tl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:t=>Ne(e,`/api/push-notifications/status${t?Rl({clientId:t}):""}`),preparePushNotifications:t=>Ne(e,"/api/push-notifications/prepare",tt("POST",{clientId:t})),subscribePushNotifications:t=>Ne(e,"/api/push-notifications/subscription",tt("POST",t)),updatePushNotificationDevice:t=>Ne(e,"/api/push-notifications/device",tt("PATCH",t)),unsubscribePushNotifications:t=>Ne(e,"/api/push-notifications/unsubscribe",tt("POST",t)),updatePushPresence:t=>Ne(e,"/api/push-notifications/presence",tt("POST",t))}}function dc(e,t=fetch){const r=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,r("terminals")),createTerminal:(s={})=>Ne(t,r("terminals"),tt("POST",s)),closeTerminal:async s=>{await Tl(t,r(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,l)=>Ne(t,r(`terminals/${encodeURIComponent(s)}`),tt("PATCH",{title:l})),getTerminalHistory:(s,l={})=>Ne(t,`${r(`terminals/${encodeURIComponent(s)}/history`)}${Rl(l)}`),getTerminalTranscriptHistory:(s,l={})=>Ne(t,`${r(`terminals/${encodeURIComponent(s)}/transcript-history`)}${Rl(l)}`),getTerminalTranscriptSource:s=>Ne(t,r(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Ne(t,r("terminal-layout")),saveTerminalLayout:s=>Ne(t,r("terminal-layout"),tt("PUT",s)),createFileRoot:s=>Ne(t,r("files/root"),tt("POST",s)),listFiles:s=>Ne(t,r("files/list"),tt("POST",s)),readFile:s=>Ne(t,r("files/read"),tt("POST",s)),writeFile:s=>Ne(t,r("files/write"),tt("POST",s)),createFileEntry:s=>Ne(t,r("files/create"),tt("POST",s)),moveFileEntry:s=>Ne(t,r("files/move"),tt("POST",s)),previewDeleteFileEntry:s=>Ne(t,r("files/delete-preview"),tt("POST",s)),deleteFileEntry:s=>Ne(t,r("files/delete"),tt("POST",s)),openFileInTerminal:s=>Ne(t,r("files/open"),tt("POST",s)),previewFile:s=>Q0(t,r("files/preview"),tt("POST",s)),createWebSocketUrl:(s,l=window.location.href)=>Hk(r(`terminals/${encodeURIComponent(s)}/ws`),l)}}function Hk(e,t){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=e,r.search="",r.hash="",r.toString()}function tt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Rl(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),e.clientId!==void 0&&t.set("clientId",e.clientId);const r=t.toString();return r?`?${r}`:""}async function Ne(e,t,r){const s=await e(t,r??{credentials:"same-origin"});await _g(s);try{return await s.json()}catch{throw new dr(s.status,"invalid_json_response")}}async function Tl(e,t,r){const s=await e(t,r);await _g(s)}async function Q0(e,t,r){const s=await e(t,r);return await _g(s),s.blob()}async function _g(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const r=await e.json(),s=typeof r.error=="string"?r.error:r.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new dr(e.status,t)}const vg="nterminal.theme.id",J0="nterminal.theme.accent",Pp="nterminal:theme",gh=[{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",...Xb({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",...Xb({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],zl="midnight";function Ih(e){return gh.some(t=>t.id===e)?e:zl}function yg(e){return gh.find(t=>t.id===e)??gh[0]}function Xs(){if(typeof window>"u")return zl;try{const e=window.localStorage.getItem(vg);return e?Ih(e):Fk(window.localStorage.getItem(J0))}catch{return zl}}function Ik(e){const t=Ih(e);if(typeof window<"u"){try{window.localStorage.setItem(vg,t)}catch{}bg(t),window.dispatchEvent(new CustomEvent(Pp,{detail:t}))}return t}function bg(e=Xs()){if(typeof document>"u")return;const t=yg(Ih(e)),r=document.documentElement;r.dataset.ntTheme=t.id,r.style.setProperty("color-scheme",t.mode),st(r,"--nt-bg",t.tokens.bg),st(r,"--nt-bg-2",t.tokens.bg2),st(r,"--nt-bg-sidebar",t.tokens.bgSidebar),st(r,"--nt-line",t.tokens.line),st(r,"--nt-line-2",t.tokens.line2),st(r,"--nt-fg",t.tokens.fg),st(r,"--nt-fg-2",t.tokens.fg2),st(r,"--nt-fg-3",t.tokens.fg3),st(r,"--nt-fg-4",t.tokens.fg4),st(r,"--nt-accent",t.tokens.accent),st(r,"--nt-accent-soft",t.tokens.accentSoft),st(r,"--nt-accent-glow",t.tokens.accentGlow),st(r,"--nt-on-accent",t.tokens.onAccent),st(r,"--nt-ok",t.tokens.ok),st(r,"--nt-danger",t.tokens.danger),st(r,"--nt-on-danger",t.tokens.onDanger),st(r,"--nt-danger-soft",t.tokens.dangerSoft),st(r,"--nt-danger-line",t.tokens.dangerLine),st(r,"--nt-warning",t.tokens.warning),st(r,"--nt-warn",t.tokens.warning),st(r,"--nt-warning-soft",t.tokens.warningSoft),st(r,"--nt-warning-glow",t.tokens.warningGlow),st(r,"--nt-scrim",t.tokens.scrim),st(r,"--nt-scrim-soft",t.tokens.scrimSoft),st(r,"--nt-shadow",t.tokens.shadow),st(r,"--nt-shadow-strong",t.tokens.shadowStrong),st(r,"--nt-floating-bg",t.tokens.floatingBg),st(r,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),st(r,"--nt-floating-bg-hover",t.tokens.floatingBgHover),st(r,"--nt-subtle-fill",t.tokens.subtleFill),st(r,"--nt-hover-fill",t.tokens.hoverFill),st(r,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),st(r,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),st(r,"--nt-transcript-user",t.tokens.transcriptUser),st(r,"--nt-transcript-assistant",t.tokens.transcriptAssistant),st(r,"--nt-transcript-tool",t.tokens.transcriptTool),st(r,"--nt-transcript-command",t.tokens.transcriptCommand),st(r,"--nt-transcript-code",t.tokens.transcriptCode),st(r,"--nt-transcript-search",t.tokens.transcriptSearch),st(r,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),st(r,"--nt-qr-bg",t.tokens.qrBg)}function Uk(e=Xs()){return yg(Ih(e)).xterm}function Sg(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===vg||r.key===J0)&&(bg(Xs()),e())};return window.addEventListener(Pp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Pp,e),window.removeEventListener("storage",t)}}function st(e,t,r){e.style.setProperty(t,r)}function Xb(e){const t=Kk(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 Kk(e){const t=[];for(let r=16;r<=e;r+=1)t.push(Wk(r));return t}function Wk(e){if(e>=16&&e<=231){const t=e-16,r=[0,95,135,175,215,255],s=r[Math.floor(t/36)%6],l=r[Math.floor(t/6)%6],c=r[t%6];return Gb(s,l,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return Gb(t,t,t)}return"#000000"}function Gb(e,t,r){return`#${ap(e)}${ap(t)}${ap(r)}`}function ap(e){return e.toString(16).padStart(2,"0")}function Fk(e){return e==="signal-red"?"signal-red":zl}function ew(){const e=v.useSyncExternalStore(Sg,Xs,()=>zl);return yg(e).mode==="light"?"-light":""}function tw({size:e=22}){const t=ew();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function iw({height:e=18}){const t=ew(),r=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:r,height:e,alt:"NTerminal"})}var Xo=Z0();const Uh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function wg(e){return"nodeType"in e}function bn(e){var t,r;return e?Kl(e)?e:wg(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Cg(e){const{Document:t}=bn(e);return e instanceof t}function Ec(e){return Kl(e)?!1:e instanceof bn(e).HTMLElement}function nw(e){return e instanceof bn(e).SVGElement}function Wl(e){return e?Kl(e)?e.document:wg(e)?Cg(e)?e:Ec(e)||nw(e)?e.ownerDocument:document:document:document}const Gs=Uh?v.useLayoutEffect:v.useEffect;function xg(e){const t=v.useRef(e);return Gs(()=>{t.current=e}),v.useCallback(function(){for(var r=arguments.length,s=new Array(r),l=0;l<r;l++)s[l]=arguments[l];return t.current==null?void 0:t.current(...s)},[])}function qk(){const e=v.useRef(null),t=v.useCallback((s,l)=>{e.current=setInterval(s,l)},[]),r=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function fc(e,t){t===void 0&&(t=[e]);const r=v.useRef(e);return Gs(()=>{r.current!==e&&(r.current=e)},t),r}function Tc(e,t){const r=v.useRef();return v.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function _h(e){const t=xg(e),r=v.useRef(null),s=v.useCallback(l=>{l!==r.current&&t?.(l,r.current),r.current=l},[]);return[r,s]}function Hp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let lp={};function Kh(e,t){return v.useMemo(()=>{if(t)return t;const r=lp[e]==null?0:lp[e]+1;return lp[e]=r,e+"-"+r},[e,t])}function rw(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];return s.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const b=c[g];b!=null&&(c[g]=b+e*f)}return c},{...t})}}const Bl=rw(1),vh=rw(-1);function $k(e){return"clientX"in e&&"clientY"in e}function sw(e){if(!e)return!1;const{KeyboardEvent:t}=bn(e.target);return t&&e instanceof t}function Vk(e){if(!e)return!1;const{TouchEvent:t}=bn(e.target);return t&&e instanceof t}function Ip(e){if(Vk(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return $k(e)?{x:e.clientX,y:e.clientY}:null}const Up=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Up.Translate.toString(e),Up.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),Zb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Yk(e){return e.matches(Zb)?e:e.querySelector(Zb)}const Xk={display:"none"};function Gk(e){let{id:t,value:r}=e;return Mi.createElement("div",{id:t,style:Xk},r)}function Zk(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const l={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 Mi.createElement("div",{id:t,style:l,role:"status","aria-live":s,"aria-atomic":!0},r)}function Qk(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const aw=v.createContext(null);function Jk(e){const t=v.useContext(aw);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(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:l,event:c}=s;e.forEach(h=>{var p;return(p=h[l])==null?void 0:p.call(h,c)})},[e]),t]}const tE={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
|
-
`},iE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function nE(e){let{announcements:t=iE,container:r,hiddenTextDescribedById:s,screenReaderInstructions:l=tE}=e;const{announce:c,announcement:h}=Qk(),p=Kh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),Jk(v.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:w}=y;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(y){let{active:S,over:w}=y;c(t.onDragOver({active:S,over:w}))},onDragEnd(y){let{active:S,over:w}=y;c(t.onDragEnd({active:S,over:w}))},onDragCancel(y){let{active:S,over:w}=y;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const b=Mi.createElement(Mi.Fragment,null,Mi.createElement(Gk,{id:s,value:l.draggable}),Mi.createElement(Zk,{id:p,announcement:h}));return r?Xo.createPortal(b,r):b}var Ri;(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"})(Ri||(Ri={}));function yh(){}function Qb(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function rE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const fr=Object.freeze({x:0,y:0});function sE(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function aE(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function lE(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),l=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=l-s,p=c-r;if(s<l&&r<c){const g=t.width*t.height,f=e.width*e.height,b=h*p,y=b/(g+f-b);return Number(y.toFixed(4))}return 0}const oE=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const l=[];for(const c of s){const{id:h}=c,p=r.get(h);if(p){const g=lE(p,t);g>0&&l.push({id:h,data:{droppableContainer:c,value:g}})}}return l.sort(sE)};function cE(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function lw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:fr}function uE(e){return function(r){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];return l.reduce((h,p)=>({...h,top:h.top+e*p.y,bottom:h.bottom+e*p.y,left:h.left+e*p.x,right:h.right+e*p.x}),{...r})}}const hE=uE(1);function dE(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 fE(e,t,r){const s=dE(t);if(!s)return e;const{scaleX:l,scaleY:c,x:h,y:p}=s,g=e.left-h-(1-l)*parseFloat(r),f=e.top-p-(1-c)*parseFloat(r.slice(r.indexOf(" ")+1)),b=l?e.width/l:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:g+b,bottom:f+y,left:g}}const pE={ignoreTransform:!1};function Dc(e,t){t===void 0&&(t=pE);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=bn(e).getComputedStyle(e);f&&(r=fE(r,f,b))}const{top:s,left:l,width:c,height:h,bottom:p,right:g}=r;return{top:s,left:l,width:c,height:h,bottom:p,right:g}}function Jb(e){return Dc(e,{ignoreTransform:!0})}function mE(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function gE(e,t){return t===void 0&&(t=bn(e).getComputedStyle(e)),t.position==="fixed"}function _E(e,t){t===void 0&&(t=bn(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=t[l];return typeof c=="string"?r.test(c):!1})}function kg(e,t){const r=[];function s(l){if(t!=null&&r.length>=t||!l)return r;if(Cg(l)&&l.scrollingElement!=null&&!r.includes(l.scrollingElement))return r.push(l.scrollingElement),r;if(!Ec(l)||nw(l)||r.includes(l))return r;const c=bn(e).getComputedStyle(l);return l!==e&&_E(l,c)&&r.push(l),gE(l,c)?r:s(l.parentNode)}return e?s(e):r}function ow(e){const[t]=kg(e,1);return t??null}function op(e){return!Uh||!e?null:Kl(e)?e:wg(e)?Cg(e)||e===Wl(e).scrollingElement?window:Ec(e)?e:null:null}function cw(e){return Kl(e)?e.scrollX:e.scrollLeft}function uw(e){return Kl(e)?e.scrollY:e.scrollTop}function Kp(e){return{x:cw(e),y:uw(e)}}var ji;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ji||(ji={}));function hw(e){return!Uh||!e?!1:e===document.scrollingElement}function dw(e){const t={x:0,y:0},r=hw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},l=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=s.y,p=e.scrollLeft>=s.x;return{isTop:l,isLeft:c,isBottom:h,isRight:p,maxScroll:s,minScroll:t}}const vE={x:.2,y:.2};function yE(e,t,r,s,l){let{top:c,left:h,right:p,bottom:g}=r;s===void 0&&(s=10),l===void 0&&(l=vE);const{isTop:f,isBottom:b,isLeft:y,isRight:S}=dw(e),w={x:0,y:0},k={x:0,y:0},E={height:t.height*l.y,width:t.width*l.x};return!f&&c<=t.top+E.height?(w.y=ji.Backward,k.y=s*Math.abs((t.top+E.height-c)/E.height)):!b&&g>=t.bottom-E.height&&(w.y=ji.Forward,k.y=s*Math.abs((t.bottom-E.height-g)/E.height)),!S&&p>=t.right-E.width?(w.x=ji.Forward,k.x=s*Math.abs((t.right-E.width-p)/E.width)):!y&&h<=t.left+E.width&&(w.x=ji.Backward,k.x=s*Math.abs((t.left+E.width-h)/E.width)),{direction:w,speed:k}}function bE(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:r,right:s,bottom:l}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:l,width:e.clientWidth,height:e.clientHeight}}function fw(e){return e.reduce((t,r)=>Bl(t,Kp(r)),fr)}function SE(e){return e.reduce((t,r)=>t+cw(r),0)}function wE(e){return e.reduce((t,r)=>t+uw(r),0)}function CE(e,t){if(t===void 0&&(t=Dc),!e)return;const{top:r,left:s,bottom:l,right:c}=t(e);ow(e)&&(l<=0||c<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const xE=[["x",["left","right"],SE],["y",["top","bottom"],wE]];class Eg{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=kg(r),l=fw(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of xE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(s),b=l[c]-f;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ac{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var l;(l=this.target)==null||l.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function kE(e){const{EventTarget:t}=bn(e);return e instanceof t?e:Wl(e)}function cp(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var Zn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Zn||(Zn={}));function eS(e){e.preventDefault()}function EE(e){e.stopPropagation()}var jt;(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"})(jt||(jt={}));const pw={start:[jt.Space,jt.Enter],cancel:[jt.Esc],end:[jt.Space,jt.Enter,jt.Tab]},TE=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case jt.Right:return{...r,x:r.x+25};case jt.Left:return{...r,x:r.x-25};case jt.Down:return{...r,y:r.y+25};case jt.Up:return{...r,y:r.y-25}}};class mw{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:r}}=t;this.props=t,this.listeners=new ac(Wl(r)),this.windowListeners=new ac(bn(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zn.Resize,this.handleCancel),this.windowListeners.add(Zn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&CE(s),r(fr)}handleKeyDown(t){if(sw(t)){const{active:r,context:s,options:l}=this.props,{keyboardCodes:c=pw,coordinateGetter:h=TE,scrollBehavior:p="smooth"}=l,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,b=f?{x:f.left,y:f.top}:fr;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:r,context:s.current,currentCoordinates:b});if(y){const S=vh(y,b),w={x:0,y:0},{scrollableAncestors:k}=s.current;for(const E of k){const L=t.code,{isTop:A,isRight:B,isLeft:Y,isBottom:P,maxScroll:q,minScroll:re}=dw(E),ie=bE(E),he={x:Math.min(L===jt.Right?ie.right-ie.width/2:ie.right,Math.max(L===jt.Right?ie.left:ie.left+ie.width/2,y.x)),y:Math.min(L===jt.Down?ie.bottom-ie.height/2:ie.bottom,Math.max(L===jt.Down?ie.top:ie.top+ie.height/2,y.y))},ve=L===jt.Right&&!B||L===jt.Left&&!Y,U=L===jt.Down&&!P||L===jt.Up&&!A;if(ve&&he.x!==y.x){const K=E.scrollLeft+S.x,W=L===jt.Right&&K<=q.x||L===jt.Left&&K>=re.x;if(W&&!S.y){E.scrollTo({left:K,behavior:p});return}W?w.x=E.scrollLeft-K:w.x=L===jt.Right?E.scrollLeft-q.x:E.scrollLeft-re.x,w.x&&E.scrollBy({left:-w.x,behavior:p});break}else if(U&&he.y!==y.y){const K=E.scrollTop+S.y,W=L===jt.Down&&K<=q.y||L===jt.Up&&K>=re.y;if(W&&!S.x){E.scrollTo({top:K,behavior:p});return}W?w.y=E.scrollTop-K:w.y=L===jt.Down?E.scrollTop-q.y:E.scrollTop-re.y,w.y&&E.scrollBy({top:-w.y,behavior:p});break}}this.handleMove(t,Bl(vh(y,this.referenceCoordinates),w))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}mw.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=pw,onActivation:l}=t,{active:c}=r;const{code:h}=e.nativeEvent;if(s.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function tS(e){return!!(e&&"distance"in e)}function iS(e){return!!(e&&"delay"in e)}class Tg{constructor(t,r,s){var l;s===void 0&&(s=kE(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=r;const{event:c}=t,{target:h}=c;this.props=t,this.events=r,this.document=Wl(h),this.documentListeners=new ac(this.document),this.listeners=new ac(s),this.windowListeners=new ac(bn(h)),this.initialCoordinates=(l=Ip(c))!=null?l:fr,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:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Zn.Resize,this.handleCancel),this.windowListeners.add(Zn.DragStart,eS),this.windowListeners.add(Zn.VisibilityChange,this.handleCancel),this.windowListeners.add(Zn.ContextMenu,eS),this.documentListeners.add(Zn.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(iS(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(tS(r)){this.handlePending(r);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,r){const{active:s,onPending:l}=this.props;l(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Zn.Click,EE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zn.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:l,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!l)return;const g=(r=Ip(t))!=null?r:fr,f=vh(l,g);if(!s&&p){if(tS(p)){if(p.tolerance!=null&&cp(f,p.tolerance))return this.handleCancel();if(cp(f,p.distance))return this.handleStart()}if(iS(p)&&cp(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===jt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const DE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gw extends Tg{constructor(t){const{event:r}=t,s=Wl(r.target);super(t,DE,s)}}gw.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s?.({event:r}),!0)}}];const RE={move:{name:"mousemove"},end:{name:"mouseup"}};var Wp;(function(e){e[e.RightClick=2]="RightClick"})(Wp||(Wp={}));class _w extends Tg{constructor(t){super(t,RE,Wl(t.event.target))}}_w.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===Wp.RightClick?!1:(s?.({event:r}),!0)}}];const up={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class vw extends Tg{constructor(t){super(t,up)}static setup(){return window.addEventListener(up.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(up.move.name,t)};function t(){}}}vw.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:l}=r;return l.length>1?!1:(s?.({event:r}),!0)}}];var lc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(lc||(lc={}));var bh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bh||(bh={}));function ME(e){let{acceleration:t,activator:r=lc.Pointer,canScroll:s,draggingRect:l,enabled:c,interval:h=5,order:p=bh.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:S}=e;const w=AE({delta:y,disabled:!c}),[k,E]=qk(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),B=v.useMemo(()=>{switch(r){case lc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case lc.DraggableRect:return l}},[r,l,g]),Y=v.useRef(null),P=v.useCallback(()=>{const re=Y.current;if(!re)return;const ie=L.current.x*A.current.x,he=L.current.y*A.current.y;re.scrollBy(ie,he)},[]),q=v.useMemo(()=>p===bh.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!B){E();return}for(const re of q){if(s?.(re)===!1)continue;const ie=f.indexOf(re),he=b[ie];if(!he)continue;const{direction:ve,speed:U}=yE(re,he,B,t,S);for(const K of["x","y"])w[K][ve[K]]||(U[K]=0,ve[K]=0);if(U.x>0||U.y>0){E(),Y.current=re,k(P,h),L.current=U,A.current=ve;return}}L.current={x:0,y:0},A.current={x:0,y:0},E()},[t,P,s,E,c,h,JSON.stringify(B),JSON.stringify(w),k,f,q,b,JSON.stringify(S)])}const NE={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function AE(e){let{delta:t,disabled:r}=e;const s=Hp(t);return Tc(l=>{if(r||!s||!l)return NE;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[ji.Backward]:l.x[ji.Backward]||c.x===-1,[ji.Forward]:l.x[ji.Forward]||c.x===1},y:{[ji.Backward]:l.y[ji.Backward]||c.y===-1,[ji.Forward]:l.y[ji.Forward]||c.y===1}}},[r,t,s])}function LE(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return Tc(l=>{var c;return t==null?null:(c=s??l)!=null?c:null},[s,t])}function BE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{const{sensor:l}=s,c=l.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,s)}));return[...r,...c]},[]),[e,t])}var pc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(pc||(pc={}));var Fp;(function(e){e.Optimized="optimized"})(Fp||(Fp={}));const nS=new Map;function OE(e,t){let{dragging:r,dependencies:s,config:l}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=l,b=v.useRef(e),y=L(),S=fc(y),w=v.useCallback(function(A){A===void 0&&(A=[]),!S.current&&h(B=>B===null?A:B.concat(A.filter(Y=>!B.includes(Y))))},[S]),k=v.useRef(null),E=Tc(A=>{if(y&&!r)return nS;if(!A||A===nS||b.current!==e||c!=null){const B=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){B.set(Y.id,Y.rect.current);continue}const P=Y.node.current,q=P?new Eg(g(P),P):null;Y.rect.current=q,q&&B.set(Y.id,q)}return B}return A},[e,c,r,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||w()},[r,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof p!="number"||k.current!==null||(k.current=setTimeout(()=>{w(),k.current=null},p))},[p,y,w,...s]),{droppableRects:E,measureDroppableContainers:w,measuringScheduled:c!=null};function L(){switch(f){case pc.Always:return!1;case pc.BeforeDragging:return r;default:return!r}}}function yw(e,t){return Tc(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function zE(e,t){return yw(e,t)}function jE(e){let{callback:t,disabled:r}=e;const s=xg(t),l=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,r]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function Wh(e){let{callback:t,disabled:r}=e;const s=xg(t),l=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[r]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function PE(e){return new Eg(Dc(e),e)}function rS(e,t,r){t===void 0&&(t=PE);const[s,l]=v.useState(null);function c(){l(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??r)!=null?f:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=jE({callback(g){if(e)for(const f of g){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Wh({callback:c});return Gs(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),s}function HE(e){const t=yw(e);return lw(e,t)}const sS=[];function IE(e){const t=v.useRef(e),r=Tc(s=>e?s&&s!==sS&&e&&t.current&&e.parentNode===t.current.parentNode?s:kg(e):sS,[e]);return v.useEffect(()=>{t.current=e},[e]),r}function UE(e){const[t,r]=v.useState(null),s=v.useRef(e),l=v.useCallback(c=>{const h=op(c.target);h&&r(p=>p?(p.set(h,Kp(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){h(c);const p=e.map(g=>{const f=op(g);return f?(f.addEventListener("scroll",l,{passive:!0}),[f,Kp(f)]):null}).filter(g=>g!=null);r(p.length?new Map(p):null),s.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=op(g);f?.removeEventListener("scroll",l)})}},[l,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>Bl(c,h),fr):fw(e):fr,[e,t])}function aS(e,t){t===void 0&&(t=[]);const r=v.useRef(null);return v.useEffect(()=>{r.current=null},t),v.useEffect(()=>{const s=e!==fr;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?vh(e,r.current):fr}function KE(e){v.useEffect(()=>{if(!Uh)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function WE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{let{eventName:l,handler:c}=s;return r[l]=h=>{c(h,t)},r},{}),[e,t])}function bw(e){return v.useMemo(()=>e?mE(e):null,[e])}const lS=[];function FE(e,t){t===void 0&&(t=Dc);const[r]=e,s=bw(r?bn(r):null),[l,c]=v.useState(lS);function h(){c(()=>e.length?e.map(g=>hw(g)?s:new Eg(t(g),g)):lS)}const p=Wh({callback:h});return Gs(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),l}function qE(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ec(t)?t:e}function $E(e){let{measure:t}=e;const[r,s]=v.useState(null),l=v.useCallback(f=>{for(const{target:b}of f)if(Ec(b)){s(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=Wh({callback:l}),h=v.useCallback(f=>{const b=qE(f);c?.disconnect(),b&&c?.observe(b),s(b?t(b):null)},[t,c]),[p,g]=_h(h);return v.useMemo(()=>({nodeRef:p,rect:r,setRef:g}),[r,p,g])}const VE=[{sensor:gw,options:{}},{sensor:mw,options:{}}],YE={current:{}},nh={draggable:{measure:Jb},droppable:{measure:Jb,strategy:pc.WhileDragging,frequency:Fp.Optimized},dragOverlay:{measure:Dc}};class oc extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const XE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new oc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nh,measureDroppableContainers:yh,windowRect:null,measuringScheduled:!1},GE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yh,draggableNodes:new Map,over:null,measureDroppableContainers:yh},Fh=v.createContext(GE),ZE=v.createContext(XE);function QE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new oc}}}function JE(e,t){switch(t.type){case Ri.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ri.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 Ri.DragEnd:case Ri.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ri.RegisterDroppable:{const{element:r}=t,{id:s}=r,l=new oc(e.droppable.containers);return l.set(s,r),{...e,droppable:{...e.droppable,containers:l}}}case Ri.SetDroppableDisabled:{const{id:r,key:s,disabled:l}=t,c=e.droppable.containers.get(r);if(!c||s!==c.key)return e;const h=new oc(e.droppable.containers);return h.set(r,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:h}}}case Ri.UnregisterDroppable:{const{id:r,key:s}=t,l=e.droppable.containers.get(r);if(!l||s!==l.key)return e;const c=new oc(e.droppable.containers);return c.delete(r),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function e2(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:l}=v.useContext(Fh),c=Hp(s),h=Hp(r?.id);return v.useEffect(()=>{if(!t&&!s&&c&&h!=null){if(!sw(c)||document.activeElement===c.target)return;const p=l.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[g.current,f.current]){if(!b)continue;const y=Yk(b);if(y){y.focus();break}}})}},[s,t,l,h,c]),null}function t2(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...s}),r):r}function i2(e){return v.useMemo(()=>({draggable:{...nh.draggable,...e?.draggable},droppable:{...nh.droppable,...e?.droppable},dragOverlay:{...nh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function n2(e){let{activeNode:t,measure:r,initialRect:s,config:l=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof l=="boolean"?{x:l,y:l}:l;Gs(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=r(f),y=lw(b,s);if(h||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=ow(f);S&&S.scrollBy({top:y.y,left:y.x})}},[t,h,p,s,r])}const Sw=v.createContext({...fr,scaleX:1,scaleY:1});var Fs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Fs||(Fs={}));const r2=v.memo(function(t){var r,s,l,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:b=VE,collisionDetection:y=oE,measuring:S,modifiers:w,...k}=t;const E=v.useReducer(JE,void 0,QE),[L,A]=E,[B,Y]=eE(),[P,q]=v.useState(Fs.Uninitialized),re=P===Fs.Initialized,{draggable:{active:ie,nodes:he,translate:ve},droppable:{containers:U}}=L,K=ie!=null?he.get(ie):null,W=v.useRef({initial:null,translated:null}),H=v.useMemo(()=>{var St;return ie!=null?{id:ie,data:(St=K?.data)!=null?St:YE,rect:W}:null},[ie,K]),j=v.useRef(null),[le,R]=v.useState(null),[X,Z]=v.useState(null),Ce=fc(k,Object.values(k)),Te=Kh("DndDescribedBy",h),M=v.useMemo(()=>U.getEnabled(),[U]),Q=i2(S),{droppableRects:de,measureDroppableContainers:me,measuringScheduled:ge}=OE(M,{dragging:re,dependencies:[ve.x,ve.y],config:Q.droppable}),Se=LE(he,ie),Ee=v.useMemo(()=>X?Ip(X):null,[X]),De=Ci(),Ue=zE(Se,Q.draggable.measure);n2({activeNode:ie!=null?he.get(ie):null,config:De.layoutShiftCompensation,initialRect:Ue,measure:Q.draggable.measure});const se=rS(Se,Q.draggable.measure,Ue),pe=rS(Se?Se.parentElement:null),Le=v.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:de,draggableNodes:he,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ye=U.getNodeFor((r=Le.current.over)==null?void 0:r.id),Me=$E({measure:Q.dragOverlay.measure}),Pe=(s=Me.nodeRef.current)!=null?s:Se,ze=re?(l=Me.rect)!=null?l:se:null,te=!!(Me.nodeRef.current&&Me.rect),ke=HE(te?null:se),Re=bw(Pe?bn(Pe):null),Be=IE(re?ye??Se:null),je=FE(Be),at=t2(w,{transform:{x:ve.x-ke.x,y:ve.y-ke.y,scaleX:1,scaleY:1},activatorEvent:X,active:H,activeNodeRect:se,containerNodeRect:pe,draggingNodeRect:ze,over:Le.current.over,overlayNodeRect:Me.rect,scrollableAncestors:Be,scrollableAncestorRects:je,windowRect:Re}),Wt=Ee?Bl(Ee,ve):null,$e=UE(Be),kt=aS($e),ei=aS($e,[se]),Et=Bl(at,kt),_e=ze?hE(ze,at):null,We=H&&_e?y({active:H,collisionRect:_e,droppableRects:de,droppableContainers:M,pointerCoordinates:Wt}):null,Je=aE(We,"id"),[ct,Pt]=v.useState(null),Tt=te?at:Bl(at,ei),Lt=cE(Tt,(c=ct?.rect)!=null?c:null,se),Dt=v.useRef(null),F=v.useCallback((St,wt)=>{let{sensor:Yt,options:Ft}=wt;if(j.current==null)return;const Ai=he.get(j.current);if(!Ai)return;const ti=St.nativeEvent,di=new Yt({active:j.current,activeNode:Ai,event:ti,options:Ft,context:Le,onAbort(qt){if(!he.get(qt))return;const{onDragAbort:gt}=Ce.current,Gt={id:qt};gt?.(Gt),B({type:"onDragAbort",event:Gt})},onPending(qt,Wi,gt,Gt){if(!he.get(qt))return;const{onDragPending:Zi}=Ce.current,Qi={id:qt,constraint:Wi,initialCoordinates:gt,offset:Gt};Zi?.(Qi),B({type:"onDragPending",event:Qi})},onStart(qt){const Wi=j.current;if(Wi==null)return;const gt=he.get(Wi);if(!gt)return;const{onDragStart:Gt}=Ce.current,ln={activatorEvent:ti,active:{id:Wi,data:gt.data,rect:W}};Xo.unstable_batchedUpdates(()=>{Gt?.(ln),q(Fs.Initializing),A({type:Ri.DragStart,initialCoordinates:qt,active:Wi}),B({type:"onDragStart",event:ln}),R(Dt.current),Z(ti)})},onMove(qt){A({type:Ri.DragMove,coordinates:qt})},onEnd:Xt(Ri.DragEnd),onCancel:Xt(Ri.DragCancel)});Dt.current=di;function Xt(qt){return async function(){const{active:gt,collisions:Gt,over:ln,scrollAdjustedTranslate:Zi}=Le.current;let Qi=null;if(gt&&Zi){const{cancelDrop:dn}=Ce.current;Qi={activatorEvent:ti,active:gt,collisions:Gt,delta:Zi,over:ln},qt===Ri.DragEnd&&typeof dn=="function"&&await Promise.resolve(dn(Qi))&&(qt=Ri.DragCancel)}j.current=null,Xo.unstable_batchedUpdates(()=>{A({type:qt}),q(Fs.Uninitialized),Pt(null),R(null),Z(null),Dt.current=null;const dn=qt===Ri.DragEnd?"onDragEnd":"onDragCancel";if(Qi){const Li=Ce.current[dn];Li?.(Qi),B({type:dn,event:Qi})}})}}},[he]),Ie=v.useCallback((St,wt)=>(Yt,Ft)=>{const Ai=Yt.nativeEvent,ti=he.get(Ft);if(j.current!==null||!ti||Ai.dndKit||Ai.defaultPrevented)return;const di={active:ti};St(Yt,wt.options,di)===!0&&(Ai.dndKit={capturedBy:wt.sensor},j.current=Ft,F(Yt,wt))},[he,F]),it=BE(b,Ie);KE(b),Gs(()=>{se&&P===Fs.Initializing&&q(Fs.Initialized)},[se,P]),v.useEffect(()=>{const{onDragMove:St}=Ce.current,{active:wt,activatorEvent:Yt,collisions:Ft,over:Ai}=Le.current;if(!wt||!Yt)return;const ti={active:wt,activatorEvent:Yt,collisions:Ft,delta:{x:Et.x,y:Et.y},over:Ai};Xo.unstable_batchedUpdates(()=>{St?.(ti),B({type:"onDragMove",event:ti})})},[Et.x,Et.y]),v.useEffect(()=>{const{active:St,activatorEvent:wt,collisions:Yt,droppableContainers:Ft,scrollAdjustedTranslate:Ai}=Le.current;if(!St||j.current==null||!wt||!Ai)return;const{onDragOver:ti}=Ce.current,di=Ft.get(Je),Xt=di&&di.rect.current?{id:di.id,rect:di.rect.current,data:di.data,disabled:di.disabled}:null,qt={active:St,activatorEvent:wt,collisions:Yt,delta:{x:Ai.x,y:Ai.y},over:Xt};Xo.unstable_batchedUpdates(()=>{Pt(Xt),ti?.(qt),B({type:"onDragOver",event:qt})})},[Je]),Gs(()=>{Le.current={activatorEvent:X,active:H,activeNode:Se,collisionRect:_e,collisions:We,droppableRects:de,draggableNodes:he,draggingNode:Pe,draggingNodeRect:ze,droppableContainers:U,over:ct,scrollableAncestors:Be,scrollAdjustedTranslate:Et},W.current={initial:ze,translated:_e}},[H,Se,We,_e,he,Pe,ze,de,U,ct,Be,Et]),ME({...De,delta:ve,draggingRect:_e,pointerCoordinates:Wt,scrollableAncestors:Be,scrollableAncestorRects:je});const hi=v.useMemo(()=>({active:H,activeNode:Se,activeNodeRect:se,activatorEvent:X,collisions:We,containerNodeRect:pe,dragOverlay:Me,draggableNodes:he,droppableContainers:U,droppableRects:de,over:ct,measureDroppableContainers:me,scrollableAncestors:Be,scrollableAncestorRects:je,measuringConfiguration:Q,measuringScheduled:ge,windowRect:Re}),[H,Se,se,X,We,pe,Me,he,U,de,ct,me,Be,je,Q,ge,Re]),Gi=v.useMemo(()=>({activatorEvent:X,activators:it,active:H,activeNodeRect:se,ariaDescribedById:{draggable:Te},dispatch:A,draggableNodes:he,over:ct,measureDroppableContainers:me}),[X,it,H,se,A,Te,he,ct,me]);return Mi.createElement(aw.Provider,{value:Y},Mi.createElement(Fh.Provider,{value:Gi},Mi.createElement(ZE.Provider,{value:hi},Mi.createElement(Sw.Provider,{value:Lt},f)),Mi.createElement(e2,{disabled:p?.restoreFocus===!1})),Mi.createElement(nE,{...p,hiddenTextDescribedById:Te}));function Ci(){const St=le?.autoScrollEnabled===!1,wt=typeof g=="object"?g.enabled===!1:g===!1,Yt=re&&!St&&!wt;return typeof g=="object"?{...g,enabled:Yt}:{enabled:Yt}}}),s2=v.createContext(null),oS="button",a2="Draggable";function ww(e){let{id:t,data:r,disabled:s=!1,attributes:l}=e;const c=Kh(a2),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:S}=v.useContext(Fh),{role:w=oS,roleDescription:k="draggable",tabIndex:E=0}=l??{},L=g?.id===t,A=v.useContext(L?Sw:s2),[B,Y]=_h(),[P,q]=_h(),re=WE(h,t),ie=fc(r);Gs(()=>(y.set(t,{id:t,key:c,node:B,activatorNode:P,data:ie}),()=>{const ve=y.get(t);ve&&ve.key===c&&y.delete(t)}),[y,t]);const he=v.useMemo(()=>({role:w,tabIndex:E,"aria-disabled":s,"aria-pressed":L&&w===oS?!0:void 0,"aria-roledescription":k,"aria-describedby":b.draggable}),[s,w,E,L,k,b.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:he,isDragging:L,listeners:s?void 0:re,node:B,over:S,setNodeRef:Y,setActivatorNodeRef:q,transform:A}}const l2="Droppable",o2={timeout:25};function Dg(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:l}=e;const c=Kh(l2),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(Fh),b=v.useRef({disabled:r}),y=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:k,updateMeasurementsFor:E,timeout:L}={...o2,...l},A=fc(E??s),B=v.useCallback(()=>{if(!y.current){y.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),w.current=null},L)},[L]),Y=Wh({callback:B,disabled:k||!h}),P=v.useCallback((he,ve)=>{Y&&(ve&&(Y.unobserve(ve),y.current=!1),he&&Y.observe(he))},[Y]),[q,re]=_h(P),ie=fc(t);return v.useEffect(()=>{!Y||!q.current||(Y.disconnect(),y.current=!1,Y.observe(q.current))},[q,Y]),v.useEffect(()=>(p({type:Ri.RegisterDroppable,element:{id:s,key:c,disabled:r,node:q,rect:S,data:ie}}),()=>p({type:Ri.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{r!==b.current.disabled&&(p({type:Ri.SetDroppableDisabled,id:s,key:c,disabled:r}),b.current.disabled=r)},[s,c,r,p]),{active:h,rect:S,isOver:g?.id===s,node:q,over:g,setNodeRef:re}}const c2=128,u2=512,Fl=100,h2="too_many_detached_terminals",d2=64,f2=4096;function Cw(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>c2)return null;const r=t.workspaces.map(p2);return r.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function xw(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(r=>{if(!r||typeof r!="object")return!1;const s=r.detachedTerminalIds;return Array.isArray(s)&&s.length>Fl}):!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>u2)return null;const r=t.tabs.map(m2);if(r.some(l=>l===null))return null;const s=y2(t.detachedTerminalIds,Fl);return s===null?null:{id:t.id,title:t.title,defaultCwd:v2(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:r}}function m2(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 r=g2(t.root);return r?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:r}:null}function g2(e){if(!e||typeof e!="object")return null;let t=0;return qp(e,1,()=>(t+=1,t<=f2))}function qp(e,t,r){if(!e||typeof e!="object"||t>d2||!r())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const l=qp(s.first,t+1,r),c=qp(s.second,t+1,r);return!l||!c?null:{type:"split",direction:s.direction,ratio:_2(s.ratio),first:l,second:c}}function _2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function v2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function y2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const r=new Set,s=[];for(const l of e)typeof l!="string"||!l||r.has(l)||(r.add(l),s.push(l));return s}const kw=[{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"}],Ew="nterminal.notifications.completionEnabled",Rg="nterminal.notifications.completionToastEnabled",Mg="nterminal.notifications.completionToastDurationSeconds",Ng="nterminal.notifications.completionToastPersistent",$p="nterminal:completion-toast-display",cc=6.5,Vp=2,Yp=60;function qh(){return typeof window<"u"&&"Notification"in window}function Ag(){try{return window.localStorage.getItem(Ew)==="true"}catch{return!1}}function cS(e){try{window.localStorage.setItem(Ew,e?"true":"false")}catch{}}function Pa(){return{enabled:C2(),durationSeconds:w2(),persistUntilDismissed:x2()}}function b2(e){if(typeof window<"u"){try{window.localStorage.setItem(Rg,e?"true":"false")}catch{}Lg()}return Pa()}function uS(e){const t=Dw(e);if(typeof window<"u"){try{window.localStorage.setItem(Mg,String(t))}catch{}Lg()}return Pa()}function S2(e){if(typeof window<"u"){try{window.localStorage.setItem(Ng,e?"true":"false")}catch{}Lg()}return Pa()}function Tw(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Rg||r.key===Mg||r.key===Ng)&&e()};return window.addEventListener($p,e),window.addEventListener("storage",t),()=>{window.removeEventListener($p,e),window.removeEventListener("storage",t)}}function Rc(){return qh()?window.Notification.permission:"unsupported"}function w2(){if(typeof window>"u")return cc;try{const e=window.localStorage.getItem(Mg);return e===null?cc:Dw(Number(e))}catch{return cc}}function C2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Rg)!=="false"}catch{return!0}}function x2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ng)==="true"}catch{return!1}}function Dw(e){if(!Number.isFinite(e))return cc;const t=Math.round(e*2)/2;return Math.max(Vp,Math.min(Yp,t))}function Lg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent($p))}async function Rw(){if(!qh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Rc()}}function k2(e){if(!qh()||Rc()!=="granted"||!Ag()||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 hS="nterminal.push.clientId",E2=2e4;function La(){try{const e=window.localStorage.getItem(hS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Xp()}`;return window.localStorage.setItem(hS,t),t}catch{return`client-${Xp()}`}}function T2(){return`page-${Xp()}`}function Bg(){const e=typeof window<"u"&&window.isSecureContext===!0,t=A2(),r=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone";return{supported:r,secure:e,displayMode:t,deviceKind:L2(),reason:e?t!=="standalone"?"not_standalone":r?"supported":"unsupported":"insecure"}}async function D2(e,t){const r=Bg();if(!r.supported)throw new Error(r.reason);if((Rc()==="granted"?"granted":await Rw())!=="granted")throw new Error("permission_denied");const l=La(),c=await navigator.serviceWorker.register("/sw.js"),h=await e.preparePushNotifications(l),g=await j2(c,h.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:H2(h.publicKey)});await e.subscribePushNotifications({clientId:l,subscription:z2(g),deviceKind:r.deviceKind,displayMode:r.displayMode,label:B2(r.deviceKind),alwaysNotify:t})}async function R2(e){const t=La();let r;try{const l=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();r=l?.endpoint,await l?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...r?{endpoint:r}:{}})}async function M2(e,t){await e.updatePushNotificationDevice({clientId:La(),alwaysNotify:t})}function N2(e){if(typeof window>"u")return()=>{};const t=La(),r=T2();let s=null,l=!1;const c=(f=!0)=>{const b=Bg();e.updatePushPresence({clientId:t,pageId:r,visibilityState:O2(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:Ag()&&Rc()==="granted",active:f}).catch(()=>{})},h=()=>{l||s!==null||(s=window.setInterval(()=>c(!0),E2))},p=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",p),window.addEventListener("blur",p),document.addEventListener("visibilitychange",p),window.addEventListener("pagehide",g),c(!0),h(),()=>{l=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",p),window.removeEventListener("blur",p),document.removeEventListener("visibilitychange",p),window.removeEventListener("pagehide",g),c(!1)}}function A2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function L2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function B2(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function O2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function z2(e){const t=e.toJSON(),r=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!r||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:r,auth:s}}}async function j2(e,t){const r=await e.pushManager.getSubscription();return r?P2(r,t)?r:(await r.unsubscribe(),null):null}function P2(e,t){const r=e.options.applicationServerKey;return r?I2(r)===t:!0}function H2(e){const t="=".repeat((4-e.length%4)%4),r=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(r),l=new ArrayBuffer(s.length),c=new Uint8Array(l);for(let h=0;h<s.length;h+=1)c[h]=s.charCodeAt(h);return l}function I2(e){const t=new Uint8Array(e);let r="";for(const s of t)r+=String.fromCharCode(s);return window.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Xp(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const Na="__main__";function U2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function K2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const dS="Local",W2=3e4,F2=2,q2=6,Mw="nterminal.serverList.viewMode.v1";function $2(){try{return window.localStorage.getItem(Mw)==="list"?"list":"stats"}catch{return"stats"}}function V2(e){try{window.localStorage.setItem(Mw,e)}catch{}}function Ta(e,t){const r=[Na,...t.map(h=>h.id)],s=new Set(r),l=new Set,c=[];for(const h of e??[])!s.has(h)||l.has(h)||(l.add(h),c.push(h));for(const h of r)l.has(h)||c.push(h);return c}function Y2(e,t){const r=new Map(e.map(s=>[s.id,s]));return Ta(t,e).flatMap(s=>{if(s===Na)return[{kind:"main",id:Na}];const l=r.get(s);return l?[{kind:"agent",id:s,agent:l}]:[]})}function fS(e,t){return e.length===t.length&&e.every((r,s)=>r===t[s])}function Nw(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Jn(e.cpuPercent)} ${Og(e)}`,`MEM ${Jn(e.memoryPercent)} ${is(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Jn(e.diskPercent)} ${is(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Jn(e.swapPercent)} ${is(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function X2(e){if(!(e===void 0||e==="error"))return[`CPU ${Jn(e.cpuPercent)} (${Og(e)})`,`RAM ${Jn(e.memoryPercent)} (${is(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Jn(e.diskPercent)} (${is(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Jn(e.swapPercent)} (${is(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function G2(e,t){const r=Nw(t);return`${e}${r?` — ${r}`:""}. Double-click to rename.`}function Jn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Og(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`:`${Gp(e.cpuPercent/100*t)}/${t} cores`}function is(e,t){return!pS(e)||!pS(t)?"–/–":Z2(e,t)}function Z2(e,t){const r=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=r==="GB"?1024**3:r==="MB"?1024**2:1024;return`${Gp(e/s)}/${Gp(t/s)} ${r}`}function Gp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function pS(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 Q2(e){return[{label:"CPU",percent:Jn(e.cpuPercent),detail:Og(e),tone:Wu(e.cpuPercent)},{label:"MEM",percent:Jn(e.memoryPercent),detail:is(e.memoryUsedBytes,e.memoryTotalBytes),tone:Wu(e.memoryPercent)},{label:"DISK",percent:Jn(e.diskPercent),detail:is(e.diskUsedBytes,e.diskTotalBytes),tone:Wu(e.diskPercent)},{label:"SWAP",percent:Jn(e.swapPercent),detail:is(e.swapUsedBytes,e.swapTotalBytes),tone:Wu(e.swapPercent)}]}function J2({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:X2(e),children:Q2(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 mS({api:e,activeAgentId:t,onSelectServer:r,onSessionInvalid:s,refreshToken:l=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,b]=v.useState([Na]),[y,S]=v.useState(null),[w,k]=v.useState(null),[E,L]=v.useState(""),A=v.useRef(null),[B,Y]=v.useState(()=>$2()),[P,q]=v.useState(null),[re,ie]=v.useState(null),[he,ve]=v.useState({}),U=v.useRef({}),K=v.useRef(0),W=v.useRef([]),H=v.useRef([Na]),j=v.useRef(null);v.useEffect(()=>{W.current=p},[p]),v.useEffect(()=>{const se=Ta(f,p);H.current=se,fS(se,f)||b(se)},[p,f]),v.useEffect(()=>{let se=!1;return e.listAgents().then(pe=>{se||(g(pe.agents),b(Ta(pe.serverOrder,pe.agents)))}).catch(()=>{}),e.getMainInfo().then(pe=>{se||S(pe.name)}).catch(()=>{}),()=>{se=!0}},[e,l]),v.useEffect(()=>{w&&(A.current?.focus(),A.current?.select())},[w]),v.useEffect(()=>{let se=!1;function pe(){const ye=[{key:"__main__",load:()=>e.getMainStats()},...p.map(Pe=>({key:Pe.id,load:()=>e.getAgentStats(Pe.id)}))],Me=new Set(ye.map(Pe=>Pe.key));for(const Pe of Object.keys(U.current))Me.has(Pe)||delete U.current[Pe];ve(Pe=>{const ze={};for(const te of Me)te in Pe&&(ze[te]=Pe[te]);return ze});for(const Pe of ye)Pe.load().then(ze=>{se||(U.current[Pe.key]=0,ve(te=>Me.has(Pe.key)?{...te,[Pe.key]:ze}:te))}).catch(ze=>{if(se)return;if(ze instanceof dr&&ze.status===401&&Pe.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const te=(U.current[Pe.key]??0)+1;U.current[Pe.key]=te,te>=F2&&ve(ke=>Me.has(Pe.key)?{...ke,[Pe.key]:"error"}:ke)})}pe();const Le=window.setInterval(pe,W2);return()=>{se=!0,window.clearInterval(Le)}},[e,p,s]);function le(se){se==="main"?(L(y??""),k({kind:"main"})):(L(se.name),k({kind:"agent",id:se.id}))}async function R(){if(!w)return;const se=E.trim(),pe=w;if(k(null),pe.kind==="main"){const Le=se||"";try{const ye=await e.renameMain(Le);S(ye.name)}catch{}}else{if(!se)return;const Le=p.find(ye=>ye.id===pe.id)?.name;g(ye=>ye.map(Me=>Me.id===pe.id?{...Me,name:se}:Me));try{await e.renameAgent(pe.id,se)}catch{Le!==void 0&&g(ye=>ye.map(Me=>Me.id===pe.id?{...Me,name:Le}:Me))}}}function X(){k(null)}function Z(se){Y(se),V2(se)}function Ce(se,pe,Le){if(se===pe)return;const ye=Ta(H.current,W.current),Me=ye.findIndex(je=>je===se),Pe=ye.findIndex(je=>je===pe);if(Me<0||Pe<0)return;const ze=[...ye],[te]=ze.splice(Me,1);if(!te)return;const ke=ze.findIndex(je=>je===pe);if(ke<0)return;const Re=Le==="before"?ke:ke+1;if(ze.splice(Re,0,te),fS(ze,ye))return;const Be=K.current+1;K.current=Be,H.current=ze,b(ze),e.reorderAgents(ze).then(je=>{if(K.current===Be){W.current=je.agents;const at=Ta(je.serverOrder,je.agents);H.current=at,g(je.agents),b(at)}}).catch(async()=>{if(K.current===Be)try{const je=await e.listAgents();if(K.current===Be){W.current=je.agents;const at=Ta(je.serverOrder,je.agents);H.current=at,g(je.agents),b(at)}}catch{K.current===Be&&(H.current=ye,b(ye))}})}function Te(se,pe){const Le=Ta(H.current,W.current),ye=Le.findIndex(Pe=>Pe===se),Me=Le[ye+pe];ye<0||!Me||Ce(se,Me,pe<0?"before":"after")}function M(se,pe){pe.pointerType==="mouse"&&pe.button!==0||(pe.stopPropagation(),j.current={sourceId:se,pointerId:pe.pointerId,startX:pe.clientX,startY:pe.clientY,active:!1,targetId:null,placement:"after"},pe.currentTarget.setPointerCapture?.(pe.pointerId))}function Q(se){const pe=j.current;if(!pe||pe.pointerId!==se.pointerId)return;const Le=Math.hypot(se.clientX-pe.startX,se.clientY-pe.startY);if(!pe.active){if(Le<q2)return;pe.active=!0,q(pe.sourceId)}const Me=document.elementFromPoint(se.clientX,se.clientY)?.closest("[data-server-id]"),Pe=Me?.dataset.serverId??null;if(!Me||!Pe||Pe===pe.sourceId){pe.targetId=null,ie(null);return}const ze=Me.getBoundingClientRect(),te=se.clientY<ze.top+ze.height/2?"before":"after";pe.targetId=Pe,pe.placement=te,ie({serverId:Pe,placement:te})}function de(se){const pe=j.current;!pe||pe.pointerId!==se.pointerId||(se.stopPropagation(),se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ie(null),pe.active&&pe.targetId&&Ce(pe.sourceId,pe.targetId,pe.placement))}function me(se){const pe=j.current;pe&&pe.pointerId===se.pointerId&&se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ie(null)}const ge=y?.trim()||dS,Se=w?.kind==="main",Ee=B==="stats",De=Y2(p,f),Ue=De.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:De.map(se=>{const pe=se.kind==="main",Le=pe?ge:se.agent.name,ye=pe?Na:se.id,Me=he[ye],Pe=Nw(Me);return m.jsxs("button",{type:"button",className:`server-list-chip${(pe?t===null:t===se.id)?" server-list-chip--active":""}`,onClick:()=>r(pe?null:se.id),"aria-label":Le,title:`${Le}${Pe?` — ${Pe}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:K2(Le)}),m.jsx("span",{className:"server-list-chip-pip","data-status":U2(Me)})]},se.id)})}):m.jsxs("div",{className:`server-list server-list--${B}`,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":B==="list",onClick:()=>Z("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":B==="stats",onClick:()=>Z("stats"),title:"Show resource usage",children:"Stats"})]}),De.map(se=>{const pe=se.kind==="main",Le=pe?ge:se.agent.name,ye=pe?Na:se.id,Me=pe?t===null:t===se.id,Pe=pe?Se:w?.kind==="agent"&&w.id===se.id,ze=c?.({agentId:pe?null:se.id,serverId:se.id,label:Le,active:Me}),te=re?.serverId===se.id&&P!==se.id?` server-list-section--drop-target server-list-section--drop-${re.placement}`:"";return m.jsxs("section",{className:`server-list-section${te}`,"aria-label":`${Le} server`,children:[m.jsx("div",{className:["server-list-row",P===se.id?"server-list-row--dragging":"",re?.serverId===se.id&&P!==se.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":se.id,children:Pe?m.jsxs(m.Fragment,{children:[Ue?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:ke=>{ke.preventDefault(),R()},children:m.jsx("input",{ref:A,"aria-label":pe?"Rename main server":`Rename ${Le}`,value:E,onChange:ke=>L(ke.target.value),onBlur:()=>{R()},onKeyDown:ke=>{ke.key==="Escape"&&(ke.preventDefault(),X())},placeholder:pe?dS:void 0})})]}):m.jsxs(m.Fragment,{children:[Ue?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":se.id,title:"Drag to reorder","aria-label":`Reorder ${Le}`,"aria-grabbed":P===se.id,onPointerDown:ke=>M(se.id,ke),onPointerMove:Q,onPointerUp:de,onPointerCancel:me,onKeyDown:ke=>{(ke.key==="ArrowUp"||ke.key==="ArrowDown")&&(ke.preventDefault(),ke.stopPropagation(),Te(se.id,ke.key==="ArrowUp"?-1:1))},onClick:ke=>ke.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Me?" server-list-item--active":""}`,onClick:()=>r(pe?null:se.id),onDoubleClick:ke=>{ke.preventDefault(),le(pe?"main":{id:se.id,name:Le})},title:G2(Le,he[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:pe?void 0:se.agent.url,children:Le})]}),Ee?m.jsx(J2,{entry:he[ye]}):null]})]})}),ze?m.jsx("div",{className:"server-list-children",children:ze}):null]},se.id)})]})}function eT({api:e}){const[t,r]=v.useState([]),[s,l]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,b]=v.useState(""),[y,S]=v.useState("");async function w(){try{const[A,B,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);r(A.devices),l(B.networks),h(Y.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function k(A){await e.revokeDevice(A),await w()}async function E(A){await e.removeNetwork(A),await w()}async function L(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),S(""),await w()}catch(B){g(B instanceof Error?B.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[p?m.jsx("p",{className:"form-error",children:p}):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(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[A.label,A.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(A.id)},children:"revoke"})]},A.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."}),s.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:s.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?m.jsx("span",{className:"security-item-meta",children:A.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{E(A.id)},children:"remove"})]},A.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:L,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:A=>b(A.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:A=>S(A.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!f.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 w()},children:"Disable 2FA"})]}):null]})}const tT=1500,zg="nterminal.terminal.fontSize",jg="nterminal.terminal.fontFamily",Zp="nterminal:terminal-font-size",Qp="nterminal:terminal-font-family",Jp=11,em=20,Ba=14,Sh=[{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:[]}],jl="meslo";tm(jl);async function hp(e=Ba,t=jl){if(typeof document>"u"||!document.fonts)return;const r=Bw(t).webFontFamilies;if(r.length===0)return;const s=Promise.all(r.map(l=>document.fonts.load(`${e}px ${l}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(l=>{globalThis.setTimeout(l,tT)})])}function Aw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Ba;const r=Math.round(t);return Math.max(Jp,Math.min(em,r))}function Lw(e){return Sh.some(t=>t.id===e)?e:jl}function tm(e){return Bw(e).cssFamily}function Bw(e){return Sh.find(t=>t.id===e)??Sh[0]}function im(){if(typeof window>"u")return Ba;try{const e=window.localStorage.getItem(zg);return e?Aw(e):Ba}catch{return Ba}}function nm(){if(typeof window>"u")return jl;try{return Lw(window.localStorage.getItem(jg))}catch{return jl}}function Fu(e){const t=Aw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(zg,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Zp,{detail:t})),t}function iT(e){const t=Lw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(jg,t)}catch{}return window.dispatchEvent(new CustomEvent(Qp,{detail:t})),t}function Ow(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===zg&&e()};return window.addEventListener(Zp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Zp,e),window.removeEventListener("storage",t)}}function zw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===jg&&e()};return window.addEventListener(Qp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Qp,e),window.removeEventListener("storage",t)}}const Pg="nterminal.terminal.showScrollProgress",rm="nterminal:terminal-scroll-progress",Hg="nterminal.terminal.tmuxScrollback.shell",Ig="nterminal.terminal.tmuxScrollback.agent",Ug="nterminal.terminal.tmuxScrollback.overrides",mc="nterminal:terminal-tmux-scrollback",nT=200;function sm(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Pg)!=="false"}catch{return!0}}function rT(e){if(typeof window<"u"){try{window.localStorage.setItem(Pg,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(rm,{detail:e}))}return e}function jw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Pg&&e()};return window.addEventListener(rm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(rm,e),window.removeEventListener("storage",t)}}function am(){return Pw(Hg,!0)}function sT(e){return Hw(Hg,e,mc)}function lm(){return Pw(Ig,!0)}function aT(e){return Hw(Ig,e,mc)}function rh(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Hg||r.key===Ig||r.key===Ug)&&e()};return window.addEventListener(mc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(mc,e),window.removeEventListener("storage",t)}}function dp(e){const r=Iw()[e];return typeof r=="boolean"?r:null}function lT(e,t){if(typeof window<"u"){try{const r=Iw(),s=Object.entries(r).filter(([c])=>c!==e);s.push([e,t]);const l=s.slice(-nT);window.localStorage.setItem(Ug,JSON.stringify(Object.fromEntries(l)))}catch{}window.dispatchEvent(new CustomEvent(mc,{detail:{terminalId:e,enabled:t}}))}return t}function Pw(e,t){if(typeof window>"u")return t;try{const r=window.localStorage.getItem(e);if(r==="true")return!0;if(r==="false")return!1}catch{}return t}function Hw(e,t,r){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(r,{detail:t}))}return t}function Iw(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Ug);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const r={};for(const[s,l]of Object.entries(t))typeof l=="boolean"&&(r[s]=l);return r}catch{return{}}}const Kg="nterminal.shortcuts.workspace.v1",om="nterminal:workspace-shortcuts",gc=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],$h={"server.previous":Si("ArrowUp",{ctrlKey:!0}),"server.next":Si("ArrowDown",{ctrlKey:!0}),"tab.previous":Si("ArrowLeft",{ctrlKey:!0}),"tab.next":Si("ArrowRight",{ctrlKey:!0}),"tab.index":Si("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Si("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Si("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Si("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Si("KeyH",{altKey:!0}),"scrollback.toggle":Si("KeyS",{altKey:!0})},oT={"server.previous":Si("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Si("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Si("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Si("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Si("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Si("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Si("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Si("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Si("KeyH",{altKey:!0}),"scrollback.toggle":Si("KeyS",{altKey:!0})};function Ha(){const e=Ww($h);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Kg);if(!t)return e;const r=JSON.parse(t);for(const s of gc){const l=r[s.id];if(gT(l)){const c=Fw(l,s);mT(c,oT[s.id])||(e[s.id]=c)}}}catch{return e}return e}function gS(){return JSON.stringify(Ha())}function cT(e,t){const r=Ha(),s=gc.find(l=>l.id===e);return s&&(r[e]=Fw(t,s),Wg(r)),r}function uT(e){const t=Ha();return t[e]={...$h[e]},Wg(t),t}function hT(){const e=Ww($h);return Wg(e),e}function wh(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Kg&&e()};return window.addEventListener(om,e),window.addEventListener("storage",t),()=>{window.removeEventListener(om,e),window.removeEventListener("storage",t)}}function dT(e,t){const r=Vw(e);return!r||vT(r)||t.indexed&&$w(e)===null||t.requiresPrimaryModifier&&!qw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":r}}function Uw(e){const t=Ha();for(const r of gc){const s=t[r.id];if(!(!s||!_T(e,s))){if(r.indexed){if(s.code!=="Digit")continue;const l=$w(e);if(l!==null)return{id:r.id,index:l};continue}if(Vw(e)===s.code)return{id:r.id,index:null}}}return null}function Ch(e){return Kw(Ha()[e])}function Kw(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(yT(e.code)),t.join("+")}const fT=()=>Ch("split.right"),pT=()=>Ch("split.down");function Si(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Ww(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r}]))}function mT(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Wg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Kg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(om))}}function Fw(e,t){return t.requiresPrimaryModifier&&!qw(e)?{...$h[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function qw(e){return e.ctrlKey||e.altKey||e.metaKey}function gT(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 _T(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function $w(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 Vw(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 vT(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function yT(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const r=/^Key([A-Z])$/.exec(e);if(r?.[1])return r[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 bT="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 ST(e="nterminal",t=new Date){return{reason:"permission",message:bT,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function wT(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 Yw=3600*1e3,CT="local",cm=new Set,Vs=new Map;let Zs={checking:!1,hasUpdates:!1,lastCheckedAt:null},Fg=null,uc=null,xh=0,Ws=null;function xT(e){return cm.add(e),()=>{cm.delete(e)}}function _S(){return Zs}function kT(e){const t=MT();Fg=e,qg(),um(e,t);const r=()=>{if(document.visibilityState!=="visible"||!Qs(e,t))return;const s=Zs.lastCheckedAt;(s===null||Date.now()-s>=Yw)&&um(e,t)};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r),Qs(e,t)&&RT()}}function ET(e,t){Vs.set(e,Xw(t)),Pl({...Zs,hasUpdates:$g(),lastCheckedAt:Date.now()})}function fp(e){e===void 0?Vs.clear():Vs.set(e,!1),Pl({...Zs,hasUpdates:$g()})}async function um(e,t){if(!Qs(e,t))return;if(Ws&&Ws.api===e&&Ws.runId===t)return Ws.promise;Pl({...Zs,checking:!0});const r=TT(e,t).finally(()=>{Ws?.promise===r&&(Ws=null),Qs(e,t)&&(Pl({...Zs,checking:!1,lastCheckedAt:Date.now()}),DT(e,t))});return Ws={api:e,runId:t,promise:r},r}async function TT(e,t){try{const r=await e.listAgents();if(!Qs(e,t))return;const s=[{key:CT,check:()=>e.checkUpdate()},...r.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],l=new Map;if(await Promise.all(s.map(async c=>{try{const h=await c.check();l.set(c.key,Xw(h))}catch{l.set(c.key,Vs.get(c.key)??!1)}})),!Qs(e,t))return;Vs.clear();for(const[c,h]of l)Vs.set(c,h);Pl({...Zs,hasUpdates:$g()})}catch{}}function DT(e,t){Qs(e,t)&&(qg(),uc=window.setTimeout(()=>{uc=null,Qs(e,t)&&um(e,t)},Yw))}function RT(){xh+=1,qg(),Fg=null,Ws=null,Vs.clear(),Pl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function qg(){uc!==null&&(window.clearTimeout(uc),uc=null)}function MT(){return xh+=1,xh}function Qs(e,t){return Fg===e&&xh===t}function Xw(e){return e.updateAvailable===!0}function $g(){return Array.from(Vs.values()).some(Boolean)}function Pl(e){Zs=e;for(const t of Array.from(cm))t()}const NT=e=>new Promise(t=>setTimeout(t,e));function AT({api:e,onAgentRemoved:t}){const[r,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[l,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[b,y]=v.useState(!1);function S(U,K){c(W=>({...W,[U]:{...W[U],...K}}))}const w=U=>U.id===null?e.getVersion():e.getAgentVersion(U.id),k=U=>U.id===null?e.checkUpdate():e.checkAgentUpdate(U.id),E=U=>U.id===null?e.runUpdate():e.runAgentUpdate(U.id);v.useEffect(()=>{let U=!1;return e.listAgents().then(K=>{if(U)return;const W=[{key:"local",id:null,name:"Local (main)"},...K.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];s(W);for(const H of W)w(H).then(j=>S(H.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(H.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{U=!0}},[]);async function L(U){S(U.key,{busy:!0,status:"checking…",error:void 0});try{const K=await k(U);ET(U.key,K),S(U.key,{latestVersion:K.latestVersion,updateAvailable:K.updateAvailable,status:ie(K),...K.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(K){S(U.key,{busy:!1,error:K instanceof Error?K.message:"check failed"})}}async function A(){p(!0),await Promise.all(r.map(U=>L(U))),p(!1)}async function B(U,K){const W=Date.now()+18e4;for(;Date.now()<W;){await NT(3e3);try{const H=await w(U);if(K&&H.runningVersion!==K.runningVersion)return H}catch{}}return null}async function Y(U){let K=l[U.key]?.version;if(!K)try{K=await w(U),S(U.key,{version:K,manualUpdate:K.manualUpdate??null})}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(U.key,{busy:!0,status:"updating…",error:void 0});let W;try{W=await E(U)}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!W.ok){const j=W.manualUpdate??(wT(W.message)?ST():null);return j?(S(U.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(U.key,{busy:!1,status:void 0,error:W.message}),"failed")}if(!W.changed)return S(U.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),fp(U.key),"unchanged";S(U.key,{status:"restarting…"});const H=await B(U,K);return H?(S(U.key,{busy:!1,version:H,updateAvailable:!1,status:"updated",manualUpdate:H.manualUpdate??null}),fp(U.key),U.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(U.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function P(U){if(!(U.id===null||!window.confirm([`Delete secondary server "${U.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
|
-
`)))){S(U.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const W=await e.uninstallAgent(U.id);s(H=>H.filter(j=>j.key!==U.key)),c(H=>{const j={...H};return delete j[U.key],j}),fp(U.key),t?.(U.id),f(W.message)}catch(W){S(U.key,{busy:!1,status:void 0,error:W instanceof Error?W.message:"delete failed"})}}}async function q(){p(!0),f(null);const U=r.filter(R=>R.id!==null),K=r.find(R=>R.id===null),W=await Promise.all(U.map(R=>Y(R))),H=W.filter(R=>R==="failed").length;let j=W.filter(R=>R==="manual").length,le=null;if(K&&(le=await Y(K),le==="manual"&&(j+=1),le==="updated")){H>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}H>0&&j>0?f("Some servers failed and some need manual update. Check each marked row."):H>0?f("Some secondary servers failed to update. Check their rows and retry."):j>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function re(U){return U?U.error?U.error:U.status?U.status:U.manualUpdate?"manual update required":U.version?`v${U.version.version}`:"…":"…"}function ie(U){return U.error?U.error:typeof U.updateAvailable=="boolean"?U.updateAvailable?`latest v${U.latestVersion??"available"}`:"up to date":"unknown"}function he(U){const K=U?.version;return K?`npm package v${K.runningVersion}`:""}async function ve(U,K){try{await LT(K),S(U,{copiedCommand:!0}),window.setTimeout(()=>S(U,{copiedCommand:!1}),1800)}catch(W){S(U,{error:W instanceof Error?W.message:"copy failed"})}}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:()=>{A()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{q()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?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.jsx("ul",{className:"security-list",children:r.map(U=>{const K=l[U.key],W=he(K),H=K?.manualUpdate??null,j=K?.version!==void 0&&K?.updateAvailable!==!1&&!K?.busy&&!h,le=U.id!==null&&!K?.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:U.name}),m.jsxs("span",{className:"security-item-meta",children:[W?`${W} — `:"",re(K)]})]}),H?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:H.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:H.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(U.key,H.command)},children:K?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Y(U)},disabled:!j,children:K?.busy?"…":"Update"}),U.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{P(U)},disabled:!le,children:"Delete"}):null]})]},U.key)})})]})}async function LT(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 qu=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function BT({onClose:e,api:t,updateAvailable:r=!1,onNotificationAssetsChanged:s,onAgentRemoved:l}){const c=v.useMemo(()=>t??Hh(),[t]),[h,p]=v.useState(()=>im()),[g,f]=v.useState(()=>nm()),[b,y]=v.useState(()=>sm()),[S,w]=v.useState(()=>am()),[k,E]=v.useState(()=>lm()),[L,A]=v.useState(()=>Xs()),[B,Y]=v.useState(()=>Ha()),[P,q]=v.useState(null),[re,ie]=v.useState(null),[he,ve]=v.useState("appearance"),[U,K]=v.useState(()=>Ag()),[W,H]=v.useState(()=>Pa()),[j,le]=v.useState(()=>Rc()),[R,X]=v.useState([]),[Z,Ce]=v.useState([]),[Te,M]=v.useState([]),[Q,de]=v.useState(5*1024*1024),[me,ge]=v.useState(!1),[Se,Ee]=v.useState(null),[De,Ue]=v.useState(null),[se,pe]=v.useState(!1),[Le,ye]=v.useState(null),Me=v.useRef(null),Pe=v.useRef(null),ze=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),te=v.useMemo(()=>new Set(Z),[Z]),ke=!zT(Z,Te),Re=v.useMemo(()=>Bg(),[]),Be=De?.displayMode==="standalone"&&(De.deviceKind==="mobile"||De.deviceKind==="tablet");v.useEffect(()=>Ow(()=>p(im())),[]),v.useEffect(()=>zw(()=>f(nm())),[]),v.useEffect(()=>jw(()=>y(sm())),[]),v.useEffect(()=>rh(()=>{w(am()),E(lm())}),[]),v.useEffect(()=>Sg(()=>A(Xs())),[]),v.useEffect(()=>wh(()=>Y(Ha())),[]),v.useEffect(()=>Tw(()=>H(Pa())),[]),v.useEffect(()=>{if(!P)return;const F=gc.find(it=>it.id===P);if(!F)return;const Ie=it=>{if(it.preventDefault(),it.stopPropagation(),it.key==="Escape"){q(null),ie(null);return}const hi=dT(it,F);if(!hi){ie(OT(F));return}Y(cT(P,hi)),q(null),ie(null)};return window.addEventListener("keydown",Ie,!0),()=>window.removeEventListener("keydown",Ie,!0)},[P]),v.useEffect(()=>{let F=!1;return c.listNotificationAssets().then(Ie=>{F||Et(Ie)}).catch(Ie=>{F||Ee(Dl(Ie))}),()=>{F=!0}},[c]),v.useEffect(()=>{let F=!1;return c.getPushNotificationStatus(La()).then(Ie=>{F||(Ue(Ie.currentDevice),ye(null))}).catch(Ie=>{F||ye(Dl(Ie))}),()=>{F=!0}},[c]);function je(F){p(Fu(Number(F)))}function at(F){H(uS(Number(F)))}function Wt(F){ve(F);const Ie=Pe.current,it=ze.current[F];if(!Ie||!it)return;const hi=Math.max(0,vS(it,Ie)-12);typeof Ie.scrollTo=="function"?Ie.scrollTo({top:hi,behavior:"smooth"}):Ie.scrollTop=hi}function $e(){const F=Pe.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){ve(qu[qu.length-1].id);return}let Ie="appearance";const it=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const hi of qu){const Gi=ze.current[hi.id];Gi&&vS(Gi,F)<=it&&(Ie=hi.id)}ve(Ie)}function kt(F){Y(uT(F)),q(null),ie(null)}function ei(){Y(hT()),q(null),ie(null)}function Et(F){const Ie=F.assets.filter(it=>it.enabled).map(it=>it.id);X(F.assets),Ce(Ie),M(Ie),de(F.maxFileBytes),Ee(null)}async function _e(){if(U){cS(!1),K(!1);return}let F=j;F==="default"&&(F=await Rw(),le(F)),F==="granted"&&(cS(!0),K(!0))}async function We(){pe(!0),ye(null);try{if(De)await R2(c),Ue(null);else{await D2(c,!1);const F=await c.getPushNotificationStatus(La());Ue(F.currentDevice)}}catch(F){ye(yS(F))}finally{pe(!1)}}async function Je(F){pe(!0),ye(null);try{await M2(c,F);const Ie=await c.getPushNotificationStatus(La());Ue(Ie.currentDevice)}catch(Ie){ye(yS(Ie))}finally{pe(!1)}}async function ct(F){const Ie=F?.[0];if(Ie){if(Ie.size>Q){Ee(`File must be ${pp(Q)} or smaller.`),Tt();return}if(Ie.type!=="video/mp4"&&Ie.type!=="video/webm"){Ee("Upload an MP4 or WebM video."),Tt();return}ge(!0),Ee(null);try{await c.uploadNotificationAsset(Ie),Et(await c.listNotificationAssets()),s?.()}catch(it){Ee(Dl(it))}finally{ge(!1),Tt()}}}async function Pt(F){ge(!0),Ee(null);try{await c.deleteNotificationAsset(F),Et(await c.listNotificationAssets()),s?.()}catch(Ie){Ee(Dl(Ie))}finally{ge(!1)}}function Tt(){Me.current&&(Me.current.value="")}function Lt(F,Ie){const it=new Set(Z);if(Ie?it.add(F):it.delete(F),it.size===0){Ee("Keep at least one toast video selected.");return}Ee(null),Ce(Array.from(it))}async function Dt(){if(Z.length===0){Ee("Keep at least one toast video selected.");return}ge(!0),Ee(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:Z});Et(F),s?.()}catch(F){Ee(Dl(F))}finally{ge(!1)}}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:qu.map(F=>m.jsxs("button",{type:"button","data-active":he===F.id?"true":"false","aria-current":he===F.id?"true":void 0,onClick:()=>Wt(F.id),children:[F.label,F.id==="servers"&&r?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),m.jsxs("div",{ref:Pe,className:"settings-content",onScroll:$e,children:[m.jsxs("section",{id:"settings-appearance",ref:F=>{ze.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:gh.map(F=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===F.id,"data-active":L===F.id?"true":"false",onClick:()=>A(Ik(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:Jp,max:em,step:1,value:h,"aria-label":"Terminal font size",onChange:F=>je(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Fu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Jp,max:em,step:1,value:h,"aria-label":"Terminal font size value",onChange:F=>je(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Fu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Fu(Ba)),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=>f(iT(F.currentTarget.value)),children:Sh.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:b,onChange:F=>y(rT(F.currentTarget.checked))}),"Show scroll progress"]}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:S,onChange:F=>w(sT(F.currentTarget.checked))}),"Shell panes"]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:k,onChange:F=>E(aT(F.currentTarget.checked))}),"Codex/Claude panes"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:F=>{ze.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:ei,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."}),re?m.jsx("p",{className:"settings-error",children:re}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:gc.map(F=>{const Ie=P===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":Ie?"true":"false",onClick:()=>{q(F.id),ie(null)},children:Ie?"Press keys…":Kw(B[F.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>kt(F.id),children:"Reset"})]})]},F.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:F=>{ze.current.notifications=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),qh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:U&&j==="granted",onChange:()=>{_e()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="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("div",{className:"settings-subsection",children:[m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:!!De,onChange:()=>{We()},disabled:se||!Re.supported}),"Installed app push notifications"]}),m.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Re.supported?null:m.jsx("p",{className:"muted",children:hm(Re.reason)}),De?m.jsxs("p",{className:"muted",children:["Registered as ",De.label,". Last active ",new Date(De.lastActiveAt).toLocaleString(),"."]}):null,Be?m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:De?.alwaysNotify===!0,onChange:F=>{Je(F.currentTarget.checked)},disabled:se||!De}),"Always notify this mobile device"]}):null,Le?m.jsx("p",{className:"form-error",children:Le}):null]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.enabled,onChange:F=>H(b2(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:W.persistUntilDismissed?"Until closed":`${W.durationSeconds}s`}),m.jsx("input",{type:"range",min:Vp,max:Yp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>at(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Vp,max:Yp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>at(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!W.enabled||W.persistUntilDismissed,onClick:()=>H(uS(cc)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.persistUntilDismissed,disabled:!W.enabled,onChange:F=>H(S2(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:[pp(Q)," max"]})]}),m.jsx("input",{ref:Me,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{ct(F.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:me,onClick:()=>Me.current?.click(),children:"Upload video"}),Se?m.jsx("p",{className:"settings-error",children:Se}):null,R.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:R.map(F=>m.jsxs("li",{"data-enabled":te.has(F.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:te.has(F.id),disabled:me,"aria-label":`Use ${F.filename}`,onChange:Ie=>Lt(F.id,Ie.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":pp(F.size)})]})]}),F.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:me,"aria-label":`Delete ${F.filename}`,onClick:()=>{Pt(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:me||R.length===0||!ke,onClick:()=>{Dt()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:F=>{ze.current.security=F},className:"settings-section-group",children:m.jsx(eT,{api:c})}),m.jsx("div",{id:"settings-servers",ref:F=>{ze.current.servers=F},className:"settings-section-group",children:m.jsx(AT,{api:c,...l?{onAgentRemoved:l}:{}})})]})]})]})})}function vS(e,t){const r=e.getBoundingClientRect(),s=t.getBoundingClientRect();return r.top-s.top+t.scrollTop}function pp(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 Dl(e){return e instanceof Error?e.message:"Request failed."}function hm(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":"This browser does not support installed app push notifications."}function yS(e){const t=Dl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?hm("not_standalone"):t==="insecure"?hm("insecure"):t}function OT(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 zT(e,t){if(e.length!==t.length)return!1;const r=new Set(t);return e.every(s=>r.has(s))}class xa extends Error{constructor(t,r){super(r),this.status=t,this.name="UploadClientError"}status}function jT(e){const t=e.createXhr?.()??new XMLHttpRequest,r=new FormData,s=e.files.map((l,c)=>({fieldName:`file${c}`,relativePath:l.relativePath,size:l.file.size}));r.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[l,c]of e.files.entries())r.append(`file${l}`,c.file);return new Promise((l,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,p(),l(y))},f=y=>{h||(h=!0,p(),c(y))},b=()=>{t.abort(),f(new xa(0,"Upload aborted."))};if(e.signal?.aborted){f(new xa(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new xa(t.status,"Invalid upload response."))}return}f(new xa(t.status,PT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new xa(0,"Upload failed.")),t.onabort=()=>f(new xa(0,"Upload aborted.")),t.ontimeout=()=>f(new xa(0,"Upload timed out.")),t.send(r)})}function PT(e,t){try{const r=JSON.parse(e),s=typeof r.error=="string"?r.error:r.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const HT="modulepreload",IT=function(e){return"/"+e},bS={},Vg=function(t,r,s){let l=Promise.resolve();if(r&&r.length>0){let g=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");l=g(r.map(f=>{if(f=IT(f),f in bS)return;bS[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":HT,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((w,k)=>{S.addEventListener("load",w),S.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return l.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},UT=v.lazy(()=>Vg(()=>import("./MarkdownPreview-CkGAM69L.js"),__vite__mapDeps([0,1])));function KT({api:e,activeTerminalId:t,activeTerminalCwd:r,workspaceRootPath:s=null,onOpenFile:l}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,b]=v.useState({}),[y,S]=v.useState(()=>new Set),[w,k]=v.useState(null),[E,L]=v.useState({type:"empty"}),[A,B]=v.useState("idle"),[Y,P]=v.useState(null),q=v.useRef(null),re=v.useRef(null),ie=v.useRef(!1),he=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const U=ve.current,K=s?FT(s):t?SS(t,r):null,W=c?[c.rootPath,p].filter(Boolean).join("/"):"",H=w?.path??null;v.useEffect(()=>(ie.current=!0,()=>{ie.current=!1,he.current+=1,pe()}),[]),v.useEffect(()=>{ve.current=t,re.current=null,j(K)},[e]),v.useEffect(()=>{s&&K!==re.current&&le(s,K)},[s,K]),v.useEffect(()=>{if(s||!U||t!==U)return;const te=SS(U,r);te!==re.current&&R(U,te)},[U,t,r,s]);async function j(te=K){if(s){await le(s,te);return}await R(t,te)}async function le(te,ke=K){const Re=Le();if(re.current=ke,pe(),h(null),g(""),b({}),S(new Set),k(null),L({type:"empty"}),P(null),!te){B("idle");return}B("loading");try{const Be=await e.createFileRoot({path:te});if(!ye(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const je=await e.listFiles({rootToken:Be.rootToken,path:""});if(!ye(Re))return;Ce(je),B("idle")}catch(Be){ye(Re)&&(P(Zr(Be)),B("idle"))}}async function R(te,ke=K){const Re=Le();if(re.current=ke,pe(),h(null),g(""),b({}),S(new Set),k(null),L({type:"empty"}),P(null),!te){B("idle");return}B("loading");try{const Be=await e.createFileRoot({terminalId:te});if(!ye(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const je=await e.listFiles({rootToken:Be.rootToken,path:""});if(!ye(Re))return;Ce(je),B("idle")}catch(Be){if(await Me(Be,Re))return;ye(Re)&&(P(Zr(Be)),B("idle"))}}async function X(te=p,ke=c){if(!ke)return;const Re=Le();B("loading"),P(null);try{const Be=await e.listFiles({rootToken:ke.rootToken,path:te});if(!ye(Re))return;Ce(Be),B("idle")}catch(Be){if(await Me(Be,Re))return;ye(Re)&&(P(Zr(Be)),B("idle"))}}async function Z(){if(s){await le(s,K);return}ve.current=t,await R(t,K)}function Ce(te){b(ke=>({...ke,[te.path]:qT(te.entries)}))}async function Te(te){if(!(!mp(te)||!c)){if(k(te),P(null),te.kind==="directory"){g(te.path),se(),await Q(te);return}if(g(ka(te.path)),te.editable){await me(te);return}te.previewKind!=="none"&&await Se(te,te.previewKind)}}async function M(te){if(!(!mp(te)||!c)){if(k(te),P(null),te.kind==="directory"){g(te.path),se(),await Q(te);return}if(g(ka(te.path)),te.editable){await ge(te);return}te.previewKind!=="none"&&await Se(te,te.previewKind)}}async function Q(te){if(y.has(te.path)){S(ke=>{const Re=new Set(ke);return Re.delete(te.path),Re});return}S(ke=>new Set(ke).add(te.path)),await X(te.path)}function de(te,ke){te.key==="Enter"&&(te.preventDefault(),M(ke))}async function me(te){if(!c)return;const ke=Le();B("loading"),pe();try{const Re=await e.readFile({rootToken:c.rootToken,path:te.path});if(!ye(ke))return;L({type:"text-preview",file:te,read:Re}),B("idle")}catch(Re){if(await Me(Re,ke))return;ye(ke)&&(P(Zr(Re)),B("idle"))}}async function ge(te){if(!c)return;const ke=Le();B("loading");try{await l({rootToken:c.rootToken,path:te.path,...t?{terminalId:t}:{}}),ye(ke)&&B("idle")}catch(Re){if(await Me(Re,ke))return;ye(ke)&&(P(Zr(Re)),B("idle"))}}async function Se(te,ke){if(!c)return;const Re=Le();B("loading"),pe();try{const Be=await e.previewFile({rootToken:c.rootToken,path:te.path});if(!ye(Re))return;const je=URL.createObjectURL(Be);if(!ye(Re)){URL.revokeObjectURL(je);return}q.current=je,L({type:"preview",file:te,previewKind:ke,url:je}),B("idle")}catch(Be){if(await Me(Be,Re))return;ye(Re)&&(P(Zr(Be)),B("idle"))}}async function Ee(te){if(!c)return;const ke=te==="file"?"New file":"New folder",Re=window.prompt(ke,""),Be=w?w.kind==="directory"?w.path:ka(w.path):p,je=wS(Re,Be);if(je){P(null);try{const at=await e.createFileEntry({rootToken:c.rootToken,path:je,kind:te});k(at.entry),await X(Be)}catch(at){if(await Me(at))return;P(Zr(at))}}}async function De(){if(!c||!w)return;const te=window.prompt("Move selected entry",w.path),ke=wS(te,"");if(!ke||ke===w.path)return;const Re=ka(w.path),Be=ka(ke);P(null);try{const je=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:ke});k(je.entry),g(je.entry.kind==="directory"?je.entry.path:ka(je.entry.path)),se(),await X(Re),Be!==Re&&await X(Be)}catch(je){if(await Me(je))return;P(Zr(je))}}async function Ue(){if(!c||!w)return;const te=w.path,ke=ka(te);P(null);try{const Re=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Be=Re.descendantCount>0?` and ${Re.descendantCount} nested item${Re.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Re.path}${Be}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:Re.previewToken}),k(null),g(ke),S(je=>{const at=new Set(je);for(const Wt of je)(Wt===te||Wt.startsWith(`${te}/`))&&at.delete(Wt);return at}),se(),await X(ke)}catch(Re){if(await Me(Re))return;P(Zr(Re))}}function se(){he.current+=1,pe(),L({type:"empty"})}function pe(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function Le(){return he.current+=1,he.current}function ye(te){return ie.current&&te===he.current}async function Me(te,ke){return $T(te)?(ke!==void 0&&!ye(ke)||await j(K),!0):!1}function Pe(te,ke){const Re=mp(te),Be=te.kind==="directory"&&y.has(te.path),je=f[te.path]??[],at={"--file-tree-depth":ke};return m.jsxs(Mi.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":te.kind,"data-expanded":Be,"data-active":H===te.path,disabled:!Re,style:at,"aria-expanded":te.kind==="directory"?Be:void 0,"aria-label":`${te.kind==="directory"?"Open folder":"Open file"} ${te.name}`,title:te.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{Te(te)},onDoubleClick:()=>{M(te)},onKeyDown:Wt=>de(Wt,te),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:te.kind==="directory"?Be?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:te.name}),m.jsx("small",{children:WT(te)})]}),Be?m.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Wt=>Pe(Wt,ke+1))}):null]},te.path)}const ze=f[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:W,children:W||"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:!s&&!t,onClick:()=>{Z()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ee("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ee("directory")},children:"▣"})]})]}),Y?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":W?`Files in ${W}`:"Files",children:ze.map(te=>Pe(te,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{De()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ue()},children:"Delete"})]})]}),A==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,E.type==="empty"&&A!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,E.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[E.previewKind==="image"?m.jsx("img",{src:E.url,alt:E.file.name}):null,E.previewKind==="pdf"?m.jsx("iframe",{src:E.url,title:E.file.name}):null]}):null,E.type==="text-preview"&&E.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${E.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(UT,{content:E.read.content})})}):null,E.type==="text-preview"&&E.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${E.file.name}`,children:E.read.content}):null]})]})]})}function mp(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function WT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function SS(e,t){return`${e}\0${t??""}`}function FT(e){return`workspace\0${e}`}function qT(e){return[...e].sort((t,r)=>t.kind==="directory"&&r.kind!=="directory"?-1:t.kind!=="directory"&&r.kind==="directory"?1:t.name.localeCompare(r.name))}function ka(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function wS(e,t){if(e===null)return null;const r=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return r?!t||r.includes("/")?r:`${t}/${r}`:null}function Zr(e){return e instanceof Error?e.message:"Request failed"}function $T(e){return e instanceof dr&&e.status===409&&e.message==="terminal_cwd_changed"}const VT=v.lazy(()=>Vg(()=>import("./MarkdownPreview-CkGAM69L.js"),__vite__mapDeps([0,1])));function CS({api:e,editor:t,canClose:r,onClose:s}){const[l,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[b,y]=v.useState(null),[S,w]=v.useState(!1),[k,E]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),B=v.useRef(t.read.content),Y=v.useRef(!1),P=v.useRef(!1),q=v.useRef(0),re=h!==l.content&&g!=="saving"&&!S;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,Y.current=!1,L.current=t,A.current=t.read,B.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),w(!1),E("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=l},[l]),v.useEffect(()=>{B.current=h},[h]),v.useEffect(()=>{if(h===l.content||S)return;const K=window.setInterval(()=>{!Y.current&&B.current!==A.current.content&&ie()},1e3);return()=>window.clearInterval(K)},[h===l.content,S,t.id]);async function ie(){if(Y.current)return;const K=B.current,W=A.current;if(K===W.content)return;const H=L.current,j=q.current;Y.current=!0,f("saving"),y(null),w(!1);try{const le=await e.writeFile({rootToken:H.rootToken,path:H.path,content:K,expectedVersion:W.version});if(!P.current||j!==q.current)return;const R={...W,content:K,version:le.version};A.current=R,c(R),f(B.current===K?"saved":"idle")}catch(le){if(!P.current||j!==q.current)return;if(le instanceof dr&&le.status===409){w(!0),f("idle");return}y(YT(le)),f("idle")}finally{j===q.current&&(Y.current=!1)}}const he=g==="saving"?"saving":g==="saved"?"saved":l.language,ve=l.language==="markdown",U=ve&&k==="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:he}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!re,onClick:()=>{ie()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${U?"Edit":"Preview"} ${t.title}`,onClick:()=>E(K=>K==="preview"?"edit":"preview"),children:U?"Edit":"Preview"}):null,r?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,U?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(VT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:K=>{const W=K.target.value;B.current=W,p(W),f("idle"),y(null),w(!1)}})]})}function YT(e){return e instanceof Error?e.message:"Request failed"}var XT=2,GT=1,ZT=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,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),l=Math.max(0,parseInt(r.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"))},p=h.top+h.bottom,g=h.right+h.left,f=s-p,b=l-g-t;return{cols:Math.max(XT,Math.floor(b/e.css.cell.width)),rows:Math.max(GT,Math.floor(f/e.css.cell.height))}}};var Gw=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,JT=(e,t)=>{for(var r in t)Gw(e,r,{get:t[r],enumerable:!0})},ai=(e,t,r,s)=>{for(var l=s>1?void 0:s?QT(t,r):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(l=(s?h(t,r,l):h(l))||l);return s&&l&&Gw(t,r,l),l},Ae=(e,t)=>(r,s)=>t(r,s,e),xS="Terminal input",dm={get:()=>xS,set:e=>xS=e},kS="Too much output to announce, navigate to rows manually to read",fm={get:()=>kS,set:e=>kS=e};function eD(e){return e.replace(/\r?\n/g,"\r")}function tD(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function iD(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function nD(e,t,r,s){if(e.stopPropagation(),e.clipboardData){let l=e.clipboardData.getData("text/plain");Zw(l,t,r,s)}}function Zw(e,t,r,s){e=eD(e),e=tD(e,r.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),t.value=""}function Qw(e,t,r){let s=r.getBoundingClientRect(),l=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function ES(e,t,r,s,l){Qw(e,t,r),l&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function qs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Vh(e,t=0,r=e.length){let s="";for(let l=t;l<r;++l){let c=e[l];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var rD=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let r=e.length;if(!r)return 0;let s=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=l;c<r;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=r)return this._interim=h,s;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[s++]=(h-55296)*1024+p-56320+65536:(t[s++]=h,t[s++]=p);continue}h!==65279&&(t[s++]=h)}return s}},sD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let r=e.length;if(!r)return 0;let s=0,l,c,h,p,g=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let k=0,E;for(;(E=this.interim[++k]&63)&&k<4;)w<<=6,w|=E;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-k;for(;f<A;){if(f>=r)return 0;if(E=e[f++],(E&192)!==128){f--,S=!0;break}else this.interim[k++]=E,w<<=6,w|=E&63}S||(L===2?w<128?f--:t[s++]=w:L===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let b=r-4,y=f;for(;y<r;){for(;y<b&&!((l=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((p=e[y+3])&128);)t[s++]=l,t[s++]=c,t[s++]=h,t[s++]=p,y+=4;if(l=e[y++],l<128)t[s++]=l;else if((l&224)===192){if(y>=r)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(g=(l&31)<<6|c&63,g<128){y--;continue}t[s++]=g}else if((l&240)===224){if(y>=r)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(g=(l&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((l&248)===240){if(y>=r)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=r)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(y>=r)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=h,s;if(p=e[y++],(p&192)!==128){y--;continue}if(g=(l&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},Jw="",$s=" ",Mc=class e1{constructor(){this.fg=0,this.bg=0,this.extended=new kh}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 e1;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}},kh=class t1{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 t1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},er=class i1 extends Mc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new kh,this.combinedData=""}static fromCharData(t){let r=new i1;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?qs(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let l=t[1].charCodeAt(1);56320<=l&&l<=57343?this.content=(s-55296)*1024+l-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},TS="di$target",pm="di$dependencies",gp=new Map;function aD(e){return e[pm]||[]}function Ki(e){if(gp.has(e))return gp.get(e);let t=function(r,s,l){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");lD(t,r,l)};return t._id=e,gp.set(e,t),t}function lD(e,t,r){t[TS]===t?t[pm].push({id:e,index:r}):(t[pm]=[{id:e,index:r}],t[TS]=t)}var un=Ki("BufferService"),n1=Ki("CoreMouseService"),Wa=Ki("CoreService"),oD=Ki("CharsetService"),Yg=Ki("InstantiationService"),r1=Ki("LogService"),hn=Ki("OptionsService"),s1=Ki("OscLinkService"),cD=Ki("UnicodeService"),Nc=Ki("DecorationService"),mm=class{constructor(e,t,r){this._bufferService=e,this._optionsService=t,this._oscLinkService=r}provideLinks(e,t){let r=this._bufferService.buffer.lines.get(e-1);if(!r){t(void 0);return}let s=[],l=this._optionsService.rawOptions.linkHandler,c=new er,h=r.getTrimmedLength(),p=-1,g=-1,f=!1;for(let b=0;b<h;b++)if(!(g===-1&&!r.hasContent(b))){if(r.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:g+1,y:e},end:{x:b+(!f&&b===h-1?1:0),y:e}},w=!1;if(!l?.allowNonHttpProtocols)try{let k=new URL(y);["http:","https:"].includes(k.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:S,activate:(k,E)=>l?l.activate(k,E,S):uD(k,E),hover:(k,E)=>l?.hover?.(k,E,S),leave:(k,E)=>l?.leave?.(k,E,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,p=c.extended.urlId):(g=-1,p=-1)}}t(s)}};mm=ai([Ae(0,un),Ae(1,hn),Ae(2,s1)],mm);function uD(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
-
|
|
17
|
-
WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Yh=Ki("CharSizeService"),ns=Ki("CoreBrowserService"),Xg=Ki("MouseService"),rs=Ki("RenderService"),hD=Ki("SelectionService"),a1=Ki("CharacterJoinerService"),ql=Ki("ThemeService"),l1=Ki("LinkProviderService"),dD=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?DS.isErrorNoTelemetry(e)?new DS(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)}},fD=new dD;function sh(e){pD(e)||fD.onUnexpectedError(e)}var gm="Canceled";function pD(e){return e instanceof mD?!0:e instanceof Error&&e.name===gm&&e.message===gm}var mD=class extends Error{constructor(){super(gm),this.name=this.message}};function gD(e){return new Error(`Illegal argument: ${e}`)}var DS=class _m extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof _m)return t;let r=new _m;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},vm=class o1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,o1.prototype)}};function Nn(e,t=0){return e[e.length-(1+t)]}var _D;(e=>{function t(c){return c<0}e.isLessThan=t;function r(c){return c<=0}e.isLessThanOrEqual=r;function s(c){return c>0}e.isGreaterThan=s;function l(c){return c===0}e.isNeitherLessOrGreaterThan=l,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(_D||={});function vD(e,t){let r=this,s=!1,l;return function(){return s||(s=!0,t||(l=e.apply(r,arguments))),l}}var c1;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function s(){return r}e.empty=s;function*l(P){yield P}e.single=l;function c(P){return t(P)?P:l(P)}e.wrap=c;function h(P){return P||r}e.from=h;function*p(P){for(let q=P.length-1;q>=0;q--)yield P[q]}e.reverse=p;function g(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(P){return P[Symbol.iterator]().next().value}e.first=f;function b(P,q){let re=0;for(let ie of P)if(q(ie,re++))return!0;return!1}e.some=b;function y(P,q){for(let re of P)if(q(re))return re}e.find=y;function*S(P,q){for(let re of P)q(re)&&(yield re)}e.filter=S;function*w(P,q){let re=0;for(let ie of P)yield q(ie,re++)}e.map=w;function*k(P,q){let re=0;for(let ie of P)yield*q(ie,re++)}e.flatMap=k;function*E(...P){for(let q of P)yield*q}e.concat=E;function L(P,q,re){let ie=re;for(let he of P)ie=q(ie,he);return ie}e.reduce=L;function*A(P,q,re=P.length){for(q<0&&(q+=P.length),re<0?re+=P.length:re>P.length&&(re=P.length);q<re;q++)yield P[q]}e.slice=A;function B(P,q=Number.POSITIVE_INFINITY){let re=[];if(q===0)return[re,P];let ie=P[Symbol.iterator]();for(let he=0;he<q;he++){let ve=ie.next();if(ve.done)return[re,e.empty()];re.push(ve.value)}return[re,{[Symbol.iterator](){return ie}}]}e.consume=B;async function Y(P){let q=[];for await(let re of P)q.push(re);return Promise.resolve(q)}e.asyncToArray=Y})(c1||={});function Ia(e){if(c1.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function yD(...e){return Vt(()=>Ia(e))}function Vt(e){return{dispose:vD(()=>{e()})}}var u1=class h1{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{Ia(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?h1.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)}};u1.DISABLE_DISPOSED_WARNING=!1;var Ys=u1,ot=class{constructor(){this._store=new Ys,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)}};ot.None=Object.freeze({dispose(){}});var Hl=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}},ts=typeof window=="object"?window:globalThis,ym=class bm{constructor(t){this.element=t,this.next=bm.Undefined,this.prev=bm.Undefined}};ym.Undefined=new ym(void 0);var Qt=ym,RS=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 r=new Qt(e);if(this._first===Qt.Undefined)this._first=r,this._last=r;else if(t){let l=this._last;this._last=r,r.prev=l,l.next=r}else{let l=this._first;this._first=r,r.next=l,l.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}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}},bD=globalThis.performance&&typeof globalThis.performance.now=="function",SD=class d1{static create(t){return new d1(t)}constructor(t){this._now=bD&&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}},Xi;(e=>{e.None=()=>ot.None;function t(W,H){return y(W,()=>{},0,void 0,!0,void 0,H)}e.defer=t;function r(W){return(H,j=null,le)=>{let R=!1,X;return X=W(Z=>{if(!R)return X?X.dispose():R=!0,H.call(j,Z)},null,le),R&&X.dispose(),X}}e.once=r;function s(W,H,j){return f((le,R=null,X)=>W(Z=>le.call(R,H(Z)),null,X),j)}e.map=s;function l(W,H,j){return f((le,R=null,X)=>W(Z=>{H(Z),le.call(R,Z)},null,X),j)}e.forEach=l;function c(W,H,j){return f((le,R=null,X)=>W(Z=>H(Z)&&le.call(R,Z),null,X),j)}e.filter=c;function h(W){return W}e.signal=h;function p(...W){return(H,j=null,le)=>{let R=yD(...W.map(X=>X(Z=>H.call(j,Z))));return b(R,le)}}e.any=p;function g(W,H,j,le){let R=j;return s(W,X=>(R=H(R,X),R),le)}e.reduce=g;function f(W,H){let j,le={onWillAddFirstListener(){j=W(R.fire,R)},onDidRemoveLastListener(){j?.dispose()}},R=new xe(le);return H?.add(R),R.event}function b(W,H){return H instanceof Array?H.push(W):H&&H.add(W),W}function y(W,H,j=100,le=!1,R=!1,X,Z){let Ce,Te,M,Q=0,de,me={leakWarningThreshold:X,onWillAddFirstListener(){Ce=W(Se=>{Q++,Te=H(Te,Se),le&&!M&&(ge.fire(Te),Te=void 0),de=()=>{let Ee=Te;Te=void 0,M=void 0,(!le||Q>1)&&ge.fire(Ee),Q=0},typeof j=="number"?(clearTimeout(M),M=setTimeout(de,j)):M===void 0&&(M=0,queueMicrotask(de))})},onWillRemoveListener(){R&&Q>0&&de?.()},onDidRemoveLastListener(){de=void 0,Ce.dispose()}},ge=new xe(me);return Z?.add(ge),ge.event}e.debounce=y;function S(W,H=0,j){return e.debounce(W,(le,R)=>le?(le.push(R),le):[R],H,void 0,!0,void 0,j)}e.accumulate=S;function w(W,H=(le,R)=>le===R,j){let le=!0,R;return c(W,X=>{let Z=le||!H(X,R);return le=!1,R=X,Z},j)}e.latch=w;function k(W,H,j){return[e.filter(W,H,j),e.filter(W,le=>!H(le),j)]}e.split=k;function E(W,H=!1,j=[],le){let R=j.slice(),X=W(Te=>{R?R.push(Te):Ce.fire(Te)});le&&le.add(X);let Z=()=>{R?.forEach(Te=>Ce.fire(Te)),R=null},Ce=new xe({onWillAddFirstListener(){X||(X=W(Te=>Ce.fire(Te)),le&&le.add(X))},onDidAddFirstListener(){R&&(H?setTimeout(Z):Z())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return le&&le.add(Ce),Ce.event}e.buffer=E;function L(W,H){return(j,le,R)=>{let X=H(new B);return W(function(Z){let Ce=X.evaluate(Z);Ce!==A&&j.call(le,Ce)},void 0,R)}}e.chain=L;let A=Symbol("HaltChainable");class B{constructor(){this.steps=[]}map(H){return this.steps.push(H),this}forEach(H){return this.steps.push(j=>(H(j),j)),this}filter(H){return this.steps.push(j=>H(j)?j:A),this}reduce(H,j){let le=j;return this.steps.push(R=>(le=H(le,R),le)),this}latch(H=(j,le)=>j===le){let j=!0,le;return this.steps.push(R=>{let X=j||!H(R,le);return j=!1,le=R,X?R:A}),this}evaluate(H){for(let j of this.steps)if(H=j(H),H===A)break;return H}}function Y(W,H,j=le=>le){let le=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.on(H,le),X=()=>W.removeListener(H,le),Z=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromNodeEventEmitter=Y;function P(W,H,j=le=>le){let le=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.addEventListener(H,le),X=()=>W.removeEventListener(H,le),Z=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromDOMEventEmitter=P;function q(W){return new Promise(H=>r(W)(H))}e.toPromise=q;function re(W){let H=new xe;return W.then(j=>{H.fire(j)},()=>{H.fire(void 0)}).finally(()=>{H.dispose()}),H.event}e.fromPromise=re;function ie(W,H){return W(j=>H.fire(j))}e.forward=ie;function he(W,H,j){return H(j),W(le=>H(le))}e.runAndSubscribe=he;class ve{constructor(H,j){this._observable=H,this._counter=0,this._hasChanged=!1;let le={onWillAddFirstListener:()=>{H.addObserver(this)},onDidRemoveLastListener:()=>{H.removeObserver(this)}};this.emitter=new xe(le),j&&j.add(this.emitter)}beginUpdate(H){this._counter++}handlePossibleChange(H){}handleChange(H,j){this._hasChanged=!0}endUpdate(H){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(W,H){return new ve(W,H).emitter.event}e.fromObservable=U;function K(W){return(H,j,le)=>{let R=0,X=!1,Z={beginUpdate(){R++},endUpdate(){R--,R===0&&(W.reportChanges(),X&&(X=!1,H.call(j)))},handlePossibleChange(){},handleChange(){X=!0}};W.addObserver(Z),W.reportChanges();let Ce={dispose(){W.removeObserver(Z)}};return le instanceof Ys?le.add(Ce):Array.isArray(le)&&le.push(Ce),Ce}}e.fromObservableLight=K})(Xi||={});var Sm=class wm{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${wm._idPool++}`,wm.all.add(this)}start(t){this._stopWatch=new SD,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}}};Sm.all=new Set,Sm._idPool=0;var wD=Sm,CD=-1,f1=class p1{constructor(t,r,s=(p1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let l=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,l+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new ED(p,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,r=0;for(let[s,l]of this._stacks)(!t||r<l)&&(t=[s,l],r=l);return t}};f1._idPool=1;var xD=f1,kD=class m1{constructor(t){this.value=t}static create(){let t=new Error;return new m1(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}},DD=0,_p=class{constructor(e){this.value=e,this.id=DD++}},RD=2,MD,xe=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new xD(e?.onListenerError??sh,this._options?.leakWarningThreshold??CD):void 0,this._perfMon=this._options?._profName?new wD(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,r)=>{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 p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new TD(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||sh)(g),ot.None}if(this._disposed)return ot.None;t&&(e=e.bind(t));let s=new _p(e),l;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=kD.create(),l=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof _p?(this._deliveryQueue??=new ND,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Vt(()=>{l?.(),this._removeListener(s)});return r instanceof Ys?r.add(c):Array.isArray(r)&&r.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,r=t.indexOf(e);if(r===-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[r]=void 0;let s=this._deliveryQueue.current===this;if(this._size*RD<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:s&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){if(!e)return;let r=this._options?.onListenerError||sh;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof _p)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}},ND=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Cm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new xe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new xe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Cm.INSTANCE=new Cm;var Gg=Cm;function AD(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}Gg.INSTANCE.onDidChangeZoomLevel;function LD(e){return Gg.INSTANCE.getZoomFactor(e)}Gg.INSTANCE.onDidChangeFullscreen;var $l=typeof navigator=="object"?navigator.userAgent:"",xm=$l.indexOf("Firefox")>=0,BD=$l.indexOf("AppleWebKit")>=0,Zg=$l.indexOf("Chrome")>=0,OD=!Zg&&$l.indexOf("Safari")>=0;$l.indexOf("Electron/")>=0;$l.indexOf("Android")>=0;var vp=!1;if(typeof ts.matchMedia=="function"){let e=ts.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ts.matchMedia("(display-mode: fullscreen)");vp=e.matches,AD(ts,e,({matches:r})=>{vp&&t.matches||(vp=r)})}var Ml="en",km=!1,Em=!1,ah=!1,g1=!1,$u,lh=Ml,MS=Ml,zD,Jr,Oa=globalThis,Bn;typeof Oa.vscode<"u"&&typeof Oa.vscode.process<"u"?Bn=Oa.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Bn=process);var jD=typeof Bn?.versions?.electron=="string",PD=jD&&Bn?.type==="renderer";if(typeof Bn=="object"){km=Bn.platform==="win32",Em=Bn.platform==="darwin",ah=Bn.platform==="linux",ah&&Bn.env.SNAP&&Bn.env.SNAP_REVISION,Bn.env.CI||Bn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$u=Ml,lh=Ml;let e=Bn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$u=t.userLocale,MS=t.osLocale,lh=t.resolvedLanguage||Ml,zD=t.languagePack?.translationsConfigFile}catch{}g1=!0}else typeof navigator=="object"&&!PD?(Jr=navigator.userAgent,km=Jr.indexOf("Windows")>=0,Em=Jr.indexOf("Macintosh")>=0,(Jr.indexOf("Macintosh")>=0||Jr.indexOf("iPad")>=0||Jr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ah=Jr.indexOf("Linux")>=0,Jr?.indexOf("Mobi")>=0,lh=globalThis._VSCODE_NLS_LANGUAGE||Ml,$u=navigator.language.toLowerCase(),MS=$u):console.error("Unable to resolve platform.");var _1=km,Nr=Em,HD=ah,NS=g1,Ar=Jr,Ps=lh,ID;(e=>{function t(){return Ps}e.value=t;function r(){return Ps.length===2?Ps==="en":Ps.length>=3?Ps[0]==="e"&&Ps[1]==="n"&&Ps[2]==="-":!1}e.isDefaultVariant=r;function s(){return Ps==="en"}e.isDefault=s})(ID||={});var UD=typeof Oa.postMessage=="function"&&!Oa.importScripts;(()=>{if(UD){let e=[];Oa.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,l=e.length;s<l;s++){let c=e[s];if(c.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return r=>{let s=++t;e.push({id:s,callback:r}),Oa.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var KD=!!(Ar&&Ar.indexOf("Chrome")>=0);Ar&&Ar.indexOf("Firefox")>=0;!KD&&Ar&&Ar.indexOf("Safari")>=0;Ar&&Ar.indexOf("Edg/")>=0;Ar&&Ar.indexOf("Android")>=0;var kl=typeof navigator=="object"?navigator:{};NS||document.queryCommandSupported&&document.queryCommandSupported("copy")||kl&&kl.clipboard&&kl.clipboard.writeText,NS||kl&&kl.clipboard&&kl.clipboard.readText;var Qg=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}},yp=new Qg,AS=new Qg,LS=new Qg,WD=new Array(230),v1;(e=>{function t(p){return yp.keyCodeToStr(p)}e.toString=t;function r(p){return yp.strToKeyCode(p)}e.fromString=r;function s(p){return AS.keyCodeToStr(p)}e.toUserSettingsUS=s;function l(p){return LS.keyCodeToStr(p)}e.toUserSettingsGeneral=l;function c(p){return AS.strToKeyCode(p)||LS.strToKeyCode(p)}e.fromUserSettings=c;function h(p){if(p>=98&&p<=113)return null;switch(p){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return yp.keyCodeToStr(p)}e.toElectronAccelerator=h})(v1||={});var FD=class y1{constructor(t,r,s,l,c){this.ctrlKey=t,this.shiftKey=r,this.altKey=s,this.metaKey=l,this.keyCode=c}equals(t){return t instanceof y1&&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",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",l=this.metaKey?"1":"0";return`K${t}${r}${s}${l}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new qD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},qD=class{constructor(e){if(e.length===0)throw gD("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;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 $D(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return v1.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(xm)switch(t){case 59:return 85;case 60:if(HD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Nr)return 57;break}else if(BD&&(Nr&&t===93||!Nr&&t===92))return 57;return WD[t]||0}var VD=Nr?256:2048,YD=512,XD=1024,GD=Nr?2048:256,BS=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=$D(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|=VD),this.altKey&&(t|=YD),this.shiftKey&&(t|=XD),this.metaKey&&(t|=GD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new FD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},OS=new WeakMap;function ZD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var QD=class{static getSameOriginWindowChain(e){let t=OS.get(e);if(!t){t=[],OS.set(e,t);let r=e,s;do s=ZD(r),s?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,s=0,l=this.getSameOriginWindowChain(e);for(let c of l){let h=c.window.deref();if(r+=h?.scrollY??0,s+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();r+=p.top,s+=p.left}return{top:r,left:s}}},Vu=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 r=QD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},zS=class{constructor(e,t=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let s=!1;if(Zg){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*h):this.deltaY=l.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?xm&&!Nr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")OD&&_1?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*h):this.deltaX=l.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?xm&&!Nr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},b1=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),JD;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof eR?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Xi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:b1})})(JD||={});var eR=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?b1:(this._emitter||(this._emitter=new xe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Jg=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 vm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new vm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},tR=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,r=globalThis){if(this.isDisposed)throw new vm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},t);this.disposable=Vt(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},iR;(e=>{async function t(s){let l,c=await Promise.all(s.map(h=>h.then(p=>p,p=>{l||(l=p)})));if(typeof l<"u")throw l;return c}e.settled=t;function r(s){return new Promise(async(l,c)=>{try{await s(l,c)}catch(h){c(h)}})}e.withAsyncBody=r})(iR||={});var jS=class Gn{static fromArray(t){return new Gn(r=>{r.emitMany(t)})}static fromPromise(t){return new Gn(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Gn(async r=>{await Promise.all(t.map(async s=>r.emitOne(await s)))})}static merge(t){return new Gn(async r=>{await Promise.all(t.map(async s=>{for await(let l of s)r.emitOne(l)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new xe,queueMicrotask(async()=>{let s={emitOne:l=>this.emitOne(l),emitMany:l=>this.emitMany(l),reject:l=>this.reject(l)};try{await Promise.resolve(t(s)),this.resolve()}catch(l){this.reject(l)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Xi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,r){return new Gn(async s=>{for await(let l of t)s.emitOne(r(l))})}map(t){return Gn.map(this,t)}static filter(t,r){return new Gn(async s=>{for await(let l of t)r(l)&&s.emitOne(l)})}filter(t){return Gn.filter(this,t)}static coalesce(t){return Gn.filter(t,r=>!!r)}coalesce(){return Gn.coalesce(this)}static async toPromise(t){let r=[];for await(let s of t)r.push(s);return r}toPromise(){return Gn.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())}};jS.EMPTY=jS.fromArray([]);var{getWindow:Mr,getWindowId:nR,onDidRegisterWindow:rR}=(function(){let e=new Map,t={window:ts,disposables:new Ys};e.set(ts.vscodeWindowId,t);let r=new xe,s=new xe,l=new xe;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:l.event,onDidUnregisterWindow:s.event,registerWindow(h){if(e.has(h.vscodeWindowId))return ot.None;let p=new Ys,g={window:h,disposables:p.add(new Ys)};return e.set(h.vscodeWindowId,g),p.add(Vt(()=>{e.delete(h.vscodeWindowId),s.fire(h)})),p.add(Xe(h,zi.BEFORE_UNLOAD,()=>{l.fire(h)})),r.fire(g),p},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let p=h;if(p?.ownerDocument?.defaultView)return p.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:ts},getDocument(h){return Mr(h).document}}})(),sR=class{constructor(e,t,r,s){this._node=e,this._type=t,this._handler=r,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Xe(e,t,r,s){return new sR(e,t,r,s)}var PS=function(e,t,r,s){return Xe(e,t,r,s)},e_,aR=class extends tR{constructor(e){super(),this.defaultTarget=e&&Mr(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},HS=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){sh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,s=new Map,l=c=>{r.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),s.set(c,!0);h.length>0;)h.sort(HS.sort),h.shift().execute();s.set(c,!1)};e_=(c,h,p=0)=>{let g=nR(c),f=new HS(h,p),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(f),r.get(g)||(r.set(g,!0),c.requestAnimationFrame(()=>l(g))),f}})();function lR(e){let t=e.getBoundingClientRect(),r=Mr(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var zi={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"},oR=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=vn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=vn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=vn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=vn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=vn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=vn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=vn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=vn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=vn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=vn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=vn(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=vn(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=vn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=vn(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 vn(e){return typeof e=="number"?`${e}px`:e}function hc(e){return new oR(e)}var S1=class{constructor(){this._hooks=new Ys,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,s,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=l;let c=e;try{e.setPointerCapture(t),this._hooks.add(Vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Mr(e)}this._hooks.add(Xe(c,zi.POINTER_MOVE,h=>{if(h.buttons!==r){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Xe(c,zi.POINTER_UP,h=>this.stopMonitoring(!0)))}};function cR(e,t,r){let s=null,l=null;if(typeof r.value=="function"?(s="value",l=r.value,l.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(s="get",l=r.get),!l)throw new Error("not supported");let c=`$memoize$${t}`;r[s]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:l.apply(this,h)}),this[c]}}var Rr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Rr||={});var Go=class an extends ot{constructor(){super(),this.dispatched=!1,this.targets=new RS,this.ignoreTargets=new RS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Xi.runAndSubscribe(rR,({window:t,disposables:r})=>{r.add(Xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),r.add(Xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),r.add(Xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ts,disposables:this._store}))}static addTarget(t){if(!an.isTouchDevice())return ot.None;an.INSTANCE||(an.INSTANCE=new an);let r=an.INSTANCE.targets.push(t);return Vt(r)}static ignoreTarget(t){if(!an.isTouchDevice())return ot.None;an.INSTANCE||(an.INSTANCE=new an);let r=an.INSTANCE.ignoreTargets.push(t);return Vt(r)}static isTouchDevice(){return"ontouchstart"in ts||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,l=t.targetTouches.length;s<l;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:r,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[r],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(Rr.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,r){let s=Date.now(),l=Object.keys(this.activeTouches).length;for(let c=0,h=r.changedTouches.length;c<h;c++){let p=r.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(p.identifier))){console.warn("move of an UNKNOWN touch",p);continue}let g=this.activeTouches[p.identifier],f=Date.now()-g.initialTimeStamp;if(f<an.HOLD_DELAY&&Math.abs(g.initialPageX-Nn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Nn(g.rollingPageY))<30){let b=this.newGestureEvent(Rr.Tap,g.initialTarget);b.pageX=Nn(g.rollingPageX),b.pageY=Nn(g.rollingPageY),this.dispatchEvent(b)}else if(f>=an.HOLD_DELAY&&Math.abs(g.initialPageX-Nn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Nn(g.rollingPageY))<30){let b=this.newGestureEvent(Rr.Contextmenu,g.initialTarget);b.pageX=Nn(g.rollingPageX),b.pageY=Nn(g.rollingPageY),this.dispatchEvent(b)}else if(l===1){let b=Nn(g.rollingPageX),y=Nn(g.rollingPageY),S=Nn(g.rollingTimestamps)-g.rollingTimestamps[0],w=b-g.rollingPageX[0],k=y-g.rollingPageY[0],E=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,E,s,Math.abs(w)/S,w>0?1:-1,b,Math.abs(k)/S,k>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Rr.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(t){if(t.type===Rr.Tap){let r=new Date().getTime(),s=0;r-this._lastSetTapCountTime>an.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=r,t.tapCount=s}else(t.type===Rr.Change||t.type===Rr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let r=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let l=0,c=t.initialTarget;for(;c&&c!==s;)l++,c=c.parentElement;r.push([l,s])}r.sort((s,l)=>s[0]-l[0]);for(let[s,l]of r)l.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,s,l,c,h,p,g,f){this.handle=e_(t,()=>{let b=Date.now(),y=b-s,S=0,w=0,k=!0;l+=an.SCROLL_FRICTION*y,p+=an.SCROLL_FRICTION*y,l>0&&(k=!1,S=c*l*y),p>0&&(k=!1,w=g*p*y);let E=this.newGestureEvent(Rr.Change);E.translationX=S,E.translationY=w,r.forEach(L=>L.dispatchEvent(E)),k||this.inertia(t,r,b,l,c,h+S,p,g,f+w)})}onTouchMove(t){let r=Date.now();for(let s=0,l=t.changedTouches.length;s<l;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(Rr.Change,h.initialTarget);p.translationX=c.pageX-Nn(h.rollingPageX),p.translationY=c.pageY-Nn(h.rollingPageY),p.pageX=c.pageX,p.pageY=c.pageY,this.dispatchEvent(p),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(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Go.SCROLL_FRICTION=-.005,Go.HOLD_DELAY=700,Go.CLEAR_TAP_COUNT_TIME=400,ai([cR],Go,"isTouchDevice",1);var uR=Go,t_=class extends ot{onclick(e,t){this._register(Xe(e,zi.CLICK,r=>t(new Vu(Mr(e),r))))}onmousedown(e,t){this._register(Xe(e,zi.MOUSE_DOWN,r=>t(new Vu(Mr(e),r))))}onmouseover(e,t){this._register(Xe(e,zi.MOUSE_OVER,r=>t(new Vu(Mr(e),r))))}onmouseleave(e,t){this._register(Xe(e,zi.MOUSE_LEAVE,r=>t(new Vu(Mr(e),r))))}onkeydown(e,t){this._register(Xe(e,zi.KEY_DOWN,r=>t(new BS(r))))}onkeyup(e,t){this._register(Xe(e,zi.KEY_UP,r=>t(new BS(r))))}oninput(e,t){this._register(Xe(e,zi.INPUT,t))}onblur(e,t){this._register(Xe(e,zi.BLUR,t))}onfocus(e,t){this._register(Xe(e,zi.FOCUS,t))}onchange(e,t){this._register(Xe(e,zi.CHANGE,t))}ignoreGesture(e){return uR.ignoreTarget(e)}},IS=11,hR=class extends t_{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=IS+"px",this.domNode.style.height=IS+"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 S1),this._register(PS(this.bgDomNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(PS(this.domNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new aR),this._pointerdownScheduleRepeatTimer=this._register(new Jg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Mr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},dR=class Tm{constructor(t,r,s,l,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,s=s|0,l=l|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=l,this.rawScrollTop=p,r<0&&(r=0),l+r>s&&(l=s-r),l<0&&(l=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=r,this.scrollWidth=s,this.scrollLeft=l,this.height=c,this.scrollHeight=h,this.scrollTop=p}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,r){return new Tm(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Tm(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,r){let s=this.width!==t.width,l=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,p=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:l,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},fR=class extends ot{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new dR(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 r=this._state.withScrollDimensions(e,t);this._setState(r,!!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 r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let s;t?s=new KS(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=KS.start(this._state,r,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 r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},US=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function bp(e,t){let r=t-e;return function(s){return e+r*gR(s)}}function pR(e,t,r){return function(s){return s<r?e(s/r):t((s-r)/(1-r))}}var KS=class Dm{constructor(t,r,s,l){this.from=t,this.to=r,this.duration=l,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,r,s){if(Math.abs(t-r)>2.5*s){let l,c;return t<r?(l=t+.75*s,c=r-.75*s):(l=t-.75*s,c=r+.75*s),pR(bp(t,l),bp(c,r),.33)}return bp(t,r)}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 r=(t-this.startTime)/this.duration;if(r<1){let s=this.scrollLeft(r),l=this.scrollTop(r);return new US(s,l,!1)}return new US(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,s){return Dm.start(t,r,s)}static start(t,r,s){s=s+10;let l=Date.now()-10;return new Dm(t,r,l,s)}};function mR(e){return Math.pow(e,3)}function gR(e){return 1-mR(1-e)}var _R=class extends ot{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Jg)}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":"")))}},vR=140,w1=class extends t_{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 _R(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new S1),this._shouldRender=!0,this.domNode=hc(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(Xe(this.domNode.domNode,zi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new hR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,s){this.slider=hc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Xe(this.slider.domNode,zi.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.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,r=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);r<=l&&l<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let l=lR(this.domNode.domNode);t=e.pageX-l.left,r=e.pageY-l.top}let s=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),h=Math.abs(c-r);if(_1&&h>vR){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let p=this._sliderPointerPosition(l)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(p))},()=>{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()}},C1=class Rm{constructor(t,r,s,l,c,h){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=l,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 Rm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,s,l,c){let h=Math.max(0,s-t),p=Math.max(0,h-2*r),g=l>0&&l>s;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*p/l))),b=(p-f)/(l-s),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=Rm._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 r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},yR=class extends w1{constructor(e,t,r){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new C1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,l.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}},bR=class extends w1{constructor(e,t,r){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new C1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,l.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}},SR=500,WS=50,wR=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},Mm=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,r=0,s=1,l=this._rear;do{let c=l===this._front?t:Math.pow(2,-s);if(t-=c,r+=this._memory[l].score*c,l===this._front)break;l=(this._capacity+l-1)%this._capacity,s++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(Zg){let r=Mr(t.browserEvent),s=LD(r);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,s){let l=null,c=new wR(t,r,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(l=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,l)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),r){let l=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(r.deltaX),p=Math.abs(r.deltaY),g=Math.max(Math.min(l,h),1),f=Math.max(Math.min(c,p),1),b=Math.max(l,h),y=Math.max(c,p);b%g===0&&y%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mm.INSTANCE=new Mm;var CR=Mm,xR=class extends t_{constructor(e,t,r){super(),this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new xe),this.onWillScroll=this._onWillScroll.event,this._options=ER(t),this._scrollable=r,this._register(this._scrollable.onScroll(l=>{this._onWillScroll.fire(l),this._onDidScroll(l),this._onScroll.fire(l)}));let s={onMouseWheel:l=>this._onMouseWheel(l),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new bR(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new yR(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=hc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=hc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=hc(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,l=>this._onMouseOver(l)),this.onmouseleave(this._listenOnDomNode,l=>this._onMouseLeave(l)),this._hideTimeout=this._register(new Jg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ia(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,Nr&&(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 zS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ia(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new zS(r))};this._mouseWheelToDispose.push(Xe(this._listenOnDomNode,zi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=CR.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let h=!Nr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(l){let f=WS*l,b=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let f=WS*c,b=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),r=!0)}let s=r;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,r=e.scrollLeft>0,s=r?" left":"",l=t?" top":"",c=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${l}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${l}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),SR)}},kR=class extends xR{constructor(e,t,r){super(e,t,r)}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,Nr&&(t.className+=" mac"),t}var Nm=class extends ot{constructor(e,t,r,s,l,c,h,p){super(),this._bufferService=r,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new fR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>e_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new kR(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(l.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Xi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Vt(()=>this._styleElement.remove())),this._register(Xi.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(f=>this._handleScroll(f)))}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),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};Nm=ai([Ae(2,un),Ae(3,ns),Ae(4,n1),Ae(5,ql),Ae(6,hn),Ae(7,rs)],Nm);var Am=class extends ot{constructor(e,t,r,s,l){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=s,this._renderService=l,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(Vt(()=>{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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Am=ai([Ae(1,un),Ae(2,ns),Ae(3,Nc),Ae(4,rs)],Am);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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Tr={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},Po={full:0,left:0,center:0,right:0},Eh=class extends ot{constructor(e,t,r,s,l,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=s,this._renderService=l,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,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(Vt(()=>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);Hs.full=this._canvas.width,Hs.left=e,Hs.center=t,Hs.right=e,this._refreshDrawHeightConstants(),Po.full=1,Po.left=1,Po.center=1+Hs.left,Po.right=1+Hs.left+Hs.center}_refreshDrawHeightConstants(){Tr.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);Tr.left=t,Tr.center=t,Tr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Tr.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(Po[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Tr[e.position||"full"]/2),Hs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Tr[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}))}};Eh=ai([Ae(2,un),Ae(3,Nc),Ae(4,rs),Ae(5,hn),Ae(6,ql),Ae(7,ns)],Eh);var fe;(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=""))(fe||={});var oh;(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=""))(oh||={});var x1;(e=>e.ST=`${fe.ESC}\\`)(x1||={});var Lm=class{constructor(e,t,r,s,l,c){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=s,this._coreService=l,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 r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${fe.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),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"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=l+"px",this._textarea.style.top=s+"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)}}};Lm=ai([Ae(2,un),Ae(3,hn),Ae(4,Wa),Ae(5,rs)],Lm);var Pi=0,Hi=0,Ii=0,si=0,FS={css:"#00000000",rgba:0},wi;(e=>{function t(l,c,h,p){return p!==void 0?`#${Ea(l)}${Ea(c)}${Ea(h)}${Ea(p)}`:`#${Ea(l)}${Ea(c)}${Ea(h)}`}e.toCss=t;function r(l,c,h,p=255){return(l<<24|c<<16|h<<8|p)>>>0}e.toRgba=r;function s(l,c,h,p){return{css:e.toCss(l,c,h,p),rgba:e.toRgba(l,c,h,p)}}e.toColor=s})(wi||={});var Kt;(e=>{function t(g,f){if(si=(f.rgba&255)/255,si===1)return{css:f.css,rgba:f.rgba};let b=f.rgba>>24&255,y=f.rgba>>16&255,S=f.rgba>>8&255,w=g.rgba>>24&255,k=g.rgba>>16&255,E=g.rgba>>8&255;Pi=w+Math.round((b-w)*si),Hi=k+Math.round((y-k)*si),Ii=E+Math.round((S-E)*si);let L=wi.toCss(Pi,Hi,Ii),A=wi.toRgba(Pi,Hi,Ii);return{css:L,rgba:A}}e.blend=t;function r(g){return(g.rgba&255)===255}e.isOpaque=r;function s(g,f,b){let y=ch.ensureContrastRatio(g.rgba,f.rgba,b);if(y)return wi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function l(g){let f=(g.rgba|255)>>>0;return[Pi,Hi,Ii]=ch.toChannels(f),{css:wi.toCss(Pi,Hi,Ii),rgba:f}}e.opaque=l;function c(g,f){return si=Math.round(f*255),[Pi,Hi,Ii]=ch.toChannels(g.rgba),{css:wi.toCss(Pi,Hi,Ii,si),rgba:wi.toRgba(Pi,Hi,Ii,si)}}e.opacity=c;function h(g,f){return si=g.rgba&255,c(g,si*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Kt||={});var Jt;(e=>{let t,r;try{let l=document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function s(l){if(l.match(/#[\da-f]{3,8}/i))switch(l.length){case 4:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),wi.toColor(Pi,Hi,Ii);case 5:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),si=parseInt(l.slice(4,5).repeat(2),16),wi.toColor(Pi,Hi,Ii,si);case 7:return{css:l,rgba:(parseInt(l.slice(1),16)<<8|255)>>>0};case 9:return{css:l,rgba:parseInt(l.slice(1),16)>>>0}}let c=l.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 Pi=parseInt(c[1]),Hi=parseInt(c[2]),Ii=parseInt(c[3]),si=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),wi.toColor(Pi,Hi,Ii,si);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=l,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pi,Hi,Ii,si]=t.getImageData(0,0,1,1).data,si!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:wi.toRgba(Pi,Hi,Ii,si),css:l}}e.toColor=s})(Jt||={});var cn;(e=>{function t(s){return r(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function r(s,l,c){let h=s/255,p=l/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+b*.7152+y*.0722}e.relativeLuminance2=r})(cn||={});var ch;(e=>{function t(h,p){if(si=(p&255)/255,si===1)return p;let g=p>>24&255,f=p>>16&255,b=p>>8&255,y=h>>24&255,S=h>>16&255,w=h>>8&255;return Pi=y+Math.round((g-y)*si),Hi=S+Math.round((f-S)*si),Ii=w+Math.round((b-w)*si),wi.toRgba(Pi,Hi,Ii)}e.blend=t;function r(h,p,g){let f=cn.relativeLuminance(h>>8),b=cn.relativeLuminance(p>>8);if(Qr(f,b)<g){if(b<f){let w=s(h,p,g),k=Qr(f,cn.relativeLuminance(w>>8));if(k<g){let E=l(h,p,g),L=Qr(f,cn.relativeLuminance(E>>8));return k>L?w:E}return w}let y=l(h,p,g),S=Qr(f,cn.relativeLuminance(y>>8));if(S<g){let w=s(h,p,g),k=Qr(f,cn.relativeLuminance(w>>8));return S>k?y:w}return y}}e.ensureContrastRatio=r;function s(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,E=Qr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));for(;E<g&&(S>0||w>0||k>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),k-=Math.max(0,Math.ceil(k*.1)),E=Qr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.reduceLuminance=s;function l(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,E=Qr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));for(;E<g&&(S<255||w<255||k<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),E=Qr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.increaseLuminance=l;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(ch||={});function Ea(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Qr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var DR=class extends Mc{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},Th=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new er}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 r=[],s=t.translateToString(!0),l=0,c=0,h=0,p=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==p||this._workCell.bg!==g){if(f-l>1){let b=this._getJoinedRanges(s,h,c,t,l);for(let y=0;y<b.length;y++)r.push(b[y])}l=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||$s.length}if(this._bufferService.cols-l>1){let f=this._getJoinedRanges(s,h,c,t,l);for(let b=0;b<f.length;b++)r.push(f[b])}return r}_getJoinedRanges(e,t,r,s,l){let c=e.substring(t,r),h=[];try{h=this._characterJoiners[0].handler(c)}catch(p){console.error(p)}for(let p=1;p<this._characterJoiners.length;p++)try{let g=this._characterJoiners[p].handler(c);for(let f=0;f<g.length;f++)Th._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,s,l),h}_stringRangesToCellRanges(e,t,r){let s=0,l=!1,c=0,h=e[s];if(h){for(let p=r;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||$s.length;if(g!==0){if(!l&&h[0]<=c&&(h[0]=p,l=!0),h[1]<=c){if(h[1]=p,h=e[++s],!h)break;h[0]<=c?(h[0]=p,l=!0):l=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let s=0;s<e.length;s++){let l=e[s];if(r){if(t[1]<=l[0])return e[s-1][1]=t[1],e;if(t[1]<=l[1])return e[s-1][1]=Math.max(t[1],l[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=l[0])return e.splice(s,0,t),e;if(t[1]<=l[1])return l[0]=Math.min(t[0],l[0]),e;t[0]<l[1]&&(l[0]=Math.min(t[0],l[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};Th=ai([Ae(0,un)],Th);function RR(e){return 57508<=e&&e<=57558}function MR(e){return 9472<=e&&e<=9631}function NR(e){return RR(e)||MR(e)}function AR(){return{css:{canvas:Yu(),cell:Yu()},device:{canvas:Yu(),cell:Yu(),char:{width:0,height:0,left:0,top:0}}}}function Yu(){return{width:0,height:0}}var Bm=class{constructor(e,t,r,s,l,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=s,this._coreService=l,this._decorationService=c,this._themeService=h,this._workCell=new er,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,s,l,c,h,p,g,f,b){let y=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,k=e.getNoBgTrimmedLength();r&&k<c+1&&(k=c+1);let E,L=0,A="",B=0,Y=0,P=0,q=0,re=!1,ie=0,he=!1,ve=0,U=0,K=[],W=f!==-1&&b!==-1;for(let H=0;H<k;H++){e.loadCell(H,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let le=!1,R=H>=U,X=H,Z=this._workCell;if(S.length>0&&H===S[0][0]&&R){let ye=S.shift(),Me=this._isCellInSelection(ye[0],t);for(B=ye[0]+1;B<ye[1];B++)R&&=Me===this._isCellInSelection(B,t);R&&=!r||c<ye[0]||c>=ye[1],R?(le=!0,Z=new DR(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),X=ye[1]-1,j=Z.getWidth()):U=ye[1]}let Ce=this._isCellInSelection(H,t),Te=r&&H===c,M=W&&H>=f&&H<=b,Q=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,ye=>{Q=!0});let de=Z.getChars()||$s;if(de===" "&&(Z.isUnderline()||Z.isOverline())&&(de=" "),ve=j*p-g.get(de,Z.isBold(),Z.isItalic()),!E)E=this._document.createElement("span");else if(L&&(Ce&&he||!Ce&&!he&&Z.bg===Y)&&(Ce&&he&&w.selectionForeground||Z.fg===P)&&Z.extended.ext===q&&M===re&&ve===ie&&!Te&&!le&&!Q&&R){Z.isInvisible()?A+=$s:A+=de,L++;continue}else L&&(E.textContent=A),E=this._document.createElement("span"),L=0,A="";if(Y=Z.bg,P=Z.fg,q=Z.extended.ext,re=M,ie=ve,he=Ce,le&&c>=H&&c<=X&&(c=H),!this._coreService.isCursorHidden&&Te&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(Z.isBold()&&K.push("xterm-bold"),Z.isItalic()&&K.push("xterm-italic"),Z.isDim()&&K.push("xterm-dim"),Z.isInvisible()?A=$s:A=Z.getChars()||$s,Z.isUnderline()&&(K.push(`xterm-underline-${Z.extended.underlineStyle}`),A===" "&&(A=" "),!Z.isUnderlineColorDefault()))if(Z.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${Mc.toColorRGB(Z.getUnderlineColor()).join(",")})`;else{let ye=Z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Z.isBold()&&ye<8&&(ye+=8),E.style.textDecorationColor=w.ansi[ye].css}Z.isOverline()&&(K.push("xterm-overline"),A===" "&&(A=" ")),Z.isStrikethrough()&&K.push("xterm-strikethrough"),M&&(E.style.textDecoration="underline");let me=Z.getFgColor(),ge=Z.getFgColorMode(),Se=Z.getBgColor(),Ee=Z.getBgColorMode(),De=!!Z.isInverse();if(De){let ye=me;me=Se,Se=ye;let Me=ge;ge=Ee,Ee=Me}let Ue,se,pe=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,ye=>{ye.options.layer!=="top"&&pe||(ye.backgroundColorRGB&&(Ee=50331648,Se=ye.backgroundColorRGB.rgba>>8&16777215,Ue=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ge=50331648,me=ye.foregroundColorRGB.rgba>>8&16777215,se=ye.foregroundColorRGB),pe=ye.options.layer==="top")}),!pe&&Ce&&(Ue=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Se=Ue.rgba>>8&16777215,Ee=50331648,pe=!0,w.selectionForeground&&(ge=50331648,me=w.selectionForeground.rgba>>8&16777215,se=w.selectionForeground)),pe&&K.push("xterm-decoration-top");let Le;switch(Ee){case 16777216:case 33554432:Le=w.ansi[Se],K.push(`xterm-bg-${Se}`);break;case 50331648:Le=wi.toColor(Se>>16,Se>>8&255,Se&255),this._addStyle(E,`background-color:#${qS((Se>>>0).toString(16),"0",6)}`);break;default:De?(Le=w.foreground,K.push("xterm-bg-257")):Le=w.background}switch(Ue||Z.isDim()&&(Ue=Kt.multiplyOpacity(Le,.5)),ge){case 16777216:case 33554432:Z.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(E,Le,w.ansi[me],Z,Ue,void 0)||K.push(`xterm-fg-${me}`);break;case 50331648:let ye=wi.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(E,Le,ye,Z,Ue,se)||this._addStyle(E,`color:#${qS(me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(E,Le,w.foreground,Z,Ue,se)||De&&K.push("xterm-fg-257")}K.length&&(E.className=K.join(" "),K.length=0),!Te&&!le&&!Q&&R?L++:E.textContent=A,ve!==this.defaultSpacing&&(E.style.letterSpacing=`${ve}px`),y.push(E),H=X}return E&&L&&(E.textContent=A),y}_applyMinimumContrast(e,t,r,s,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||NR(s.getCode()))return!1;let h=this._getContrastCache(s),p;if(!l&&!c&&(p=h.getColor(t.rgba,r.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);p=Kt.ensureContrastRatio(l||t,c||r,g),h.setColor((l||t).rgba,(c||r).rgba,p??null)}return p?(this._addStyle(e,`color:${p.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 r=this._selectionStart,s=this._selectionEnd;return!r||!s?!1:this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&t>=r[1]&&e<s[0]&&t<=s[1]:e<r[0]&&t>=r[1]&&e>=s[0]&&t<=s[1]:t>r[1]&&t<s[1]||r[1]===s[1]&&t===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&t===s[1]&&e<s[0]||r[1]<s[1]&&t===r[1]&&e>=r[0]}};Bm=ai([Ae(1,a1),Ae(2,hn),Ae(3,ns),Ae(4,Wa),Ae(5,Nc),Ae(6,ql)],Bm);function qS(e,t,r){for(;e.length<r;)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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.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=[r,s,l,c],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(l),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,r,s){e===this._font&&t===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,r){let s=0;if(!t&&!r&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let h=this._measure(e,0);return h>0&&(this._flat[s]=h),h}let l=e;t&&(l+="B"),r&&(l+="I");let c=this._holey.get(l);if(c===void 0){let h=0;t&&(h|=1),r&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(l,c)}return c}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},BR=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,r,s=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let l=e.buffers.active.ydisp,c=t[1]-l,h=r[1]-l,p=Math.max(c,0),g=Math.min(h,e.rows-1);if(p>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function OR(){return new BR}var Sp="xterm-dom-renderer-owner-",Xn="xterm-rows",Xu="xterm-fg-",$S="xterm-bg-",Ho="xterm-focus",Gu="xterm-selection",zR=1,Om=class extends ot{constructor(e,t,r,s,l,c,h,p,g,f,b,y,S,w){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=s,this._viewportElement=l,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=b,this._coreService=y,this._coreBrowserService=S,this._themeService=w,this._terminalClass=zR++,this._rowElements=[],this._selectionRenderModel=OR(),this.onRequestRedraw=this._register(new xe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Xn),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(Gu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=AR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(Bm,document),this._element.classList.add(Sp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(Vt(()=>{this._element.classList.remove(Sp+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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Xn} 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} .${Xn} { 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} .${Xn} .xterm-dim { color: ${Kt.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Xn}.${Ho} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Xn}.${Ho} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Xn}.${Ho} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Gu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Gu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Gu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Xu}${c} { color: ${h.css}; }${this._terminalSelector} .${Xu}${c}.xterm-dim { color: ${Kt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${$S}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Xu}257 { color: ${Kt.opaque(e.background).css}; }${this._terminalSelector} .${Xu}257.xterm-dim { color: ${Kt.multiplyOpacity(Kt.opaque(e.background),.5).css}; }${this._terminalSelector} .${$S}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 r=this._rowElements.length;r<=t;r++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ho),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ho),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(r){let g=e[0]>t[0];p.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=s===c?e[0]:0,f=c===l?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let b=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=l===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,r,s=1){let l=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(r-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),l.style.height=`${s*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${h}px`,l}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 r=this._bufferService.buffer,s=r.ybase+r.y,l=Math.min(r.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+r.ydisp,b=this._rowElements[g],y=r.lines.get(f);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,f,f===s,h,p,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Sp}${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,r,s,l,c){r<0&&(e=0),s<0&&(t=0);let h=this._bufferService.rows-1;r=Math.max(Math.min(r,h),0),s=Math.max(Math.min(s,h),0),l=Math.min(l,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,l-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=r;w<=s;++w){let k=w+p.ydisp,E=this._rowElements[w],L=p.lines.get(k);if(!E||!L)break;E.replaceChildren(...this._rowFactory.createRow(L,k,k===g,y,S,f,b,this.dimensions.css.cell.width,this._widthCache,c?w===r?e:0:-1,c?(w===s?t:l)-1:-1))}}};Om=ai([Ae(7,Yg),Ae(8,Yh),Ae(9,hn),Ae(10,un),Ae(11,Wa),Ae(12,ns),Ae(13,ql)],Om);var zm=class extends ot{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new xe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new PR(this._optionsService))}catch{this._measureStrategy=this._register(new jR(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())}};zm=ai([Ae(2,hn)],zm);var k1=class extends ot{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)}},jR=class extends k1{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},PR=class extends k1{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}},HR=class extends ot{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new IR(this._window)),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new xe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Xi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(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}},IR=class extends ot{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Hl),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(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)}},UR=class extends ot{constructor(){super(),this.linkProviders=[],this._register(Vt(()=>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 i_(e,t,r){let s=r.getBoundingClientRect(),l=e.getComputedStyle(r),c=parseInt(l.getPropertyValue("padding-left")),h=parseInt(l.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-h]}function KR(e,t,r,s,l,c,h,p,g){if(!c)return;let f=i_(e,t,r);if(f)return f[0]=Math.ceil((f[0]+(g?h/2:0))/h),f[1]=Math.ceil(f[1]/p),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),l),f}var jm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,s,l){return KR(window,e,t,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,t){let r=i_(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};jm=ai([Ae(0,rs),Ae(1,Yh)],jm);var WR=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,r){this._rowCount=r,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=[]}},E1={};JT(E1,{getSafariVersion:()=>qR,isChromeOS:()=>M1,isFirefox:()=>T1,isIpad:()=>$R,isIphone:()=>VR,isLegacyEdge:()=>FR,isLinux:()=>n_,isMac:()=>Dh,isNode:()=>Xh,isSafari:()=>D1,isWindows:()=>R1});var Xh=typeof process<"u"&&"title"in process,Ac=Xh?"node":navigator.userAgent,Lc=Xh?"node":navigator.platform,T1=Ac.includes("Firefox"),FR=Ac.includes("Edge"),D1=/^((?!chrome|android).)*safari/i.test(Ac);function qR(){if(!D1)return 0;let e=Ac.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Dh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Lc),$R=Lc==="iPad",VR=Lc==="iPhone",R1=["Windows","Win16","Win32","WinCE"].includes(Lc),n_=Lc.indexOf("Linux")>=0,M1=/\bCrOS\b/.test(Ac),N1=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,r=0,s=e.timeRemaining(),l=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),l=e.timeRemaining(),r*1.5>l){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=l}this.clear()}},YR=class extends N1{_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())}}},XR=class extends N1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Rh=!Xh&&"requestIdleCallback"in window?XR:YR,GR=class{constructor(){this._queue=new Rh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Pm=class extends ot{constructor(e,t,r,s,l,c,h,p,g){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=l,this._coreBrowserService=p,this._renderer=this._register(new Hl),this._pausedResizeTask=new GR,this._observerDisposable=this._register(new Hl),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 xe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new xe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new xe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new WR((f,b)=>this._renderRows(f,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ZR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Vt(()=>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(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=Vt(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),r||(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,r){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,t,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Pm=ai([Ae(2,hn),Ae(3,Yh),Ae(4,Wa),Ae(5,Nc),Ae(6,un),Ae(7,ns),Ae(8,ql)],Pm);var ZR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,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 QR(e,t,r,s){let l=r.buffer.x,c=r.buffer.y;if(!r.buffer.hasScrollback)return tM(l,c,e,t,r,s)+Gh(c,t,r,s)+iM(l,c,e,t,r,s);let h;if(c===t)return h=l>e?"D":"C",vc(Math.abs(l-e),_c(h,s));h=c>t?"D":"C";let p=Math.abs(c-t),g=eM(c>t?e:l,r)+(p-1)*r.cols+1+JR(c>t?l:e);return vc(g,_c(h,s))}function JR(e,t){return e-1}function eM(e,t){return t.cols-e}function tM(e,t,r,s,l,c){return Gh(t,s,l,c).length===0?"":vc(L1(e,t,e,t-Ua(t,l),!1,l).length,_c("D",c))}function Gh(e,t,r,s){let l=e-Ua(e,r),c=t-Ua(t,r),h=Math.abs(l-c)-nM(e,t,r);return vc(h,_c(A1(e,t),s))}function iM(e,t,r,s,l,c){let h;Gh(t,s,l,c).length>0?h=s-Ua(s,l):h=t;let p=s,g=rM(e,t,r,s,l,c);return vc(L1(e,h,r,p,g==="C",l).length,_c(g,c))}function nM(e,t,r){let s=0,l=e-Ua(e,r),c=t-Ua(t,r);for(let h=0;h<Math.abs(l-c);h++){let p=A1(e,t)==="A"?-1:1;r.buffer.lines.get(l+p*h)?.isWrapped&&s++}return s}function Ua(e,t){let r=0,s=t.buffer.lines.get(e),l=s?.isWrapped;for(;l&&e>=0&&e<t.rows;)r++,s=t.buffer.lines.get(--e),l=s?.isWrapped;return r}function rM(e,t,r,s,l,c){let h;return Gh(r,s,l,c).length>0?h=s-Ua(s,l):h=t,e<r&&h<=s||e>=r&&h<s?"C":"D"}function A1(e,t){return e>t?"A":"B"}function L1(e,t,r,s,l,c){let h=e,p=t,g="";for(;(h!==r||p!==s)&&p>=0&&p<c.buffer.lines.length;)h+=l?1:-1,l&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!l&&h<0&&(g+=c.buffer.translateBufferLineToString(p,!1,0,e+1),h=c.cols-1,e=h,p--);return g+c.buffer.translateBufferLineToString(p,!1,e,h)}function _c(e,t){let r=t?"O":"[";return fe.ESC+r+e}function vc(e,t){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=t;return r}var sM=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 VS(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 wp=50,aM=15,lM=50,oM=500,cM=" ",uM=new RegExp(cM,"g"),Hm=class extends ot{constructor(e,t,r,s,l,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=s,this._coreService=l,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new er,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new xe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new xe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new sM(this._bufferService),this._activeSelectionMode=0,this._register(Vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.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 r=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let l=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 p=r.translateBufferLineToString(h,!0,l,c);s.push(p)}}else{let l=e[1]===t[1]?t[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=t[1]-1;c++){let h=r.lines.get(c),p=r.translateBufferLineToString(c,!0);h?.isWrapped?s[s.length-1]+=p:s.push(p)}if(e[1]!==t[1]){let c=r.lines.get(t[1]),h=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=h:s.push(h)}}return s.map(l=>l.replace(uM," ")).join(R1?`\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())),n_&&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),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s||!t?!1:this._areCoordsInSelection(t,r,s)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s?!1:this._areCoordsInSelection([e,t],r,s)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=VS(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=i_(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-wp),wp),t/=wp,t/Math.abs(t)+Math.round(t*(aM-1)))}shouldForceSelection(e){return Dh?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(),lM)}_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&&!(Dh&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let s=r.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<oM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let s=QR(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let s=0;t>=s;s++){let l=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:l>1&&t!==s&&(r+=l-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let h=l.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,b=0,y=0,S=0,w=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let L=e[0],A=e[0];c.getWidth(L)===0&&(b++,L--),c.getWidth(A)===2&&(y++,A++);let B=c.getString(A).length;for(B>1&&(w+=B-1,g+=B-1);L>0&&p>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,L--):Y>1&&(S+=Y-1,p-=Y-1),p--,L--}for(;A<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,A++):Y>1&&(w+=Y-1,g+=Y-1),g++,A++}}g++;let k=p+f-b+S,E=Math.min(this._bufferService.cols,g-p+b+y-S-w);if(!(!t&&h.slice(p,g).trim()==="")){if(r&&k===0&&c.getCodePoint(0)!==32){let L=l.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let B=this._bufferService.cols-A.start;k-=B,E+=B}}}if(s&&k+E===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=l.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(E+=A.length)}}return{start:k,length:E}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=VS(r,this._bufferService.cols)}};Hm=ai([Ae(3,un),Ae(4,Wa),Ae(5,Xg),Ae(6,hn),Ae(7,rs),Ae(8,ns)],Hm);var YS=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},XS=class{constructor(){this._color=new YS,this._css=new YS}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ti=Object.freeze((()=>{let e=[Jt.toColor("#2e3436"),Jt.toColor("#cc0000"),Jt.toColor("#4e9a06"),Jt.toColor("#c4a000"),Jt.toColor("#3465a4"),Jt.toColor("#75507b"),Jt.toColor("#06989a"),Jt.toColor("#d3d7cf"),Jt.toColor("#555753"),Jt.toColor("#ef2929"),Jt.toColor("#8ae234"),Jt.toColor("#fce94f"),Jt.toColor("#729fcf"),Jt.toColor("#ad7fa8"),Jt.toColor("#34e2e2"),Jt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=t[r/36%6|0],l=t[r/6%6|0],c=t[r%6];e.push({css:wi.toCss(s,l,c),rgba:wi.toRgba(s,l,c)})}for(let r=0;r<24;r++){let s=8+r*10;e.push({css:wi.toCss(s,s,s),rgba:wi.toRgba(s,s,s)})}return e})()),Da=Jt.toColor("#ffffff"),Zo=Jt.toColor("#000000"),GS=Jt.toColor("#ffffff"),ZS=Zo,Io={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},hM=Da,Im=class extends ot{constructor(e){super(),this._optionsService=e,this._contrastCache=new XS,this._halfContrastCache=new XS,this._onChangeColors=this._register(new xe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Da,background:Zo,cursor:GS,cursorAccent:ZS,selectionForeground:void 0,selectionBackgroundTransparent:Io,selectionBackgroundOpaque:Kt.blend(Zo,Io),selectionInactiveBackgroundTransparent:Io,selectionInactiveBackgroundOpaque:Kt.blend(Zo,Io),scrollbarSliderBackground:Kt.opacity(Da,.2),scrollbarSliderHoverBackground:Kt.opacity(Da,.4),scrollbarSliderActiveBackground:Kt.opacity(Da,.5),overviewRulerBorder:Da,ansi:Ti.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=At(e.foreground,Da),t.background=At(e.background,Zo),t.cursor=Kt.blend(t.background,At(e.cursor,GS)),t.cursorAccent=Kt.blend(t.background,At(e.cursorAccent,ZS)),t.selectionBackgroundTransparent=At(e.selectionBackground,Io),t.selectionBackgroundOpaque=Kt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=At(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Kt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?At(e.selectionForeground,FS):void 0,t.selectionForeground===FS&&(t.selectionForeground=void 0),Kt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Kt.opacity(t.selectionBackgroundTransparent,.3)),Kt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Kt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=At(e.scrollbarSliderBackground,Kt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=At(e.scrollbarSliderHoverBackground,Kt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=At(e.scrollbarSliderActiveBackground,Kt.opacity(t.foreground,.5)),t.overviewRulerBorder=At(e.overviewRulerBorder,hM),t.ansi=Ti.slice(),t.ansi[0]=At(e.black,Ti[0]),t.ansi[1]=At(e.red,Ti[1]),t.ansi[2]=At(e.green,Ti[2]),t.ansi[3]=At(e.yellow,Ti[3]),t.ansi[4]=At(e.blue,Ti[4]),t.ansi[5]=At(e.magenta,Ti[5]),t.ansi[6]=At(e.cyan,Ti[6]),t.ansi[7]=At(e.white,Ti[7]),t.ansi[8]=At(e.brightBlack,Ti[8]),t.ansi[9]=At(e.brightRed,Ti[9]),t.ansi[10]=At(e.brightGreen,Ti[10]),t.ansi[11]=At(e.brightYellow,Ti[11]),t.ansi[12]=At(e.brightBlue,Ti[12]),t.ansi[13]=At(e.brightMagenta,Ti[13]),t.ansi[14]=At(e.brightCyan,Ti[14]),t.ansi[15]=At(e.brightWhite,Ti[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)t.ansi[s+16]=At(e.extendedAnsi[s],Ti[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Im=ai([Ae(0,hn)],Im);function At(e,t){if(e!==void 0)try{return Jt.toColor(e)}catch{}return t}var dM=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},fM=class{constructor(){this._services=new dM,this._services.set(Yg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=aD(e).sort((c,h)=>c.index-h.index),s=[];for(let c of r){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(h)}let l=r.length>0?r[0].index:t.length;if(t.length!==l)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${l+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},pM={trace:0,debug:1,info:2,warn:3,error:4,off:5},mM="xterm.js: ",Um=class extends ot{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=pM[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":mM)+t,...r)}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)}};Um=ai([Ae(0,hn)],Um);var QS=class extends ot{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new xe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new xe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new xe),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+r.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<r.length;s++)this._array[this._getCyclicIndex(e+s)]=r[s];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let s=this._length+r.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let l=t-1;l>=0;l--)this.set(e+l+r,this.get(e+l));let s=e+t+r-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},lt=3,bi=Object.freeze(new Mc),Zu=0,Cp=2,Qo=class B1{constructor(t,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*lt);let l=r||er.fromCharData([0,Jw,1,0]);for(let c=0;c<t;++c)this.setCell(c,l);this.length=t}get(t){let r=this._data[t*lt+0],s=r&2097151;return[this._data[t*lt+1],r&2097152?this._combined[t]:s?qs(s):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,r){this._data[t*lt+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*lt+0]=t|2097152|r[2]<<22):this._data[t*lt+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*lt+0]>>22}hasWidth(t){return this._data[t*lt+0]&12582912}getFg(t){return this._data[t*lt+1]}getBg(t){return this._data[t*lt+2]}hasContent(t){return this._data[t*lt+0]&4194303}getCodePoint(t){let r=this._data[t*lt+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*lt+0]&2097152}getString(t){let r=this._data[t*lt+0];return r&2097152?this._combined[t]:r&2097151?qs(r&2097151):""}isProtected(t){return this._data[t*lt+2]&536870912}loadCell(t,r){return Zu=t*lt,r.content=this._data[Zu+0],r.fg=this._data[Zu+1],r.bg=this._data[Zu+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*lt+0]=r.content,this._data[t*lt+1]=r.fg,this._data[t*lt+2]=r.bg}setCellFromCodepoint(t,r,s,l){l.bg&268435456&&(this._extendedAttrs[t]=l.extended),this._data[t*lt+0]=r|s<<22,this._data[t*lt+1]=l.fg,this._data[t*lt+2]=l.bg}addCodepointToCell(t,r,s){let l=this._data[t*lt+0];l&2097152?this._combined[t]+=qs(r):l&2097151?(this._combined[t]=qs(l&2097151)+qs(r),l&=-2097152,l|=2097152):l=r|1<<22,s&&(l&=-12582913,l|=s<<22),this._data[t*lt+0]=l}insertCells(t,r,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length-t){let l=new er;for(let c=this.length-t-r-1;c>=0;--c)this.setCell(t+r+c,this.loadCell(t+c,l));for(let c=0;c<r;++c)this.setCell(t+c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,r,s){if(t%=this.length,r<this.length-t){let l=new er;for(let c=0;c<this.length-t-r;++c)this.setCell(t+c,this.loadCell(t+r+c,l));for(let c=this.length-r;c<this.length;++c)this.setCell(c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,r,s,l=!1){if(l){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.setCell(t++,s)}resize(t,r){if(t===this.length)return this._data.length*4*Cp<this._data.buffer.byteLength;let s=t*lt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<t;++l)this.setCell(l,r)}else{this._data=this._data.subarray(0,s);let l=Object.keys(this._combined);for(let h=0;h<l.length;h++){let p=parseInt(l[h],10);p>=t&&delete this._combined[p]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let p=parseInt(c[h],10);p>=t&&delete this._extendedAttrs[p]}}return this.length=t,s*4*Cp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Cp<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new B1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303)return t+(this._data[t*lt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303||this._data[t*lt+2]&50331648)return t+(this._data[t*lt+0]>>22);return 0}copyCellsFrom(t,r,s,l,c){let h=t._data;if(c)for(let g=l-1;g>=0;g--){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(r+g)*lt+f];h[(r+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}else for(let g=0;g<l;g++){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(r+g)*lt+f];h[(r+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=r&&(this._combined[f-r+s]=t._combined[f])}}translateToString(t,r,s,l){r=r??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let c="";for(;r<s;){let h=this._data[r*lt+0],p=h&2097151,g=h&2097152?this._combined[r]:p?qs(p):$s;if(c+=g,l)for(let f=0;f<g.length;++f)l.push(r);r+=h>>22||1}return l&&l.push(r),c}};function gM(e,t,r,s,l,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let b=[e.get(p)];for(;g<e.length&&f.isWrapped;)b.push(f),f=e.get(++g);if(!c&&s>=p&&s<g){p+=b.length-1;continue}let y=0,S=yc(b,y,t),w=1,k=0;for(;w<b.length;){let L=yc(b,w,t),A=L-k,B=r-S,Y=Math.min(A,B);b[y].copyCellsFrom(b[w],k,S,Y,!1),S+=Y,S===r&&(y++,S=0),k+=Y,k===L&&(w++,k=0),S===0&&y!==0&&b[y-1].getWidth(r-1)===2&&(b[y].copyCellsFrom(b[y-1],r-1,S++,1,!1),b[y-1].setCell(r-1,l))}b[y].replaceCells(S,r,l);let E=0;for(let L=b.length-1;L>0&&(L>y||b[L].getTrimmedLength()===0);L--)E++;E>0&&(h.push(p+b.length-E),h.push(E)),p+=b.length-1}return h}function _M(e,t){let r=[],s=0,l=t[s],c=0;for(let h=0;h<e.length;h++)if(l===h){let p=t[++s];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,l=t[++s]}else r.push(h);return{layout:r,countRemoved:c}}function vM(e,t){let r=[];for(let s=0;s<t.length;s++)r.push(e.get(t[s]));for(let s=0;s<r.length;s++)e.set(s,r[s]);e.length=t.length}function yM(e,t,r){let s=[],l=e.map((g,f)=>yc(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<l;){if(l-p<r){s.push(l-p);break}c+=r;let g=yc(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let b=f?r-1:r;s.push(b),p+=b}return s}function yc(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,l=e[t+1].getWidth(0)===2;return s&&l?r-1:r}var O1=class z1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=z1._nextId++,this._onDispose=this.register(new xe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ia(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};O1._nextId=1;var bM=O1,Ni={},Ra=Ni.B;Ni[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ni.A={"#":"£"};Ni.B=void 0;Ni[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ni.C=Ni[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ni.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ni.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ni.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ni.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ni.E=Ni[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ni.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ni.H=Ni[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ni["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var JS=4294967295,e0=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=bi.clone(),this.savedCharset=Ra,this.markers=[],this._nullCell=er.fromCharData([0,Jw,1,0]),this._whitespaceCell=er.fromCharData([0,$s,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Rh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new QS(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 kh),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 kh),this._whitespaceCell}getBlankLine(e,t){return new Qo(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>JS?JS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=bi);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 QS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(bi),s=0,l=this._getCorrectBufferLength(t);if(l>this.lines.maxLength&&(this.lines.maxLength=l),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)s+=+this.lines.get(h).resize(e,r);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 Qo(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Qo(e,r)));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(l<this.lines.maxLength){let h=this.lines.length-l;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=l}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++)s+=+this.lines.get(c).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=gM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(bi),r);if(s.length>0){let l=_M(this.lines,s);vM(this.lines,l.layout),this._reflowLargerAdjustViewport(e,t,l.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let s=this.getNullCell(bi),l=r;for(;l-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Qo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(bi),l=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let p=this.lines.get(h);if(!p||!p.isWrapped&&p.getTrimmedLength()<=e)continue;let g=[p];for(;p.isWrapped&&h>0;)p=this.lines.get(--h),g.unshift(p);if(!r){let Y=this.ybase+this.y;if(Y>=h&&Y<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),b=yM(g,this._cols,e),y=b.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+y):S=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let Y=0;Y<y;Y++){let P=this.getBlankLine(bi,!0);w.push(P)}w.length>0&&(l.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let k=b.length-1,E=b[k];E===0&&(k--,E=b[k]);let L=g.length-y-1,A=f;for(;L>=0;){let Y=Math.min(A,E);if(g[k]===void 0)break;if(g[k].copyCellsFrom(g[L],A-Y,E-Y,Y,!0),E-=Y,E===0&&(k--,E=b[k]),A-=Y,A===0){L--;let P=Math.max(L,0);A=yc(g,P,this._cols)}}for(let Y=0;Y<g.length;Y++)b[Y]<e&&g[Y].setCell(b[Y],s);let B=y-S;for(;B-- >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+y,this.ybase+t-1)}if(l.length>0){let h=[],p=[];for(let E=0;E<this.lines.length;E++)p.push(this.lines.get(E));let g=this.lines.length,f=g-1,b=0,y=l[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let E=Math.min(this.lines.maxLength-1,g+c-1);E>=0;E--)if(y&&y.start>f+S){for(let L=y.newLines.length-1;L>=0;L--)this.lines.set(E--,y.newLines[L]);E++,h.push({index:f+1,amount:y.newLines.length}),S+=y.newLines.length,y=l[++b]}else this.lines.set(E,p[f--]);let w=0;for(let E=h.length-1;E>=0;E--)h[E].index+=w,this.lines.onInsertEmitter.fire(h[E]),w+=h[E].amount;let k=Math.max(0,g+c-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,r=0,s){let l=this.lines.get(e);return l?l.translateToString(t,r,s):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}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 bM(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},SM=class extends ot{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new xe),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 e0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new e0(!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)}},j1=2,P1=1,Km=class extends ot{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,j1),this.rows=Math.max(e.rawOptions.rows||0,P1),this.buffers=this._register(new SM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=r.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let l=r.ybase+r.scrollTop,c=r.ybase+r.scrollBottom;if(r.scrollTop===0){let h=r.lines.isFull;c===r.lines.length-1?h?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(c+1,0,s.clone()),h?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let h=c-l+1;r.lines.shiftElements(l+1,h-1,-1),r.lines.set(c,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Km=ai([Ae(0,hn)],Km);var El={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:Dh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},wM=["normal","bold","100","200","300","400","500","600","700","800","900"],CM=class extends ot{constructor(e){super(),this._onOptionChange=this._register(new xe),this.onOptionChange=this._onOptionChange.event;let t={...El};for(let r in e)if(r in t)try{let s=e[r];t[r]=this._sanitizeAndValidateOption(r,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Vt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in El))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,s)=>{if(!(r in El))throw new Error(`No option with key "${r}"`);s=this._sanitizeAndValidateOption(r,s),this.rawOptions[r]!==s&&(this.rawOptions[r]=s,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=El[e]),!xM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=El[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=wM.includes(t)?t:El[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 xM(e){return e==="block"||e==="underline"||e==="bar"}function Jo(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=t<=1?e[s]:e[s]&&Jo(e[s],t-1);return r}var t0=Object.freeze({insertMode:!1}),i0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Wm=class extends ot{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new xe),this.onData=this._onData.event,this._onUserInput=this._register(new xe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new xe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Jo(t0),this.decPrivateModes=Jo(i0)}reset(){this.modes=Jo(t0),this.decPrivateModes=Jo(i0)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Wm=ai([Ae(0,un),Ae(1,r1),Ae(2,hn)],Wm);var n0={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 xp(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var kp=String.fromCharCode,r0={DEFAULT:e=>{let t=[xp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${kp(t[0])}${kp(t[1])}${kp(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${xp(e,!0)};${e.x};${e.y}${t}`}},Fm=class extends ot{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new xe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(n0))this.addProtocol(s,n0[s]);for(let s of Object.keys(r0))this.addEncoding(s,r0[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let s=t/r,l=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=s+0,Math.abs(e.deltaY)<50&&(l*=.3),this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_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,r){if(r){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)}};Fm=ai([Ae(0,un),Ae(1,Wa),Ae(2,hn)],Fm);var Ep=[[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]],kM=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Di;function EM(e,t){let r=0,s=t.length-1,l;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=r;)if(l=r+s>>1,e>t[l][1])r=l+1;else if(e<t[l][0])s=l-1;else return!0;return!1}var TM=class{constructor(){if(this.version="6",!Di){Di=new Uint8Array(65536),Di.fill(1),Di[0]=0,Di.fill(0,1,32),Di.fill(0,127,160),Di.fill(2,4352,4448),Di[9001]=2,Di[9002]=2,Di.fill(2,11904,42192),Di[12351]=1,Di.fill(2,44032,55204),Di.fill(2,63744,64256),Di.fill(2,65040,65050),Di.fill(2,65072,65136),Di.fill(2,65280,65377),Di.fill(2,65504,65511);for(let e=0;e<Ep.length;++e)Di.fill(0,Ep[e][0],Ep[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Di[e]:EM(e,kM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),s=r===0&&t!==0;if(s){let l=Aa.extractWidth(t);l===0?s=!1:l>r&&(r=l)}return Aa.createPropertyValue(0,r,s)}},Aa=class uh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new xe,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,r,s=!1){return(t&16777215)<<3|(r&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,s=0,l=t.length;for(let c=0;c<l;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=l)return r+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:r+=this.wcwidth(f)}let p=this.charProperties(h,s),g=uh.extractWidth(p);uh.extractShouldJoin(p)&&(g-=uh.extractWidth(s)),r+=g,s=p}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},DM=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 s0(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Uo=2147483647,RM=256,H1=class qm{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>RM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new qm;if(!t.length)return r;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let l=t[s];if(Array.isArray(l))for(let c=0;c<l.length;++c)r.addSubParam(l[c]);else r.addParam(l)}return r}clone(){let t=new qm(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 r=0;r<this.length;++r){t.push(this.params[r]);let s=this._subParamsIdx[r]>>8,l=this._subParamsIdx[r]&255;l-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,l))}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>Uo?Uo: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>Uo?Uo:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,l=this._subParamsIdx[r]&255;l-s>0&&(t[r]=this._subParams.slice(s,l))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,l=s[r-1];s[r-1]=~l?Math.min(l*10+t,Uo):t}},Ko=[],MM=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 r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Vh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&r===!1){for(;s>=0&&(r=this._active[s].end(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=Ko,this._id=-1,this._state=0}}},An=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Vh(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Wo=[],NM=class{constructor(){this._handlers=Object.create(null),this._active=Wo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Wo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Wo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Wo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Vh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&r===!1){for(;s>=0&&(r=this._active[s].unhook(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=Wo,this._ident=0}},ec=new H1;ec.addParam(0);var a0=class{constructor(e){this._handler=e,this._data="",this._params=ec,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ec,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Vh(e,t,r),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(r=>(this._params=ec,this._data="",this._hitLimit=!1,r));return this._params=ec,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,r,s){this.table[t<<8|e]=r<<4|s}addMany(e,t,r,s){for(let l=0;l<e.length;l++)this.table[t<<8|e[l]]=r<<4|s}},Qn=160,LM=(function(){let e=new AM(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),r=(p,g)=>t.slice(p,g),s=r(32,127),l=r(0,24);l.push(25),l.push.apply(l,r(28,32));let c=r(0,14),h;e.setDefault(1,0),e.addMany(s,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(r(128,144),h,3,0),e.addMany(r(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(l,0,3,0),e.addMany(l,1,3,1),e.add(127,1,0,1),e.addMany(l,8,0,8),e.addMany(l,3,3,3),e.add(127,3,0,3),e.addMany(l,4,3,4),e.add(127,4,0,4),e.addMany(l,6,3,6),e.addMany(l,5,3,5),e.add(127,5,0,5),e.addMany(l,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(l,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(l,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(l,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(l,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(l,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(l,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Qn,0,2,0),e.add(Qn,8,5,8),e.add(Qn,6,0,6),e.add(Qn,11,0,11),e.add(Qn,13,13,13),e})(),BM=class extends ot{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 H1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(Vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new MM),this._dcsParser=this._register(new NM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>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 l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=s,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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,r,s,l){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=l}parse(e,t,r){let s=0,l=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let p=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(s!==24&&s!==26,r),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],h=this._oscParser.end(s!==24&&s!==26,r),h)return h;s===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 p=c;p<t;++p){switch(s=e[p],l=this._transitions.table[this.currentState<<8|(s<160?s:Qn)],l>>4){case 2:for(let S=p+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(h=g[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._preserveStack(3,g,f,l,p),h;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++p<t&&(s=e[p])>47&&s<60);p--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let b=this._escHandlers[this._collect<<8|s],y=b?b.length-1:-1;for(;y>=0&&(h=b[y](),h!==!0);y--)if(h instanceof Promise)return this._preserveStack(4,b,y,l,p),h;y<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let S=p+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Qn){this._dcsParser.put(e,p,S),p=S-1;break}break;case 14:if(h=this._dcsParser.unhook(s!==24&&s!==26),h)return this._preserveStack(6,[],0,l,p),h;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let S=p+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Qn){this._oscParser.put(e,p,S),p=S-1;break}break;case 6:if(h=this._oscParser.end(s!==24&&s!==26),h)return this._preserveStack(5,[],0,l,p),h;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},OM=/^([\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})$/,zM=/^[\da-f]+$/;function l0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=OM.exec(t);if(r){let s=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/s*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/s*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),zM.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,s=[0,0,0];for(let l=0;l<3;++l){let c=parseInt(t.slice(r*l,r*l+r),16);s[l]=r===1?c<<4:r===2?c:r===3?c>>4:c>>8}return s}}function Tp(e,t){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function jM(e,t=16){let[r,s,l]=e;return`rgb:${Tp(r,t)}/${Tp(s,t)}/${Tp(l,t)}`}var PM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Is=131072,o0=10;function c0(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 u0=5e3,h0=0,HM=class extends ot{constructor(e,t,r,s,l,c,h,p,g=new BM){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=s,this._optionsService=l,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rD,this._utf8Decoder=new sD,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=bi.clone(),this._eraseAttrDataInternal=bi.clone(),this._onRequestBell=this._register(new xe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new xe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new xe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new xe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new xe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new xe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new xe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new xe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new xe),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 $m(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:b.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:b,data:y})}),this._parser.setDcsHandlerFallback((f,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:b,payload:y})}),this._parser.setPrintHandler((f,b,y)=>this.print(f,b,y)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(fe.BEL,()=>this.bell()),this._parser.setExecuteHandler(fe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(fe.BS,()=>this.backspace()),this._parser.setExecuteHandler(fe.HT,()=>this.tab()),this._parser.setExecuteHandler(fe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(fe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(oh.IND,()=>this.index()),this._parser.setExecuteHandler(oh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(oh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new An(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new An(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new An(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new An(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new An(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new An(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new An(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new An(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new An(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new An(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new An(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new An(f=>this.restoreCursorColor(f))),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 f in Ni)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new a0((f,b)=>this.requestStatusString(f,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),u0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${u0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,s=this._activeBuffer.x,l=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,l=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Is&&(c=this._parseStack.position+Is)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Is&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Is))),h||this._dirtyRowTracker.clearRange(),e.length>Is)for(let f=c;f<e.length;f+=Is){let b=f+Is<e.length?f+Is:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(f,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,b),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,l,y,f),this._logSlowResolvingAsync(r),r}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,l,f,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==l)&&this._onCursorMove.fire();let p=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(p,this._bufferService.rows-1)})}print(e,t,r){let s,l,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,b=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let S=this._parser.precedingJoinState;for(let w=t;w<r;++w){if(s=e[w],s<127&&c){let A=c[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let k=this._unicodeService.charProperties(s,S);l=Aa.extractWidth(k);let E=Aa.extractShouldJoin(k),L=E?Aa.extractWidth(S):0;if(S=k,h&&this._onA11yChar.fire(qs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+l-L>p){if(g){let A=y,B=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&y instanceof Qo&&y.copyCellsFrom(A,B,0,L,!1);B<p;)A.setCellFromCodepoint(B++,0,1,b)}else if(this._activeBuffer.x=p-1,l===2)continue}if(E&&this._activeBuffer.x){let A=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-A,s,l);for(let B=l-L;--B>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(f&&(y.insertCells(this._activeBuffer.x,l-L,this._activeBuffer.getNullCell(b)),y.getWidth(p-1)===2&&y.setCellFromCodepoint(p-1,0,1,b)),y.setCellFromCodepoint(this._activeBuffer.x++,s,l,b),l>0)for(;--l;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=S,this._activeBuffer.x<p&&r-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>c0(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new a0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new An(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,r,s=!1,l=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),l),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,l=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(l-1,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}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 r=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(bi));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 r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,s=Aa.extractWidth(t),l=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(l),h=new Uint32Array(c.length*r),p=0;for(let f=0;f<c.length;){let b=c.codePointAt(f)||0;h[p++]=b,f+=b>65535?2:1}let g=p;for(let f=1;f<r;++f)h.copyWithin(g,0,p),g+=p;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(fe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(fe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(fe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(fe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(fe.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,Ra),this._charsetService.setgCharset(1,Ra),this._charsetService.setgCharset(2,Ra),this._charsetService.setgCharset(3,Ra);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 r;(E=>(E[E.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",E[E.SET=1]="SET",E[E.RESET=2]="RESET",E[E.PERMANENTLY_SET=3]="PERMANENTLY_SET",E[E.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(r||={});let s=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:b}=p,y=this._optionsService.rawOptions,S=(E,L)=>(h.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${E};${L}$y`),!0),w=E=>E?1:2,k=e.params[0];return t?k===2?S(k,4):k===4?S(k,w(h.modes.insertMode)):k===12?S(k,3):k===20?S(k,w(y.convertEol)):S(k,0):k===1?S(k,w(s.applicationCursorKeys)):k===3?S(k,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):k===6?S(k,w(s.origin)):k===7?S(k,w(s.wraparound)):k===8?S(k,3):k===9?S(k,w(l==="X10")):k===12?S(k,w(y.cursorBlink)):k===25?S(k,w(!h.isCursorHidden)):k===45?S(k,w(s.reverseWraparound)):k===66?S(k,w(s.applicationKeypad)):k===67?S(k,4):k===1e3?S(k,w(l==="VT200")):k===1002?S(k,w(l==="DRAG")):k===1003?S(k,w(l==="ANY")):k===1004?S(k,w(s.sendFocus)):k===1005?S(k,4):k===1006?S(k,w(c==="SGR")):k===1015?S(k,4):k===1016?S(k,w(c==="SGR_PIXELS")):k===1048?S(k,1):k===47||k===1047||k===1049?S(k,w(f===b)):k===2004?S(k,w(s.bracketedPasteMode)):k===2026?S(k,w(s.synchronizedOutput)):S(k,0)}_updateAttrColor(e,t,r,s,l){return t===2?(e|=50331648,e&=-16777216,e|=Mc.fromColorRGB([r,s,l])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let s=[0,0,-1,0,0,0],l=0,c=0;do{if(s[c+l]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do s[1]===5&&(l=1),s[c+p+1+l]=h[p];while(++p<h.length&&p+c+1+l<s.length);break}if(s[1]===5&&c+l>=2||s[1]===2&&c+l>=5)break;s[1]&&(l=1)}while(++c+t<e.length&&c+l<s.length);for(let h=2;h<s.length;++h)s[h]===-1&&(s[h]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,s[1],s[3],s[4],s[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=bi.fg,e.bg=bi.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,r,s=this._curAttrData;for(let l=0;l<t;l++)r=e.params[l],r>=30&&r<=37?(s.fg&=-50331904,s.fg|=16777216|r-30):r>=40&&r<=47?(s.bg&=-50331904,s.bg|=16777216|r-40):r>=90&&r<=97?(s.fg&=-50331904,s.fg|=16777216|r-90|8):r>=100&&r<=107?(s.bg&=-50331904,s.bg|=16777216|r-100|8):r===0?this._processSGR0(s):r===1?s.fg|=134217728:r===3?s.bg|=67108864:r===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(l)?e.getSubParams(l)[0]:1,s)):r===5?s.fg|=536870912:r===7?s.fg|=67108864:r===8?s.fg|=1073741824:r===9?s.fg|=2147483648:r===2?s.bg|=134217728:r===21?this._processUnderline(2,s):r===22?(s.fg&=-134217729,s.bg&=-134217729):r===23?s.bg&=-67108865:r===24?(s.fg&=-268435457,this._processUnderline(0,s)):r===25?s.fg&=-536870913:r===27?s.fg&=-67108865:r===28?s.fg&=-1073741825:r===29?s.fg&=2147483647:r===39?(s.fg&=-67108864,s.fg|=bi.fg&16777215):r===49?(s.bg&=-67108864,s.bg|=bi.bg&16777215):r===38||r===48||r===58?l+=this._extractColor(e,l,s):r===53?s.bg|=1073741824:r===55?s.bg&=-1073741825:r===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):r===100?(s.fg&=-67108864,s.fg|=bi.fg&16777215,s.bg&=-67108864,s.bg|=bi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${fe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[?${t};${r}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=bi.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 r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!c0(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(`${fe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>o0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>o0&&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=[],r=e.split(";");for(;r.length>1;){let s=r.shift(),l=r.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(d0(c))if(l==="?")t.push({type:0,index:c});else{let h=l0(l);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 r=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(r,s):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,l=r.findIndex(c=>c.startsWith("id="));return l!==-1&&(s=r[l].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let s=0;s<r.length&&!(t>=this._specialColors.length);++s,++t)if(r[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let l=l0(r[s]);l&&this._onColor.fire([{type:1,index:this._specialColors[t],color:l}])}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=[],r=e.split(";");for(let s=0;s<r.length;++s)if(/^\d+$/.exec(r[s])){let l=parseInt(r[s]);d0(l)&&t.push({type:2,index:l})}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,Ra),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(PM[e[0]],Ni[e[1]]||Ra),!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=bi.clone(),this._eraseAttrDataInternal=bi.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 er;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 r=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=h=>(this._coreService.triggerDataEvent(`${fe.ESC}${h}${fe.ESC}\\`),!0),s=this._bufferService.buffer,l=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[l.cursorStyle]-(l.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},$m=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&&(h0=e,e=t,t=h0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};$m=ai([Ae(0,un)],$m);function d0(e){return 0<=e&&e<256}var IM=5e7,f0=12,UM=50,KM=class extends ot{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 xe),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>IM)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],l=this._action(s,t);if(l){let h=p=>performance.now()-r>=f0?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(r,p);l.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-r>=f0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>UM&&(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()}},Vm=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 p=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(g,p)),this._dataByLinkId.set(g.id,g),g.id}let r=e,s=this._getEntryIdKey(r),l=this._entriesWithId.get(s);if(l)return this.addLineToLink(l.id,t.ybase+t.y),l.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(r),data:r,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 r=this._dataByLinkId.get(e);if(r&&r.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);r.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(r,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Vm=ai([Ae(0,un)],Vm);var p0=!1,WM=class extends ot{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Hl),this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onData=this._register(new xe),this.onData=this._onData.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new xe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new xe),this._instantiationService=new fM,this.optionsService=this._register(new CM(e)),this._instantiationService.setService(hn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Km)),this._instantiationService.setService(un,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Um)),this._instantiationService.setService(r1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Wm)),this._instantiationService.setService(Wa,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Fm)),this._instantiationService.setService(n1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Aa)),this._instantiationService.setService(cD,this.unicodeService),this._charsetService=this._instantiationService.createInstance(DM),this._instantiationService.setService(oD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Vm),this._instantiationService.setService(s1,this._oscLinkService),this._inputHandler=this._register(new HM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Xi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Xi.forward(this._bufferService.onResize,this._onResize)),this._register(Xi.forward(this.coreService.onData,this._onData)),this._register(Xi.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 KM((t,r)=>this._inputHandler.parse(t,r))),this._register(Xi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new xe),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&&!p0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),p0=!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,j1),t=Math.max(t,P1),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(s0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(s0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Vt(()=>{for(let t of e)t.dispose()})}}},FM={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 qM(e,t,r,s){let l={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?l.key=fe.ESC+"OA":l.key=fe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?l.key=fe.ESC+"OD":l.key=fe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?l.key=fe.ESC+"OC":l.key=fe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?l.key=fe.ESC+"OB":l.key=fe.ESC+"[B");break;case 8:l.key=e.ctrlKey?"\b":fe.DEL,e.altKey&&(l.key=fe.ESC+l.key);break;case 9:if(e.shiftKey){l.key=fe.ESC+"[Z";break}l.key=fe.HT,l.cancel=!0;break;case 13:l.key=e.altKey?fe.ESC+fe.CR:fe.CR,l.cancel=!0;break;case 27:l.key=fe.ESC,e.altKey&&(l.key=fe.ESC+fe.ESC),l.cancel=!0;break;case 37:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"D":t?l.key=fe.ESC+"OD":l.key=fe.ESC+"[D";break;case 39:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"C":t?l.key=fe.ESC+"OC":l.key=fe.ESC+"[C";break;case 38:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"A":t?l.key=fe.ESC+"OA":l.key=fe.ESC+"[A";break;case 40:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"B":t?l.key=fe.ESC+"OB":l.key=fe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(l.key=fe.ESC+"[2~");break;case 46:c?l.key=fe.ESC+"[3;"+(c+1)+"~":l.key=fe.ESC+"[3~";break;case 36:c?l.key=fe.ESC+"[1;"+(c+1)+"H":t?l.key=fe.ESC+"OH":l.key=fe.ESC+"[H";break;case 35:c?l.key=fe.ESC+"[1;"+(c+1)+"F":t?l.key=fe.ESC+"OF":l.key=fe.ESC+"[F";break;case 33:e.shiftKey?l.type=2:e.ctrlKey?l.key=fe.ESC+"[5;"+(c+1)+"~":l.key=fe.ESC+"[5~";break;case 34:e.shiftKey?l.type=3:e.ctrlKey?l.key=fe.ESC+"[6;"+(c+1)+"~":l.key=fe.ESC+"[6~";break;case 112:c?l.key=fe.ESC+"[1;"+(c+1)+"P":l.key=fe.ESC+"OP";break;case 113:c?l.key=fe.ESC+"[1;"+(c+1)+"Q":l.key=fe.ESC+"OQ";break;case 114:c?l.key=fe.ESC+"[1;"+(c+1)+"R":l.key=fe.ESC+"OR";break;case 115:c?l.key=fe.ESC+"[1;"+(c+1)+"S":l.key=fe.ESC+"OS";break;case 116:c?l.key=fe.ESC+"[15;"+(c+1)+"~":l.key=fe.ESC+"[15~";break;case 117:c?l.key=fe.ESC+"[17;"+(c+1)+"~":l.key=fe.ESC+"[17~";break;case 118:c?l.key=fe.ESC+"[18;"+(c+1)+"~":l.key=fe.ESC+"[18~";break;case 119:c?l.key=fe.ESC+"[19;"+(c+1)+"~":l.key=fe.ESC+"[19~";break;case 120:c?l.key=fe.ESC+"[20;"+(c+1)+"~":l.key=fe.ESC+"[20~";break;case 121:c?l.key=fe.ESC+"[21;"+(c+1)+"~":l.key=fe.ESC+"[21~";break;case 122:c?l.key=fe.ESC+"[23;"+(c+1)+"~":l.key=fe.ESC+"[23~";break;case 123:c?l.key=fe.ESC+"[24;"+(c+1)+"~":l.key=fe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?l.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?l.key=fe.NUL:e.keyCode>=51&&e.keyCode<=55?l.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?l.key=fe.DEL:e.keyCode===219?l.key=fe.ESC:e.keyCode===220?l.key=fe.FS:e.keyCode===221&&(l.key=fe.GS);else if((!r||s)&&e.altKey&&!e.metaKey){let h=FM[e.keyCode]?.[e.shiftKey?1:0];if(h)l.key=fe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(p);e.shiftKey&&(g=g.toUpperCase()),l.key=fe.ESC+g}else if(e.keyCode===32)l.key=fe.ESC+(e.ctrlKey?fe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),l.key=fe.ESC+p,l.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(l.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?l.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(l.key=fe.US),e.key==="@"&&(l.key=fe.NUL));break}return l}var ui=0,$M=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Rh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Rh,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((l,c)=>this._getKey(l)-this._getKey(c)),t=0,r=0,s=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<s.length;l++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(s[l]=e[t],t++):s[l]=this._array[r++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ui=this._search(t),ui===-1)||this._getKey(this._array[ui])!==t)return!1;do if(this._array[ui]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ui),!0;while(++ui<this._array.length&&this._getKey(this._array[ui])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),t=0,r=new Array(this._array.length-e.length),s=0;for(let l=0;l<this._array.length;l++)e[t]===l?t++:r[s++]=this._array[l];this._array=r,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&&(ui=this._search(e),!(ui<0||ui>=this._array.length)&&this._getKey(this._array[ui])===e))do yield this._array[ui];while(++ui<this._array.length&&this._getKey(this._array[ui])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ui=this._search(e),!(ui<0||ui>=this._array.length)&&this._getKey(this._array[ui])===e))do t(this._array[ui]);while(++ui<this._array.length&&this._getKey(this._array[ui])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let s=t+r>>1,l=this._getKey(this._array[s]);if(l>e)r=s-1;else if(l<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Dp=0,m0=0,VM=class extends ot{constructor(){super(),this._decorations=new $M(e=>e?.marker.line),this._onDecorationRegistered=this._register(new xe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new xe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new YM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let s=0,l=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,l=s+(c.options.width??1),e>=s&&e<l&&(!r||(c.options.layer??"bottom")===r)&&(yield c)}forEachDecorationAtCell(e,t,r,s){this._decorations.forEachByKey(t,l=>{Dp=l.options.x??0,m0=Dp+(l.options.width??1),e>=Dp&&e<m0&&(!r||(l.options.layer??"bottom")===r)&&s(l)})}},YM=class extends Ys{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new xe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new xe),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=Jt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Jt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},XM=1e3,GM=class{constructor(e,t=XM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let l=s-this._lastRefreshMs,c=this._debounceThresholdMS-l;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)}},g0=20,Mh=class extends ot{constructor(e,t,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let l=this._coreBrowserService.mainDocument;this._accessibilityContainer=l.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=l.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=l.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new GM(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(Xe(l,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<g0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===g0+1&&(this._liveRegion.textContent+=fm.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 r=this._terminal.buffer,s=r.lines.length.toString();for(let l=e;l<=t;l++){let c=r.lines.get(r.ydisp+l),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(r.ydisp+l+1).toString(),f=this._rowElements[l];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,h)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],l=r.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(l===c||e.relatedTarget!==s)return;let h,p;if(t===0?(h=r,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=r,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),p.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},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let l=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let S=g<y.length?y[g]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=l(t),h=l(r);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,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Mh=ai([Ae(1,Yg),Ae(2,ns),Ae(3,rs)],Mh);var Ym=class extends ot{constructor(e,t,r,s,l){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=s,this._linkProviderService=l,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new xe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new xe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Vt(()=>{Ia(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(Xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Xe(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 r=e.composedPath();for(let s=0;s<r.length;s++){let l=r[s];if(l.classList.contains("xterm"))break;if(l.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,l]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):l.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(s,h),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let s=0;s<t.size;s++){let l=t.get(s);if(l)for(let c=0;c<l.length;c++){let h=l[c],p=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 f=p;f<=g;f++){if(r.has(f)){l.splice(c--,1);break}r.add(f)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),l=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(l=!0);if(!l&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(r=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){r=!0,this._handleNewLink(h);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&ZM(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,Ia(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:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let s=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,l=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=l&&(this._clearCurrentLink(s,l),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,r){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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,s=this._bufferService.buffer.ydisp,l=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(l)}_linkLeave(e,t,r){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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,l=t.y*this._bufferService.cols+t.x;return r<=l&&l<=s}_positionFromMouseEvent(e,t,r){let s=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,s,l){return{x1:e,y1:t,x2:r,y2:s,cols:this._bufferService.cols,fg:l}}};Ym=ai([Ae(1,Xg),Ae(2,rs),Ae(3,un),Ae(4,l1)],Ym);function ZM(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 QM=class extends WM{constructor(e={}){super(e),this._linkifier=this._register(new Hl),this.browser=E1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Hl),this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new xe),this.onKey=this._onKey.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new xe),this.onBell=this._onBell.event,this._onFocus=this._register(new xe),this._onBlur=this._register(new xe),this._onA11yCharEmitter=this._register(new xe),this._onA11yTabEmitter=this._register(new xe),this._onWillOpen=this._register(new xe),this._setup(),this._decorationService=this._instantiationService.createInstance(VM),this._instantiationService.setService(Nc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(UR),this._instantiationService.setService(l1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mm)),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(Xi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Xi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Xi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Xi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Vt(()=>{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 r,s="";switch(t.index){case 256:r="foreground",s="10";break;case 257:r="background",s="11";break;case 258:r="cursor",s="12";break;default:r="ansi",s="4;"+t.index}switch(t.type){case 0:let l=Kt.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${fe.ESC}]${s};${jM(l)}${x1.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=wi.toColor(...t.color));else{let c=r;this._themeService.modifyColors(h=>h[c]=wi.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(Mh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.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(fe.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 r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,l=t.getWidth(r),c=this._renderService.dimensions.css.cell.width*l,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Xe(this.element,"copy",t=>{this.hasSelection()&&iD(t,this._selectionService)}));let e=t=>nD(t,this.textarea,this.coreService,this.optionsService);this._register(Xe(this.textarea,"paste",e)),this._register(Xe(this.element,"paste",e)),T1?this._register(Xe(this.element,"mousedown",t=>{t.button===2&&ES(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Xe(this.element,"contextmenu",t=>{ES(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),n_&&this._register(Xe(this.element,"auxclick",t=>{t.button===1&&Qw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Xe(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(Xe(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",dm.get()),M1||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(HR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ns,this._coreBrowserService),this._register(Xe(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(zm,this._document,this._helperContainer),this._instantiationService.setService(Yh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Im),this._instantiationService.setService(ql,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Th),this._instantiationService.setService(a1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Pm,this.rows,this.screenElement)),this._instantiationService.setService(rs,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Lm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(jm),this._instantiationService.setService(Xg,this._mouseService);let s=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(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hm,this.element,this.screenElement,s)),this._instantiationService.setService(hD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Xi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Am,this.screenElement)),this._register(Xe(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),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(Mh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Eh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Eh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Om,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let p,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,p=c.button<3?c.button:3;break;case"mousedown":g=1,p=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,p=4;break;default:return!1}return g===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:p,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(r(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(r(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&r(c)},mousemove:c=>{c.buttons||r(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?s.mousemove||(t.addEventListener("mousemove",l.mousemove),s.mousemove=l.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",l.wheel,{passive:!1}),s.wheel=l.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Xe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return r(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Xe(t,"wheel",c=>{if(!s.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=fe.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){Zw(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,r){this._selectionService.setSelection(e,t,r)}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 r=qM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let s=this.rows-1;return this.scrollLines(r.type===2?-s:s),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===fe.ETX||r.key===fe.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(JM(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(bi));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(fe.ESC+"[I"):this.coreService.triggerDataEvent(fe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[4;${r};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[6;${l};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function JM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var eN=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},tN=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 er)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},_0=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 tN(t)}getNullCell(){return new er}},iN=class extends ot{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new xe),this.onBufferChange=this._onBufferChange.event,this._normal=new _0(this._core.buffers.normal,"normal"),this._alternate=new _0(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)}},nN=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,s)=>t(r,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},rN=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}},sN=["cols","rows"],Dr=0,aN=class extends ot{constructor(e){super(),this._core=this._register(new QM(e)),this._addonManager=this._register(new eN),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],r=(s,l)=>{this._checkReadonlyOptions(s),this._core.options[s]=l};for(let s in this._core.options){let l={get:t.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this._publicOptions,s,l)}}_checkReadonlyOptions(e){if(sN.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 nN(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new rN(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 iN(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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}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 dm.get()},set promptLabel(e){dm.set(e)},get tooMuchOutput(){return fm.get()},set tooMuchOutput(e){fm.set(e)}}}_verifyIntegers(...e){for(Dr of e)if(Dr===1/0||isNaN(Dr)||Dr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Dr of e)if(Dr&&(Dr===1/0||isNaN(Dr)||Dr%1!==0||Dr<0))throw new Error("This API only accepts positive integers")}};class lN{pending=null;accept(t){let r="";for(const s of t)r+=this.acceptChar(s);return r}acceptChar(t){return t===""?this.acceptBackspace():W1.has(t)?this.acceptConsonant(t):F1.has(t)?this.acceptVowel(t):hN(t)&&this.canReplacePendingWith(t)?(this.pending=y0(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const l=this.flushPending();return this.pending={initial:t},l}if(!this.pending.final){if(q1.has(t))return this.pending.final=t,"";const l=this.flushPending();return this.pending={initial:t},l}const r=uN.get(`${this.pending.final}${t}`);if(r)return this.pending.final=r,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=cN.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const r=v0.get(this.pending.final);if(r){this.pending.final=r[0];const c=this.flushPending();return this.pending={initial:r[1],vowel:t},c}const s=this.pending.final,l=b0({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},l}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=v0.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 r=y0(t);return r.initial===this.pending.initial&&(!this.pending.vowel||r.vowel===this.pending.vowel)&&(!this.pending.final||r.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=b0(this.pending);return this.pending=null,t}}const Nh=44032,Ah=21,Nl=28,oN=19*Ah*Nl,I1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],U1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],K1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],W1=r_(I1),F1=r_(U1),q1=r_(K1),cN=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),$1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],uN=new Map($1),v0=new Map($1.map(([e,t])=>[t,[e[0],e[1]]]));function r_(e){return new Map(e.map((t,r)=>[t,r]))}function hN(e){const t=e.codePointAt(0);return t!==void 0&&t>=Nh&&t<Nh+oN}function y0(e){const t=e.codePointAt(0)-Nh,r=Math.floor(t/(Ah*Nl)),s=Math.floor(t%(Ah*Nl)/Nl),l=t%Nl,c={initial:I1[r],vowel:U1[s]};return l===0?c:{...c,final:K1[l]}}function b0(e){if(!e.vowel)return e.initial;const t=W1.get(e.initial),r=F1.get(e.vowel),s=e.final?q1.get(e.final):0;return t===void 0||r===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Nh+(t*Ah+r)*Nl+s)}const dN=[{key:"interrupt",label:"^C",ariaLabel:"Send Interrupt"},{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function fN({ctrlActive:e,onCtrl:t,onStandaloneKey:r,onPreserveFocus:s,onHide:l}){function c(h){h.preventDefault(),h.stopPropagation(),s()}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"}),dN.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>r(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:l,children:"×"})]})}const pN={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function mN(e){return pN[e]}function gN(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const V1="--nterminal-viewport-height",Y1="--nterminal-keyboard-inset-bottom",X1="data-nterminal-keyboard-visible",Zh="data-nterminal-compose-open",Lh="nterminal:viewport-refresh",_N=120;function vN(e=window){const t=e.document.documentElement,r=e.visualViewport,s=xN(e);function l(){s_(e)}return l(),r?.addEventListener("resize",l),r?.addEventListener("scroll",l),s?.addEventListener("geometrychange",l),e.addEventListener("resize",l),e.addEventListener(Lh,l),e.addEventListener("orientationchange",l),e.addEventListener("pageshow",l),e.document.addEventListener("visibilitychange",l),()=>{r?.removeEventListener("resize",l),r?.removeEventListener("scroll",l),s?.removeEventListener("geometrychange",l),e.removeEventListener("resize",l),e.removeEventListener(Lh,l),e.removeEventListener("orientationchange",l),e.removeEventListener("pageshow",l),e.document.removeEventListener("visibilitychange",l),t.style.removeProperty(V1),t.style.removeProperty(Y1),t.removeAttribute(X1)}}function s_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:r,keyboardVisible:s}=Xm(e),l=yN(e,s);return l!==null&&S0(t,V1,`${l}px`),S0(t,Y1,`${r}px`),bN(t,X1,String(s)),{viewportHeight:l,keyboardInsetBottom:r,keyboardVisible:s}}function Xm(e=window){const t=SN(e);return{keyboardInsetBottom:t,keyboardVisible:t>_N}}function yN(e,t){if((e.document.documentElement.hasAttribute(Zh)||t)&&za(e.innerHeight))return e.innerHeight;const r=e.visualViewport?.height;return za(r)?r:za(e.innerHeight)?e.innerHeight:null}function za(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function S0(e,t,r){e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}function bN(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function SN(e){return Math.max(wN(e),CN(e))}function wN(e){const t=e.visualViewport?.height;if(!za(t)||!za(e.innerHeight))return 0;const r=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-r))}function CN(e){if(!za(e.innerHeight))return 0;const r=G1(e)?.boundingRect?.height;return!za(r)||r>=e.innerHeight*.8?0:Math.round(r)}function G1(e){return e.navigator.virtualKeyboard}function xN(e){const t=G1(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Bc=new Map,bc=new Map,kN=Object.freeze({open:!1,text:""});function EN(e){let t=bc.get(e);return t||(t=new Set,bc.set(e,t)),t}function Z1(e){const t=bc.get(e);if(t)for(const r of Array.from(t))r()}function a_(e){return Bc.get(e)??kN}function TN(e,t){const r=EN(e);return r.add(t),()=>{r.delete(t)}}function DN(e,t){const r=a_(e);r.open!==t&&(Bc.set(e,{...r,open:t}),Z1(e))}function RN(e,t){const r=a_(e);r.text!==t&&(Bc.set(e,{...r,text:t}),Z1(e))}function Qu(e){Bc.delete(e),bc.delete(e)}function w0(){Bc.clear(),bc.clear()}const Q1=120,MN="\x1B[200~",NN="\x1B[201~";function C0(e,t){const r=t.stripTrailingLineBreaks===!1?e:l_(e),s=LN(r);return s?t.bracketedPasteMode?`${MN}${s}${NN}`:s:""}function AN(e){return e==="queue"?" ":"\r"}function l_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function LN(e){return e.replace(/\r\n/g,`
|
|
31
|
-
`).replace(/\r/g,`
|
|
32
|
-
`).replace(/\n/g,"\r")}const BN=420,ON=3e3,x0=650,zN=80,jN=3,hh=new Set;let Ol=null;function PN({terminalId:e,onSubmit:t,queueAvailable:r=!1,disabled:s=!1}){const l=v.useMemo(()=>B=>TN(e,B),[e]),c=v.useMemo(()=>()=>a_(e),[e]),h=v.useSyncExternalStore(l,c,c),{open:p,text:g}=h,f=v.useRef(null),b=v.useRef(null),y=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!p||!dh()))return IN(e),()=>UN(e)},[p,e]),v.useLayoutEffect(()=>{const B=f.current?.closest(".terminal-pane");if(!B)return;function Y(){B?.removeAttribute("data-compose-open"),B?.style.removeProperty("--compose-drawer-panel-height")}if(!p){Y();return}const P=b.current;B.setAttribute("data-compose-open","true");function q(){const ve=P?.getBoundingClientRect().height??0;ve>0&&B?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}q();const re=[window.setTimeout(q,0),window.setTimeout(q,180),window.setTimeout(q,260)],ie=window.requestAnimationFrame?.(q)??null,he=typeof ResizeObserver=="function"&&P?new ResizeObserver(q):null;return he&&P&&he.observe(P),()=>{for(const ve of re)window.clearTimeout(ve);ie!==null&&window.cancelAnimationFrame?.(ie),he?.disconnect(),Y()}},[p]),v.useEffect(()=>{if(!p){S.current?.(),S.current=null;return}k0(y.current),A()},[p]);function w(B){DN(e,B)}function k(B){RN(e,B)}function E(){HN(f.current),w(!1),E0()}function L(B="send"){if(!(s||!g)){if(t(g,B),k(""),dh()){y.current?.blur(),E0();return}window.setTimeout(()=>y.current?.focus(),Q1+20)}}function A(){dh()&&(S.current?.(),S.current=KN())}return m.jsxs("div",{ref:f,className:"compose-drawer","data-open":p?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":p?"true":void 0,tabIndex:p?-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:b,className:"compose-drawer-panel","aria-hidden":p?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:p?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:r?"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:y,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:p?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:B=>k(B.target.value),onFocus:A,onKeyDown:B=>{if(B.key==="Enter"&&(B.metaKey||B.ctrlKey)){if(B.preventDefault(),B.shiftKey){r&&L("queue");return}L("send");return}B.key==="Escape"&&(B.preventDefault(),E())},placeholder:r?"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:p?0:-1,onClick:()=>{k(""),k0(y.current),A()},disabled:!g,children:"Clear"}),r?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:p?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>L("queue"),disabled:s||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:p?0:-1,onClick:()=>L("send"),disabled:s||!g,children:"Send"})]})]})]})}function HN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function k0(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function dh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function E0(){if(!dh())return;const e=Al;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function IN(e){Ol!==null&&(window.clearTimeout(Ol),Ol=null),hh.add(e),document.documentElement.setAttribute(Zh,"true"),Al()}function UN(e){if(hh.delete(e),hh.size>0||Ol!==null){Al();return}Ol=window.setTimeout(()=>{if(Ol=null,hh.size>0){Al();return}document.documentElement.removeAttribute(Zh),Al()},BN),Al()}function KN(){let e=!1,t=null,r=null,s=null,l=0;const c=Date.now(),h=window.visualViewport,p=WN();function g(){t!==null&&(window.clearTimeout(t),t=null),r!==null&&(window.cancelAnimationFrame?.(r),r=null)}function f(){e||(e=!0,g(),h?.removeEventListener("resize",y),h?.removeEventListener("scroll",y),p?.removeEventListener("geometrychange",y))}function b(S){if(!e){if(S<x0&&typeof window.requestAnimationFrame=="function"){r=window.requestAnimationFrame(y);return}t=window.setTimeout(y,zN)}}function y(){if(e)return;g();const S=s_(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?l+=1:(l=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=ON||w>=x0&&l>=jN){f();return}b(w)}return h?.addEventListener("resize",y),h?.addEventListener("scroll",y),p?.addEventListener("geometrychange",y),y(),f}function Al(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,s_()}function WN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function FN(e,t={}){const r=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(h=>{if(VN(h))return h.preventDefault(),h.stopPropagation(),qN(e),!1;if($N(h)&&r.onInterrupt&&r.shouldInterruptPlainCtrlC?.())return h.preventDefault(),h.stopPropagation(),r.onInterrupt(),!1;if(YN(h)){const p=Gm(e);return p?(h.preventDefault(),h.stopPropagation(),Zm(p),!1):!0}return XN(h)?(h.preventDefault(),h.stopPropagation(),GN(e,r.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const l=h=>{const p=Gm(e);if(p){if(h.clipboardData){h.clipboardData.setData("text/plain",p),h.preventDefault();return}h.preventDefault(),Zm(p)}},c=h=>{const p=h.clipboardData?.getData("text/plain");if(!p)return;const g=l_(p);h.preventDefault(),h.stopImmediatePropagation(),J1(e,g,r.onPasteText)};return s.addEventListener("copy",l,!0),s.addEventListener("paste",c,!0),{dispose(){s.removeEventListener("copy",l,!0),s.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function qN(e){const t=Gm(e);t&&await Zm(t)}function $N(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function VN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function YN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function XN(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 GN(e,t){if(navigator.clipboard?.readText)try{const r=await navigator.clipboard.readText();if(!r)return;J1(e,l_(r),t)}catch{}}function J1(e,t,r){if(t){if(r){r(t);return}e.paste(t)}}function Gm(e){return e.hasSelection()?e.getSelection():ZN(e.element??null)}function ZN(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const r=t.toString();if(!r)return"";for(let s=0;s<t.rangeCount;s+=1){const l=t.getRangeAt(s);if(e.contains(l.commonAncestorContainer))return r}return""}async function Zm(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}QN(e)}function QN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",r.style.opacity="0",document.body.appendChild(r),r.focus({preventScroll:!0}),r.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{r.remove(),t?.focus({preventScroll:!0})}}const JN=[4,10,11,12];function eA(e,t){const r=[e.parser.registerCsiHandler({final:"c"},s=>T0(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>T0(s)),e.parser.registerCsiHandler({final:"n"},s=>tA(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>iA(s)),e.parser.registerCsiHandler({final:"t"},s=>nA(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...JN.map(s=>e.parser.registerOscHandler(s,l=>rA(l)))];return{dispose(){for(const s of r)s.dispose()}}}function T0(e){return Qh(e)===0}function tA(e){const t=Qh(e);return t===5||t===6}function iA(e){return Qh(e)===6}function nA(e){const t=Qh(e);return t===14||t===16||t===18}function rA(e){return e.split(";").some(t=>t==="?")}function Qh(e){const t=e[0];return typeof t=="number"?t:0}const Ka=new Map,sA=2*1024*1024,aA=1500,lA=25e3;function oA(e,t){let r=Ka.get(e);r||(r=hA(e),Ka.set(e,r),Jh(r)),r.listeners.add(t);const s=c=>_A(r,c),l=()=>{r.listeners.delete(t)};return{status:r.status,snapshot:r.snapshot,output:r.output.slice(),history:r.history,send:s,detach:l}}function tc(e){const t=Ka.get(e);t&&(vA(t),Ka.delete(e))}function cA(e,t={}){const r=Ka.get(e);if(!r)return!1;r.exited=!1,r.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(r.preserveCachedOutputOnNextSnapshot=!0),r.reconnectTimer!==null&&(window.clearTimeout(r.reconnectTimer),r.reconnectTimer=null),Oc(r);const s=r.socket;return r.socket=null,Ma(r,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),Jh(r),!0}function uA(){for(const e of Ka.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Oc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ma(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Jh(e)}}function Rp(){for(const e of Array.from(Ka.keys()))tc(e)}function hA(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 Jh(e){if(!e.reconnectEnabled)return;Ma(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){Ma(e,"connected");for(const r of e.pendingOut)t.send(JSON.stringify(r));e.pendingOut.length=0,e.isAlive=!0,dA(e)}}),t.addEventListener("message",r=>{if(e.socket!==t)return;const s=typeof r.data=="string"?r.data:"";if(!s)return;let l=null;try{l=JSON.parse(s)}catch{return}if(!l||typeof l.type!="string")return;if(l.type==="pong"){e.isAlive=!0;return}const c=pA(e,l);eC(e,{type:"message",message:c})}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,Oc(e),r.code===1008){e.reconnectEnabled=!1,Ma(e,fA(r.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){Ma(e,"closed");return}Ma(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Jh(e)},aA)}}),t.addEventListener("error",()=>{})}function dA(e){Oc(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)}))}},lA)}function Oc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function fA(e){return e.trim().toLowerCase()==="unauthorized"}function pA(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,mA(e,t.output),Mp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((r,s)=>r+s.length,0),Mp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,Mp(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 mA(e,t){const r=gA(e.output,t);if(r===0)return;const s=t.slice(r);for(const l of s)e.output.push(l),e.outputBytes+=l.length}function gA(e,t){const r=Math.min(e.length,t.length);for(let s=r;s>0;s-=1){let l=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){l=!1;break}if(l)return s}return 0}function Mp(e){for(;e.outputBytes>sA&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Ma(e,t){e.status!==t&&(e.status=t,eC(e,{type:"status",status:t}))}function eC(e,t){for(const r of Array.from(e.listeners))r(t)}function _A(e,t){const r=e.socket;return r&&r.readyState===WebSocket.OPEN?(r.send(JSON.stringify(t)),!0):((t.type==="input"||t.type==="cancel_scrollback")&&e.pendingOut.push(t),!1)}function vA(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Oc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const yA=[0,50,150,350],bA=2,SA=[300,1200,2500],wA=1e3,CA=1e5,xA="",Qm="\x1B[?1049l\x1B[?1047l\x1B[?47l",kA=new Set(["47","1047","1049"]),EA=400,TA=3,DA=3,RA=32,MA=1.42,NA=2,AA=24,LA=240,BA=60,OA=420,zA=6,jA=2,D0=[500,1500,3e3,5e3,8e3],R0=15e3,PA=40,Ju=240,HA=Mi.lazy(()=>Vg(()=>import("./TranscriptMarkdownBody-BCX4YRz8.js"),__vite__mapDeps([2,1])));function M0({terminal:e,serverApi:t,active:r,visible:s=!0,canClose:l,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:b,onAuthClose:y}){const S=v.useSyncExternalStore(Ow,im,()=>Ba),w=v.useSyncExternalStore(zw,nm,()=>jl),k=v.useSyncExternalStore(jw,sm,()=>!0),E=v.useSyncExternalStore(rh,am,()=>!0),L=v.useSyncExternalStore(rh,lm,()=>!0),A=v.useSyncExternalStore(Sg,Xs,()=>zl),B=v.useSyncExternalStore(wh,()=>Ch("history.toggle"),()=>"Alt+H"),Y=v.useSyncExternalStore(wh,()=>Ch("scrollback.toggle"),()=>"Alt+S"),P=v.useRef(null),q=v.useRef(null),re=v.useRef(null),ie=v.useRef(null),he=v.useRef({onExit:f,onSnapshot:b}),ve=v.useRef(t.createWebSocketUrl),U=v.useRef(y),K=v.useRef(null),W=v.useRef(null),H=v.useRef(null),j=v.useRef(!1),le=v.useRef(new Map),R=v.useRef([]),X=v.useRef(null),Z=v.useRef(0),Ce=v.useRef(!1),Te=v.useRef(!1),M=v.useRef(!1),Q=v.useRef({terminalId:e.id,enabled:!1}),de=v.useRef([]),me=v.useRef([]),ge=v.useRef(0),Se=v.useRef(!1),Ee=v.useRef(null),De=v.useRef(0),Ue=v.useRef(null),se=v.useRef(null),pe=v.useRef(!1),Le=v.useRef(!1),ye=v.useRef(!1),Me=v.useRef(!1),Pe=v.useRef(null),ze=v.useRef(null),te=v.useRef(!1),ke=v.useRef(!1),Re=v.useRef(!1),Be=v.useRef(!1),je=v.useRef(!1),at=v.useRef(!1),Wt=v.useRef(!1),$e=v.useRef(r),kt=v.useRef(s),ei=v.useRef(c),Et=v.useRef(S),_e=v.useRef(w),We=v.useRef(!1),Je=v.useRef(null),ct=v.useRef(null),Pt=v.useRef(!1),Tt=v.useRef(!1),Lt=v.useRef(null),[,Dt]=v.useState("connecting"),[F,Ie]=v.useState(!1),[it,hi]=v.useState(null),[Gi,Ci]=v.useState(!1),[St,wt]=v.useState(null),[Yt,Ft]=v.useState(!1),[Ai,ti]=v.useState(!1),[di,Xt]=v.useState(!1),[qt,Wi]=v.useState(!1),[gt,Gt]=v.useState(null),[ln,Zi]=v.useState(!1),[Qi,dn]=v.useState(()=>dp(e.id)),Li=!!gt||ic(e.currentCommand),ii=gt?.provider==="claude"||nC(e.currentCommand),xi=!!gt||ic(e.currentCommand),Sn=e.capabilities?.tmuxScrollback===!0,Ji=Sn&&(Qi??(xi?L:E)),[Xl,as]=v.useState(!1);v.useLayoutEffect(()=>{$e.current=r},[r]),v.useLayoutEffect(()=>{kt.current=s},[s]),v.useLayoutEffect(()=>{ei.current=c},[c]),v.useLayoutEffect(()=>{Et.current=S},[S]),v.useLayoutEffect(()=>{_e.current=w},[w]),v.useLayoutEffect(()=>{We.current=ln},[ln]),v.useLayoutEffect(()=>{Je.current=gt},[gt]),v.useLayoutEffect(()=>{Pt.current=Li},[Li]),v.useLayoutEffect(()=>{Tt.current=ii},[ii]),v.useLayoutEffect(()=>{const D=Q.current;Te.current=Ji,M.current=Sn,Q.current={terminalId:e.id,enabled:Ji},z0(P.current,Ji),D.terminalId===e.id&&D.enabled&&!Ji&&x(),Ji||Xt(!1)},[e.id,Ji,Sn]),v.useEffect(()=>{dn(dp(e.id)),Z.current=0,Ce.current=!1,Xt(!1),ki()},[e.id]),v.useEffect(()=>rh(()=>{dn(dp(e.id))}),[e.id]),v.useEffect(()=>{s&&r&&e.status==="running"&&(Ht(),_t("auto"))},[r,s,e.status]),v.useEffect(()=>{he.current={onExit:f,onSnapshot:b}},[f,b]),v.useEffect(()=>{ve.current=t.createWebSocketUrl,U.current=y},[t,y]),v.useEffect(()=>{let D=!1,J=null,Ke=0;const Ye=a3(e.currentCommand),Ge=ic(e.currentCommand);function dt(){J!==null&&(window.clearTimeout(J),J=null)}function pi(Zt){if(D)return;let mi;if(Zt){if(!Ge)return;mi=R0}else if(Ke<D0.length){if(!Ye)return;mi=D0[Ke++]}else{if(!Ge)return;mi=R0}J=window.setTimeout(()=>{J=null,rn()},mi)}async function rn(){try{const Zt=await t.getTerminalTranscriptSource(e.id);if(D)return;Gt(mi=>mi&&Zt.source&&mi.provider===Zt.source.provider&&mi.sessionId===Zt.source.sessionId?mi:Zt.source),pi(!!Zt.source)}catch(Zt){if(D)return;Np(Zt)&&Gt(null),pi(!1)}}return Gt(null),e.status!=="running"?()=>{D=!0,dt()}:(rn(),()=>{D=!0,dt()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const D=gt?`${e.id}:${gt.provider}:${gt.sessionId}`:null,J=ct.current;J!==null&&D!==null&&J!==D&&We.current&&Zi(!1),ct.current=D},[e.id,gt?.provider,gt?.sessionId]),v.useEffect(()=>{function D(J){if(!$e.current||!kt.current||J.isComposing||J.key==="Process"||KA(J.target))return;const Ke=Uw(J);if(Ke?.id==="history.toggle"&&Je.current){J.preventDefault(),J.stopPropagation(),Zi(Ye=>!Ye);return}if(Ke?.id==="scrollback.toggle"&&M.current){J.preventDefault(),J.stopPropagation(),ne();return}}return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[]),v.useEffect(()=>{const D=q.current;D&&(D.options.disableStdin=e.status==="exited"),e.status==="exited"&&Dt("closed")},[e.status]),v.useEffect(()=>{const D=q.current;D&&(D.options.fontSize=S,hp(S,_e.current).then(()=>{Et.current===S&&Ht()}))},[S]),v.useEffect(()=>{const D=q.current;D&&(D.options.fontFamily=tm(w),hp(Et.current,w).then(()=>{_e.current===w&&Ht()}))},[w]),v.useEffect(()=>{const D=q.current;D&&(D.options.theme=N0(A))},[A]),v.useEffect(()=>{const D=P.current;if(!D)return;let J=!1,Ke=null,Ye=null,Ge=null,dt=null,pi=null,rn=null,Zt=null;K.current=null,je.current=!1,at.current=!1,Me.current=!1,na(),ls();const mi=Et.current,oa=_e.current,Cn=new aN({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:tm(oa),fontSize:mi,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:CA,theme:{...N0(Xs())}}),jc=new ZT;return Cn.loadAddon(jc),dt=eA(Cn),q.current=Cn,re.current=jc,hp(mi,oa).then(()=>{if(J)return;Cn.open(D),z0(D,Te.current),je.current=!0,Ke=FN(Cn,{onPasteText:qe,onInterrupt:we,shouldInterruptPlainCtrlC:()=>Tt.current}),kt.current&&$e.current&&e.status==="running"&&_t("auto"),Ht(),pi=m3(D,Cn,()=>Et.current*1.2,rr,In=>{Bt(In)},tn,Or,()=>Te.current,fs),rn=d3(D,Cn,rr,In=>{Bt(In)},tn,Or,()=>Te.current,fs);const rd=new lN;Ye=Cn.onData(In=>{if(Wt.current){const Hc=gN(In);if(Hc){ms(!1),ae(Hc);return}}const Pc=rd.accept(In);Pc&&ae(Pc)}),Ge=Cn.onScroll(In=>{if(ke.current||Be.current||Re.current){li();return}ra(),hr(Cn)&&jn({scrollToBottom:!0}),rr(),!Te.current&&In<=3&&Bt()}),Zt=new ResizeObserver(()=>{ta()}),Zt.observe(D),at.current&&(gr(),at.current=!1,Ht()),_r()}),()=>{T(ie.current,{updateUi:!1}),J=!0,je.current=!1,at.current=!1,na(),W.current=null,H.current=null,j.current=!1,Bi(),sr(),Re.current=!1,pi?.(),rn?.(),Zt?.disconnect(),Ke?.dispose(),Ye?.dispose(),Ge?.dispose(),dt?.dispose(),Cn.dispose(),q.current=null,re.current=null}},[e.id]),v.useEffect(()=>{const D=ve.current(e.id),J=oA(D,Lr);return ie.current=J.send,Dt(J.status),J.status==="connected"&&Ht(),J.snapshot&&(he.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),q.current&&(Ht(),On(J.output,J.history),Ht())),()=>{T(J.send,{updateUi:!1}),J.detach(),ie.current=null}},[e.id,e.status]);function Lr(D){if(D.type==="status"){Dt(D.status),D.status==="unauthorized"&&U.current?.({source:"terminal-ws-1008",terminalId:e.id}),D.status==="connected"&&Ht();return}ir(D.message)}function ls(D=[],J=null){de.current=[],me.current=eh(D),ge.current=0,Se.current=!1,Ee.current=null,Re.current=!1,De.current+=1,Ue.current=J,se.current=null,pe.current=!1,Le.current=!1,ye.current=!1,at.current=!1,Lt.current=null,Pe.current=null,te.current=!1,Ie(!1),hi(null),Ci(!1),wt(null),Ft(!1),ti(!1)}function On(D=[],J=null){ls(D,J),mr()}function mr(){if(!q.current||!je.current){at.current=!0;return}at.current=!1,gr()}async function gr(){const D=q.current;if(!D)return;const J=th(D,te.current),Ke=J?me.current.length:ge.current;await zn(D,{liveOutputLimit:Ke,scrollToBottom:J}),q.current===D&&li()}function zn(D,J={}){return new Promise(Ke=>{Re.current=!0,Se.current=!1;const Ye=De.current+1;De.current=Ye;const Ge=Math.max(0,Math.min(J.liveOutputLimit??me.current.length,me.current.length)),dt=J.historyPages??de.current,pi=()=>{if(q.current!==D||De.current!==Ye){Ke(!1);return}try{ge.current=Ge,J.scrollToBottom&&br(D)}finally{Re.current=!1;const Zt=Va();Zt?jn(Zt):J.applyDeferredSnapshot!==!1&&Hn(),Ke(!0)}},rn=()=>{if(q.current!==D||De.current!==Ye){Ke(!1);return}D.clear();const Zt=eh([...dt,...me.current.slice(0,Ge)]);if(Zt.length===0){pi();return}for(let mi=0;mi<Zt.length;mi+=1){const oa=Zt[mi];mi===Zt.length-1?D.write(oa,pi):D.write(oa)}};if(D.buffer.active.type==="alternate"){D.write(Qm,rn);return}rn()})}async function Bt(D=0){const J=q.current;if(ye.current||!J)return;if(hs(J)){li();return}const Ke=Ue.current;ye.current=!0,Ie(!0);const Ye=J.buffer.active.viewportY;try{let Ge=!!(Ke&&!Ke.hasMore);if(!Ge)try{const dt=await t.getTerminalHistory(e.id,{beforeLine:Ke?.startLine??0,limit:wA}),pi={startLine:dt.startLine,endLine:dt.endLine,hasMore:dt.hasMore};if(dt.output.length>0){await ea(J,dt.output,Ye,D)&&(Ue.current=pi);return}Ue.current=pi,Ge=!dt.hasMore}catch(dt){Ge=Np(dt)}if(Ge){if(hs(J)){li();return}await $a(J,Ye,D)}}catch{}finally{ye.current=!1,Ie(!1)}}async function $a(D,J,Ke){if(!(pe.current||Le.current))try{const Ye=se.current,Ge=await t.getTerminalTranscriptHistory(e.id,{...Ye?{cursor:Ye}:{},limit:EA}),dt=Ge.output.map(rC);if(!Ge.source)return;if(dt.length===0){Gt(Ge.source),se.current=Ge.cursor,Le.current=!Ge.hasMore||!Ge.cursor;return}await ea(D,dt,J,Ke)&&(Gt(Ge.source),se.current=Ge.cursor,Le.current=!Ge.hasMore||!Ge.cursor)}catch(Ye){Np(Ye)&&(pe.current=!0)}}async function ea(D,J,Ke,Ye){if(hs(D))return li(),!1;const Ge=[...J,...de.current],dt=u3(J);return!await zn(D,{liveOutputLimit:ge.current,scrollToBottom:!1,historyPages:Ge,applyDeferredSnapshot:!1})||q.current!==D?!1:(de.current=Ge,Sr(D,Math.max(0,Ke+dt+Math.min(0,Ye))),te.current=!hr(D),rr(),!0)}v.useEffect(()=>{const D=window.visualViewport;function J(){document.visibilityState==="visible"&&Ht()}function Ke(){Ht()}function Ye(){ta()}function Ge(){Zl()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",Ke),window.addEventListener("resize",Ye),window.addEventListener(Lh,Ge),D?.addEventListener("resize",Ye),D?.addEventListener("scroll",Ye),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",Ke),window.removeEventListener("resize",Ye),window.removeEventListener(Lh,Ge),D?.removeEventListener("resize",Ye),D?.removeEventListener("scroll",Ye)}},[e.id]);function tr(){const D=ve.current(e.id);Me.current=!0,Lt.current=null,Dt("reconnecting"),Ht(),cA(D,{preserveCachedOutputOnNextSnapshot:!0})}function ir(D){if(D.type==="snapshot"&&D.terminal.id===e.id){he.current.onSnapshot(D.terminal,{notifyCompletion:!1});const Ke=q.current;if(!Ke)return;Ht();const Ye=Me.current;if(Me.current=!1,Ye){Ue.current=D.history??Ue.current,li(),Ht();return}if(yr(Ke,D.terminal)){Pn(D.output,D.history??null),li(),Ht();return}On(D.output,D.history??null),Ht();return}if(D.type==="terminal_updated"&&D.terminal.id===e.id){he.current.onSnapshot(D.terminal,{notifyCompletion:!0});return}if(D.type==="output"&&D.terminalId===e.id){const Ke=lC(D.data);if(!Ke)return;me.current.push(Ke),q.current&&je.current?jn({scrollToBottom:!0}):at.current=!0;return}const J=q.current;if(J){if(D.type==="exit"&&D.terminalId===e.id){he.current.onExit(D.exitCode),Dt("closed");return}D.type==="error"&&J.writeln(`\r
|
|
33
|
-
[nterminal] ${D.message}`)}}function Gl(D=25){if(document.visibilityState==="hidden"||!kt.current||le.current.has(D))return;const J=window.setTimeout(()=>{le.current.delete(D),!ia()&&wn()},D);le.current.set(D,J)}function ta(){ia()||_r()}function ia(){const D=Fi();return D&&os(D)?(j.current=!0,H.current=D,!0):D&&cs(D)?(j.current=!1,H.current=null,!0):((!D||!D.composeOpen&&!D.keyboardVisible)&&(j.current=!1,H.current=null),!1)}function Zl(){if(!j.current)return;const D=Fi();D&&(D.composeOpen||D.keyboardVisible)||(j.current=!1,H.current=null)}function os(D){if(!D.mobileLike||!D.composeOpen&&!D.keyboardVisible)return!1;const J=W.current;return J?Qe(D.windowWidth,J.windowWidth)&&Qe(D.visualViewportWidth,J.visualViewportWidth)&&Qe(D.containerWidth,J.containerWidth):!1}function cs(D){if(!D.mobileLike||D.composeOpen||D.keyboardVisible)return!1;const J=H.current;return!J||!J.composeOpen&&!J.keyboardVisible?!1:Qe(D.windowWidth,J.windowWidth)&&Qe(D.visualViewportWidth,J.visualViewportWidth)&&Qe(D.containerWidth,J.containerWidth)}function Fi(){const D=P.current;if(!D||D.isConnected===!1)return null;const J=D.getBoundingClientRect(),Ke=Br(window.innerWidth)??0,Ye=Br(window.visualViewport?.width)??Ke,Ge=Br(J.width)??Br(D.clientWidth)??Ke;if(Ke<=0||Ye<=0||Ge<=0)return null;const{keyboardVisible:dt}=Xm(),pi=document.documentElement.hasAttribute(Zh),rn=en()||dt;return{windowWidth:Ke,visualViewportWidth:Ye,containerWidth:Ge,composeOpen:pi,keyboardVisible:dt,mobileLike:rn}}function en(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function nr(){return Xm().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Br(D){return typeof D=="number"&&Number.isFinite(D)&&D>0?D:null}function Qe(D,J){return Math.abs(D-J)<=bA}function _r(){for(const D of yA)Gl(D)}function Ht(){K.current=null,_r()}function na(){for(const D of le.current.values())window.clearTimeout(D);le.current.clear()}function Bi(){for(const D of R.current)window.clearTimeout(D);R.current=[]}function rr(){if(li(),!Pe.current){Ci(!1);return}Ci(!0),sr(),ze.current=window.setTimeout(()=>{ze.current=null,Ci(!1)},1200)}function li(){const D=q.current,J=D?h3(D):null;if(Pe.current=J,hi(J),ti(!!(D&&J)),Ft(!!(D&&J&&!hr(D))),J||!D||!us()){wt(null);return}wt({alternate:D.buffer.active.type==="alternate"})}function us(){const D=Ue.current;return de.current.length>0||!!D?.hasMore}function sr(){ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null)}function ra(){const D=q.current;D&&(te.current=!hr(D),li())}function sa(D){Ee.current=Ap(Ee.current,D)}function vr(D){const J=Ee.current;return Ee.current=null,Ap(J,D)}function Va(){const D=Ee.current;return Ee.current=null,D}function jn(D={}){const J=q.current;if(!J||!je.current){at.current=!0;return}if(Re.current){sa(D);return}if(Se.current){sa(D);return}const Ke=vr(D);if(!Ke.force&&!th(J,te.current)){li();return}Se.current=!0;const Ye=De.current,Ge=()=>{if(q.current!==J||De.current!==Ye){Se.current=!1;return}if(!Ke.force&&!th(J,te.current)){Se.current=!1,li();return}const dt=ge.current,pi=me.current[dt];if(pi===void 0){Se.current=!1,Ke.scrollToBottom&&br(J),li();const rn=Va();rn?jn(Ap(Ke,rn)):Hn();return}J.write(pi,()=>{if(q.current!==J||De.current!==Ye){Se.current=!1;return}ge.current=dt+1,Ge()})};Ge()}function hs(D){return!hr(D)&&(aa()||Se.current||Re.current)}function yr(D,J){return(Pt.current||ic(J?.currentCommand))&&!hr(D)}function aa(){return ge.current<me.current.length}function Pn(D,J){Lt.current={output:D,history:J,appendFromLiveOutputIndex:ge.current}}function Hn(){const D=q.current,J=Lt.current;if(!D||!J||!hr(D)||aa()||Se.current||Re.current)return;const Ke=eh(J.output),Ye=eh(me.current.slice(J.appendFromLiveOutputIndex));Lt.current=null,On(c3(Ke,Ye),J.history),Ht()}function tn(){Be.current=!0}function Or(){ra(),Be.current=!1;const D=q.current;D&&hr(D)&&jn({scrollToBottom:!0})}function br(D){ar(()=>j0(D))&&(te.current=!1)}function Sr(D,J){ar(()=>(D.scrollToLine(J),!0))}function ar(D){ke.current=!0;try{return D()}finally{ke.current=!1}}function Ya(){const D=q.current;if(!D)return;const J=()=>{Te.current&&(z(ie.current),Xt(!1)),j0(D),te.current=!1,li(),jn({force:!0,scrollToBottom:!0}),_t("scroll-action")};if(D.buffer.active.type==="alternate"){D.write(Qm,J);return}J()}function ds(D){const J=q.current,Ke=P.current;if(!J||!Ke)return;const Ye=Ke.getBoundingClientRect();if(Ye.height<=0)return;const Ge=Math.max(0,Math.min(1,(D-Ye.top)/Ye.height)),dt=Math.round(J.buffer.active.baseY*Ge);tn();try{J.scrollToLine(dt)}finally{Or()}te.current=!hr(J),li(),rr(),dt<=3&&Bt()}function Xa(D){D.preventDefault(),D.stopPropagation(),D.currentTarget.setPointerCapture?.(D.pointerId),ds(D.clientY)}function lr(D){(D.buttons&1)!==0&&(D.preventDefault(),D.stopPropagation(),ds(D.clientY))}function wn(){const D=q.current,J=re.current;if(!(!D||!J)&&!(document.visibilityState==="hidden"||!kt.current||P.current?.isConnected===!1))try{const Ke=th(D,te.current),Ye=Fi();J.fit(),Ye&&(W.current=Ye),Ke&&br(D),D.refresh(0,Math.max(0,D.rows-1)),li();const Ge={cols:D.cols,rows:D.rows},dt=K.current;if(dt&&dt.cols===Ge.cols&&dt.rows===Ge.rows)return;wr({type:"resize",terminalId:e.id,cols:Ge.cols,rows:Ge.rows})&&(K.current=Ge)}catch{}}function wr(D){const J=ie.current;return J?J(D):!1}function ki(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function nn(){ki();const D=Math.max(-Ju,Math.min(Ju,Z.current));if(Z.current=0,D===0)return!1;const J=wr({type:"scrollback_scroll",terminalId:e.id,lines:D});return J&&(Ce.current=!0,D<0&&Xt(!0)),J}function fs(D){if(!Te.current||D===0)return;const J=Z.current+D;Z.current=Math.max(-Ju,Math.min(Ju,J)),X.current===null&&(X.current=window.setTimeout(()=>{X.current=null,nn()},PA))}function x(){z(ie.current)}function T(D=ie.current,J={}){const Ke=Ce.current;ki(),Z.current=0,Ce.current=!1,J.updateUi!==!1&&Xt(!1),Ke&&D?.({type:"cancel_scrollback",terminalId:e.id})}function z(D){ki(),Z.current=0,Ce.current=!1,Xt(!1),D?.({type:"cancel_scrollback",terminalId:e.id})}function ne(){if(!M.current)return;const D=!Te.current;dn(lT(e.id,D)),be()}function be(){const D=q.current;D&&(br(D),li())}function ae(D){nn();const J=Ce.current;Ce.current=!1,J&&Xt(!1),jn({force:!0,scrollToBottom:!0}),wr({type:"input",terminalId:e.id,data:D,...J?{cancelScrollbackMode:!0}:{}})&&s3(D)&&fi()}function we(){Wt.current&&ms(!1),ae(xA)}function qe(D){const J=C0(D,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&ae(J)}function nt(D,J){const Ke=C0(D,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ke&&ae(Ke),window.setTimeout(()=>ae(AN(J)),Q1)}function fi(){!ei.current||!$e.current||(Bi(),R.current=SA.map(D=>{const J=window.setTimeout(()=>{R.current=R.current.filter(Ke=>Ke!==J),ei.current&&$e.current&&wr({type:"refresh_cwd",terminalId:e.id})},D);return J}))}function _t(D="terminal-interaction"){We.current||nr()&&(D==="auto"||D==="scroll-action")||q.current?.focus()}const ps=v.useCallback(()=>{Zi(!1)},[]);function la(){Wi(D=>{const J=!D;return Wt.current=J,J}),_t("input-action")}function ms(D){Wt.current=D,Wi(D)}function zc(D){Wt.current&&ms(!1),ae(mN(D)),_t("input-action")}return m.jsxs("section",{className:"terminal-pane","data-active":r,"data-tmux-scrollback":Ji?"true":"false",onMouseDown:()=>{r||p()},children:[m.jsx(WA,{terminal:e,canClose:l,tabId:h,transcriptSource:gt,transcriptShortcutLabel:B,scrollbackShortcutLabel:Y,tmuxScrollbackSupported:Sn,tmuxScrollbackEnabled:Ji,onToggleTmuxScrollback:ne,onOpenTranscript:()=>Zi(!0),onInterrupt:we,onReload:tr,onClose:g}),m.jsx("div",{className:"xterm-container",ref:P}),F?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,k&&!Ji&&it?m.jsxs("div",{className:"terminal-scroll-progress","data-active":Gi,"aria-hidden":"true",children:[it.current,"/",it.total]}):k&&!Ji&&St?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":St.alternate?"alternate":"normal","aria-hidden":"true",children:[St.alternate?"alt ":"","0/?"]}):null,Yt||Ji&&di?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),Ya()},children:"↓"}):null,Ai&&!Ji?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Xa,onPointerMove:lr,children:m.jsx("span",{"aria-hidden":"true"})}):null,r&&e.status==="running"?Xl?m.jsx(fN,{ctrlActive:qt,onCtrl:la,onStandaloneKey:zc,onPreserveFocus:()=>_t("input-action"),onHide:()=>as(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:D=>{D.stopPropagation(),_t("input-action")},onPointerDown:D=>{D.stopPropagation(),_t("input-action")},onClick:()=>as(!0),children:"⌨"}):null,m.jsx(PN,{terminalId:e.id,onSubmit:nt,queueAvailable:gt?.provider==="codex"||iC(e.currentCommand),disabled:e.status!=="running"}),ln&>?m.jsx(FA,{terminalId:e.id,serverApi:t,source:gt,fontSize:S,onClose:ps}):null]})}function N0(e){return Uk(e)}function IA(e,t,r){const s=UA(e,t),l=A0(s*Math.max(1,r),BA,OA);return{limit:A0(Math.ceil(l/NA),AA,LA),maxLines:l}}function UA(e,t){const r=e?.clientHeight??0;if(r<=0)return RA;const s=Math.max(10,t*MA);return Math.max(1,Math.floor(r/s))}function A0(e,t,r){return Math.max(t,Math.min(r,Math.floor(e)))}function KA(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function WA({terminal:e,canClose:t,tabId:r,transcriptSource:s,transcriptShortcutLabel:l,scrollbackShortcutLabel:c,tmuxScrollbackSupported:h,tmuxScrollbackEnabled:p,onToggleTmuxScrollback:g,onOpenTranscript:f,onInterrupt:b,onReload:y,onClose:S}){const w=ww({id:`pane-${e.id}`,disabled:!r,...r?{data:{kind:"pane",sourceTabId:r,terminalId:e.id}}:{}}),k={cursor:r?"grab":"default",opacity:w.isDragging?.5:void 0};return m.jsxs("header",{ref:w.setNodeRef,className:"terminal-pane-header",style:k,"data-dragging":w.isDragging,...w.attributes,...w.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"}),s?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Bh(s.provider)} transcript history`,"aria-label":`View ${Bh(s.provider)} transcript history`,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),f()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:l})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),h&&e.status==="running"?m.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":p?"true":"false","aria-pressed":p,"aria-label":`Toggle tmux scrollback (${c})`,title:p?`Scroll input uses tmux scrollback (${c}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${c}).`,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),g()},children:[p?m.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),m.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):m.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),m.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),m.jsx("kbd",{children:c})]}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-interrupt","aria-label":`Send interrupt to ${e.title}`,title:"Send interrupt (^C)",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),b()},children:"^C"}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),y()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),S()},children:"x"}):null]})}const FA=Mi.memo(function({terminalId:t,serverApi:r,source:s,fontSize:l,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),S=v.useRef(null),w=v.useRef(null),[k,E]=v.useState([]),[L,A]=v.useState(!1),[B,Y]=v.useState(""),[P,q]=v.useState(-1),[re,ie]=v.useState(!1),[he,ve]=v.useState(-1),[U,K]=v.useState(null),[W,H]=v.useState(null),[j,le]=v.useState(!1),[R,X]=v.useState(!0),[Z,Ce]=v.useState(!1),[Te,M]=v.useState(null);v.useEffect(()=>{function _e(We){We.key==="Escape"&&(We.preventDefault(),We.stopPropagation(),c())}return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[c]),v.useEffect(()=>{p.current+=1;const _e=p.current;return g.current=!1,f.current=!0,b.current=null,S.current=null,w.current=null,E([]),H(null),le(!1),M(null),q(-1),ve(-1),K(null),Be(null,"initial",_e),()=>{p.current===_e&&(p.current+=1)}},[r,L,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const _e=h.current;if(!_e)return;if(f.current){if(R||k.length===0)return;f.current=!1;const Je=()=>{_e.scrollTop=_e.scrollHeight};Je(),window.requestAnimationFrame?.(Je);return}const We=b.current;We!==null&&(b.current=null,_e.scrollTop+=_e.scrollHeight-We)},[k,R,L]);const Q=Bh(s.provider),de=O0(k,L),me=VA(de),ge=ZA(me),Se=ge.map(_e=>_e.key).join(""),Ee=U?ge.find(_e=>_e.key===U)?.entryIndex??null:null,De=B.trim().length>0,Ue=GA(me,B),se=Ue.length,pe=se>0?P>=0&&P<se?P:0:-1,Le=pe>=0?Ue[pe]?.entryIndex??null:null,ye=pe>=0?Ue[pe]??null:null,Me=De?Le:Ee,Pe=De?Le===null?null:"search":Ee===null?null:"prompt",ze=de?de.split(`
|
|
34
|
-
`).length-1:0,te=ge.length>0&&he>=0&&he<ge.length?he:ge.length-1,ke=U??(te>=0?ge[te]?.key??null:null),Re=De?se>0?`${pe+1}/${se} ${se===1?"match":"matches"} · ${ze} ${ze===1?"line":"lines"}`:`0 matches · ${ze} ${ze===1?"line":"lines"}`:ge.length>0?`${te+1}/${ge.length} prompts · ${ze} ${ze===1?"line":"lines"}`:`0 prompts · ${ze} ${ze===1?"line":"lines"}`;v.useEffect(()=>{const _e=B.trim().toLowerCase();q(We=>!_e||se===0?-1:y.current!==_e?0:We>=0&&We<se?We:0),y.current=_e},[B,se]),v.useEffect(()=>{if(De){K(null);return}U&&!ge.some(_e=>_e.key===U)&&K(null),ve(_e=>{if(ge.length===0)return w.current=null,-1;const We=w.current?ge.findIndex(ct=>ct.key===w.current):-1,Je=We>=0?We:_e>=0&&_e<ge.length?_e:ge.length-1;return w.current=ge[Je]?.key??null,Je})},[U,De,Se]),v.useEffect(()=>{const _e=S.current;if(!_e||ge.length===0)return;S.current=null;const We=_e.anchorKey?ge.findIndex(ct=>ct.key===_e.anchorKey):-1,Je=We>0?We-1:0;kt(Je)},[Se]);async function Be(_e,We,Je=p.current){if(!g.current){g.current=!0,We==="initial"?X(!0):(Ce(!0),b.current=h.current?.scrollHeight??null),M(null);try{await je(_e,We,Je)}catch(ct){if(p.current!==Je)return;M(ct instanceof Error?ct.message:"Failed to load transcript history.")}finally{p.current===Je&&(g.current=!1,X(!1),Ce(!1))}}}async function je(_e,We,Je){let ct=_e,Pt=0,Tt=[];const Lt=We==="initial"&&s.provider!=="claude"?jA:zA;for(;p.current===Je;){const Dt=await r.getTerminalTranscriptHistory(t,{...ct?{cursor:ct}:{},...IA(h.current,l,We==="initial"?TA:DA),includeTools:L});if(p.current!==Je)return;const F=B0(Dt.output,s.provider,{includeTools:L}),Ie=at(Dt,We,Tt,F);if(F&&(Tt=[F,...Tt],Ie))return;if(!Dt.hasMore||!Dt.cursor||Pt>=Lt){Tt.length>0&&E(it=>We==="older"?[...Tt,...it]:Tt);return}ct=Dt.cursor,Pt+=1}}function at(_e,We,Je,ct=B0(_e.output,s.provider,{includeTools:L})){if(H(_e.cursor),le(!!(_e.hasMore&&_e.cursor)),!ct)return!1;const Pt=[ct,...Je];return O0(Pt,L)?(E(Tt=>We==="older"?[...Pt,...Tt]:Pt),!0):!1}function Wt(){const _e=h.current;_e&&(Et(),!(_e.scrollTop>72||!j||!W||g.current)&&Be(W,"older"))}function $e(_e){se!==0&&q(We=>{const Je=pe>=0?pe:_e>0?-1:0;return((We>=0&&We<se?We:Je)+_e+se)%se})}function kt(_e){const We=ge[_e];We&&(w.current=We.key,ve(_e),K(We.key))}async function ei(_e){if(ge.length===0){_e<0&&j&&W&&!g.current&&(S.current={anchorKey:null},await Be(W,"older"));return}const Je=(he>=0&&he<ge.length?he:_e<0?ge.length-1:-1)+_e;if(Je>=0&&Je<ge.length){kt(Je);return}_e<0&&Je<0&&j&&W&&!g.current&&(S.current={anchorKey:ge[0]?.key??null},await Be(W,"older"))}function Et(){if(De)return;const _e=h.current;if(!_e)return;const Je=_e.getBoundingClientRect().top+Math.min(140,Math.max(48,_e.clientHeight*.28));let ct=null;for(const Pt of i3(_e)){const Tt=n3(Pt);if(Tt!==null)if(Pt.getBoundingClientRect().top<=Je)ct=Tt;else break}if(ct!==null){const Pt=ge[ct]?.key??null;w.current=Pt,ve(ct),U&&U!==Pt&&K(null)}}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>_e.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:[Q," JSONL"]}),m.jsx("span",{title:s.sessionId,children:s.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:L,onChange:_e=>A(_e.currentTarget.checked)}),"Show tool output"]}),m.jsx("label",{className:"transcript-search",children:m.jsx("input",{type:"search",value:B,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:_e=>Y(_e.currentTarget.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),De?$e(_e.shiftKey?-1:1):ei(_e.shiftKey?-1:1))}})}),m.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":re,"aria-label":"Toggle prompt list",onClick:()=>ie(_e=>!_e),disabled:ge.length===0,children:"List"}),m.jsxs("div",{className:"transcript-search-actions","aria-label":De?"Search result navigation":"Prompt navigation",children:[m.jsx("button",{type:"button",onClick:()=>De?$e(-1):void ei(-1),disabled:De?se===0:ge.length===0&&!j,"aria-label":De?"Previous search match":"Previous user prompt",title:De?"Previous search match":"Previous user prompt",children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>De?$e(1):void ei(1),disabled:De?se===0:ge.length===0,"aria-label":De?"Next search match":"Next user prompt",title:De?"Next search match":"Next user prompt",children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:Re})]}),re?m.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:ge.length>0?ge.map((_e,We)=>m.jsxs("button",{type:"button",className:ke===_e.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>kt(We),children:[m.jsx("span",{children:_e.timestampLabel}),m.jsx("strong",{children:_e.snippet})]},`${_e.key}:${We}`)):m.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Wt,children:[Z?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&j?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,de?m.jsx(qA,{entries:me,searchQuery:B,activeEntryIndex:Me,activeEntryMode:Pe,activeSearchMatch:ye,fontSize:l}):null,R?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!R&&!de&&!Te?j&&W?m.jsxs("div",{className:"transcript-dialog-status",children:[L?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{Be(W,"older")},disabled:Z,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,Te?m.jsx("div",{className:"transcript-dialog-error",children:Te}):null]})]})})});function qA({entries:e,searchQuery:t,activeEntryIndex:r,activeEntryMode:s,activeSearchMatch:l,fontSize:c}){const h=v.useRef(new Map);v.useEffect(()=>{if(r===null)return;const g=h.current.get(r);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((l?.entryIndex===r?f[l.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[r,s,l,t]);let p=-1;return m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const b=g.kind==="user"?++p:null,y=r===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return m.jsxs("section",{ref:S=>{S?h.current.set(f,S):h.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${y}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...b!==null?{"data-transcript-prompt-position":b}:{},children:[g.header?m.jsx("div",{className:"transcript-entry-header",children:tC(g.header,t)}):null,g.body?m.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?m.jsx(L0,{text:g.body,searchQuery:t}):m.jsx(Mi.Suspense,{fallback:m.jsx(L0,{text:g.body,searchQuery:t}),children:m.jsx(HA,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function L0({text:e,searchQuery:t}){const r=e.endsWith(`
|
|
35
|
-
`)?e.slice(0,-1).split(`
|
|
36
|
-
`):e.split(`
|
|
37
|
-
`);return m.jsx("pre",{className:"transcript-entry-pre",children:r.map((s,l)=>m.jsx("span",{className:`transcript-line transcript-line-${r3(s,l===0||r[l-1]?.trim()==="")}`,children:tC(s,t)},l))})}function tC(e,t){const r=t.trim();if(!r)return e||" ";const s=e.toLowerCase(),l=r.toLowerCase(),c=[];let h=0,p=s.indexOf(l);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+r.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=s.indexOf(l,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function $A(e,t){const r=t.trim().toLowerCase();if(!r)return 0;const s=e.toLowerCase();let l=0,c=s.indexOf(r);for(;c!==-1;)l+=1,c=s.indexOf(r,c+r.length);return l}function VA(e){const t=e.endsWith(`
|
|
38
|
-
`)?e.slice(0,-1):e;if(!t)return[];const r=[];let s=null,l="plain",c=[];function h(){const p=YA(c).join(`
|
|
39
|
-
`);(s||p)&&r.push({header:s,body:p,kind:l}),s=null,l="plain",c=[]}for(const p of t.split(`
|
|
40
|
-
`)){const g=XA(p);g?(h(),s=p,l=g):c.push(p)}return h(),r}function YA(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function XA(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const r=t[1]??"";return r==="User"?"user":r==="Codex"||r==="Claude"?"assistant":r==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(r)?"tool":null}function GA(e,t){const r=[];for(let s=0;s<e.length;s+=1){const l=e[s];if(!l)continue;const c=l.header?`${l.header}
|
|
41
|
-
${l.body}`:l.body,h=$A(c,t);for(let p=0;p<h;p+=1)r.push({entryIndex:s,matchIndexInEntry:p})}return r}function ZA(e){const t=[];for(let l=0;l<e.length;l+=1){const c=e[l];!c||c.kind!=="user"||t.push({contentKey:QA(c),entry:c,entryIndex:l})}const r=new Map,s=new Map;for(let l=t.length-1;l>=0;l-=1){const c=t[l];if(!c)continue;const h=r.get(c.contentKey)??0;r.set(c.contentKey,h+1),s.set(l,JSON.stringify([c.contentKey,h]))}return t.map((l,c)=>({entryIndex:l.entryIndex,key:s.get(c)??JSON.stringify([l.contentKey,0]),snippet:e3(l.entry.body),timestampLabel:t3(l.entry.header)}))}function QA(e){return JSON.stringify([e.header??"",e.body.length,JA(e.body)])}function JA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function e3(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function t3(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function i3(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function n3(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const r=Number(t);return Number.isInteger(r)&&r>=0?r:null}function r3(e,t){const r=e.trim();if(!r)return"blank";const s=r.replace(/^\[[^\]]+\]\s+/,""),l=/^\[[^\]]+\]\s+/.test(r);return(l||t)&&/^User$/.test(s)?"user":(l||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(l||t)&&/^System$/.test(s)?"system":(l||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||aC(r))?"tool":/^(?:\$|>|❯|➜)\s+/.test(r)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(r)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(r)?"error":/^\[[^\]]+\]/.test(r)||/^(?:info|debug|warn)\b/i.test(r)?"dim":"plain"}function s3(e){return e.includes("\r")||e.includes(`
|
|
42
|
-
`)}function Np(e){return e instanceof dr&&e.status===404}function ic(e){return iC(e)||nC(e)}function iC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function nC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function a3(e){if(ic(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Bh(e){return e==="codex"?"Codex":"Claude"}function B0(e,t,r={}){const s=`[nterminal] ${Bh(t)} transcript archive ends here. Live terminal screen continues below.`,l=e.join("").replace(/\r\n/g,`
|
|
43
|
-
`).replace(/\r/g,`
|
|
44
|
-
`).replace(s,"").replace(/\n{3,}/g,`
|
|
45
|
-
|
|
46
|
-
`).trimEnd(),c=rC(l),h=r.includeTools?c:sC(c);return h?`${h}
|
|
47
|
-
`:""}function rC(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,r)=>{const s=l3(r);return s?`[${s}]`:t})}function l3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const r=t.getFullYear(),s=Fo(t.getMonth()+1),l=Fo(t.getDate()),c=Fo(t.getHours()),h=Fo(t.getMinutes()),p=Fo(t.getSeconds());return`${r}-${s}-${l} ${c}:${h}:${p}`}function Fo(e){return e.toString().padStart(2,"0")}function O0(e,t){return e.map(r=>t?r:sC(r)).filter(Boolean).map(r=>r.endsWith(`
|
|
48
|
-
`)?r:`${r}
|
|
49
|
-
`).join("")}function sC(e){if(!e)return"";const t=e.split(`
|
|
50
|
-
`),r=[];let s=!1,l=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?o3(h):null;if(g&&(s=g==="tool",l=!1),aC(h)){l=!0,c=!1;continue}if(l){p?(l=!1,s||r.push(h),c=!0):c=!1;continue}s||r.push(h),c=p}return r.join(`
|
|
51
|
-
`).replace(/\n{3,}/g,`
|
|
52
|
-
|
|
53
|
-
`).trimEnd()}function o3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function aC(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function c3(e,t){if(t.length===0)return e;let r=0;const s=Math.min(e.length,t.length);for(let l=s;l>0;l-=1){let c=!0;for(let h=0;h<l;h+=1)if(e[e.length-l+h]!==t[h]){c=!1;break}if(c){r=l;break}}return[...e,...t.slice(r)]}function u3(e){let t=0;for(const r of e){if(!r)continue;const s=r.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function eh(e){const t=[];for(const r of e){const s=lC(r);s&&t.push(s)}return t}function lC(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,r,s)=>{const l=r.split(";").filter(Boolean).filter(c=>!kA.has(c.split(":")[0]??""));return l.length>0?`\x1B[?${l.join(";")}${s}`:""})}function Ap(e,t={}){const r={};return(e?.force||t.force)&&(r.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(r.scrollToBottom=!0),r}function h3(e){const t=e.buffer.active,r=t.baseY+e.rows;return r<=e.rows?null:{current:Math.max(1,Math.min(r,t.viewportY+1)),total:r}}function z0(e,t){const r=e?.querySelector(".xterm .xterm-viewport");if(r){if(t){r.dataset.nterminalTmuxScrollHidden="true",r.style.setProperty("overflow-y","hidden","important"),r.style.setProperty("scrollbar-color","transparent transparent","important"),r.style.setProperty("scrollbar-width","none","important"),r.style.setProperty("-ms-overflow-style","none");return}r.dataset.nterminalTmuxScrollHidden==="true"&&(delete r.dataset.nterminalTmuxScrollHidden,r.style.removeProperty("overflow-y"),r.style.removeProperty("scrollbar-color"),r.style.removeProperty("scrollbar-width"),r.style.removeProperty("-ms-overflow-style"))}}function hr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function th(e,t){return!t||hr(e)}function j0(e){return hr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function d3(e,t,r,s,l,c,h,p){const g=f=>{const b=p3(f);if(b!==0){if(h()){if(_3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),p(b);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),f3(t,b,r,s,l,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function f3(e,t,r,s,l,c){const h=()=>{l();try{e.scrollLines(t)}finally{c()}r(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Qm,h);return}h()}function p3(e){const r=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(r===0)return 0;const s=r<0?Math.floor(r):Math.ceil(r);return Math.max(-30,Math.min(30,s))}function m3(e,t,r,s,l,c,h,p,g){let f=null,b=0;const y={passive:!1};function S(E){f=Lp(E),b=0}function w(E){const L=Lp(E);if(L===null){f=null,b=0;return}if(f===null){f=L;return}const A=L.clientY-f.clientY;if(f=L,E.cancelable&&E.preventDefault(),A===0)return;if(g3(t)&&v3(t,L,-A)){b=0;return}b-=A/r();const B=b<0?Math.ceil(b):Math.floor(b);if(B!==0){if(b-=B,p()){g(B);return}c();try{t.scrollLines(B)}finally{h()}s(),B<0&&t.buffer.active.viewportY<=3&&l(B)}}function k(E){if(E.touches.length>0){f=Lp(E);return}f=null,b=0}return e.addEventListener("touchstart",S,y),e.addEventListener("touchmove",w,y),e.addEventListener("touchend",k),e.addEventListener("touchcancel",k),()=>{e.removeEventListener("touchstart",S,y),e.removeEventListener("touchmove",w,y),e.removeEventListener("touchend",k),e.removeEventListener("touchcancel",k)}}function Lp(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function g3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function _3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function v3(e,t,r){const s=e.element;return s?(s.dispatchEvent(y3(t,r)),!0):!1}function y3(e,t){const r=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:r};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const l=new Event("wheel",s);return Object.defineProperties(l,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),l}function Jm({node:e,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:S,onSelect:w,onClose:k,onResize:E,onExit:L,onSnapshot:A,onCloseEditor:B,onAuthClose:Y}){const P=S??eg(e);if(y.length===0&&b){const he=tg(e),ve=he.some(U=>U.key===b)?b:he[0]?.key;if(he.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:he.map(U=>{const K=U.key===ve;if(U.type==="editor"){const H=r[U.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:H?m.jsx(CS,{api:s,editor:H,canClose:P>1,onClose:()=>B(U.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},U.key)}const W=t[U.terminalId];return W?m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx(M0,{terminal:W,serverApi:s,active:K,visible:c&&K,canClose:P>1,refreshCwdOnEnter:h&&K,tabId:p,onSelect:()=>w(U.terminalId),onClose:()=>k(U.terminalId),onExit:H=>L(U.terminalId,H),onSnapshot:A,...Y?{onAuthClose:Y}:{}})},U.key):m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},U.key)})})}if(e.type==="pane"){const he=t[e.terminalId];if(!he)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(M0,{terminal:he,serverApi:s,active:e.terminalId===l,visible:c,canClose:P>1,refreshCwdOnEnter:h&&e.terminalId===l,tabId:p,onSelect:()=>w(e.terminalId),onClose:()=>k(e.terminalId),onExit:K=>L(e.terminalId,K),onSnapshot:A,...Y?{onAuthClose:Y}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(ih,{terminalId:e.terminalId,side:"top"}),m.jsx(ih,{terminalId:e.terminalId,side:"right"}),m.jsx(ih,{terminalId:e.terminalId,side:"bottom"}),m.jsx(ih,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const he=r[e.editorId];return he?m.jsx(CS,{api:s,editor:he,canClose:P>1,onClose:()=>B(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const q=Math.max(.1,Math.min(.9,e.ratio)),re=1-q,ie=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`}:{gridTemplateRows:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ie,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Jm,{node:e.first,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,0],totalPanes:P,onSelect:w,onClose:k,onResize:E,onExit:L,onSnapshot:A,onCloseEditor:B,...Y?{onAuthClose:Y}:{}})}),m.jsx(b3,{direction:e.direction,path:y,onResize:E}),m.jsx("div",{className:"split-cell",children:m.jsx(Jm,{node:e.second,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,1],totalPanes:P,onSelect:w,onClose:k,onResize:E,onExit:L,onSnapshot:A,onCloseEditor:B,...Y?{onAuthClose:Y}:{}})})]})}function ih({terminalId:e,side:t}){const{setNodeRef:r,isOver:s}=Dg({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:r,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function b3({direction:e,path:t,onResize:r}){function s(l){l.preventDefault(),l.stopPropagation();const c=l.currentTarget;c.setPointerCapture?.(l.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-p.left)/p.width:(b.clientY-p.top)/p.height;r(t,Math.min(.9,Math.max(.1,y)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function eg(e){return e.type==="pane"||e.type==="editor"?1:eg(e.first)+eg(e.second)}function tg(e){return e.type==="pane"?[{key:S3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:w3(e.editorId),type:"editor",editorId:e.editorId}]:[...tg(e.first),...tg(e.second)]}function S3(e){return`terminal:${e}`}function w3(e){return`editor:${e}`}const ed="workspace-default",C3="NTerminal";function x3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function k3(e,t){switch(t.type){case"workspace.hydrated":return ig(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return E3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return M3(e,t.workspaceId);case"workspace.selected":return oC(e,t.workspaceId);case"workspace.renamed":return T3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return D3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return R3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return cC(e,t.terminal);case"terminal.split":return N3(e,t.terminal,t.direction);case"terminal.updated":return K3(e,t.terminal);case"terminal.exited":return W3(e,t.terminalId,t.exitCode);case"terminal.closed":return dC(e,t.terminalId);case"terminal.detached":return F3(e,t.terminalId,t.workspaceId);case"editor.split":return A3(e,t.editorId,t.title,t.direction);case"editor.closed":return q3(e,t.editorId);case"pane.selected":return I3(e,t.terminalId);case"pane.resized":return U3(e,t.path,t.ratio);case"tab.selected":return B3(e,t.tabId);case"tab.renamed":return H3(e,t.tabId,t.title);case"tab.reordered":return o_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return O3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return uC(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return hC(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return z3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return L3(e);default:return e}}function E3(e,t){if(e.workspaces.some(s=>s.id===t.id))return oC(e,t.id);const r={id:t.id,title:t.title,defaultCwd:pr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,r],activeWorkspaceId:r.id}}function oC(e,t){return e.workspaces.some(r=>r.id===t)?{...e,activeWorkspaceId:t}:e}function T3(e,t,r){const s=r.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===s?h:(l=!0,{...h,title:s}));return l?{...e,workspaces:c}:e}function D3(e,t,r){const s=pr(r);let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===s?h:(l=!0,{...h,defaultCwd:s}));return l?{...e,workspaces:c}:e}function R3(e,t,r,s){if(t===r)return e;const l=e.workspaces.findIndex(y=>y.id===t),c=e.workspaces.findIndex(y=>y.id===r);if(l<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(l,1);if(!p)return e;const g=h.findIndex(y=>y.id===r);if(g<0)return e;const f=s==="before"?g:g+1,b=h.slice();return b.splice(f,0,p),P3(e.workspaces,b)?e:{...e,workspaces:b}}function M3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const r=e.workspaces.find(p=>p.id===t),s=new Set(r?Oh(r):[]),l={...e.terminals};for(const p of s)delete l[p];const c=e.workspaces.filter(p=>p.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:l}}function cC(e,t){const r=pC(e),s=Fa(r)??id(),l=yC(t);return{...r,activeWorkspaceId:s.id,terminals:{...r.terminals,[t.id]:t},workspaces:r.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??pr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,l],activeTabId:l.id}:vC(c,t.id))}}function N3(e,t,r){const s=Fa(e),l=s?td(s):void 0;if(!s||!l)return cC(e,t);const c=l.activeTerminalId,h=wc(l.root,c,{type:"split",direction:r,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(p=>p.id===s.id?{...p,defaultCwd:p.defaultCwd??pr(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===l.id?{...g,root:h,activeTerminalId:t.id}:g)}:vC(p,t.id))}}function A3(e,t,r,s){const l=Fa(e),c=l?td(l):void 0;if(!l||!c)return e;const h=c.activeTerminalId,p=wc(c.root,h,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:r}});return{...e,workspaces:e.workspaces.map(g=>g.id===l.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function L3(e){const t=Fa(e),r=t?td(t):void 0;return r?dC(e,r.activeTerminalId):e}function B3(e,t){const r=Fa(e);return!r||!r.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===r.id?{...s,activeTabId:t}:s)}}function o_(e,t,r){const s=e.workspaces.map(l=>{const c=l.tabs.findIndex(b=>b.id===t);if(c<0)return l;const h=l.tabs.slice(),[p]=h.splice(c,1);if(!p)return l;const g=Math.max(0,Math.min(h.length,r)),f=h.slice();return f.splice(g,0,p),j3(l.tabs,f)?l:{...l,tabs:f}});return s.every((l,c)=>l===e.workspaces[c])?e:{...e,workspaces:s}}function O3(e,t,r,s,l){if(r===s||!e.terminals[r]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(k=>k.id===t);if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y=Il(b.root,r);if(!y){const k=g.tabs.filter((E,L)=>L!==f);return{...g,tabs:k}}const S={...b,root:y,activeTerminalId:Ui(y)[0]??b.activeTerminalId},w=g.tabs.slice();return w[f]=S,{...g,tabs:w}});const h=l==="left"||l==="right"?"vertical":"horizontal",p=l==="left"||l==="top";return c=c.map(g=>{const f=g.tabs.findIndex(E=>Ui(E.root).includes(s));if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y={type:"pane",terminalId:r},S={type:"split",direction:h,ratio:.5,first:p?y:{type:"pane",terminalId:s},second:p?{type:"pane",terminalId:s}:y},w=wc(b.root,s,S),k=g.tabs.slice();return k[f]={...b,root:w,activeTerminalId:r},{...g,tabs:k,activeTabId:b.id}}),pC({...e,workspaces:c})}function uC(e,t,r,s){let l=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(B=>B.id===t);if(A>=0){l=L,c=A;break}}if(l<0)return e;const h=e.workspaces[l],p=h.tabs[c],g=Ui(p.root);if(!g.includes(r))return e;if(g.length===1)return o_(e,t,s);const f=Il(p.root,r);if(!f)return e;const b={...p,root:f,activeTerminalId:Ui(f)[0]??p.activeTerminalId},y=e.terminals[r],S={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:y?.title??"",activeTerminalId:r,root:{type:"pane",terminalId:r}},w=h.tabs.slice();w[c]=b;const k=Math.max(0,Math.min(w.length,s));w.splice(k,0,S);const E=e.workspaces.slice();return E[l]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:E}}function hC(e,t,r,s=Number.MAX_SAFE_INTEGER){const l=mC(e.workspaces,t),c=e.workspaces.find(f=>f.id===r);if(!l||!c)return e;if(l.workspace.id===r)return s===Number.MAX_SAFE_INTEGER?e:o_(e,t,s);const h=Ui(l.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===l.workspace.id)return qa({...f,tabs:f.tabs.filter(b=>b.id!==t)});if(f.id===r){const b=f.tabs.slice(),y=Math.max(0,Math.min(b.length,s));return b.splice(y,0,l.tab),{...f,defaultCwd:f.defaultCwd??pr(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:b,activeTabId:l.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:r}}function z3(e,t,r,s,l=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),h=mC(e.workspaces,t);if(!c||!h||!e.terminals[r]||!Ui(h.tab.root).includes(r))return e;if(h.workspace.id===s)return uC(e,t,r,l);if(Ui(h.tab.root).length===1)return hC(e,t,s,l);const g=Il(h.tab.root,r);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Ui(g)[0]??h.tab.activeTerminalId},b=e.terminals[r],y={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:b.title??r,activeTerminalId:r,root:{type:"pane",terminalId:r}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return qa({...w,tabs:w.tabs.map(k=>k.id===t?f:k)});if(w.id===s){const k=w.tabs.slice(),E=Math.max(0,Math.min(k.length,l));return k.splice(E,0,y),{...w,defaultCwd:w.defaultCwd??pr(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(L=>L!==r),tabs:k,activeTabId:y.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function j3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function P3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function H3(e,t,r){const s=r.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===s?f:(l=!0,p=!0,{...f,title:s}));return p?{...h,tabs:g}:h});return l?{...e,workspaces:c}:e}function I3(e,t){const r=e.workspaces.find(l=>l.tabs.some(c=>Ul(c.root,t))),s=r?.tabs.find(l=>Ul(l.root,t));return!r||!s?e:{...e,activeWorkspaceId:r.id,workspaces:e.workspaces.map(l=>l.id===r.id?{...l,activeTabId:s.id,tabs:l.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:l)}}function U3(e,t,r){const s=Fa(e),l=s?td(s):void 0;if(!s||!l)return e;const c=og(l.root,t,wC(r));return c===l.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===s.id?{...h,tabs:h.tabs.map(p=>p.id===l.id?{...p,root:c}:p)}:h)}}function ig(e,t,r,s){const l=Object.fromEntries(e.map(y=>[y.id,y])),c=new Set(e.map(y=>y.id)),h=new Set,p=!!(r&&r.some(y=>bC(y))||t&&t.some(y=>SC(y)));let g=$3(t,r,c,h);g.length===0&&(g=[id()]);const f=typeof s=="string"&&g.some(y=>y.id===s)?s:g[0]?.id??null,b=f??g[0]?.id??ed;for(const y of e)if(!h.has(y.id)){if(p)g=X3(g,b,y.id,y);else{const S=yC(y);g=Z3(g,b,S,y)}h.add(y.id)}return{workspaces:g.map(y=>qa(G3(y,l))),activeWorkspaceId:f,terminals:l}}function Sc(e){return Ui(e.root)}function ng(e){return cg(e.root)}function Oh(e){return c_([...e.tabs.flatMap(t=>Ui(t.root)),...e.detachedTerminalIds])}function Bp(e){const t=e.workspaces.map(r=>{const s=r.tabs.flatMap(l=>{const c=ag(l.root);return c?[{...l,root:c}]:[]});return qa({...r,tabs:s})});return{activeWorkspaceId:t.some(r=>r.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function K3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(r=>({...r,tabs:r.tabs.map(s=>Ul(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function W3(e,t,r){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:r}}}:e}function dC(e,t){const r={...e.terminals};return delete r[t],fC(e,t,r)}function F3(e,t,r){if(!e.terminals[t])return e;const s=(r&&e.workspaces.some(c=>c.id===r)?r:null)??V3(e,t)?.id??Y3(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??ed,l=e.workspaces.find(c=>c.id===s);return!l||!_C(l,t)?e:fC(e,t,{...e.terminals},{detachToWorkspaceId:s})}function fC(e,t,r,s={}){let l=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=Il(g.root,t);if(!f)continue;const b=Ui(f),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&p.push({...g,root:f,activeTerminalId:y})}return qa({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});s.detachToWorkspaceId&&r[t]&&(l=l.map(h=>h.id===s.detachToWorkspaceId?gC(h,t,r[t]):h));const c=l.some(h=>h.id===e.activeWorkspaceId);return{workspaces:l,activeWorkspaceId:c?e.activeWorkspaceId:l[0]?.id??null,terminals:r}}function q3(e,t){const r=e.workspaces.map(l=>{const c=[];for(const h of l.tabs){const p=rg(h.root,t);if(!p)continue;const g=Ui(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return qa({...l,tabs:c})}),s=r.some(l=>l.id===e.activeWorkspaceId);return{...e,workspaces:r,activeWorkspaceId:s?e.activeWorkspaceId:r[0]?.id??null}}function $3(e,t,r,s){if(t&&t.length>0){const l=[];for(const c of t)bC(c)&&l.push(P0(c,r,s));if(l.length>0)return l}return[P0({...id(),tabs:e??[]},r,s)]}function P0(e,t,r){const s=[];for(const c of e.tabs){if(!SC(c))continue;const h=sg(c.root,t);if(!h)continue;const p=Ui(h);for(const f of p)r.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&s.push({...c,root:h,activeTerminalId:g})}const l=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||r.has(c)||(r.add(c),l.push(c));return qa({...e,defaultCwd:pr(e.defaultCwd),detachedTerminalIds:l,tabs:s})}function pC(e){return Fa(e)?e:{...e,workspaces:[id()],activeWorkspaceId:ed}}function Fa(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function td(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function mC(e,t){for(const r of e){const s=r.tabs.findIndex(l=>l.id===t);if(s>=0)return{workspace:r,tab:r.tabs[s],tabIndex:s}}return null}function V3(e,t){return e.workspaces.find(r=>r.tabs.some(s=>Ul(s.root,t)))}function Y3(e,t){return e.workspaces.find(r=>r.detachedTerminalIds.includes(t))}function X3(e,t,r,s){return e.map(l=>l.id===t?gC(l,r,s):l)}function gC(e,t,r){return _C(e,t)?{...e,defaultCwd:e.defaultCwd??pr(r?.cwd),detachedTerminalIds:c_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function _C(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Fl}function vC(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(r=>r!==t)}:e}function G3(e,t){if(e.defaultCwd)return e;const r=Oh(e).find(l=>!!t[l]),s=r?pr(t[r]?.cwd):null;return s?{...e,defaultCwd:s}:e}function id(){return{id:ed,title:C3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function qa(e){const t=e.tabs.some(r=>r.id===e.activeTabId);return{...e,defaultCwd:pr(e.defaultCwd),detachedTerminalIds:c_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function Z3(e,t,r,s){const l=Ui(r.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??pr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!l.includes(h)),tabs:[...c.tabs,r],activeTabId:c.activeTabId??r.id}:c)}function yC(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function wc(e,t,r){return e.type==="pane"?e.terminalId===t?r:e:e.type==="editor"?e:{...e,first:wc(e.first,t,r),second:wc(e.second,t,r)}}function Il(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const r=Il(e.first,t),s=Il(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function rg(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const r=rg(e.first,t),s=rg(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function sg(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const r=sg(e.first,t),s=sg(e.second,t);return r&&s?{...e,ratio:wC(e.ratio),first:r,second:s}:r??s}function ag(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=ag(e.first),r=ag(e.second);return t&&r?{...e,first:t,second:r}:t??r}function bC(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 SC(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&lg(t.root)}function lg(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")&&lg(t.first)&&lg(t.second):!1}function og(e,t,r){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===r?e:{...e,ratio:r};const[s,...l]=t;if(s===0){const c=og(e.first,l,r);return c===e.first?e:{...e,first:c}}if(s===1){const c=og(e.second,l,r);return c===e.second?e:{...e,second:c}}return e}function wC(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function pr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function c_(e){const t=new Set,r=[];for(const s of e)!s||t.has(s)||(t.add(s),r.push(s));return r}function Ul(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Ul(e.first,t)||Ul(e.second,t)}function Ui(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ui(e.first),...Ui(e.second)]}function cg(e){return e.type==="pane"||e.type==="editor"?1:cg(e.first)+cg(e.second)}const Js=new Map,Cc=new Map,xc=new Map,kc=new Map;function Vl(e){return e??"__local__"}function Q3(e){return{agentId:e,state:x3(),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 zt(e){const t=Vl(e);let r=Js.get(t);return r||(r=Q3(e),Js.set(t,r)),r}function CC(e,t){const r=Vl(e);let s=Cc.get(r);return s||(s=new Set,Cc.set(r,s)),s.add(t),()=>{s.delete(t)}}function J3(e){const t=Vl(e),r=Cc.get(t);if(r)for(const s of Array.from(r))s()}function Yl(e,t){Js.set(Vl(e),t),J3(e)}const ug=new Set;function e5(e){return ug.add(e),()=>{ug.delete(e)}}function qo(e,t){const r=zt(e),s=Vl(e);t.type==="workspace.hydrated"&&(xc.delete(s),kc.delete(s));const l=k3(r.state,t);let c=r.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=r.state.terminals[t.terminal.id],b=l5(s),y=o5(s);if(t.notifyCompletion===!0&&t.terminal.agentStatus)t.terminal.agentStatus.state==="working"&&y.add(t.terminal.id),t.terminal.agentStatus.state==="done"&&y.has(t.terminal.id)&&(h=I0(l,t.terminal.id,f?.currentCommand??null),y.delete(t.terminal.id)),t.terminal.agentStatus.state==="idle"&&y.delete(t.terminal.id),b.delete(t.terminal.id);else{const S=f?.activity==="busy",w=t.terminal.activity==="busy",k=t.terminal.activity==="idle";t.notifyCompletion===!0&&w&&b.add(t.terminal.id),t.notifyCompletion===!0&&S&&k&&b.has(t.terminal.id)&&(h=I0(l,t.terminal.id,f?.currentCommand??null)),(k||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(h){const S=xC(l,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==l.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=t5(l,t.tabId)?.tab??null;else{const y=l.workspaces.find(S=>S.id===t.workspaceId);f=y?.tabs.find(S=>S.id===y.activeTabId)??null}const b=f?Ui(f.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const S of b)y.delete(S);c=y}}const p=l!==r.state,g=c!==r.unreadCompletions;if((p||g)&&Yl(e,{...r,state:l,unreadCompletions:c}),g&&u_(),h)for(const f of Array.from(ug))f({agentId:e,...h})}function xC(e,t){for(const r of e.workspaces)for(const s of r.tabs)if(Ui(s.root).includes(t))return{workspace:r,tab:s};return null}function t5(e,t){for(const r of e.workspaces){const s=r.tabs.find(l=>l.id===t);if(s)return{workspace:r,tab:s}}return null}const hg=new Set;function i5(e){return hg.add(e),()=>{hg.delete(e)}}function n5(){let e=0;for(const t of Js.values())e+=t.unreadCompletions.size;return e}function u_(){for(const e of Array.from(hg))e()}function r5(e,t){const r=zt(e);if(!r.unreadCompletions.has(t))return;const s=new Set(r.unreadCompletions);s.delete(t),Yl(e,{...r,unreadCompletions:s}),u_()}function H0(e,t){const r=zt(e);t!==r.state&&Yl(e,{...r,state:t})}function Op(e,t){const r=zt(e),s=t(r.editors);s!==r.editors&&Yl(e,{...r,editors:s})}function Us(e,t,r){const s=zt(e);s.loaded===t&&s.error===r||Yl(e,{...s,loaded:t,error:r})}function $o(e,t,r){const s=zt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===r||Yl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:r})}function s5(e){const t=zt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function a5(e){const t=Vl(e),r=Js.get(t);r&&r.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(r.mutable.saveCoord.saveTimer);const s=r?r.unreadCompletions.size>0:!1;Js.delete(t),Cc.delete(t),xc.delete(t),kc.delete(t),s&&u_()}function zp(){for(const e of Js.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Js.clear(),Cc.clear(),xc.clear(),kc.clear()}function l5(e){let t=xc.get(e);return t||(t=new Set,xc.set(e,t)),t}function o5(e){let t=kc.get(e);return t||(t=new Set,kc.set(e,t)),t}function I0(e,t,r){const s=xC(e,t);return s?{terminalId:t,tabId:s.tab.id,commandName:r}:null}function dg(e,t){let r=!1,s=!1,l=null,c=!1;for(const h of Sc(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,r=!0;continue}p.activity==="busy"?(s=!0,r=!0,!l&&p.currentCommand&&(l=p.currentCommand)):p.activity==="idle"&&(r=!0)}}return r?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:l}:{state:"idle",commandName:null}:null}function h_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function fg(e,t){const r=t[e.activeTerminalId];return e.title||r?.title||e.activeTerminalId}function c5(e,t,r,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${r} pane${r===1?"":"s"}`}function u5({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:k}){const[E,L]=v.useState(null),[A,B]=v.useState(!1),[Y,P]=v.useState(null),q=v.useRef(null),re=e.findIndex(j=>j.id===t),ie=re>=0?e[re]:e[0]??null,he=ie?dg(ie,r):null,ve=ie?ng(ie):0,U=ie?fg(ie,r):"No tab";v.useEffect(()=>{q.current?.focus(),q.current?.select()},[E?.tabId]),v.useEffect(()=>{if(!A)return;const j=le=>{le.key==="Escape"&&B(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[A]),v.useEffect(()=>{A&&e.length===0&&B(!1)},[A,e.length]);function K(j,le){L({tabId:j,title:le})}function W(){if(!E)return;const j=E.title.trim();j&&w(E.tabId,j),L(null)}function H(){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 - ${fT()}`,onClick:y,disabled:!k,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 - ${pT()}`,onClick:S,disabled:!k,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:p,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:U,onClick:()=>B(!0),disabled:e.length===0,children:[he?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":he.state,"aria-hidden":"true",title:h_(he)}):null,m.jsx("span",{children:U}),m.jsxs("small",{children:[re>=0?re+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,le)=>{const R=Sc(j),X=ng(j),Z=fg(j,r),Ce=j.id===t,Te=E?.tabId===j.id,M=dg(j,r),Q=s?.has(j.id)??!1;return m.jsxs(Mi.Fragment,{children:[m.jsx(U0,{index:le}),m.jsx(h5,{tab:j,active:Ce,editing:Te,title:Z,paneCount:X,terminalIds:R,canClose:e.length>1,editValue:Te?E.title:null,editInputRef:Te?q:null,activity:M,unread:Q,onSelect:()=>c(j.id),onBeginRename:()=>K(j.id,Z),onCloseAll:()=>g(R),onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:de=>L({tabId:j.id,title:de})})]},j.id)}),m.jsx(U0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(l?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(j=>m.jsx(f5,{terminal:j,onReattach:()=>f?.(j.id),onDelete:()=>P(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),k?H():null]}),A?m.jsx(d5,{tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:E,editInputRef:q,onClose:()=>B(!1),onSelectTab:j=>{c(j),B(!1)},onCreateTab:()=>{h(),B(!1)},onBeginRename:K,onCloseTerminals:j=>{g(j),B(!1)},onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:(j,le)=>L({tabId:j,title:le}),onReattachTerminal:j=>{f?.(j),B(!1)},onDeleteTerminal:j=>{P(j),B(!1)}}):null,Y?m.jsx(p5,{terminal:Y,onCancel:()=>P(null),onConfirm:()=>{b?.(Y.id),P(null)}}):null]})}function h5({tab:e,active:t,editing:r,title:s,paneCount:l,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:b,onBeginRename:y,onCloseAll:S,onCommitRename:w,onCancelRename:k,onRenameChange:E}){const{attributes:L,listeners:A,setNodeRef:B,transform:Y,isDragging:P}=ww({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:r}),q={transform:Up.Translate.toString(Y),opacity:P?.4:void 0,zIndex:P?2:void 0};return m.jsxs("div",{ref:B,className:"terminal-tab","data-active":t,"data-dragging":P,"data-unread":f?"true":void 0,style:q,...L,...A,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:h_(g)}):null,r&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:re=>{re.preventDefault(),w()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${s}`,value:h,onBlur:w,onChange:re=>E(re.target.value),onKeyDown:re=>{if(re.key==="Enter"){re.preventDefault(),w();return}re.key==="Escape"&&(re.preventDefault(),k())}}),m.jsx("small",{children:l})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:b,onDoubleClick:re=>{re.preventDefault(),y()},children:[m.jsx("span",{children:s}),m.jsxs("small",{children:[l," pane",l===1?"":"s"]})]}),c&&!r?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),S()},children:"x"}):null]})}function d5({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:b,onCloseTerminals:y,onCommitRename:S,onCancelRename:w,onRenameChange:k,onReattachTerminal:E,onDeleteTerminal:L}){const A=v.useRef(null);return v.useEffect(()=>{A.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:p,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:B=>B.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:f,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:p,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((B,Y)=>{const P=Sc(B),q=ng(B),re=fg(B,r),ie=B.id===t,he=c?.tabId===B.id,ve=dg(B,r),U=s?.has(B.id)??!1;return m.jsxs("div",{ref:ie?A:null,className:"mobile-tab-sheet-row","data-active":ie,"data-unread":U?"true":void 0,children:[he&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:K=>{K.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${re}`,value:c.title,onBlur:S,onChange:K=>k(B.id,K.target.value),onKeyDown:K=>{if(K.key==="Enter"){K.preventDefault(),S();return}K.key==="Escape"&&(K.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${re}`,onClick:()=>g(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:re}),m.jsx("small",{children:c5(B,r,q,ve)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ve?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:h_(ve)}):null,m.jsx("span",{children:q})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[he?m.jsx("button",{type:"button","aria-label":`Done renaming ${re}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${re}`,onClick:()=>b(B.id,re),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${re}`,onClick:()=>y(P),children:"×"}):null]})]},B.id)}),(l?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(l??[]).map(B=>{const Y=B.title||B.cwd||B.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 ${Y}`,onClick:()=>E(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:Y}),m.jsx("small",{children:B.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 ${Y}`,onClick:()=>L(B),children:"×"})})]},B.id)})]}):null]})]})})}function U0({index:e}){const{setNodeRef:t,isOver:r}=Dg({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":r,"aria-hidden":"true"})}function f5({terminal:e,onReattach:t,onDelete:r}){const s=e.title||e.cwd||e.id.slice(0,8),l=`${e.title||"Terminal"}
|
|
54
|
-
${e.cwd}
|
|
55
|
-
(detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:l,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),r()},children:"×"})]})}function p5({terminal:e,onCancel:t,onConfirm:r}){const s=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:l=>l.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:s}),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:r,children:"Delete"})]})]})})}function m5({uploads:e,onDismiss:t,onDismissAll:r,onRetry:s,onCancel:l}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",p=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${b5(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?fh(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:r,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(g5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>l(g.id)},g.id))})]})}function g5({upload:e,compact:t,onDismiss:r,onRetry:s,onCancel:l}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":fh(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:fh(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:l,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${fh(e)}`,onClick:r,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(_5,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(v5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function _5({toast:e}){const t=e.percent===null?S5(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 v5({response:e,compact:t}){const r=e.results.filter(h=>h.status==="failed"),s=e.results.filter(h=>h.status==="uploaded"),l=t?3:6,c=[...r,...s].slice(0,l);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,p)=>m.jsx(y5,{result:h},`${h.relativePath}-${p}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function y5({result:e}){const t=e.savedRelativePath??e.relativePath,r=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}),r?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 fh(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,r=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${r} files`}return"Upload failed"}function b5(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 S5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function w5({toast:e,onActivate:t,onDismiss:r}){if(!e)return null;const s=e,l=s.commandName?`${s.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),r()}function h(p){p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(s)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:s.tabTitle}),m.jsx("span",{children:l})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:p=>p.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const C5=rc(0,0,1,1),es=1e-6;function x5(e){return kC(e).map(t=>t.terminalId)}function kC(e){return nc(e,C5).sort(D5).map((t,r)=>({...t,index:r+1}))}function k5(e,t,r){const s=kC(e),l=s.find(h=>h.terminalId===t);return l?s.filter(h=>h.terminalId!==t).map(h=>T5(l,h,r)).filter(h=>h!==null).sort(R5)[0]?.entry.terminalId??null:null}function E5(e,t){return!Number.isInteger(t)||t<1?null:x5(e)[t-1]??null}function nc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const r=M5(e.ratio);if(e.direction==="vertical"){const l=t.left+(t.right-t.left)*r;return[...nc(e.first,rc(t.left,t.top,l,t.bottom)),...nc(e.second,rc(l,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*r;return[...nc(e.first,rc(t.left,t.top,t.right,s)),...nc(e.second,rc(t.left,s,t.right,t.bottom))]}function T5(e,t,r){const s=e.bounds,l=t.bounds,c=K0(s.left,s.right,l.left,l.right),h=K0(s.top,s.bottom,l.top,l.bottom);switch(r){case"left":return l.centerX>=s.centerX-es||h<=es?null:{entry:t,primaryDistance:Math.max(0,s.left-l.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"right":return l.centerX<=s.centerX+es||h<=es?null:{entry:t,primaryDistance:Math.max(0,l.left-s.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"up":return l.centerY>=s.centerY-es||c<=es?null:{entry:t,primaryDistance:Math.max(0,s.top-l.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};case"down":return l.centerY<=s.centerY+es||c<=es?null:{entry:t,primaryDistance:Math.max(0,l.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};default:return null}}function D5(e,t){return Ll(e.bounds.top,t.bounds.top)||Ll(e.bounds.left,t.bounds.left)}function R5(e,t){return Ll(e.primaryDistance,t.primaryDistance)||Ll(e.perpendicularDistance,t.perpendicularDistance)||Ll(t.overlap,e.overlap)||Ll(e.entry.index,t.entry.index)}function Ll(e,t){const r=e-t;return Math.abs(r)<=es?0:r}function K0(e,t,r,s){return Math.max(0,Math.min(t,s)-Math.max(e,r))}function rc(e,t,r,s){return{left:e,top:t,right:r,bottom:s,centerX:e+(r-e)/2,centerY:t+(s-t)/2}}function M5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class N5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function W0(e){return e?Array.from(e.types??[]).includes("Files")||RC(e.items).some(r=>r.kind==="file")?!0:MC(e.files).length>0:!1}async function A5(e){const t=RC(e.items).filter(r=>r.kind==="file");return t.length>0?L5(t):B5(e.files)}async function L5(e){const t=[];for(const r of e){const s=P5(r);if(s){await EC(s,"",t);continue}const l=r.getAsFile();if(l){t.push({relativePath:TC(l),file:l});continue}throw new N5("Folder upload is not supported by this browser.")}return t}function B5(e){return MC(e).map(t=>({relativePath:TC(t),file:t}))}async function EC(e,t,r){const s=I5(t,e.name);if(e.isFile){const h=await O5(e);r.push({relativePath:s,file:h});return}if(!e.isDirectory)return;const l=e.createReader(),c=await z5(l);for(const h of c)await EC(h,s,r)}function O5(e){return new Promise((t,r)=>{e.file(t,s=>r(s))})}async function z5(e){const t=[];for(;;){const r=await j5(e);if(r.length===0)return t;t.push(...r)}}function j5(e){return new Promise((t,r)=>{e.readEntries(t,s=>r(s))})}function TC(e){const t=e.webkitRelativePath;return DC(typeof t=="string"&&t?t:e.name)}function P5(e){const t=e.webkitGetAsEntry?.();return H5(t)?t:null}function H5(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 I5(e,t){return DC(e?`${e}/${t}`:t)}function DC(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function RC(e){return e?Array.from(e):[]}function MC(e){return e?Array.from(e):[]}const F0="nterminal.terminalWorkspaces.v2",NC="nterminal.sidebarCollapsed.v1",U5=75,q0=kw.map(e=>e.url),K5=kw[0].url,W5=6;function F5({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s,sessionExpiresAt:l=null,previewMode:c=!1,onLogout:h=async()=>{},onSessionInvalid:p}){const g=v.useMemo(()=>e??Hh(),[e]),f=v.useMemo(()=>t??dc(null),[t]),b=v.useMemo(()=>oL(r),[r]),y=v.useMemo(()=>x=>CC(r,x),[r]),S=v.useMemo(()=>()=>zt(r),[r]),w=v.useSyncExternalStore(y,S,S),k=w.state,E=w.editors,L=!w.loaded,A=w.error,[B,Y]=v.useState(!1),[P,q]=v.useState(()=>mL()),[re,ie]=v.useState("servers"),[he,ve]=v.useState(!1),U=v.useSyncExternalStore(xT,_S,_S);v.useSyncExternalStore(wh,gS,gS);const[K,W]=v.useState(0),[H,j]=v.useState(null),[le,R]=v.useState(()=>[null]),[X,Z]=v.useState(0),[Ce,Te]=v.useState(()=>[r]),[M,Q]=v.useState(()=>new Set),[de,me]=v.useState({}),[ge,Se]=v.useState(null),Ee=v.useRef(0),De=v.useRef(0),[Ue,se]=v.useState(null),[pe,Le]=v.useState(null),ye=v.useRef(null),Me=v.useRef(0),Pe=v.useRef(null),ze=v.useRef(null),te=v.useRef(null),[ke,Re]=v.useState(null),Be=rE(Qb(_w,{activationConstraint:{distance:8}}),Qb(vw,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>kT(g),[g]);function je(x){const T=x.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){Re({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&Re({tabId:T.sourceTabId,terminalId:T.terminalId})}}function at(x){Re(null);const T=x.active.data.current,z=x.over?.data.current;if(!(!T||!z||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){Qe({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){Qe({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&Qe({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){Qe({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){Qe({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&Qe({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Wt(){Re(null)}const $e=k.workspaces.find(x=>x.id===k.activeWorkspaceId)??k.workspaces[0],kt=$e?.tabs.find(x=>x.id===$e.activeTabId)??$e?.tabs[0],ei=kt?.activeTerminalId??null,Et=ei?k.terminals[ei]:void 0,_e=sL("(max-width: 760px)"),We=v.useMemo(()=>kt?zh(kt.root):[],[kt]),Je=$e&&kt?sc(r,$e.id,kt.id):null,ct=kt?AC(We,kt.activeTerminalId,Je?de[Je]:void 0):null,Pt=_e&&We.length>1,Tt=v.useMemo(()=>($e?.detachedTerminalIds??[]).flatMap(x=>{const T=k.terminals[x];return T?[T]:[]}),[$e?.detachedTerminalIds,k.terminals]),Lt=v.useMemo(()=>{const x=new Set;for(const T of $e?.tabs??[])Sc(T).some(z=>w.unreadCompletions.has(z))&&x.add(T.id);return x},[$e?.tabs,w.unreadCompletions]),[Dt,F]=v.useState([]),Ie=v.useRef([]),it=v.useRef(null),[hi,Gi]=v.useState(null),[Ci,St]=v.useState(null),[wt,Yt]=v.useState([]),[Ft,Ai]=v.useState(()=>Pa()),ti=v.useRef(0),di=v.useRef(r),Xt=v.useRef(q0),qt=v.useRef(Ft),Wi=v.useRef(()=>{});Wi.current=li;const gt=v.useCallback(async()=>{try{const x=await g.listNotificationAssets();Yt(x.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Yt([])}},[g]);v.useEffect(()=>{Te(x=>x.some(T=>yn(T,r))?x:[...x,r])},[r]);const Gt=v.useCallback(x=>{const T=zt(x),z=dc(x);for(const ne of Object.keys(T.state.terminals))tc(z.createWebSocketUrl(ne)),Qu(ne);a5(x),Te(ne=>ne.filter(be=>!yn(be,x))),Q(ne=>{const be=`${mh(x)}:`;let ae=!1;const we=new Set;for(const qe of ne){if(qe.startsWith(be)){ae=!0;continue}we.add(qe)}return ae?we:ne}),me(ne=>{const be=`${mh(x)}:`;let ae=!1;const we={};for(const[qe,nt]of Object.entries(ne)){if(qe.startsWith(be)){ae=!0;continue}we[qe]=nt}return ae?we:ne})},[]);v.useEffect(()=>{let x=!1;return g.listAgents().then(T=>{if(!x){const z=T.agents.map(be=>be.id),ne=[null,...z];r!==null&&!z.includes(r)&&(Gt(r),s?.(null)),R(ne)}}).catch(()=>{}),()=>{x=!0}},[r,g,Gt,s,X]);const ln=v.useCallback(x=>{Gt(x),Z(T=>T+1),yn(x,di.current)&&s?.(null)},[Gt,s]);v.useEffect(()=>{R(x=>x.some(T=>yn(T,r))?x:[...x,r])},[r]),v.useEffect(()=>{di.current=r},[r]),v.useEffect(()=>{j(null)},[r]),v.useEffect(()=>{const x=Pe.current;if(!x)return;if(!yn(x.agentId,r)){Pe.current=null;return}if(!w.loaded||k.workspaces.length===0)return;Pe.current=null;const T=x.edge==="first"?k.workspaces[0]:k.workspaces[k.workspaces.length-1];T&&T.id!==k.activeWorkspaceId&&Qe({type:"workspace.selected",workspaceId:T.id})},[r,w.loaded,k.activeWorkspaceId,k.workspaces]),v.useEffect(()=>{const x=ze.current;if(x){if(!yn(x.agentId,r)){ze.current=null;return}w.loaded&&(ze.current=null,k.workspaces.some(T=>T.id===x.workspaceId)&&Qe({type:"workspace.selected",workspaceId:x.workspaceId}))}},[r,w.loaded,k.workspaces]),v.useEffect(()=>{const x=te.current;if(x){if(!yn(x.agentId,r)){te.current=null;return}w.loaded&&(te.current=null,w.error||Li())}},[r,w.error,w.loaded]),v.useEffect(()=>{gt()},[gt]),v.useEffect(()=>Tw(()=>Ai(Pa())),[]),v.useEffect(()=>{const x=T=>{Wi.current(T)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{Xt.current=wt.length>0?wt:q0},[wt]),v.useEffect(()=>{qt.current=Ft},[Ft]),v.useEffect(()=>{if(!w.loaded||!$e||!kt)return;const x=sc(r,$e.id,kt.id);Q(T=>{if(T.has(x))return T;const z=new Set(T);return z.add(x),z})},[r,w.loaded,$e?.id,kt?.id]),v.useEffect(()=>()=>{Xa()},[]),v.useEffect(()=>N2(g),[g]),v.useEffect(()=>e5(x=>{const T=zt(x.agentId).state,z=T.workspaces.flatMap(we=>we.tabs).find(we=>we.id===x.tabId),ne=T.terminals[x.terminalId],be=z?.title?.trim()||ne?.title||x.commandName||"terminal",ae=document.visibilityState==="visible"&&yn(x.agentId,di.current)&&x.tabId===lL(T);if(ae||k2({tabTitle:be,commandName:x.commandName,terminalId:x.terminalId}),!ae&&document.visibilityState==="visible"&&qt.current.enabled){const we=ti.current+1;ti.current=we;const qe=Xt.current;Gi({id:we,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:be,commandName:x.commandName,assetSrc:qe[Math.floor(Math.random()*qe.length)]??K5})}}),[]),v.useEffect(()=>{if(!hi||Ft.persistUntilDismissed)return;const x=window.setTimeout(()=>{Gi(T=>T?.id===hi.id?null:T)},Ft.durationSeconds*1e3);return()=>window.clearTimeout(x)},[hi,Ft]),v.useEffect(()=>{gL(P),P&&Qi()},[P]),v.useEffect(()=>{let x=!1;async function T(){if(!zt(r).loaded){Us(r,!1,null);try{let ne=null,be=null;try{ne=cL(b)}catch(nt){if(!(nt instanceof Ph))throw nt;be=nt}const[ae,we]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),qe=ae.terminals.length>0?ae.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!x){const nt=we.layout?BC(we.layout):null;if(!nt&&be)throw be;const fi=nt??ne??{},_t=ig(qe,void 0,fi.savedWorkspaces,fi.savedActiveWorkspaceId),ps=Bp(_t);H0(r,_t),$o(r,we.revision,JSON.stringify(ps)),Us(r,!0,null),!nt&&ne&&lr(ps,{baseRevision:we.revision})}}catch(ne){!x&&!Br(ne)&&Us(r,!0,Ks(ne))}}}return T(),()=>{x=!0}},[r,f,K]);function Zi(){Us(r,!1,null),W(x=>x+1)}function Qi(){Ee.current+=1,De.current+=1,Se(null)}function dn(x){Ee.current+=1,De.current+=1,Se(T=>T&&{...T,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Li(){Ee.current+=1,De.current+=1;const x=k.workspaces.length+1,T=Sn();Se({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&ss(T)}function ii(x){if(yn(x,r)){Li();return}te.current={agentId:x},s?.(x)}function xi(x){if(P&&!B)return;const T=k.workspaces.find(ne=>ne.id===x);if(!T)return;Ee.current+=1,De.current+=1;const z=T.defaultCwd??Et?.cwd??"";Se({mode:"edit",workspaceId:x,title:T.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&ss(z)}function Sn(){return $e?.defaultCwd??Et?.cwd??""}async function ss(x){const T=Ee.current+1;Ee.current=T;const z=x.trim();if(Se(ne=>ne&&{...ne,cwd:x,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const ne=await f.createFileRoot({path:z}),be=await f.listFiles({rootToken:ne.rootToken,path:""});if(Ee.current!==T)return;Se(ae=>ae&&{...ae,cwd:ne.rootPath,browseRoot:{rootToken:ne.rootToken,rootPath:ne.rootPath},browseEntries:be.entries.filter(we=>we.kind==="directory"),browseStatus:"idle",error:null})}catch(ne){if(Ee.current!==T)return;Se(be=>be&&{...be,browseStatus:"idle",error:Ks(ne)})}}async function Ji(){const x=ge;if(!x)return;const T=x.title.trim(),z=x.cwd.trim();if(!T||!z){Se({...x,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const ne=De.current+1;De.current=ne,Se({...x,submitStatus:"submitting",error:null});try{const be=await f.createFileRoot({path:z});if(De.current!==ne)return;if(x.mode==="create"){const ae=k.workspaces.length+1;Qe({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ae}`,title:T,defaultCwd:be.rootPath})}else x.workspaceId&&(Qe({type:"workspace.renamed",workspaceId:x.workspaceId,title:T}),Qe({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:be.rootPath}));Se(null)}catch(be){if(De.current!==ne)return;Se(ae=>ae&&{...ae,submitStatus:"idle",error:Ks(be)})}}function Xl(x){De.current+=1,Se(x)}function as(x,T,z){if(x===T)return;const ne=k.workspaces.some(ae=>ae.id===x),be=k.workspaces.some(ae=>ae.id===T);!ne||!be||Qe({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:T,placement:z})}function Lr(x,T){const z=k.workspaces.findIndex(be=>be.id===x),ne=k.workspaces[z+T];z<0||!ne||as(x,ne.id,T<0?"before":"after")}function ls(x,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),ye.current={sourceId:x,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function On(x){const T=ye.current;if(!T||T.pointerId!==x.pointerId)return;const z=Math.hypot(x.clientX-T.startX,x.clientY-T.startY);if(!T.active){if(z<W5)return;T.active=!0,se(T.sourceId)}const be=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),ae=be?.dataset.workspaceId??null;if(!be||!ae||ae===T.sourceId||!k.workspaces.some(nt=>nt.id===ae)){T.targetId=null,Le(null);return}const we=be.getBoundingClientRect(),qe=x.clientY<we.top+we.height/2?"before":"after";T.targetId=ae,T.placement=qe,Le({workspaceId:ae,placement:qe})}function mr(x){const T=ye.current;!T||T.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),ye.current=null,se(null),Le(null),T.active&&T.targetId&&as(T.sourceId,T.targetId,T.placement))}function gr(x){const T=ye.current;T&&T.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),ye.current=null,se(null),Le(null)}async function zn(){await nr(async()=>{const x=$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},T=await f.createTerminal(x);Qe({type:"terminal.created",terminal:T.terminal})})}async function Bt(x){await nr(async()=>{const T=ei?{parentTerminalId:ei,cols:80,rows:24}:$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},z=await f.createTerminal(T);Qe({type:"terminal.split",terminal:z.terminal,direction:x})})}async function $a(x){let T=ei,z=Je;const ne=$e?.defaultCwd?.trim();if(!T&&!ne)throw new Error("No active pane is available.");const be=await f.readFile(x);if(!T&&ne){const qe=await f.createTerminal({cols:80,rows:24,cwd:ne});T=qe.terminal.id,Qe({type:"terminal.created",terminal:qe.terminal})}if(T){Qe({type:"pane.selected",terminalId:T});const qe=zt(r).state,nt=qe.workspaces.find(_t=>_t.id===qe.activeWorkspaceId)??qe.workspaces[0],fi=nt?.tabs.find(_t=>_t.id===nt.activeTabId)??nt?.tabs[0];z=nt&&fi?sc(r,nt.id,fi.id):null}const ae=`editor-${Date.now().toString(36)}-${s5(r)}`,we=pL(be.path);Op(r,qe=>({...qe,[ae]:{id:ae,title:we,rootToken:x.rootToken,path:be.path,read:be}})),z&&me(qe=>({...qe,[z]:LC(ae)})),Qe({type:"editor.split",editorId:ae,title:we,direction:"vertical"})}function ea(x){Op(r,T=>{const z={...T};return delete z[x],z}),Qe({type:"editor.closed",editorId:x})}function tr(x){ir([x])}function ir(x){const T=[...new Set(x)].filter(ne=>k.terminals[ne]);if(T.length===0)return;const z=T.length===1?k.terminals[T[0]]?.title||k.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;j(null),St({terminalIds:T,label:z,workspaceId:$e?.id??k.activeWorkspaceId??null})}function Gl(x,T){const z=sa(x,T);if(!z)return!1;const ne=x.filter(be=>!z.detachedTerminalIds.includes(be));if(z.detachedTerminalIds.length+ne.length>Fl)return j(hL(z.detachedTerminalIds.length)),!1;j(null);for(const be of x)Qe(z.id?{type:"terminal.detached",terminalId:be,workspaceId:z.id}:{type:"terminal.detached",terminalId:be});return!0}async function ta(x){await nr(async()=>{for(const T of x)await Fi(T),tc(f.createWebSocketUrl(T)),Qu(T),Qe({type:"terminal.closed",terminalId:T})})}async function ia(x){const T=k.workspaces.find(z=>z.id===x);!T||k.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await nr(async()=>{const z=Oh(T),ne=[];let be=null;for(const we of z)try{await Fi(we)}catch(qe){ne.push(Ks(qe)),qe instanceof dr&&qe.status===401&&!f.isAgent&&(be=qe)}finally{tc(f.createWebSocketUrl(we)),Qu(we)}const ae=T.tabs.flatMap(we=>pg(we.root));if(ae.length>0){const we=new Set(ae);Op(r,qe=>{const nt={...qe};for(const fi of we)delete nt[fi];return nt})}if(Qe({type:"workspace.closed",workspaceId:x}),be)throw be;if(ne.length>0)throw new Error(`Workspace was removed, but ${ne.length} terminal session${ne.length===1?"":"s"} may still be running. ${ne[0]}`)})}async function Zl(x){await nr(async()=>{await Fi(x),tc(f.createWebSocketUrl(x)),Qu(x),Qe({type:"terminal.closed",terminalId:x})})}async function os(x,T){const z=T.trim();if(!z)return;let ne=null;for(const be of k.workspaces){const ae=be.tabs.find(we=>we.id===x);if(ae){ne=ae.activeTerminalId;break}}if(Qe({type:"tab.renamed",tabId:x,title:z}),!!ne)try{const be=await f.renameTerminal(ne,z);_r({type:"terminal.updated",terminal:be.terminal})}catch(be){Us(r,!0,Ks(be))}}function cs(x){const T=k.terminals[x];T&&Qe({type:"terminal.created",terminal:T})}async function Fi(x){try{await f.closeTerminal(x)}catch(T){if(T instanceof dr&&T.status===404)return;throw T}}async function en(){await nr(async()=>{await h()})}async function nr(x){Us(r,!0,null);try{await x()}catch(T){if(Br(T))return;Us(r,!0,Ks(T))}}function Br(x){return x instanceof dr&&x.status===401&&!f.isAgent&&p?(p({source:"workspace-api-401",status:401,activeAgentId:r}),!0):!1}function Qe(x){qo(r,x);const T=zt(r),z=T.state;if(!T.loaded||z.workspaces.length===0)return;const ne=Bp(z);JSON.stringify(ne)!==T.lastPersistedLayoutJson&&ds(ne)}function _r(x){qo(r,x)}function Ht(x,T,z,ne){const be=sc(x,T,z);me(ae=>({...ae,[be]:ne}))}function na(x){Je&&me(T=>({...T,[Je]:x}))}function Bi(x,T){const z=jh(x);T?Ht(r,T.workspaceId,T.tabId,z):na(z),Qe({type:"pane.selected",terminalId:x})}function rr(x){na(x.key),x.type==="terminal"&&Qe({type:"pane.selected",terminalId:x.terminalId})}function li(x){if(he||Ci||x.isComposing||x.key==="Process"||G5(x.target))return;const T=$5(x);if(!T)return;if(x.preventDefault(),x.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){sr(T.type==="server.next"?1:-1);return}const z=zt(r).state,ne=z.workspaces.find(we=>we.id===z.activeWorkspaceId)??z.workspaces[0],be=ne?.tabs.find(we=>we.id===ne.activeTabId)??ne?.tabs[0];if(T.type==="split"){if(!be)return;Bt(T.direction);return}if(!ne||!be)return;if(T.type==="tab.previous"||T.type==="tab.next"){const we=X5(ne.tabs,be.id,T.type==="tab.next"?1:-1);we&&Qe({type:"tab.selected",tabId:we.id});return}if(T.type==="tab.index"){const we=ne.tabs[T.index-1];we&&Qe({type:"tab.selected",tabId:we.id});return}const ae=V5(be.root,be.activeTerminalId,T);ae&&Bi(ae,{workspaceId:ne.id,tabId:be.id})}function us(x,T){if(!s||le.length===0)return;const z=le.findIndex(we=>yn(we,r)),be=((z===-1?0:z)+x+le.length)%le.length,ae=le[be]??null;yn(ae,r)||(T&&(Pe.current={agentId:ae,edge:T}),s(ae))}function sr(x){const T=zt(r).state,z=T.workspaces;if(z.length===0){us(x,x===1?"first":"last");return}const ne=z.findIndex(we=>we.id===T.activeWorkspaceId),ae=(ne===-1?0:ne)+x;if(ae>=0&&ae<z.length){Qe({type:"workspace.selected",workspaceId:z[ae].id});return}us(x,x===1?"first":"last")}function ra(x,T){if(yn(x,r)){Qe({type:"workspace.selected",workspaceId:T});return}ze.current={agentId:x,workspaceId:T},s?.(x)}function sa(x,T){if(T)return k.workspaces.find(z=>z.id===T)??null;for(const z of x){const ne=k.workspaces.find(ae=>ae.tabs.some(we=>Sc(we).includes(z)));if(ne)return ne;const be=k.workspaces.find(ae=>ae.detachedTerminalIds.includes(z));if(be)return be}return k.workspaces.find(z=>z.id===k.activeWorkspaceId)??k.workspaces[0]??null}function vr(x){W0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function Va(x){if(!W0(x.dataTransfer))return;x.preventDefault();const T=dL(zt(r).state),z=Me.current+1;if(Me.current=z,!T){aa({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}aa({id:z,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),jn(z,T.id,x.dataTransfer)}async function jn(x,T,z){try{const ne=await A5(z);if(ne.length===0)throw new Error("No files were found in the drop.");Pn(x,{id:x,status:"queued",fileCount:ne.length,message:"Queued"},{terminalId:T,files:ne})}catch(ne){Pn(x,{id:x,status:"failed",fileCount:0,message:Ks(ne)},{terminalId:T})}finally{yr()}}async function hs(x){const T=Ie.current.find(ae=>ae.id===x);if(!T?.terminalId||!T.files||T.files.length===0)return;const z=T.terminalId,ne=T.files,be=new AbortController;it.current=x,Pn(x,{id:x,status:"uploading",fileCount:ne.length,loaded:0,total:null,percent:null},{terminalId:z,files:ne,abortController:be});try{const ae=await jT({terminalId:z,files:ne,signal:be.signal,onProgress:fi=>{Pn(x,{id:x,status:"uploading",fileCount:ne.length,loaded:fi.loaded,total:fi.total,percent:fi.percent},{terminalId:z,files:ne,abortController:be})}}),we=ae.failed>0?ae.uploaded>0?"partial":"failed":"success",qe=ae.failed>0?fL(ae):void 0,nt={id:x,status:we,fileCount:ne.length,response:ae};qe&&(nt.message=qe),Pn(x,nt,{terminalId:z,files:ne})}catch(ae){Pn(x,{id:x,status:"failed",fileCount:ne.length,message:be.signal.aborted?"Upload canceled.":Ks(ae)},{terminalId:z,files:ne})}finally{it.current===x&&(it.current=null),yr()}}function yr(){if(it.current!==null)return;const x=Ie.current.find(T=>T.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&hs(x.id)}function aa(x){Hn(T=>[...T,x])}function Pn(x,T,z={}){Hn(ne=>ne.map(be=>{if(be.id!==x)return be;const ae={...T},we=z.terminalId??be.terminalId,qe=z.files??be.files;return we!==void 0&&(ae.terminalId=we),qe!==void 0&&(ae.files=qe),z.abortController!==void 0&&(ae.abortController=z.abortController),ae}))}function Hn(x){const T=x(Ie.current);Ie.current=T,F(T)}function tn(x){Ie.current.find(z=>z.id===x)?.abortController?.abort(),it.current===x&&(it.current=null),Hn(z=>z.filter(ne=>ne.id!==x)),yr()}function Or(){for(const x of Ie.current)x.abortController?.abort();it.current=null,Hn(()=>[])}function br(x){const T=Ie.current.find(z=>z.id===x);if(T){if(T.status==="queued"){tn(x);return}T.abortController?.abort()}}function Sr(x){const T=Ie.current.find(ne=>ne.id===x);if(!T?.terminalId||!T.files||T.files.length===0)return;const z=ar(T);if(z.length===0){Pn(x,{id:x,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Pn(x,{id:x,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:T.terminalId,files:z}),yr()}function ar(x){const T=x.files??[],z="response"in x?x.response:void 0;if(!z)return T;const ne=z.results.filter(we=>we.status==="failed").map(we=>we.relativePath);if(ne.length===0)return[];const be=new Map;for(const we of T){const qe=be.get(we.relativePath)??[];qe.push(we),be.set(we.relativePath,qe)}const ae=[];for(const we of ne){const nt=be.get(we)?.shift();nt&&ae.push(nt)}return ae}function Ya(x){const z=zt(x.agentId).state.workspaces.find(ne=>ne.tabs.some(be=>be.id===x.tabId));z&&Ht(x.agentId,z.id,x.tabId,jh(x.terminalId)),qo(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),r5(x.agentId,x.terminalId),yn(x.agentId,r)||s?.(x.agentId),Gi(null)}function ds(x){const T=zt(r).mutable.saveCoord;T.pendingLayoutSave=x,Vo(x,b),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const z=T.pendingLayoutSave;T.pendingLayoutSave=null,z&&lr(z)},U5)}function Xa(){const x=zt(r).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const T=x.pendingLayoutSave;x.pendingLayoutSave=null,T&&(Vo(T,b),lr(T))}function lr(x,T={}){const z=zt(r).mutable.saveCoord;z.nextPersistLayout=x,T.baseRevision!==void 0&&(z.queuedBaseRevision=T.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const ne=z.nextPersistLayout,be=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,ne&&await wn(ne,be!==void 0?{baseRevision:be}:{})}))}async function wn(x,T={}){const z=zt(r),ne=T.baseRevision??z.layoutRevision,be={layout:x,...typeof ne=="number"?{baseRevision:ne}:{}};try{const ae=await f.saveTerminalLayout(be),we=ae.layout??x;$o(r,ae.revision,JSON.stringify(we)),Vo(we,b);return}catch(ae){if(ae instanceof dr&&ae.status===400&&ae.message===h2){uL(r,b),Us(r,!0,OC());return}if(ae instanceof dr&&ae.status===409)try{const we=await f.getTerminalLayout(),qe=zt(r).mutable.saveCoord;if(qe.nextPersistLayout||qe.pendingLayoutSave){const nt=we.layout?JSON.stringify(we.layout):zt(r).lastPersistedLayoutJson;$o(r,we.revision,nt);return}if(we.layout){const nt=zt(r).state,fi=ig(Object.values(nt.terminals),void 0,we.layout.workspaces,we.layout.activeWorkspaceId),_t=Bp(fi);H0(r,fi),$o(r,we.revision,JSON.stringify(_t)),Vo(_t,b)}else $o(r,we.revision,z.lastPersistedLayoutJson);return}catch{}Vo(x,b)}}const wr=_L(l),ki=!P||B,nn=ki?re:"servers";function fs(x){const T=x.active?w:zt(x.agentId),z=x.active?k:T.state,ne=x.active?w.loaded:T.loaded,be=x.active?A:T.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:()=>ii(x.agentId),children:"+"})]}),ne?be?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(x.agentId),children:be}):m.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(ae=>{const we=x.active&&ae.id===$e?.id,qe=Oh(ae).length,nt=x.active&&z.workspaces.length>1,fi=pe?.workspaceId===ae.id&&Ue!==ae.id?pe.placement:null;return m.jsxs(tL,{workspaceId:ae.id,active:we,disabled:!x.active,reorderable:nt,dragging:Ue===ae.id,dropPlacement:fi,children:[nt?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ae.id,title:"Drag to reorder","aria-label":`Reorder ${ae.title}`,"aria-grabbed":Ue===ae.id,onPointerDown:_t=>ls(ae.id,_t),onPointerMove:On,onPointerUp:mr,onPointerCancel:gr,onKeyDown:_t=>{(_t.key==="ArrowUp"||_t.key==="ArrowDown")&&(_t.preventDefault(),_t.stopPropagation(),Lr(ae.id,_t.key==="ArrowUp"?-1:1))},onClick:_t=>_t.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":we?"page":void 0,title:ae.defaultCwd??void 0,onClick:()=>ra(x.agentId,ae.id),onDoubleClick:()=>{x.active&&xi(ae.id)},children:[m.jsx("span",{className:"workspace-list-name",children:ae.title}),m.jsxs("small",{children:[ae.defaultCwd??"No folder"," · ",qe," ",qe===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 ${ae.title}`,title:"Edit workspace",onClick:()=>xi(ae.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ae.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{ia(ae.id)},children:"x"})]}):null]},ae.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(r2,{sensors:Be,onDragStart:je,onDragEnd:at,onDragCancel:Wt,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":P,"data-sidebar-open":B,onDragOver:vr,onDrop:Va,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[m.jsxs("div",{className:"workspace-brand-lockup",children:[ki?m.jsx(iw,{height:20}):m.jsx(tw,{size:24}),c&&ki?m.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":P?"Expand sidebar":"Collapse sidebar",title:P?"Expand sidebar":"Collapse sidebar",onClick:()=>q(x=>!x),children:P?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${nn==="files"?"files":"servers"}`,children:[ki?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":re==="servers",onClick:()=>{ie("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":re==="files",onClick:()=>{ie("files")},children:"Files"})]}):null,nn==="servers"&&ki?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(mS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,renderServerChildren:fs})}):null,ki?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(mS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,compact:!0})}),nn==="files"?m.jsx(KT,{api:f,activeTerminalId:ei,activeTerminalCwd:Et?.cwd??null,workspaceRootPath:$e?.defaultCwd??Et?.cwd??null,onOpenFile:$a}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[ki?m.jsx("span",{children:wr}):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:()=>ve(!0),children:[m.jsx(V0,{name:"settings"}),U.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),ki?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{en()},children:m.jsx(V0,{name:"logout"})}):null]})]})]}),he?m.jsx(BT,{api:g,onClose:()=>ve(!1),updateAvailable:U.hasUpdates,onNotificationAssetsChanged:()=>{gt()},onAgentRemoved:ln}):null,ge?m.jsx(Z5,{dialog:ge,activePaneCwd:Et?.cwd??null,activeWorkspaceCwd:$e?.defaultCwd??null,onChange:Xl,onManualCwdChange:dn,onBrowse:ss,onCancel:Qi,onSubmit:()=>{Ji()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":Pt?"true":void 0,children:[m.jsx(u5,{tabs:$e?.tabs??[],activeTabId:$e?.activeTabId??null,terminals:k.terminals,unreadCompletionTabIds:Lt,detachedTerminals:Tt,onSelectTab:x=>Qe({type:"tab.selected",tabId:x}),onCreateTab:()=>{zn()},onToggleWorkspaces:()=>Y(x=>!x),onCloseTerminals:x=>ir(x),onReattachTerminal:x=>cs(x),onDeleteTerminal:x=>{Zl(x)},onSplitVertical:()=>{Bt("vertical")},onSplitHorizontal:()=>{Bt("horizontal")},onRenameTab:(x,T)=>{os(x,T)},activePaneAvailable:!!ei}),Pt?m.jsx(nL,{targets:We,activeLeafKey:ct,terminals:k.terminals,editors:E,onSelect:rr}):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:Zi,children:"Retry"}),r!==null&&s?m.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!kt?m.jsx(eL,{onCreate:()=>{zn()}}):null,Ce.map(x=>{const T=yn(x,r);return m.jsx(q5,{agentId:x,active:T,activeServerApi:T?f:void 0,visitedTabKeys:M,refreshCwdOnEnter:T&&nn==="files",draggingTab:T?ke:null,mobileSplitFocus:_e,mobileFocusedLeafByTabKey:de,onSelect:z=>{T&&Bi(z)},onClose:z=>{T&&tr(z)},onCloseEditor:z=>{T&&ea(z)},onResize:(z,ne)=>{T&&Qe({type:"pane.resized",path:z,ratio:ne})},onExit:(z,ne)=>{T?_r({type:"terminal.exited",terminalId:z,exitCode:ne}):qo(x,{type:"terminal.exited",terminalId:z,exitCode:ne})},onSnapshot:(z,ne)=>{const be={type:"terminal.updated",terminal:z,notifyCompletion:ne?.notifyCompletion===!0};T?_r(be):qo(x,be)},...x===null&&p?{onAuthClose:z=>p({...z,source:z?.source??"terminal-ws-1008",activeAgentId:x})}:{}},mh(x))})]}),Ci?m.jsx(iL,{label:Ci.label,count:Ci.terminalIds.length,warning:H,onCancel:()=>{j(null),St(null)},onHide:()=>{Gl(Ci.terminalIds,Ci.workspaceId)&&St(null)},onDelete:()=>{const x=Ci.terminalIds;j(null),St(null),ta(x)}}):null,m.jsx(w5,{toast:hi,onActivate:Ya,onDismiss:()=>Gi(null)}),m.jsx(m5,{uploads:Dt,onDismiss:tn,onDismissAll:Or,onRetry:Sr,onCancel:br})]})]})})}function q5({agentId:e,active:t,activeServerApi:r,visitedTabKeys:s,refreshCwdOnEnter:l,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,onAuthClose:k}){const E=v.useMemo(()=>ve=>CC(e,ve),[e]),L=v.useMemo(()=>()=>zt(e),[e]),A=v.useSyncExternalStore(E,L,L),B=v.useMemo(()=>dc(e),[e]),Y=r??B,P=A.state,q=P.workspaces.find(ve=>ve.id===P.activeWorkspaceId)??P.workspaces[0],re=q?.id??null,he=(q?.tabs.find(ve=>ve.id===q.activeTabId)??q?.tabs[0])?.id??null;return!A.loaded||P.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:P.workspaces.flatMap(ve=>ve.tabs.map(U=>{const K=t&&ve.id===re&&U.id===he,W=sc(e,ve.id,U.id),H=zh(U.root),j=h&&H.length>1?AC(H,U.activeTerminalId,p[W]):null;return!K&&!s.has(W)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":K,"aria-hidden":!K,children:m.jsx(Jm,{node:U.root,terminals:P.terminals,editors:A.editors,api:Y,activeTerminalId:U.activeTerminalId,visible:K,refreshCwdOnEnter:K&&l,tabId:U.id,dropZoneActive:K&&c!==null,draggingTerminalId:K?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,...k?{onAuthClose:k}:{}})},`${ve.id}:${U.id}`)}))})}function $5(e){const t=Uw(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 r=Y5(e.key);return r?{type:"pane.direction",direction:r}:null}return null}function V5(e,t,r){switch(r.type){case"pane.direction":return k5(e,t,r.direction);case"pane.index":return E5(e,r.index);default:return null}}function Y5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function X5(e,t,r){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+r+e.length)%e.length]??null}function zh(e){return e.type==="pane"?[{key:jh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:LC(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...zh(e.first),...zh(e.second)]}function pg(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...pg(e.first),...pg(e.second)]}function AC(e,t,r){if(r&&e.some(l=>l.key===r))return r;const s=t?jh(t):null;return s&&e.some(l=>l.key===s)?s:e[0]?.key??null}function jh(e){return`terminal:${e}`}function LC(e){return`editor:${e}`}function G5(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 Z5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:r,onChange:s,onManualCwdChange:l,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function y(w){s(k=>k&&{...k,...w})}function S(w){w&&(y({cwd:w,error:null}),c(w))}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:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||p()},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:b,onChange:w=>y({title:w.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:b,onChange:w=>l(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(r),disabled:b||!r,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(J5(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{c(Q5(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.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:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function Q5(e,t){return t?t.startsWith("/")?ph(t):ph(`${e||"/"}/${t}`):ph(e)}function J5(e){const t=ph(e);if(!t||t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function ph(e){const t=e.trim();if(!t)return"";const r=t.replace(/\/+/g,"/");return r==="/"?"/":r.endsWith("/")?r.slice(0,-1):r}function eL({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 tL({workspaceId:e,active:t,disabled:r=!1,reorderable:s=!1,dragging:l=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=Dg({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:r}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",l?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function iL({label:e,count:t,warning:r,onCancel:s,onHide:l,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,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:s,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."}),r?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:r}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:l,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function nL({targets:e,activeLeafKey:t,terminals:r,editors:s,onSelect:l}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(S=>S.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],b=$0(f,r,s);function y(S){const w=(g+S+e.length)%e.length,k=e[w];k&&l(k)}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:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(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:S=>S.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((S,w)=>{const k=$0(S,r,s),E=rL(S,r,s),L=S.key===f.key;return m.jsxs("button",{type:"button","data-active":L,onClick:()=>{l(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:k}),m.jsx("small",{children:E})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function $0(e,t,r){if(e.type==="editor")return r[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function rL(e,t,r){if(e.type==="editor"){const c=r[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function sL(e){const[t,r]=v.useState(()=>aL(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){r(!1);return}const s=window.matchMedia(e),l=()=>r(s.matches);return l(),typeof s.addEventListener=="function"?(s.addEventListener("change",l),()=>s.removeEventListener("change",l)):(s.addListener(l),()=>s.removeListener(l))},[e]),t}function aL(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function yn(e,t){return e===t}function lL(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function mh(e){return e??"__local__"}function sc(e,t,r){return`${mh(e)}:${t}:${r}`}class Ph extends Error{constructor(){super(OC())}}function oL(e){return e?{workspaceKey:`${F0}:${e}`}:{workspaceKey:F0}}function cL(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const r=JSON.parse(t);if(xw(r))throw new Ph;const s=Cw(r);return s?BC(s):null}catch(r){if(r instanceof Ph)throw r;return null}}function BC(e){if(xw(e))throw new Ph;const t=Cw(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Vo(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function uL(e,t){const r=zt(e).lastPersistedLayoutJson;if(r){localStorage.setItem(t.workspaceKey,r);return}localStorage.removeItem(t.workspaceKey)}function hL(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Fl}. Re-open or delete hidden sessions before hiding more.`}function OC(){return`A saved terminal layout has more than ${Fl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function dL(e){const t=e.workspaces.find(l=>l.id===e.activeWorkspaceId)??e.workspaces[0],r=t?.tabs.find(l=>l.id===t.activeTabId)??t?.tabs[0],s=r?e.terminals[r.activeTerminalId]:void 0;return s?.status==="running"?s:null}function fL(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function pL(e){return e.split("/").filter(Boolean).pop()??e}function mL(){try{return localStorage.getItem(NC)==="true"}catch{return!1}}function gL(e){try{localStorage.setItem(NC,e?"true":"false")}catch{}}function _L(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const r=t-Date.now();if(r<=0)return"session · expired";const s=Math.max(1,Math.floor(r/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function V0({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 Ks(e){return e instanceof Error?e.message:"Request failed"}function vL({api:e,onDone:t}){const[r,s]=v.useState(null),[l,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let E=!1;return e.setupTotp().then(L=>{E||(s(L.qrDataUrl),c(L.secret))}).catch(L=>{E||w(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{E=!0}},[e]);async function k(E){if(E.preventDefault(),!!l){f(!0),y(null);try{await e.activateTotp({secret:l,otp:h}),t()}catch(L){y(L instanceof Error?L.message:"Verification failed")}finally{f(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!r||!l?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:r,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:l})]}),m.jsxs("form",{className:"auth-form",onSubmit:k,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:E=>p(E.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?m.jsx("p",{className:"form-error",children:b}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}const zC="nterminal.clientDiagnostics.v1",jC=150,yL=24,bL=160;let Y0=!1,Yo=null;function SL(){Y0||typeof window>"u"||(Y0=!0,Ln("page.load",{navigation:NL(),visibility:document.visibilityState,online:navigator.onLine,viewport:IC(),standalone:ML()}),document.addEventListener("visibilitychange",()=>{Ln("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Ln("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Ln("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Ln("network.online")),window.addEventListener("offline",()=>Ln("network.offline")),window.addEventListener("focus",()=>Ln("window.focus")),window.addEventListener("blur",()=>Ln("window.blur")),window.addEventListener("error",e=>{Ln("runtime.error",{message:e.message,source:AL(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Ln("runtime.unhandledrejection",{reason:LL(e.reason)})}))}function Ln(e,t={}){const r={at:new Date().toISOString(),event:nd(e,80),data:HC({...t,visibility:t.visibility??DL(),online:t.online??RL(),viewport:t.viewport??IC()})},s=PC();return s.push(r),wL(s.slice(-jC)),r}function PC(){try{const e=window.localStorage.getItem(zC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(CL).filter(r=>r!==null).slice(-jC):[]}catch{return[]}}async function d_(e,t=fetch){if(Yo)return Yo;const r=PC(),s={reason:nd(e,80),events:r},l=JSON.stringify(s);Yo=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:l.length<48e3,body:l});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Yo}finally{Yo=null}}function wL(e){try{window.localStorage.setItem(zC,JSON.stringify(e))}catch{}}function CL(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:nd(t.event,80),...t.data&&typeof t.data=="object"?{data:HC(t.data)}:{}}}function HC(e){const t={};for(const[r,s]of Object.entries(e).slice(0,yL)){const l=nd(r,64);if(!l||xL(l))continue;const c=kL(s);c!==void 0&&(t[l]=c)}return t}function xL(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function kL(e){if(typeof e=="string")return EL(e,bL);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function nd(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function EL(e,t){return TL(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function TL(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 DL(){return typeof document>"u"?void 0:document.visibilityState}function RL(){return typeof navigator>"u"?void 0:navigator.onLine}function IC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function ML(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function NL(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function AL(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 LL(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function BL(e){return{source:jp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:jp(e.terminalId)}:{},...e?.detail?{detail:jp(e.detail)}:{}}}function OL(e){return{invalidationSource:e.source}}function zL(e){Ln("auth.session_invalid.request",UC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),d_("session-invalid-request").catch(()=>{}))}function jL(e,t){Ln("auth.session_invalid.result",{...UC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),d_("session-invalid-result").catch(()=>{}))}function UC(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 jp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function PL({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s}){const l=v.useMemo(()=>e??Hh(),[e]),c=v.useMemo(()=>t??dc(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let A=!1;return l.getSession().then(B=>{A||(p(B),f(null))}).catch(B=>{A||(f(ja(B)),p(null))}),()=>{A=!0}},[l]);const S=KL(h);v.useEffect(()=>{const A=y.current;Ln("auth.view",{view:S,previousView:A,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),A==="workspace"&&S!=="workspace"&&d_(`auth-left-workspace-${S}`).catch(()=>{}),y.current=S},[h,S]);async function w(){const A=await l.getSession();p(A),f(null)}async function k(){Rp(),zp(),w0(),f(null),p(null);try{await w()}catch(A){f(ja(A))}}function E(A){const B=BL(A);if(zL(B),b.current)return b.current;const Y=(async()=>{f(null);try{const P=await l.getSession(OL(B));if(jL(B,P.authenticated),p(P),P.authenticated){uA();return}Rp(),zp(),w0()}catch(P){f(ja(P))}finally{b.current=null}})();return b.current=Y,Y}if(S==="workspace")return m.jsx(F5,{api:l,serverApi:c,activeAgentId:r,onSelectServer:s,sessionExpiresAt:h?.expiresAt??null,previewMode:h?.previewMode===!0,onSessionInvalid:A=>{E(A)},onLogout:async()=>{Rp(),zp();const A=await l.logout();p(A)}});const L={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":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(tw,{size:26}),m.jsxs("div",{children:[m.jsx(iw,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:L[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},children:"Retry"}):null,S==="setup_password"?m.jsx(HL,{api:l,onSession:A=>{p(A)}}):null,S==="setup_totp"?m.jsx(vL,{api:l,onDone:()=>{w()}}):null,S==="login"?m.jsx(IL,{api:l,session:h,onSession:p,onRefresh:w}):null,S==="reauth"?m.jsx(UL,{api:l,session:h,onSession:p,onFullLogin:()=>p(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function HL({api:e,onSession:t}){const[r,s]=v.useState(""),[l,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function b(y){y.preventDefault(),p(!0),f(null);try{if(r!==l){f("Passwords do not match");return}t(await e.setupPassword({password:r}))}catch(S){f(ja(S))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:b,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:r,onChange:y=>s(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:l,onChange:y=>c(y.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||r.length<8||l.length<8,children:"Set password"})]})}function IL({api:e,session:t,onSession:r,onRefresh:s}){const[l,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(!1),[S,w]=v.useState(null),k=t?.totpEnabled??!1,E=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),y(!0),w(null);try{r(await e.login({password:l,...k?{otp:h}:{},rememberNetwork:g}))}catch(B){w(ja(B))}finally{y(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:L,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:l,onChange:A=>c(A.currentTarget.value),required:!0})]}),k?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:A=>p(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,E?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||l.length===0||k&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function UL({api:e,session:t,onSession:r,onFullLogin:s}){const l=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,b]=v.useState(!1),[y,S]=v.useState(!1),[w,k]=v.useState(!1),[E,L]=v.useState(null),A=Mi.useCallback(async(Y,P)=>{b(!0),L(null);try{r(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:P}))}catch(q){L(ja(q))}finally{b(!1)}},[e,r]);v.useEffect(()=>{if(l){let Y=!1;S(!0),k(!1),L(null);const P=window.setTimeout(()=>{Y||k(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{Y||r(q)}).catch(q=>{Y||(L(ja(q)),k(!0))}).finally(()=>{window.clearTimeout(P),Y||S(!1)}),()=>{Y=!0,window.clearTimeout(P)}}},[e,l,r]);async function B(Y){Y.preventDefault(),await A(c,p)}return l&&y&&!w&&!E?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:B,children:[l&&w&&!E?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:Y=>h(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),E?m.jsx("p",{className:"form-error",children:E}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function KL(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ja(e){return e instanceof Error?e.message:"Request failed"}const X0="NTerminal",mg="nterminal.activeAgentId";function WL(){const[e,t]=v.useState(()=>FL()),r=v.useMemo(()=>Hh(),[]),s=v.useMemo(()=>dc(e),[e]);v.useEffect(()=>{const c=()=>{const h=n5();document.title=h>0?`(${h}) ${X0}`:X0};return c(),i5(c)},[]);function l(c){qL(c),t(c)}return m.jsx(PL,{api:r,activeAgentId:e,serverApi:s,onSelectServer:l})}function FL(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mg);return e&&e.trim()?e:null}catch{return null}}function qL(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(mg,e);return}window.localStorage.removeItem(mg)}catch{}}const G0=["gesturestart","gesturechange","gestureend"],$L=[".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 VL(e=window){if(!XL(e))return()=>{};const t={passive:!1},r=e.document;function s(c){c.cancelable&&c.preventDefault()}function l(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!YL(c.target))&&s(c)}for(const c of G0)r.addEventListener(c,s,t);return r.addEventListener("touchmove",l,t),r.addEventListener("dblclick",s,t),()=>{for(const c of G0)r.removeEventListener(c,s,t);r.removeEventListener("touchmove",l,t),r.removeEventListener("dblclick",s,t)}}function YL(e){return e instanceof Element&&e.closest($L)!==null}function XL(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}SL();vN();VL();bg();Pk.createRoot(document.getElementById("root")).render(m.jsx(Mi.StrictMode,{children:m.jsx(WL,{})}));export{Mi as R,Rk as g,m as j};
|