nterminal 1.2.89 → 1.2.91
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/assets/brand/claude.webp +0 -0
- package/assets/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-DeuMEC4W.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-Du5Pkx1T.js → TranscriptMarkdownBody-Ba-PCW9y.js} +1 -1
- package/dist/client/assets/{index-Cyt748r3.js → index-AlID8r7Q.js} +1 -1
- package/dist/client/assets/index-B8YltmYF.js +57 -0
- package/dist/client/assets/index-BZjaqOfH.css +1 -0
- package/dist/client/brand/claude.webp +0 -0
- package/dist/client/brand/codex.webp +0 -0
- package/dist/client/index.html +2 -2
- package/dist/server/accounts/accountService.d.ts +70 -0
- package/dist/server/accounts/accountService.js +765 -0
- package/dist/server/accounts/accountService.js.map +1 -0
- package/dist/server/agent/agentRoutes.d.ts +2 -0
- package/dist/server/agent/agentRoutes.js +61 -0
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/http.d.ts +2 -1
- package/dist/server/http.js +6 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/accountRoutes.d.ts +9 -0
- package/dist/server/routes/accountRoutes.js +84 -0
- package/dist/server/routes/accountRoutes.js.map +1 -0
- package/dist/server/routes/agentManagementRoutes.js +35 -0
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/shared/protocol.d.ts +30 -0
- package/dist/shared/protocol.js.map +1 -1
- package/package.json +1 -1
- package/public/brand/claude.webp +0 -0
- package/public/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-Bpy611pE.js +0 -1
- package/dist/client/assets/index-BcPAKIRq.css +0 -1
- package/dist/client/assets/index-Bm5iXlSq.js +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-Bpy611pE.js","assets/index-Cyt748r3.js","assets/TranscriptMarkdownBody-Du5Pkx1T.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function $E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wm={exports:{}},Hc={};var O0;function qE(){if(O0)return Hc;O0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var m in o)m!=="key"&&(c[m]=o[m])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:c}}return Hc.Fragment=t,Hc.jsx=n,Hc.jsxs=n,Hc}var B0;function VE(){return B0||(B0=1,Wm.exports=qE()),Wm.exports}var f=VE(),Fm={exports:{}},at={};var j0;function YE(){if(j0)return at;j0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),k=Symbol.iterator;function w(N){return N===null||typeof N!="object"?null:(N=k&&N[k]||N["@@iterator"],typeof N=="function"?N:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,I={};function L(N,U,ue){this.props=N,this.context=U,this.refs=I,this.updater=ue||S}L.prototype.isReactComponent={},L.prototype.setState=function(N,U){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,U,"setState")},L.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function H(){}H.prototype=L.prototype;function Y(N,U,ue){this.props=N,this.context=U,this.refs=I,this.updater=ue||S}var $=Y.prototype=new H;$.constructor=Y,D($,L.prototype),$.isPureReactComponent=!0;var se=Array.isArray;function J(){}var F={H:null,A:null,T:null,S:null},xe=Object.prototype.hasOwnProperty;function re(N,U,ue){var Ce=ue.ref;return{$$typeof:e,type:N,key:U,ref:Ce!==void 0?Ce:null,props:ue}}function Ee(N,U){return re(N.type,U,N.props)}function ie(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function V(N){var U={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(ue){return U[ue]})}var X=/\/+/g;function W(N,U){return typeof N=="object"&&N!==null&&N.key!=null?V(""+N.key):U.toString(36)}function le(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(J,J):(N.status="pending",N.then(function(U){N.status==="pending"&&(N.status="fulfilled",N.value=U)},function(U){N.status==="pending"&&(N.status="rejected",N.reason=U)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function O(N,U,ue,Ce,Oe){var De=typeof N;(De==="undefined"||De==="boolean")&&(N=null);var Be=!1;if(N===null)Be=!0;else switch(De){case"bigint":case"string":case"number":Be=!0;break;case"object":switch(N.$$typeof){case e:case t:Be=!0;break;case y:return Be=N._init,O(Be(N._payload),U,ue,Ce,Oe)}}if(Be)return Oe=Oe(N),Be=Ce===""?"."+W(N,0):Ce,se(Oe)?(ue="",Be!=null&&(ue=Be.replace(X,"$&/")+"/"),O(Oe,U,ue,"",function(We){return We})):Oe!=null&&(ie(Oe)&&(Oe=Ee(Oe,ue+(Oe.key==null||N&&N.key===Oe.key?"":(""+Oe.key).replace(X,"$&/")+"/")+Be)),U.push(Oe)),1;Be=0;var Ne=Ce===""?".":Ce+":";if(se(N))for(var Ue=0;Ue<N.length;Ue++)Ce=N[Ue],De=Ne+W(Ce,Ue),Be+=O(Ce,U,ue,De,Oe);else if(Ue=w(N),typeof Ue=="function")for(N=Ue.call(N),Ue=0;!(Ce=N.next()).done;)Ce=Ce.value,De=Ne+W(Ce,Ue++),Be+=O(Ce,U,ue,De,Oe);else if(De==="object"){if(typeof N.then=="function")return O(le(N),U,ue,Ce,Oe);throw U=String(N),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Be}function M(N,U,ue){if(N==null)return N;var Ce=[],Oe=0;return O(N,Ce,"","",function(De){return U.call(ue,De,Oe++)}),Ce}function B(N){if(N._status===-1){var U=N._result;U=U(),U.then(function(ue){(N._status===0||N._status===-1)&&(N._status=1,N._result=ue)},function(ue){(N._status===0||N._status===-1)&&(N._status=2,N._result=ue)}),N._status===-1&&(N._status=0,N._result=U)}if(N._status===1)return N._result.default;throw N._result}var ae=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},we={map:M,forEach:function(N,U,ue){M(N,function(){U.apply(this,arguments)},ue)},count:function(N){var U=0;return M(N,function(){U++}),U},toArray:function(N){return M(N,function(U){return U})||[]},only:function(N){if(!ie(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return at.Activity=b,at.Children=we,at.Component=L,at.Fragment=n,at.Profiler=o,at.PureComponent=Y,at.StrictMode=r,at.Suspense=g,at.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=F,at.__COMPILER_RUNTIME={__proto__:null,c:function(N){return F.H.useMemoCache(N)}},at.cache=function(N){return function(){return N.apply(null,arguments)}},at.cacheSignal=function(){return null},at.cloneElement=function(N,U,ue){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Ce=D({},N.props),Oe=N.key;if(U!=null)for(De in U.key!==void 0&&(Oe=""+U.key),U)!xe.call(U,De)||De==="key"||De==="__self"||De==="__source"||De==="ref"&&U.ref===void 0||(Ce[De]=U[De]);var De=arguments.length-2;if(De===1)Ce.children=ue;else if(1<De){for(var Be=Array(De),Ne=0;Ne<De;Ne++)Be[Ne]=arguments[Ne+2];Ce.children=Be}return re(N.type,Oe,Ce)},at.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:c,_context:N},N},at.createElement=function(N,U,ue){var Ce,Oe={},De=null;if(U!=null)for(Ce in U.key!==void 0&&(De=""+U.key),U)xe.call(U,Ce)&&Ce!=="key"&&Ce!=="__self"&&Ce!=="__source"&&(Oe[Ce]=U[Ce]);var Be=arguments.length-2;if(Be===1)Oe.children=ue;else if(1<Be){for(var Ne=Array(Be),Ue=0;Ue<Be;Ue++)Ne[Ue]=arguments[Ue+2];Oe.children=Ne}if(N&&N.defaultProps)for(Ce in Be=N.defaultProps,Be)Oe[Ce]===void 0&&(Oe[Ce]=Be[Ce]);return re(N,De,Oe)},at.createRef=function(){return{current:null}},at.forwardRef=function(N){return{$$typeof:m,render:N}},at.isValidElement=ie,at.lazy=function(N){return{$$typeof:y,_payload:{_status:-1,_result:N},_init:B}},at.memo=function(N,U){return{$$typeof:p,type:N,compare:U===void 0?null:U}},at.startTransition=function(N){var U=F.T,ue={};F.T=ue;try{var Ce=N(),Oe=F.S;Oe!==null&&Oe(ue,Ce),typeof Ce=="object"&&Ce!==null&&typeof Ce.then=="function"&&Ce.then(J,ae)}catch(De){ae(De)}finally{U!==null&&ue.types!==null&&(U.types=ue.types),F.T=U}},at.unstable_useCacheRefresh=function(){return F.H.useCacheRefresh()},at.use=function(N){return F.H.use(N)},at.useActionState=function(N,U,ue){return F.H.useActionState(N,U,ue)},at.useCallback=function(N,U){return F.H.useCallback(N,U)},at.useContext=function(N){return F.H.useContext(N)},at.useDebugValue=function(){},at.useDeferredValue=function(N,U){return F.H.useDeferredValue(N,U)},at.useEffect=function(N,U){return F.H.useEffect(N,U)},at.useEffectEvent=function(N){return F.H.useEffectEvent(N)},at.useId=function(){return F.H.useId()},at.useImperativeHandle=function(N,U,ue){return F.H.useImperativeHandle(N,U,ue)},at.useInsertionEffect=function(N,U){return F.H.useInsertionEffect(N,U)},at.useLayoutEffect=function(N,U){return F.H.useLayoutEffect(N,U)},at.useMemo=function(N,U){return F.H.useMemo(N,U)},at.useOptimistic=function(N,U){return F.H.useOptimistic(N,U)},at.useReducer=function(N,U,ue){return F.H.useReducer(N,U,ue)},at.useRef=function(N){return F.H.useRef(N)},at.useState=function(N){return F.H.useState(N)},at.useSyncExternalStore=function(N,U,ue){return F.H.useSyncExternalStore(N,U,ue)},at.useTransition=function(){return F.H.useTransition()},at.version="19.2.6",at}var I0;function L_(){return I0||(I0=1,Fm.exports=YE()),Fm.exports}var v=L_();const Ai=$E(v);var $m={exports:{}},Uc={},qm={exports:{}},Vm={};var z0;function XE(){return z0||(z0=1,(function(e){function t(O,M){var B=O.length;O.push(M);e:for(;0<B;){var ae=B-1>>>1,we=O[ae];if(0<o(we,M))O[ae]=M,O[B]=we,B=ae;else break e}}function n(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var M=O[0],B=O.pop();if(B!==M){O[0]=B;e:for(var ae=0,we=O.length,N=we>>>1;ae<N;){var U=2*(ae+1)-1,ue=O[U],Ce=U+1,Oe=O[Ce];if(0>o(ue,B))Ce<we&&0>o(Oe,ue)?(O[ae]=Oe,O[Ce]=B,ae=Ce):(O[ae]=ue,O[U]=B,ae=U);else if(Ce<we&&0>o(Oe,B))O[ae]=Oe,O[Ce]=B,ae=Ce;else break e}}return M}function o(O,M){var B=O.sortIndex-M.sortIndex;return B!==0?B:O.id-M.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 u=Date,m=u.now();e.unstable_now=function(){return u.now()-m}}var g=[],p=[],y=1,b=null,k=3,w=!1,S=!1,D=!1,I=!1,L=typeof setTimeout=="function"?setTimeout:null,H=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function $(O){for(var M=n(p);M!==null;){if(M.callback===null)r(p);else if(M.startTime<=O)r(p),M.sortIndex=M.expirationTime,t(g,M);else break;M=n(p)}}function se(O){if(D=!1,$(O),!S)if(n(g)!==null)S=!0,J||(J=!0,V());else{var M=n(p);M!==null&&le(se,M.startTime-O)}}var J=!1,F=-1,xe=5,re=-1;function Ee(){return I?!0:!(e.unstable_now()-re<xe)}function ie(){if(I=!1,J){var O=e.unstable_now();re=O;var M=!0;try{e:{S=!1,D&&(D=!1,H(F),F=-1),w=!0;var B=k;try{t:{for($(O),b=n(g);b!==null&&!(b.expirationTime>O&&Ee());){var ae=b.callback;if(typeof ae=="function"){b.callback=null,k=b.priorityLevel;var we=ae(b.expirationTime<=O);if(O=e.unstable_now(),typeof we=="function"){b.callback=we,$(O),M=!0;break t}b===n(g)&&r(g),$(O)}else r(g);b=n(g)}if(b!==null)M=!0;else{var N=n(p);N!==null&&le(se,N.startTime-O),M=!1}}break e}finally{b=null,k=B,w=!1}M=void 0}}finally{M?V():J=!1}}}var V;if(typeof Y=="function")V=function(){Y(ie)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,W=X.port2;X.port1.onmessage=ie,V=function(){W.postMessage(null)}}else V=function(){L(ie,0)};function le(O,M){F=L(function(){O(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):xe=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_next=function(O){switch(k){case 1:case 2:case 3:var M=3;break;default:M=k}var B=k;k=M;try{return O()}finally{k=B}},e.unstable_requestPaint=function(){I=!0},e.unstable_runWithPriority=function(O,M){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var B=k;k=O;try{return M()}finally{k=B}},e.unstable_scheduleCallback=function(O,M,B){var ae=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?ae+B:ae):B=ae,O){case 1:var we=-1;break;case 2:we=250;break;case 5:we=1073741823;break;case 4:we=1e4;break;default:we=5e3}return we=B+we,O={id:y++,callback:M,priorityLevel:O,startTime:B,expirationTime:we,sortIndex:-1},B>ae?(O.sortIndex=B,t(p,O),n(g)===null&&O===n(p)&&(D?(H(F),F=-1):D=!0,le(se,B-ae))):(O.sortIndex=we,t(g,O),S||w||(S=!0,J||(J=!0,V()))),O},e.unstable_shouldYield=Ee,e.unstable_wrapCallback=function(O){var M=k;return function(){var B=k;k=M;try{return O.apply(this,arguments)}finally{k=B}}}})(Vm)),Vm}var P0;function GE(){return P0||(P0=1,qm.exports=XE()),qm.exports}var Ym={exports:{}},fn={};var H0;function ZE(){if(H0)return fn;H0=1;var e=L_();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:y}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return fn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,fn.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return c(g,p,null,y)},fn.flushSync=function(g){var p=u.T,y=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=p,r.p=y,r.d.f()}},fn.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},fn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},fn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),k=typeof p.integrity=="string"?p.integrity:void 0,w=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:k,fetchPriority:w}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:k,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},fn.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=m(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},fn.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin);r.d.L(g,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},fn.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=m(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},fn.requestFormReset=function(g){r.d.r(g)},fn.unstable_batchedUpdates=function(g,p){return g(p)},fn.useFormState=function(g,p,y){return u.H.useFormState(g,p,y)},fn.useFormStatus=function(){return u.H.useHostTransitionStatus()},fn.version="19.2.6",fn}var U0;function oC(){if(U0)return Ym.exports;U0=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(),Ym.exports=ZE(),Ym.exports}var K0;function QE(){if(K0)return Uc;K0=1;var e=GE(),t=L_(),n=oC();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function u(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,l=s;;){var d=a.return;if(d===null)break;var h=d.alternate;if(h===null){if(l=d.return,l!==null){a=l;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===a)return g(d),i;if(h===l)return g(d),s;h=h.sibling}throw Error(r(188))}if(a.return!==l.return)a=d,l=h;else{for(var _=!1,T=d.child;T;){if(T===a){_=!0,a=d,l=h;break}if(T===l){_=!0,l=d,a=h;break}T=T.sibling}if(!_){for(T=h.child;T;){if(T===a){_=!0,a=h,l=d;break}if(T===l){_=!0,l=h,a=d;break}T=T.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var b=Object.assign,k=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),Ee=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var X=Symbol.for("react.client.reference");function W(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===X?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case L:return"Profiler";case I:return"StrictMode";case se:return"Suspense";case J:return"SuspenseList";case re:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case S:return"Portal";case Y:return i.displayName||"Context";case H:return(i._context.displayName||"Context")+".Consumer";case $:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case F:return s=i.displayName||null,s!==null?s:W(i.type)||"Memo";case xe:s=i._payload,i=i._init;try{return W(i(s))}catch{}}return null}var le=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},ae=[],we=-1;function N(i){return{current:i}}function U(i){0>we||(i.current=ae[we],ae[we]=null,we--)}function ue(i,s){we++,ae[we]=i.current,i.current=s}var Ce=N(null),Oe=N(null),De=N(null),Be=N(null);function Ne(i,s){switch(ue(De,s),ue(Oe,i),ue(Ce,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?n0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=n0(s),i=s0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(Ce),ue(Ce,i)}function Ue(){U(Ce),U(Oe),U(De)}function We(i){i.memoizedState!==null&&ue(Be,i);var s=Ce.current,a=s0(s,i.type);s!==a&&(ue(Oe,i),ue(Ce,a))}function ne(i){Oe.current===i&&(U(Ce),U(Oe)),Be.current===i&&(U(Be),jc._currentValue=B)}var pe,R;function q(i){if(pe===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);pe=s&&s[1]||"",R=-1<a.stack.indexOf(`
|
|
3
|
-
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+pe+i+R}var fe=!1;function ge(i,s){if(!i||fe)return"";fe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(ce){var te=ce}Reflect.construct(i,[],_e)}else{try{_e.call()}catch(ce){te=ce}i.call(_e.prototype)}}else{try{throw Error()}catch(ce){te=ce}(_e=i())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(ce){if(ce&&te&&typeof ce.stack=="string")return[ce.stack,te.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),_=h[0],T=h[1];if(_&&T){var A=_.split(`
|
|
5
|
-
`),Z=T.split(`
|
|
6
|
-
`);for(d=l=0;l<A.length&&!A[l].includes("DetermineComponentFrameRoot");)l++;for(;d<Z.length&&!Z[d].includes("DetermineComponentFrameRoot");)d++;if(l===A.length||d===Z.length)for(l=A.length-1,d=Z.length-1;1<=l&&0<=d&&A[l]!==Z[d];)d--;for(;1<=l&&0<=d;l--,d--)if(A[l]!==Z[d]){if(l!==1||d!==1)do if(l--,d--,0>d||A[l]!==Z[d]){var he=`
|
|
7
|
-
`+A[l].replace(" at new "," at ");return i.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",i.displayName)),he}while(1<=l&&0<=d);break}}}finally{fe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?q(a):""}function Q(i,s){switch(i.tag){case 26:case 27:case 5:return q(i.type);case 16:return q("Lazy");case 13:return i.child!==s&&s!==null?q("Suspense Fallback"):q("Suspense");case 19:return q("SuspenseList");case 0:case 15:return ge(i.type,!1);case 11:return ge(i.type.render,!1);case 1:return ge(i.type,!0);case 31:return q("Activity");default:return""}}function ke(i){try{var s="",a=null;do s+=Q(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
|
|
8
|
-
Error generating stack: `+l.message+`
|
|
9
|
-
`+l.stack}}var de=Object.prototype.hasOwnProperty,Re=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,je=e.unstable_shouldYield,Ye=e.unstable_requestPaint,lt=e.unstable_now,Nt=e.unstable_getCurrentPriorityLevel,yt=e.unstable_ImmediatePriority,Tt=e.unstable_UserBlockingPriority,$e=e.unstable_NormalPriority,St=e.unstable_LowPriority,Lt=e.unstable_IdlePriority,ye=e.log,Xe=e.unstable_setDisableYieldValue,rt=null,Ze=null;function Et(i){if(typeof ye=="function"&&Xe(i),Ze&&typeof Ze.setStrictMode=="function")try{Ze.setStrictMode(rt,i)}catch{}}var ct=Math.clz32?Math.clz32:ee,Tn=Math.log,vi=Math.LN2;function ee(i){return i>>>=0,i===0?32:31-(Tn(i)/vi|0)|0}var Pe=256,st=262144,tt=4194304;function kt(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Xt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var d=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var T=l&134217727;return T!==0?(l=T&~h,l!==0?d=kt(l):(_&=T,_!==0?d=kt(_):a||(a=T&~i,a!==0&&(d=kt(a))))):(T=l&~h,T!==0?d=kt(T):_!==0?d=kt(_):a||(a=l&~i,a!==0&&(d=kt(a)))),d===0?0:s!==0&&s!==d&&(s&h)===0&&(h=d&-d,a=s&-s,h>=a||h===32&&(a&4194048)!==0)?s:d}function Wt(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function ui(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),i}function ri(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function di(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ft(i,s,a,l,d,h){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 T=i.entanglements,A=i.expirationTimes,Z=i.hiddenUpdates;for(a=_&~a;0<a;){var he=31-ct(a),_e=1<<he;T[he]=0,A[he]=-1;var te=Z[he];if(te!==null)for(Z[he]=null,he=0;he<te.length;he++){var ce=te[he];ce!==null&&(ce.lane&=-536870913)}a&=~_e}l!==0&&cn(i,l,0),h!==0&&d===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~s))}function cn(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-ct(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ti(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-ct(a),d=1<<l;d&s|i[l]&s&&(i[l]|=s),a&=~d}}function Ui(i,s){var a=s&-s;return a=(a&42)!==0?1:vn(a),(a&(i.suspendedLanes|s))!==0?0:a}function vn(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 _n(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function ii(){var i=M.p;return i!==0?i:(i=window.event,i===void 0?32:E0(i.type))}function Ji(i,s){var a=M.p;try{return M.p=i,s()}finally{M.p=a}}var ai=Math.random().toString(36).slice(2),_i="__reactFiber$"+ai,bi="__reactProps$"+ai,Bn="__reactContainer$"+ai,Ir="__reactEvents$"+ai,Oo="__reactListeners$"+ai,zr="__reactHandles$"+ai,Zs="__reactResources$"+ai,ds="__reactMarker$"+ai;function Qs(i){delete i[_i],delete i[bi],delete i[Ir],delete i[Oo],delete i[zr]}function hs(i){var s=i[_i];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Bn]||a[_i]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=d0(i);i!==null;){if(a=i[_i])return a;i=d0(i)}return s}i=a,a=i.parentNode}return null}function Es(i){if(i=i[_i]||i[Bn]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function fs(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function Ds(i){var s=i[Zs];return s||(s=i[Zs]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function It(i){i[ds]=!0}var Bo=new Set,Pr={};function $t(i,s){jn(i,s),jn(i+"Capture",s)}function jn(i,s){for(Pr[i]=s,i=0;i<s.length;i++)Bo.add(s[i])}var en=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]*$"),Hr={},jo={};function Js(i){return de.call(jo,i)?!0:de.call(Hr,i)?!1:en.test(i)?jo[i]=!0:(Hr[i]=!0,!1)}function ps(i,s,a){if(Js(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function Ur(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function bn(i,s,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+l)}}function Ki(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Rs(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function $a(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var d=l.get,h=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.call(this)},set:function(_){a=""+_,h.call(this,_)}}),Object.defineProperty(i,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function ms(i){if(!i._valueTracker){var s=Rs(i)?"checked":"value";i._valueTracker=$a(i,s,""+i[s])}}function Wi(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Rs(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function gs(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 Ms=/[\n"\\]/g;function Oi(i){return i.replace(Ms,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function pt(i,s,a,l,d,h,_,T){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),s!=null?_==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Ki(s)):i.value!==""+Ki(s)&&(i.value=""+Ki(s)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),s!=null?er(i,_,Ki(s)):a!=null?er(i,_,Ki(a)):l!=null&&i.removeAttribute("value"),d==null&&h!=null&&(i.defaultChecked=!!h),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?i.name=""+Ki(T):i.removeAttribute("name")}function vs(i,s,a,l,d,h,_,T){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),s!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||s!=null)){ms(i);return}a=a!=null?""+Ki(a):"",s=s!=null?""+Ki(s):a,T||s===i.value||(i.value=s),i.defaultValue=s}l=l??d,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=T?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),ms(i)}function er(i,s,a){s==="number"&&gs(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function un(i,s,a,l){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Ki(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,l&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function Kr(i,s,a){if(s!=null&&(s=""+Ki(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Ki(a):""}function qa(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(le(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Ki(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),ms(i)}function dn(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var Io=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 Wr(i,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":l?i.setProperty(s,a):typeof a!="number"||a===0||Io.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function _s(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var d in s)l=s[d],s.hasOwnProperty(d)&&a[d]!==l&&Wr(i,d,l)}else for(var h in s)s.hasOwnProperty(h)&&Wr(i,h,s[h])}function Fr(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 zo=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"]]),Yl=/^[\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 bs(i){return Yl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Yn(){}var yi=null;function $r(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Fi=null,oi=null;function Ns(i){var s=Es(i);if(s&&(i=s.stateNode)){var a=i[bi]||null;e:switch(i=s.stateNode,s.type){case"input":if(pt(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Oi(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var d=l[bi]||null;if(!d)throw Error(r(90));pt(l,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&Wi(l)}break e;case"textarea":Kr(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&un(i,!!a.multiple,s,!1)}}}var tr=!1;function Va(i,s,a){if(tr)return i(s,a);tr=!0;try{var l=i(s);return l}finally{if(tr=!1,(Fi!==null||oi!==null)&&(qd(),Fi&&(s=Fi,i=oi,oi=Fi=null,Ns(s),i)))for(s=0;s<i.length;s++)Ns(i[s])}}function In(i,s){var a=i.stateNode;if(a===null)return null;var l=a[bi]||null;if(l===null)return null;a=l[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Si=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),qr=!1;if(Si)try{var ir={};Object.defineProperty(ir,"passive",{get:function(){qr=!0}}),window.addEventListener("test",ir,ir),window.removeEventListener("test",ir,ir)}catch{qr=!1}var yn=null,As=null,Ls=null;function nr(){if(Ls)return Ls;var i,s=As,a=s.length,l,d="value"in yn?yn.value:yn.textContent,h=d.length;for(i=0;i<a&&s[i]===d[i];i++);var _=a-i;for(l=1;l<=_&&s[a-l]===d[h-l];l++);return Ls=d.slice(i,1<l?1-l:void 0)}function sr(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function Os(){return!0}function hn(){return!1}function ki(i){function s(a,l,d,h,_){this._reactName=a,this._targetInst=d,this.type=l,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(h):h[T]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Os:hn,this.isPropagationStopped=hn,this}return b(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Os)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Os)},persist:function(){},isPersistent:Os}),s}var Xn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},C=ki(Xn),E=b({},Xn,{view:0,detail:0}),z=ki(E),oe,Se,me,Me=b({},E,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bs,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!==me&&(me&&i.type==="mousemove"?(oe=i.screenX-me.screenX,Se=i.screenY-me.screenY):Se=oe=0,me=i),oe)},movementY:function(i){return"movementY"in i?i.movementY:Se}}),Qe=ki(Me),vt=b({},Me,{dataTransfer:0}),Ti=ki(vt),Zt=b({},E,{relatedTarget:0}),Vr=ki(Zt),Ff=b({},Xn,{animationName:0,elapsedTime:0,pseudoElement:0}),Po=ki(Ff),Yr=b({},Xn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Xl=ki(Yr),tn=b({},Xn,{data:0}),Ho=ki(tn),Uo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gu={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"},Zu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qu(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Zu[i])?!!s[i]:!1}function Bs(){return Qu}var nn=b({},E,{key:function(i){if(i.key){var s=Uo[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=sr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Gu[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bs,charCode:function(i){return i.type==="keypress"?sr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?sr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),$f=ki(nn),Ju=b({},Me,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gl=ki(Ju),ed=b({},E,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bs}),qf=ki(ed),td=b({},Xn,{propertyName:0,elapsedTime:0,pseudoElement:0}),rr=ki(td),Zl=b({},Me,{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}),Vf=ki(Zl),Yf=b({},Xn,{newState:0,oldState:0}),Xf=ki(Yf),Ql=[9,13,27,32],Ya=Si&&"CompositionEvent"in window,ar=null;Si&&"documentMode"in document&&(ar=document.documentMode);var Ko=Si&&"TextEvent"in window&&!ar,Jl=Si&&(!Ya||ar&&8<ar&&11>=ar),ec=" ",id=!1;function tc(i,s){switch(i){case"keyup":return Ql.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Xr=!1;function Gf(i,s){switch(i){case"compositionend":return nd(s);case"keypress":return s.which!==32?null:(id=!0,ec);case"textInput":return i=s.data,i===ec&&id?null:i;default:return null}}function sd(i,s){if(Xr)return i==="compositionend"||!Ya&&tc(i,s)?(i=nr(),Ls=As=yn=null,Xr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Jl&&s.locale!=="ko"?null:s.data;default:return null}}var ic={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 Xa(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!ic[i.type]:s==="textarea"}function nc(i,s,a,l){Fi?oi?oi.push(l):oi=[l]:Fi=l,s=Jd(s,"onChange"),0<s.length&&(a=new C("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var Gr=null,Ga=null;function rd(i){ZS(i,0)}function Za(i){var s=fs(i);if(Wi(s))return i}function sc(i,s){if(i==="change")return s}var ad=!1;if(Si){var Wo;if(Si){var Gn="oninput"in document;if(!Gn){var od=document.createElement("div");od.setAttribute("oninput","return;"),Gn=typeof od.oninput=="function"}Wo=Gn}else Wo=!1;ad=Wo&&(!document.documentMode||9<document.documentMode)}function ld(){Gr&&(Gr.detachEvent("onpropertychange",rc),Ga=Gr=null)}function rc(i){if(i.propertyName==="value"&&Za(Ga)){var s=[];nc(s,Ga,i,$r(i)),Va(rd,s)}}function Zf(i,s,a){i==="focusin"?(ld(),Gr=s,Ga=a,Gr.attachEvent("onpropertychange",rc)):i==="focusout"&&ld()}function Qf(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Za(Ga)}function or(i,s){if(i==="click")return Za(s)}function Jf(i,s){if(i==="input"||i==="change")return Za(s)}function ep(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var Sn=typeof Object.is=="function"?Object.is:ep;function Zr(i,s){if(Sn(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var d=a[l];if(!de.call(s,d)||!Sn(i[d],s[d]))return!1}return!0}function ys(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function cd(i,s){var a=ys(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=ys(a)}}function ud(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?ud(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function dd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=gs(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=gs(i.document)}return s}function Qa(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var tp=Si&&"documentMode"in document&&11>=document.documentMode,lr=null,x=null,j=null,Te=!1;function qe(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Te||lr==null||lr!==gs(l)||(l=lr,"selectionStart"in l&&Qa(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),j&&Zr(j,l)||(j=l,l=Jd(x,"onSelect"),0<l.length&&(s=new C("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=lr)))}function Ke(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var et={animationend:Ke("Animation","AnimationEnd"),animationiteration:Ke("Animation","AnimationIteration"),animationstart:Ke("Animation","AnimationStart"),transitionrun:Ke("Transition","TransitionRun"),transitionstart:Ke("Transition","TransitionStart"),transitioncancel:Ke("Transition","TransitionCancel"),transitionend:Ke("Transition","TransitionEnd")},ut={},ft={};Si&&(ft=document.createElement("div").style,"AnimationEvent"in window||(delete et.animationend.animation,delete et.animationiteration.animation,delete et.animationstart.animation),"TransitionEvent"in window||delete et.transitionend.transition);function Ve(i){if(ut[i])return ut[i];if(!et[i])return i;var s=et[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in ft)return ut[i]=s[a];return i}var qt=Ve("animationend"),Ot=Ve("animationiteration"),At=Ve("animationstart"),js=Ve("transitionrun"),Fo=Ve("transitionstart"),Is=Ve("transitioncancel"),ac=Ve("transitionend"),oc=new Map,ip="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(" ");ip.push("scrollEnd");function Ss(i,s){oc.set(i,s),$t(s,[i])}var hd=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Zn=[],$o=0,np=0;function fd(){for(var i=$o,s=np=$o=0;s<i;){var a=Zn[s];Zn[s++]=null;var l=Zn[s];Zn[s++]=null;var d=Zn[s];Zn[s++]=null;var h=Zn[s];if(Zn[s++]=null,l!==null&&d!==null){var _=l.pending;_===null?d.next=d:(d.next=_.next,_.next=d),l.pending=d}h!==0&&Ab(a,d,h)}}function pd(i,s,a,l){Zn[$o++]=i,Zn[$o++]=s,Zn[$o++]=a,Zn[$o++]=l,np|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function sp(i,s,a,l){return pd(i,s,a,l),md(i)}function Ja(i,s){return pd(i,null,null,s),md(i)}function Ab(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var d=!1,h=i.return;h!==null;)h.childLanes|=a,l=h.alternate,l!==null&&(l.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(d=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,d&&s!==null&&(d=31-ct(a),i=h.hiddenUpdates,l=i[d],l===null?i[d]=[s]:l.push(s),s.lane=a|536870912),h):null}function md(i){if(50<Rc)throw Rc=0,fm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var qo={};function DT(i,s,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(i,s,a,l){return new DT(i,s,a,l)}function rp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function cr(i,s){var a=i.alternate;return a===null?(a=zn(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function Lb(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function gd(i,s,a,l,d,h){var _=0;if(l=i,typeof i=="function")rp(i)&&(_=1);else if(typeof i=="string")_=LE(i,a,Ce.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case re:return i=zn(31,a,s,d),i.elementType=re,i.lanes=h,i;case D:return eo(a.children,d,h,s);case I:_=8,d|=24;break;case L:return i=zn(12,a,s,d|2),i.elementType=L,i.lanes=h,i;case se:return i=zn(13,a,s,d),i.elementType=se,i.lanes=h,i;case J:return i=zn(19,a,s,d),i.elementType=J,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case H:_=9;break e;case $:_=11;break e;case F:_=14;break e;case xe:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return s=zn(_,a,s,d),s.elementType=i,s.type=l,s.lanes=h,s}function eo(i,s,a,l){return i=zn(7,i,l,s),i.lanes=a,i}function ap(i,s,a){return i=zn(6,i,null,s),i.lanes=a,i}function Ob(i){var s=zn(18,null,null,0);return s.stateNode=i,s}function op(i,s,a){return s=zn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var Bb=new WeakMap;function Qn(i,s){if(typeof i=="object"&&i!==null){var a=Bb.get(i);return a!==void 0?a:(s={value:i,source:s,stack:ke(s)},Bb.set(i,s),s)}return{value:i,source:s,stack:ke(s)}}var Vo=[],Yo=0,vd=null,lc=0,Jn=[],es=0,Qr=null,zs=1,Ps="";function ur(i,s){Vo[Yo++]=lc,Vo[Yo++]=vd,vd=i,lc=s}function jb(i,s,a){Jn[es++]=zs,Jn[es++]=Ps,Jn[es++]=Qr,Qr=i;var l=zs;i=Ps;var d=32-ct(l)-1;l&=~(1<<d),a+=1;var h=32-ct(s)+d;if(30<h){var _=d-d%5;h=(l&(1<<_)-1).toString(32),l>>=_,d-=_,zs=1<<32-ct(s)+d|a<<d|l,Ps=h+i}else zs=1<<h|a<<d|l,Ps=i}function lp(i){i.return!==null&&(ur(i,1),jb(i,1,0))}function cp(i){for(;i===vd;)vd=Vo[--Yo],Vo[Yo]=null,lc=Vo[--Yo],Vo[Yo]=null;for(;i===Qr;)Qr=Jn[--es],Jn[es]=null,Ps=Jn[--es],Jn[es]=null,zs=Jn[--es],Jn[es]=null}function Ib(i,s){Jn[es++]=zs,Jn[es++]=Ps,Jn[es++]=Qr,zs=s.id,Ps=s.overflow,Qr=i}var sn=null,Qt=null,xt=!1,Jr=null,ts=!1,up=Error(r(519));function ea(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw cc(Qn(s,i)),up}function zb(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[_i]=i,s[bi]=l,a){case"dialog":bt("cancel",s),bt("close",s);break;case"iframe":case"object":case"embed":bt("load",s);break;case"video":case"audio":for(a=0;a<Nc.length;a++)bt(Nc[a],s);break;case"source":bt("error",s);break;case"img":case"image":case"link":bt("error",s),bt("load",s);break;case"details":bt("toggle",s);break;case"input":bt("invalid",s),vs(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":bt("invalid",s);break;case"textarea":bt("invalid",s),qa(s,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||l.suppressHydrationWarning===!0||t0(s.textContent,a)?(l.popover!=null&&(bt("beforetoggle",s),bt("toggle",s)),l.onScroll!=null&&bt("scroll",s),l.onScrollEnd!=null&&bt("scrollend",s),l.onClick!=null&&(s.onclick=Yn),s=!0):s=!1,s||ea(i,!0)}function Pb(i){for(sn=i.return;sn;)switch(sn.tag){case 5:case 31:case 13:ts=!1;return;case 27:case 3:ts=!0;return;default:sn=sn.return}}function Xo(i){if(i!==sn)return!1;if(!xt)return Pb(i),xt=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Dm(i.type,i.memoizedProps)),a=!a),a&&Qt&&ea(i),Pb(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Qt=u0(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Qt=u0(i)}else s===27?(s=Qt,pa(i.type)?(i=Lm,Lm=null,Qt=i):Qt=s):Qt=sn?ns(i.stateNode.nextSibling):null;return!0}function to(){Qt=sn=null,xt=!1}function dp(){var i=Jr;return i!==null&&(Mn===null?Mn=i:Mn.push.apply(Mn,i),Jr=null),i}function cc(i){Jr===null?Jr=[i]:Jr.push(i)}var hp=N(null),io=null,dr=null;function ta(i,s,a){ue(hp,s._currentValue),s._currentValue=a}function hr(i){i._currentValue=hp.current,U(hp)}function fp(i,s,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),i===a)break;i=i.return}}function pp(i,s,a,l){var d=i.child;for(d!==null&&(d.return=i);d!==null;){var h=d.dependencies;if(h!==null){var _=d.child;h=h.firstContext;e:for(;h!==null;){var T=h;h=d;for(var A=0;A<s.length;A++)if(T.context===s[A]){h.lanes|=a,T=h.alternate,T!==null&&(T.lanes|=a),fp(h.return,a,i),l||(_=null);break e}h=T.next}}else if(d.tag===18){if(_=d.return,_===null)throw Error(r(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),fp(_,a,i),_=null}else _=d.child;if(_!==null)_.return=d;else for(_=d;_!==null;){if(_===i){_=null;break}if(d=_.sibling,d!==null){d.return=_.return,_=d;break}_=_.return}d=_}}function Go(i,s,a,l){i=null;for(var d=s,h=!1;d!==null;){if(!h){if((d.flags&524288)!==0)h=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var _=d.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var T=d.type;Sn(d.pendingProps.value,_.value)||(i!==null?i.push(T):i=[T])}}else if(d===Be.current){if(_=d.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(i!==null?i.push(jc):i=[jc])}d=d.return}i!==null&&pp(s,i,a,l),s.flags|=262144}function _d(i){for(i=i.firstContext;i!==null;){if(!Sn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function no(i){io=i,dr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function rn(i){return Hb(io,i)}function bd(i,s){return io===null&&no(i),Hb(i,s)}function Hb(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},dr===null){if(i===null)throw Error(r(308));dr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else dr=dr.next=s;return a}var RT=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},MT=e.unstable_scheduleCallback,NT=e.unstable_NormalPriority,Ei={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mp(){return{controller:new RT,data:new Map,refCount:0}}function uc(i){i.refCount--,i.refCount===0&&MT(NT,function(){i.controller.abort()})}var dc=null,gp=0,Zo=0,Qo=null;function AT(i,s){if(dc===null){var a=dc=[];gp=0,Zo=bm(),Qo={status:"pending",value:void 0,then:function(l){a.push(l)}}}return gp++,s.then(Ub,Ub),s}function Ub(){if(--gp===0&&dc!==null){Qo!==null&&(Qo.status="fulfilled");var i=dc;dc=null,Zo=0,Qo=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function LT(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(d){a.push(d)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var d=0;d<a.length;d++)(0,a[d])(s)},function(d){for(l.status="rejected",l.reason=d,d=0;d<a.length;d++)(0,a[d])(void 0)}),l}var Kb=O.S;O.S=function(i,s){kS=lt(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&AT(i,s),Kb!==null&&Kb(i,s)};var so=N(null);function vp(){var i=so.current;return i!==null?i:Vt.pooledCache}function yd(i,s){s===null?ue(so,so.current):ue(so,s.pool)}function Wb(){var i=vp();return i===null?null:{parent:Ei._currentValue,pool:i}}var Jo=Error(r(460)),_p=Error(r(474)),Sd=Error(r(542)),wd={then:function(){}};function Fb(i){return i=i.status,i==="fulfilled"||i==="rejected"}function $b(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Yn,Yn),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Vb(i),i;default:if(typeof s.status=="string")s.then(Yn,Yn);else{if(i=Vt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var d=s;d.status="fulfilled",d.value=l}},function(l){if(s.status==="pending"){var d=s;d.status="rejected",d.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Vb(i),i}throw ao=s,Jo}}function ro(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ao=a,Jo):a}}var ao=null;function qb(){if(ao===null)throw Error(r(459));var i=ao;return ao=null,i}function Vb(i){if(i===Jo||i===Sd)throw Error(r(483))}var el=null,hc=0;function Cd(i){var s=hc;return hc+=1,el===null&&(el=[]),$b(el,i,s)}function fc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function xd(i,s){throw s.$$typeof===k?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function Yb(i){function s(K,P){if(i){var G=K.deletions;G===null?(K.deletions=[P],K.flags|=16):G.push(P)}}function a(K,P){if(!i)return null;for(;P!==null;)s(K,P),P=P.sibling;return null}function l(K){for(var P=new Map;K!==null;)K.key!==null?P.set(K.key,K):P.set(K.index,K),K=K.sibling;return P}function d(K,P){return K=cr(K,P),K.index=0,K.sibling=null,K}function h(K,P,G){return K.index=G,i?(G=K.alternate,G!==null?(G=G.index,G<P?(K.flags|=67108866,P):G):(K.flags|=67108866,P)):(K.flags|=1048576,P)}function _(K){return i&&K.alternate===null&&(K.flags|=67108866),K}function T(K,P,G,ve){return P===null||P.tag!==6?(P=ap(G,K.mode,ve),P.return=K,P):(P=d(P,G),P.return=K,P)}function A(K,P,G,ve){var Ge=G.type;return Ge===D?he(K,P,G.props.children,ve,G.key):P!==null&&(P.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===xe&&ro(Ge)===P.type)?(P=d(P,G.props),fc(P,G),P.return=K,P):(P=gd(G.type,G.key,G.props,null,K.mode,ve),fc(P,G),P.return=K,P)}function Z(K,P,G,ve){return P===null||P.tag!==4||P.stateNode.containerInfo!==G.containerInfo||P.stateNode.implementation!==G.implementation?(P=op(G,K.mode,ve),P.return=K,P):(P=d(P,G.children||[]),P.return=K,P)}function he(K,P,G,ve,Ge){return P===null||P.tag!==7?(P=eo(G,K.mode,ve,Ge),P.return=K,P):(P=d(P,G),P.return=K,P)}function _e(K,P,G){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=ap(""+P,K.mode,G),P.return=K,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case w:return G=gd(P.type,P.key,P.props,null,K.mode,G),fc(G,P),G.return=K,G;case S:return P=op(P,K.mode,G),P.return=K,P;case xe:return P=ro(P),_e(K,P,G)}if(le(P)||V(P))return P=eo(P,K.mode,G,null),P.return=K,P;if(typeof P.then=="function")return _e(K,Cd(P),G);if(P.$$typeof===Y)return _e(K,bd(K,P),G);xd(K,P)}return null}function te(K,P,G,ve){var Ge=P!==null?P.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Ge!==null?null:T(K,P,""+G,ve);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return G.key===Ge?A(K,P,G,ve):null;case S:return G.key===Ge?Z(K,P,G,ve):null;case xe:return G=ro(G),te(K,P,G,ve)}if(le(G)||V(G))return Ge!==null?null:he(K,P,G,ve,null);if(typeof G.then=="function")return te(K,P,Cd(G),ve);if(G.$$typeof===Y)return te(K,P,bd(K,G),ve);xd(K,G)}return null}function ce(K,P,G,ve,Ge){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return K=K.get(G)||null,T(P,K,""+ve,Ge);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case w:return K=K.get(ve.key===null?G:ve.key)||null,A(P,K,ve,Ge);case S:return K=K.get(ve.key===null?G:ve.key)||null,Z(P,K,ve,Ge);case xe:return ve=ro(ve),ce(K,P,G,ve,Ge)}if(le(ve)||V(ve))return K=K.get(G)||null,he(P,K,ve,Ge,null);if(typeof ve.then=="function")return ce(K,P,G,Cd(ve),Ge);if(ve.$$typeof===Y)return ce(K,P,G,bd(P,ve),Ge);xd(P,ve)}return null}function He(K,P,G,ve){for(var Ge=null,Dt=null,Fe=P,dt=P=0,Ct=null;Fe!==null&&dt<G.length;dt++){Fe.index>dt?(Ct=Fe,Fe=null):Ct=Fe.sibling;var Rt=te(K,Fe,G[dt],ve);if(Rt===null){Fe===null&&(Fe=Ct);break}i&&Fe&&Rt.alternate===null&&s(K,Fe),P=h(Rt,P,dt),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt,Fe=Ct}if(dt===G.length)return a(K,Fe),xt&&ur(K,dt),Ge;if(Fe===null){for(;dt<G.length;dt++)Fe=_e(K,G[dt],ve),Fe!==null&&(P=h(Fe,P,dt),Dt===null?Ge=Fe:Dt.sibling=Fe,Dt=Fe);return xt&&ur(K,dt),Ge}for(Fe=l(Fe);dt<G.length;dt++)Ct=ce(Fe,K,dt,G[dt],ve),Ct!==null&&(i&&Ct.alternate!==null&&Fe.delete(Ct.key===null?dt:Ct.key),P=h(Ct,P,dt),Dt===null?Ge=Ct:Dt.sibling=Ct,Dt=Ct);return i&&Fe.forEach(function(ba){return s(K,ba)}),xt&&ur(K,dt),Ge}function Je(K,P,G,ve){if(G==null)throw Error(r(151));for(var Ge=null,Dt=null,Fe=P,dt=P=0,Ct=null,Rt=G.next();Fe!==null&&!Rt.done;dt++,Rt=G.next()){Fe.index>dt?(Ct=Fe,Fe=null):Ct=Fe.sibling;var ba=te(K,Fe,Rt.value,ve);if(ba===null){Fe===null&&(Fe=Ct);break}i&&Fe&&ba.alternate===null&&s(K,Fe),P=h(ba,P,dt),Dt===null?Ge=ba:Dt.sibling=ba,Dt=ba,Fe=Ct}if(Rt.done)return a(K,Fe),xt&&ur(K,dt),Ge;if(Fe===null){for(;!Rt.done;dt++,Rt=G.next())Rt=_e(K,Rt.value,ve),Rt!==null&&(P=h(Rt,P,dt),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt);return xt&&ur(K,dt),Ge}for(Fe=l(Fe);!Rt.done;dt++,Rt=G.next())Rt=ce(Fe,K,dt,Rt.value,ve),Rt!==null&&(i&&Rt.alternate!==null&&Fe.delete(Rt.key===null?dt:Rt.key),P=h(Rt,P,dt),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt);return i&&Fe.forEach(function(FE){return s(K,FE)}),xt&&ur(K,dt),Ge}function Ht(K,P,G,ve){if(typeof G=="object"&&G!==null&&G.type===D&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case w:e:{for(var Ge=G.key;P!==null;){if(P.key===Ge){if(Ge=G.type,Ge===D){if(P.tag===7){a(K,P.sibling),ve=d(P,G.props.children),ve.return=K,K=ve;break e}}else if(P.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===xe&&ro(Ge)===P.type){a(K,P.sibling),ve=d(P,G.props),fc(ve,G),ve.return=K,K=ve;break e}a(K,P);break}else s(K,P);P=P.sibling}G.type===D?(ve=eo(G.props.children,K.mode,ve,G.key),ve.return=K,K=ve):(ve=gd(G.type,G.key,G.props,null,K.mode,ve),fc(ve,G),ve.return=K,K=ve)}return _(K);case S:e:{for(Ge=G.key;P!==null;){if(P.key===Ge)if(P.tag===4&&P.stateNode.containerInfo===G.containerInfo&&P.stateNode.implementation===G.implementation){a(K,P.sibling),ve=d(P,G.children||[]),ve.return=K,K=ve;break e}else{a(K,P);break}else s(K,P);P=P.sibling}ve=op(G,K.mode,ve),ve.return=K,K=ve}return _(K);case xe:return G=ro(G),Ht(K,P,G,ve)}if(le(G))return He(K,P,G,ve);if(V(G)){if(Ge=V(G),typeof Ge!="function")throw Error(r(150));return G=Ge.call(G),Je(K,P,G,ve)}if(typeof G.then=="function")return Ht(K,P,Cd(G),ve);if(G.$$typeof===Y)return Ht(K,P,bd(K,G),ve);xd(K,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,P!==null&&P.tag===6?(a(K,P.sibling),ve=d(P,G),ve.return=K,K=ve):(a(K,P),ve=ap(G,K.mode,ve),ve.return=K,K=ve),_(K)):a(K,P)}return function(K,P,G,ve){try{hc=0;var Ge=Ht(K,P,G,ve);return el=null,Ge}catch(Fe){if(Fe===Jo||Fe===Sd)throw Fe;var Dt=zn(29,Fe,null,K.mode);return Dt.lanes=ve,Dt.return=K,Dt}}}var oo=Yb(!0),Xb=Yb(!1),ia=!1;function bp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yp(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function na(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function sa(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Mt&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,s=md(i),Ab(i,null,a),s}return pd(i,l,s,a),md(i)}function pc(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,ti(i,a)}}function Sp(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var d=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?d=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?d=h=s:h=h.next=s}else d=h=s;a={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var wp=!1;function mc(){if(wp){var i=Qo;if(i!==null)throw i}}function gc(i,s,a,l){wp=!1;var d=i.updateQueue;ia=!1;var h=d.firstBaseUpdate,_=d.lastBaseUpdate,T=d.shared.pending;if(T!==null){d.shared.pending=null;var A=T,Z=A.next;A.next=null,_===null?h=Z:_.next=Z,_=A;var he=i.alternate;he!==null&&(he=he.updateQueue,T=he.lastBaseUpdate,T!==_&&(T===null?he.firstBaseUpdate=Z:T.next=Z,he.lastBaseUpdate=A))}if(h!==null){var _e=d.baseState;_=0,he=Z=A=null,T=h;do{var te=T.lane&-536870913,ce=te!==T.lane;if(ce?(wt&te)===te:(l&te)===te){te!==0&&te===Zo&&(wp=!0),he!==null&&(he=he.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var He=i,Je=T;te=s;var Ht=a;switch(Je.tag){case 1:if(He=Je.payload,typeof He=="function"){_e=He.call(Ht,_e,te);break e}_e=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=Je.payload,te=typeof He=="function"?He.call(Ht,_e,te):He,te==null)break e;_e=b({},_e,te);break e;case 2:ia=!0}}te=T.callback,te!==null&&(i.flags|=64,ce&&(i.flags|=8192),ce=d.callbacks,ce===null?d.callbacks=[te]:ce.push(te))}else ce={lane:te,tag:T.tag,payload:T.payload,callback:T.callback,next:null},he===null?(Z=he=ce,A=_e):he=he.next=ce,_|=te;if(T=T.next,T===null){if(T=d.shared.pending,T===null)break;ce=T,T=ce.next,ce.next=null,d.lastBaseUpdate=ce,d.shared.pending=null}}while(!0);he===null&&(A=_e),d.baseState=A,d.firstBaseUpdate=Z,d.lastBaseUpdate=he,h===null&&(d.shared.lanes=0),ca|=_,i.lanes=_,i.memoizedState=_e}}function Gb(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function Zb(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Gb(a[i],s)}var tl=N(null),kd=N(0);function Qb(i,s){i=Sr,ue(kd,i),ue(tl,s),Sr=i|s.baseLanes}function Cp(){ue(kd,Sr),ue(tl,tl.current)}function xp(){Sr=kd.current,U(tl),U(kd)}var Pn=N(null),is=null;function ra(i){var s=i.alternate;ue(wi,wi.current&1),ue(Pn,i),is===null&&(s===null||tl.current!==null||s.memoizedState!==null)&&(is=i)}function kp(i){ue(wi,wi.current),ue(Pn,i),is===null&&(is=i)}function Jb(i){i.tag===22?(ue(wi,wi.current),ue(Pn,i),is===null&&(is=i)):aa()}function aa(){ue(wi,wi.current),ue(Pn,Pn.current)}function Hn(i){U(Pn),is===i&&(is=null),U(wi)}var wi=N(0);function Td(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Nm(a)||Am(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var fr=0,ot=null,zt=null,Di=null,Ed=!1,il=!1,lo=!1,Dd=0,vc=0,nl=null,OT=0;function hi(){throw Error(r(321))}function Tp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!Sn(i[a],s[a]))return!1;return!0}function Ep(i,s,a,l,d,h){return fr=h,ot=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,O.H=i===null||i.memoizedState===null?jy:Kp,lo=!1,h=a(l,d),lo=!1,il&&(h=ty(s,a,l,d)),ey(i),h}function ey(i){O.H=yc;var s=zt!==null&&zt.next!==null;if(fr=0,Di=zt=ot=null,Ed=!1,vc=0,nl=null,s)throw Error(r(300));i===null||Ri||(i=i.dependencies,i!==null&&_d(i)&&(Ri=!0))}function ty(i,s,a,l){ot=i;var d=0;do{if(il&&(nl=null),vc=0,il=!1,25<=d)throw Error(r(301));if(d+=1,Di=zt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}O.H=Iy,h=s(a,l)}while(il);return h}function BT(){var i=O.H,s=i.useState()[0];return s=typeof s.then=="function"?_c(s):s,i=i.useState()[0],(zt!==null?zt.memoizedState:null)!==i&&(ot.flags|=1024),s}function Dp(){var i=Dd!==0;return Dd=0,i}function Rp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Mp(i){if(Ed){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Ed=!1}fr=0,Di=zt=ot=null,il=!1,vc=Dd=0,nl=null}function wn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Di===null?ot.memoizedState=Di=i:Di=Di.next=i,Di}function Ci(){if(zt===null){var i=ot.alternate;i=i!==null?i.memoizedState:null}else i=zt.next;var s=Di===null?ot.memoizedState:Di.next;if(s!==null)Di=s,zt=i;else{if(i===null)throw ot.alternate===null?Error(r(467)):Error(r(310));zt=i,i={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},Di===null?ot.memoizedState=Di=i:Di=Di.next=i}return Di}function Rd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function _c(i){var s=vc;return vc+=1,nl===null&&(nl=[]),i=$b(nl,i,s),s=ot,(Di===null?s.memoizedState:Di.next)===null&&(s=s.alternate,O.H=s===null||s.memoizedState===null?jy:Kp),i}function Md(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return _c(i);if(i.$$typeof===Y)return rn(i)}throw Error(r(438,String(i)))}function Np(i){var s=null,a=ot.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=ot.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(d){return d.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Rd(),ot.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),l=0;l<i;l++)a[l]=Ee;return s.index++,a}function pr(i,s){return typeof s=="function"?s(i):s}function Nd(i){var s=Ci();return Ap(s,zt,i)}function Ap(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var d=i.baseQueue,h=l.pending;if(h!==null){if(d!==null){var _=d.next;d.next=h.next,h.next=_}s.baseQueue=d=h,l.pending=null}if(h=i.baseState,d===null)i.memoizedState=h;else{s=d.next;var T=_=null,A=null,Z=s,he=!1;do{var _e=Z.lane&-536870913;if(_e!==Z.lane?(wt&_e)===_e:(fr&_e)===_e){var te=Z.revertLane;if(te===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),_e===Zo&&(he=!0);else if((fr&te)===te){Z=Z.next,te===Zo&&(he=!0);continue}else _e={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},A===null?(T=A=_e,_=h):A=A.next=_e,ot.lanes|=te,ca|=te;_e=Z.action,lo&&a(h,_e),h=Z.hasEagerState?Z.eagerState:a(h,_e)}else te={lane:_e,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},A===null?(T=A=te,_=h):A=A.next=te,ot.lanes|=_e,ca|=_e;Z=Z.next}while(Z!==null&&Z!==s);if(A===null?_=h:A.next=T,!Sn(h,i.memoizedState)&&(Ri=!0,he&&(a=Qo,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=A,l.lastRenderedState=h}return d===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Lp(i){var s=Ci(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,d=a.pending,h=s.memoizedState;if(d!==null){a.pending=null;var _=d=d.next;do h=i(h,_.action),_=_.next;while(_!==d);Sn(h,s.memoizedState)||(Ri=!0),s.memoizedState=h,s.baseQueue===null&&(s.baseState=h),a.lastRenderedState=h}return[h,l]}function iy(i,s,a){var l=ot,d=Ci(),h=xt;if(h){if(a===void 0)throw Error(r(407));a=a()}else a=s();var _=!Sn((zt||d).memoizedState,a);if(_&&(d.memoizedState=a,Ri=!0),d=d.queue,jp(ry.bind(null,l,d,i),[i]),d.getSnapshot!==s||_||Di!==null&&Di.memoizedState.tag&1){if(l.flags|=2048,sl(9,{destroy:void 0},sy.bind(null,l,d,a,s),null),Vt===null)throw Error(r(349));h||(fr&127)!==0||ny(l,s,a)}return a}function ny(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=ot.updateQueue,s===null?(s=Rd(),ot.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function sy(i,s,a,l){s.value=a,s.getSnapshot=l,ay(s)&&oy(i)}function ry(i,s,a){return a(function(){ay(s)&&oy(i)})}function ay(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!Sn(i,a)}catch{return!0}}function oy(i){var s=Ja(i,2);s!==null&&Nn(s,i,2)}function Op(i){var s=wn();if(typeof i=="function"){var a=i;if(i=a(),lo){Et(!0);try{a()}finally{Et(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:i},s}function ly(i,s,a,l){return i.baseState=a,Ap(i,zt,typeof l=="function"?l:pr)}function jT(i,s,a,l,d){if(Od(i))throw Error(r(485));if(i=s.action,i!==null){var h={payload:d,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){h.listeners.push(_)}};O.T!==null?a(!0):h.isTransition=!1,l(h),a=s.pending,a===null?(h.next=s.pending=h,cy(s,h)):(h.next=a.next,s.pending=a.next=h)}}function cy(i,s){var a=s.action,l=s.payload,d=i.state;if(s.isTransition){var h=O.T,_={};O.T=_;try{var T=a(d,l),A=O.S;A!==null&&A(_,T),uy(i,s,T)}catch(Z){Bp(i,s,Z)}finally{h!==null&&_.types!==null&&(h.types=_.types),O.T=h}}else try{h=a(d,l),uy(i,s,h)}catch(Z){Bp(i,s,Z)}}function uy(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){dy(i,s,l)},function(l){return Bp(i,s,l)}):dy(i,s,a)}function dy(i,s,a){s.status="fulfilled",s.value=a,hy(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,cy(i,a)))}function Bp(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,hy(s),s=s.next;while(s!==l)}i.action=null}function hy(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function fy(i,s){return s}function py(i,s){if(xt){var a=Vt.formState;if(a!==null){e:{var l=ot;if(xt){if(Qt){t:{for(var d=Qt,h=ts;d.nodeType!==8;){if(!h){d=null;break t}if(d=ns(d.nextSibling),d===null){d=null;break t}}h=d.data,d=h==="F!"||h==="F"?d:null}if(d){Qt=ns(d.nextSibling),l=d.data==="F!";break e}}ea(l)}l=!1}l&&(s=a[0])}}return a=wn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fy,lastRenderedState:s},a.queue=l,a=Ly.bind(null,ot,l),l.dispatch=a,l=Op(!1),h=Up.bind(null,ot,!1,l.queue),l=wn(),d={state:s,dispatch:null,action:i,pending:null},l.queue=d,a=jT.bind(null,ot,d,h,a),d.dispatch=a,l.memoizedState=i,[s,a,!1]}function my(i){var s=Ci();return gy(s,zt,i)}function gy(i,s,a){if(s=Ap(i,s,fy)[0],i=Nd(pr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=_c(s)}catch(_){throw _===Jo?Sd:_}else l=s;s=Ci();var d=s.queue,h=d.dispatch;return a!==s.memoizedState&&(ot.flags|=2048,sl(9,{destroy:void 0},IT.bind(null,d,a),null)),[l,h,i]}function IT(i,s){i.action=s}function vy(i){var s=Ci(),a=zt;if(a!==null)return gy(s,a,i);Ci(),s=s.memoizedState,a=Ci();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function sl(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=ot.updateQueue,s===null&&(s=Rd(),ot.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,s.lastEffect=i),i}function _y(){return Ci().memoizedState}function Ad(i,s,a,l){var d=wn();ot.flags|=i,d.memoizedState=sl(1|s,{destroy:void 0},a,l===void 0?null:l)}function Ld(i,s,a,l){var d=Ci();l=l===void 0?null:l;var h=d.memoizedState.inst;zt!==null&&l!==null&&Tp(l,zt.memoizedState.deps)?d.memoizedState=sl(s,h,a,l):(ot.flags|=i,d.memoizedState=sl(1|s,h,a,l))}function by(i,s){Ad(8390656,8,i,s)}function jp(i,s){Ld(2048,8,i,s)}function zT(i){ot.flags|=4;var s=ot.updateQueue;if(s===null)s=Rd(),ot.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function yy(i){var s=Ci().memoizedState;return zT({ref:s,nextImpl:i}),function(){if((Mt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Sy(i,s){return Ld(4,2,i,s)}function wy(i,s){return Ld(4,4,i,s)}function Cy(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function xy(i,s,a){a=a!=null?a.concat([i]):null,Ld(4,4,Cy.bind(null,s,i),a)}function Ip(){}function ky(i,s){var a=Ci();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Tp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function Ty(i,s){var a=Ci();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Tp(s,l[1]))return l[0];if(l=i(),lo){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,s],l}function zp(i,s,a){return a===void 0||(fr&1073741824)!==0&&(wt&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=ES(),ot.lanes|=i,ca|=i,a)}function Ey(i,s,a,l){return Sn(a,s)?a:tl.current!==null?(i=zp(i,a,l),Sn(i,s)||(Ri=!0),i):(fr&42)===0||(fr&1073741824)!==0&&(wt&261930)===0?(Ri=!0,i.memoizedState=a):(i=ES(),ot.lanes|=i,ca|=i,s)}function Dy(i,s,a,l,d){var h=M.p;M.p=h!==0&&8>h?h:8;var _=O.T,T={};O.T=T,Up(i,!1,s,a);try{var A=d(),Z=O.S;if(Z!==null&&Z(T,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var he=LT(A,l);bc(i,s,he,Wn(i))}else bc(i,s,l,Wn(i))}catch(_e){bc(i,s,{then:function(){},status:"rejected",reason:_e},Wn())}finally{M.p=h,_!==null&&T.types!==null&&(_.types=T.types),O.T=_}}function PT(){}function Pp(i,s,a,l){if(i.tag!==5)throw Error(r(476));var d=Ry(i).queue;Dy(i,d,s,B,a===null?PT:function(){return My(i),a(l)})}function Ry(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:B},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function My(i){var s=Ry(i);s.next===null&&(s=i.alternate.memoizedState),bc(i,s.next.queue,{},Wn())}function Hp(){return rn(jc)}function Ny(){return Ci().memoizedState}function Ay(){return Ci().memoizedState}function HT(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Wn();i=na(a);var l=sa(s,i,a);l!==null&&(Nn(l,s,a),pc(l,s,a)),s={cache:mp()},i.payload=s;return}s=s.return}}function UT(i,s,a){var l=Wn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Od(i)?Oy(s,a):(a=sp(i,s,a,l),a!==null&&(Nn(a,i,l),By(a,s,l)))}function Ly(i,s,a){var l=Wn();bc(i,s,a,l)}function bc(i,s,a,l){var d={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Od(i))Oy(s,d);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var _=s.lastRenderedState,T=h(_,a);if(d.hasEagerState=!0,d.eagerState=T,Sn(T,_))return pd(i,s,d,0),Vt===null&&fd(),!1}catch{}if(a=sp(i,s,d,l),a!==null)return Nn(a,i,l),By(a,s,l),!0}return!1}function Up(i,s,a,l){if(l={lane:2,revertLane:bm(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Od(i)){if(s)throw Error(r(479))}else s=sp(i,a,l,2),s!==null&&Nn(s,i,2)}function Od(i){var s=i.alternate;return i===ot||s!==null&&s===ot}function Oy(i,s){il=Ed=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function By(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,ti(i,a)}}var yc={readContext:rn,use:Md,useCallback:hi,useContext:hi,useEffect:hi,useImperativeHandle:hi,useLayoutEffect:hi,useInsertionEffect:hi,useMemo:hi,useReducer:hi,useRef:hi,useState:hi,useDebugValue:hi,useDeferredValue:hi,useTransition:hi,useSyncExternalStore:hi,useId:hi,useHostTransitionStatus:hi,useFormState:hi,useActionState:hi,useOptimistic:hi,useMemoCache:hi,useCacheRefresh:hi};yc.useEffectEvent=hi;var jy={readContext:rn,use:Md,useCallback:function(i,s){return wn().memoizedState=[i,s===void 0?null:s],i},useContext:rn,useEffect:by,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,Ad(4194308,4,Cy.bind(null,s,i),a)},useLayoutEffect:function(i,s){return Ad(4194308,4,i,s)},useInsertionEffect:function(i,s){Ad(4,2,i,s)},useMemo:function(i,s){var a=wn();s=s===void 0?null:s;var l=i();if(lo){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=wn();if(a!==void 0){var d=a(s);if(lo){Et(!0);try{a(s)}finally{Et(!1)}}}else d=s;return l.memoizedState=l.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},l.queue=i,i=i.dispatch=UT.bind(null,ot,i),[l.memoizedState,i]},useRef:function(i){var s=wn();return i={current:i},s.memoizedState=i},useState:function(i){i=Op(i);var s=i.queue,a=Ly.bind(null,ot,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:Ip,useDeferredValue:function(i,s){var a=wn();return zp(a,i,s)},useTransition:function(){var i=Op(!1);return i=Dy.bind(null,ot,i.queue,!0,!1),wn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=ot,d=wn();if(xt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Vt===null)throw Error(r(349));(wt&127)!==0||ny(l,s,a)}d.memoizedState=a;var h={value:a,getSnapshot:s};return d.queue=h,by(ry.bind(null,l,h,i),[i]),l.flags|=2048,sl(9,{destroy:void 0},sy.bind(null,l,h,a,s),null),a},useId:function(){var i=wn(),s=Vt.identifierPrefix;if(xt){var a=Ps,l=zs;a=(l&~(1<<32-ct(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Dd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=OT++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:Hp,useFormState:py,useActionState:py,useOptimistic:function(i){var s=wn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=Up.bind(null,ot,!0,a),a.dispatch=s,[i,s]},useMemoCache:Np,useCacheRefresh:function(){return wn().memoizedState=HT.bind(null,ot)},useEffectEvent:function(i){var s=wn(),a={impl:i};return s.memoizedState=a,function(){if((Mt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Kp={readContext:rn,use:Md,useCallback:ky,useContext:rn,useEffect:jp,useImperativeHandle:xy,useInsertionEffect:Sy,useLayoutEffect:wy,useMemo:Ty,useReducer:Nd,useRef:_y,useState:function(){return Nd(pr)},useDebugValue:Ip,useDeferredValue:function(i,s){var a=Ci();return Ey(a,zt.memoizedState,i,s)},useTransition:function(){var i=Nd(pr)[0],s=Ci().memoizedState;return[typeof i=="boolean"?i:_c(i),s]},useSyncExternalStore:iy,useId:Ny,useHostTransitionStatus:Hp,useFormState:my,useActionState:my,useOptimistic:function(i,s){var a=Ci();return ly(a,zt,i,s)},useMemoCache:Np,useCacheRefresh:Ay};Kp.useEffectEvent=yy;var Iy={readContext:rn,use:Md,useCallback:ky,useContext:rn,useEffect:jp,useImperativeHandle:xy,useInsertionEffect:Sy,useLayoutEffect:wy,useMemo:Ty,useReducer:Lp,useRef:_y,useState:function(){return Lp(pr)},useDebugValue:Ip,useDeferredValue:function(i,s){var a=Ci();return zt===null?zp(a,i,s):Ey(a,zt.memoizedState,i,s)},useTransition:function(){var i=Lp(pr)[0],s=Ci().memoizedState;return[typeof i=="boolean"?i:_c(i),s]},useSyncExternalStore:iy,useId:Ny,useHostTransitionStatus:Hp,useFormState:vy,useActionState:vy,useOptimistic:function(i,s){var a=Ci();return zt!==null?ly(a,zt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Np,useCacheRefresh:Ay};Iy.useEffectEvent=yy;function Wp(i,s,a,l){s=i.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Fp={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=na(l);d.payload=s,a!=null&&(d.callback=a),s=sa(i,d,l),s!==null&&(Nn(s,i,l),pc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=na(l);d.tag=1,d.payload=s,a!=null&&(d.callback=a),s=sa(i,d,l),s!==null&&(Nn(s,i,l),pc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Wn(),l=na(a);l.tag=2,s!=null&&(l.callback=s),s=sa(i,l,a),s!==null&&(Nn(s,i,a),pc(s,i,a))}};function zy(i,s,a,l,d,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):s.prototype&&s.prototype.isPureReactComponent?!Zr(a,l)||!Zr(d,h):!0}function Py(i,s,a,l){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==i&&Fp.enqueueReplaceState(s,s.state,null)}function co(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var d in i)a[d]===void 0&&(a[d]=i[d])}return a}function Hy(i){hd(i)}function Uy(i){console.error(i)}function Ky(i){hd(i)}function Bd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Wy(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function $p(i,s,a){return a=na(a),a.tag=3,a.payload={element:null},a.callback=function(){Bd(i,s)},a}function Fy(i){return i=na(i),i.tag=3,i}function $y(i,s,a,l){var d=a.type.getDerivedStateFromError;if(typeof d=="function"){var h=l.value;i.payload=function(){return d(h)},i.callback=function(){Wy(s,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Wy(s,a,l),typeof d!="function"&&(ua===null?ua=new Set([this]):ua.add(this));var T=l.stack;this.componentDidCatch(l.value,{componentStack:T!==null?T:""})})}function KT(i,s,a,l,d){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Go(s,a,d,!0),a=Pn.current,a!==null){switch(a.tag){case 31:case 13:return is===null?Vd():a.alternate===null&&fi===0&&(fi=3),a.flags&=-257,a.flags|=65536,a.lanes=d,l===wd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),gm(i,l,d)),!1;case 22:return a.flags|=65536,l===wd?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([l]):a.add(l)),gm(i,l,d)),!1}throw Error(r(435,a.tag))}return gm(i,l,d),Vd(),!1}if(xt)return s=Pn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=d,l!==up&&(i=Error(r(422),{cause:l}),cc(Qn(i,a)))):(l!==up&&(s=Error(r(423),{cause:l}),cc(Qn(s,a))),i=i.current.alternate,i.flags|=65536,d&=-d,i.lanes|=d,l=Qn(l,a),d=$p(i.stateNode,l,d),Sp(i,d),fi!==4&&(fi=2)),!1;var h=Error(r(520),{cause:l});if(h=Qn(h,a),Dc===null?Dc=[h]:Dc.push(h),fi!==4&&(fi=2),s===null)return!0;l=Qn(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=d&-d,a.lanes|=i,i=$p(a.stateNode,l,i),Sp(a,i),!1;case 1:if(s=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(ua===null||!ua.has(h))))return a.flags|=65536,d&=-d,a.lanes|=d,d=Fy(d),$y(d,i,a,l),Sp(a,d),!1}a=a.return}while(a!==null);return!1}var qp=Error(r(461)),Ri=!1;function an(i,s,a,l){s.child=i===null?Xb(s,null,a,l):oo(s,i.child,a,l)}function qy(i,s,a,l,d){a=a.render;var h=s.ref;if("ref"in l){var _={};for(var T in l)T!=="ref"&&(_[T]=l[T])}else _=l;return no(s),l=Ep(i,s,a,_,h,d),T=Dp(),i!==null&&!Ri?(Rp(i,s,d),mr(i,s,d)):(xt&&T&&lp(s),s.flags|=1,an(i,s,l,d),s.child)}function Vy(i,s,a,l,d){if(i===null){var h=a.type;return typeof h=="function"&&!rp(h)&&h.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=h,Yy(i,s,h,l,d)):(i=gd(a.type,null,l,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(h=i.child,!em(i,d)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Zr,a(_,l)&&i.ref===s.ref)return mr(i,s,d)}return s.flags|=1,i=cr(h,l),i.ref=s.ref,i.return=s,s.child=i}function Yy(i,s,a,l,d){if(i!==null){var h=i.memoizedProps;if(Zr(h,l)&&i.ref===s.ref)if(Ri=!1,s.pendingProps=l=h,em(i,d))(i.flags&131072)!==0&&(Ri=!0);else return s.lanes=i.lanes,mr(i,s,d)}return Vp(i,s,a,l,d)}function Xy(i,s,a,l){var d=l.children,h=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(l=s.child=i.child,d=0;l!==null;)d=d|l.lanes|l.childLanes,l=l.sibling;l=d&~h}else l=0,s.child=null;return Gy(i,s,h,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&yd(s,h!==null?h.cachePool:null),h!==null?Qb(s,h):Cp(),Jb(s);else return l=s.lanes=536870912,Gy(i,s,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(yd(s,h.cachePool),Qb(s,h),aa(),s.memoizedState=null):(i!==null&&yd(s,null),Cp(),aa());return an(i,s,d,a),s.child}function Sc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function Gy(i,s,a,l,d){var h=vp();return h=h===null?null:{parent:Ei._currentValue,pool:h},s.memoizedState={baseLanes:a,cachePool:h},i!==null&&yd(s,null),Cp(),Jb(s),i!==null&&Go(i,s,l,!0),s.childLanes=d,null}function jd(i,s){return s=zd({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function Zy(i,s,a){return oo(s,i.child,null,a),i=jd(s,s.pendingProps),i.flags|=2,Hn(s),s.memoizedState=null,i}function WT(i,s,a){var l=s.pendingProps,d=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(xt){if(l.mode==="hidden")return i=jd(s,l),s.lanes=536870912,Sc(null,i);if(kp(s),(i=Qt)?(i=c0(i,ts),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:zs,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},a=Ob(i),a.return=s,s.child=a,sn=s,Qt=null)):i=null,i===null)throw ea(s);return s.lanes=536870912,null}return jd(s,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(kp(s),d)if(s.flags&256)s.flags&=-257,s=Zy(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Ri||Go(i,s,a,!1),d=(a&i.childLanes)!==0,Ri||d){if(l=Vt,l!==null&&(_=Ui(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,Ja(i,_),Nn(l,i,_),qp;Vd(),s=Zy(i,s,a)}else i=h.treeContext,Qt=ns(_.nextSibling),sn=s,xt=!0,Jr=null,ts=!1,i!==null&&Ib(s,i),s=jd(s,l),s.flags|=4096;return s}return i=cr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Id(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function Vp(i,s,a,l,d){return no(s),a=Ep(i,s,a,l,void 0,d),l=Dp(),i!==null&&!Ri?(Rp(i,s,d),mr(i,s,d)):(xt&&l&&lp(s),s.flags|=1,an(i,s,a,d),s.child)}function Qy(i,s,a,l,d,h){return no(s),s.updateQueue=null,a=ty(s,l,a,d),ey(i),l=Dp(),i!==null&&!Ri?(Rp(i,s,h),mr(i,s,h)):(xt&&l&&lp(s),s.flags|=1,an(i,s,a,h),s.child)}function Jy(i,s,a,l,d){if(no(s),s.stateNode===null){var h=qo,_=a.contextType;typeof _=="object"&&_!==null&&(h=rn(_)),h=new a(l,h),s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Fp,s.stateNode=h,h._reactInternals=s,h=s.stateNode,h.props=l,h.state=s.memoizedState,h.refs={},bp(s),_=a.contextType,h.context=typeof _=="object"&&_!==null?rn(_):qo,h.state=s.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Wp(s,a,_,l),h.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(_=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),_!==h.state&&Fp.enqueueReplaceState(h,h.state,null),gc(s,l,h,d),mc(),h.state=s.memoizedState),typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){h=s.stateNode;var T=s.memoizedProps,A=co(a,T);h.props=A;var Z=h.context,he=a.contextType;_=qo,typeof he=="object"&&he!==null&&(_=rn(he));var _e=a.getDerivedStateFromProps;he=typeof _e=="function"||typeof h.getSnapshotBeforeUpdate=="function",T=s.pendingProps!==T,he||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(T||Z!==_)&&Py(s,h,l,_),ia=!1;var te=s.memoizedState;h.state=te,gc(s,l,h,d),mc(),Z=s.memoizedState,T||te!==Z||ia?(typeof _e=="function"&&(Wp(s,a,_e,l),Z=s.memoizedState),(A=ia||zy(s,a,A,l,te,Z,_))?(he||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(s.flags|=4194308)):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=Z),h.props=l,h.state=Z,h.context=_,l=A):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{h=s.stateNode,yp(i,s),_=s.memoizedProps,he=co(a,_),h.props=he,_e=s.pendingProps,te=h.context,Z=a.contextType,A=qo,typeof Z=="object"&&Z!==null&&(A=rn(Z)),T=a.getDerivedStateFromProps,(Z=typeof T=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==_e||te!==A)&&Py(s,h,l,A),ia=!1,te=s.memoizedState,h.state=te,gc(s,l,h,d),mc();var ce=s.memoizedState;_!==_e||te!==ce||ia||i!==null&&i.dependencies!==null&&_d(i.dependencies)?(typeof T=="function"&&(Wp(s,a,T,l),ce=s.memoizedState),(he=ia||zy(s,a,he,l,te,ce,A)||i!==null&&i.dependencies!==null&&_d(i.dependencies))?(Z||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(l,ce,A),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(l,ce,A)),typeof h.componentDidUpdate=="function"&&(s.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ce),h.props=l,h.state=ce,h.context=A,l=he):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),l=!1)}return h=l,Id(i,s),l=(s.flags&128)!==0,h||l?(h=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:h.render(),s.flags|=1,i!==null&&l?(s.child=oo(s,i.child,null,d),s.child=oo(s,null,a,d)):an(i,s,a,d),s.memoizedState=h.state,i=s.child):i=mr(i,s,d),i}function eS(i,s,a,l){return to(),s.flags|=256,an(i,s,a,l),s.child}var Yp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Xp(i){return{baseLanes:i,cachePool:Wb()}}function Gp(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Kn),i}function tS(i,s,a){var l=s.pendingProps,d=!1,h=(s.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(wi.current&2)!==0),_&&(d=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,i===null){if(xt){if(d?ra(s):aa(),(i=Qt)?(i=c0(i,ts),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:zs,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},a=Ob(i),a.return=s,s.child=a,sn=s,Qt=null)):i=null,i===null)throw ea(s);return Am(i)?s.lanes=32:s.lanes=536870912,null}var T=l.children;return l=l.fallback,d?(aa(),d=s.mode,T=zd({mode:"hidden",children:T},d),l=eo(l,d,a,null),T.return=s,l.return=s,T.sibling=l,s.child=T,l=s.child,l.memoizedState=Xp(a),l.childLanes=Gp(i,_,a),s.memoizedState=Yp,Sc(null,l)):(ra(s),Zp(s,T))}var A=i.memoizedState;if(A!==null&&(T=A.dehydrated,T!==null)){if(h)s.flags&256?(ra(s),s.flags&=-257,s=Qp(i,s,a)):s.memoizedState!==null?(aa(),s.child=i.child,s.flags|=128,s=null):(aa(),T=l.fallback,d=s.mode,l=zd({mode:"visible",children:l.children},d),T=eo(T,d,a,null),T.flags|=2,l.return=s,T.return=s,l.sibling=T,s.child=l,oo(s,i.child,null,a),l=s.child,l.memoizedState=Xp(a),l.childLanes=Gp(i,_,a),s.memoizedState=Yp,s=Sc(null,l));else if(ra(s),Am(T)){if(_=T.nextSibling&&T.nextSibling.dataset,_)var Z=_.dgst;_=Z,l=Error(r(419)),l.stack="",l.digest=_,cc({value:l,source:null,stack:null}),s=Qp(i,s,a)}else if(Ri||Go(i,s,a,!1),_=(a&i.childLanes)!==0,Ri||_){if(_=Vt,_!==null&&(l=Ui(_,a),l!==0&&l!==A.retryLane))throw A.retryLane=l,Ja(i,l),Nn(_,i,l),qp;Nm(T)||Vd(),s=Qp(i,s,a)}else Nm(T)?(s.flags|=192,s.child=i.child,s=null):(i=A.treeContext,Qt=ns(T.nextSibling),sn=s,xt=!0,Jr=null,ts=!1,i!==null&&Ib(s,i),s=Zp(s,l.children),s.flags|=4096);return s}return d?(aa(),T=l.fallback,d=s.mode,A=i.child,Z=A.sibling,l=cr(A,{mode:"hidden",children:l.children}),l.subtreeFlags=A.subtreeFlags&65011712,Z!==null?T=cr(Z,T):(T=eo(T,d,a,null),T.flags|=2),T.return=s,l.return=s,l.sibling=T,s.child=l,Sc(null,l),l=s.child,T=i.child.memoizedState,T===null?T=Xp(a):(d=T.cachePool,d!==null?(A=Ei._currentValue,d=d.parent!==A?{parent:A,pool:A}:d):d=Wb(),T={baseLanes:T.baseLanes|a,cachePool:d}),l.memoizedState=T,l.childLanes=Gp(i,_,a),s.memoizedState=Yp,Sc(i.child,l)):(ra(s),a=i.child,i=a.sibling,a=cr(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,i!==null&&(_=s.deletions,_===null?(s.deletions=[i],s.flags|=16):_.push(i)),s.child=a,s.memoizedState=null,a)}function Zp(i,s){return s=zd({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function zd(i,s){return i=zn(22,i,null,s),i.lanes=0,i}function Qp(i,s,a){return oo(s,i.child,null,a),i=Zp(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function iS(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),fp(i.return,s,a)}function Jp(i,s,a,l,d,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:d,treeForkCount:h}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=d,_.treeForkCount=h)}function nS(i,s,a){var l=s.pendingProps,d=l.revealOrder,h=l.tail;l=l.children;var _=wi.current,T=(_&2)!==0;if(T?(_=_&1|2,s.flags|=128):_&=1,ue(wi,_),an(i,s,l,a),l=xt?lc:0,!T&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&iS(i,a,s);else if(i.tag===19)iS(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&Td(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),Jp(s,!1,d,a,h,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&Td(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}Jp(s,!0,a,null,h,l);break;case"together":Jp(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function mr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),ca|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Go(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=cr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=cr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function em(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&_d(i)))}function FT(i,s,a){switch(s.tag){case 3:Ne(s,s.stateNode.containerInfo),ta(s,Ei,i.memoizedState.cache),to();break;case 27:case 5:We(s);break;case 4:Ne(s,s.stateNode.containerInfo);break;case 10:ta(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,kp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(ra(s),s.flags|=128,null):(a&s.child.childLanes)!==0?tS(i,s,a):(ra(s),i=mr(i,s,a),i!==null?i.sibling:null);ra(s);break;case 19:var d=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Go(i,s,a,!1),l=(a&s.childLanes)!==0),d){if(l)return nS(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),ue(wi,wi.current),l)break;return null;case 22:return s.lanes=0,Xy(i,s,a,s.pendingProps);case 24:ta(s,Ei,i.memoizedState.cache)}return mr(i,s,a)}function sS(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Ri=!0;else{if(!em(i,a)&&(s.flags&128)===0)return Ri=!1,FT(i,s,a);Ri=(i.flags&131072)!==0}else Ri=!1,xt&&(s.flags&1048576)!==0&&jb(s,lc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=ro(s.elementType),s.type=i,typeof i=="function")rp(i)?(l=co(i,l),s.tag=1,s=Jy(null,s,i,l,a)):(s.tag=0,s=Vp(null,s,i,l,a));else{if(i!=null){var d=i.$$typeof;if(d===$){s.tag=11,s=qy(null,s,i,l,a);break e}else if(d===F){s.tag=14,s=Vy(null,s,i,l,a);break e}}throw s=W(i)||i,Error(r(306,s,""))}}return s;case 0:return Vp(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,d=co(l,s.pendingProps),Jy(i,s,l,d,a);case 3:e:{if(Ne(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var h=s.memoizedState;d=h.element,yp(i,s),gc(s,l,null,a);var _=s.memoizedState;if(l=_.cache,ta(s,Ei,l),l!==h.cache&&pp(s,[Ei],a,!0),mc(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){s=eS(i,s,l,a);break e}else if(l!==d){d=Qn(Error(r(424)),s),cc(d),s=eS(i,s,l,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Qt=ns(i.firstChild),sn=s,xt=!0,Jr=null,ts=!0,a=Xb(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(to(),l===d){s=mr(i,s,a);break e}an(i,s,l,a)}s=s.child}return s;case 26:return Id(i,s),i===null?(a=m0(s.type,null,s.pendingProps,null))?s.memoizedState=a:xt||(a=s.type,i=s.pendingProps,l=eh(De.current).createElement(a),l[_i]=s,l[bi]=i,on(l,a,i),It(l),s.stateNode=l):s.memoizedState=m0(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return We(s),i===null&&xt&&(l=s.stateNode=h0(s.type,s.pendingProps,De.current),sn=s,ts=!0,d=Qt,pa(s.type)?(Lm=d,Qt=ns(l.firstChild)):Qt=d),an(i,s,s.pendingProps.children,a),Id(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&xt&&((d=l=Qt)&&(l=yE(l,s.type,s.pendingProps,ts),l!==null?(s.stateNode=l,sn=s,Qt=ns(l.firstChild),ts=!1,d=!0):d=!1),d||ea(s)),We(s),d=s.type,h=s.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,Dm(d,h)?l=null:_!==null&&Dm(d,_)&&(s.flags|=32),s.memoizedState!==null&&(d=Ep(i,s,BT,null,null,a),jc._currentValue=d),Id(i,s),an(i,s,l,a),s.child;case 6:return i===null&&xt&&((i=a=Qt)&&(a=SE(a,s.pendingProps,ts),a!==null?(s.stateNode=a,sn=s,Qt=null,i=!0):i=!1),i||ea(s)),null;case 13:return tS(i,s,a);case 4:return Ne(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=oo(s,null,l,a):an(i,s,l,a),s.child;case 11:return qy(i,s,s.type,s.pendingProps,a);case 7:return an(i,s,s.pendingProps,a),s.child;case 8:return an(i,s,s.pendingProps.children,a),s.child;case 12:return an(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,ta(s,s.type,l.value),an(i,s,l.children,a),s.child;case 9:return d=s.type._context,l=s.pendingProps.children,no(s),d=rn(d),l=l(d),s.flags|=1,an(i,s,l,a),s.child;case 14:return Vy(i,s,s.type,s.pendingProps,a);case 15:return Yy(i,s,s.type,s.pendingProps,a);case 19:return nS(i,s,a);case 31:return WT(i,s,a);case 22:return Xy(i,s,a,s.pendingProps);case 24:return no(s),l=rn(Ei),i===null?(d=vp(),d===null&&(d=Vt,h=mp(),d.pooledCache=h,h.refCount++,h!==null&&(d.pooledCacheLanes|=a),d=h),s.memoizedState={parent:l,cache:d},bp(s),ta(s,Ei,d)):((i.lanes&a)!==0&&(yp(i,s),gc(s,null,null,a),mc()),d=i.memoizedState,h=s.memoizedState,d.parent!==l?(d={parent:l,cache:l},s.memoizedState=d,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=d),ta(s,Ei,l)):(l=h.cache,ta(s,Ei,l),l!==d.cache&&pp(s,[Ei],a,!0))),an(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function gr(i){i.flags|=4}function tm(i,s,a,l,d){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(d&335544128)===d)if(i.stateNode.complete)i.flags|=8192;else if(NS())i.flags|=8192;else throw ao=wd,_p}else i.flags&=-16777217}function rS(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!y0(s))if(NS())i.flags|=8192;else throw ao=wd,_p}function Pd(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Gt():536870912,i.lanes|=s,ll|=s)}function wc(i,s){if(!xt)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function Jt(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags&65011712,l|=d.flags&65011712,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function $T(i,s,a){var l=s.pendingProps;switch(cp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jt(s),null;case 1:return Jt(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),hr(Ei),Ue(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Xo(s)?gr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,dp())),Jt(s),null;case 26:var d=s.type,h=s.memoizedState;return i===null?(gr(s),h!==null?(Jt(s),rS(s,h)):(Jt(s),tm(s,d,null,l,a))):h?h!==i.memoizedState?(gr(s),Jt(s),rS(s,h)):(Jt(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&gr(s),Jt(s),tm(s,d,i,l,a)),null;case 27:if(ne(s),a=De.current,d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Jt(s),null}i=Ce.current,Xo(s)?zb(s):(i=h0(d,l,a),s.stateNode=i,gr(s))}return Jt(s),null;case 5:if(ne(s),d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Jt(s),null}if(h=Ce.current,Xo(s))zb(s);else{var _=eh(De.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":h=_.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?h.multiple=!0:l.size&&(h.size=l.size);break;default:h=typeof l.is=="string"?_.createElement(d,{is:l.is}):_.createElement(d)}}h[_i]=s,h[bi]=l;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)h.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=h;e:switch(on(h,d,l),d){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&gr(s)}}return Jt(s),tm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=De.current,Xo(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,d=sn,d!==null)switch(d.tag){case 27:case 5:l=d.memoizedProps}i[_i]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||t0(i.nodeValue,a)),i||ea(s,!0)}else i=eh(i).createTextNode(l),i[_i]=s,s.stateNode=i}return Jt(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=Xo(s),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_i]=s}else to(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Jt(s),i=!1}else a=dp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Hn(s),s):(Hn(s),null);if((s.flags&128)!==0)throw Error(r(558))}return Jt(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=Xo(s),l!==null&&l.dehydrated!==null){if(i===null){if(!d)throw Error(r(318));if(d=s.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[_i]=s}else to(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Jt(s),d=!1}else d=dp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return s.flags&256?(Hn(s),s):(Hn(s),null)}return Hn(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,d=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(d=l.alternate.memoizedState.cachePool.pool),h=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(h=l.memoizedState.cachePool.pool),h!==d&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Pd(s,s.updateQueue),Jt(s),null);case 4:return Ue(),i===null&&Cm(s.stateNode.containerInfo),Jt(s),null;case 10:return hr(s.type),Jt(s),null;case 19:if(U(wi),l=s.memoizedState,l===null)return Jt(s),null;if(d=(s.flags&128)!==0,h=l.rendering,h===null)if(d)wc(l,!1);else{if(fi!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(h=Td(i),h!==null){for(s.flags|=128,wc(l,!1),i=h.updateQueue,s.updateQueue=i,Pd(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)Lb(a,i),a=a.sibling;return ue(wi,wi.current&1|2),xt&&ur(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&<()>Fd&&(s.flags|=128,d=!0,wc(l,!1),s.lanes=4194304)}else{if(!d)if(i=Td(h),i!==null){if(s.flags|=128,d=!0,i=i.updateQueue,s.updateQueue=i,Pd(s,i),wc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!xt)return Jt(s),null}else 2*lt()-l.renderingStartTime>Fd&&a!==536870912&&(s.flags|=128,d=!0,wc(l,!1),s.lanes=4194304);l.isBackwards?(h.sibling=s.child,s.child=h):(i=l.last,i!==null?i.sibling=h:s.child=h,l.last=h)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=lt(),i.sibling=null,a=wi.current,ue(wi,d?a&1|2:a&1),xt&&ur(s,l.treeForkCount),i):(Jt(s),null);case 22:case 23:return Hn(s),xp(),l=s.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(Jt(s),s.subtreeFlags&6&&(s.flags|=8192)):Jt(s),a=s.updateQueue,a!==null&&Pd(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),i!==null&&U(so),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),hr(Ei),Jt(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function qT(i,s){switch(cp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return hr(Ei),Ue(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return ne(s),null;case 31:if(s.memoizedState!==null){if(Hn(s),s.alternate===null)throw Error(r(340));to()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Hn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));to()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return U(wi),null;case 4:return Ue(),null;case 10:return hr(s.type),null;case 22:case 23:return Hn(s),xp(),i!==null&&U(so),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return hr(Ei),null;case 25:return null;default:return null}}function aS(i,s){switch(cp(s),s.tag){case 3:hr(Ei),Ue();break;case 26:case 27:case 5:ne(s);break;case 4:Ue();break;case 31:s.memoizedState!==null&&Hn(s);break;case 13:Hn(s);break;case 19:U(wi);break;case 10:hr(s.type);break;case 22:case 23:Hn(s),xp(),i!==null&&U(so);break;case 24:hr(Ei)}}function Cc(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var d=l.next;a=d;do{if((a.tag&i)===i){l=void 0;var h=a.create,_=a.inst;l=h(),_.destroy=l}a=a.next}while(a!==d)}}catch(T){jt(s,s.return,T)}}function oa(i,s,a){try{var l=s.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var h=d.next;l=h;do{if((l.tag&i)===i){var _=l.inst,T=_.destroy;if(T!==void 0){_.destroy=void 0,d=s;var A=a,Z=T;try{Z()}catch(he){jt(d,A,he)}}}l=l.next}while(l!==h)}}catch(he){jt(s,s.return,he)}}function oS(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{Zb(s,a)}catch(l){jt(i,i.return,l)}}}function lS(i,s,a){a.props=co(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){jt(i,s,l)}}function xc(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(d){jt(i,s,d)}}function Hs(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(d){jt(i,s,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(d){jt(i,s,d)}else a.current=null}function cS(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(d){jt(i,i.return,d)}}function im(i,s,a){try{var l=i.stateNode;pE(l,i.type,a,s),l[bi]=s}catch(d){jt(i,i.return,d)}}function uS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&pa(i.type)||i.tag===4}function nm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||uS(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&&pa(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 sm(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Yn));else if(l!==4&&(l===27&&pa(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(sm(i,s,a),i=i.sibling;i!==null;)sm(i,s,a),i=i.sibling}function Hd(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(l!==4&&(l===27&&pa(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Hd(i,s,a),i=i.sibling;i!==null;)Hd(i,s,a),i=i.sibling}function dS(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,d=s.attributes;d.length;)s.removeAttributeNode(d[0]);on(s,l,a),s[_i]=i,s[bi]=a}catch(h){jt(i,i.return,h)}}var vr=!1,Mi=!1,rm=!1,hS=typeof WeakSet=="function"?WeakSet:Set,$i=null;function VT(i,s){if(i=i.containerInfo,Tm=oh,i=dd(i),Qa(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,T=-1,A=-1,Z=0,he=0,_e=i,te=null;t:for(;;){for(var ce;_e!==a||d!==0&&_e.nodeType!==3||(T=_+d),_e!==h||l!==0&&_e.nodeType!==3||(A=_+l),_e.nodeType===3&&(_+=_e.nodeValue.length),(ce=_e.firstChild)!==null;)te=_e,_e=ce;for(;;){if(_e===i)break t;if(te===a&&++Z===d&&(T=_),te===h&&++he===l&&(A=_),(ce=_e.nextSibling)!==null)break;_e=te,te=_e.parentNode}_e=ce}a=T===-1||A===-1?null:{start:T,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(Em={focusedElem:i,selectionRange:a},oh=!1,$i=s;$i!==null;)if(s=$i,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,$i=i;else for(;$i!==null;){switch(s=$i,h=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)d=i[a],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=s,d=h.memoizedProps,h=h.memoizedState,l=a.stateNode;try{var He=co(a.type,d);i=l.getSnapshotBeforeUpdate(He,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Je){jt(a,a.return,Je)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Mm(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Mm(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,$i=i;break}$i=s.return}}function fS(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:br(i,a),l&4&&Cc(5,a);break;case 1:if(br(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(_){jt(a,a.return,_)}else{var d=co(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(d,s,i.__reactInternalSnapshotBeforeUpdate)}catch(_){jt(a,a.return,_)}}l&64&&oS(a),l&512&&xc(a,a.return);break;case 3:if(br(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{Zb(i,s)}catch(_){jt(a,a.return,_)}}break;case 27:s===null&&l&4&&dS(a);case 26:case 5:br(i,a),s===null&&l&4&&cS(a),l&512&&xc(a,a.return);break;case 12:br(i,a);break;case 31:br(i,a),l&4&&gS(i,a);break;case 13:br(i,a),l&4&&vS(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=iE.bind(null,a),wE(i,a))));break;case 22:if(l=a.memoizedState!==null||vr,!l){s=s!==null&&s.memoizedState!==null||Mi,d=vr;var h=Mi;vr=l,(Mi=s)&&!h?yr(i,a,(a.subtreeFlags&8772)!==0):br(i,a),vr=d,Mi=h}break;case 30:break;default:br(i,a)}}function pS(i){var s=i.alternate;s!==null&&(i.alternate=null,pS(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Qs(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var ni=null,En=!1;function _r(i,s,a){for(a=a.child;a!==null;)mS(i,s,a),a=a.sibling}function mS(i,s,a){if(Ze&&typeof Ze.onCommitFiberUnmount=="function")try{Ze.onCommitFiberUnmount(rt,a)}catch{}switch(a.tag){case 26:Mi||Hs(a,s),_r(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Mi||Hs(a,s);var l=ni,d=En;pa(a.type)&&(ni=a.stateNode,En=!1),_r(i,s,a),Lc(a.stateNode),ni=l,En=d;break;case 5:Mi||Hs(a,s);case 6:if(l=ni,d=En,ni=null,_r(i,s,a),ni=l,En=d,ni!==null)if(En)try{(ni.nodeType===9?ni.body:ni.nodeName==="HTML"?ni.ownerDocument.body:ni).removeChild(a.stateNode)}catch(h){jt(a,s,h)}else try{ni.removeChild(a.stateNode)}catch(h){jt(a,s,h)}break;case 18:ni!==null&&(En?(i=ni,o0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),gl(i)):o0(ni,a.stateNode));break;case 4:l=ni,d=En,ni=a.stateNode.containerInfo,En=!0,_r(i,s,a),ni=l,En=d;break;case 0:case 11:case 14:case 15:oa(2,a,s),Mi||oa(4,a,s),_r(i,s,a);break;case 1:Mi||(Hs(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&lS(a,s,l)),_r(i,s,a);break;case 21:_r(i,s,a);break;case 22:Mi=(l=Mi)||a.memoizedState!==null,_r(i,s,a),Mi=l;break;default:_r(i,s,a)}}function gS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{gl(i)}catch(a){jt(s,s.return,a)}}}function vS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{gl(i)}catch(a){jt(s,s.return,a)}}function YT(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new hS),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new hS),s;default:throw Error(r(435,i.tag))}}function Ud(i,s){var a=YT(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var d=nE.bind(null,i,l);l.then(d,d)}})}function Dn(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var d=a[l],h=i,_=s,T=_;e:for(;T!==null;){switch(T.tag){case 27:if(pa(T.type)){ni=T.stateNode,En=!1;break e}break;case 5:ni=T.stateNode,En=!1;break e;case 3:case 4:ni=T.stateNode.containerInfo,En=!0;break e}T=T.return}if(ni===null)throw Error(r(160));mS(h,_,d),ni=null,En=!1,h=d.alternate,h!==null&&(h.return=null),d.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)_S(s,i),s=s.sibling}var ws=null;function _S(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Dn(s,i),Rn(i),l&4&&(oa(3,i,i.return),Cc(3,i),oa(5,i,i.return));break;case 1:Dn(s,i),Rn(i),l&512&&(Mi||a===null||Hs(a,a.return)),l&64&&vr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var d=ws;if(Dn(s,i),Rn(i),l&512&&(Mi||a===null||Hs(a,a.return)),l&4){var h=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,d=d.ownerDocument||d;t:switch(l){case"title":h=d.getElementsByTagName("title")[0],(!h||h[ds]||h[_i]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=d.createElement(l),d.head.insertBefore(h,d.querySelector("head > title"))),on(h,l,a),h[_i]=i,It(h),l=h;break e;case"link":var _=_0("link","href",d).get(l+(a.href||""));if(_){for(var T=0;T<_.length;T++)if(h=_[T],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(T,1);break t}}h=d.createElement(l),on(h,l,a),d.head.appendChild(h);break;case"meta":if(_=_0("meta","content",d).get(l+(a.content||""))){for(T=0;T<_.length;T++)if(h=_[T],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(T,1);break t}}h=d.createElement(l),on(h,l,a),d.head.appendChild(h);break;default:throw Error(r(468,l))}h[_i]=i,It(h),l=h}i.stateNode=l}else b0(d,i.type,i.stateNode);else i.stateNode=v0(d,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?b0(d,i.type,i.stateNode):v0(d,l,i.memoizedProps)):l===null&&i.stateNode!==null&&im(i,i.memoizedProps,a.memoizedProps)}break;case 27:Dn(s,i),Rn(i),l&512&&(Mi||a===null||Hs(a,a.return)),a!==null&&l&4&&im(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Dn(s,i),Rn(i),l&512&&(Mi||a===null||Hs(a,a.return)),i.flags&32){d=i.stateNode;try{dn(d,"")}catch(He){jt(i,i.return,He)}}l&4&&i.stateNode!=null&&(d=i.memoizedProps,im(i,d,a!==null?a.memoizedProps:d)),l&1024&&(rm=!0);break;case 6:if(Dn(s,i),Rn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(He){jt(i,i.return,He)}}break;case 3:if(nh=null,d=ws,ws=th(s.containerInfo),Dn(s,i),ws=d,Rn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{gl(s.containerInfo)}catch(He){jt(i,i.return,He)}rm&&(rm=!1,bS(i));break;case 4:l=ws,ws=th(i.stateNode.containerInfo),Dn(s,i),Rn(i),ws=l;break;case 12:Dn(s,i),Rn(i);break;case 31:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Ud(i,l)));break;case 13:Dn(s,i),Rn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Wd=lt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Ud(i,l)));break;case 22:d=i.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,Z=vr,he=Mi;if(vr=Z||d,Mi=he||A,Dn(s,i),Mi=he,vr=Z,Rn(i),l&8192)e:for(s=i.stateNode,s._visibility=d?s._visibility&-2:s._visibility|1,d&&(a===null||A||vr||Mi||uo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){A=a=s;try{if(h=A.stateNode,d)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{T=A.stateNode;var _e=A.memoizedProps.style,te=_e!=null&&_e.hasOwnProperty("display")?_e.display:null;T.style.display=te==null||typeof te=="boolean"?"":(""+te).trim()}}catch(He){jt(A,A.return,He)}}}else if(s.tag===6){if(a===null){A=s;try{A.stateNode.nodeValue=d?"":A.memoizedProps}catch(He){jt(A,A.return,He)}}}else if(s.tag===18){if(a===null){A=s;try{var ce=A.stateNode;d?l0(ce,!0):l0(A.stateNode,!1)}catch(He){jt(A,A.return,He)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Ud(i,a))));break;case 19:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Ud(i,l)));break;case 30:break;case 21:break;default:Dn(s,i),Rn(i)}}function Rn(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(uS(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var d=a.stateNode,h=nm(i);Hd(i,h,d);break;case 5:var _=a.stateNode;a.flags&32&&(dn(_,""),a.flags&=-33);var T=nm(i);Hd(i,T,_);break;case 3:case 4:var A=a.stateNode.containerInfo,Z=nm(i);sm(i,Z,A);break;default:throw Error(r(161))}}catch(he){jt(i,i.return,he)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function bS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;bS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function br(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)fS(i,s.alternate,s),s=s.sibling}function uo(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:oa(4,s,s.return),uo(s);break;case 1:Hs(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&lS(s,s.return,a),uo(s);break;case 27:Lc(s.stateNode);case 26:case 5:Hs(s,s.return),uo(s);break;case 22:s.memoizedState===null&&uo(s);break;case 30:uo(s);break;default:uo(s)}i=i.sibling}}function yr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,d=i,h=s,_=h.flags;switch(h.tag){case 0:case 11:case 15:yr(d,h,a),Cc(4,h);break;case 1:if(yr(d,h,a),l=h,d=l.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(Z){jt(l,l.return,Z)}if(l=h,d=l.updateQueue,d!==null){var T=l.stateNode;try{var A=d.shared.hiddenCallbacks;if(A!==null)for(d.shared.hiddenCallbacks=null,d=0;d<A.length;d++)Gb(A[d],T)}catch(Z){jt(l,l.return,Z)}}a&&_&64&&oS(h),xc(h,h.return);break;case 27:dS(h);case 26:case 5:yr(d,h,a),a&&l===null&&_&4&&cS(h),xc(h,h.return);break;case 12:yr(d,h,a);break;case 31:yr(d,h,a),a&&_&4&&gS(d,h);break;case 13:yr(d,h,a),a&&_&4&&vS(d,h);break;case 22:h.memoizedState===null&&yr(d,h,a),xc(h,h.return);break;case 30:break;default:yr(d,h,a)}s=s.sibling}}function am(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&uc(a))}function om(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&uc(i))}function Cs(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)yS(i,s,a,l),s=s.sibling}function yS(i,s,a,l){var d=s.flags;switch(s.tag){case 0:case 11:case 15:Cs(i,s,a,l),d&2048&&Cc(9,s);break;case 1:Cs(i,s,a,l);break;case 3:Cs(i,s,a,l),d&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&uc(i)));break;case 12:if(d&2048){Cs(i,s,a,l),i=s.stateNode;try{var h=s.memoizedProps,_=h.id,T=h.onPostCommit;typeof T=="function"&&T(_,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(A){jt(s,s.return,A)}}else Cs(i,s,a,l);break;case 31:Cs(i,s,a,l);break;case 13:Cs(i,s,a,l);break;case 23:break;case 22:h=s.stateNode,_=s.alternate,s.memoizedState!==null?h._visibility&2?Cs(i,s,a,l):kc(i,s):h._visibility&2?Cs(i,s,a,l):(h._visibility|=2,rl(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),d&2048&&am(_,s);break;case 24:Cs(i,s,a,l),d&2048&&om(s.alternate,s);break;default:Cs(i,s,a,l)}}function rl(i,s,a,l,d){for(d=d&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var h=i,_=s,T=a,A=l,Z=_.flags;switch(_.tag){case 0:case 11:case 15:rl(h,_,T,A,d),Cc(8,_);break;case 23:break;case 22:var he=_.stateNode;_.memoizedState!==null?he._visibility&2?rl(h,_,T,A,d):kc(h,_):(he._visibility|=2,rl(h,_,T,A,d)),d&&Z&2048&&am(_.alternate,_);break;case 24:rl(h,_,T,A,d),d&&Z&2048&&om(_.alternate,_);break;default:rl(h,_,T,A,d)}s=s.sibling}}function kc(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,d=l.flags;switch(l.tag){case 22:kc(a,l),d&2048&&am(l.alternate,l);break;case 24:kc(a,l),d&2048&&om(l.alternate,l);break;default:kc(a,l)}s=s.sibling}}var Tc=8192;function al(i,s,a){if(i.subtreeFlags&Tc)for(i=i.child;i!==null;)SS(i,s,a),i=i.sibling}function SS(i,s,a){switch(i.tag){case 26:al(i,s,a),i.flags&Tc&&i.memoizedState!==null&&OE(a,ws,i.memoizedState,i.memoizedProps);break;case 5:al(i,s,a);break;case 3:case 4:var l=ws;ws=th(i.stateNode.containerInfo),al(i,s,a),ws=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Tc,Tc=16777216,al(i,s,a),Tc=l):al(i,s,a));break;default:al(i,s,a)}}function wS(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Ec(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,xS(l,i)}wS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)CS(i),i=i.sibling}function CS(i){switch(i.tag){case 0:case 11:case 15:Ec(i),i.flags&2048&&oa(9,i,i.return);break;case 3:Ec(i);break;case 12:Ec(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,Kd(i)):Ec(i);break;default:Ec(i)}}function Kd(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,xS(l,i)}wS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:oa(8,s,s.return),Kd(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,Kd(s));break;default:Kd(s)}i=i.sibling}}function xS(i,s){for(;$i!==null;){var a=$i;switch(a.tag){case 0:case 11:case 15:oa(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:uc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,$i=l;else e:for(a=i;$i!==null;){l=$i;var d=l.sibling,h=l.return;if(pS(l),l===a){$i=null;break e}if(d!==null){d.return=h,$i=d;break e}$i=h}}}var XT={getCacheForType:function(i){var s=rn(Ei),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return rn(Ei).controller.signal}},GT=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Vt=null,_t=null,wt=0,Bt=0,Un=null,la=!1,ol=!1,lm=!1,Sr=0,fi=0,ca=0,ho=0,cm=0,Kn=0,ll=0,Dc=null,Mn=null,um=!1,Wd=0,kS=0,Fd=1/0,$d=null,ua=null,Bi=0,da=null,cl=null,wr=0,dm=0,hm=null,TS=null,Rc=0,fm=null;function Wn(){return(Mt&2)!==0&&wt!==0?wt&-wt:O.T!==null?bm():ii()}function ES(){if(Kn===0)if((wt&536870912)===0||xt){var i=st;st<<=1,(st&3932160)===0&&(st=262144),Kn=i}else Kn=536870912;return i=Pn.current,i!==null&&(i.flags|=32),Kn}function Nn(i,s,a){(i===Vt&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)&&(ul(i,0),ha(i,wt,Kn,!1)),di(i,a),((Mt&2)===0||i!==Vt)&&(i===Vt&&((Mt&2)===0&&(ho|=a),fi===4&&ha(i,wt,Kn,!1)),Us(i))}function DS(i,s,a){if((Mt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Wt(i,s),d=l?JT(i,s):mm(i,s,!0),h=l;do{if(d===0){ol&&!l&&ha(i,s,0,!1);break}else{if(a=i.current.alternate,h&&!ZT(a)){d=mm(i,s,!1),h=!1;continue}if(d===2){if(h=s,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var T=i;d=Dc;var A=T.current.memoizedState.isDehydrated;if(A&&(ul(T,_).flags|=256),_=mm(T,_,!1),_!==2){if(lm&&!A){T.errorRecoveryDisabledLanes|=h,ho|=h,d=4;break e}h=Mn,Mn=d,h!==null&&(Mn===null?Mn=h:Mn.push.apply(Mn,h))}d=_}if(h=!1,d!==2)continue}}if(d===1){ul(i,0),ha(i,s,0,!0);break}e:{switch(l=i,h=d,h){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:ha(l,s,Kn,!la);break e;case 2:Mn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(d=Wd+300-lt(),10<d)){if(ha(l,s,Kn,!la),Xt(l,0,!0)!==0)break e;wr=s,l.timeoutHandle=r0(RS.bind(null,l,a,Mn,$d,um,s,Kn,ho,ll,la,h,"Throttled",-0,0),d);break e}RS(l,a,Mn,$d,um,s,Kn,ho,ll,la,h,null,-0,0)}}break}while(!0);Us(i)}function RS(i,s,a,l,d,h,_,T,A,Z,he,_e,te,ce){if(i.timeoutHandle=-1,_e=s.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Yn},SS(s,h,_e);var He=(h&62914560)===h?Wd-lt():(h&4194048)===h?kS-lt():0;if(He=BE(_e,He),He!==null){wr=h,i.cancelPendingCommit=He(IS.bind(null,i,s,h,a,l,d,_,T,A,he,_e,null,te,ce)),ha(i,h,_,!Z);return}}IS(i,s,h,a,l,d,_,T,A)}function ZT(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var d=a[l],h=d.getSnapshot;d=d.value;try{if(!Sn(h(),d))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function ha(i,s,a,l){s&=~cm,s&=~ho,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var d=s;0<d;){var h=31-ct(d),_=1<<h;l[h]=-1,d&=~_}a!==0&&cn(i,a,s)}function qd(){return(Mt&6)===0?(Mc(0),!1):!0}function pm(){if(_t!==null){if(Bt===0)var i=_t.return;else i=_t,dr=io=null,Mp(i),el=null,hc=0,i=_t;for(;i!==null;)aS(i.alternate,i),i=i.return;_t=null}}function ul(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,vE(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),wr=0,pm(),Vt=i,_t=a=cr(i.current,null),wt=s,Bt=0,Un=null,la=!1,ol=Wt(i,s),lm=!1,ll=Kn=cm=ho=ca=fi=0,Mn=Dc=null,um=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var d=31-ct(l),h=1<<d;s|=i[d],l&=~h}return Sr=s,fd(),a}function MS(i,s){ot=null,O.H=yc,s===Jo||s===Sd?(s=qb(),Bt=3):s===_p?(s=qb(),Bt=4):Bt=s===qp?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Un=s,_t===null&&(fi=1,Bd(i,Qn(s,i.current)))}function NS(){var i=Pn.current;return i===null?!0:(wt&4194048)===wt?is===null:(wt&62914560)===wt||(wt&536870912)!==0?i===is:!1}function AS(){var i=O.H;return O.H=yc,i===null?yc:i}function LS(){var i=O.A;return O.A=XT,i}function Vd(){fi=4,la||(wt&4194048)!==wt&&Pn.current!==null||(ol=!0),(ca&134217727)===0&&(ho&134217727)===0||Vt===null||ha(Vt,wt,Kn,!1)}function mm(i,s,a){var l=Mt;Mt|=2;var d=AS(),h=LS();(Vt!==i||wt!==s)&&($d=null,ul(i,s)),s=!1;var _=fi;e:do try{if(Bt!==0&&_t!==null){var T=_t,A=Un;switch(Bt){case 8:pm(),_=6;break e;case 3:case 2:case 9:case 6:Pn.current===null&&(s=!0);var Z=Bt;if(Bt=0,Un=null,dl(i,T,A,Z),a&&ol){_=0;break e}break;default:Z=Bt,Bt=0,Un=null,dl(i,T,A,Z)}}QT(),_=fi;break}catch(he){MS(i,he)}while(!0);return s&&i.shellSuspendCounter++,dr=io=null,Mt=l,O.H=d,O.A=h,_t===null&&(Vt=null,wt=0,fd()),_}function QT(){for(;_t!==null;)OS(_t)}function JT(i,s){var a=Mt;Mt|=2;var l=AS(),d=LS();Vt!==i||wt!==s?($d=null,Fd=lt()+500,ul(i,s)):ol=Wt(i,s);e:do try{if(Bt!==0&&_t!==null){s=_t;var h=Un;t:switch(Bt){case 1:Bt=0,Un=null,dl(i,s,h,1);break;case 2:case 9:if(Fb(h)){Bt=0,Un=null,BS(s);break}s=function(){Bt!==2&&Bt!==9||Vt!==i||(Bt=7),Us(i)},h.then(s,s);break e;case 3:Bt=7;break e;case 4:Bt=5;break e;case 7:Fb(h)?(Bt=0,Un=null,BS(s)):(Bt=0,Un=null,dl(i,s,h,7));break;case 5:var _=null;switch(_t.tag){case 26:_=_t.memoizedState;case 5:case 27:var T=_t;if(_?y0(_):T.stateNode.complete){Bt=0,Un=null;var A=T.sibling;if(A!==null)_t=A;else{var Z=T.return;Z!==null?(_t=Z,Yd(Z)):_t=null}break t}}Bt=0,Un=null,dl(i,s,h,5);break;case 6:Bt=0,Un=null,dl(i,s,h,6);break;case 8:pm(),fi=6;break e;default:throw Error(r(462))}}eE();break}catch(he){MS(i,he)}while(!0);return dr=io=null,O.H=l,O.A=d,Mt=a,_t!==null?0:(Vt=null,wt=0,fd(),fi)}function eE(){for(;_t!==null&&!je();)OS(_t)}function OS(i){var s=sS(i.alternate,i,Sr);i.memoizedProps=i.pendingProps,s===null?Yd(i):_t=s}function BS(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=Qy(a,s,s.pendingProps,s.type,void 0,wt);break;case 11:s=Qy(a,s,s.pendingProps,s.type.render,s.ref,wt);break;case 5:Mp(s);default:aS(a,s),s=_t=Lb(s,Sr),s=sS(a,s,Sr)}i.memoizedProps=i.pendingProps,s===null?Yd(i):_t=s}function dl(i,s,a,l){dr=io=null,Mp(s),el=null,hc=0;var d=s.return;try{if(KT(i,d,s,a,wt)){fi=1,Bd(i,Qn(a,i.current)),_t=null;return}}catch(h){if(d!==null)throw _t=d,h;fi=1,Bd(i,Qn(a,i.current)),_t=null;return}s.flags&32768?(xt||l===1?i=!0:ol||(wt&536870912)!==0?i=!1:(la=i=!0,(l===2||l===9||l===3||l===6)&&(l=Pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),jS(s,i)):Yd(s)}function Yd(i){var s=i;do{if((s.flags&32768)!==0){jS(s,la);return}i=s.return;var a=$T(s.alternate,s,Sr);if(a!==null){_t=a;return}if(s=s.sibling,s!==null){_t=s;return}_t=s=i}while(s!==null);fi===0&&(fi=5)}function jS(i,s){do{var a=qT(i.alternate,i);if(a!==null){a.flags&=32767,_t=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){_t=i;return}_t=i=a}while(i!==null);fi=6,_t=null}function IS(i,s,a,l,d,h,_,T,A){i.cancelPendingCommit=null;do Xd();while(Bi!==0);if((Mt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(h=s.lanes|s.childLanes,h|=np,Ft(i,a,h,_,T,A),i===Vt&&(_t=Vt=null,wt=0),cl=s,da=i,wr=a,dm=h,hm=d,TS=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,sE($e,function(){return KS(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=O.T,O.T=null,d=M.p,M.p=2,_=Mt,Mt|=4;try{VT(i,s,a)}finally{Mt=_,M.p=d,O.T=l}}Bi=1,zS(),PS(),HS()}}function zS(){if(Bi===1){Bi=0;var i=da,s=cl,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var l=M.p;M.p=2;var d=Mt;Mt|=4;try{_S(s,i);var h=Em,_=dd(i.containerInfo),T=h.focusedElem,A=h.selectionRange;if(_!==T&&T&&T.ownerDocument&&ud(T.ownerDocument.documentElement,T)){if(A!==null&&Qa(T)){var Z=A.start,he=A.end;if(he===void 0&&(he=Z),"selectionStart"in T)T.selectionStart=Z,T.selectionEnd=Math.min(he,T.value.length);else{var _e=T.ownerDocument||document,te=_e&&_e.defaultView||window;if(te.getSelection){var ce=te.getSelection(),He=T.textContent.length,Je=Math.min(A.start,He),Ht=A.end===void 0?Je:Math.min(A.end,He);!ce.extend&&Je>Ht&&(_=Ht,Ht=Je,Je=_);var K=cd(T,Je),P=cd(T,Ht);if(K&&P&&(ce.rangeCount!==1||ce.anchorNode!==K.node||ce.anchorOffset!==K.offset||ce.focusNode!==P.node||ce.focusOffset!==P.offset)){var G=_e.createRange();G.setStart(K.node,K.offset),ce.removeAllRanges(),Je>Ht?(ce.addRange(G),ce.extend(P.node,P.offset)):(G.setEnd(P.node,P.offset),ce.addRange(G))}}}}for(_e=[],ce=T;ce=ce.parentNode;)ce.nodeType===1&&_e.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<_e.length;T++){var ve=_e[T];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}oh=!!Tm,Em=Tm=null}finally{Mt=d,M.p=l,O.T=a}}i.current=s,Bi=2}}function PS(){if(Bi===2){Bi=0;var i=da,s=cl,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var l=M.p;M.p=2;var d=Mt;Mt|=4;try{fS(i,s.alternate,s)}finally{Mt=d,M.p=l,O.T=a}}Bi=3}}function HS(){if(Bi===4||Bi===3){Bi=0,Ye();var i=da,s=cl,a=wr,l=TS;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Bi=5:(Bi=0,cl=da=null,US(i,i.pendingLanes));var d=i.pendingLanes;if(d===0&&(ua=null),_n(a),s=s.stateNode,Ze&&typeof Ze.onCommitFiberRoot=="function")try{Ze.onCommitFiberRoot(rt,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=O.T,d=M.p,M.p=2,O.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var T=l[_];h(T.value,{componentStack:T.stack})}}finally{O.T=s,M.p=d}}(wr&3)!==0&&Xd(),Us(i),d=i.pendingLanes,(a&261930)!==0&&(d&42)!==0?i===fm?Rc++:(Rc=0,fm=i):Rc=0,Mc(0)}}function US(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,uc(s)))}function Xd(){return zS(),PS(),HS(),KS()}function KS(){if(Bi!==5)return!1;var i=da,s=dm;dm=0;var a=_n(wr),l=O.T,d=M.p;try{M.p=32>a?32:a,O.T=null,a=hm,hm=null;var h=da,_=wr;if(Bi=0,cl=da=null,wr=0,(Mt&6)!==0)throw Error(r(331));var T=Mt;if(Mt|=4,CS(h.current),yS(h,h.current,_,a),Mt=T,Mc(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(rt,h)}catch{}return!0}finally{M.p=d,O.T=l,US(i,s)}}function WS(i,s,a){s=Qn(a,s),s=$p(i.stateNode,s,2),i=sa(i,s,2),i!==null&&(di(i,2),Us(i))}function jt(i,s,a){if(i.tag===3)WS(i,i,a);else for(;s!==null;){if(s.tag===3){WS(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ua===null||!ua.has(l))){i=Qn(a,i),a=Fy(2),l=sa(s,a,2),l!==null&&($y(a,l,s,i),di(l,2),Us(l));break}}s=s.return}}function gm(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new GT;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(a)||(lm=!0,d.add(a),i=tE.bind(null,i,s,a),s.then(i,i))}function tE(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Vt===i&&(wt&a)===a&&(fi===4||fi===3&&(wt&62914560)===wt&&300>lt()-Wd?(Mt&2)===0&&ul(i,0):cm|=a,ll===wt&&(ll=0)),Us(i)}function FS(i,s){s===0&&(s=Gt()),i=Ja(i,s),i!==null&&(di(i,s),Us(i))}function iE(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),FS(i,a)}function nE(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,d=i.memoizedState;d!==null&&(a=d.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),FS(i,a)}function sE(i,s){return Re(i,s)}var Gd=null,hl=null,vm=!1,Zd=!1,_m=!1,fa=0;function Us(i){i!==hl&&i.next===null&&(hl===null?Gd=hl=i:hl=hl.next=i),Zd=!0,vm||(vm=!0,aE())}function Mc(i,s){if(!_m&&Zd){_m=!0;do for(var a=!1,l=Gd;l!==null;){if(i!==0){var d=l.pendingLanes;if(d===0)var h=0;else{var _=l.suspendedLanes,T=l.pingedLanes;h=(1<<31-ct(42|i)+1)-1,h&=d&~(_&~T),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,YS(l,h))}else h=wt,h=Xt(l,l===Vt?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||Wt(l,h)||(a=!0,YS(l,h));l=l.next}while(a);_m=!1}}function rE(){$S()}function $S(){Zd=vm=!1;var i=0;fa!==0&&gE()&&(i=fa);for(var s=lt(),a=null,l=Gd;l!==null;){var d=l.next,h=qS(l,s);h===0?(l.next=null,a===null?Gd=d:a.next=d,d===null&&(hl=a)):(a=l,(i!==0||(h&3)!==0)&&(Zd=!0)),l=d}Bi!==0&&Bi!==5||Mc(i),fa!==0&&(fa=0)}function qS(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,d=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-ct(h),T=1<<_,A=d[_];A===-1?((T&a)===0||(T&l)!==0)&&(d[_]=ui(T,s)):A<=s&&(i.expiredLanes|=T),h&=~T}if(s=Vt,a=wt,a=Xt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ie(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Wt(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&Ie(l),_n(a)){case 2:case 8:a=Tt;break;case 32:a=$e;break;case 268435456:a=Lt;break;default:a=$e}return l=VS.bind(null,i),a=Re(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&Ie(l),i.callbackPriority=2,i.callbackNode=null,2}function VS(i,s){if(Bi!==0&&Bi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Xd()&&i.callbackNode!==a)return null;var l=wt;return l=Xt(i,i===Vt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(DS(i,l,s),qS(i,lt()),i.callbackNode!=null&&i.callbackNode===a?VS.bind(null,i):null)}function YS(i,s){if(Xd())return null;DS(i,s,!0)}function aE(){_E(function(){(Mt&6)!==0?Re(yt,rE):$S()})}function bm(){if(fa===0){var i=Zo;i===0&&(i=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),fa=i}return fa}function XS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:bs(""+i)}function GS(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function oE(i,s,a,l,d){if(s==="submit"&&a&&a.stateNode===d){var h=XS((d[bi]||null).action),_=l.submitter;_&&(s=(s=_[bi]||null)?XS(s.formAction):_.getAttribute("formAction"),s!==null&&(h=s,_=null));var T=new C("action","action",null,l,d);i.push({event:T,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(fa!==0){var A=_?GS(d,_):new FormData(d);Pp(a,{pending:!0,data:A,method:d.method,action:h},null,A)}}else typeof h=="function"&&(T.preventDefault(),A=_?GS(d,_):new FormData(d),Pp(a,{pending:!0,data:A,method:d.method,action:h},h,A))},currentTarget:d}]})}}for(var ym=0;ym<ip.length;ym++){var Sm=ip[ym],lE=Sm.toLowerCase(),cE=Sm[0].toUpperCase()+Sm.slice(1);Ss(lE,"on"+cE)}Ss(qt,"onAnimationEnd"),Ss(Ot,"onAnimationIteration"),Ss(At,"onAnimationStart"),Ss("dblclick","onDoubleClick"),Ss("focusin","onFocus"),Ss("focusout","onBlur"),Ss(js,"onTransitionRun"),Ss(Fo,"onTransitionStart"),Ss(Is,"onTransitionCancel"),Ss(ac,"onTransitionEnd"),jn("onMouseEnter",["mouseout","mouseover"]),jn("onMouseLeave",["mouseout","mouseover"]),jn("onPointerEnter",["pointerout","pointerover"]),jn("onPointerLeave",["pointerout","pointerover"]),$t("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),$t("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),$t("onBeforeInput",["compositionend","keypress","textInput","paste"]),$t("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),$t("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),$t("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Nc="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(" "),uE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Nc));function ZS(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],d=l.event;l=l.listeners;e:{var h=void 0;if(s)for(var _=l.length-1;0<=_;_--){var T=l[_],A=T.instance,Z=T.currentTarget;if(T=T.listener,A!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=Z;try{h(d)}catch(he){hd(he)}d.currentTarget=null,h=A}else for(_=0;_<l.length;_++){if(T=l[_],A=T.instance,Z=T.currentTarget,T=T.listener,A!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=Z;try{h(d)}catch(he){hd(he)}d.currentTarget=null,h=A}}}}function bt(i,s){var a=s[Ir];a===void 0&&(a=s[Ir]=new Set);var l=i+"__bubble";a.has(l)||(QS(s,i,2,!1),a.add(l))}function wm(i,s,a){var l=0;s&&(l|=4),QS(a,i,l,s)}var Qd="_reactListening"+Math.random().toString(36).slice(2);function Cm(i){if(!i[Qd]){i[Qd]=!0,Bo.forEach(function(a){a!=="selectionchange"&&(uE.has(a)||wm(a,!1,i),wm(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[Qd]||(s[Qd]=!0,wm("selectionchange",!1,s))}}function QS(i,s,a,l){switch(E0(s)){case 2:var d=zE;break;case 8:d=PE;break;default:d=zm}a=d.bind(null,s,a,i),d=void 0,!qr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),l?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function xm(i,s,a,l,d){var h=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var T=l.stateNode.containerInfo;if(T===d)break;if(_===4)for(_=l.return;_!==null;){var A=_.tag;if((A===3||A===4)&&_.stateNode.containerInfo===d)return;_=_.return}for(;T!==null;){if(_=hs(T),_===null)return;if(A=_.tag,A===5||A===6||A===26||A===27){l=h=_;continue e}T=T.parentNode}}l=l.return}Va(function(){var Z=h,he=$r(a),_e=[];e:{var te=oc.get(i);if(te!==void 0){var ce=C,He=i;switch(i){case"keypress":if(sr(a)===0)break e;case"keydown":case"keyup":ce=$f;break;case"focusin":He="focus",ce=Vr;break;case"focusout":He="blur",ce=Vr;break;case"beforeblur":case"afterblur":ce=Vr;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":ce=Qe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=Ti;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=qf;break;case qt:case Ot:case At:ce=Po;break;case ac:ce=rr;break;case"scroll":case"scrollend":ce=z;break;case"wheel":ce=Vf;break;case"copy":case"cut":case"paste":ce=Xl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=Gl;break;case"toggle":case"beforetoggle":ce=Xf}var Je=(s&4)!==0,Ht=!Je&&(i==="scroll"||i==="scrollend"),K=Je?te!==null?te+"Capture":null:te;Je=[];for(var P=Z,G;P!==null;){var ve=P;if(G=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||G===null||K===null||(ve=In(P,K),ve!=null&&Je.push(Ac(P,ve,G))),Ht)break;P=P.return}0<Je.length&&(te=new ce(te,He,null,a,he),_e.push({event:te,listeners:Je}))}}if((s&7)===0){e:{if(te=i==="mouseover"||i==="pointerover",ce=i==="mouseout"||i==="pointerout",te&&a!==yi&&(He=a.relatedTarget||a.fromElement)&&(hs(He)||He[Bn]))break e;if((ce||te)&&(te=he.window===he?he:(te=he.ownerDocument)?te.defaultView||te.parentWindow:window,ce?(He=a.relatedTarget||a.toElement,ce=Z,He=He?hs(He):null,He!==null&&(Ht=c(He),Je=He.tag,He!==Ht||Je!==5&&Je!==27&&Je!==6)&&(He=null)):(ce=null,He=Z),ce!==He)){if(Je=Qe,ve="onMouseLeave",K="onMouseEnter",P="mouse",(i==="pointerout"||i==="pointerover")&&(Je=Gl,ve="onPointerLeave",K="onPointerEnter",P="pointer"),Ht=ce==null?te:fs(ce),G=He==null?te:fs(He),te=new Je(ve,P+"leave",ce,a,he),te.target=Ht,te.relatedTarget=G,ve=null,hs(he)===Z&&(Je=new Je(K,P+"enter",He,a,he),Je.target=G,Je.relatedTarget=Ht,ve=Je),Ht=ve,ce&&He)t:{for(Je=dE,K=ce,P=He,G=0,ve=K;ve;ve=Je(ve))G++;ve=0;for(var Ge=P;Ge;Ge=Je(Ge))ve++;for(;0<G-ve;)K=Je(K),G--;for(;0<ve-G;)P=Je(P),ve--;for(;G--;){if(K===P||P!==null&&K===P.alternate){Je=K;break t}K=Je(K),P=Je(P)}Je=null}else Je=null;ce!==null&&JS(_e,te,ce,Je,!1),He!==null&&Ht!==null&&JS(_e,Ht,He,Je,!0)}}e:{if(te=Z?fs(Z):window,ce=te.nodeName&&te.nodeName.toLowerCase(),ce==="select"||ce==="input"&&te.type==="file")var Dt=sc;else if(Xa(te))if(ad)Dt=Jf;else{Dt=Qf;var Fe=Zf}else ce=te.nodeName,!ce||ce.toLowerCase()!=="input"||te.type!=="checkbox"&&te.type!=="radio"?Z&&Fr(Z.elementType)&&(Dt=sc):Dt=or;if(Dt&&(Dt=Dt(i,Z))){nc(_e,Dt,a,he);break e}Fe&&Fe(i,te,Z),i==="focusout"&&Z&&te.type==="number"&&Z.memoizedProps.value!=null&&er(te,"number",te.value)}switch(Fe=Z?fs(Z):window,i){case"focusin":(Xa(Fe)||Fe.contentEditable==="true")&&(lr=Fe,x=Z,j=null);break;case"focusout":j=x=lr=null;break;case"mousedown":Te=!0;break;case"contextmenu":case"mouseup":case"dragend":Te=!1,qe(_e,a,he);break;case"selectionchange":if(tp)break;case"keydown":case"keyup":qe(_e,a,he)}var dt;if(Ya)e:{switch(i){case"compositionstart":var Ct="onCompositionStart";break e;case"compositionend":Ct="onCompositionEnd";break e;case"compositionupdate":Ct="onCompositionUpdate";break e}Ct=void 0}else Xr?tc(i,a)&&(Ct="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Ct="onCompositionStart");Ct&&(Jl&&a.locale!=="ko"&&(Xr||Ct!=="onCompositionStart"?Ct==="onCompositionEnd"&&Xr&&(dt=nr()):(yn=he,As="value"in yn?yn.value:yn.textContent,Xr=!0)),Fe=Jd(Z,Ct),0<Fe.length&&(Ct=new Ho(Ct,i,null,a,he),_e.push({event:Ct,listeners:Fe}),dt?Ct.data=dt:(dt=nd(a),dt!==null&&(Ct.data=dt)))),(dt=Ko?Gf(i,a):sd(i,a))&&(Ct=Jd(Z,"onBeforeInput"),0<Ct.length&&(Fe=new Ho("onBeforeInput","beforeinput",null,a,he),_e.push({event:Fe,listeners:Ct}),Fe.data=dt)),oE(_e,i,Z,a,he)}ZS(_e,s)})}function Ac(i,s,a){return{instance:i,listener:s,currentTarget:a}}function Jd(i,s){for(var a=s+"Capture",l=[];i!==null;){var d=i,h=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||h===null||(d=In(i,a),d!=null&&l.unshift(Ac(i,d,h)),d=In(i,s),d!=null&&l.push(Ac(i,d,h))),i.tag===3)return l;i=i.return}return[]}function dE(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function JS(i,s,a,l,d){for(var h=s._reactName,_=[];a!==null&&a!==l;){var T=a,A=T.alternate,Z=T.stateNode;if(T=T.tag,A!==null&&A===l)break;T!==5&&T!==26&&T!==27||Z===null||(A=Z,d?(Z=In(a,h),Z!=null&&_.unshift(Ac(a,Z,A))):d||(Z=In(a,h),Z!=null&&_.push(Ac(a,Z,A)))),a=a.return}_.length!==0&&i.push({event:s,listeners:_})}var hE=/\r\n?/g,fE=/\u0000|\uFFFD/g;function e0(i){return(typeof i=="string"?i:""+i).replace(hE,`
|
|
10
|
-
`).replace(fE,"")}function t0(i,s){return s=e0(s),e0(i)===s}function Pt(i,s,a,l,d,h){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||dn(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&dn(i,""+l);break;case"className":Ur(i,"class",l);break;case"tabIndex":Ur(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Ur(i,a,l);break;case"style":_s(i,l,h);break;case"data":if(s!=="object"){Ur(i,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=bs(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(s!=="input"&&Pt(i,s,"name",d.name,d,null),Pt(i,s,"formEncType",d.formEncType,d,null),Pt(i,s,"formMethod",d.formMethod,d,null),Pt(i,s,"formTarget",d.formTarget,d,null)):(Pt(i,s,"encType",d.encType,d,null),Pt(i,s,"method",d.method,d,null),Pt(i,s,"target",d.target,d,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=bs(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Yn);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=bs(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":bt("beforetoggle",i),bt("toggle",i),ps(i,"popover",l);break;case"xlinkActuate":bn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":bn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":bn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":bn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":bn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":bn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":bn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":bn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":bn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":ps(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=zo.get(a)||a,ps(i,a,l))}}function km(i,s,a,l,d,h){switch(a){case"style":_s(i,l,h);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?dn(i,l):(typeof l=="number"||typeof l=="bigint")&&dn(i,""+l);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Yn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Pr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(d=a.endsWith("Capture"),s=a.slice(2,d?a.length-7:void 0),h=i[bi]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(s,h,d),typeof l=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,d);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):ps(i,a,l)}}}function on(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",i),bt("load",i);var l=!1,d=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":l=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Pt(i,s,h,_,a,null)}}d&&Pt(i,s,"srcSet",a.srcSet,a,null),l&&Pt(i,s,"src",a.src,a,null);return;case"input":bt("invalid",i);var T=h=_=d=null,A=null,Z=null;for(l in a)if(a.hasOwnProperty(l)){var he=a[l];if(he!=null)switch(l){case"name":d=he;break;case"type":_=he;break;case"checked":A=he;break;case"defaultChecked":Z=he;break;case"value":h=he;break;case"defaultValue":T=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(r(137,s));break;default:Pt(i,s,l,he,a,null)}}vs(i,h,T,A,Z,_,d,!1);return;case"select":bt("invalid",i),l=_=h=null;for(d in a)if(a.hasOwnProperty(d)&&(T=a[d],T!=null))switch(d){case"value":h=T;break;case"defaultValue":_=T;break;case"multiple":l=T;default:Pt(i,s,d,T,a,null)}s=h,a=_,i.multiple=!!l,s!=null?un(i,!!l,s,!1):a!=null&&un(i,!!l,a,!0);return;case"textarea":bt("invalid",i),h=d=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(T=a[_],T!=null))switch(_){case"value":l=T;break;case"defaultValue":d=T;break;case"children":h=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:Pt(i,s,_,T,a,null)}qa(i,l,d,h);return;case"option":for(A in a)a.hasOwnProperty(A)&&(l=a[A],l!=null)&&(A==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":Pt(i,s,A,l,a,null));return;case"dialog":bt("beforetoggle",i),bt("toggle",i),bt("cancel",i),bt("close",i);break;case"iframe":case"object":bt("load",i);break;case"video":case"audio":for(l=0;l<Nc.length;l++)bt(Nc[l],i);break;case"image":bt("error",i),bt("load",i);break;case"details":bt("toggle",i);break;case"embed":case"source":case"link":bt("error",i),bt("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(Z in a)if(a.hasOwnProperty(Z)&&(l=a[Z],l!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Pt(i,s,Z,l,a,null)}return;default:if(Fr(s)){for(he in a)a.hasOwnProperty(he)&&(l=a[he],l!==void 0&&km(i,s,he,l,a,void 0));return}}for(T in a)a.hasOwnProperty(T)&&(l=a[T],l!=null&&Pt(i,s,T,l,a,null))}function pE(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,h=null,_=null,T=null,A=null,Z=null,he=null;for(ce in a){var _e=a[ce];if(a.hasOwnProperty(ce)&&_e!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":A=_e;default:l.hasOwnProperty(ce)||Pt(i,s,ce,null,l,_e)}}for(var te in l){var ce=l[te];if(_e=a[te],l.hasOwnProperty(te)&&(ce!=null||_e!=null))switch(te){case"type":h=ce;break;case"name":d=ce;break;case"checked":Z=ce;break;case"defaultChecked":he=ce;break;case"value":_=ce;break;case"defaultValue":T=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(r(137,s));break;default:ce!==_e&&Pt(i,s,te,ce,l,_e)}}pt(i,_,T,A,Z,he,h,d);return;case"select":ce=_=T=te=null;for(h in a)if(A=a[h],a.hasOwnProperty(h)&&A!=null)switch(h){case"value":break;case"multiple":ce=A;default:l.hasOwnProperty(h)||Pt(i,s,h,null,l,A)}for(d in l)if(h=l[d],A=a[d],l.hasOwnProperty(d)&&(h!=null||A!=null))switch(d){case"value":te=h;break;case"defaultValue":T=h;break;case"multiple":_=h;default:h!==A&&Pt(i,s,d,h,l,A)}s=T,a=_,l=ce,te!=null?un(i,!!a,te,!1):!!l!=!!a&&(s!=null?un(i,!!a,s,!0):un(i,!!a,a?[]:"",!1));return;case"textarea":ce=te=null;for(T in a)if(d=a[T],a.hasOwnProperty(T)&&d!=null&&!l.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:Pt(i,s,T,null,l,d)}for(_ in l)if(d=l[_],h=a[_],l.hasOwnProperty(_)&&(d!=null||h!=null))switch(_){case"value":te=d;break;case"defaultValue":ce=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==h&&Pt(i,s,_,d,l,h)}Kr(i,te,ce);return;case"option":for(var He in a)te=a[He],a.hasOwnProperty(He)&&te!=null&&!l.hasOwnProperty(He)&&(He==="selected"?i.selected=!1:Pt(i,s,He,null,l,te));for(A in l)te=l[A],ce=a[A],l.hasOwnProperty(A)&&te!==ce&&(te!=null||ce!=null)&&(A==="selected"?i.selected=te&&typeof te!="function"&&typeof te!="symbol":Pt(i,s,A,te,l,ce));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 Je in a)te=a[Je],a.hasOwnProperty(Je)&&te!=null&&!l.hasOwnProperty(Je)&&Pt(i,s,Je,null,l,te);for(Z in l)if(te=l[Z],ce=a[Z],l.hasOwnProperty(Z)&&te!==ce&&(te!=null||ce!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(137,s));break;default:Pt(i,s,Z,te,l,ce)}return;default:if(Fr(s)){for(var Ht in a)te=a[Ht],a.hasOwnProperty(Ht)&&te!==void 0&&!l.hasOwnProperty(Ht)&&km(i,s,Ht,void 0,l,te);for(he in l)te=l[he],ce=a[he],!l.hasOwnProperty(he)||te===ce||te===void 0&&ce===void 0||km(i,s,he,te,l,ce);return}}for(var K in a)te=a[K],a.hasOwnProperty(K)&&te!=null&&!l.hasOwnProperty(K)&&Pt(i,s,K,null,l,te);for(_e in l)te=l[_e],ce=a[_e],!l.hasOwnProperty(_e)||te===ce||te==null&&ce==null||Pt(i,s,_e,te,l,ce)}function i0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function mE(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var d=a[l],h=d.transferSize,_=d.initiatorType,T=d.duration;if(h&&T&&i0(_)){for(_=0,T=d.responseEnd,l+=1;l<a.length;l++){var A=a[l],Z=A.startTime;if(Z>T)break;var he=A.transferSize,_e=A.initiatorType;he&&i0(_e)&&(A=A.responseEnd,_+=he*(A<T?1:(T-Z)/(A-Z)))}if(--l,s+=8*(h+_)/(d.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Tm=null,Em=null;function eh(i){return i.nodeType===9?i:i.ownerDocument}function n0(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 s0(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function Dm(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Rm=null;function gE(){var i=window.event;return i&&i.type==="popstate"?i===Rm?!1:(Rm=i,!0):(Rm=null,!1)}var r0=typeof setTimeout=="function"?setTimeout:void 0,vE=typeof clearTimeout=="function"?clearTimeout:void 0,a0=typeof Promise=="function"?Promise:void 0,_E=typeof queueMicrotask=="function"?queueMicrotask:typeof a0<"u"?function(i){return a0.resolve(null).then(i).catch(bE)}:r0;function bE(i){setTimeout(function(){throw i})}function pa(i){return i==="head"}function o0(i,s){var a=s,l=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(d),gl(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Lc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Lc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,T=h.nodeName;h[ds]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&Lc(i.ownerDocument.body);a=d}while(a);gl(s)}function l0(i,s){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function Mm(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Mm(a),Qs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function yE(i,s,a,l){for(;i.nodeType===1;){var d=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[ds])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==d.rel||i.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||i.getAttribute("title")!==(d.title==null?null:d.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(d.src==null?null:d.src)||i.getAttribute("type")!==(d.type==null?null:d.type)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var h=d.name==null?null:""+d.name;if(d.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=ns(i.nextSibling),i===null)break}return null}function SE(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ns(i.nextSibling),i===null))return null;return i}function c0(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=ns(i.nextSibling),i===null))return null;return i}function Nm(i){return i.data==="$?"||i.data==="$~"}function Am(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function wE(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function ns(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var Lm=null;function u0(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return ns(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function d0(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function h0(i,s,a){switch(s=eh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Lc(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Qs(i)}var ss=new Map,f0=new Set;function th(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Cr=M.d;M.d={f:CE,r:xE,D:kE,C:TE,L:EE,m:DE,X:ME,S:RE,M:NE};function CE(){var i=Cr.f(),s=qd();return i||s}function xE(i){var s=Es(i);s!==null&&s.tag===5&&s.type==="form"?My(s):Cr.r(i)}var fl=typeof document>"u"?null:document;function p0(i,s,a){var l=fl;if(l&&typeof s=="string"&&s){var d=Oi(s);d='link[rel="'+i+'"][href="'+d+'"]',typeof a=="string"&&(d+='[crossorigin="'+a+'"]'),f0.has(d)||(f0.add(d),i={rel:i,crossOrigin:a,href:s},l.querySelector(d)===null&&(s=l.createElement("link"),on(s,"link",i),It(s),l.head.appendChild(s)))}}function kE(i){Cr.D(i),p0("dns-prefetch",i,null)}function TE(i,s){Cr.C(i,s),p0("preconnect",i,s)}function EE(i,s,a){Cr.L(i,s,a);var l=fl;if(l&&i&&s){var d='link[rel="preload"][as="'+Oi(s)+'"]';s==="image"&&a&&a.imageSrcSet?(d+='[imagesrcset="'+Oi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(d+='[imagesizes="'+Oi(a.imageSizes)+'"]')):d+='[href="'+Oi(i)+'"]';var h=d;switch(s){case"style":h=pl(i);break;case"script":h=ml(i)}ss.has(h)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),ss.set(h,i),l.querySelector(d)!==null||s==="style"&&l.querySelector(Oc(h))||s==="script"&&l.querySelector(Bc(h))||(s=l.createElement("link"),on(s,"link",i),It(s),l.head.appendChild(s)))}}function DE(i,s){Cr.m(i,s);var a=fl;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+Oi(l)+'"][href="'+Oi(i)+'"]',h=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=ml(i)}if(!ss.has(h)&&(i=b({rel:"modulepreload",href:i},s),ss.set(h,i),a.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Bc(h)))return}l=a.createElement("link"),on(l,"link",i),It(l),a.head.appendChild(l)}}}function RE(i,s,a){Cr.S(i,s,a);var l=fl;if(l&&i){var d=Ds(l).hoistableStyles,h=pl(i);s=s||"default";var _=d.get(h);if(!_){var T={loading:0,preload:null};if(_=l.querySelector(Oc(h)))T.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=ss.get(h))&&Om(i,a);var A=_=l.createElement("link");It(A),on(A,"link",i),A._p=new Promise(function(Z,he){A.onload=Z,A.onerror=he}),A.addEventListener("load",function(){T.loading|=1}),A.addEventListener("error",function(){T.loading|=2}),T.loading|=4,ih(_,s,l)}_={type:"stylesheet",instance:_,count:1,state:T},d.set(h,_)}}}function ME(i,s){Cr.X(i,s);var a=fl;if(a&&i){var l=Ds(a).hoistableScripts,d=ml(i),h=l.get(d);h||(h=a.querySelector(Bc(d)),h||(i=b({src:i,async:!0},s),(s=ss.get(d))&&Bm(i,s),h=a.createElement("script"),It(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function NE(i,s){Cr.M(i,s);var a=fl;if(a&&i){var l=Ds(a).hoistableScripts,d=ml(i),h=l.get(d);h||(h=a.querySelector(Bc(d)),h||(i=b({src:i,async:!0,type:"module"},s),(s=ss.get(d))&&Bm(i,s),h=a.createElement("script"),It(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function m0(i,s,a,l){var d=(d=De.current)?th(d):null;if(!d)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=pl(a.href),a=Ds(d).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=pl(a.href);var h=Ds(d).hoistableStyles,_=h.get(i);if(_||(d=d.ownerDocument||d,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=d.querySelector(Oc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),ss.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},ss.set(i,a),h||AE(d,i,a,_.state))),s&&l===null)throw Error(r(528,""));return _}if(s&&l!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=ml(a),a=Ds(d).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function pl(i){return'href="'+Oi(i)+'"'}function Oc(i){return'link[rel="stylesheet"]['+i+"]"}function g0(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function AE(i,s,a,l){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=i.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),on(s,"link",a),It(s),i.head.appendChild(s))}function ml(i){return'[src="'+Oi(i)+'"]'}function Bc(i){return"script[async]"+i}function v0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+Oi(a.href)+'"]');if(l)return s.instance=l,It(l),l;var d=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),It(l),on(l,"style",d),ih(l,a.precedence,i),s.instance=l;case"stylesheet":d=pl(a.href);var h=i.querySelector(Oc(d));if(h)return s.state.loading|=4,s.instance=h,It(h),h;l=g0(a),(d=ss.get(d))&&Om(l,d),h=(i.ownerDocument||i).createElement("link"),It(h);var _=h;return _._p=new Promise(function(T,A){_.onload=T,_.onerror=A}),on(h,"link",l),s.state.loading|=4,ih(h,a.precedence,i),s.instance=h;case"script":return h=ml(a.src),(d=i.querySelector(Bc(h)))?(s.instance=d,It(d),d):(l=a,(d=ss.get(h))&&(l=b({},a),Bm(l,d)),i=i.ownerDocument||i,d=i.createElement("script"),It(d),on(d,"link",l),i.head.appendChild(d),s.instance=d);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,ih(l,a.precedence,i));return s.instance}function ih(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,h=d,_=0;_<l.length;_++){var T=l[_];if(T.dataset.precedence===s)h=T;else if(h!==d)break}h?h.parentNode.insertBefore(i,h.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function Om(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Bm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var nh=null;function _0(i,s,a){if(nh===null){var l=new Map,d=nh=new Map;d.set(a,l)}else d=nh,l=d.get(a),l||(l=new Map,d.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),d=0;d<a.length;d++){var h=a[d];if(!(h[ds]||h[_i]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(s)||"";_=i+_;var T=l.get(_);T?T.push(h):l.set(_,[h])}}return l}function b0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function LE(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function y0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function OE(i,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var d=pl(l.href),h=s.querySelector(Oc(d));if(h){s=h._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=sh.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=h,It(h);return}h=s.ownerDocument||s,l=g0(l),(d=ss.get(d))&&Om(l,d),h=h.createElement("link"),It(h);var _=h;_._p=new Promise(function(T,A){_.onload=T,_.onerror=A}),on(h,"link",l),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=sh.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var jm=0;function BE(i,s){return i.stylesheets&&i.count===0&&ah(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&ah(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+s);0<i.imgBytes&&jm===0&&(jm=62500*mE());var d=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&ah(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>jm?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function sh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ah(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var rh=null;function ah(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,rh=new Map,s.forEach(jE,i),rh=null,sh.call(i))}function jE(i,s){if(!(s.state.loading&4)){var a=rh.get(i);if(a)var l=a.get(null);else{a=new Map,rh.set(i,a);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<d.length;h++){var _=d[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}d=s.instance,_=d.getAttribute("data-precedence"),h=a.get(_)||l,h===l&&a.set(null,d),a.set(_,d),this.count++,l=sh.bind(this),d.addEventListener("load",l),d.addEventListener("error",l),h?h.parentNode.insertBefore(d,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(d,i.firstChild)),s.state.loading|=4}}var jc={$$typeof:Y,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function IE(i,s,a,l,d,h,_,T,A){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=ri(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ri(0),this.hiddenUpdates=ri(null),this.identifierPrefix=l,this.onUncaughtError=d,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function S0(i,s,a,l,d,h,_,T,A,Z,he,_e){return i=new IE(i,s,a,_,A,Z,he,_e,T),s=1,h===!0&&(s|=24),h=zn(3,null,null,s),i.current=h,h.stateNode=i,s=mp(),s.refCount++,i.pooledCache=s,s.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:s},bp(h),i}function w0(i){return i?(i=qo,i):qo}function C0(i,s,a,l,d,h){d=w0(d),l.context===null?l.context=d:l.pendingContext=d,l=na(s),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=sa(i,l,s),a!==null&&(Nn(a,i,s),pc(a,i,s))}function x0(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function Im(i,s){x0(i,s),(i=i.alternate)&&x0(i,s)}function k0(i){if(i.tag===13||i.tag===31){var s=Ja(i,67108864);s!==null&&Nn(s,i,67108864),Im(i,67108864)}}function T0(i){if(i.tag===13||i.tag===31){var s=Wn();s=vn(s);var a=Ja(i,s);a!==null&&Nn(a,i,s),Im(i,s)}}var oh=!0;function zE(i,s,a,l){var d=O.T;O.T=null;var h=M.p;try{M.p=2,zm(i,s,a,l)}finally{M.p=h,O.T=d}}function PE(i,s,a,l){var d=O.T;O.T=null;var h=M.p;try{M.p=8,zm(i,s,a,l)}finally{M.p=h,O.T=d}}function zm(i,s,a,l){if(oh){var d=Pm(l);if(d===null)xm(i,s,l,lh,a),D0(i,l);else if(UE(d,i,s,a,l))l.stopPropagation();else if(D0(i,l),s&4&&-1<HE.indexOf(i)){for(;d!==null;){var h=Es(d);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=kt(h.pendingLanes);if(_!==0){var T=h;for(T.pendingLanes|=2,T.entangledLanes|=2;_;){var A=1<<31-ct(_);T.entanglements[1]|=A,_&=~A}Us(h),(Mt&6)===0&&(Fd=lt()+500,Mc(0))}}break;case 31:case 13:T=Ja(h,2),T!==null&&Nn(T,h,2),qd(),Im(h,2)}if(h=Pm(l),h===null&&xm(i,s,l,lh,a),h===d)break;d=h}d!==null&&l.stopPropagation()}else xm(i,s,l,null,a)}}function Pm(i){return i=$r(i),Hm(i)}var lh=null;function Hm(i){if(lh=null,i=hs(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=u(s),i!==null)return i;i=null}else if(a===31){if(i=m(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return lh=i,null}function E0(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(Nt()){case yt:return 2;case Tt:return 8;case $e:case St:return 32;case Lt:return 268435456;default:return 32}default:return 32}}var Um=!1,ma=null,ga=null,va=null,Ic=new Map,zc=new Map,_a=[],HE="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 D0(i,s){switch(i){case"focusin":case"focusout":ma=null;break;case"dragenter":case"dragleave":ga=null;break;case"mouseover":case"mouseout":va=null;break;case"pointerover":case"pointerout":Ic.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":zc.delete(s.pointerId)}}function Pc(i,s,a,l,d,h){return i===null||i.nativeEvent!==h?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[d]},s!==null&&(s=Es(s),s!==null&&k0(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function UE(i,s,a,l,d){switch(s){case"focusin":return ma=Pc(ma,i,s,a,l,d),!0;case"dragenter":return ga=Pc(ga,i,s,a,l,d),!0;case"mouseover":return va=Pc(va,i,s,a,l,d),!0;case"pointerover":var h=d.pointerId;return Ic.set(h,Pc(Ic.get(h)||null,i,s,a,l,d)),!0;case"gotpointercapture":return h=d.pointerId,zc.set(h,Pc(zc.get(h)||null,i,s,a,l,d)),!0}return!1}function R0(i){var s=hs(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){i.blockedOn=s,Ji(i.priority,function(){T0(a)});return}}else if(s===31){if(s=m(a),s!==null){i.blockedOn=s,Ji(i.priority,function(){T0(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function ch(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Pm(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);yi=l,a.target.dispatchEvent(l),yi=null}else return s=Es(a),s!==null&&k0(s),i.blockedOn=a,!1;s.shift()}return!0}function M0(i,s,a){ch(i)&&a.delete(s)}function KE(){Um=!1,ma!==null&&ch(ma)&&(ma=null),ga!==null&&ch(ga)&&(ga=null),va!==null&&ch(va)&&(va=null),Ic.forEach(M0),zc.forEach(M0)}function uh(i,s){i.blockedOn===s&&(i.blockedOn=null,Um||(Um=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,KE)))}var dh=null;function N0(i){dh!==i&&(dh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){dh===i&&(dh=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],d=i[s+2];if(typeof l!="function"){if(Hm(l||a)===null)continue;break}var h=Es(a);h!==null&&(i.splice(s,3),s-=3,Pp(h,{pending:!0,data:d,method:a.method,action:l},l,d))}}))}function gl(i){function s(A){return uh(A,i)}ma!==null&&uh(ma,i),ga!==null&&uh(ga,i),va!==null&&uh(va,i),Ic.forEach(s),zc.forEach(s);for(var a=0;a<_a.length;a++){var l=_a[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<_a.length&&(a=_a[0],a.blockedOn===null);)R0(a),a.blockedOn===null&&_a.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var d=a[l],h=a[l+1],_=d[bi]||null;if(typeof h=="function")_||N0(a);else if(_){var T=null;if(h&&h.hasAttribute("formAction")){if(d=h,_=h[bi]||null)T=_.formAction;else if(Hm(d)!==null)continue}else T=_.action;typeof T=="function"?a[l+1]=T:(a.splice(l,3),l-=3),N0(a)}}}function A0(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return d=_})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,d=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),d!==null&&(d(),d=null)}}}function Km(i){this._internalRoot=i}hh.prototype.render=Km.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Wn();C0(a,l,i,s,null,null)},hh.prototype.unmount=Km.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;C0(i.current,2,null,i,null,null),qd(),s[Bn]=null}};function hh(i){this._internalRoot=i}hh.prototype.unstable_scheduleHydration=function(i){if(i){var s=ii();i={blockedOn:null,target:i,priority:s};for(var a=0;a<_a.length&&s!==0&&s<_a[a].priority;a++);_a.splice(a,0,i),a===0&&R0(i)}};var L0=t.version;if(L0!=="19.2.6")throw Error(r(527,L0,"19.2.6"));M.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var WE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var fh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fh.isDisabled&&fh.supportsFiber)try{rt=fh.inject(WE),Ze=fh}catch{}}return Uc.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",d=Hy,h=Uy,_=Ky;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(h=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=S0(i,1,!1,null,null,a,l,null,d,h,_,A0),i[Bn]=s.current,Cm(i),new Km(s)},Uc.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,d="",h=Hy,_=Uy,T=Ky,A=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(T=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),s=S0(i,1,!0,s,a??null,l,d,A,h,_,T,A0),s.context=w0(null),a=s.current,l=Wn(),l=vn(l),d=na(l),d.callback=null,sa(a,d,l),a=l,s.current.lanes=a,di(s,a),Us(s),i[Bn]=s.current,Cm(i),new hh(s)},Uc.version="19.2.6",Uc}var W0;function JE(){if(W0)return $m.exports;W0=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(),$m.exports=QE(),$m.exports}var e2=JE();class fo extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function lC(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let u=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{u||(u=!0,m(),o(b))},p=b=>{u||(u=!0,m(),c(b))},y=()=>{t.abort(),p(new fo(0,"Upload aborted."))};if(e.signal?.aborted){p(new fo(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST",e.endpoint??"/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{p(new fo(t.status,"Invalid upload response."))}return}p(new fo(t.status,t2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new fo(0,"Upload failed.")),t.onabort=()=>p(new fo(0,"Upload aborted.")),t.ontimeout=()=>p(new fo(0,"Upload timed out.")),t.send(n)})}function t2(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class Ln extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Sf(e=fetch){return{getSession:(t={})=>Ae(e,`/api/auth/session${$s(t)}`),setupPassword:t=>Ae(e,"/api/auth/password",it("POST",t)),login:t=>Ae(e,"/api/auth/login",it("POST",t)),reauth:t=>Ae(e,"/api/auth/reauth",it("POST",t)),logout:()=>Ae(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ae(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Ae(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ae(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Ae(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ae(e,"/api/auth/devices"),revokeDevice:async t=>{await yl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ae(e,"/api/auth/networks"),addNetwork:t=>Ae(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await yl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ae(e,"/api/agents"),addAgent:t=>Ae(e,"/api/agents",it("POST",t)),reorderAgents:t=>Ae(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>Ae(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>Ae(e,"/api/main"),renameMain:t=>Ae(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await yl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ae(e,"/api/stats"),getAgentStats:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ae(e,"/api/version"),checkUpdate:()=>Ae(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ae(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Ae(e,`/api/code-server/status${$s(t)}`),installCodeServer:()=>Ae(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Ae(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>Ae(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>Ae(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ae(e,"/api/terminals"),getTerminalLayout:()=>Ae(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ae(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>Ae(e,"/api/files/root",it("POST",t)),listFiles:t=>Ae(e,"/api/files/list",it("POST",t)),readFile:t=>Ae(e,"/api/files/read",it("POST",t)),writeFile:t=>Ae(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Ae(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Ae(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Ae(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Ae(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Ae(e,"/api/files/open",it("POST",t)),previewFile:t=>cC(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Ae(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await yl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Ae(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/history${$s(n)}`),getTerminalTranscriptHistory:(t,n={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${$s(n)}`),getTerminalTranscriptSource:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${$s(r)}`),listNotificationAssets:()=>Ae(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Ae(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Ae(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await yl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Ae(e,`/api/push-notifications/status${t||n?$s({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Ae(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>Ae(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>Ae(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>Ae(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>Ae(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>Ae(e,"/api/push-notifications/test",it("POST",t))}}function Al(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Ae(t,n("terminals")),createTerminal:(r={})=>Ae(t,n("terminals"),it("POST",r)),closeTerminal:async r=>{await yl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ae(t,n(`terminals/${encodeURIComponent(r)}`),it("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${$s(o)}`),getTerminalTranscriptHistory:(r,o={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${$s(o)}`),getTerminalTranscriptSource:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${$s(c)}`),getTerminalLayout:()=>Ae(t,n("terminal-layout")),saveTerminalLayout:r=>Ae(t,n("terminal-layout"),it("PUT",r)),createFileRoot:r=>Ae(t,n("files/root"),it("POST",r)),listFiles:r=>Ae(t,n("files/list"),it("POST",r)),readFile:r=>Ae(t,n("files/read"),it("POST",r)),writeFile:r=>Ae(t,n("files/write"),it("POST",r)),createFileEntry:r=>Ae(t,n("files/create"),it("POST",r)),moveFileEntry:r=>Ae(t,n("files/move"),it("POST",r)),previewDeleteFileEntry:r=>Ae(t,n("files/delete-preview"),it("POST",r)),deleteFileEntry:r=>Ae(t,n("files/delete"),it("POST",r)),openFileInTerminal:r=>Ae(t,n("files/open"),it("POST",r)),previewFile:r=>cC(t,n("files/preview"),it("POST",r)),uploadComposeAttachments:r=>lC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>Ae(t,n("attachments/limits")),deleteComposeAttachments:r=>Ae(t,n("attachments/delete"),it("POST",r)),getCodeServerStatus:(r={})=>Ae(t,`${n("code-server/status")}${$s(r)}`),installCodeServer:()=>Ae(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>Ae(t,n("code-server/open"),it("POST",r)),stopCodeServer:(r={})=>Ae(t,n("code-server/stop"),it("POST",r)),uninstallCodeServer:()=>Ae(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>i2(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function i2(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function it(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function $s(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.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),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function Ae(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await O_(r);try{return await r.json()}catch{throw new Ln(r.status,"invalid_json_response")}}async function yl(e,t,n){const r=await e(t,n);await O_(r)}async function cC(e,t,n){const r=await e(t,n);return await O_(r),r.blob()}async function O_(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Ln(e.status,t)}const B_="nterminal.theme.id",uC="nterminal.theme.accent",Wg="nterminal:theme",Xh=[{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",...F0({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",...F0({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Ll="midnight";function wf(e){return Xh.some(t=>t.id===e)?e:Ll}function j_(e){return Xh.find(t=>t.id===e)??Xh[0]}function Ba(){if(typeof window>"u")return Ll;try{const e=window.localStorage.getItem(B_);return e?wf(e):o2(window.localStorage.getItem(uC))}catch{return Ll}}function n2(e){const t=wf(e);if(typeof window<"u"){try{window.localStorage.setItem(B_,t)}catch{}I_(t),window.dispatchEvent(new CustomEvent(Wg,{detail:t}))}return t}function I_(e=Ba()){if(typeof document>"u")return;const t=j_(wf(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),ht(n,"--nt-bg",t.tokens.bg),ht(n,"--nt-bg-2",t.tokens.bg2),ht(n,"--nt-bg-sidebar",t.tokens.bgSidebar),ht(n,"--nt-line",t.tokens.line),ht(n,"--nt-line-2",t.tokens.line2),ht(n,"--nt-fg",t.tokens.fg),ht(n,"--nt-fg-2",t.tokens.fg2),ht(n,"--nt-fg-3",t.tokens.fg3),ht(n,"--nt-fg-4",t.tokens.fg4),ht(n,"--nt-accent",t.tokens.accent),ht(n,"--nt-accent-soft",t.tokens.accentSoft),ht(n,"--nt-accent-glow",t.tokens.accentGlow),ht(n,"--nt-on-accent",t.tokens.onAccent),ht(n,"--nt-ok",t.tokens.ok),ht(n,"--nt-danger",t.tokens.danger),ht(n,"--nt-on-danger",t.tokens.onDanger),ht(n,"--nt-danger-soft",t.tokens.dangerSoft),ht(n,"--nt-danger-line",t.tokens.dangerLine),ht(n,"--nt-warning",t.tokens.warning),ht(n,"--nt-warn",t.tokens.warning),ht(n,"--nt-warning-soft",t.tokens.warningSoft),ht(n,"--nt-warning-glow",t.tokens.warningGlow),ht(n,"--nt-scrim",t.tokens.scrim),ht(n,"--nt-scrim-soft",t.tokens.scrimSoft),ht(n,"--nt-shadow",t.tokens.shadow),ht(n,"--nt-shadow-strong",t.tokens.shadowStrong),ht(n,"--nt-floating-bg",t.tokens.floatingBg),ht(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),ht(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),ht(n,"--nt-subtle-fill",t.tokens.subtleFill),ht(n,"--nt-hover-fill",t.tokens.hoverFill),ht(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),ht(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),ht(n,"--nt-transcript-user",t.tokens.transcriptUser),ht(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),ht(n,"--nt-transcript-tool",t.tokens.transcriptTool),ht(n,"--nt-transcript-command",t.tokens.transcriptCommand),ht(n,"--nt-transcript-code",t.tokens.transcriptCode),ht(n,"--nt-transcript-search",t.tokens.transcriptSearch),ht(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),ht(n,"--nt-qr-bg",t.tokens.qrBg)}function s2(e=Ba()){return j_(wf(e)).xterm}function z_(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===B_||n.key===uC)&&(I_(Ba()),e())};return window.addEventListener(Wg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Wg,e),window.removeEventListener("storage",t)}}function ht(e,t,n){e.style.setProperty(t,n)}function F0(e){const t=r2(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 r2(e){const t=[];for(let n=16;n<=e;n+=1)t.push(a2(n));return t}function a2(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return $0(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return $0(t,t,t)}return"#000000"}function $0(e,t,n){return`#${Xm(e)}${Xm(t)}${Xm(n)}`}function Xm(e){return e.toString(16).padStart(2,"0")}function o2(e){return e==="signal-red"?"signal-red":Ll}function dC(){const e=v.useSyncExternalStore(z_,Ba,()=>Ll);return j_(e).mode==="light"?"-light":""}function hC({size:e=22}){const t=dC();return f.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function fC({height:e=18}){const t=dC(),n=Math.round(243/34*e);return f.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var eu=oC();const Cf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function P_(e){return"nodeType"in e}function On(e){var t,n;return e?Pl(e)?e:P_(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function H_(e){const{Document:t}=On(e);return e instanceof t}function Ku(e){return Pl(e)?!1:e instanceof On(e).HTMLElement}function pC(e){return e instanceof On(e).SVGElement}function Hl(e){return e?Pl(e)?e.document:P_(e)?H_(e)?e:Ku(e)||pC(e)?e.ownerDocument:document:document:document}const ja=Cf?v.useLayoutEffect:v.useEffect;function U_(e){const t=v.useRef(e);return ja(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function l2(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function wu(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ja(()=>{n.current!==e&&(n.current=e)},t),n}function Wu(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Gh(e){const t=U_(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Fg(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Gm={};function xf(e,t){return v.useMemo(()=>{if(t)return t;const n=Gm[e]==null?0:Gm[e]+1;return Gm[e]=n,e+"-"+n},[e,t])}function mC(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,u)=>{const m=Object.entries(u);for(const[g,p]of m){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const Rl=mC(1),Zh=mC(-1);function c2(e){return"clientX"in e&&"clientY"in e}function gC(e){if(!e)return!1;const{KeyboardEvent:t}=On(e.target);return t&&e instanceof t}function u2(e){if(!e)return!1;const{TouchEvent:t}=On(e.target);return t&&e instanceof t}function $g(e){if(u2(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return c2(e)?{x:e.clientX,y:e.clientY}:null}const qg=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[qg.Translate.toString(e),qg.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),q0="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function d2(e){return e.matches(q0)?e:e.querySelector(q0)}const h2={display:"none"};function f2(e){let{id:t,value:n}=e;return Ai.createElement("div",{id:t,style:h2},n)}function p2(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ai.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function m2(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const vC=v.createContext(null);function g2(e){const t=v.useContext(vC);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function v2(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(u=>{var m;return(m=u[o])==null?void 0:m.call(u,c)})},[e]),t]}const _2={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
|
-
`},b2={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function y2(e){let{announcements:t=b2,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=_2}=e;const{announce:c,announcement:u}=m2(),m=xf("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),g2(v.useMemo(()=>({onDragStart(b){let{active:k}=b;c(t.onDragStart({active:k}))},onDragMove(b){let{active:k,over:w}=b;t.onDragMove&&c(t.onDragMove({active:k,over:w}))},onDragOver(b){let{active:k,over:w}=b;c(t.onDragOver({active:k,over:w}))},onDragEnd(b){let{active:k,over:w}=b;c(t.onDragEnd({active:k,over:w}))},onDragCancel(b){let{active:k,over:w}=b;c(t.onDragCancel({active:k,over:w}))}}),[c,t])),!g)return null;const y=Ai.createElement(Ai.Fragment,null,Ai.createElement(f2,{id:r,value:o.draggable}),Ai.createElement(p2,{id:m,announcement:u}));return n?eu.createPortal(y,n):y}var zi;(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"})(zi||(zi={}));function Qh(){}function V0(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function S2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ks=Object.freeze({x:0,y:0});function w2(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function C2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function x2(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),u=o-r,m=c-n;if(r<o&&n<c){const g=t.width*t.height,p=e.width*e.height,y=u*m,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const k2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,m=n.get(u);if(m){const g=x2(m,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(w2)};function T2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function _C(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ks}function E2(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((u,m)=>({...u,top:u.top+e*m.y,bottom:u.bottom+e*m.y,left:u.left+e*m.x,right:u.right+e*m.x}),{...n})}}const D2=E2(1);function R2(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 M2(e,t,n){const r=R2(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:m}=r,g=e.left-u-(1-o)*parseFloat(n),p=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:p,right:g+y,bottom:p+b,left:g}}const N2={ignoreTransform:!1};function Fu(e,t){t===void 0&&(t=N2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=On(e).getComputedStyle(e);p&&(n=M2(n,p,y))}const{top:r,left:o,width:c,height:u,bottom:m,right:g}=n;return{top:r,left:o,width:c,height:u,bottom:m,right:g}}function Y0(e){return Fu(e,{ignoreTransform:!0})}function A2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function L2(e,t){return t===void 0&&(t=On(e).getComputedStyle(e)),t.position==="fixed"}function O2(e,t){t===void 0&&(t=On(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function K_(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(H_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ku(o)||pC(o)||n.includes(o))return n;const c=On(e).getComputedStyle(o);return o!==e&&O2(o,c)&&n.push(o),L2(o,c)?n:r(o.parentNode)}return e?r(e):n}function bC(e){const[t]=K_(e,1);return t??null}function Zm(e){return!Cf||!e?null:Pl(e)?e:P_(e)?H_(e)||e===Hl(e).scrollingElement?window:Ku(e)?e:null:null}function yC(e){return Pl(e)?e.scrollX:e.scrollLeft}function SC(e){return Pl(e)?e.scrollY:e.scrollTop}function Vg(e){return{x:yC(e),y:SC(e)}}var Vi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vi||(Vi={}));function wC(e){return!Cf||!e?!1:e===document.scrollingElement}function CC(e){const t={x:0,y:0},n=wC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,u=e.scrollTop>=r.y,m=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:u,isRight:m,maxScroll:r,minScroll:t}}const B2={x:.2,y:.2};function j2(e,t,n,r,o){let{top:c,left:u,right:m,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=B2);const{isTop:p,isBottom:y,isLeft:b,isRight:k}=CC(e),w={x:0,y:0},S={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+D.height?(w.y=Vi.Backward,S.y=r*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(w.y=Vi.Forward,S.y=r*Math.abs((t.bottom-D.height-g)/D.height)),!k&&m>=t.right-D.width?(w.x=Vi.Forward,S.x=r*Math.abs((t.right-D.width-m)/D.width)):!b&&u<=t.left+D.width&&(w.x=Vi.Backward,S.x=r*Math.abs((t.left+D.width-u)/D.width)),{direction:w,speed:S}}function I2(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function xC(e){return e.reduce((t,n)=>Rl(t,Vg(n)),ks)}function z2(e){return e.reduce((t,n)=>t+yC(n),0)}function P2(e){return e.reduce((t,n)=>t+SC(n),0)}function H2(e,t){if(t===void 0&&(t=Fu),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);bC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const U2=[["x",["left","right"],z2],["y",["top","bottom"],P2]];class W_{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=K_(n),o=xC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,m]of U2)for(const g of u)Object.defineProperty(this,g,{get:()=>{const p=m(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class du{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function K2(e){const{EventTarget:t}=On(e);return e instanceof t?e:Hl(e)}function Qm(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var os;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(os||(os={}));function X0(e){e.preventDefault()}function W2(e){e.stopPropagation()}var Yt;(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"})(Yt||(Yt={}));const kC={start:[Yt.Space,Yt.Enter],cancel:[Yt.Esc],end:[Yt.Space,Yt.Enter,Yt.Tab]},F2=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Yt.Right:return{...n,x:n.x+25};case Yt.Left:return{...n,x:n.x-25};case Yt.Down:return{...n,y:n.y+25};case Yt.Up:return{...n,y:n.y-25}}};class TC{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new du(Hl(n)),this.windowListeners=new du(On(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(os.Resize,this.handleCancel),this.windowListeners.add(os.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(os.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&H2(r),n(ks)}handleKeyDown(t){if(gC(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=kC,coordinateGetter:u=F2,scrollBehavior:m="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,y=p?{x:p.left,y:p.top}:ks;this.referenceCoordinates||(this.referenceCoordinates=y);const b=u(t,{active:n,context:r.current,currentCoordinates:y});if(b){const k=Zh(b,y),w={x:0,y:0},{scrollableAncestors:S}=r.current;for(const D of S){const I=t.code,{isTop:L,isRight:H,isLeft:Y,isBottom:$,maxScroll:se,minScroll:J}=CC(D),F=I2(D),xe={x:Math.min(I===Yt.Right?F.right-F.width/2:F.right,Math.max(I===Yt.Right?F.left:F.left+F.width/2,b.x)),y:Math.min(I===Yt.Down?F.bottom-F.height/2:F.bottom,Math.max(I===Yt.Down?F.top:F.top+F.height/2,b.y))},re=I===Yt.Right&&!H||I===Yt.Left&&!Y,Ee=I===Yt.Down&&!$||I===Yt.Up&&!L;if(re&&xe.x!==b.x){const ie=D.scrollLeft+k.x,V=I===Yt.Right&&ie<=se.x||I===Yt.Left&&ie>=J.x;if(V&&!k.y){D.scrollTo({left:ie,behavior:m});return}V?w.x=D.scrollLeft-ie:w.x=I===Yt.Right?D.scrollLeft-se.x:D.scrollLeft-J.x,w.x&&D.scrollBy({left:-w.x,behavior:m});break}else if(Ee&&xe.y!==b.y){const ie=D.scrollTop+k.y,V=I===Yt.Down&&ie<=se.y||I===Yt.Up&&ie>=J.y;if(V&&!k.x){D.scrollTo({top:ie,behavior:m});return}V?w.y=D.scrollTop-ie:w.y=I===Yt.Down?D.scrollTop-se.y:D.scrollTop-J.y,w.y&&D.scrollBy({top:-w.y,behavior:m});break}}this.handleMove(t,Rl(Zh(b,this.referenceCoordinates),w))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}TC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=kC,onActivation:o}=t,{active:c}=n;const{code:u}=e.nativeEvent;if(r.start.includes(u)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function G0(e){return!!(e&&"distance"in e)}function Z0(e){return!!(e&&"delay"in e)}class F_{constructor(t,n,r){var o;r===void 0&&(r=K2(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:u}=c;this.props=t,this.events=n,this.document=Hl(u),this.documentListeners=new du(this.document),this.listeners=new du(r),this.windowListeners=new du(On(u)),this.initialCoordinates=(o=$g(c))!=null?o:ks,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(os.Resize,this.handleCancel),this.windowListeners.add(os.DragStart,X0),this.windowListeners.add(os.VisibilityChange,this.handleCancel),this.windowListeners.add(os.ContextMenu,X0),this.documentListeners.add(os.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Z0(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(G0(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(os.Click,W2,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(os.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=$g(t))!=null?n:ks,p=Zh(o,g);if(!r&&m){if(G0(m)){if(m.tolerance!=null&&Qm(p,m.tolerance))return this.handleCancel();if(Qm(p,m.distance))return this.handleStart()}if(Z0(m)&&Qm(p,m.tolerance))return this.handleCancel();this.handlePending(m,p);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Yt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const $2={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class EC extends F_{constructor(t){const{event:n}=t,r=Hl(n.target);super(t,$2,r)}}EC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const q2={move:{name:"mousemove"},end:{name:"mouseup"}};var Yg;(function(e){e[e.RightClick=2]="RightClick"})(Yg||(Yg={}));class DC extends F_{constructor(t){super(t,q2,Hl(t.event.target))}}DC.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Yg.RightClick?!1:(r?.({event:n}),!0)}}];const Jm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class RC extends F_{constructor(t){super(t,Jm)}static setup(){return window.addEventListener(Jm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Jm.move.name,t)};function t(){}}}RC.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var hu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(hu||(hu={}));var Jh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Jh||(Jh={}));function V2(e){let{acceleration:t,activator:n=hu.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:m=Jh.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:k}=e;const w=X2({delta:b,disabled:!c}),[S,D]=l2(),I=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),H=v.useMemo(()=>{switch(n){case hu.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case hu.DraggableRect:return o}},[n,o,g]),Y=v.useRef(null),$=v.useCallback(()=>{const J=Y.current;if(!J)return;const F=I.current.x*L.current.x,xe=I.current.y*L.current.y;J.scrollBy(F,xe)},[]),se=v.useMemo(()=>m===Jh.TreeOrder?[...p].reverse():p,[m,p]);v.useEffect(()=>{if(!c||!p.length||!H){D();return}for(const J of se){if(r?.(J)===!1)continue;const F=p.indexOf(J),xe=y[F];if(!xe)continue;const{direction:re,speed:Ee}=j2(J,xe,H,t,k);for(const ie of["x","y"])w[ie][re[ie]]||(Ee[ie]=0,re[ie]=0);if(Ee.x>0||Ee.y>0){D(),Y.current=J,S($,u),I.current=Ee,L.current=re;return}}I.current={x:0,y:0},L.current={x:0,y:0},D()},[t,$,r,D,c,u,JSON.stringify(H),JSON.stringify(w),S,p,se,y,JSON.stringify(k)])}const Y2={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function X2(e){let{delta:t,disabled:n}=e;const r=Fg(t);return Wu(o=>{if(n||!r||!o)return Y2;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Vi.Backward]:o.x[Vi.Backward]||c.x===-1,[Vi.Forward]:o.x[Vi.Forward]||c.x===1},y:{[Vi.Backward]:o.y[Vi.Backward]||c.y===-1,[Vi.Forward]:o.y[Vi.Forward]||c.y===1}}},[n,t,r])}function G2(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Wu(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function Z2(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...n,...c]},[]),[e,t])}var Cu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Cu||(Cu={}));var Xg;(function(e){e.Optimized="optimized"})(Xg||(Xg={}));const Q0=new Map;function Q2(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:m,measure:g,strategy:p}=o,y=v.useRef(e),b=I(),k=wu(b),w=v.useCallback(function(L){L===void 0&&(L=[]),!k.current&&u(H=>H===null?L:H.concat(L.filter(Y=>!H.includes(Y))))},[k]),S=v.useRef(null),D=Wu(L=>{if(b&&!n)return Q0;if(!L||L===Q0||y.current!==e||c!=null){const H=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){H.set(Y.id,Y.rect.current);continue}const $=Y.node.current,se=$?new W_(g($),$):null;Y.rect.current=se,se&&H.set(Y.id,se)}return H}return L},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||w()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||S.current!==null||(S.current=setTimeout(()=>{w(),S.current=null},m))},[m,b,w,...r]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function I(){switch(p){case Cu.Always:return!1;case Cu.BeforeDragging:return n;default:return!n}}}function MC(e,t){return Wu(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function J2(e,t){return MC(e,t)}function eD(e){let{callback:t,disabled:n}=e;const r=U_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function kf(e){let{callback:t,disabled:n}=e;const r=U_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function tD(e){return new W_(Fu(e),e)}function J0(e,t,n){t===void 0&&(t=tD);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const u=eD({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=kf({callback:c});return ja(()=>{c(),e?(m?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),u?.disconnect())},[e]),r}function iD(e){const t=MC(e);return _C(e,t)}const ew=[];function nD(e){const t=v.useRef(e),n=Wu(r=>e?r&&r!==ew&&e&&t.current&&e.parentNode===t.current.parentNode?r:K_(e):ew,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function sD(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=Zm(c.target);u&&n(m=>m?(m.set(u,Vg(u)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const m=e.map(g=>{const p=Zm(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Vg(p)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),r.current=e}return()=>{u(e),u(c)};function u(m){m.forEach(g=>{const p=Zm(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>Rl(c,u),ks):xC(e):ks,[e,t])}function tw(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==ks;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Zh(e,n.current):ks}function rD(e){v.useEffect(()=>{if(!Cf)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function aD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=u=>{c(u,t)},n},{}),[e,t])}function NC(e){return v.useMemo(()=>e?A2(e):null,[e])}const iw=[];function oD(e,t){t===void 0&&(t=Fu);const[n]=e,r=NC(n?On(n):null),[o,c]=v.useState(iw);function u(){c(()=>e.length?e.map(g=>wC(g)?r:new W_(t(g),g)):iw)}const m=kf({callback:u});return ja(()=>{m?.disconnect(),u(),e.forEach(g=>m?.observe(g))},[e]),o}function lD(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ku(t)?t:e}function cD(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if(Ku(y)){r(b=>{const k=t(y);return b?{...b,width:k.width,height:k.height}:k});break}},[t]),c=kf({callback:o}),u=v.useCallback(p=>{const y=lD(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[m,g]=Gh(u);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const uD=[{sensor:EC,options:{}},{sensor:TC,options:{}}],dD={current:{}},Ah={draggable:{measure:Y0},droppable:{measure:Y0,strategy:Cu.WhileDragging,frequency:Xg.Optimized},dragOverlay:{measure:Fu}};class fu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const hD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ah,measureDroppableContainers:Qh,windowRect:null,measuringScheduled:!1},fD={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qh,draggableNodes:new Map,over:null,measureDroppableContainers:Qh},Tf=v.createContext(fD),pD=v.createContext(hD);function mD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new fu}}}function gD(e,t){switch(t.type){case zi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case zi.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 zi.DragEnd:case zi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case zi.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new fu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case zi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const u=new fu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case zi.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new fu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function vD(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Tf),c=Fg(r),u=Fg(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!gC(c)||document.activeElement===c.target)return;const m=o.get(u);if(!m)return;const{activatorNode:g,node:p}=m;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=d2(y);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function _D(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function bD(e){return v.useMemo(()=>({draggable:{...Ah.draggable,...e?.draggable},droppable:{...Ah.droppable,...e?.droppable},dragOverlay:{...Ah.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function yD(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:m}=typeof o=="boolean"?{x:o,y:o}:o;ja(()=>{if(!u&&!m||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=n(p),b=_C(y,r);if(u||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const k=bC(p);k&&k.scrollBy({top:b.y,left:b.x})}},[t,u,m,r,n])}const AC=v.createContext({...ks,scaleX:1,scaleY:1});var Ta;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ta||(Ta={}));const SD=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:m,autoScroll:g=!0,children:p,sensors:y=uD,collisionDetection:b=k2,measuring:k,modifiers:w,...S}=t;const D=v.useReducer(gD,void 0,mD),[I,L]=D,[H,Y]=v2(),[$,se]=v.useState(Ta.Uninitialized),J=$===Ta.Initialized,{draggable:{active:F,nodes:xe,translate:re},droppable:{containers:Ee}}=I,ie=F!=null?xe.get(F):null,V=v.useRef({initial:null,translated:null}),X=v.useMemo(()=>{var tt;return F!=null?{id:F,data:(tt=ie?.data)!=null?tt:dD,rect:V}:null},[F,ie]),W=v.useRef(null),[le,O]=v.useState(null),[M,B]=v.useState(null),ae=wu(S,Object.values(S)),we=xf("DndDescribedBy",u),N=v.useMemo(()=>Ee.getEnabled(),[Ee]),U=bD(k),{droppableRects:ue,measureDroppableContainers:Ce,measuringScheduled:Oe}=Q2(N,{dragging:J,dependencies:[re.x,re.y],config:U.droppable}),De=G2(xe,F),Be=v.useMemo(()=>M?$g(M):null,[M]),Ne=st(),Ue=J2(De,U.draggable.measure);yD({activeNode:F!=null?xe.get(F):null,config:Ne.layoutShiftCompensation,initialRect:Ue,measure:U.draggable.measure});const We=J0(De,U.draggable.measure,Ue),ne=J0(De?De.parentElement:null),pe=v.useRef({activatorEvent:null,active:null,activeNode:De,collisionRect:null,collisions:null,droppableRects:ue,draggableNodes:xe,draggingNode:null,draggingNodeRect:null,droppableContainers:Ee,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),R=Ee.getNodeFor((n=pe.current.over)==null?void 0:n.id),q=cD({measure:U.dragOverlay.measure}),fe=(r=q.nodeRef.current)!=null?r:De,ge=J?(o=q.rect)!=null?o:We:null,Q=!!(q.nodeRef.current&&q.rect),ke=iD(Q?null:We),de=NC(fe?On(fe):null),Re=nD(J?R??De:null),Ie=oD(Re),je=_D(w,{transform:{x:re.x-ke.x,y:re.y-ke.y,scaleX:1,scaleY:1},activatorEvent:M,active:X,activeNodeRect:We,containerNodeRect:ne,draggingNodeRect:ge,over:pe.current.over,overlayNodeRect:q.rect,scrollableAncestors:Re,scrollableAncestorRects:Ie,windowRect:de}),Ye=Be?Rl(Be,re):null,lt=sD(Re),Nt=tw(lt),yt=tw(lt,[We]),Tt=Rl(je,Nt),$e=ge?D2(ge,je):null,St=X&&$e?b({active:X,collisionRect:$e,droppableRects:ue,droppableContainers:N,pointerCoordinates:Ye}):null,Lt=C2(St,"id"),[ye,Xe]=v.useState(null),rt=Q?je:Rl(je,yt),Ze=T2(rt,(c=ye?.rect)!=null?c:null,We),Et=v.useRef(null),ct=v.useCallback((tt,kt)=>{let{sensor:Xt,options:Wt}=kt;if(W.current==null)return;const ui=xe.get(W.current);if(!ui)return;const Gt=tt.nativeEvent,ri=new Xt({active:W.current,activeNode:ui,event:Gt,options:Wt,context:pe,onAbort(Ft){if(!xe.get(Ft))return;const{onDragAbort:ti}=ae.current,Ui={id:Ft};ti?.(Ui),H({type:"onDragAbort",event:Ui})},onPending(Ft,cn,ti,Ui){if(!xe.get(Ft))return;const{onDragPending:_n}=ae.current,ii={id:Ft,constraint:cn,initialCoordinates:ti,offset:Ui};_n?.(ii),H({type:"onDragPending",event:ii})},onStart(Ft){const cn=W.current;if(cn==null)return;const ti=xe.get(cn);if(!ti)return;const{onDragStart:Ui}=ae.current,vn={activatorEvent:Gt,active:{id:cn,data:ti.data,rect:V}};eu.unstable_batchedUpdates(()=>{Ui?.(vn),se(Ta.Initializing),L({type:zi.DragStart,initialCoordinates:Ft,active:cn}),H({type:"onDragStart",event:vn}),O(Et.current),B(Gt)})},onMove(Ft){L({type:zi.DragMove,coordinates:Ft})},onEnd:di(zi.DragEnd),onCancel:di(zi.DragCancel)});Et.current=ri;function di(Ft){return async function(){const{active:ti,collisions:Ui,over:vn,scrollAdjustedTranslate:_n}=pe.current;let ii=null;if(ti&&_n){const{cancelDrop:Ji}=ae.current;ii={activatorEvent:Gt,active:ti,collisions:Ui,delta:_n,over:vn},Ft===zi.DragEnd&&typeof Ji=="function"&&await Promise.resolve(Ji(ii))&&(Ft=zi.DragCancel)}W.current=null,eu.unstable_batchedUpdates(()=>{L({type:Ft}),se(Ta.Uninitialized),Xe(null),O(null),B(null),Et.current=null;const Ji=Ft===zi.DragEnd?"onDragEnd":"onDragCancel";if(ii){const ai=ae.current[Ji];ai?.(ii),H({type:Ji,event:ii})}})}}},[xe]),Tn=v.useCallback((tt,kt)=>(Xt,Wt)=>{const ui=Xt.nativeEvent,Gt=xe.get(Wt);if(W.current!==null||!Gt||ui.dndKit||ui.defaultPrevented)return;const ri={active:Gt};tt(Xt,kt.options,ri)===!0&&(ui.dndKit={capturedBy:kt.sensor},W.current=Wt,ct(Xt,kt))},[xe,ct]),vi=Z2(y,Tn);rD(y),ja(()=>{We&&$===Ta.Initializing&&se(Ta.Initialized)},[We,$]),v.useEffect(()=>{const{onDragMove:tt}=ae.current,{active:kt,activatorEvent:Xt,collisions:Wt,over:ui}=pe.current;if(!kt||!Xt)return;const Gt={active:kt,activatorEvent:Xt,collisions:Wt,delta:{x:Tt.x,y:Tt.y},over:ui};eu.unstable_batchedUpdates(()=>{tt?.(Gt),H({type:"onDragMove",event:Gt})})},[Tt.x,Tt.y]),v.useEffect(()=>{const{active:tt,activatorEvent:kt,collisions:Xt,droppableContainers:Wt,scrollAdjustedTranslate:ui}=pe.current;if(!tt||W.current==null||!kt||!ui)return;const{onDragOver:Gt}=ae.current,ri=Wt.get(Lt),di=ri&&ri.rect.current?{id:ri.id,rect:ri.rect.current,data:ri.data,disabled:ri.disabled}:null,Ft={active:tt,activatorEvent:kt,collisions:Xt,delta:{x:ui.x,y:ui.y},over:di};eu.unstable_batchedUpdates(()=>{Xe(di),Gt?.(Ft),H({type:"onDragOver",event:Ft})})},[Lt]),ja(()=>{pe.current={activatorEvent:M,active:X,activeNode:De,collisionRect:$e,collisions:St,droppableRects:ue,draggableNodes:xe,draggingNode:fe,draggingNodeRect:ge,droppableContainers:Ee,over:ye,scrollableAncestors:Re,scrollAdjustedTranslate:Tt},V.current={initial:ge,translated:$e}},[X,De,St,$e,xe,fe,ge,ue,Ee,ye,Re,Tt]),V2({...Ne,delta:re,draggingRect:$e,pointerCoordinates:Ye,scrollableAncestors:Re,scrollableAncestorRects:Ie});const ee=v.useMemo(()=>({active:X,activeNode:De,activeNodeRect:We,activatorEvent:M,collisions:St,containerNodeRect:ne,dragOverlay:q,draggableNodes:xe,droppableContainers:Ee,droppableRects:ue,over:ye,measureDroppableContainers:Ce,scrollableAncestors:Re,scrollableAncestorRects:Ie,measuringConfiguration:U,measuringScheduled:Oe,windowRect:de}),[X,De,We,M,St,ne,q,xe,Ee,ue,ye,Ce,Re,Ie,U,Oe,de]),Pe=v.useMemo(()=>({activatorEvent:M,activators:vi,active:X,activeNodeRect:We,ariaDescribedById:{draggable:we},dispatch:L,draggableNodes:xe,over:ye,measureDroppableContainers:Ce}),[M,vi,X,We,L,we,xe,ye,Ce]);return Ai.createElement(vC.Provider,{value:Y},Ai.createElement(Tf.Provider,{value:Pe},Ai.createElement(pD.Provider,{value:ee},Ai.createElement(AC.Provider,{value:Ze},p)),Ai.createElement(vD,{disabled:m?.restoreFocus===!1})),Ai.createElement(y2,{...m,hiddenTextDescribedById:we}));function st(){const tt=le?.autoScrollEnabled===!1,kt=typeof g=="object"?g.enabled===!1:g===!1,Xt=J&&!tt&&!kt;return typeof g=="object"?{...g,enabled:Xt}:{enabled:Xt}}}),wD=v.createContext(null),nw="button",CD="Draggable";function LC(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=xf(CD),{activators:u,activatorEvent:m,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:k}=v.useContext(Tf),{role:w=nw,roleDescription:S="draggable",tabIndex:D=0}=o??{},I=g?.id===t,L=v.useContext(I?AC:wD),[H,Y]=Gh(),[$,se]=Gh(),J=aD(u,t),F=wu(n);ja(()=>(b.set(t,{id:t,key:c,node:H,activatorNode:$,data:F}),()=>{const re=b.get(t);re&&re.key===c&&b.delete(t)}),[b,t]);const xe=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":r,"aria-pressed":I&&w===nw?!0:void 0,"aria-roledescription":S,"aria-describedby":y.draggable}),[r,w,D,I,S,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:p,attributes:xe,isDragging:I,listeners:r?void 0:J,node:H,over:k,setNodeRef:Y,setActivatorNodeRef:se,transform:L}}const xD="Droppable",kD={timeout:25};function $_(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=xf(xD),{active:u,dispatch:m,over:g,measureDroppableContainers:p}=v.useContext(Tf),y=v.useRef({disabled:n}),b=v.useRef(!1),k=v.useRef(null),w=v.useRef(null),{disabled:S,updateMeasurementsFor:D,timeout:I}={...kD,...o},L=wu(D??r),H=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{p(Array.isArray(L.current)?L.current:[L.current]),w.current=null},I)},[I]),Y=kf({callback:H,disabled:S||!u}),$=v.useCallback((xe,re)=>{Y&&(re&&(Y.unobserve(re),b.current=!1),xe&&Y.observe(xe))},[Y]),[se,J]=Gh($),F=wu(t);return v.useEffect(()=>{!Y||!se.current||(Y.disconnect(),b.current=!1,Y.observe(se.current))},[se,Y]),v.useEffect(()=>(m({type:zi.RegisterDroppable,element:{id:r,key:c,disabled:n,node:se,rect:k,data:F}}),()=>m({type:zi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:zi.SetDroppableDisabled,id:r,key:c,disabled:n}),y.current.disabled=n)},[r,c,n,m]),{active:u,rect:k,isOver:g?.id===r,node:se,over:g,setNodeRef:J}}const TD=128,ED=512,Ul=100,DD="too_many_detached_terminals",RD=64,MD=4096;function OC(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>TD)return null;const n=t.workspaces.map(ND);if(n.some(u=>u===null))return null;const r=n,o=new Set,c=new Set;for(const u of r){if(o.has(u.id))return null;o.add(u.id);for(const m of u.tabs){if(c.has(m.id))return null;c.add(m.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function BC(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>Ul}):!1}function ND(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>ED)return null;const n=t.tabs.map(AD);if(n.some(o=>o===null))return null;const r=jD(t.detachedTerminalIds,Ul);return r===null?null:{id:t.id,title:t.title,defaultCwd:BD(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function AD(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=LD(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function LD(e){if(!e||typeof e!="object")return null;let t=0;return Gg(e,1,()=>(t+=1,t<=MD))}function Gg(e,t,n){if(!e||typeof e!="object"||t>RD||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=Gg(r.first,t+1,n),c=Gg(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:OD(r.ratio),first:o,second:c}}function OD(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function BD(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function jD(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const jC=[{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"}],ID="nterminal-focus",zD=/^[A-Za-z0-9_.:-]{1,128}$/;function PD(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(ID)!=="terminal"?null:Ef({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Ef(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!sw(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!sw(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function sw(e){return typeof e=="string"&&zD.test(e)}const Yi="__main__",IC=128,HD=600*1e3,zC="nterminal.clientDiagnostics.v1",PC="nterminal.terminalDiagnosticsCursor.v1",Df=150,UD=24,KD=160,WD=48*1024,FD="terminal-connection-recovery";let rw=!1,Kc=null,Wc=null,eg=0;function $D(){rw||typeof window>"u"||(rw=!0,gn("page.load",{navigation:lR(),visibility:document.visibilityState,online:navigator.onLine,viewport:FC(),standalone:oR()}),document.addEventListener("visibilitychange",()=>{gn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{gn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{gn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>gn("network.online")),window.addEventListener("offline",()=>gn("network.offline")),window.addEventListener("focus",()=>gn("window.focus")),window.addEventListener("blur",()=>gn("window.blur")),window.addEventListener("error",e=>{gn("runtime.error",{message:e.message,source:cR(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{gn("runtime.unhandledrejection",{reason:uR(e.reason)})}))}function gn(e,t={}){const n={id:eR(),at:new Date().toISOString(),event:xu(e,80),data:WC({...t,visibility:t.visibility??rR(),online:t.online??aR(),viewport:t.viewport??FC()})},r=q_();return r.push(n),QD(r.slice(-Df)),n}function q_(){try{const e=window.localStorage.getItem(zC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(JD).filter(n=>n!==null).slice(-Df):[]}catch{return[]}}async function V_(e,t=fetch){if(Kc)return Kc;const n=q_(),r={reason:xu(e,80),events:n},o=JSON.stringify(r);Kc=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Kc}finally{Kc=null}}function Rf(){return HC().events.length>0}async function qD(e=fetch){if(Wc)return Wc;Wc=VD(e);try{return await Wc}finally{Wc=null}}async function VD(e){const t=HC();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(ZD(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function HC(){const e=UC(),t=q_().filter(o=>YD(o)&&GD(o,e)),n=[];let r=aw([]);for(const o of t){const c=[...n,o],u=aw(c);if(XD(u)>WD)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function aw(e){return JSON.stringify({reason:FD,events:e})}function YD(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function XD(e){return new TextEncoder().encode(e).byteLength}function GD(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(KC(e))}function UC(){try{const e=window.localStorage.getItem(PC);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-Df):[]}}catch{return null}}function ZD(e){const t=e.at(-1);if(!t)return;const n=UC(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(KC(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-Df)};try{window.localStorage.setItem(PC,JSON.stringify(o))}catch{}}function QD(e){try{window.localStorage.setItem(zC,JSON.stringify(e))}catch{}}function JD(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:xu(t.id,128)}:{},at:t.at.slice(0,40),event:xu(t.event,80),...t.data&&typeof t.data=="object"?{data:WC(t.data)}:{}}}function eR(){return eg=(eg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${eg.toString(36)}`.slice(0,128)}function KC(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function WC(e){const t={};for(const[n,r]of Object.entries(e).slice(0,UD)){const o=xu(n,64);if(!o||tR(o))continue;const c=iR(r);c!==void 0&&(t[o]=c)}return t}function tR(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function iR(e){if(typeof e=="string")return nR(e,KD);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function xu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function nR(e,t){return sR(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function sR(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 rR(){return typeof document>"u"?void 0:document.visibilityState}function aR(){return typeof navigator>"u"?void 0:navigator.onLine}function FC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function oR(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function lR(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function cR(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 uR(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const $C="nterminal.notifications.completionEnabled",Y_="nterminal.notifications.completionToastEnabled",X_="nterminal.notifications.completionToastDurationSeconds",G_="nterminal.notifications.completionToastPersistent",Zg="nterminal:completion-toast-display",Qg="nterminal:notification-focus",pu=6.5,Jg=2,ev=60;function Mf(){return typeof window<"u"&&"Notification"in window}function Z_(){try{return window.localStorage.getItem($C)==="true"}catch{return!1}}function ow(e){try{window.localStorage.setItem($C,e?"true":"false")}catch{}}function Co(){return{enabled:pR(),durationSeconds:fR(),persistUntilDismissed:mR()}}function dR(e){if(typeof window<"u"){try{window.localStorage.setItem(Y_,e?"true":"false")}catch{}Q_()}return Co()}function lw(e){const t=VC(e);if(typeof window<"u"){try{window.localStorage.setItem(X_,String(t))}catch{}Q_()}return Co()}function hR(e){if(typeof window<"u"){try{window.localStorage.setItem(G_,e?"true":"false")}catch{}Q_()}return Co()}function qC(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Y_||n.key===X_||n.key===G_)&&e()};return window.addEventListener(Zg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Zg,e),window.removeEventListener("storage",t)}}function Kl(){return Mf()?window.Notification.permission:"unsupported"}function fR(){if(typeof window>"u")return pu;try{const e=window.localStorage.getItem(X_);return e===null?pu:VC(Number(e))}catch{return pu}}function pR(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Y_)!=="false"}catch{return!0}}function mR(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(G_)==="true"}catch{return!1}}function VC(e){if(!Number.isFinite(e))return pu;const t=Math.round(e*2)/2;return Math.max(Jg,Math.min(ev,t))}function Q_(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Zg))}async function YC(){if(!Mf())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Kl()}}function gR(e){if(!Mf()||Kl()!=="granted"||!Z_()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=Ef({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),vR(r)})}catch{}}function vR(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Qg,{detail:e}))}const cw="nterminal.push.clientId",_R=2e4,uw=[5e3,3e4,12e4];function Rr(){try{const e=window.localStorage.getItem(cw);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${iv()}`;return window.localStorage.setItem(cw,t),t}catch{return`client-${iv()}`}}function bR(){return`page-${iv()}`}function Nf(){const e=typeof window<"u"&&window.isSecureContext===!0,t=TR(),n=ER(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function yR(e,t){const n=Nf();if(!n.supported)throw new Error(n.reason);if((Kl()==="granted"?"granted":await YC())!=="granted")throw new Error("permission_denied");const o=Rr(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await RR(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ZC(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:GC(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:XC(n.deviceKind),alwaysNotify:t})}async function SR(e){const t=Nf();if(!t.supported||Kl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Rr(),c=await MR(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&tv(r,u.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&tv(r,m.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ZC(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:GC(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:XC(t.deviceKind),alwaysNotify:!1}),!0}function wR(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=y=>{t||n||(n=!0,SR(e).then(b=>{r=0,b&&gn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(gn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&r<uw.length){const k=uw[r++];o=window.setTimeout(()=>{o=null,u("retry")},k)}}).finally(()=>{n=!1}))},m=y=>{c(),r=0,u(y)},g=()=>m("online"),p=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function CR(e){const t=Rr();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function xR(e,t){await e.updatePushNotificationDevice({clientId:Rr(),alwaysNotify:t})}function kR(e){if(typeof window>"u")return()=>{};const t=Rr(),n=bR();let r=null,o=!1;const c=(p=!0)=>{const y=Nf();e.updatePushPresence({clientId:t,pageId:n,visibilityState:DR(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:Z_()&&Kl()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),_R))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),u(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function TR(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function ER(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function XC(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function DR(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function GC(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function RR(e,t){const n=await e.pushManager.getSubscription();return n?tv(n,t)?n:(await n.unsubscribe(),null):null}function tv(e,t){const n=e.options.applicationServerKey;return n?QC(n)===t:!0}async function MR(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return QC(t)}function ZC(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let u=0;u<r.length;u+=1)c[u]=r.charCodeAt(u);return o}function QC(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function iv(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Dr(e,t){const n=[Yi,...t.map(u=>u.id)],r=new Set(n),o=new Set,c=[];for(const u of e??[])!r.has(u)||o.has(u)||(o.add(u),c.push(u));for(const u of n)o.has(u)||c.push(u);return c}function NR(e,t){return Dr(e,t).map(n=>n===Yi?null:n)}function AR(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function LR(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const dw="Local",OR=3e4,BR=2,jR=6,JC="nterminal.serverList.viewMode.v1";function IR(){try{return window.localStorage.getItem(JC)==="list"?"list":"stats"}catch{return"stats"}}function zR(e){try{window.localStorage.setItem(JC,e)}catch{}}function PR(e,t){const n=new Map(e.map(r=>[r.id,r]));return Dr(t,e).flatMap(r=>{if(r===Yi)return[{kind:"main",id:Yi}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function hw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function ex(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${cs(e.value.cpuPercent)} ${J_(e.value)}`,`MEM ${cs(e.value.memoryPercent)} ${Ar(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${cs(e.value.diskPercent)} ${Ar(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${cs(e.value.swapPercent)} ${Ar(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function fw(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${cs(e.value.cpuPercent)} (${J_(e.value)})`,`RAM ${cs(e.value.memoryPercent)} (${Ar(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${cs(e.value.diskPercent)} (${Ar(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${cs(e.value.swapPercent)} (${Ar(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function HR(e,t){const n=ex(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function cs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function J_(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`:`${nv(e.cpuPercent/100*t)}/${t} cores`}function Ar(e,t){return!pw(e)||!pw(t)?"–/–":UR(e,t)}function UR(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${nv(e/r)}/${nv(t/r)} ${n}`}function nv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function pw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function ph(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function KR(e){return[{label:"CPU",percent:cs(e.cpuPercent),detail:J_(e),tone:ph(e.cpuPercent)},{label:"MEM",percent:cs(e.memoryPercent),detail:Ar(e.memoryUsedBytes,e.memoryTotalBytes),tone:ph(e.memoryPercent)},{label:"DISK",percent:cs(e.diskPercent),detail:Ar(e.diskUsedBytes,e.diskTotalBytes),tone:ph(e.diskPercent)},{label:"SWAP",percent:cs(e.swapPercent),detail:Ar(e.swapUsedBytes,e.swapTotalBytes),tone:ph(e.swapPercent)}]}function WR({entry:e}){return e?.status==="offline"?f.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?f.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t}),f.jsx("span",{className:"server-list-stat-value",children:"–"})]}),f.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):f.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:fw(e),"aria-label":fw(e),children:KR(e.value).map(t=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t.label}),f.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),f.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function mw({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,renderServerChildren:u,compact:m=!1}){const[g,p]=v.useState([]),[y,b]=v.useState([Yi]),[k,w]=v.useState(null),[S,D]=v.useState(null),[I,L]=v.useState(""),H=v.useRef(null),[Y,$]=v.useState(()=>IR()),[se,J]=v.useState(null),[F,xe]=v.useState(null),[re,Ee]=v.useState({}),ie=v.useRef({}),V=v.useRef(0),X=v.useRef([]),W=v.useRef([Yi]),le=v.useRef(null);v.useEffect(()=>{X.current=g},[g]),v.useEffect(()=>{const ne=Dr(y,g);W.current=ne,hw(ne,y)||b(ne)},[g,y]),v.useEffect(()=>{let ne=!1;return e.listAgents().then(pe=>{ne||(p(pe.agents),b(Dr(pe.serverOrder,pe.agents)))}).catch(()=>{}),e.getMainInfo().then(pe=>{ne||w(pe.name)}).catch(()=>{}),()=>{ne=!0}},[e,o]),v.useEffect(()=>{S&&(H.current?.focus(),H.current?.select())},[S]),v.useEffect(()=>{let ne=!1;function pe(){const q=[{key:Yi,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...g.map(ge=>({key:ge.id,load:()=>e.getAgentStats(ge.id),probe:async()=>(await e.pingAgent(ge.id)).ok}))],fe=new Set(q.map(ge=>ge.key));for(const ge of Object.keys(ie.current))fe.has(ge)||delete ie.current[ge];Ee(ge=>{const Q={};for(const ke of fe)ke in ge&&(Q[ke]=ge[ke]);return Q});for(const ge of q)ge.load().then(Q=>{ne||(ie.current[ge.key]=0,Ee(ke=>fe.has(ge.key)?{...ke,[ge.key]:{status:"online",value:Q,stale:!1}}:ke))}).catch(async Q=>{if(ne)return;if(Q instanceof Ln&&Q.status===401&&ge.key===Yi){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(ge.key===Yi&&Q instanceof Ln){ie.current[ge.key]=0,Ee(de=>{if(!fe.has(ge.key))return de;const Re=de[ge.key];return{...de,[ge.key]:{status:"online",value:Re?.value??null,stale:!0}}});return}if(ge.probe)try{if(await ge.probe()){if(ne)return;ie.current[ge.key]=0,Ee(de=>{if(!fe.has(ge.key))return de;const Re=de[ge.key];return{...de,[ge.key]:{status:"online",value:Re?.value??null,stale:!0}}});return}}catch(de){if(ne)return;if(de instanceof Ln&&de.status===401){r?.({source:ge.key===Yi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const ke=(ie.current[ge.key]??0)+1;ie.current[ge.key]=ke,ke>=BR&&Ee(de=>fe.has(ge.key)?{...de,[ge.key]:{status:"offline",value:de[ge.key]?.value??null,stale:!0}}:de)})}pe();const R=window.setInterval(pe,OR);return()=>{ne=!0,window.clearInterval(R)}},[e,g,r]);function O(ne){ne==="main"?(L(k??""),D({kind:"main"})):(L(ne.name),D({kind:"agent",id:ne.id}))}async function M(){if(!S)return;const ne=I.trim(),pe=S;if(D(null),pe.kind==="main"){const R=ne||"";try{const q=await e.renameMain(R);w(q.name)}catch{}}else{if(!ne)return;const R=g.find(q=>q.id===pe.id)?.name;p(q=>q.map(fe=>fe.id===pe.id?{...fe,name:ne}:fe));try{await e.renameAgent(pe.id,ne)}catch{R!==void 0&&p(q=>q.map(fe=>fe.id===pe.id?{...fe,name:R}:fe))}}}function B(){D(null)}function ae(ne){$(ne),zR(ne)}function we(ne,pe,R){if(ne===pe)return;const q=Dr(W.current,X.current),fe=q.findIndex(je=>je===ne),ge=q.findIndex(je=>je===pe);if(fe<0||ge<0)return;const Q=[...q],[ke]=Q.splice(fe,1);if(!ke)return;const de=Q.findIndex(je=>je===pe);if(de<0)return;const Re=R==="before"?de:de+1;if(Q.splice(Re,0,ke),hw(Q,q))return;const Ie=V.current+1;V.current=Ie,W.current=Q,b(Q),e.reorderAgents(Q).then(je=>{if(V.current===Ie){X.current=je.agents;const Ye=Dr(je.serverOrder,je.agents);W.current=Ye,p(je.agents),b(Ye)}}).catch(async()=>{if(V.current===Ie)try{const je=await e.listAgents();if(V.current===Ie){X.current=je.agents;const Ye=Dr(je.serverOrder,je.agents);W.current=Ye,p(je.agents),b(Ye)}}catch{V.current===Ie&&(W.current=q,b(q))}})}function N(ne,pe){const R=Dr(W.current,X.current),q=R.findIndex(ge=>ge===ne),fe=R[q+pe];q<0||!fe||we(ne,fe,pe<0?"before":"after")}function U(ne,pe){pe.pointerType==="mouse"&&pe.button!==0||(pe.stopPropagation(),le.current={sourceId:ne,pointerId:pe.pointerId,startX:pe.clientX,startY:pe.clientY,active:!1,targetId:null,placement:"after"},pe.currentTarget.setPointerCapture?.(pe.pointerId))}function ue(ne){const pe=le.current;if(!pe||pe.pointerId!==ne.pointerId)return;const R=Math.hypot(ne.clientX-pe.startX,ne.clientY-pe.startY);if(!pe.active){if(R<jR)return;pe.active=!0,J(pe.sourceId)}const fe=document.elementFromPoint(ne.clientX,ne.clientY)?.closest("[data-server-id]"),ge=fe?.dataset.serverId??null;if(!fe||!ge||ge===pe.sourceId){pe.targetId=null,xe(null);return}const Q=fe.getBoundingClientRect(),ke=ne.clientY<Q.top+Q.height/2?"before":"after";pe.targetId=ge,pe.placement=ke,xe({serverId:ge,placement:ke})}function Ce(ne){const pe=le.current;!pe||pe.pointerId!==ne.pointerId||(ne.stopPropagation(),ne.currentTarget.releasePointerCapture?.(ne.pointerId),le.current=null,J(null),xe(null),pe.active&&pe.targetId&&we(pe.sourceId,pe.targetId,pe.placement))}function Oe(ne){const pe=le.current;pe&&pe.pointerId===ne.pointerId&&ne.currentTarget.releasePointerCapture?.(ne.pointerId),le.current=null,J(null),xe(null)}const De=k?.trim()||dw,Be=S?.kind==="main",Ne=Y==="stats",Ue=PR(g,y),We=Ue.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:De},...g.map(ne=>({agentId:ne.id,label:ne.name}))])},[g,De,c]),m?f.jsx("div",{className:"server-list server-list--compact",children:Ue.map(ne=>{const pe=ne.kind==="main",R=pe?De:ne.agent.name,q=pe?Yi:ne.id,fe=re[q],ge=ex(fe);return f.jsxs("button",{type:"button",className:`server-list-chip${(pe?t===null:t===ne.id)?" server-list-chip--active":""}`,onClick:()=>n(pe?null:ne.id),"aria-label":`${R}${ge?` — ${ge}`:""}`,title:`${R}${ge?` — ${ge}`:""}`,children:[f.jsx("span",{className:"server-list-chip-initial",children:LR(R)}),f.jsx("span",{className:"server-list-chip-pip","data-status":AR(fe)})]},ne.id)})}):f.jsxs("div",{className:`server-list server-list--${Y}`,children:[f.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="list",onClick:()=>ae("list"),title:"Show server names only",children:"List"}),f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="stats",onClick:()=>ae("stats"),title:"Show resource usage",children:"Stats"})]}),Ue.map(ne=>{const pe=ne.kind==="main",R=pe?De:ne.agent.name,q=pe?Yi:ne.id,fe=pe?t===null:t===ne.id,ge=pe?Be:S?.kind==="agent"&&S.id===ne.id,Q=u?.({agentId:pe?null:ne.id,serverId:ne.id,label:R,active:fe}),ke=F?.serverId===ne.id&&se!==ne.id?` server-list-section--drop-target server-list-section--drop-${F.placement}`:"";return f.jsxs("section",{className:`server-list-section${ke}`,"aria-label":`${R} server`,children:[f.jsx("div",{className:["server-list-row",se===ne.id?"server-list-row--dragging":"",F?.serverId===ne.id&&se!==ne.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ne.id,children:ge?f.jsxs(f.Fragment,{children:[We?f.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,f.jsx("form",{className:"server-list-editor",onSubmit:de=>{de.preventDefault(),M()},children:f.jsx("input",{ref:H,"aria-label":pe?"Rename main server":`Rename ${R}`,value:I,onChange:de=>L(de.target.value),onBlur:()=>{M()},onKeyDown:de=>{de.key==="Escape"&&(de.preventDefault(),B())},placeholder:pe?dw:void 0})})]}):f.jsxs(f.Fragment,{children:[We?f.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ne.id,title:"Drag to reorder","aria-label":`Reorder ${R}`,"aria-grabbed":se===ne.id,onPointerDown:de=>U(ne.id,de),onPointerMove:ue,onPointerUp:Ce,onPointerCancel:Oe,onKeyDown:de=>{(de.key==="ArrowUp"||de.key==="ArrowDown")&&(de.preventDefault(),de.stopPropagation(),N(ne.id,de.key==="ArrowUp"?-1:1))},onClick:de=>de.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:`server-list-item${fe?" server-list-item--active":""}`,onClick:()=>n(pe?null:ne.id),onDoubleClick:de=>{de.preventDefault(),O(pe?"main":{id:ne.id,name:R})},title:HR(R,re[q]),children:[f.jsxs("span",{className:"server-list-item-header",children:[f.jsx("span",{className:"server-list-dot"}),f.jsx("span",{className:"server-list-name",title:pe?void 0:ne.agent.url??"Outbound connection to main",children:R})]}),Ne?f.jsx(WR,{entry:re[q]}):null]})]})}),Q?f.jsx("div",{className:"server-list-children",children:Q}):null]},ne.id)})]})}function FR({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[m,g]=v.useState(null),[p,y]=v.useState(""),[b,k]=v.useState("");async function w(){try{const[L,H,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(L.devices),o(H.networks),u(Y.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function S(L){await e.revokeDevice(L),await w()}async function D(L){await e.removeNetwork(L),await w()}async function I(L){L.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),k(""),await w()}catch(H){g(H instanceof Error?H.message:"Failed to add network")}}return f.jsxs(f.Fragment,{children:[m?f.jsx("p",{className:"form-error",children:m}):null,f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted devices"}),f.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?f.jsx("p",{className:"muted",children:"No trusted devices."}):f.jsx("ul",{className:"security-list",children:t.map(L=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[L.label,L.current?f.jsx("span",{className:"security-badge",children:"this device"}):null]}),f.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{S(L.id)},children:"revoke"})]},L.id))})]}),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted networks"}),f.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?f.jsx("p",{className:"muted",children:"No trusted networks."}):f.jsx("ul",{className:"security-list",children:r.map(L=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?f.jsx("span",{className:"security-item-meta",children:L.label}):null]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(L.id)},children:"remove"})]},L.id))}),f.jsxs("form",{className:"security-add-form",onSubmit:I,children:[f.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:L=>y(L.currentTarget.value),required:!0}),f.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:L=>k(L.currentTarget.value)}),f.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Two-factor authentication"}),f.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."}),f.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const $R=1500,eb="nterminal.terminal.fontSize",tb="nterminal.terminal.fontFamily",sv="nterminal:terminal-font-size",rv="nterminal:terminal-font-family",av=11,ov=20,bo=14,ef=[{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:[]}],Ol="meslo";lv(Ol);async function tg(e=bo,t=Ol){if(typeof document>"u"||!document.fonts)return;const n=nx(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,$R)})])}function tx(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return bo;const n=Math.round(t);return Math.max(av,Math.min(ov,n))}function ix(e){return ef.some(t=>t.id===e)?e:Ol}function lv(e){return nx(e).cssFamily}function nx(e){return ef.find(t=>t.id===e)??ef[0]}function cv(){if(typeof window>"u")return bo;try{const e=window.localStorage.getItem(eb);return e?tx(e):bo}catch{return bo}}function uv(){if(typeof window>"u")return Ol;try{return ix(window.localStorage.getItem(tb))}catch{return Ol}}function mh(e){const t=tx(e);if(typeof window>"u")return t;try{window.localStorage.setItem(eb,String(t))}catch{}return window.dispatchEvent(new CustomEvent(sv,{detail:t})),t}function qR(e){const t=ix(e);if(typeof window>"u")return t;try{window.localStorage.setItem(tb,t)}catch{}return window.dispatchEvent(new CustomEvent(rv,{detail:t})),t}function sx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===eb&&e()};return window.addEventListener(sv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(sv,e),window.removeEventListener("storage",t)}}function rx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===tb&&e()};return window.addEventListener(rv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(rv,e),window.removeEventListener("storage",t)}}const ib="nterminal.terminal.showScrollProgress",dv="nterminal:terminal-scroll-progress",nb="nterminal.terminal.tmuxScrollback.shell",sb="nterminal.terminal.tmuxScrollback.agent",rb="nterminal.terminal.tmuxScrollback.overrides",ku="nterminal:terminal-tmux-scrollback",VR=200;function hv(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(ib)!=="false"}catch{return!0}}function YR(e){if(typeof window<"u"){try{window.localStorage.setItem(ib,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(dv,{detail:e}))}return e}function ax(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ib&&e()};return window.addEventListener(dv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(dv,e),window.removeEventListener("storage",t)}}function fv(){return ox(nb,!0)}function XR(e){return lx(nb,e,ku)}function pv(){return ox(sb,!0)}function GR(e){return lx(sb,e,ku)}function Lh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===nb||n.key===sb||n.key===rb)&&e()};return window.addEventListener(ku,e),window.addEventListener("storage",t),()=>{window.removeEventListener(ku,e),window.removeEventListener("storage",t)}}function ig(e){const n=cx()[e];return typeof n=="boolean"?n:null}function ZR(e,t){if(typeof window<"u"){try{const n=cx(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-VR);window.localStorage.setItem(rb,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(ku,{detail:{terminalId:e,enabled:t}}))}return t}function ox(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function lx(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function cx(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(rb);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const ab="nterminal.shortcuts.workspace.v1",mv="nterminal:workspace-shortcuts",Tu=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"subagents.toggle",label:"Toggle view agents",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],Af={"server.previous":pi("ArrowUp",{ctrlKey:!0}),"server.next":pi("ArrowDown",{ctrlKey:!0}),"tab.previous":pi("ArrowLeft",{ctrlKey:!0}),"tab.next":pi("ArrowRight",{ctrlKey:!0}),"tab.index":pi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":pi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":pi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":pi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":pi("KeyH",{altKey:!0}),"subagents.toggle":pi("KeyA",{altKey:!0}),"scrollback.toggle":pi("KeyS",{altKey:!0})},QR={"server.previous":pi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":pi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":pi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":pi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":pi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":pi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":pi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":pi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":pi("KeyH",{altKey:!0}),"subagents.toggle":pi("KeyA",{altKey:!0}),"scrollback.toggle":pi("KeyS",{altKey:!0})};function xo(){const e=hx(Af);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(ab);if(!t)return e;const n=JSON.parse(t);for(const r of Tu){const o=n[r.id];if(aM(o)){const c=fx(o,r);rM(c,QR[r.id])||(e[r.id]=c)}}}catch{return e}return e}function gw(){return JSON.stringify(xo())}function JR(e,t){const n=xo(),r=Tu.find(o=>o.id===e);return r&&(n[e]=fx(t,r),ob(n)),n}function eM(e){const t=xo();return t[e]={...Af[e]},ob(t),t}function tM(){const e=hx(Af);return ob(e),e}function mu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ab&&e()};return window.addEventListener(mv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(mv,e),window.removeEventListener("storage",t)}}function iM(e,t){const n=gx(e);return!n||lM(n)||t.indexed&&mx(e)===null||t.requiresPrimaryModifier&&!px(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function ux(e){const t=xo();for(const n of Tu){const r=t[n.id];if(!(!r||!oM(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=mx(e);if(o!==null)return{id:n.id,index:o};continue}if(gx(e)===r.code)return{id:n.id,index:null}}}return null}function gu(e){return dx(xo()[e])}function dx(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(cM(e.code)),t.join("+")}const nM=()=>gu("split.right"),sM=()=>gu("split.down");function pi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function hx(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function rM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function ob(e){if(!(typeof window>"u")){try{window.localStorage.setItem(ab,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(mv))}}function fx(e,t){return t.requiresPrimaryModifier&&!px(e)?{...Af[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function px(e){return e.ctrlKey||e.altKey||e.metaKey}function aM(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 oM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function mx(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 gx(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 lM(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function cM(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const uM="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 dM(e="nterminal",t=new Date){return{reason:"permission",message:uM,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function hM(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 vx=3600*1e3,fM="local",gv=new Set,Ma=new Map;let Ia={checking:!1,hasUpdates:!1,lastCheckedAt:null},lb=null,vu=null,tf=0,ka=null;function pM(e){return gv.add(e),()=>{gv.delete(e)}}function vw(){return Ia}function mM(e){const t=yM();lb=e,cb(),vv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!za(e,t))return;const r=Ia.lastCheckedAt;(r===null||Date.now()-r>=vx)&&vv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),za(e,t)&&bM()}}function gM(e,t){Ma.set(e,_x(t)),Bl({...Ia,hasUpdates:ub(),lastCheckedAt:Date.now()})}function ng(e){e===void 0?Ma.clear():Ma.set(e,!1),Bl({...Ia,hasUpdates:ub()})}async function vv(e,t){if(!za(e,t))return;if(ka&&ka.api===e&&ka.runId===t)return ka.promise;Bl({...Ia,checking:!0});const n=vM(e,t).finally(()=>{ka?.promise===n&&(ka=null),za(e,t)&&(Bl({...Ia,checking:!1,lastCheckedAt:Date.now()}),_M(e,t))});return ka={api:e,runId:t,promise:n},n}async function vM(e,t){try{const n=await e.listAgents();if(!za(e,t))return;const r=[{key:fM,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const u=await c.check();o.set(c.key,_x(u))}catch{o.set(c.key,Ma.get(c.key)??!1)}})),!za(e,t))return;Ma.clear();for(const[c,u]of o)Ma.set(c,u);Bl({...Ia,hasUpdates:ub()})}catch{}}function _M(e,t){za(e,t)&&(cb(),vu=window.setTimeout(()=>{vu=null,za(e,t)&&vv(e,t)},vx))}function bM(){tf+=1,cb(),lb=null,ka=null,Ma.clear(),Bl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function cb(){vu!==null&&(window.clearTimeout(vu),vu=null)}function yM(){return tf+=1,tf}function za(e,t){return lb===e&&tf===t}function _x(e){return e.updateAvailable===!0}function ub(){return Array.from(Ma.values()).some(Boolean)}function Bl(e){Ia=e;for(const t of Array.from(gv))t()}const SM=e=>new Promise(t=>setTimeout(t,e));function wM({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[u,m]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[k,w]=v.useState({});function S(M,B){c(ae=>({...ae,[M]:{...ae[M],...B}}))}function D(M,B){w(ae=>({...ae,[M]:{status:ae[M]?.status??null,busy:ae[M]?.busy??!1,error:ae[M]?.error??null,...B}}))}const I=M=>M.id===null?e.getVersion():e.getAgentVersion(M.id),L=M=>M.id===null?e.checkUpdate():e.checkAgentUpdate(M.id),H=M=>M.id===null?e.runUpdate():e.runAgentUpdate(M.id),Y=M=>M.id===null?e:Al(M.id);v.useEffect(()=>{let M=!1;return e.listAgents().then(async B=>{if(M)return;let ae="Local";try{ae=(await e.getMainInfo()).name?.trim()||ae}catch{}if(M)return;const we=new Map(B.agents.map(U=>[U.id,U])),N=Dr(B.serverOrder,B.agents).flatMap(U=>{if(U===Yi)return[{key:"local",id:null,name:ae}];const ue=we.get(U);return ue?[{key:ue.id,id:ue.id,name:ue.name}]:[]});r(N);for(const U of N)I(U).then(ue=>S(U.key,{version:ue,manualUpdate:ue.manualUpdate??null})).catch(ue=>S(U.key,{error:ue instanceof Error?ue.message:"unreachable"})),W(U)}).catch(()=>{}),()=>{M=!0}},[]);async function $(M){S(M.key,{busy:!0,status:"checking…",error:void 0});try{const B=await L(M);gM(M.key,B),S(M.key,{latestVersion:B.latestVersion,updateAvailable:B.updateAvailable,status:ie(B),...B.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(B){S(M.key,{busy:!1,error:B instanceof Error?B.message:"check failed"})}}async function se(){m(!0),await Promise.all(n.map(M=>$(M))),m(!1)}async function J(M,B){const ae=Date.now()+18e4;for(;Date.now()<ae;){await SM(3e3);try{const we=await I(M);if(B&&we.runningVersion!==B.runningVersion)return we}catch{}}return null}async function F(M){let B=o[M.key]?.version;if(!B)try{B=await I(M),S(M.key,{version:B,manualUpdate:B.manualUpdate??null})}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}S(M.key,{busy:!0,status:"updating…",error:void 0});let ae;try{ae=await H(M)}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!ae.ok){const N=ae.manualUpdate??(hM(ae.message)?dM():null);return N?(S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(S(M.key,{busy:!1,status:void 0,error:ae.message}),"failed")}if(!ae.changed)return S(M.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),ng(M.key),"unchanged";S(M.key,{status:"restarting…"});const we=await J(M,B);return we?(S(M.key,{busy:!1,version:we,updateAvailable:!1,status:"updated",manualUpdate:we.manualUpdate??null}),ng(M.key),M.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(S(M.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function xe(M){if(!(M.id===null||!window.confirm([`Delete secondary server "${M.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(M.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const ae=await e.uninstallAgent(M.id);r(we=>we.filter(N=>N.key!==M.key)),c(we=>{const N={...we};return delete N[M.key],N}),ng(M.key),t?.(M.id),p(ae.message)}catch(ae){S(M.key,{busy:!1,status:void 0,error:ae instanceof Error?ae.message:"delete failed"})}}}async function re(){m(!0),p(null);const M=n.filter(ue=>ue.id!==null),B=n.find(ue=>ue.id===null),ae=await Promise.all(M.map(ue=>F(ue))),we=ae.filter(ue=>ue==="failed").length;let N=ae.filter(ue=>ue==="manual").length,U=null;if(B&&(U=await F(B),U==="manual"&&(N+=1),U==="updated")){we>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),m(!1);return}we>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):we>0?p("Some secondary servers failed to update. Check their rows and retry."):N>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function Ee(M){return M?M.error?M.error:M.status?M.status:M.manualUpdate?"manual update required":M.version?`v${M.version.version}`:"…":"…"}function ie(M){return M.error?M.error:typeof M.updateAvailable=="boolean"?M.updateAvailable?`latest v${M.latestVersion??"available"}`:"up to date":"unknown"}function V(M){const B=M?.version;return B?`npm package v${B.runningVersion}`:""}async function X(M,B){try{await xM(B),S(M,{copiedCommand:!0}),window.setTimeout(()=>S(M,{copiedCommand:!1}),1800)}catch(ae){S(M,{error:ae instanceof Error?ae.message:"copy failed"})}}async function W(M,B=!1){try{const ae=await Y(M).getCodeServerStatus(B?{checkLatest:!0}:void 0);D(M.key,{status:ae,error:null})}catch(ae){D(M.key,{error:ae instanceof Error?ae.message:"code-server status failed"})}}async function le(M,B){if(B==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${M.name} and stop its running VS Code sessions?`))return;const ae=Y(M);D(M.key,{busy:!0,error:null});try{if(B==="install"){const we=await ae.installCodeServer();D(M.key,{status:we.status})}else if(B==="update"){const we=await ae.updateCodeServer();D(M.key,{status:we.status})}else if(B==="stop")D(M.key,{status:await ae.stopCodeServer()});else{const we=await ae.uninstallCodeServer();D(M.key,{status:we.status})}}catch(we){D(M.key,{error:we instanceof Error?we.message:"code-server action failed"})}finally{D(M.key,{busy:!1})}}const O=n.filter(M=>k[M.key]?.status?.job?.status==="running").map(M=>M.key).join("|");return v.useEffect(()=>{const M=n.filter(ae=>k[ae.key]?.status?.job?.status==="running");if(M.length===0)return;const B=window.setInterval(()=>{for(const ae of M)W(ae)},1e3);return()=>window.clearInterval(B)},[O]),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Servers"}),f.jsxs("div",{className:"update-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{se()},disabled:u,children:"Check for updates"}),f.jsx("button",{type:"button",onClick:()=>{re()},disabled:u,children:"Update all"})]}),g?f.jsx("p",{className:"settings-status",children:g}):null,y?f.jsxs("div",{className:"server-reload-required",role:"status",children:[f.jsx("span",{children:"Main server update is ready."}),f.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,f.jsx("ul",{className:"security-list",children:n.map(M=>{const B=o[M.key],ae=V(B),we=B?.manualUpdate??null,N=k[M.key]??{status:null,busy:!1,error:null},U=B?.version!==void 0&&B?.updateAvailable!==!1&&!B?.busy&&!u,ue=M.id!==null&&!B?.busy&&!u;return f.jsxs("li",{children:[f.jsxs("div",{className:"server-row-main",children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[M.name,M.id===null?f.jsx("span",{className:"security-badge",children:"Main"}):null]}),f.jsxs("span",{className:"security-item-meta",children:[ae?`${ae} — `:"",Ee(B)]})]}),we?f.jsxs("div",{className:"server-manual-update",children:[f.jsx("span",{children:we.message}),f.jsxs("div",{className:"server-manual-command",children:[f.jsx("code",{children:we.command}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{X(M.key,we.command)},children:B?.copiedCommand?"Copied":"Copy"})]})]}):null,f.jsx(CM,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{W(M,!0)},onInstall:()=>{le(M,"install")},onUpdate:()=>{le(M,"update")},onStop:()=>{le(M,"stop")},onUninstall:()=>{le(M,"uninstall")}})]}),f.jsxs("div",{className:"server-row-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{F(M)},disabled:!U,children:B?.busy?"…":"Update"}),M.id!==null?f.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{xe(M)},disabled:!ue,children:"Delete"}):null]})]},M.key)})})]})}function CM({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onStop:u,onUninstall:m}){const g=e?.job??null,p=g?.status==="running",y=e!==null,b=e?.installed===!0,k=(e?.instances.length??0)>0,w=e?.supported!==!1,S=e===null&&!n;return f.jsxs("div",{className:"server-code-addon",children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),f.jsxs("span",{className:"security-item-meta",children:[w?S?"checking...":b?`code-server v${e?.version??"unknown"}${k?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?f.jsx("p",{className:"settings-error",children:n}):null,g?f.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
|
|
16
|
-
`):`${g.action} ${g.status}`}):null,f.jsxs("div",{className:"server-code-addon-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:t||p||!w,children:"Check"}),b?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||p||!w,children:e?.updateAvailable?"Update code-server":"Reinstall"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!k,children:"Stop"}),f.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||p,children:"Uninstall"})]}):f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:!y||S||t||p||!w,children:"Install code-server"})]})]})}async function xM(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const gh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function kM({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??Sf(),[t]),[u,m]=v.useState(()=>cv()),[g,p]=v.useState(()=>uv()),[y,b]=v.useState(()=>hv()),[k,w]=v.useState(()=>fv()),[S,D]=v.useState(()=>pv()),[I,L]=v.useState(()=>Ba()),[H,Y]=v.useState(()=>xo()),[$,se]=v.useState(null),[J,F]=v.useState(null),[xe,re]=v.useState("appearance"),[Ee,ie]=v.useState(()=>Z_()),[V,X]=v.useState(()=>Co()),[W,le]=v.useState(()=>Kl()),[O,M]=v.useState([]),[B,ae]=v.useState([]),[we,N]=v.useState([]),[U,ue]=v.useState(5*1024*1024),[Ce,Oe]=v.useState(!1),[De,Be]=v.useState(null),[Ne,Ue]=v.useState(null),[We,ne]=v.useState(!1),[pe,R]=v.useState(null),[q,fe]=v.useState(null),ge=v.useRef(null),Q=v.useRef(null),ke=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),de=v.useMemo(()=>new Set(B),[B]),Re=!EM(B,we),Ie=v.useMemo(()=>Nf(),[]),je=Ne?.displayMode==="standalone"&&(Ne.deviceKind==="mobile"||Ne.deviceKind==="tablet");v.useEffect(()=>sx(()=>m(cv())),[]),v.useEffect(()=>rx(()=>p(uv())),[]),v.useEffect(()=>ax(()=>b(hv())),[]),v.useEffect(()=>Lh(()=>{w(fv()),D(pv())}),[]),v.useEffect(()=>z_(()=>L(Ba())),[]),v.useEffect(()=>mu(()=>Y(xo())),[]),v.useEffect(()=>qC(()=>X(Co())),[]),v.useEffect(()=>{if(!$)return;const ee=Tu.find(st=>st.id===$);if(!ee)return;const Pe=st=>{if(st.preventDefault(),st.stopPropagation(),st.key==="Escape"){se(null),F(null);return}const tt=iM(st,ee);if(!tt){F(TM(ee));return}Y(JR($,tt)),se(null),F(null)};return window.addEventListener("keydown",Pe,!0),()=>window.removeEventListener("keydown",Pe,!0)},[$]),v.useEffect(()=>{let ee=!1;return c.listNotificationAssets().then(Pe=>{ee||St(Pe)}).catch(Pe=>{ee||Be(Sl(Pe))}),()=>{ee=!0}},[c]),v.useEffect(()=>{let ee=!1;return c.getPushNotificationStatus(Rr()).then(Pe=>{ee||(Ue(Pe.currentDevice),R(null))}).catch(Pe=>{ee||R(Sl(Pe))}),()=>{ee=!0}},[c]);function Ye(ee){m(mh(Number(ee)))}function lt(ee){X(lw(Number(ee)))}function Nt(ee){re(ee);const Pe=Q.current,st=ke.current[ee];if(!Pe||!st)return;const tt=Math.max(0,_w(st,Pe)-12);typeof Pe.scrollTo=="function"?Pe.scrollTo({top:tt,behavior:"smooth"}):Pe.scrollTop=tt}function yt(){const ee=Q.current;if(!ee)return;if(ee.scrollTop+ee.clientHeight>=ee.scrollHeight-2){re(gh[gh.length-1].id);return}let Pe="appearance";const st=ee.scrollTop+Math.min(180,Math.max(48,ee.clientHeight*.28));for(const tt of gh){const kt=ke.current[tt.id];kt&&_w(kt,ee)<=st&&(Pe=tt.id)}re(Pe)}function Tt(ee){Y(eM(ee)),se(null),F(null)}function $e(){Y(tM()),se(null),F(null)}function St(ee){const Pe=ee.assets.filter(st=>st.enabled).map(st=>st.id);M(ee.assets),ae(Pe),N(Pe),ue(ee.maxFileBytes),Be(null)}async function Lt(){if(Ee){ow(!1),ie(!1);return}let ee=W;ee==="default"&&(ee=await YC(),le(ee)),ee==="granted"&&(ow(!0),ie(!0))}async function ye(){ne(!0),R(null),fe(null);try{if(Ne)await CR(c),Ue(null);else{await yR(c,!1);const ee=await c.getPushNotificationStatus(Rr());Ue(ee.currentDevice)}}catch(ee){R(rg(ee))}finally{ne(!1)}}async function Xe(ee){ne(!0),R(null),fe(null);try{await xR(c,ee);const Pe=await c.getPushNotificationStatus(Rr());Ue(Pe.currentDevice)}catch(Pe){R(rg(Pe))}finally{ne(!1)}}async function rt(){ne(!0),R(null),fe(null);try{await c.testPushNotification({clientId:Rr()}),fe("Test notification accepted by the push service.")}catch(ee){R(rg(ee))}finally{ne(!1)}}async function Ze(ee){const Pe=ee?.[0];if(Pe){if(Pe.size>U){Be(`File must be ${sg(U)} or smaller.`),ct();return}if(Pe.type!=="video/mp4"&&Pe.type!=="video/webm"){Be("Upload an MP4 or WebM video."),ct();return}Oe(!0),Be(null);try{await c.uploadNotificationAsset(Pe),St(await c.listNotificationAssets()),r?.()}catch(st){Be(Sl(st))}finally{Oe(!1),ct()}}}async function Et(ee){Oe(!0),Be(null);try{await c.deleteNotificationAsset(ee),St(await c.listNotificationAssets()),r?.()}catch(Pe){Be(Sl(Pe))}finally{Oe(!1)}}function ct(){ge.current&&(ge.current.value="")}function Tn(ee,Pe){const st=new Set(B);if(Pe?st.add(ee):st.delete(ee),st.size===0){Be("Keep at least one toast video selected.");return}Be(null),ae(Array.from(st))}async function vi(){if(B.length===0){Be("Keep at least one toast video selected.");return}Oe(!0),Be(null);try{const ee=await c.updateNotificationAssetSelection({enabledAssetIds:B});St(ee),r?.()}catch(ee){Be(Sl(ee))}finally{Oe(!1)}}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:f.jsxs("div",{className:"security-panel settings-panel",onClick:ee=>ee.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{children:"Settings"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),f.jsxs("div",{className:"settings-layout",children:[f.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:gh.map(ee=>f.jsxs("button",{type:"button","data-active":xe===ee.id?"true":"false","aria-current":xe===ee.id?"true":void 0,onClick:()=>Nt(ee.id),children:[ee.label,ee.id==="servers"&&n?f.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ee.id))}),f.jsxs("div",{ref:Q,className:"settings-content",onScroll:yt,children:[f.jsxs("section",{id:"settings-appearance",ref:ee=>{ke.current.appearance=ee},className:"security-section settings-section",children:[f.jsx("h3",{children:"Appearance"}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Theme"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),f.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Xh.map(ee=>f.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":I===ee.id,"data-active":I===ee.id?"true":"false",onClick:()=>L(n2(ee.id)),style:{"--settings-theme-bg":ee.tokens.bg,"--settings-theme-bg-2":ee.tokens.bg2,"--settings-theme-sidebar":ee.tokens.bgSidebar,"--settings-theme-line":ee.tokens.line,"--settings-theme-fg":ee.tokens.fg,"--settings-theme-fg-2":ee.tokens.fg2,"--settings-theme-accent":ee.tokens.accent,"--settings-theme-xterm-bg":ee.xterm.background,"--settings-theme-xterm-fg":ee.xterm.foreground,"--settings-theme-xterm-selection":ee.xterm.selectionBackground},children:[f.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[f.jsxs("span",{className:"settings-theme-preview-sidebar",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-main",children:[f.jsxs("span",{className:"settings-theme-preview-tabs",children:[f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-terminal",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})]})]}),f.jsxs("span",{className:"settings-theme-card-copy",children:[f.jsx("strong",{children:ee.label}),f.jsx("small",{children:ee.description})]})]},ee.id))}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font size"}),f.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),f.jsx("input",{type:"range",min:av,max:ov,step:1,value:u,"aria-label":"Terminal font size",onChange:ee=>Ye(ee.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row",children:[f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(mh(u-1)),children:"-"}),f.jsx("input",{type:"number",min:av,max:ov,step:1,value:u,"aria-label":"Terminal font size value",onChange:ee=>Ye(ee.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(mh(u+1)),children:"+"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(mh(bo)),children:"Reset"})]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font family"}),f.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:ee=>p(qR(ee.currentTarget.value)),children:ef.map(ee=>f.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:y,onChange:ee=>b(YR(ee.currentTarget.checked))}),"Show scroll progress"]}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:k,onChange:ee=>w(XR(ee.currentTarget.checked))}),"Shell panes"]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:S,onChange:ee=>D(GR(ee.currentTarget.checked))}),"Codex/Claude panes"]})]}),f.jsxs("section",{id:"settings-shortcuts",ref:ee=>{ke.current.shortcuts=ee},className:"security-section settings-section",children:[f.jsxs("div",{className:"settings-section-heading",children:[f.jsx("h3",{children:"Shortcuts"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:$e,children:"Reset all"})]}),f.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),J?f.jsx("p",{className:"settings-error",children:J}):null,f.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Tu.map(ee=>{const Pe=$===ee.id;return f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"settings-shortcut-label",children:ee.label}),f.jsx("span",{className:"settings-shortcut-group",children:ee.group})]}),f.jsxs("div",{className:"settings-shortcut-actions",children:[f.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Pe?"true":"false",onClick:()=>{se(ee.id),F(null)},children:Pe?"Press keys…":dx(H[ee.id])}),f.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Tt(ee.id),children:"Reset"})]})]},ee.id)})})]}),f.jsxs("section",{id:"settings-notifications",ref:ee=>{ke.current.notifications=ee},className:"security-section settings-section",children:[f.jsx("h3",{children:"Notifications"}),Mf()?f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Ee&&W==="granted",onChange:()=>{Lt()},disabled:W==="denied"}),"System notification when page is hidden"]}),W==="denied"?f.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."}):f.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):f.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),f.jsxs("div",{className:"settings-subsection",children:[f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:!!Ne,onChange:()=>{ye()},disabled:We||!Ie.supported}),"Installed app push notifications"]}),f.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."}),Ie.supported?null:f.jsx("p",{className:"muted",children:Oh(Ie.reason)}),Ne?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"muted",children:["Registered as ",Ne.label,". Last active ",new Date(Ne.lastActiveAt).toLocaleString(),"."]}),f.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{rt()},disabled:We,children:"Send test notification"})]}):null,je?f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Ne?.alwaysNotify===!0,onChange:ee=>{Xe(ee.currentTarget.checked)},disabled:We||!Ne}),"Always notify this mobile device"]}):null,pe?f.jsx("p",{className:"form-error",children:pe}):null,q?f.jsx("p",{className:"muted",role:"status",children:q}):null]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:V.enabled,onChange:ee=>X(dR(ee.currentTarget.checked))}),"Show animated completion toast"]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Toast duration"}),f.jsx("span",{className:"settings-control-value",children:V.persistUntilDismissed?"Until closed":`${V.durationSeconds}s`}),f.jsx("input",{type:"range",min:Jg,max:ev,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ee=>lt(ee.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[f.jsx("input",{type:"number",min:Jg,max:ev,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ee=>lt(ee.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!V.enabled||V.persistUntilDismissed,onClick:()=>X(lw(pu)),children:"Reset"})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:V.persistUntilDismissed,disabled:!V.enabled,onChange:ee=>X(hR(ee.currentTarget.checked))}),"Keep toast until dismissed"]}),f.jsxs("div",{className:"settings-assets-header",children:[f.jsx("span",{children:"Toast videos"}),f.jsxs("span",{children:[sg(U)," max"]})]}),f.jsx("input",{ref:ge,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ee=>{Ze(ee.currentTarget.files)}}),f.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Ce,onClick:()=>ge.current?.click(),children:"Upload video"}),De?f.jsx("p",{className:"settings-error",children:De}):null,O.length>0?f.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(ee=>f.jsxs("li",{"data-enabled":de.has(ee.id)?"true":"false",children:[f.jsxs("label",{className:"settings-asset-choice",children:[f.jsx("input",{type:"checkbox",checked:de.has(ee.id),disabled:Ce,"aria-label":`Use ${ee.filename}`,onChange:Pe=>Tn(ee.id,Pe.currentTarget.checked)}),f.jsx("video",{src:ee.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),f.jsxs("span",{className:"settings-asset-copy",children:[f.jsx("span",{children:ee.filename}),f.jsx("small",{children:ee.source==="built-in"?"Built-in":sg(ee.size)})]})]}),ee.source==="uploaded"?f.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Ce,"aria-label":`Delete ${ee.filename}`,onClick:()=>{Et(ee.id)},children:"x"}):null]},ee.id))}):f.jsx("p",{className:"muted",children:"Built-in videos will be used."}),f.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Ce||O.length===0||!Re,onClick:()=>{vi()},children:"Save selected videos"})]}),f.jsx("div",{id:"settings-security",ref:ee=>{ke.current.security=ee},className:"settings-section-group",children:f.jsx(FR,{api:c})}),f.jsx("div",{id:"settings-servers",ref:ee=>{ke.current.servers=ee},className:"settings-section-group",children:f.jsx(wM,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function _w(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function sg(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 Sl(e){return e instanceof Error?e.message:"Request failed."}function Oh(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function rg(e){const t=Sl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Oh("not_standalone"):t==="insecure"?Oh("insecure"):t==="not_mobile"?Oh("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function TM(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 EM(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const DM="modulepreload",RM=function(e){return"/"+e},bw={},db=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");o=g(n.map(p=>{if(p=RM(p),p in bw)return;bw[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":DM,y||(k.as="script"),k.crossOrigin="",k.href=p,m&&k.setAttribute("nonce",m),document.head.appendChild(k),y)return new Promise((w,S)=>{k.addEventListener("load",w),k.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(u){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=u,window.dispatchEvent(m),!m.defaultPrevented)throw u}return o.then(u=>{for(const m of u||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},MM=v.lazy(()=>db(()=>import("./MarkdownPreview-Bpy611pE.js"),__vite__mapDeps([0,1])));function NM({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[m,g]=v.useState(""),[p,y]=v.useState({}),[b,k]=v.useState(()=>new Set),[w,S]=v.useState(null),[D,I]=v.useState({type:"empty"}),[L,H]=v.useState("idle"),[Y,$]=v.useState(null),se=v.useRef(null),J=v.useRef(null),F=v.useRef(!1),xe=v.useRef(0),re=v.useRef(null);re.current===null&&t&&(re.current=t);const Ee=re.current,ie=r?LM(r):t?yw(t,n):null,V=c?[c.rootPath,m].filter(Boolean).join("/"):"",X=w?.path??null;v.useEffect(()=>(F.current=!0,()=>{F.current=!1,xe.current+=1,ne()}),[]),v.useEffect(()=>{re.current=t,J.current=null,W(ie)},[e]),v.useEffect(()=>{r&&ie!==J.current&&le(r,ie)},[r,ie]),v.useEffect(()=>{if(r||!Ee||t!==Ee)return;const Q=yw(Ee,n);Q!==J.current&&O(Ee,Q)},[Ee,t,n,r]);async function W(Q=ie){if(r){await le(r,Q);return}await O(t,Q)}async function le(Q,ke=ie){const de=pe();if(J.current=ke,ne(),u(null),g(""),y({}),k(new Set),S(null),I({type:"empty"}),$(null),!Q){H("idle");return}H("loading");try{const Re=await e.createFileRoot({path:Q});if(!R(de))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Ie=await e.listFiles({rootToken:Re.rootToken,path:""});if(!R(de))return;ae(Ie),H("idle")}catch(Re){R(de)&&($(xr(Re)),H("idle"))}}async function O(Q,ke=ie){const de=pe();if(J.current=ke,ne(),u(null),g(""),y({}),k(new Set),S(null),I({type:"empty"}),$(null),!Q){H("idle");return}H("loading");try{const Re=await e.createFileRoot({terminalId:Q});if(!R(de))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Ie=await e.listFiles({rootToken:Re.rootToken,path:""});if(!R(de))return;ae(Ie),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(xr(Re)),H("idle"))}}async function M(Q=m,ke=c){if(!ke)return;const de=pe();H("loading"),$(null);try{const Re=await e.listFiles({rootToken:ke.rootToken,path:Q});if(!R(de))return;ae(Re),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(xr(Re)),H("idle"))}}async function B(){if(r){await le(r,ie);return}re.current=t,await O(t,ie)}function ae(Q){y(ke=>({...ke,[Q.path]:OM(Q.entries)}))}async function we(Q){if(!(!ag(Q)||!c)){if(S(Q),$(null),Q.kind==="directory"){g(Q.path),We(),await U(Q);return}if(g(po(Q.path)),Q.editable){await Ce(Q);return}Q.previewKind!=="none"&&await De(Q,Q.previewKind)}}async function N(Q){if(!(!ag(Q)||!c)){if(S(Q),$(null),Q.kind==="directory"){g(Q.path),We(),await U(Q);return}if(g(po(Q.path)),Q.editable){await Oe(Q);return}Q.previewKind!=="none"&&await De(Q,Q.previewKind)}}async function U(Q){if(b.has(Q.path)){k(ke=>{const de=new Set(ke);return de.delete(Q.path),de});return}k(ke=>new Set(ke).add(Q.path)),await M(Q.path)}function ue(Q,ke){Q.key==="Enter"&&(Q.preventDefault(),N(ke))}async function Ce(Q){if(!c)return;const ke=pe();H("loading"),ne();try{const de=await e.readFile({rootToken:c.rootToken,path:Q.path});if(!R(ke))return;I({type:"text-preview",file:Q,read:de}),H("idle")}catch(de){if(await q(de,ke))return;R(ke)&&($(xr(de)),H("idle"))}}async function Oe(Q){if(!c)return;const ke=pe();H("loading");try{await o({rootToken:c.rootToken,path:Q.path,...t?{terminalId:t}:{}}),R(ke)&&H("idle")}catch(de){if(await q(de,ke))return;R(ke)&&($(xr(de)),H("idle"))}}async function De(Q,ke){if(!c)return;const de=pe();H("loading"),ne();try{const Re=await e.previewFile({rootToken:c.rootToken,path:Q.path});if(!R(de))return;const Ie=URL.createObjectURL(Re);if(!R(de)){URL.revokeObjectURL(Ie);return}se.current=Ie,I({type:"preview",file:Q,previewKind:ke,url:Ie}),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(xr(Re)),H("idle"))}}async function Be(Q){if(!c)return;const ke=Q==="file"?"New file":"New folder",de=window.prompt(ke,""),Re=w?w.kind==="directory"?w.path:po(w.path):m,Ie=Sw(de,Re);if(Ie){$(null);try{const je=await e.createFileEntry({rootToken:c.rootToken,path:Ie,kind:Q});S(je.entry),await M(Re)}catch(je){if(await q(je))return;$(xr(je))}}}async function Ne(){if(!c||!w)return;const Q=window.prompt("Move selected entry",w.path),ke=Sw(Q,"");if(!ke||ke===w.path)return;const de=po(w.path),Re=po(ke);$(null);try{const Ie=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:ke});S(Ie.entry),g(Ie.entry.kind==="directory"?Ie.entry.path:po(Ie.entry.path)),We(),await M(de),Re!==de&&await M(Re)}catch(Ie){if(await q(Ie))return;$(xr(Ie))}}async function Ue(){if(!c||!w)return;const Q=w.path,ke=po(Q);$(null);try{const de=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Re=de.descendantCount>0?` and ${de.descendantCount} nested item${de.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${de.path}${Re}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:de.previewToken}),S(null),g(ke),k(Ie=>{const je=new Set(Ie);for(const Ye of Ie)(Ye===Q||Ye.startsWith(`${Q}/`))&&je.delete(Ye);return je}),We(),await M(ke)}catch(de){if(await q(de))return;$(xr(de))}}function We(){xe.current+=1,ne(),I({type:"empty"})}function ne(){se.current&&(URL.revokeObjectURL(se.current),se.current=null)}function pe(){return xe.current+=1,xe.current}function R(Q){return F.current&&Q===xe.current}async function q(Q,ke){return BM(Q)?(ke!==void 0&&!R(ke)||await W(ie),!0):!1}function fe(Q,ke){const de=ag(Q),Re=Q.kind==="directory"&&b.has(Q.path),Ie=p[Q.path]??[],je={"--file-tree-depth":ke};return f.jsxs(Ai.Fragment,{children:[f.jsxs("button",{type:"button",className:"file-entry-button","data-kind":Q.kind,"data-expanded":Re,"data-active":X===Q.path,disabled:!de,style:je,"aria-expanded":Q.kind==="directory"?Re:void 0,"aria-label":`${Q.kind==="directory"?"Open folder":"Open file"} ${Q.name}`,title:Q.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{we(Q)},onDoubleClick:()=>{N(Q)},onKeyDown:Ye=>ue(Ye,Q),children:[f.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:Q.kind==="directory"?Re?"▾":"▸":""}),f.jsx("span",{className:"file-entry-name",children:Q.name}),f.jsx("small",{children:AM(Q)})]}),Re?f.jsx("div",{className:"file-tree-children",role:"group",children:Ie.map(Ye=>fe(Ye,ke+1))}):null]},Q.path)}const ge=p[""]??[];return f.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[f.jsxs("header",{className:"file-explorer-header",children:[f.jsx("div",{className:"file-explorer-path",title:V,children:V||"No active pane"}),f.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[f.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{B()},children:"↻"}),f.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Be("file")},children:"+"}),f.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Be("directory")},children:"▣"})]})]}),Y?f.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,f.jsxs("div",{className:"file-explorer-layout",children:[f.jsx("div",{className:"file-tree","aria-label":V?`Files in ${V}`:"Files",children:ge.map(Q=>fe(Q,0))}),f.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[f.jsxs("div",{className:"file-detail-header",children:[f.jsx("strong",{children:w?.name??"detail"}),f.jsxs("div",{className:"file-detail-actions",children:[f.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Ne()},children:"Move"}),f.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ue()},children:"Delete"})]})]}),L==="loading"?f.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&L!=="loading"?f.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?f.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?f.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?f.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?f.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:f.jsx(MM,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?f.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function ag(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function AM(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function yw(e,t){return`${e}\0${t??""}`}function LM(e){return`workspace\0${e}`}function OM(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function po(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Sw(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function xr(e){return e instanceof Error?e.message:"Request failed"}function BM(e){return e instanceof Ln&&e.status===409&&e.message==="terminal_cwd_changed"}const jM=v.lazy(()=>db(()=>import("./MarkdownPreview-Bpy611pE.js"),__vite__mapDeps([0,1])));function ww({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,m]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[k,w]=v.useState(!1),[S,D]=v.useState("edit"),I=v.useRef(t),L=v.useRef(t.read),H=v.useRef(t.read.content),Y=v.useRef(!1),$=v.useRef(!1),se=v.useRef(0),J=u!==o.content&&g!=="saving"&&!k;v.useEffect(()=>($.current=!0,()=>{$.current=!1,se.current+=1}),[]),v.useEffect(()=>{se.current+=1,Y.current=!1,I.current=t,L.current=t.read,H.current=t.read.content,c(t.read),m(t.read.content),p("idle"),b(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{I.current=t},[t]),v.useEffect(()=>{L.current=o},[o]),v.useEffect(()=>{H.current=u},[u]),v.useEffect(()=>{if(u===o.content||k)return;const ie=window.setInterval(()=>{!Y.current&&H.current!==L.current.content&&F()},1e3);return()=>window.clearInterval(ie)},[u===o.content,k,t.id]);async function F(){if(Y.current)return;const ie=H.current,V=L.current;if(ie===V.content)return;const X=I.current,W=se.current;Y.current=!0,p("saving"),b(null),w(!1);try{const le=await e.writeFile({rootToken:X.rootToken,path:X.path,content:ie,expectedVersion:V.version});if(!$.current||W!==se.current)return;const O={...V,content:ie,version:le.version};L.current=O,c(O),p(H.current===ie?"saved":"idle")}catch(le){if(!$.current||W!==se.current)return;if(le instanceof Ln&&le.status===409){w(!0),p("idle");return}b(IM(le)),p("idle")}finally{W===se.current&&(Y.current=!1)}}const xe=g==="saving"?"saving":g==="saved"?"saved":o.language,re=o.language==="markdown",Ee=re&&S==="preview";return f.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[f.jsxs("header",{className:"editor-pane-header",children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("strong",{children:t.title}),f.jsx("span",{className:"terminal-pane-spacer"}),f.jsx("span",{className:"terminal-pane-state",children:xe}),f.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!J,onClick:()=>{F()},children:"Save"}),re?f.jsx("button",{type:"button","aria-label":`${Ee?"Edit":"Preview"} ${t.title}`,onClick:()=>D(ie=>ie==="preview"?"edit":"preview"),children:Ee?"Edit":"Preview"}):null,n?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,k?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Ee?f.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:f.jsx(jM,{content:u})})}):f.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ie=>{const V=ie.target.value;H.current=V,m(V),p("idle"),b(null),w(!1)}})]})}function IM(e){return e instanceof Error?e.message:"Request failed"}var zM=2,PM=1,HM=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),u={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=u.top+u.bottom,g=u.right+u.left,p=r-m,y=o-g-t;return{cols:Math.max(zM,Math.floor(y/e.css.cell.width)),rows:Math.max(PM,Math.floor(p/e.css.cell.height))}}};var bx=Object.defineProperty,UM=Object.getOwnPropertyDescriptor,KM=(e,t)=>{for(var n in t)bx(e,n,{get:t[n],enumerable:!0})},gi=(e,t,n,r)=>{for(var o=r>1?void 0:r?UM(t,n):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,n,o):u(o))||o);return r&&o&&bx(t,n,o),o},ze=(e,t)=>(n,r)=>t(n,r,e),Cw="Terminal input",_v={get:()=>Cw,set:e=>Cw=e},xw="Too much output to announce, navigate to rows manually to read",bv={get:()=>xw,set:e=>xw=e};function WM(e){return e.replace(/\r?\n/g,"\r")}function FM(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function $M(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function qM(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");yx(o,t,n,r)}}function yx(e,t,n,r){e=WM(e),e=FM(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Sx(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function kw(e,t,n,r,o){Sx(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ea(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Lf(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var VM=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=n)return this._interim=u,r;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[r++]=(u-55296)*1024+m-56320+65536:(t[r++]=u,t[r++]=m);continue}u!==65279&&(t[r++]=u)}return r}},YM=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,u,m,g=0,p=0;if(this.interim[0]){let k=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let S=0,D;for(;(D=this.interim[++S]&63)&&S<4;)w<<=6,w|=D;let I=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=I-S;for(;p<L;){if(p>=n)return 0;if(D=e[p++],(D&192)!==128){p--,k=!0;break}else this.interim[S++]=D,w<<=6,w|=D&63}k||(I===2?w<128?p--:t[r++]=w:I===3?w<2048||w>=55296&&w<=57343||w===65279||(t[r++]=w):w<65536||w>1114111||(t[r++]=w)),this.interim.fill(0)}let y=n-4,b=p;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((u=e[b+2])&128)&&!((m=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=u,t[r++]=m,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=u,r;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(u&63)<<6|m&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},wx="",Ra=" ",$u=class Cx{constructor(){this.fg=0,this.bg=0,this.extended=new nf}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 Cx;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}},nf=class xx{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new xx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},us=class kx extends $u{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new nf,this.combinedData=""}static fromCharData(t){let n=new kx;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ea(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Tw="di$target",yv="di$dependencies",og=new Map;function XM(e){return e[yv]||[]}function Qi(e){if(og.has(e))return og.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");GM(t,n,o)};return t._id=e,og.set(e,t),t}function GM(e,t,n){t[Tw]===t?t[yv].push({id:e,index:n}):(t[yv]=[{id:e,index:n}],t[Tw]=t)}var xn=Qi("BufferService"),Tx=Qi("CoreMouseService"),Mo=Qi("CoreService"),ZM=Qi("CharsetService"),hb=Qi("InstantiationService"),Ex=Qi("LogService"),kn=Qi("OptionsService"),Dx=Qi("OscLinkService"),QM=Qi("UnicodeService"),qu=Qi("DecorationService"),Sv=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new us,u=n.getTrimmedLength(),m=-1,g=-1,p=!1;for(let y=0;y<u;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else p=c.extended.urlId!==m;else g!==-1&&(p=!0);if(p||g!==-1&&y===u-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let k={start:{x:g+1,y:e},end:{x:y+(!p&&y===u-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let S=new URL(b);["http:","https:"].includes(S.protocol)||(w=!0)}catch{w=!0}w||r.push({text:b,range:k,activate:(S,D)=>o?o.activate(S,D,k):JM(S,D),hover:(S,D)=>o?.hover?.(S,D,k),leave:(S,D)=>o?.leave?.(S,D,k)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(r)}};Sv=gi([ze(0,xn),ze(1,kn),ze(2,Dx)],Sv);function JM(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
17
|
-
|
|
18
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Of=Qi("CharSizeService"),Br=Qi("CoreBrowserService"),fb=Qi("MouseService"),jr=Qi("RenderService"),eN=Qi("SelectionService"),Rx=Qi("CharacterJoinerService"),Wl=Qi("ThemeService"),Mx=Qi("LinkProviderService"),tN=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ew.isErrorNoTelemetry(e)?new Ew(e.message+`
|
|
19
|
-
|
|
20
|
-
`+e.stack):new Error(e.message+`
|
|
21
|
-
|
|
22
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},iN=new tN;function Bh(e){nN(e)||iN.onUnexpectedError(e)}var wv="Canceled";function nN(e){return e instanceof sN?!0:e instanceof Error&&e.name===wv&&e.message===wv}var sN=class extends Error{constructor(){super(wv),this.name=this.message}};function rN(e){return new Error(`Illegal argument: ${e}`)}var Ew=class Cv extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Cv)return t;let n=new Cv;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},xv=class Nx extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Nx.prototype)}};function Fn(e,t=0){return e[e.length-(1+t)]}var aN;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(aN||={});function oN(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var Ax;(e=>{function t($){return $&&typeof $=="object"&&typeof $[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o($){yield $}e.single=o;function c($){return t($)?$:o($)}e.wrap=c;function u($){return $||n}e.from=u;function*m($){for(let se=$.length-1;se>=0;se--)yield $[se]}e.reverse=m;function g($){return!$||$[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p($){return $[Symbol.iterator]().next().value}e.first=p;function y($,se){let J=0;for(let F of $)if(se(F,J++))return!0;return!1}e.some=y;function b($,se){for(let J of $)if(se(J))return J}e.find=b;function*k($,se){for(let J of $)se(J)&&(yield J)}e.filter=k;function*w($,se){let J=0;for(let F of $)yield se(F,J++)}e.map=w;function*S($,se){let J=0;for(let F of $)yield*se(F,J++)}e.flatMap=S;function*D(...$){for(let se of $)yield*se}e.concat=D;function I($,se,J){let F=J;for(let xe of $)F=se(F,xe);return F}e.reduce=I;function*L($,se,J=$.length){for(se<0&&(se+=$.length),J<0?J+=$.length:J>$.length&&(J=$.length);se<J;se++)yield $[se]}e.slice=L;function H($,se=Number.POSITIVE_INFINITY){let J=[];if(se===0)return[J,$];let F=$[Symbol.iterator]();for(let xe=0;xe<se;xe++){let re=F.next();if(re.done)return[J,e.empty()];J.push(re.value)}return[J,{[Symbol.iterator](){return F}}]}e.consume=H;async function Y($){let se=[];for await(let J of $)se.push(J);return Promise.resolve(se)}e.asyncToArray=Y})(Ax||={});function ko(e){if(Ax.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function lN(...e){return si(()=>ko(e))}function si(e){return{dispose:oN(()=>{e()})}}var Lx=class Ox{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{ko(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?Ox.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)}};Lx.DISABLE_DISPOSED_WARNING=!1;var Na=Lx,gt=class{constructor(){this._store=new Na,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)}};gt.None=Object.freeze({dispose(){}});var jl=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}},Mr=typeof window=="object"?window:globalThis,kv=class Tv{constructor(t){this.element=t,this.next=Tv.Undefined,this.prev=Tv.Undefined}};kv.Undefined=new kv(void 0);var li=kv,Dw=class{constructor(){this._first=li.Undefined,this._last=li.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===li.Undefined}clear(){let e=this._first;for(;e!==li.Undefined;){let t=e.next;e.prev=li.Undefined,e.next=li.Undefined,e=t}this._first=li.Undefined,this._last=li.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new li(e);if(this._first===li.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==li.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==li.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==li.Undefined&&e.next!==li.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===li.Undefined&&e.next===li.Undefined?(this._first=li.Undefined,this._last=li.Undefined):e.next===li.Undefined?(this._last=this._last.prev,this._last.next=li.Undefined):e.prev===li.Undefined&&(this._first=this._first.next,this._first.prev=li.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==li.Undefined;)yield e.element,e=e.next}},cN=globalThis.performance&&typeof globalThis.performance.now=="function",uN=class Bx{static create(t){return new Bx(t)}constructor(t){this._now=cN&&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}},ln;(e=>{e.None=()=>gt.None;function t(V,X){return b(V,()=>{},0,void 0,!0,void 0,X)}e.defer=t;function n(V){return(X,W=null,le)=>{let O=!1,M;return M=V(B=>{if(!O)return M?M.dispose():O=!0,X.call(W,B)},null,le),O&&M.dispose(),M}}e.once=n;function r(V,X,W){return p((le,O=null,M)=>V(B=>le.call(O,X(B)),null,M),W)}e.map=r;function o(V,X,W){return p((le,O=null,M)=>V(B=>{X(B),le.call(O,B)},null,M),W)}e.forEach=o;function c(V,X,W){return p((le,O=null,M)=>V(B=>X(B)&&le.call(O,B),null,M),W)}e.filter=c;function u(V){return V}e.signal=u;function m(...V){return(X,W=null,le)=>{let O=lN(...V.map(M=>M(B=>X.call(W,B))));return y(O,le)}}e.any=m;function g(V,X,W,le){let O=W;return r(V,M=>(O=X(O,M),O),le)}e.reduce=g;function p(V,X){let W,le={onWillAddFirstListener(){W=V(O.fire,O)},onDidRemoveLastListener(){W?.dispose()}},O=new Le(le);return X?.add(O),O.event}function y(V,X){return X instanceof Array?X.push(V):X&&X.add(V),V}function b(V,X,W=100,le=!1,O=!1,M,B){let ae,we,N,U=0,ue,Ce={leakWarningThreshold:M,onWillAddFirstListener(){ae=V(De=>{U++,we=X(we,De),le&&!N&&(Oe.fire(we),we=void 0),ue=()=>{let Be=we;we=void 0,N=void 0,(!le||U>1)&&Oe.fire(Be),U=0},typeof W=="number"?(clearTimeout(N),N=setTimeout(ue,W)):N===void 0&&(N=0,queueMicrotask(ue))})},onWillRemoveListener(){O&&U>0&&ue?.()},onDidRemoveLastListener(){ue=void 0,ae.dispose()}},Oe=new Le(Ce);return B?.add(Oe),Oe.event}e.debounce=b;function k(V,X=0,W){return e.debounce(V,(le,O)=>le?(le.push(O),le):[O],X,void 0,!0,void 0,W)}e.accumulate=k;function w(V,X=(le,O)=>le===O,W){let le=!0,O;return c(V,M=>{let B=le||!X(M,O);return le=!1,O=M,B},W)}e.latch=w;function S(V,X,W){return[e.filter(V,X,W),e.filter(V,le=>!X(le),W)]}e.split=S;function D(V,X=!1,W=[],le){let O=W.slice(),M=V(we=>{O?O.push(we):ae.fire(we)});le&&le.add(M);let B=()=>{O?.forEach(we=>ae.fire(we)),O=null},ae=new Le({onWillAddFirstListener(){M||(M=V(we=>ae.fire(we)),le&&le.add(M))},onDidAddFirstListener(){O&&(X?setTimeout(B):B())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return le&&le.add(ae),ae.event}e.buffer=D;function I(V,X){return(W,le,O)=>{let M=X(new H);return V(function(B){let ae=M.evaluate(B);ae!==L&&W.call(le,ae)},void 0,O)}}e.chain=I;let L=Symbol("HaltChainable");class H{constructor(){this.steps=[]}map(X){return this.steps.push(X),this}forEach(X){return this.steps.push(W=>(X(W),W)),this}filter(X){return this.steps.push(W=>X(W)?W:L),this}reduce(X,W){let le=W;return this.steps.push(O=>(le=X(le,O),le)),this}latch(X=(W,le)=>W===le){let W=!0,le;return this.steps.push(O=>{let M=W||!X(O,le);return W=!1,le=O,M?O:L}),this}evaluate(X){for(let W of this.steps)if(X=W(X),X===L)break;return X}}function Y(V,X,W=le=>le){let le=(...ae)=>B.fire(W(...ae)),O=()=>V.on(X,le),M=()=>V.removeListener(X,le),B=new Le({onWillAddFirstListener:O,onDidRemoveLastListener:M});return B.event}e.fromNodeEventEmitter=Y;function $(V,X,W=le=>le){let le=(...ae)=>B.fire(W(...ae)),O=()=>V.addEventListener(X,le),M=()=>V.removeEventListener(X,le),B=new Le({onWillAddFirstListener:O,onDidRemoveLastListener:M});return B.event}e.fromDOMEventEmitter=$;function se(V){return new Promise(X=>n(V)(X))}e.toPromise=se;function J(V){let X=new Le;return V.then(W=>{X.fire(W)},()=>{X.fire(void 0)}).finally(()=>{X.dispose()}),X.event}e.fromPromise=J;function F(V,X){return V(W=>X.fire(W))}e.forward=F;function xe(V,X,W){return X(W),V(le=>X(le))}e.runAndSubscribe=xe;class re{constructor(X,W){this._observable=X,this._counter=0,this._hasChanged=!1;let le={onWillAddFirstListener:()=>{X.addObserver(this)},onDidRemoveLastListener:()=>{X.removeObserver(this)}};this.emitter=new Le(le),W&&W.add(this.emitter)}beginUpdate(X){this._counter++}handlePossibleChange(X){}handleChange(X,W){this._hasChanged=!0}endUpdate(X){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(V,X){return new re(V,X).emitter.event}e.fromObservable=Ee;function ie(V){return(X,W,le)=>{let O=0,M=!1,B={beginUpdate(){O++},endUpdate(){O--,O===0&&(V.reportChanges(),M&&(M=!1,X.call(W)))},handlePossibleChange(){},handleChange(){M=!0}};V.addObserver(B),V.reportChanges();let ae={dispose(){V.removeObserver(B)}};return le instanceof Na?le.add(ae):Array.isArray(le)&&le.push(ae),ae}}e.fromObservableLight=ie})(ln||={});var Ev=class Dv{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Dv._idPool++}`,Dv.all.add(this)}start(t){this._stopWatch=new uN,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}}};Ev.all=new Set,Ev._idPool=0;var dN=Ev,hN=-1,jx=class Ix{constructor(t,n,r=(Ix._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,u]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(m),console.warn(c);let g=new mN(m,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,n=0;for(let[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};jx._idPool=1;var fN=jx,pN=class zx{constructor(t){this.value=t}static create(){let t=new Error;return new zx(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
-
`).slice(2).join(`
|
|
24
|
-
`))}},mN=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},gN=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},vN=0,lg=class{constructor(e){this.value=e,this.id=vN++}},_N=2,bN,Le=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new fN(e?.onListenerError??Bh,this._options?.leakWarningThreshold??hN):void 0,this._perfMon=this._options?._profName?new dN(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new gN(`${u}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||Bh)(g),gt.None}if(this._disposed)return gt.None;t&&(e=e.bind(t));let r=new lg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=pN.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof lg?(this._deliveryQueue??=new yN,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=si(()=>{o?.(),this._removeListener(r)});return n instanceof Na?n.add(c):Array.isArray(n)&&n.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,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*_N<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Bh;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof lg)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}},yN=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Rv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Le,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Le,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Rv.INSTANCE=new Rv;var pb=Rv;function SN(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}pb.INSTANCE.onDidChangeZoomLevel;function wN(e){return pb.INSTANCE.getZoomFactor(e)}pb.INSTANCE.onDidChangeFullscreen;var Fl=typeof navigator=="object"?navigator.userAgent:"",Mv=Fl.indexOf("Firefox")>=0,CN=Fl.indexOf("AppleWebKit")>=0,mb=Fl.indexOf("Chrome")>=0,xN=!mb&&Fl.indexOf("Safari")>=0;Fl.indexOf("Electron/")>=0;Fl.indexOf("Android")>=0;var cg=!1;if(typeof Mr.matchMedia=="function"){let e=Mr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Mr.matchMedia("(display-mode: fullscreen)");cg=e.matches,SN(Mr,e,({matches:n})=>{cg&&t.matches||(cg=n)})}var xl="en",Nv=!1,Av=!1,jh=!1,Px=!1,vh,Ih=xl,Rw=xl,kN,Tr,yo=globalThis,Vn;typeof yo.vscode<"u"&&typeof yo.vscode.process<"u"?Vn=yo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Vn=process);var TN=typeof Vn?.versions?.electron=="string",EN=TN&&Vn?.type==="renderer";if(typeof Vn=="object"){Nv=Vn.platform==="win32",Av=Vn.platform==="darwin",jh=Vn.platform==="linux",jh&&Vn.env.SNAP&&Vn.env.SNAP_REVISION,Vn.env.CI||Vn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,vh=xl,Ih=xl;let e=Vn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);vh=t.userLocale,Rw=t.osLocale,Ih=t.resolvedLanguage||xl,kN=t.languagePack?.translationsConfigFile}catch{}Px=!0}else typeof navigator=="object"&&!EN?(Tr=navigator.userAgent,Nv=Tr.indexOf("Windows")>=0,Av=Tr.indexOf("Macintosh")>=0,(Tr.indexOf("Macintosh")>=0||Tr.indexOf("iPad")>=0||Tr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,jh=Tr.indexOf("Linux")>=0,Tr?.indexOf("Mobi")>=0,Ih=globalThis._VSCODE_NLS_LANGUAGE||xl,vh=navigator.language.toLowerCase(),Rw=vh):console.error("Unable to resolve platform.");var Hx=Nv,Vs=Av,DN=jh,Mw=Px,Xs=Tr,ya=Ih,RN;(e=>{function t(){return ya}e.value=t;function n(){return ya.length===2?ya==="en":ya.length>=3?ya[0]==="e"&&ya[1]==="n"&&ya[2]==="-":!1}e.isDefaultVariant=n;function r(){return ya==="en"}e.isDefault=r})(RN||={});var MN=typeof yo.postMessage=="function"&&!yo.importScripts;(()=>{if(MN){let e=[];yo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),yo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var NN=!!(Xs&&Xs.indexOf("Chrome")>=0);Xs&&Xs.indexOf("Firefox")>=0;!NN&&Xs&&Xs.indexOf("Safari")>=0;Xs&&Xs.indexOf("Edg/")>=0;Xs&&Xs.indexOf("Android")>=0;var vl=typeof navigator=="object"?navigator:{};Mw||document.queryCommandSupported&&document.queryCommandSupported("copy")||vl&&vl.clipboard&&vl.clipboard.writeText,Mw||vl&&vl.clipboard&&vl.clipboard.readText;var gb=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}},ug=new gb,Nw=new gb,Aw=new gb,AN=new Array(230),Ux;(e=>{function t(m){return ug.keyCodeToStr(m)}e.toString=t;function n(m){return ug.strToKeyCode(m)}e.fromString=n;function r(m){return Nw.keyCodeToStr(m)}e.toUserSettingsUS=r;function o(m){return Aw.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return Nw.strToKeyCode(m)||Aw.strToKeyCode(m)}e.fromUserSettings=c;function u(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ug.keyCodeToStr(m)}e.toElectronAccelerator=u})(Ux||={});var LN=class Kx{constructor(t,n,r,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Kx&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new ON([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},ON=class{constructor(e){if(e.length===0)throw rN("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function BN(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Ux.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Mv)switch(t){case 59:return 85;case 60:if(DN)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Vs)return 57;break}else if(CN&&(Vs&&t===93||!Vs&&t===92))return 57;return AN[t]||0}var jN=Vs?256:2048,IN=512,zN=1024,PN=Vs?2048:256,Lw=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=BN(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|=jN),this.altKey&&(t|=IN),this.shiftKey&&(t|=zN),this.metaKey&&(t|=PN),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new LN(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ow=new WeakMap;function HN(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var UN=class{static getSameOriginWindowChain(e){let t=Ow.get(e);if(!t){t=[],Ow.set(e,t);let n=e,r;do r=HN(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(n+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,r+=m.left}return{top:n,left:r}}},_h=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=UN.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Bw=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(mb){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*u):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?Mv&&!Vs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")xN&&Hx?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*u):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?Mv&&!Vs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Wx=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),KN;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof WN?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ln.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Wx})})(KN||={});var WN=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?Wx:(this._emitter||(this._emitter=new Le),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},vb=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 xv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new xv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},FN=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new xv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=si(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},$N;(e=>{async function t(r){let o,c=await Promise.all(r.map(u=>u.then(m=>m,m=>{o||(o=m)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(u){c(u)}})}e.withAsyncBody=n})($N||={});var jw=class as{static fromArray(t){return new as(n=>{n.emitMany(t)})}static fromPromise(t){return new as(async n=>{n.emitMany(await t)})}static fromPromises(t){return new as(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new as(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Le,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await ln.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new as(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return as.map(this,t)}static filter(t,n){return new as(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return as.filter(this,t)}static coalesce(t){return as.filter(t,n=>!!n)}coalesce(){return as.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return as.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())}};jw.EMPTY=jw.fromArray([]);var{getWindow:qs,getWindowId:qN,onDidRegisterWindow:VN}=(function(){let e=new Map,t={window:Mr,disposables:new Na};e.set(Mr.vscodeWindowId,t);let n=new Le,r=new Le,o=new Le;function c(u,m){return(typeof u=="number"?e.get(u):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return gt.None;let m=new Na,g={window:u,disposables:m.add(new Na)};return e.set(u.vscodeWindowId,g),m.add(si(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),m.add(nt(u,qi.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:c,getWindow(u){let m=u;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:Mr},getDocument(u){return qs(u).document}}})(),YN=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function nt(e,t,n,r){return new YN(e,t,n,r)}var Iw=function(e,t,n,r){return nt(e,t,n,r)},_b,XN=class extends FN{constructor(e){super(),this.defaultTarget=e&&qs(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},zw=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){Bh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let u=e.get(c)??[];for(t.set(c,u),e.set(c,[]),r.set(c,!0);u.length>0;)u.sort(zw.sort),u.shift().execute();r.set(c,!1)};_b=(c,u,m=0)=>{let g=qN(c),p=new zw(u,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function GN(e){let t=e.getBoundingClientRect(),n=qs(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var qi={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"},ZN=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=An(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=An(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=An(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=An(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=An(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=An(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=An(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=An(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=An(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=An(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=An(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=An(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=An(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=An(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 An(e){return typeof e=="number"?`${e}px`:e}function _u(e){return new ZN(e)}var Fx=class{constructor(){this._hooks=new Na,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(si(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=qs(e)}this._hooks.add(nt(c,qi.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(nt(c,qi.POINTER_UP,u=>this.stopMonitoring(!0)))}};function QN(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[c]}}var Fs;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Fs||={});var tu=class mn extends gt{constructor(){super(),this.dispatched=!1,this.targets=new Dw,this.ignoreTargets=new Dw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ln.runAndSubscribe(VN,({window:t,disposables:n})=>{n.add(nt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(nt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(nt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Mr,disposables:this._store}))}static addTarget(t){if(!mn.isTouchDevice())return gt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.targets.push(t);return si(n)}static ignoreTarget(t){if(!mn.isTouchDevice())return gt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.ignoreTargets.push(t);return si(n)}static isTouchDevice(){return"ontouchstart"in Mr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let u=this.newGestureEvent(Fs.Start,c.target);u.pageX=c.pageX,u.pageY=c.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=n.changedTouches.length;c<u;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],p=Date.now()-g.initialTimeStamp;if(p<mn.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(Fs.Tap,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(p>=mn.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(Fs.Contextmenu,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Fn(g.rollingPageX),b=Fn(g.rollingPageY),k=Fn(g.rollingTimestamps)-g.rollingTimestamps[0],w=y-g.rollingPageX[0],S=b-g.rollingPageY[0],D=[...this.targets].filter(I=>g.initialTarget instanceof Node&&I.contains(g.initialTarget));this.inertia(t,D,r,Math.abs(w)/k,w>0?1:-1,y,Math.abs(S)/k,S>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Fs.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Fs.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>mn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Fs.Change||t.type===Fs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,u,m,g,p){this.handle=_b(t,()=>{let y=Date.now(),b=y-r,k=0,w=0,S=!0;o+=mn.SCROLL_FRICTION*b,m+=mn.SCROLL_FRICTION*b,o>0&&(S=!1,k=c*o*b),m>0&&(S=!1,w=g*m*b);let D=this.newGestureEvent(Fs.Change);D.translationX=k,D.translationY=w,n.forEach(I=>I.dispatchEvent(D)),S||this.inertia(t,n,y,o,c,u+k,m,g,p+w)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let u=this.activeTouches[c.identifier],m=this.newGestureEvent(Fs.Change,u.initialTarget);m.translationX=c.pageX-Fn(u.rollingPageX),m.translationY=c.pageY-Fn(u.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(c.pageX),u.rollingPageY.push(c.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};tu.SCROLL_FRICTION=-.005,tu.HOLD_DELAY=700,tu.CLEAR_TAP_COUNT_TIME=400,gi([QN],tu,"isTouchDevice",1);var JN=tu,bb=class extends gt{onclick(e,t){this._register(nt(e,qi.CLICK,n=>t(new _h(qs(e),n))))}onmousedown(e,t){this._register(nt(e,qi.MOUSE_DOWN,n=>t(new _h(qs(e),n))))}onmouseover(e,t){this._register(nt(e,qi.MOUSE_OVER,n=>t(new _h(qs(e),n))))}onmouseleave(e,t){this._register(nt(e,qi.MOUSE_LEAVE,n=>t(new _h(qs(e),n))))}onkeydown(e,t){this._register(nt(e,qi.KEY_DOWN,n=>t(new Lw(n))))}onkeyup(e,t){this._register(nt(e,qi.KEY_UP,n=>t(new Lw(n))))}oninput(e,t){this._register(nt(e,qi.INPUT,t))}onblur(e,t){this._register(nt(e,qi.BLUR,t))}onfocus(e,t){this._register(nt(e,qi.FOCUS,t))}onchange(e,t){this._register(nt(e,qi.CHANGE,t))}ignoreGesture(e){return JN.ignoreTarget(e)}},Pw=11,eA=class extends bb{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=Pw+"px",this.domNode.style.height=Pw+"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 Fx),this._register(Iw(this.bgDomNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Iw(this.domNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new XN),this._pointerdownScheduleRepeatTimer=this._register(new vb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,qs(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},tA=class Lv{constructor(t,n,r,o,c,u,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,u=u|0,m=m|0),this.rawScrollLeft=o,this.rawScrollTop=m,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),c<0&&(c=0),m+c>u&&(m=u-c),m<0&&(m=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=u,this.scrollTop=m}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Lv(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Lv(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:u,scrollHeightChanged:m,scrollTopChanged:g}}},iA=class extends gt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new tA(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new Uw(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Uw.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Hw=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function dg(e,t){let n=t-e;return function(r){return e+n*rA(r)}}function nA(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Uw=class Ov{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let o,c;return t<n?(o=t+.75*r,c=n-.75*r):(o=t-.75*r,c=n+.75*r),nA(dg(t,o),dg(c,n),.33)}return dg(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new Hw(r,o,!1)}return new Hw(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Ov.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new Ov(t,n,o,r)}};function sA(e){return Math.pow(e,3)}function rA(e){return 1-sA(1-e)}var aA=class extends gt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new vb)}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":"")))}},oA=140,$x=class extends bb{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 aA(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Fx),this._shouldRender=!0,this.domNode=_u(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(nt(this.domNode.domNode,qi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new eA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=_u(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(nt(this.slider.domNode,qi.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=GN(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),u=Math.abs(c-n);if(Hx&&u>oA){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let m=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(m))},()=>{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()}},qx=class Bv{constructor(t,n,r,o,c,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Bv(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,c){let u=Math.max(0,r-t),m=Math.max(0,u-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*m/o))),y=(m-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Bv._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},lA=class extends $x{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new qx(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},cA=class extends $x{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new qx(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},uA=500,Kw=50,dA=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},jv=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(mb){let n=qs(t.browserEvent),r=wN(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,c=new dA(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),p=Math.max(Math.min(c,m),1),y=Math.max(o,u),b=Math.max(c,m);y%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};jv.INSTANCE=new jv;var hA=jv,fA=class extends bb{constructor(e,t,n){super(),this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Le),this.onWillScroll=this._onWillScroll.event,this._options=mA(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new cA(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new lA(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=_u(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=_u(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=_u(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new vb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ko(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,Vs&&(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 Bw(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ko(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Bw(n))};this._mouseWheelToDispose.push(nt(this._listenOnDomNode,qi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=hA.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let u=!Vs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=Kw*o,y=m.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=Kw*c,y=m.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),uA)}},pA=class extends fA{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function mA(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,Vs&&(t.className+=" mac"),t}var Iv=class extends gt{constructor(e,t,n,r,o,c,u,m){super(),this._bufferService=n,this._optionsService=u,this._renderService=m,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new iA({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>_b(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new pA(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ln.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(si(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(si(()=>this._styleElement.remove())),this._register(ln.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(`
|
|
25
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Iv=gi([ze(2,xn),ze(3,Br),ze(4,Tx),ze(5,Wl),ze(6,kn),ze(7,jr)],Iv);var zv=class extends gt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(si(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};zv=gi([ze(1,xn),ze(2,Br),ze(3,qu),ze(4,jr)],zv);var gA=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ks={full:0,left:0,center:0,right:0},Sa={full:0,left:0,center:0,right:0},Fc={full:0,left:0,center:0,right:0},sf=class extends gt{constructor(e,t,n,r,o,c,u,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=m,this._colorZoneStore=new gA,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(si(()=>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);Sa.full=this._canvas.width,Sa.left=e,Sa.center=t,Sa.right=e,this._refreshDrawHeightConstants(),Fc.full=1,Fc.left=1,Fc.center=1+Sa.left,Fc.right=1+Sa.left+Sa.center}_refreshDrawHeightConstants(){Ks.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ks.left=t,Ks.center=t,Ks.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ks.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ks.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ks.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ks.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Fc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ks[e.position||"full"]/2),Sa[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ks[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};sf=gi([ze(2,xn),ze(3,qu),ze(4,jr),ze(5,kn),ze(6,Wl),ze(7,Br)],sf);var be;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
26
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(be||={});var zh;(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=""))(zh||={});var Vx;(e=>e.ST=`${be.ESC}\\`)(Vx||={});var Pv=class{constructor(e,t,n,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${be.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Pv=gi([ze(2,xn),ze(3,kn),ze(4,Mo),ze(5,jr)],Pv);var Xi=0,Gi=0,Zi=0,mi=0,Ww={css:"#00000000",rgba:0},Li;(e=>{function t(o,c,u,m){return m!==void 0?`#${mo(o)}${mo(c)}${mo(u)}${mo(m)}`:`#${mo(o)}${mo(c)}${mo(u)}`}e.toCss=t;function n(o,c,u,m=255){return(o<<24|c<<16|u<<8|m)>>>0}e.toRgba=n;function r(o,c,u,m){return{css:e.toCss(o,c,u,m),rgba:e.toRgba(o,c,u,m)}}e.toColor=r})(Li||={});var ei;(e=>{function t(g,p){if(mi=(p.rgba&255)/255,mi===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,k=p.rgba>>8&255,w=g.rgba>>24&255,S=g.rgba>>16&255,D=g.rgba>>8&255;Xi=w+Math.round((y-w)*mi),Gi=S+Math.round((b-S)*mi),Zi=D+Math.round((k-D)*mi);let I=Li.toCss(Xi,Gi,Zi),L=Li.toRgba(Xi,Gi,Zi);return{css:I,rgba:L}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,y){let b=Ph.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return Li.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Xi,Gi,Zi]=Ph.toChannels(p),{css:Li.toCss(Xi,Gi,Zi),rgba:p}}e.opaque=o;function c(g,p){return mi=Math.round(p*255),[Xi,Gi,Zi]=Ph.toChannels(g.rgba),{css:Li.toCss(Xi,Gi,Zi,mi),rgba:Li.toRgba(Xi,Gi,Zi,mi)}}e.opacity=c;function u(g,p){return mi=g.rgba&255,c(g,mi*p/255)}e.multiplyOpacity=u;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(ei||={});var ci;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),Li.toColor(Xi,Gi,Zi);case 5:return Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),mi=parseInt(o.slice(4,5).repeat(2),16),Li.toColor(Xi,Gi,Zi,mi);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Xi=parseInt(c[1]),Gi=parseInt(c[2]),Zi=parseInt(c[3]),mi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Li.toColor(Xi,Gi,Zi,mi);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Xi,Gi,Zi,mi]=t.getImageData(0,0,1,1).data,mi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Li.toRgba(Xi,Gi,Zi,mi),css:o}}e.toColor=r})(ci||={});var Cn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let u=r/255,m=o/255,g=c/255,p=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(Cn||={});var Ph;(e=>{function t(u,m){if(mi=(m&255)/255,mi===1)return m;let g=m>>24&255,p=m>>16&255,y=m>>8&255,b=u>>24&255,k=u>>16&255,w=u>>8&255;return Xi=b+Math.round((g-b)*mi),Gi=k+Math.round((p-k)*mi),Zi=w+Math.round((y-w)*mi),Li.toRgba(Xi,Gi,Zi)}e.blend=t;function n(u,m,g){let p=Cn.relativeLuminance(u>>8),y=Cn.relativeLuminance(m>>8);if(kr(p,y)<g){if(y<p){let w=r(u,m,g),S=kr(p,Cn.relativeLuminance(w>>8));if(S<g){let D=o(u,m,g),I=kr(p,Cn.relativeLuminance(D>>8));return S>I?w:D}return w}let b=o(u,m,g),k=kr(p,Cn.relativeLuminance(b>>8));if(k<g){let w=r(u,m,g),S=kr(p,Cn.relativeLuminance(w>>8));return k>S?b:w}return b}}e.ensureContrastRatio=n;function r(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,k=m>>24&255,w=m>>16&255,S=m>>8&255,D=kr(Cn.relativeLuminance2(k,w,S),Cn.relativeLuminance2(p,y,b));for(;D<g&&(k>0||w>0||S>0);)k-=Math.max(0,Math.ceil(k*.1)),w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),D=kr(Cn.relativeLuminance2(k,w,S),Cn.relativeLuminance2(p,y,b));return(k<<24|w<<16|S<<8|255)>>>0}e.reduceLuminance=r;function o(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,k=m>>24&255,w=m>>16&255,S=m>>8&255,D=kr(Cn.relativeLuminance2(k,w,S),Cn.relativeLuminance2(p,y,b));for(;D<g&&(k<255||w<255||S<255);)k=Math.min(255,k+Math.ceil((255-k)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),D=kr(Cn.relativeLuminance2(k,w,S),Cn.relativeLuminance2(p,y,b));return(k<<24|w<<16|S<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(Ph||={});function mo(e){let t=e.toString(16);return t.length<2?"0"+t:t}function kr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var vA=class extends $u{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new us}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,c=0,u=0,m=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,u,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=p,u=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ra.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,u,c,t,o);for(let y=0;y<p.length;y++)n.push(p[y])}return n}_getJoinedRanges(e,t,n,r,o){let c=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let p=0;p<g.length;p++)rf._mergeRanges(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,u=e[r];if(u){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),p=t.getString(m).length||Ra.length;if(g!==0){if(!o&&u[0]<=c&&(u[0]=m,o=!0),u[1]<=c){if(u[1]=m,u=e[++r],!u)break;u[0]<=c?(u[0]=m,o=!0):o=!1}c+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};rf=gi([ze(0,xn)],rf);function _A(e){return 57508<=e&&e<=57558}function bA(e){return 9472<=e&&e<=9631}function yA(e){return _A(e)||bA(e)}function SA(){return{css:{canvas:bh(),cell:bh()},device:{canvas:bh(),cell:bh(),char:{width:0,height:0,left:0,top:0}}}}function bh(){return{width:0,height:0}}var Hv=class{constructor(e,t,n,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new us,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,u,m,g,p,y){let b=[],k=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,S=e.getNoBgTrimmedLength();n&&S<c+1&&(S=c+1);let D,I=0,L="",H=0,Y=0,$=0,se=0,J=!1,F=0,xe=!1,re=0,Ee=0,ie=[],V=p!==-1&&y!==-1;for(let X=0;X<S;X++){e.loadCell(X,this._workCell);let W=this._workCell.getWidth();if(W===0)continue;let le=!1,O=X>=Ee,M=X,B=this._workCell;if(k.length>0&&X===k[0][0]&&O){let R=k.shift(),q=this._isCellInSelection(R[0],t);for(H=R[0]+1;H<R[1];H++)O&&=q===this._isCellInSelection(H,t);O&&=!n||c<R[0]||c>=R[1],O?(le=!0,B=new vA(this._workCell,e.translateToString(!0,R[0],R[1]),R[1]-R[0]),M=R[1]-1,W=B.getWidth()):Ee=R[1]}let ae=this._isCellInSelection(X,t),we=n&&X===c,N=V&&X>=p&&X<=y,U=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,R=>{U=!0});let ue=B.getChars()||Ra;if(ue===" "&&(B.isUnderline()||B.isOverline())&&(ue=" "),re=W*m-g.get(ue,B.isBold(),B.isItalic()),!D)D=this._document.createElement("span");else if(I&&(ae&&xe||!ae&&!xe&&B.bg===Y)&&(ae&&xe&&w.selectionForeground||B.fg===$)&&B.extended.ext===se&&N===J&&re===F&&!we&&!le&&!U&&O){B.isInvisible()?L+=Ra:L+=ue,I++;continue}else I&&(D.textContent=L),D=this._document.createElement("span"),I=0,L="";if(Y=B.bg,$=B.fg,se=B.extended.ext,J=N,F=re,xe=ae,le&&c>=X&&c<=M&&(c=X),!this._coreService.isCursorHidden&&we&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ie.push("xterm-cursor-blink"),ie.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(B.isBold()&&ie.push("xterm-bold"),B.isItalic()&&ie.push("xterm-italic"),B.isDim()&&ie.push("xterm-dim"),B.isInvisible()?L=Ra:L=B.getChars()||Ra,B.isUnderline()&&(ie.push(`xterm-underline-${B.extended.underlineStyle}`),L===" "&&(L=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${$u.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let R=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&R<8&&(R+=8),D.style.textDecorationColor=w.ansi[R].css}B.isOverline()&&(ie.push("xterm-overline"),L===" "&&(L=" ")),B.isStrikethrough()&&ie.push("xterm-strikethrough"),N&&(D.style.textDecoration="underline");let Ce=B.getFgColor(),Oe=B.getFgColorMode(),De=B.getBgColor(),Be=B.getBgColorMode(),Ne=!!B.isInverse();if(Ne){let R=Ce;Ce=De,De=R;let q=Oe;Oe=Be,Be=q}let Ue,We,ne=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,R=>{R.options.layer!=="top"&&ne||(R.backgroundColorRGB&&(Be=50331648,De=R.backgroundColorRGB.rgba>>8&16777215,Ue=R.backgroundColorRGB),R.foregroundColorRGB&&(Oe=50331648,Ce=R.foregroundColorRGB.rgba>>8&16777215,We=R.foregroundColorRGB),ne=R.options.layer==="top")}),!ne&&ae&&(Ue=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,De=Ue.rgba>>8&16777215,Be=50331648,ne=!0,w.selectionForeground&&(Oe=50331648,Ce=w.selectionForeground.rgba>>8&16777215,We=w.selectionForeground)),ne&&ie.push("xterm-decoration-top");let pe;switch(Be){case 16777216:case 33554432:pe=w.ansi[De],ie.push(`xterm-bg-${De}`);break;case 50331648:pe=Li.toColor(De>>16,De>>8&255,De&255),this._addStyle(D,`background-color:#${Fw((De>>>0).toString(16),"0",6)}`);break;default:Ne?(pe=w.foreground,ie.push("xterm-bg-257")):pe=w.background}switch(Ue||B.isDim()&&(Ue=ei.multiplyOpacity(pe,.5)),Oe){case 16777216:case 33554432:B.isBold()&&Ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ce+=8),this._applyMinimumContrast(D,pe,w.ansi[Ce],B,Ue,void 0)||ie.push(`xterm-fg-${Ce}`);break;case 50331648:let R=Li.toColor(Ce>>16&255,Ce>>8&255,Ce&255);this._applyMinimumContrast(D,pe,R,B,Ue,We)||this._addStyle(D,`color:#${Fw(Ce.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,pe,w.foreground,B,Ue,We)||Ne&&ie.push("xterm-fg-257")}ie.length&&(D.className=ie.join(" "),ie.length=0),!we&&!le&&!U&&O?I++:D.textContent=L,re!==this.defaultSpacing&&(D.style.letterSpacing=`${re}px`),b.push(D),X=M}return D&&I&&(D.textContent=L),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||yA(r.getCode()))return!1;let u=this._getContrastCache(r),m;if(!o&&!c&&(m=u.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);m=ei.ensureContrastRatio(o||t,c||n,g),u.setColor((o||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Hv=gi([ze(1,Rx),ze(2,kn),ze(3,Br),ze(4,Mo),ze(5,qu),ze(6,Wl)],Hv);function Fw(e,t,n){for(;e.length<n;)e=t+e;return e}var wA=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,r,o,c],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),n&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},CA=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,u=n[1]-o,m=Math.max(c,0),g=Math.min(u,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=u,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function xA(){return new CA}var hg="xterm-dom-renderer-owner-",rs="xterm-rows",yh="xterm-fg-",$w="xterm-bg-",$c="xterm-focus",Sh="xterm-selection",kA=1,Uv=class extends gt{constructor(e,t,n,r,o,c,u,m,g,p,y,b,k,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=u,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=k,this._themeService=w,this._terminalClass=kA++,this._rowElements=[],this._selectionRenderModel=xA(),this.onRequestRedraw=this._register(new Le).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(rs),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(Sh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=SA(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(Hv,document),this._element.classList.add(hg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(si(()=>{this._element.classList.remove(hg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new wA(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${rs} 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} .${rs} { 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} .${rs} .xterm-dim { color: ${ei.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${rs}.${$c} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${rs}.${$c} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${rs}.${$c} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Sh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Sh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Sh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${yh}${c} { color: ${u.css}; }${this._terminalSelector} .${yh}${c}.xterm-dim { color: ${ei.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${$w}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${yh}257 { color: ${ei.opaque(e.background).css}; }${this._terminalSelector} .${yh}257.xterm-dim { color: ${ei.multiplyOpacity(ei.opaque(e.background),.5).css}; }${this._terminalSelector} .${$w}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove($c),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add($c),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],u-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,p));let y=u-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==u){let b=o===u?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,u,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${hg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,c){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),o=Math.min(o,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,p=Math.min(m.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,k=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=r;++w){let S=w+m.ydisp,D=this._rowElements[w],I=m.lines.get(S);if(!D||!I)break;D.replaceChildren(...this._rowFactory.createRow(I,S,S===g,b,k,p,y,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===r?t:o)-1:-1))}}};Uv=gi([ze(7,hb),ze(8,Of),ze(9,kn),ze(10,xn),ze(11,Mo),ze(12,Br),ze(13,Wl)],Uv);var Kv=class extends gt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Le),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new EA(this._optionsService))}catch{this._measureStrategy=this._register(new TA(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())}};Kv=gi([ze(2,kn)],Kv);var Yx=class extends gt{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)}},TA=class extends Yx{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},EA=class extends Yx{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}},DA=class extends gt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new RA(this._window)),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Le),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(ln.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(nt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(nt(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}},RA=class extends gt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new jl),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(si(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=nt(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)}},MA=class extends gt{constructor(){super(),this.linkProviders=[],this._register(si(()=>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 yb(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function NA(e,t,n,r,o,c,u,m,g){if(!c)return;let p=yb(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),p[1]=Math.ceil(p[1]/m),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var Wv=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return NA(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=yb(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Wv=gi([ze(0,jr),ze(1,Of)],Wv);var AA=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Xx={};KM(Xx,{getSafariVersion:()=>OA,isChromeOS:()=>Jx,isFirefox:()=>Gx,isIpad:()=>BA,isIphone:()=>jA,isLegacyEdge:()=>LA,isLinux:()=>Sb,isMac:()=>af,isNode:()=>Bf,isSafari:()=>Zx,isWindows:()=>Qx});var Bf=typeof process<"u"&&"title"in process,Vu=Bf?"node":navigator.userAgent,Yu=Bf?"node":navigator.platform,Gx=Vu.includes("Firefox"),LA=Vu.includes("Edge"),Zx=/^((?!chrome|android).)*safari/i.test(Vu);function OA(){if(!Zx)return 0;let e=Vu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var af=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Yu),BA=Yu==="iPad",jA=Yu==="iPhone",Qx=["Windows","Win16","Win32","WinCE"].includes(Yu),Sb=Yu.indexOf("Linux")>=0,Jx=/\bCrOS\b/.test(Vu),ek=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},IA=class extends ek{_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())}}},zA=class extends ek{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},of=!Bf&&"requestIdleCallback"in window?zA:IA,PA=class{constructor(){this._queue=new of}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Fv=class extends gt{constructor(e,t,n,r,o,c,u,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new jl),this._pausedResizeTask=new PA,this._observerDisposable=this._register(new jl),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 Le),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Le),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Le),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new AA((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new HA(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(si(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=si(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Fv=gi([ze(2,kn),ze(3,Of),ze(4,Mo),ze(5,qu),ze(6,xn),ze(7,Br),ze(8,Wl)],Fv);var HA=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function UA(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return FA(o,c,e,t,n,r)+jf(c,t,n,r)+$A(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",Du(Math.abs(o-e),Eu(u,r));u=c>t?"D":"C";let m=Math.abs(c-t),g=WA(c>t?e:o,n)+(m-1)*n.cols+1+KA(c>t?o:e);return Du(g,Eu(u,r))}function KA(e,t){return e-1}function WA(e,t){return t.cols-e}function FA(e,t,n,r,o,c){return jf(t,r,o,c).length===0?"":Du(ik(e,t,e,t-To(t,o),!1,o).length,Eu("D",c))}function jf(e,t,n,r){let o=e-To(e,n),c=t-To(t,n),u=Math.abs(o-c)-qA(e,t,n);return Du(u,Eu(tk(e,t),r))}function $A(e,t,n,r,o,c){let u;jf(t,r,o,c).length>0?u=r-To(r,o):u=t;let m=r,g=VA(e,t,n,r,o,c);return Du(ik(e,u,n,m,g==="C",o).length,Eu(g,c))}function qA(e,t,n){let r=0,o=e-To(e,n),c=t-To(t,n);for(let u=0;u<Math.abs(o-c);u++){let m=tk(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*u)?.isWrapped&&r++}return r}function To(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function VA(e,t,n,r,o,c){let u;return jf(n,r,o,c).length>0?u=r-To(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function tk(e,t){return e>t?"A":"B"}function ik(e,t,n,r,o,c){let u=e,m=t,g="";for(;(u!==n||m!==r)&&m>=0&&m<c.buffer.lines.length;)u+=o?1:-1,o&&u>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,u),u=0,e=0,m++):!o&&u<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),u=c.cols-1,e=u,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,u)}function Eu(e,t){let n=t?"O":"[";return be.ESC+n+e}function Du(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var YA=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 qw(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 fg=50,XA=15,GA=50,ZA=500,QA=" ",JA=new RegExp(QA,"g"),$v=class extends gt{constructor(e,t,n,r,o,c,u,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=u,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new us,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Le),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Le),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new YA(this._bufferService),this._activeSelectionMode=0,this._register(si(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let m=n.translateBufferLineToString(u,!0,o,c);r.push(m)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let u=n.lines.get(c),m=n.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=m:r.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(JA," ")).join(Qx?`\r
|
|
27
|
-
`:`
|
|
28
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Sb&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=qw(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=yb(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-fg),fg),t/=fg,t/Math.abs(t)+Math.round(t*(XA-1)))}shouldForceSelection(e){return af?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(),GA)}_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&&!(af&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<ZA&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=UA(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let u=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,p=e[0]-m,y=0,b=0,k=0,w=0;if(u.charAt(m)===" "){for(;m>0&&u.charAt(m-1)===" ";)m--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let I=e[0],L=e[0];c.getWidth(I)===0&&(y++,I--),c.getWidth(L)===2&&(b++,L++);let H=c.getString(L).length;for(H>1&&(w+=H-1,g+=H-1);I>0&&m>0&&!this._isCharWordSeparator(c.loadCell(I-1,this._workCell));){c.loadCell(I-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,I--):Y>1&&(k+=Y-1,m-=Y-1),m--,I--}for(;L<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,L++):Y>1&&(w+=Y-1,g+=Y-1),g++,L++}}g++;let S=m+p-y+k,D=Math.min(this._bufferService.cols,g-m+y+b-k-w);if(!(!t&&u.slice(m,g).trim()==="")){if(n&&S===0&&c.getCodePoint(0)!==32){let I=o.lines.get(e[1]-1);if(I&&c.isWrapped&&I.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let H=this._bufferService.cols-L.start;S-=H,D+=H}}}if(r&&S+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let I=o.lines.get(e[1]+1);if(I?.isWrapped&&I.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(D+=L.length)}}return{start:S,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=qw(n,this._bufferService.cols)}};$v=gi([ze(3,xn),ze(4,Mo),ze(5,fb),ze(6,kn),ze(7,jr),ze(8,Br)],$v);var Vw=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Yw=class{constructor(){this._color=new Vw,this._css=new Vw}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ji=Object.freeze((()=>{let e=[ci.toColor("#2e3436"),ci.toColor("#cc0000"),ci.toColor("#4e9a06"),ci.toColor("#c4a000"),ci.toColor("#3465a4"),ci.toColor("#75507b"),ci.toColor("#06989a"),ci.toColor("#d3d7cf"),ci.toColor("#555753"),ci.toColor("#ef2929"),ci.toColor("#8ae234"),ci.toColor("#fce94f"),ci.toColor("#729fcf"),ci.toColor("#ad7fa8"),ci.toColor("#34e2e2"),ci.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:Li.toCss(r,o,c),rgba:Li.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Li.toCss(r,r,r),rgba:Li.toRgba(r,r,r)})}return e})()),go=ci.toColor("#ffffff"),iu=ci.toColor("#000000"),Xw=ci.toColor("#ffffff"),Gw=iu,qc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},eL=go,qv=class extends gt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Yw,this._halfContrastCache=new Yw,this._onChangeColors=this._register(new Le),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:go,background:iu,cursor:Xw,cursorAccent:Gw,selectionForeground:void 0,selectionBackgroundTransparent:qc,selectionBackgroundOpaque:ei.blend(iu,qc),selectionInactiveBackgroundTransparent:qc,selectionInactiveBackgroundOpaque:ei.blend(iu,qc),scrollbarSliderBackground:ei.opacity(go,.2),scrollbarSliderHoverBackground:ei.opacity(go,.4),scrollbarSliderActiveBackground:ei.opacity(go,.5),overviewRulerBorder:go,ansi:ji.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=Ut(e.foreground,go),t.background=Ut(e.background,iu),t.cursor=ei.blend(t.background,Ut(e.cursor,Xw)),t.cursorAccent=ei.blend(t.background,Ut(e.cursorAccent,Gw)),t.selectionBackgroundTransparent=Ut(e.selectionBackground,qc),t.selectionBackgroundOpaque=ei.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ut(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ei.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ut(e.selectionForeground,Ww):void 0,t.selectionForeground===Ww&&(t.selectionForeground=void 0),ei.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ei.opacity(t.selectionBackgroundTransparent,.3)),ei.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ei.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ut(e.scrollbarSliderBackground,ei.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ut(e.scrollbarSliderHoverBackground,ei.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ut(e.scrollbarSliderActiveBackground,ei.opacity(t.foreground,.5)),t.overviewRulerBorder=Ut(e.overviewRulerBorder,eL),t.ansi=ji.slice(),t.ansi[0]=Ut(e.black,ji[0]),t.ansi[1]=Ut(e.red,ji[1]),t.ansi[2]=Ut(e.green,ji[2]),t.ansi[3]=Ut(e.yellow,ji[3]),t.ansi[4]=Ut(e.blue,ji[4]),t.ansi[5]=Ut(e.magenta,ji[5]),t.ansi[6]=Ut(e.cyan,ji[6]),t.ansi[7]=Ut(e.white,ji[7]),t.ansi[8]=Ut(e.brightBlack,ji[8]),t.ansi[9]=Ut(e.brightRed,ji[9]),t.ansi[10]=Ut(e.brightGreen,ji[10]),t.ansi[11]=Ut(e.brightYellow,ji[11]),t.ansi[12]=Ut(e.brightBlue,ji[12]),t.ansi[13]=Ut(e.brightMagenta,ji[13]),t.ansi[14]=Ut(e.brightCyan,ji[14]),t.ansi[15]=Ut(e.brightWhite,ji[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Ut(e.extendedAnsi[r],ji[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};qv=gi([ze(0,kn)],qv);function Ut(e,t){if(e!==void 0)try{return ci.toColor(e)}catch{}return t}var tL=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},iL=class{constructor(){this._services=new tL,this._services.set(hb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=XM(e).sort((c,u)=>c.index-u.index),r=[];for(let c of n){let u=this._services.get(c.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},nL={trace:0,debug:1,info:2,warn:3,error:4,off:5},sL="xterm.js: ",Vv=class extends gt{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=nL[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":sL)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Vv=gi([ze(0,kn)],Vv);var Zw=class extends gt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Le),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Le),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Le),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},mt=3,Ni=Object.freeze(new $u),wh=0,pg=2,nu=class nk{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*mt);let o=n||us.fromCharData([0,wx,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*mt+0],r=n&2097151;return[this._data[t*mt+1],n&2097152?this._combined[t]:r?Ea(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*mt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*mt+0]=t|2097152|n[2]<<22):this._data[t*mt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*mt+0]>>22}hasWidth(t){return this._data[t*mt+0]&12582912}getFg(t){return this._data[t*mt+1]}getBg(t){return this._data[t*mt+2]}hasContent(t){return this._data[t*mt+0]&4194303}getCodePoint(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*mt+0]&2097152}getString(t){let n=this._data[t*mt+0];return n&2097152?this._combined[t]:n&2097151?Ea(n&2097151):""}isProtected(t){return this._data[t*mt+2]&536870912}loadCell(t,n){return wh=t*mt,n.content=this._data[wh+0],n.fg=this._data[wh+1],n.bg=this._data[wh+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*mt+0]=n.content,this._data[t*mt+1]=n.fg,this._data[t*mt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*mt+0]=n|r<<22,this._data[t*mt+1]=o.fg,this._data[t*mt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*mt+0];o&2097152?this._combined[t]+=Ea(n):o&2097151?(this._combined[t]=Ea(o&2097151)+Ea(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*mt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new us;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,o));for(let c=0;c<n;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new us;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,o));for(let c=this.length-n;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*pg<this._data.buffer.byteLength;let r=t*mt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let m=parseInt(o[u],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let u=0;u<c.length;u++){let m=parseInt(c[u],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,r*4*pg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*pg<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new nk(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*mt+0]&4194303)return t+(this._data[t*mt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*mt+0]&4194303||this._data[t*mt+2]&50331648)return t+(this._data[t*mt+0]>>22);return 0}copyCellsFrom(t,n,r,o,c){let u=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<mt;p++)this._data[(r+g)*mt+p]=u[(n+g)*mt+p];u[(n+g)*mt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<mt;p++)this._data[(r+g)*mt+p]=u[(n+g)*mt+p];u[(n+g)*mt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let p=parseInt(m[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<r;){let u=this._data[n*mt+0],m=u&2097151,g=u&2097152?this._combined[n]:m?Ea(m):Ra;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function rL(e,t,n,r,o,c){let u=[];for(let m=0;m<e.length-1;m++){let g=m,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=m&&r<g){m+=y.length-1;continue}let b=0,k=Ru(y,b,t),w=1,S=0;for(;w<y.length;){let I=Ru(y,w,t),L=I-S,H=n-k,Y=Math.min(L,H);y[b].copyCellsFrom(y[w],S,k,Y,!1),k+=Y,k===n&&(b++,k=0),S+=Y,S===I&&(w++,S=0),k===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,k++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(k,n,o);let D=0;for(let I=y.length-1;I>0&&(I>b||y[I].getTrimmedLength()===0);I--)D++;D>0&&(u.push(m+y.length-D),u.push(D)),m+=y.length-1}return u}function aL(e,t){let n=[],r=0,o=t[r],c=0;for(let u=0;u<e.length;u++)if(o===u){let m=t[++r];e.onDeleteEmitter.fire({index:u-c,amount:m}),u+=m-1,c+=m,o=t[++r]}else n.push(u);return{layout:n,countRemoved:c}}function oL(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function lL(e,t,n){let r=[],o=e.map((g,p)=>Ru(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,m=0;for(;m<o;){if(o-m<n){r.push(o-m);break}c+=n;let g=Ru(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let y=p?n-1:n;r.push(y),m+=y}return r}function Ru(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var sk=class rk{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=rk._nextId++,this._onDispose=this.register(new Le),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ko(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};sk._nextId=1;var cL=sk,Hi={},vo=Hi.B;Hi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Hi.A={"#":"£"};Hi.B=void 0;Hi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Hi.C=Hi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Hi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Hi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Hi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Hi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Hi.E=Hi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Hi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Hi.H=Hi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Hi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Qw=4294967295,Jw=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ni.clone(),this.savedCharset=vo,this.markers=[],this._nullCell=us.fromCharData([0,wx,1,0]),this._whitespaceCell=us.fromCharData([0,Ra,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new of,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Zw(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 nf),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 nf),this._whitespaceCell}getBlankLine(e,t){return new nu(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>Qw?Qw:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ni);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Zw(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ni),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let c=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new nu(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new nu(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=rL(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ni),n);if(r.length>0){let o=aL(this.lines,r);oL(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ni),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new nu(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Ni),o=[],c=0;for(let u=this.lines.length-1;u>=0;u--){let m=this.lines.get(u);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&u>0;)m=this.lines.get(--u),g.unshift(m);if(!n){let Y=this.ybase+this.y;if(Y>=u&&Y<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=lL(g,this._cols,e),b=y.length-g.length,k;this.ybase===0&&this.y!==this.lines.length-1?k=Math.max(0,this.y-this.lines.maxLength+b):k=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let Y=0;Y<b;Y++){let $=this.getBlankLine(Ni,!0);w.push($)}w.length>0&&(o.push({start:u+g.length+c,newLines:w}),c+=w.length),g.push(...w);let S=y.length-1,D=y[S];D===0&&(S--,D=y[S]);let I=g.length-b-1,L=p;for(;I>=0;){let Y=Math.min(L,D);if(g[S]===void 0)break;if(g[S].copyCellsFrom(g[I],L-Y,D-Y,Y,!0),D-=Y,D===0&&(S--,D=y[S]),L-=Y,L===0){I--;let $=Math.max(I,0);L=Ru(g,$,this._cols)}}for(let Y=0;Y<g.length;Y++)y[Y]<e&&g[Y].setCell(y[Y],r);let H=b-k;for(;H-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let k=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>p+k){for(let I=b.newLines.length-1;I>=0;I--)this.lines.set(D--,b.newLines[I]);D++,u.push({index:p+1,amount:b.newLines.length}),k+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[p--]);let w=0;for(let D=u.length-1;D>=0;D--)u[D].index+=w,this.lines.onInsertEmitter.fire(u[D]),w+=u[D].amount;let S=Math.max(0,g+c-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new cL(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},uL=class extends gt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Le),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 Jw(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Jw(!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)}},ak=2,ok=1,Yv=class extends gt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ak),this.rows=Math.max(e.rawOptions.rows||0,ok),this.buffers=this._register(new uL(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;c===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=c-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(c,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Yv=gi([ze(0,kn)],Yv);var _l={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:af,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},dL=["normal","bold","100","200","300","400","500","600","700","800","900"],hL=class extends gt{constructor(e){super(),this._onOptionChange=this._register(new Le),this.onOptionChange=this._onOptionChange.event;let t={..._l};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(si(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in _l))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in _l))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=_l[e]),!fL(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=_l[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=dL.includes(t)?t:_l[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 fL(e){return e==="block"||e==="underline"||e==="bar"}function su(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&su(e[r],t-1);return n}var e1=Object.freeze({insertMode:!1}),t1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Xv=class extends gt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Le),this.onData=this._onData.event,this._onUserInput=this._register(new Le),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Le),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=su(e1),this.decPrivateModes=su(t1)}reset(){this.modes=su(e1),this.decPrivateModes=su(t1)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Xv=gi([ze(0,xn),ze(1,Ex),ze(2,kn)],Xv);var i1={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 mg(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var gg=String.fromCharCode,n1={DEFAULT:e=>{let t=[mg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${gg(t[0])}${gg(t[1])}${gg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${mg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${mg(e,!0)};${e.x};${e.y}${t}`}},Gv=class extends gt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Le),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(i1))this.addProtocol(r,i1[r]);for(let r of Object.keys(n1))this.addEncoding(r,n1[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Gv=gi([ze(0,xn),ze(1,Mo),ze(2,kn)],Gv);var vg=[[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]],pL=[[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]],Ii;function mL(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var gL=class{constructor(){if(this.version="6",!Ii){Ii=new Uint8Array(65536),Ii.fill(1),Ii[0]=0,Ii.fill(0,1,32),Ii.fill(0,127,160),Ii.fill(2,4352,4448),Ii[9001]=2,Ii[9002]=2,Ii.fill(2,11904,42192),Ii[12351]=1,Ii.fill(2,44032,55204),Ii.fill(2,63744,64256),Ii.fill(2,65040,65050),Ii.fill(2,65072,65136),Ii.fill(2,65280,65377),Ii.fill(2,65504,65511);for(let e=0;e<vg.length;++e)Ii.fill(0,vg[e][0],vg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ii[e]:mL(e,pL)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=_o.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return _o.createPropertyValue(0,n,r)}},_o=class Hh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Le,this.onChange=this._onChange.event;let t=new gL;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let c=0;c<o;++c){let u=t.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=o)return n+this.wcwidth(u);let p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let m=this.charProperties(u,r),g=Hh.extractWidth(m);Hh.extractShouldJoin(m)&&(g-=Hh.extractWidth(r)),n+=g,r=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},vL=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 s1(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Vc=2147483647,_L=256,lk=class Zv{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>_L)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Zv;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)n.addSubParam(o[c]);else n.addParam(o)}return n}clone(){let t=new Zv(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Vc?Vc: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>Vc?Vc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Vc):t}},Yc=[],bL=class{constructor(){this._state=0,this._active=Yc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Yc}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=Yc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Yc,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Lf(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Yc,this._id=-1,this._state=0}}},$n=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Lf(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Xc=[],yL=class{constructor(){this._handlers=Object.create(null),this._active=Xc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Xc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xc,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Lf(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Xc,this._ident=0}},ru=new lk;ru.addParam(0);var r1=class{constructor(e){this._handler=e,this._data="",this._params=ru,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ru,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Lf(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=ru,this._data="",this._hitLimit=!1,n));return this._params=ru,this._data="",this._hitLimit=!1,t}},SL=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},ls=160,wL=(function(){let e=new SL(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in c)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ls,0,2,0),e.add(ls,8,5,8),e.add(ls,6,0,6),e.add(ls,11,0,11),e.add(ls,13,13,13),e})(),CL=class extends gt{constructor(e=wL){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 lk,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(si(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new bL),this._dcsParser=this._register(new yL),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(r=e[m],o=this._transitions.table[this.currentState<<8|(r<160?r:ls)],o>>4){case 2:for(let k=m+1;;++k){if(k>=t||(r=e[k])<32||r>126&&r<ls){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(r=e[k])<32||r>126&&r<ls){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(r=e[k])<32||r>126&&r<ls){this._printHandler(e,m,k),m=k-1;break}if(++k>=t||(r=e[k])<32||r>126&&r<ls){this._printHandler(e,m,k),m=k-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:m,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,m),u;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++m<t&&(r=e[m])>47&&r<60);m--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(u=y[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,y,b,o,m),u;b<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let k=m+1;;++k)if(k>=t||(r=e[k])===24||r===26||r===27||r>127&&r<ls){this._dcsParser.put(e,m,k),m=k-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let k=m+1;;k++)if(k>=t||(r=e[k])<32||r>127&&r<ls){this._oscParser.put(e,m,k),m=k-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},xL=/^([\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})$/,kL=/^[\da-f]+$/;function a1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=xL.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),kL.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return r}}function _g(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function TL(e,t=16){let[n,r,o]=e;return`rgb:${_g(n,t)}/${_g(r,t)}/${_g(o,t)}`}var EL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},wa=131072,o1=10;function l1(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 c1=5e3,u1=0,DL=class extends gt{constructor(e,t,n,r,o,c,u,m,g=new CL){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=u,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new VM,this._utf8Decoder=new YM,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ni.clone(),this._eraseAttrDataInternal=Ni.clone(),this._onRequestBell=this._register(new Le),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Le),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Le),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Le),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Le),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Le),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Le),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Le),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Le),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 Qv(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,b)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(be.BEL,()=>this.bell()),this._parser.setExecuteHandler(be.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(be.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(be.BS,()=>this.backspace()),this._parser.setExecuteHandler(be.HT,()=>this.tab()),this._parser.setExecuteHandler(be.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(be.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(zh.IND,()=>this.index()),this._parser.setExecuteHandler(zh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(zh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new $n(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new $n(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new $n(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new $n(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new $n(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new $n(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new $n(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new $n(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new $n(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new $n(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new $n(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new $n(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Hi)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new r1((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),c1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${c1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>wa&&(c=this._parseStack.position+wa)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<wa&&(this._parseBuffer=new Uint32Array(Math.min(e.length,wa))),u||this._dirtyRowTracker.clearRange(),e.length>wa)for(let p=c;p<e.length;p+=wa){let y=p+wa<e.length?p+wa:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(n),n}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let m=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(m,this._bufferService.rows-1)})}print(e,t,n){let r,o,c=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let k=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(r=e[w],r<127&&c){let L=c[String.fromCharCode(r)];L&&(r=L.charCodeAt(0))}let S=this._unicodeService.charProperties(r,k);o=_o.extractWidth(S);let D=_o.extractShouldJoin(S),I=D?_o.extractWidth(k):0;if(k=S,u&&this._onA11yChar.fire(Ea(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-I>m){if(g){let L=b,H=this._activeBuffer.x-I;for(this._activeBuffer.x=I,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),I>0&&b instanceof nu&&b.copyCellsFrom(L,H,0,I,!1);H<m;)L.setCellFromCodepoint(H++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(D&&this._activeBuffer.x){let L=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-L,r,o);for(let H=o-I;--H>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-I,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=k,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>l1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new r1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $n(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ni));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=_o.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*n),m=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;u[m++]=y,p+=y>65535?2:1}let g=m;for(let p=1;p<n;++p)u.copyWithin(g,0,m),g+=m;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(be.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(be.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(be.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(be.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(be.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,vo),this._charsetService.setgCharset(1,vo),this._charsetService.setgCharset(2,vo),this._charsetService.setgCharset(3,vo);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,u=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:p,alt:y}=m,b=this._optionsService.rawOptions,k=(D,I)=>(u.triggerDataEvent(`${be.ESC}[${t?"":"?"}${D};${I}$y`),!0),w=D=>D?1:2,S=e.params[0];return t?S===2?k(S,4):S===4?k(S,w(u.modes.insertMode)):S===12?k(S,3):S===20?k(S,w(b.convertEol)):k(S,0):S===1?k(S,w(r.applicationCursorKeys)):S===3?k(S,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):S===6?k(S,w(r.origin)):S===7?k(S,w(r.wraparound)):S===8?k(S,3):S===9?k(S,w(o==="X10")):S===12?k(S,w(b.cursorBlink)):S===25?k(S,w(!u.isCursorHidden)):S===45?k(S,w(r.reverseWraparound)):S===66?k(S,w(r.applicationKeypad)):S===67?k(S,4):S===1e3?k(S,w(o==="VT200")):S===1002?k(S,w(o==="DRAG")):S===1003?k(S,w(o==="ANY")):S===1004?k(S,w(r.sendFocus)):S===1005?k(S,4):S===1006?k(S,w(c==="SGR")):S===1015?k(S,4):S===1016?k(S,w(c==="SGR_PIXELS")):S===1048?k(S,1):S===47||S===1047||S===1049?k(S,w(p===y)):S===2004?k(S,w(r.bracketedPasteMode)):S===2026?k(S,w(r.synchronizedOutput)):k(S,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=$u.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let u=e.getSubParams(t+c),m=0;do r[1]===5&&(o=1),r[c+m+1+o]=u[m];while(++m<u.length&&m+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return 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=Ni.fg,e.bg=Ni.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Ni.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ni.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Ni.fg&16777215,r.bg&=-67108864,r.bg|=Ni.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${be.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${be.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${be.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ni.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!l1(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(`${be.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>o1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>o1&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(d1(c))if(o==="?")t.push({type:0,index:c});else{let u=a1(o);u&&t.push({type:1,index:c,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=a1(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);d1(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,vo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(EL[e[0]],Hi[e[1]]||vo),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ni.clone(),this._eraseAttrDataInternal=Ni.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new us;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${be.ESC}${u}${be.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Qv=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&&(u1=e,e=t,t=u1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Qv=gi([ze(0,xn)],Qv);function d1(e){return 0<=e&&e<256}var RL=5e7,h1=12,ML=50,NL=class extends gt{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 Le),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>RL)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let u=m=>performance.now()-n>=h1?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=h1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>ML&&(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()}},Jv=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 m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jv=gi([ze(0,xn)],Jv);var f1=!1,AL=class extends gt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new jl),this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onData=this._register(new Le),this.onData=this._onData.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Le),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Le),this._instantiationService=new iL,this.optionsService=this._register(new hL(e)),this._instantiationService.setService(kn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Yv)),this._instantiationService.setService(xn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Vv)),this._instantiationService.setService(Ex,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Xv)),this._instantiationService.setService(Mo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gv)),this._instantiationService.setService(Tx,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(_o)),this._instantiationService.setService(QM,this.unicodeService),this._charsetService=this._instantiationService.createInstance(vL),this._instantiationService.setService(ZM,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jv),this._instantiationService.setService(Dx,this._oscLinkService),this._inputHandler=this._register(new DL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ln.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ln.forward(this._bufferService.onResize,this._onResize)),this._register(ln.forward(this.coreService.onData,this._onData)),this._register(ln.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 NL((t,n)=>this._inputHandler.parse(t,n))),this._register(ln.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Le),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&&!f1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),f1=!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,ak),t=Math.max(t,ok),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(s1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(s1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=si(()=>{for(let t of e)t.dispose()})}}},LL={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 OL(e,t,n,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=be.ESC+"OA":o.key=be.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=be.ESC+"OD":o.key=be.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=be.ESC+"OC":o.key=be.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=be.ESC+"OB":o.key=be.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":be.DEL,e.altKey&&(o.key=be.ESC+o.key);break;case 9:if(e.shiftKey){o.key=be.ESC+"[Z";break}o.key=be.HT,o.cancel=!0;break;case 13:o.key=e.altKey?be.ESC+be.CR:be.CR,o.cancel=!0;break;case 27:o.key=be.ESC,e.altKey&&(o.key=be.ESC+be.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"D":t?o.key=be.ESC+"OD":o.key=be.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"C":t?o.key=be.ESC+"OC":o.key=be.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"A":t?o.key=be.ESC+"OA":o.key=be.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"B":t?o.key=be.ESC+"OB":o.key=be.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=be.ESC+"[2~");break;case 46:c?o.key=be.ESC+"[3;"+(c+1)+"~":o.key=be.ESC+"[3~";break;case 36:c?o.key=be.ESC+"[1;"+(c+1)+"H":t?o.key=be.ESC+"OH":o.key=be.ESC+"[H";break;case 35:c?o.key=be.ESC+"[1;"+(c+1)+"F":t?o.key=be.ESC+"OF":o.key=be.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=be.ESC+"[5;"+(c+1)+"~":o.key=be.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=be.ESC+"[6;"+(c+1)+"~":o.key=be.ESC+"[6~";break;case 112:c?o.key=be.ESC+"[1;"+(c+1)+"P":o.key=be.ESC+"OP";break;case 113:c?o.key=be.ESC+"[1;"+(c+1)+"Q":o.key=be.ESC+"OQ";break;case 114:c?o.key=be.ESC+"[1;"+(c+1)+"R":o.key=be.ESC+"OR";break;case 115:c?o.key=be.ESC+"[1;"+(c+1)+"S":o.key=be.ESC+"OS";break;case 116:c?o.key=be.ESC+"[15;"+(c+1)+"~":o.key=be.ESC+"[15~";break;case 117:c?o.key=be.ESC+"[17;"+(c+1)+"~":o.key=be.ESC+"[17~";break;case 118:c?o.key=be.ESC+"[18;"+(c+1)+"~":o.key=be.ESC+"[18~";break;case 119:c?o.key=be.ESC+"[19;"+(c+1)+"~":o.key=be.ESC+"[19~";break;case 120:c?o.key=be.ESC+"[20;"+(c+1)+"~":o.key=be.ESC+"[20~";break;case 121:c?o.key=be.ESC+"[21;"+(c+1)+"~":o.key=be.ESC+"[21~";break;case 122:c?o.key=be.ESC+"[23;"+(c+1)+"~":o.key=be.ESC+"[23~";break;case 123:c?o.key=be.ESC+"[24;"+(c+1)+"~":o.key=be.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=be.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=be.DEL:e.keyCode===219?o.key=be.ESC:e.keyCode===220?o.key=be.FS:e.keyCode===221&&(o.key=be.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=LL[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=be.ESC+u;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),o.key=be.ESC+g}else if(e.keyCode===32)o.key=be.ESC+(e.ctrlKey?be.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=be.ESC+m,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=be.US),e.key==="@"&&(o.key=be.NUL));break}return o}var xi=0,BL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new of,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new of,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xi=this._search(t),xi===-1)||this._getKey(this._array[xi])!==t)return!1;do if(this._array[xi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xi),!0;while(++xi<this._array.length&&this._getKey(this._array[xi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do yield this._array[xi];while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do t(this._array[xi]);while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},bg=0,p1=0,jL=class extends gt{constructor(){super(),this._decorations=new BL(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Le),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Le),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(si(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new IL(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{bg=o.options.x??0,p1=bg+(o.options.width??1),e>=bg&&e<p1&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},IL=class extends Na{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Le),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Le),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=ci.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ci.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},zL=1e3,PL=class{constructor(e,t=zL){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},m1=20,lf=class extends gt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new PL(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(`
|
|
29
|
-
`))),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(nt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(si(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<m1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===m1+1&&(this._liveRegion.textContent+=bv.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),u=[],m=c?.translateToString(!0,void 0,void 0,u)||"",g=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(m.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=m,this._rowColumns.set(p,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let u,m;if(t===0?(u=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(u=this._rowElements.shift(),m=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:m,offset:g})=>{let p=m instanceof Text?m.parentNode:m,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let k=g<b.length?b[g]:b.slice(-1)[0]+1;return k>=this._terminal.cols&&(++y,k=0),{row:y,column:k}},c=o(t),u=o(n);if(!(!c||!u)){if(c.row>u.row||c.row===u.row&&c.column>=u.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(u.row-c.row)*this._terminal.cols-c.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};lf=gi([ze(1,hb),ze(2,Br),ze(3,jr)],lf);var e_=class extends gt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Le),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Le),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(si(()=>{ko(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(nt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(nt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(nt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(nt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(m=>({link:m}));this._activeProviderReplies?.set(r,u),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let u=o[c],m=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=m;p<=g;p++){if(n.has(p)){o.splice(c--,1);break}n.add(p)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(u=>this._linkAtPosition(u.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&HL(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,ko(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};e_=gi([ze(1,fb),ze(2,jr),ze(3,xn),ze(4,Mx)],e_);function HL(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 UL=class extends AL{constructor(e={}){super(e),this._linkifier=this._register(new jl),this.browser=Xx,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new jl),this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Le),this.onKey=this._onKey.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Le),this.onBell=this._onBell.event,this._onFocus=this._register(new Le),this._onBlur=this._register(new Le),this._onA11yCharEmitter=this._register(new Le),this._onA11yTabEmitter=this._register(new Le),this._onWillOpen=this._register(new Le),this._setup(),this._decorationService=this._instantiationService.createInstance(jL),this._instantiationService.setService(qu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(MA),this._instantiationService.setService(Mx,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Sv)),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(ln.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ln.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ln.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ln.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(si(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=ei.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${be.ESC}]${r};${TL(o)}${Vx.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Li.toColor(...t.color));else{let c=n;this._themeService.modifyColors(u=>u[c]=Li.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(lf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(be.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(be.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(nt(this.element,"copy",t=>{this.hasSelection()&&$M(t,this._selectionService)}));let e=t=>qM(t,this.textarea,this.coreService,this.optionsService);this._register(nt(this.textarea,"paste",e)),this._register(nt(this.element,"paste",e)),Gx?this._register(nt(this.element,"mousedown",t=>{t.button===2&&kw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(nt(this.element,"contextmenu",t=>{kw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Sb&&this._register(nt(this.element,"auxclick",t=>{t.button===1&&Sx(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(nt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(nt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(nt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(nt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(nt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(nt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(nt(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(nt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_v.get()),Jx||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(DA,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Br,this._coreBrowserService),this._register(nt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(nt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Kv,this._document,this._helperContainer),this._instantiationService.setService(Of,this._charSizeService),this._themeService=this._instantiationService.createInstance(qv),this._instantiationService.setService(Wl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(rf),this._instantiationService.setService(Rx,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Fv,this.rows,this.screenElement)),this._instantiationService.setService(jr,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Pv,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Wv),this._instantiationService.setService(fb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(e_,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(Iv,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance($v,this.element,this.screenElement,r)),this._instantiationService.setService(eN,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(ln.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(zv,this.screenElement)),this._register(nt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(lf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sf,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sf,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Uv,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(nt(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(nt(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let u=be.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!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){yx(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=OL(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===be.ETX||n.key===be.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(KL(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ni));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(be.ESC+"[I"):this.coreService.triggerDataEvent(be.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${be.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${be.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function KL(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var WL=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},FL=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 us)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},g1=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 FL(t)}getNullCell(){return new us}},$L=class extends gt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Le),this.onBufferChange=this._onBufferChange.event,this._normal=new g1(this._core.buffers.normal,"normal"),this._alternate=new g1(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)}},qL=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},VL=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}},YL=["cols","rows"],Ws=0,XL=class extends gt{constructor(e){super(),this._core=this._register(new UL(e)),this._addonManager=this._register(new WL),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(YL.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 qL(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new VL(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 $L(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
31
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return _v.get()},set promptLabel(e){_v.set(e)},get tooMuchOutput(){return bv.get()},set tooMuchOutput(e){bv.set(e)}}}_verifyIntegers(...e){for(Ws of e)if(Ws===1/0||isNaN(Ws)||Ws%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ws of e)if(Ws&&(Ws===1/0||isNaN(Ws)||Ws%1!==0||Ws<0))throw new Error("This API only accepts positive integers")}};const GL=Ai.lazy(()=>db(()=>import("./TranscriptMarkdownBody-Du5Pkx1T.js"),__vite__mapDeps([2,1])));function ck({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=u.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let m=-1;return f.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,p)=>{const y=g.kind==="user"?++m:null,b=n===p?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return f.jsxs("section",{ref:k=>{k?u.current.set(p,k):u.current.delete(p)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":p,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?f.jsx("div",{className:"transcript-entry-header",children:uk(g.header,t)}):null,g.body?f.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?f.jsx(v1,{text:g.body,searchQuery:t}):f.jsx(Ai.Suspense,{fallback:f.jsx(v1,{text:g.body,searchQuery:t}),children:f.jsx(GL,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function v1({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
32
|
-
`)?e.slice(0,-1).split(`
|
|
33
|
-
`):e.split(`
|
|
34
|
-
`);return f.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>f.jsx("span",{className:`transcript-line transcript-line-${t3(r,o===0||n[o-1]?.trim()==="")}`,children:uk(r,t)},o))})}function uk(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let u=0,m=r.indexOf(o);for(;m!==-1;){m>u&&c.push(e.slice(u,m));const g=m+n.length;c.push(f.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),u=g,m=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function ZL(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(n);for(;c!==-1;)o+=1,c=r.indexOf(n,c+n.length);return o}function dk(e){const t=e.endsWith(`
|
|
35
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function u(){const m=QL(c).join(`
|
|
36
|
-
`);(r||m)&&n.push({header:r,body:m,kind:o}),r=null,o="plain",c=[]}for(const m of t.split(`
|
|
37
|
-
`)){const g=JL(m);g?(u(),r=m,o=g):c.push(m)}return u(),n}function QL(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function JL(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function e3(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
38
|
-
${o.body}`:o.body,u=ZL(c,t);for(let m=0;m<u;m+=1)n.push({entryIndex:r,matchIndexInEntry:m})}return n}function t3(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||pk(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function Eo(e){return e==="codex"?"Codex":"Claude"}function t_(e,t,n={}){const r=`[nterminal] ${Eo(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
-
`).replace(/\r/g,`
|
|
40
|
-
`).replace(r,"").replace(/\n{3,}/g,`
|
|
41
|
-
|
|
42
|
-
`).trimEnd(),c=hk(o),u=n.includeTools?c:fk(c);return u?`${u}
|
|
43
|
-
`:""}function hk(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=i3(n);return r?`[${r}]`:t})}function i3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=Gc(t.getMonth()+1),o=Gc(t.getDate()),c=Gc(t.getHours()),u=Gc(t.getMinutes()),m=Gc(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${m}`}function Gc(e){return e.toString().padStart(2,"0")}function cf(e,t){return e.map(n=>t?n:fk(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
44
|
-
`)?n:`${n}
|
|
45
|
-
`).join("")}function fk(e){if(!e)return"";const t=e.split(`
|
|
46
|
-
`),n=[];let r=!1,o=!1,c=!0;for(const u of t){const m=u.trim()==="",g=c?n3(u):null;if(g&&(r=g==="tool",o=!1),pk(u)){o=!0,c=!1;continue}if(o){m?(o=!1,r||n.push(u),c=!0):c=!1;continue}r||n.push(u),c=m}return n.join(`
|
|
47
|
-
`).replace(/\n{3,}/g,`
|
|
48
|
-
|
|
49
|
-
`).trimEnd()}function n3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function pk(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function wb(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Ch(e,t){return e===null?t===null:t!==null&&wb(e,t)}const s3=5e3,r3=200,a3=1200,o3=4,l3=Ai.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const u=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(!1),[k,w]=v.useState(null),[S,D]=v.useState(null),[I,L]=v.useState(null),[H,Y]=v.useState(()=>new Set),[$,se]=v.useState(!1),[J,F]=v.useState(!1),[xe,re]=v.useState([]),[Ee,ie]=v.useState(null),[V,X]=v.useState(!1),[W,le]=v.useState(!1),[O,M]=v.useState(!1),[B,ae]=v.useState(null),we=k?.find(R=>R.id===I)??null;v.useEffect(()=>{function R(q){q.key==="Escape"&&(q.preventDefault(),q.stopPropagation(),c())}return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[c]);const N=v.useCallback(async()=>{try{const R=await n.getTerminalSubagents(t);if(D(null),w(q=>q&&f3(q,R.subagents)?q:R.subagents),!b.current){const q=R.subagents.find(fe=>fe.hasTranscript);q&&(b.current=!0,L(fe=>fe??q.id))}}catch(R){D(R instanceof Error?R.message:"Failed to load subagents."),w(q=>q??[])}},[n,t]);v.useEffect(()=>{N();const R=window.setInterval(()=>{document.hidden||N()},s3);function q(){document.hidden||N()}return document.addEventListener("visibilitychange",q),()=>{window.clearInterval(R),document.removeEventListener("visibilitychange",q)}},[N]),v.useEffect(()=>{m.current+=1;const R=m.current;return g.current=!1,p.current=!0,y.current=null,re([]),ie(null),X(!1),ae(null),I&&U(null,"initial",R),()=>{m.current===R&&(m.current+=1)}},[n,t,I,J]),v.useLayoutEffect(()=>{const R=u.current;if(!R)return;if(p.current){if(W||xe.length===0)return;p.current=!1;const fe=()=>{R.scrollTop=R.scrollHeight};fe(),window.requestAnimationFrame?.(fe);return}const q=y.current;q!==null&&(y.current=null,R.scrollTop+=R.scrollHeight-q)},[xe,W,J]);async function U(R,q,fe=m.current){const ge=I;if(!(!ge||g.current)){g.current=!0,q==="initial"?le(!0):(M(!0),y.current=u.current?.scrollHeight??null),ae(null);try{let Q=R,ke=0,de=0,Re=[];for(;m.current===fe;){const Ie=await n.getTerminalSubagentTranscriptHistory(t,ge,{...Q?{cursor:Q}:{},limit:r3,maxLines:a3,includeTools:J});if(m.current!==fe)return;if(!Ie.source){if(de<1){de+=1,await new Promise(Ye=>setTimeout(Ye,600));continue}ae("Subagent transcript is unavailable.");return}const je=t_(Ie.output,Ie.source.provider,{includeTools:J});if(ie(Ie.cursor),X(!!(Ie.hasMore&&Ie.cursor)),je&&(Re=[je,...Re],cf(Re,J))){re(Ye=>q==="older"?[...Re,...Ye]:Re);return}if(!Ie.hasMore||!Ie.cursor||ke>=o3){Re.length>0&&re(Ye=>q==="older"?[...Re,...Ye]:Re);return}Q=Ie.cursor,ke+=1}}catch(Q){if(m.current!==fe)return;ae(Q instanceof Error?Q.message:"Failed to load subagent transcript.")}finally{m.current===fe&&(g.current=!1,le(!1),M(!1))}}}function ue(){const R=u.current;R&&(R.scrollTop>72||!V||!Ee||g.current||U(Ee,"older"))}function Ce(R){Y(q=>{const fe=new Set(q);return fe.delete(R)||fe.add(R),fe})}function Oe(R){b.current=!0,se(!0),R.id!==I&&L(R.id),De(R.id)}function De(R){const q=d3(k??[],R);q.length!==0&&Y(fe=>{if(q.every(Q=>fe.has(Q)))return fe;const ge=new Set(fe);for(const Q of q)ge.add(Q);return ge})}function Be(){m.current+=1;const R=m.current;g.current=!1,p.current=!0,y.current=null,re([]),ie(null),X(!1),ae(null),U(null,"initial",R)}const Ne=v.useMemo(()=>cf(xe,J),[xe,J]),Ue=v.useMemo(()=>dk(Ne),[Ne]),We=k===null;v.useEffect(()=>{if(W||O||!V||!Ee||g.current)return;const R=u.current;!R||xe.length===0||R.scrollHeight<=R.clientHeight+4&&U(Ee,"older")},[xe,V,Ee,W,O]);const ne=k?.filter(R=>R.state==="working").length??0,pe=v.useMemo(()=>vk(c3(k??[]),H),[k,H]);return f.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:R=>R.stopPropagation(),onMouseDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":$?"transcript":"list",onPointerDown:R=>R.stopPropagation(),onMouseDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",k&&k.length>0?f.jsx("span",{className:"subagents-count",children:ne>0?`${ne} working · ${k.length} total`:`${k.length} total`}):null]}),f.jsxs("span",{title:r.sessionId,children:[Eo(r.provider)," session ",r.sessionId]})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),f.jsxs("div",{className:"subagents-body",children:[f.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[We?f.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!We&&S?f.jsx("div",{className:"subagents-list-status subagents-list-error",children:S}):null,!We&&!S&&k!==null&&k.length===0?f.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,pe.map(R=>{const q=R.subagent,fe=H.has(q.id);return f.jsxs("div",{className:"subagent-row-wrap",style:R.level>0?{paddingLeft:`${Math.min(R.level,4)*14}px`}:void 0,children:[R.nestedCount>0?f.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":fe,"aria-label":`${fe?"Collapse":"Expand"} ${R.nestedCount} nested subagents of ${q.name}`,title:R.nestedWorkingCount>0?`${R.nestedCount} nested · ${R.nestedWorkingCount} working`:`${R.nestedCount} nested`,onClick:()=>Ce(q.id),children:[f.jsx("span",{"aria-hidden":"true",children:fe?"▾":"▸"}),f.jsx("span",{className:"subagent-expander-count","data-working":R.nestedWorkingCount>0?"true":"false",children:R.nestedCount})]}):f.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),f.jsxs("button",{type:"button",className:"subagent-row","data-selected":q.id===I?"true":"false","data-state":q.state,disabled:!q.hasTranscript,title:q.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Oe(q),children:[f.jsx("span",{className:"subagent-row-dot","data-state":q.state,"aria-hidden":"true"}),f.jsxs("span",{className:"subagent-row-main",children:[f.jsxs("span",{className:"subagent-row-title",children:[f.jsx("strong",{children:q.name}),f.jsx("span",{className:"subagent-row-badge","data-kind":q.kind,children:q.kind==="cross"?Eo(q.provider):q.provider})]}),q.description?f.jsx("span",{className:"subagent-row-description",children:q.description}):null,f.jsxs("span",{className:"subagent-row-meta",children:[p3(q.state),q.model?` · ${q.model}`:"",q.updatedAt?` · ${m3(q.updatedAt)}`:"",R.nestedCount>0&&!fe?` · ${R.nestedCount} nested${R.nestedWorkingCount>0?` (${R.nestedWorkingCount} working)`:""}`:""]})]})]})]},q.id)})]}),f.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[f.jsxs("div",{className:"subagents-transcript-controls",children:[f.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>se(!1),children:"‹ List"}),f.jsx("span",{className:"subagents-transcript-name",children:we?we.name:"Select a subagent"}),f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:J,onChange:R=>F(R.currentTarget.checked)}),"Show tool output"]}),f.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!we,onClick:Be,children:"↻"})]}),we?f.jsx("div",{className:"subagents-transcript-hint",children:h3(we)}):null,f.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:ue,children:[O?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!W&&V?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Ne?f.jsx(ck,{entries:Ue,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,W?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!W&&we&&!Ne&&!B?V&&Ee?f.jsxs("div",{className:"transcript-dialog-status",children:[J?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{U(Ee,"older")},disabled:O,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!we&&!We&&!Ne?f.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,B?f.jsx("div",{className:"transcript-dialog-error",children:B}):null]})]})]})]})})});function c3(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=u3(r,t);o?o.children.push(r):n.push(r)}for(const r of n)mk(r);return gk(n),n}function u3(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const u=c.subagent.parentId;c=u?t.get(u):void 0}return r}function mk(e){let t=0,n=0;for(const r of e.children)mk(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,gk(e.children)}function gk(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function vk(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...vk(o.children,t,n+1));return r}function d3(e,t){const n=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function h3(e){return e.kind==="cross"?'"User" entries are the prompt the parent session passed to codex exec, not operator input.':e.provider==="codex"?"Codex forks the parent thread to start a teammate; the inherited history is hidden here. Coordinator instructions are stored encrypted by Codex, so they show as placeholders.":`"User" entries are the parent session's instructions and tool results, not operator input.`}function f3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function p3(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function m3(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}class g3{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():Sk.has(t)?this.acceptConsonant(t):wk.has(t)?this.acceptVowel(t):y3(t)&&this.canReplacePendingWith(t)?(this.pending=b1(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(Ck.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=b3.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=_3.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=_1.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const r=this.pending.final,o=y1({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=_1.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=b1(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=y1(this.pending);return this.pending=null,t}}const uf=44032,df=21,kl=28,v3=19*df*kl,_k=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],bk=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],yk=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Sk=Cb(_k),wk=Cb(bk),Ck=Cb(yk),_3=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),xk=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],b3=new Map(xk),_1=new Map(xk.map(([e,t])=>[t,[e[0],e[1]]]));function Cb(e){return new Map(e.map((t,n)=>[t,n]))}function y3(e){const t=e.codePointAt(0);return t!==void 0&&t>=uf&&t<uf+v3}function b1(e){const t=e.codePointAt(0)-uf,n=Math.floor(t/(df*kl)),r=Math.floor(t%(df*kl)/kl),o=t%kl,c={initial:_k[n],vowel:bk[r]};return o===0?c:{...c,final:yk[o]}}function y1(e){if(!e.vowel)return e.initial;const t=Sk.get(e.initial),n=wk.get(e.vowel),r=e.final?Ck.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(uf+(t*df+n)*kl+r)}const S3=[{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 w3({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return f.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[f.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"}),S3.map(u=>f.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),f.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const C3={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function x3(e){return C3[e]}function k3(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const kk="--nterminal-viewport-height",Tk="--nterminal-keyboard-inset-bottom",Ek="data-nterminal-keyboard-visible",If="data-nterminal-compose-open",hf="nterminal:viewport-refresh",T3=120;function E3(e=window){const t=e.document.documentElement,n=e.visualViewport,r=L3(e);function o(){xb(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(hf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(hf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(kk),t.style.removeProperty(Tk),t.removeAttribute(Ek)}}function xb(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=i_(e),o=D3(e,r);return o!==null&&S1(t,kk,`${o}px`),S1(t,Tk,`${n}px`),R3(t,Ek,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function i_(e=window){const t=M3(e);return{keyboardInsetBottom:t,keyboardVisible:t>T3}}function D3(e,t){if((e.document.documentElement.hasAttribute(If)||t)&&So(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return So(n)?n:So(e.innerHeight)?e.innerHeight:null}function So(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function S1(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function R3(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function M3(e){return Math.max(N3(e),A3(e))}function N3(e){const t=e.visualViewport?.height;if(!So(t)||!So(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function A3(e){if(!So(e.innerHeight))return 0;const n=Dk(e)?.boundingRect?.height;return!So(n)||n>=e.innerHeight*.8?0:Math.round(n)}function Dk(e){return e.navigator.virtualKeyboard}function L3(e){const t=Dk(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Xu=new Map,Mu=new Map,O3=Object.freeze({open:!1,text:""});function B3(e){let t=Mu.get(e);return t||(t=new Set,Mu.set(e,t)),t}function Rk(e){const t=Mu.get(e);if(t)for(const n of Array.from(t))n()}function Ml(e){return Xu.get(e)??O3}function j3(e,t){const n=B3(e);return n.add(t),()=>{n.delete(t)}}function I3(e,t){const n=Ml(e);n.open!==t&&(Xu.set(e,{...n,open:t}),Rk(e))}function z3(e,t){const n=Ml(e);n.text!==t&&(Xu.set(e,{...n,text:t}),Rk(e))}function xh(e){Xu.delete(e),Mu.delete(e)}function w1(){Xu.clear(),Mu.clear()}const Pa=new Map,Nu=new Map,ff=new Map,P3=Object.freeze([]);function Au(e){return Pa.get(e)??P3}function H3(e,t){let n=Nu.get(e);return n||(n=new Set,Nu.set(e,n)),n.add(t),()=>n?.delete(t)}function yg(e,t){t.length!==0&&(Pa.set(e,[...Au(e),...t]),zf(e))}function Sg(e){const t=ff.get(e)??1;return ff.set(e,t+1),`attach${t}`}function n_(e){ff.delete(e)}function Zc(e,t,n){const r=Au(e);r.length!==0&&(Pa.set(e,r.map(o=>t.has(o.id)?n(o):o)),zf(e))}function kh(e,t){const n=Au(e);n.find(c=>c.id===t)?.cancel?.();const o=n.filter(c=>c.id!==t);o.length!==n.length&&(o.length===0?Pa.delete(e):Pa.set(e,o),zf(e))}function Mk(e){const t=Pa.get(e);if(t){for(const n of t)n.cancel?.();Pa.delete(e),zf(e)}}function au(e){Mk(e),n_(e),Nu.delete(e)}function C1(){for(const e of Array.from(Pa.keys()))au(e);Nu.clear(),ff.clear()}function zf(e){for(const t of Array.from(Nu.get(e)??[]))t()}class U3 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Tl(e){return e?Array.from(e.types??[]).includes("Files")||Bk(e.items).some(n=>n.kind==="file")?!0:jk(e.files).length>0:!1}async function Nk(e){const t=Bk(e.items).filter(n=>n.kind==="file");return t.length>0?K3(t):W3(e.files)}async function K3(e){const t=[];for(const n of e){const r=V3(n);if(r){await Ak(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Lk(o),file:o});continue}throw new U3("Folder upload is not supported by this browser.")}return t}function W3(e){return jk(e).map(t=>({relativePath:Lk(t),file:t}))}async function Ak(e,t,n){const r=X3(t,e.name);if(e.isFile){const u=await F3(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await $3(o);for(const u of c)await Ak(u,r,n)}function F3(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function $3(e){const t=[];for(;;){const n=await q3(e);if(n.length===0)return t;t.push(...n)}}function q3(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Lk(e){const t=e.webkitRelativePath;return Ok(typeof t=="string"&&t?t:e.name)}function V3(e){const t=e.webkitGetAsEntry?.();return Y3(t)?t:null}function Y3(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 X3(e,t){return Ok(e?`${e}/${t}`:t)}function Ok(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Bk(e){return e?Array.from(e):[]}function jk(e){return e?Array.from(e):[]}const G3=120,Z3="\x1B[200~",Q3="\x1B[201~";function wg(e,t){const n=t.stripTrailingLineBreaks===!1?e:kb(e),r=eO(n);return r?t.bracketedPasteMode?`${Z3}${r}${Q3}`:r:""}function J3(e){return e==="queue"?" ":"\r"}function kb(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function eO(e){return e.replace(/\r\n/g,`
|
|
50
|
-
`).replace(/\r/g,`
|
|
51
|
-
`).replace(/\n/g,"\r")}const tO=420,iO=3e3,x1=650,nO=80,sO=3,rO=10,aO=50*1024*1024,oO=100*1024*1024,lO={maxFiles:rO,maxFileBytes:aO,maxBatchBytes:oO},Uh=new Set;let Nl=null;function cO({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const m=v.useMemo(()=>R=>j3(e,R),[e]),g=v.useMemo(()=>()=>Ml(e),[e]),p=v.useSyncExternalStore(m,g,g),{open:y,text:b}=p,k=v.useMemo(()=>R=>H3(e,R),[e]),w=v.useMemo(()=>()=>Au(e),[e]),S=v.useSyncExternalStore(k,w,w),[D,I]=v.useState(lO),[L,H]=v.useState(!1),Y=v.useRef(null),$=v.useRef(null),se=v.useRef(null),J=v.useRef(null),F=v.useRef(new Map),xe=v.useRef(c),re=v.useRef(u),Ee=v.useRef(null),ie=v.useRef({start:0,end:0});xe.current=c,re.current=u,v.useEffect(()=>()=>{Ee.current?.(),Ee.current=null},[]),v.useEffect(()=>{if(!y||!xe.current)return;let R=!0;return xe.current().then(q=>{R&&I(q)}).catch(()=>{}),()=>{R=!1}},[y,e]),v.useLayoutEffect(()=>{if(!(!y||!Kh()))return gO(e),()=>vO(e)},[y,e]),v.useLayoutEffect(()=>{const R=Y.current?.closest(".terminal-pane");if(!R)return;function q(){R?.removeAttribute("data-compose-open"),R?.style.removeProperty("--compose-drawer-panel-height")}if(!y){q();return}const fe=$.current;R.setAttribute("data-compose-open","true");function ge(){const Re=fe?.getBoundingClientRect().height??0;Re>0&&R?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Re)}px`)}ge();const Q=[window.setTimeout(ge,0),window.setTimeout(ge,180),window.setTimeout(ge,260)],ke=window.requestAnimationFrame?.(ge)??null,de=typeof ResizeObserver=="function"&&fe?new ResizeObserver(ge):null;return de&&fe&&de.observe(fe),()=>{for(const Re of Q)window.clearTimeout(Re);ke!==null&&window.cancelAnimationFrame?.(ke),de?.disconnect(),q()}},[y]),v.useEffect(()=>{if(!y){Ee.current?.(),Ee.current=null;return}Tg(se.current),We()},[y]);function V(R){I3(e,R)}function X(R){z3(e,R)}function W(){mO(Y.current),V(!1),E1()}function le(R="send"){const q=S.filter(ge=>ge.status==="uploaded"&&ge.path);if(r||S.some(ge=>ge.status==="uploading"||ge.status==="failed")||!b&&q.length===0)return;const fe=hO(b,S);if(fe.parts.some(ge=>ge.kind==="image"||ge.value.trim())&&t(fe,R)){if(X(""),Mk(e),n_(e),Kh()){se.current?.blur(),E1();return}window.setTimeout(()=>se.current?.focus(),G3+20)}}async function O(R){if(r||R.length===0)return;const q=Au(e).filter(je=>je.status!=="failed"),fe=q.reduce((je,Ye)=>je+Ye.file.size,0);let ge=0,Q=q.length;const ke=[],de=R.filter((je,Ye)=>{const lt=fe+ge+je.file.size,Nt=je.file.size>D.maxFileBytes?`File exceeds the ${T1(D.maxFileBytes)} attachment limit.`:Q>=D.maxFiles?`A compose message can include up to ${D.maxFiles} attachments.`:lt>D.maxBatchBytes?`Compose attachments cannot exceed ${T1(D.maxBatchBytes)} in total.`:null;return Nt?(ke.push({id:xg(Ye),reference:Sg(e),file:je.file,relativePath:k1(je.relativePath,je.file.name),status:"failed",error:Nt}),!1):(Q+=1,ge+=je.file.size,!0)});if(ke.length>0&&yg(e,ke),de.length===0)return;const Re=new Map,Ie=de.map((je,Ye)=>{const lt=xg(Ye),Nt=new AbortController;return Re.set(lt,Nt),{id:lt,reference:Sg(e),file:je.file,relativePath:k1(je.relativePath,je.file.name),status:"uploading",loaded:0,total:je.file.size,cancel:()=>Nt.abort()}});yg(e,Ie),ne(Ie.map(je=>je.reference));for(const je of Ie)F.current.set(je.id,Re.get(je.id));await Promise.all(Ie.map(async je=>{const Ye=Re.get(je.id),lt=new Set([je.id]);try{const yt=(await o([{relativePath:je.relativePath,file:je.file}],{signal:Ye.signal,onProgress:Tt=>{Zc(e,lt,$e=>({...$e,loaded:Tt.loaded,total:Tt.total}))}})).results[0];if(Ye.signal.aborted){const Tt=re.current;yt?.status==="uploaded"&&yt.attachmentId&&Tt&&Tt([yt.attachmentId]).catch(()=>{});return}Zc(e,lt,Tt=>{const{error:$e,cancel:St,...Lt}=Tt;return yt?.status==="uploaded"&&yt.path?{...Lt,status:"uploaded",...yt.attachmentId?{attachmentId:yt.attachmentId}:{},path:yt.path,loaded:yt.size??Tt.file.size,total:yt.size??Tt.file.size}:{...Lt,status:"failed",error:yt?.error??"upload_failed"}})}catch(Nt){const yt=Ye.signal.aborted?"Upload canceled.":kg(Nt);Zc(e,lt,Tt=>{const{cancel:$e,...St}=Tt;return{...St,status:"failed",error:yt}})}finally{F.current.get(je.id)===Ye&&F.current.delete(je.id)}}))}function M(R){if(R.status!=="removing"){if(pe(R.reference),R.status!=="uploaded"&&R.status!=="failed"||!R.attachmentId||!re.current){F.current.delete(R.id),kh(e,R.id);return}ae([R])}}function B(){X(""),n_(e);const R=S.filter(q=>!!(q.path&&q.attachmentId));for(const q of S)R.includes(q)||(F.current.delete(q.id),kh(e,q.id));R.length>0&&ae(R)}function ae(R){const q=R.flatMap(ge=>ge.attachmentId?[ge.attachmentId]:[]);if(q.length===0||!re.current){for(const ge of R)kh(e,ge.id);return}const fe=new Set(R.map(ge=>ge.id));Zc(e,fe,ge=>{const{error:Q,...ke}=ge;return{...ke,status:"removing"}}),re.current(q).then(()=>{for(const ge of R)kh(e,ge.id)}).catch(ge=>{Zc(e,fe,Q=>({...Q,status:"failed",error:`Could not remove attachment: ${kg(ge)}`}))})}function we(R){const q=Array.from(R.currentTarget.files??[]).map(fe=>({relativePath:fe.name,file:fe}));R.currentTarget.value="",O(q)}function N(R){const q=Array.from(R.clipboardData.files??[]);q.length!==0&&O(q.map(fe=>({relativePath:fe.name,file:fe})))}function U(R){r||!Tl(R.dataTransfer)||(R.preventDefault(),R.stopPropagation(),R.dataTransfer.dropEffect="copy",H(!0))}function ue(R){r||!Tl(R.dataTransfer)||(R.preventDefault(),R.stopPropagation(),H(!0))}function Ce(R){if(!Tl(R.dataTransfer))return;const q=R.relatedTarget;q instanceof Node&&R.currentTarget.contains(q)||H(!1)}function Oe(R){Tl(R.dataTransfer)&&(R.preventDefault(),R.stopPropagation(),H(!1),Nk(R.dataTransfer).then(O).catch(q=>{const fe={id:xg(0),reference:Sg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:kg(q)};yg(e,[fe])}))}const De=S.some(R=>R.status==="uploading"),Be=S.some(R=>R.status==="failed"),Ne=S.filter(R=>R.status==="uploaded"&&R.path).length,Ue=!r&&!De&&!Be&&(!!b||Ne>0);function We(){Kh()&&(Ee.current?.(),Ee.current=_O())}function ne(R){if(R.length===0)return;const q=R.map(Nt=>`@${Nt}`).join(" "),fe=Ml(e).text,ge=Math.min(ie.current.start,fe.length),Q=Math.min(Math.max(ge,ie.current.end),fe.length),ke=fe.slice(0,ge),de=fe.slice(Q),Re=ke&&!/\s$/.test(ke)?" ":"",Ie=de&&!/^\s/.test(de)?" ":"",je=`${Re}${q}${Ie}`,Ye=`${ke}${je}${de}`,lt=ke.length+je.length;ie.current={start:lt,end:lt},X(Ye),window.requestAnimationFrame(()=>{const Nt=se.current;Nt&&(Tg(Nt),Nt.setSelectionRange(lt,lt))})}function pe(R){const q=Ml(e).text,fe=q.replace(new RegExp(`@${pO(R)}(?![A-Za-z0-9_])`,"g"),"");fe!==q&&X(fe.replace(/[ \t]{2,}/g," "))}return f.jsxs("div",{ref:Y,className:"compose-drawer","data-open":y?"true":"false",children:[f.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":y?"true":void 0,tabIndex:y?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>V(!0),children:[f.jsx("span",{"aria-hidden":"true",children:"▴"}),f.jsx("span",{children:"compose"}),b||S.length>0?f.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),f.jsxs("div",{ref:$,className:"compose-drawer-panel","aria-hidden":y?void 0:"true","data-file-drag-active":L?"true":void 0,onDragEnter:ue,onDragOver:U,onDragLeave:Ce,onDrop:Oe,children:[L?f.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,f.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:y?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:W,children:[f.jsx("span",{"aria-hidden":"true",children:"▾"}),f.jsx("span",{className:"compose-drawer-title",children:"compose"}),f.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),f.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),f.jsx("textarea",{ref:se,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:y?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:R=>{ie.current={start:R.target.selectionStart,end:R.target.selectionEnd},X(R.target.value)},onSelect:R=>{ie.current={start:R.currentTarget.selectionStart,end:R.currentTarget.selectionEnd}},onPaste:N,onFocus:We,onKeyDown:R=>{if(R.key==="Enter"&&(R.metaKey||R.ctrlKey)){if(R.preventDefault(),R.shiftKey){n&&le("queue");return}le("send");return}R.key==="Escape"&&(R.preventDefault(),W())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),f.jsx("input",{ref:J,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:we}),S.length>0?f.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:S.map(R=>f.jsx(uO,{attachment:R,onRemove:()=>M(R)},R.id))}):null,f.jsxs("div",{className:"compose-drawer-actions",children:[f.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:y?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>J.current?.click(),disabled:r,children:"+"}),f.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:y?0:-1,onClick:()=>{B(),Tg(se.current),We()},disabled:!b&&S.length===0,children:"Clear"}),n?f.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:y?0:-1,title:Be?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>le("queue"),disabled:!Ue,children:"Queue"}):null,f.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:y?0:-1,title:Be?"Remove failed attachments before sending.":void 0,onClick:()=>le("send"),disabled:!Ue,children:"Send"})]})]})]})}function uO({attachment:e,onRemove:t}){const n=dO(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return f.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?f.jsx("img",{src:n,alt:""}):f.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),f.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),f.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),f.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),f.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function dO(e,t){const n=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n}function hO(e,t){const n=new Map(t.map(m=>[m.reference,m])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let c=0,u;for(;(u=o.exec(e))!==null;){const m=n.get(u[1]);m&&(Cg(r,e.slice(c,u.index)),m.status==="uploaded"&&m.path&&(fO(m)?r.push({kind:"image",path:m.path}):Cg(r,m.path)),c=o.lastIndex)}return Cg(r,e.slice(c)),{parts:r}}function Cg(e,t){if(!t)return;const n=e.at(-1);if(n?.kind==="text"){n.value+=t;return}e.push({kind:"text",value:t})}function fO(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function pO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function xg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function kg(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function T1(e){return e%(1024*1024)===0?`${e/(1024*1024)} MB`:e>=1024*1024?`${Math.round(e/(1024*1024)*10)/10} MB`:`${Math.ceil(e/1024)} KB`}function mO(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Tg(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Kh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function E1(){if(!Kh())return;const e=El;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function gO(e){Nl!==null&&(window.clearTimeout(Nl),Nl=null),Uh.add(e),document.documentElement.setAttribute(If,"true"),El()}function vO(e){if(Uh.delete(e),Uh.size>0||Nl!==null){El();return}Nl=window.setTimeout(()=>{if(Nl=null,Uh.size>0){El();return}document.documentElement.removeAttribute(If),El()},tO),El()}function _O(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,m=bO();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(k){if(!e){if(k<x1&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,nO)}}function b(){if(e)return;g();const k=xb(),w=Date.now()-c;if(k.keyboardInsetBottom>0&&k.keyboardInsetBottom===r?o+=1:(o=k.keyboardInsetBottom>0?1:0,r=k.keyboardInsetBottom),w>=iO||w>=x1&&o>=sO){p();return}y(w)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),p}function El(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,xb()}function bO(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function yO(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(CO(u))return u.preventDefault(),u.stopPropagation(),SO(e),!1;if(wO(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(xO(u)){const m=s_(e);return m?(u.preventDefault(),u.stopPropagation(),r_(m),!1):!0}return kO(u)?(u.preventDefault(),u.stopPropagation(),TO(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const m=s_(e);if(m){if(u.clipboardData){u.clipboardData.setData("text/plain",m),u.preventDefault();return}u.preventDefault(),r_(m)}},c=u=>{const m=u.clipboardData?.getData("text/plain");if(!m)return;const g=kb(m);u.preventDefault(),u.stopImmediatePropagation(),Ik(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",c,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function SO(e){const t=s_(e);t&&await r_(t)}function wO(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function CO(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 xO(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function kO(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 TO(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;Ik(e,kb(n),t)}catch{}}function Ik(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function s_(e){return e.hasSelection()?e.getSelection():EO(e.element??null)}function EO(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function r_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}DO(e)}function DO(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const RO=[4,10,11,12];function MO(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>D1(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>D1(r)),e.parser.registerCsiHandler({final:"n"},r=>NO(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>AO(r)),e.parser.registerCsiHandler({final:"t"},r=>LO(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...RO.map(r=>e.parser.registerOscHandler(r,o=>OO(o)))];return{dispose(){for(const r of n)r.dispose()}}}function D1(e){return Pf(e)===0}function NO(e){const t=Pf(e);return t===5||t===6}function AO(e){return Pf(e)===6}function LO(e){const t=Pf(e);return t===14||t===16||t===18}function OO(e){return e.split(";").some(t=>t==="?")}function Pf(e){const t=e[0];return typeof t=="number"?t:0}const Lr=new Map,Eg=2*1024*1024,BO=1500,R1=25e3,zk=2500,jO=1e3,IO=3e4,zO=16*1024*1024,a_=256,Pk=HD-3e4,PO=3e3,Hk=1e4,HO=3e3,o_=16*1024*1024,Hf=4*1024*1024,pf=25,UO=1e3,KO=3e3,Dg=8,WO=100,Uk=1e3,M1=[2e3,5e3,15e3,6e4];let FO=0,$O=0,Rg=0,Mg=null,Wh=!1,l_=0,Fh=0,Aa=!1,N1=!1,bu=null,A1=!1,c_=0,Lu=document.visibilityState!=="hidden";const mf=new Set,qO=new TextEncoder,VO=m5();function YO(e,t){GO(),n5(),Rf()&&Nr(0);let n=Lr.get(e);n||(n=JO(e),Lr.set(e,n),$l(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Tb(n));const o=(m,g)=>r5(n,m,g),c=m=>{m?(n.foregroundAttachments.add(r),Kk(n)):n.foregroundAttachments.delete(r)},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function ou(e){const t=Lr.get(e);t&&(p5(t),Lr.delete(e))}function XO(e){const t=Lr.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Ua(t),xs(t),Gs(t),Ka(t),Ys(t,"reconnecting"),Fa(t);const n=t.socket;return t.socket=null,Da(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),$l(t),!0}function GO(){if(A1)return;A1=!0;const e=()=>{if(document.visibilityState==="hidden"){Lu=!1,c_+=1,Fk(),ZO();return}Wk()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e)}function Kk(e){if(document.visibilityState!=="hidden"){if(!Lu||e?.heartbeatSuspended){Wk(e);return}e&&u_(e)}}function Wk(e){if(document.visibilityState==="hidden")return;Lu=!0;const t=++c_;Fk();const n=Array.from(Lr.values()).filter(u=>!u.exited&&u.reconnectEnabled&&u.status!=="unauthorized"),r=n.filter(u=>u===e||u.foregroundAttachments.size>0||o5(u)),o=new Set(r),c=n.filter(u=>!o.has(u));for(const u of r)u_(u);for(let u=0;u<c.length;u+=Dg){const m=c.slice(u,u+Dg),g=Math.floor(u/Dg)*WO,p=window.setTimeout(()=>{if(mf.delete(p),!(t!==c_||!Lu||document.visibilityState==="hidden"))for(const y of m)u_(y)},g);mf.add(p)}}function Fk(){for(const e of mf)window.clearTimeout(e);mf.clear()}function u_(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,$l(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<jO)return Promise.resolve("alive");Ys(e,"reconnecting"),Fa(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++FO).toString(36)}`;let o;const c=new Promise(m=>{o=m}),u={socket:t,nonce:r,timeout:0,promise:c,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(Do("terminal.connection.resume_timeout",e,{pendingInputs:La(e)}),Ys(e,"reconnecting"),Oa(e))},zk);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{Ys(e,"reconnecting"),Oa(e)}return c}function ZO(){Lu=!1;for(const e of Lr.values())e.heartbeatSuspended=!0,Ua(e),xs(e),Gs(e),Ka(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,Ys(e,"skipped"),Fa(e)}function QO(){Aa=!1,Rf()&&Nr(0);for(const e of Lr.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ua(e),xs(e),Gs(e),Ka(e),Ys(e,"reconnecting"),Fa(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),$l(e)}}function Ng(){for(const e of Array.from(Lr.keys()))ou(e)}function JO(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:pf,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function $l(e){if(!e.reconnectEnabled)return;Da(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,xs(e),Gs(e),Ka(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,Ua(e),xs(e),Da(e,"connected"),Ha(e,t),$k(e,t),e.isAlive=!0,L1(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let c=null;try{c=JSON.parse(o)}catch{return}if(!c||typeof c.type!="string")return;if(C5(c)){x5(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),Aa&&(Aa=!1,Rf()&&Nr(0));return}if(e.inputProtocolMode==="unknown"&&Yk(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),La(e)>0&&Do("terminal.connection.resume_alive",e,{pendingInputs:La(e)}),Ys(e,"alive"),Ha(e,t),L1(e),Ro(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(Bu(e),Do("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:La(e)}),Oa(e));return}if(c.type==="input_ack"){b5(e,t,c);return}if(c.type==="input_received"){y5(e,t,c);return}if(c.type==="error"&&S5(e,c),c.type==="input_ack_confirmed"){T5(e,c);return}const u=t5(e,c);if(Ou(e,{type:"message",message:u}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;Tb(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Ua(e),xs(e),Gs(e),Ka(e),Ys(e,"reconnecting"),Fa(e),r.code===1008){e.reconnectEnabled=!1,Da(e,e5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=IO)&&(e.lastUpgradeAuthProbeAt=o,Ou(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Da(e,"closed");return}Da(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,$l(e)},BO)}}),t.addEventListener("error",()=>{})}function L1(e){if(Fa(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>R1*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},R1)}function Fa(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function e5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function t5(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+Or(r),0),O1(e),e.exited&&$h(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Or(t.data),O1(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,$h(e)),t):(t.type==="exit"&&(e.exited=!0,$h(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function O1(e){for(;e.outputBytes>Eg&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Or(t)}e.outputBytes>Eg&&e.output.length===1&&(e.output[0]=D5(e.output[0],Eg),e.outputBytes=Or(e.output[0]))}function Da(e,t){e.status!==t&&(e.status=t,Ou(e,{type:"status",status:t}))}function Ou(e,t){for(const n of Array.from(e.listeners))n(t)}function La(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function i5(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function Do(e,t,n={}){gn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:La(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??i5(t)}),l_+=1,Fh=0,Nr(Uk)}function n5(){if(N1)return;N1=!0;const e=()=>{document.visibilityState==="hidden"||Aa||Rf()&&Nr(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Nr(e){if(Wh){bu=bu===null?e:Math.min(bu,e);return}Mg!==null||Aa||document.visibilityState==="hidden"||navigator.onLine===!1||(Mg=window.setTimeout(()=>{Mg=null,s5()},e))}async function s5(){if(Wh||Aa||document.visibilityState==="hidden"||navigator.onLine===!1)return;Wh=!0;const e=l_;try{const t=await qD();if(t.outcome==="auth_blocked"){Aa=!0;return}if(t.outcome==="retryable"){const n=M1[Math.min(Fh,M1.length-1)];Fh+=1,Nr(n);return}if(Fh=0,t.outcome==="sent"&&t.hasMore){Nr(0);return}}finally{Wh=!1;const t=bu;bu=null,t!==null&&Nr(t),l_!==e&&!Aa&&Nr(Uk)}}function r5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=v5(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=Or(o);if(c>zO)return"rejected";const u=n.durability!=="live-only",m={message:r,encoded:o,bytes:c,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:u};if(!_5(e,m))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(Do("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:La(e)}),Kk(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Hf))return!u&&r.type==="input"?"rejected":a5(e,r)?(p&&g&&Ha(e,g),"queued"):e.pendingOut.length>=a_||e.pendingOutBytes+c>o_?"rejected":(e.pendingOut.push(m),e.pendingOutBytes+=c,j1(e,m),p&&g&&Ha(e,g),"queued");if(p){j1(e,m);try{return g.send(o),Vk(e,m),"sent"}catch{if(b&&u&&e.pendingOut.length<a_&&e.pendingOutBytes+c<=o_)return e.pendingOut.push(m),e.pendingOutBytes+=c,g.close(),"queued";No(e,m),g.close()}}return"rejected"}function Ha(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){xs(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Hf){E5(e,t),c5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){$k(e,t);return}try{t.send(r.encoded),Vk(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=pf,n=!0}e.outboundFlushDelayMs=pf,xs(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&Ou(e,{type:"outbound_flushed"})})}function a5(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=Or(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function Ua(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=pf}function xs(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function gf(e){return e.pendingOut.some(t=>t.message.type==="input")}function o5(e){return gf(e)||e.unackedInputs.size>0}function l5(e){if(!gf(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function c5(e,t){e.outboundStallWatchdog!==null||!gf(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!gf(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Hf;if(!n&&!r){Ha(e,t);return}l5(e),Oa(e)},KO))}function Gs(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function $k(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&Oa(e)},HO))}function qk(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function Bu(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function Ka(e){qk(e),Bu(e)}function Ro(e){qk(e),d_(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=B1(e),r=u5(e),o=h5(e);if(n===null&&r===null&&o===null){Bu(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+PO,u=Math.max(0,Math.min(c,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(d_(e,{notifyImmediately:!0})){Ro(e);return}if(d5(e),B1(e)===null){Ro(e);return}f5(e,t)},u)}function u5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+Hk;t=t===null?r:Math.min(t,r)}return t}function d5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<Hk||(n.writeSlowReported=!0,Do("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function B1(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function h5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+Pk;t=t===null?r:Math.min(t,r)}return t}function f5(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Hf){Oa(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++$O).toString(36)}`;Do("terminal.input.delivery_probe_started",e,{pendingInputs:La(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(Do("terminal.input.delivery_probe_timeout",e,{pendingInputs:La(e)}),Bu(e),Oa(e))},zk);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{Bu(e),Oa(e)}}function Ys(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Oa(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ua(e),xs(e),Gs(e),Ka(e),Ys(e,"reconnecting"),Fa(e);const t=e.socket;e.socket=null,Da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),$l(e)}function p5(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ua(e),xs(e),Gs(e),Ka(e),Ys(e,"skipped"),Fa(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),$h(e),e.listeners.clear()}function m5(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function g5(){return Rg=(Rg+1)%Number.MAX_SAFE_INTEGER,`${VO}-${Rg.toString(36)}`.slice(0,IC)}function v5(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=g5();return n.length===0||n.length>IC?null:{...t,messageId:n}}function _5(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<a_&&e.unackedInputBytes+t.bytes<=o_)}function j1(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function No(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function b5(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&h_(e,t,c);return}if(No(e,r),Ro(e),!Eb(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),h_(e,t,o)}function y5(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",Ro(e))}function S5(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(No(e,n),Ro(e))}function Vk(e,t){if(t.message.type!=="input"||!t.message.messageId||!Eb(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",Ro(e)}function w5(e){if(d_(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){No(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function d_(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=Pk&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&No(e,u)}return o>0&&(Gk(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&Tb(e)),!0}function C5(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function x5(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){Yk(e,t);return}Gs(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(w5(e),k5(e,t)):c!==null&&(Xk(e),Zk(e)),Ha(e,t)}function Yk(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",Gs(e),e.serverInstanceId=null,Xk(e),Zk(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;No(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=Or(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}Ha(e,t)}}function Xk(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&No(e,o)}n>0&&Gk(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function Gk(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Tb(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)Ou(e,{type:"message",message:{type:"error",message:n.message}})}}function $h(e){Ua(e),xs(e),Gs(e),Ka(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function h_(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Eb(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Eb(e){return e==="ack"||e==="receipt-ack"}function k5(e,t){for(const n of e.pendingAckReceipts.values())if(h_(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function T5(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function Zk(e){e.pendingAckReceipts.clear()}function E5(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(UO,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Ha(e,t)},n)}function Or(e){return qO.encode(e).byteLength}function D5(e,t){if(Or(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);Or(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const R5=[0,50,150,350],M5=[100,300,750],N5=2,A5=[300,1200,2500],L5=1e3,O5=1e5,B5="",f_="\x1B[?1049l\x1B[?1047l\x1B[?47l",j5=new Set(["47","1047","1049"]),I5=400,z5=9,P5=9,H5=32,U5=1.42,K5=2,W5=24,F5=720,$5=60,q5=1260,V5=6,Y5=2,I1=[500,1500,3e3,5e3,8e3],z1=15e3,X5=2,G5=1e3,P1="Do not take action. Wait for my next input.",vf=6e4,Z5=vf+5*6e4,H1=vf+6e4,Q5=40,Th=240,J5=5e3,yu=new Map,wl=new Map;function U1({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:m,onSelect:g,onClose:p,onExit:y,onSnapshot:b,onAuthClose:k}){const w=v.useSyncExternalStore(sx,cv,()=>bo),S=v.useSyncExternalStore(rx,uv,()=>Ol),D=v.useSyncExternalStore(ax,hv,()=>!0),I=v.useSyncExternalStore(Lh,fv,()=>!0),L=v.useSyncExternalStore(Lh,pv,()=>!0),H=v.useSyncExternalStore(z_,Ba,()=>Ll),Y=v.useSyncExternalStore(mu,()=>gu("history.toggle"),()=>"Alt+H"),$=v.useSyncExternalStore(mu,()=>gu("scrollback.toggle"),()=>"Alt+S"),se=v.useSyncExternalStore(mu,()=>gu("subagents.toggle"),()=>"Alt+A"),J=v.useRef(null),F=v.useRef(null),xe=v.useRef(null),re=v.useRef(null),Ee=v.useRef(null),ie=v.useRef(e.id),V=v.useRef({onExit:y,onSnapshot:b}),X=v.useRef(t.createWebSocketUrl),W=v.useRef(k),le=v.useRef(null),O=v.useRef(null),M=v.useRef(null),B=v.useRef(!1),ae=v.useRef(new Map),we=v.useRef(new Map),N=v.useRef(new Set),U=v.useRef([]),ue=v.useRef(!1),Ce=v.useRef(null),Oe=v.useRef(0),De=v.useRef(!1),Be=v.useRef(!1),Ne=v.useRef(!1),Ue=v.useRef({terminalId:e.id,enabled:!1}),We=v.useRef([]),ne=v.useRef([]),pe=v.useRef(0),R=v.useRef(!1),q=v.useRef(null),fe=v.useRef(0),ge=v.useRef(0),Q=v.useRef(null),ke=v.useRef(null),de=v.useRef(!1),Re=v.useRef(!1),Ie=v.useRef(!1),je=v.useRef(null),Ye=v.useRef(!1),lt=v.useRef(null),Nt=v.useRef(null),yt=v.useRef(!1),Tt=v.useRef(!1),$e=v.useRef(!1),St=v.useRef(!1),Lt=v.useRef(!1),ye=v.useRef(!1),Xe=v.useRef(!1),rt=v.useRef(n),Ze=v.useRef(r),Et=v.useRef(c),ct=v.useRef(w),Tn=v.useRef(S),vi=v.useRef(!1),ee=v.useRef(!1),Pe=v.useRef(null),st=v.useRef(0),tt=v.useRef(0),kt=v.useRef(e.id),Xt=v.useRef(()=>{}),Wt=v.useRef(null),ui=v.useRef(null),Gt=v.useRef(!1),ri=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),di=v.useRef(0),Ft=v.useRef(null),cn=v.useRef(0),ti=v.useRef(null),Ui=v.useRef(0),vn=v.useRef(!1),_n=v.useRef(!1),ii=v.useRef(null),Ji=v.useRef(null),[,ai]=v.useState("connecting"),[_i,bi]=v.useState(!1),[Bn,Ir]=v.useState(null),[Oo,zr]=v.useState(!1),[Zs,ds]=v.useState(null),[Qs,hs]=v.useState(!1),[Es,fs]=v.useState(!1),[Ds,It]=v.useState(!1),[Bo,Pr]=v.useState(!1),[$t,jn]=v.useState(null),en=e.agentCache&&$t&&e.agentCache.source.provider===$t.provider&&e.agentCache.source.sessionId===$t.sessionId?e.agentCache:null,[Hr,jo]=v.useState(()=>Date.now()),[Js,ps]=v.useState(!1),[Ur,bn]=v.useState(null),[Ki,Rs]=v.useState(!1),[$a,ms]=v.useState(!1),[Wi,gs]=v.useState(null),[Ms,Oi]=v.useState(!1),[pt,vs]=v.useState(!1),[er,un]=v.useState(null),[Kr,qa]=v.useState(null),dn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Io,Wr]=v.useState(()=>ig(e.id)),_s=$t?.provider??e.agentStatus?.provider??null,Fr=_s!==null||Cl(e.currentCommand),zo=_s==="claude"||iT(e.currentCommand),Yl=_s!==null||Cl(e.currentCommand),bs=e.capabilities?.tmuxScrollback===!0,yi=bs&&(Io??(Yl?L:I)),[$r,Fi]=v.useState(!1);v.useLayoutEffect(()=>{rt.current=n},[n]),v.useLayoutEffect(()=>{Ze.current=r},[r]),v.useLayoutEffect(()=>{Et.current=c},[c]),v.useLayoutEffect(()=>{ct.current=w},[w]),v.useLayoutEffect(()=>{Tn.current=S},[S]),v.useLayoutEffect(()=>{vi.current=Ki},[Ki]),v.useLayoutEffect(()=>{ee.current=$a},[$a]),v.useLayoutEffect(()=>{Pe.current=$t},[$t]);const oi=v.useCallback((x,j={})=>{!x&&j.preserveOnNull||(Ch(Pe.current,x)||(tt.current+=1),Pe.current=x,jn(Te=>Te&&x&&Te.provider===x.provider&&Te.sessionId===x.sessionId?Te:x))},[]),Ns=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),tr=v.useCallback(()=>{const x=Pe.current,j=tt.current;x&&(async()=>{let Te=x;try{Te=await Ns()??Te}catch{}Te&&kt.current===e.id&&tt.current===j&&Ch(x,Pe.current)&&(oi(Te,{preserveOnNull:!0}),Wt.current=Og(e.id,Te),ms(!1),Rs(!0))})()},[oi,Ns,e.id]),Va=v.useCallback(()=>{Pe.current&&(Rs(!1),ms(!0))},[]),In=v.useCallback(async(x={})=>{const j=await W1(dn,t,x);return gs(j),j},[dn,t]),Si=v.useCallback((x,j="info")=>{ti.current!==null&&window.clearTimeout(ti.current),qa({id:cn.current++,message:x,tone:j}),ti.current=window.setTimeout(()=>{qa(null),ti.current=null},3200)},[]),qr=v.useCallback(()=>{const x=m?.serverKey.trim()||"local",j=m?.serverName.trim()||"Local",Te=m?.tabName.trim()||e.title||"Terminal",qe=Wi?.instances.find(ut=>ut.cwd===e.cwd);if(qe&&F1(Eh(x,qe.id))){Si("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(qe&&Ag(Eh(x,qe.id),qe.url)){Si("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ke=null;const et=()=>((!Ke||Jk(Ke))&&(Ke=window.open("about:blank","_blank"),eB(Ke)),Ke);Wi?.installed!==!0&&et(),vs(!0),un(null),(async()=>{let ut=Wi;if(ut?.installed||(ut=await In({force:!0})),!ut?.installed||ut.supported===!1){Lg(Ke),Oi(!0);return}const ft=ut.instances.find(Ot=>Ot.cwd===e.cwd);if(ft){const Ot=Eh(x,ft.id);if($1(Ke,Ot,ft.url)||Ag(Ot,ft.url)!==null){Si("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Ve=et();return{response:await t.openCodeServer({terminalId:e.id,serverName:j,tabName:Te}),targetPopup:Ve}})().then(ut=>{if(!ut)return;const{response:ft,targetPopup:Ve}=ut;p_(dn,ft.status),gs(ft.status);const qt=Eh(x,ft.instance.id);if(F1(qt)){Lg(Ve),Si("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}$1(Ve,qt,ft.url)||Ag(qt,ft.url)?Si("Opening VS Code..."):Si("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ut=>{Lg(Ke),Oi(!0),un(Dh(ut))}).finally(()=>vs(!1))},[m?.serverName,m?.tabName,dn,Wi,In,t,Si,e.cwd,e.id,e.title]);v.useEffect(()=>{let x=!1;return W1(dn,t).then(j=>{x||gs(j)}).catch(()=>{}),()=>{x=!0}},[dn,t]),v.useEffect(()=>{if(Wi?.job?.status!=="running")return;const x=window.setInterval(()=>{In({force:!0}).catch(j=>un(Dh(j)))},1e3);return()=>window.clearInterval(x)},[Wi?.job?.status,In]),v.useEffect(()=>()=>{ti.current!==null&&window.clearTimeout(ti.current)},[]),v.useLayoutEffect(()=>{Xt.current=tr},[tr]),v.useLayoutEffect(()=>{ui.current=en},[en]),v.useLayoutEffect(()=>{Gt.current=Js},[Js]),v.useLayoutEffect(()=>{vn.current=Fr},[Fr]),v.useLayoutEffect(()=>{_n.current=zo},[zo]),v.useLayoutEffect(()=>{const x=Ue.current;Be.current=yi,Ne.current=bs,Ue.current={terminalId:e.id,enabled:yi},V1(J.current,yi),x.terminalId===e.id&&x.enabled&&!yi&&Ga(),yi||It(!1)},[e.id,yi,bs]),v.useEffect(()=>{Wr(ig(e.id)),Oe.current=0,De.current=!1,It(!1),Xa()},[e.id]),v.useEffect(()=>Lh(()=>{Wr(ig(e.id))}),[e.id]),v.useEffect(()=>()=>{Wo()},[]),v.useEffect(()=>{Ee.current?.(r&&e.status==="running"),r&&e.status==="running"&&C()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&ys("auto")},[n,r,e.status]),v.useEffect(()=>{V.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{X.current=t.createWebSocketUrl,W.current=k},[t,k]),v.useLayoutEffect(()=>{ie.current=e.id,Xe.current=!1,Pr(!1)},[e.id]),v.useEffect(()=>{let x=!1,j=null,Te=0;const qe=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ke=qe||wB(e.currentCommand),et=qe||Cl(e.currentCommand);function ut(){j!==null&&(window.clearTimeout(j),j=null)}function ft(qt){if(x)return;let Ot;if(qt)Ot=z1;else if(Te<I1.length){if(!Ke)return;Ot=I1[Te++]}else{if(!et)return;Ot=z1}j=window.setTimeout(()=>{j=null,Ve()},Ot)}async function Ve(){try{const qt=Pe.current!==null,Ot=await Ns();if(x)return;if(Ot){st.current=0,oi(Ot),ft(!0);return}st.current+=1;const At=!!(qt&&Ke&&st.current<X5);oi(null,{preserveOnNull:At}),ft(At)}catch(qt){if(x)return;Bg(qt)&&oi(null),ft(!1)}}return kt.current!==e.id&&(kt.current=e.id,tt.current+=1,Pe.current=null,st.current=0,jn(null)),e.status!=="running"?(tt.current+=1,Pe.current=null,st.current=0,jn(null),()=>{x=!0,ut()}):(Ve(),()=>{x=!0,ut()})},[oi,Ns,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const x=Og(e.id,$t),j=Wt.current;j!==null&&x!==null&&j!==x&&(ke.current=null,de.current=!1,Re.current=!1,vi.current&&Rs(!1),ms(!1)),Wt.current=x},[e.id,$t?.provider,$t?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!$t){ps(!1);return}const x=window.setInterval(()=>{jo(Date.now())},G5);return()=>{window.clearInterval(x)}},[e.status,$t?.provider,$t?.sessionId]),v.useEffect(()=>{const x=nB(en);ri.current.key!==x&&(ri.current={key:x,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[en?.expiresAt,en?.source?.provider,en?.source?.sessionId]),v.useEffect(()=>{if(!Js||!en||en.status!=="ready")return;const x=eT(en,Hr);if(x===null||x<=0)return;const j=ri.current;!j.warnedFiveMinutes&&x<=Z5&&x>H1&&(j.warnedFiveMinutes=!0,Gn({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!j.warnedOneMinute&&x<=H1&&x>vf&&(j.warnedOneMinute=!0,Gn({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!j.sent&&!j.skipped&&x<=vf&&rc()},[Js,Hr,en,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function x(j){if(!rt.current||!Ze.current||j.isComposing||j.key==="Process"||aB(j.target))return;const Te=ux(j);if(Te?.id==="history.toggle"&&Pe.current){j.preventDefault(),j.stopPropagation(),vi.current?Rs(!1):Xt.current();return}if(Te?.id==="subagents.toggle"&&Pe.current){j.preventDefault(),j.stopPropagation(),ee.current?ms(!1):Va();return}if(Te?.id==="scrollback.toggle"&&Ne.current){j.preventDefault(),j.stopPropagation(),sc();return}}return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{const x=F.current;x&&(x.options.disableStdin=e.status==="exited"),e.status==="exited"&&ai("closed")},[e.status]),v.useEffect(()=>{const x=F.current;x&&(x.options.fontSize=w,tg(w,Tn.current).then(()=>{ct.current===w&&tn()}))},[w]),v.useEffect(()=>{const x=F.current;x&&(x.options.fontFamily=lv(S),tg(ct.current,S).then(()=>{Tn.current===S&&tn()}))},[S]),v.useEffect(()=>{const x=F.current;x&&(x.options.theme=K1(H))},[H]),v.useEffect(()=>{const x=J.current;if(!x)return;let j=!1,Te=null,qe=null,Ke=null,et=null,ut=null,ft=null,Ve=null;le.current=null,Lt.current=!1,ye.current=!1,Ye.current=!1,Gu(),Zu(),yn(),ue.current=!1;const qt=ct.current,Ot=Tn.current,At=new XL({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:lv(Ot),fontSize:qt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:O5,theme:{...K1(Ba())}}),js=new HM;return At.loadAddon(js),et=MO(At),F.current=At,xe.current=js,tg(qt,Ot).then(()=>{if(j)return;At.open(x),V1(x,Be.current),Lt.current=!0,Te=yO(At,{onPasteText:ep,onInterrupt:Jf,shouldInterruptPlainCtrlC:()=>_n.current}),Ze.current&&rt.current&&e.status==="running"&&ys("auto"),tn(),ut=DB(x,At,()=>ct.current*1.2,Bs,Is=>{hn(Is)},Ya,ar,()=>Be.current,Gr),ft=kB(x,At,Bs,Is=>{hn(Is)},Ya,ar,()=>Be.current,Gr);const Fo=new g3;qe=At.onData(Is=>{if(Xe.current){const oc=k3(Is);if(oc){Qa(!1),or(oc);return}}const ac=Fo.accept(Is);ac&&or(ac)}),Ke=At.onScroll(Is=>{if(Tt.current||St.current||$e.current){nn();return}Gl(),qn(At)&&rr({scrollToBottom:!0}),Bs(),!Be.current&&Is<=3&&hn()}),Ve=new ResizeObserver(()=>{me()}),Ve.observe(x),ye.current&&(sr(),ye.current=!1,tn()),Xl()}),()=>{rd(re.current,{updateUi:!1}),j=!0,Lt.current=!1,ye.current=!1,Gu(),Zu(),O.current=null,M.current=null,B.current=!1,Qu(),ue.current=!1,Ju(),$e.current=!1,R.current=!1,fe.current+=1,ge.current+=1,q.current=null,ii.current=null,Ji.current=null,Ie.current=!1,je.current=null,bi(!1),ut?.(),ft?.(),Ve?.disconnect(),Te?.dispose(),qe?.dispose(),Ke?.dispose(),et?.dispose(),At.dispose(),F.current=null,xe.current=null}},[e.id]),v.useEffect(()=>{const x=X.current(e.id),j=YO(x,ir);return re.current=j.send,Ee.current=j.setForeground,j.setForeground(Ze.current&&e.status==="running"),ai(j.status),j.status==="connected"&&tn(),j.snapshot&&(V.current.onSnapshot(j.snapshot,{notifyCompletion:!1}),F.current&&(tn(),As(j.output,j.history),tn())),()=>{rd(j.send,{updateUi:!1}),j.setForeground(!1),j.detach(),re.current=null,Ee.current=null}},[e.id,e.status]);function ir(x){if(x.type==="status"){ai(x.status),x.status==="unauthorized"&&W.current?.({source:"terminal-ws-1008",terminalId:e.id}),x.status==="connected"&&(tn(),Ho());return}if(x.type==="upgrade_rejected"){W.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(x.type==="outbound_flushed"){ue.current&&(ue.current=!1,Zr());return}z(x.message)}function yn(x=[],j=null){We.current=[],ne.current=Rh(x),pe.current=0,R.current=!1,q.current=null,$e.current=!1,fe.current+=1,Q.current=j,ke.current=null,de.current=!1,Re.current=!1,Ie.current=!1,je.current=null,ye.current=!1,ii.current=null,Ji.current=null,lt.current=null,yt.current=!1,bi(!1),Ir(null),zr(!1),ds(null),hs(!1),fs(!1)}function As(x=[],j=null){if($e.current||R.current){Ji.current={output:x,history:j,appendFromLiveOutputIndex:ne.current.length};return}yn(x,j),nr()}function Ls(){if($e.current||R.current)return!1;const x=Ji.current;if(!x)return!1;const j=ne.current.slice(x.appendFromLiveOutputIndex);return Ji.current=null,yn([...x.output,...j],x.history),nr(),!0}function nr(){if(!F.current||!Lt.current){ye.current=!0;return}ye.current=!1,sr()}async function sr(){const x=F.current;if(!x)return;const j=Mh(x,yt.current),Te=j?ne.current.length:pe.current,qe=await Os(x,{liveOutputLimit:Te,scrollToBottom:j});F.current===x&&(nn(),qe&&Ho())}function Os(x,j={}){return new Promise(Te=>{$e.current=!0,R.current=!1;const qe=fe.current+1;fe.current=qe;const Ke=Math.max(0,Math.min(j.liveOutputLimit??ne.current.length,ne.current.length)),et=j.historyPages??We.current,ut=()=>F.current===x&&fe.current===qe,ft=()=>ut()&&(j.isCurrent?.()??!0),Ve=()=>{ut()&&($e.current=!1),Te(!1)},qt=()=>{if(!ft()){Ve();return}try{pe.current=Ke,j.scrollToBottom&&Ko(x)}finally{if($e.current=!1,Ls()){Te(!1);return}const At=td();At?rr(At):j.applyDeferredSnapshot!==!1&&Ql(),Te(!0)}},Ot=()=>{if(!ft()){Ve();return}x.clear();const At=Rh([...et,...ne.current.slice(0,Ke)]);if(At.length===0){qt();return}for(let js=0;js<At.length;js+=1){const Fo=At[js];js===At.length-1?x.write(Fo,qt):x.write(Fo)}};if(x.buffer.active.type==="alternate"){x.write(f_,Ot);return}Ot()})}async function hn(x=0){const j=F.current;if(Ie.current||!j)return;if(Zl(j)){nn();return}const Te=Q.current,qe=ge.current,Ke=Symbol("history-load"),et=()=>F.current===j&&ge.current===qe;je.current=Ke,Ie.current=!0,bi(!0);const ut=j.buffer.active.viewportY;try{let ft=!!(Te&&!Te.hasMore);if(!ft)try{const Ve=await t.getTerminalHistory(e.id,{beforeLine:Te?.startLine??0,...Te?.snapshotHistorySize!==void 0?{snapshotHistorySize:Te.snapshotHistorySize}:{},...Te?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Te.snapshotHistoryLimit}:{},...Te?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Te.snapshotHistoryToken}:{},...Te?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Te.snapshotPaneWidth}:{},limit:L5});if(!et()||Q.current!==Te)return;const qt=()=>et()&&Q.current===Te;if(Ve.invalidated){E();return}const Ot=Ve.hasMore&&Ve.snapshotHistorySize!==void 0&&Ve.snapshotPaneWidth!==void 0,At={startLine:Ve.startLine,endLine:Ve.endLine,hasMore:Ot,...Ve.snapshotHistorySize!==void 0?{snapshotHistorySize:Ve.snapshotHistorySize}:{},...Ve.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ve.snapshotHistoryLimit}:{},...Ve.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ve.snapshotHistoryToken}:{},...Ve.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ve.snapshotPaneWidth}:{}};if(Ve.output.length>0){await Xn(j,Ve.output,ut,x)&&qt()&&(Q.current=At);return}if(!qt())return;Q.current=At,ft=!Ot}catch(Ve){ft=et()&&Bg(Ve)}if(ft){if(!et()||Zl(j)){nn();return}await ki(j,ut,x,et)}}catch{}finally{je.current===Ke&&(je.current=null,Ie.current=!1,bi(!1))}}async function ki(x,j,Te,qe){if(!qe()||de.current||Re.current)return;const Ke=Pe.current,et=tt.current,ut=ke.current,ft=()=>qe()&&tt.current===et&&Ch(Ke,Pe.current)&&ke.current===ut;try{const Ve=await t.getTerminalTranscriptHistory(e.id,{...ut?{cursor:ut}:{},limit:I5}),qt=Ve.output.map(hk);if(!Ve.source||Ve.terminalId!==e.id||!ft())return;if(Ke&&!wb(Ke,Ve.source)){ke.current=null,de.current=!1,Re.current=!1,oi(Ve.source);return}if(qt.length===0){oi(Ve.source),ke.current=Ve.cursor,Re.current=!Ve.hasMore||!Ve.cursor;return}await Xn(x,qt,j,Te,ft)&&ft()&&(oi(Ve.source),ke.current=Ve.cursor,Re.current=!Ve.hasMore||!Ve.cursor)}catch(Ve){ft()&&Bg(Ve)&&(de.current=!0)}}async function Xn(x,j,Te,qe,Ke){if(Zl(x)||Ke&&!Ke())return nn(),!1;const et=We.current,ut=[...j,...et],ft=CB(j),Ve=fe.current+1,qt=await Os(x,{liveOutputLimit:pe.current,scrollToBottom:!1,historyPages:ut,applyDeferredSnapshot:!1,...Ke?{isCurrent:Ke}:{}}),Ot=Ke!==void 0&&!Ke();return!qt||Ot||F.current!==x?(Ot&&F.current===x&&fe.current===Ve&&await Os(x,{liveOutputLimit:pe.current,scrollToBottom:!1,historyPages:et,applyDeferredSnapshot:!1})&&F.current===x&&(Jl(x,Te),yt.current=!qn(x),Bs()),!1):(We.current=ut,Jl(x,Math.max(0,Te+ft+Math.min(0,qe))),yt.current=!qn(x),Bs(),!0)}v.useEffect(()=>{const x=window.visualViewport;function j(){document.visibilityState!=="hidden"&&C()}function Te(){C()}function qe(){C()}function Ke(){me()}function et(){Qe()}return document.addEventListener("visibilitychange",j),window.addEventListener("pageshow",Te),window.addEventListener("online",qe),window.addEventListener("resize",Ke),window.addEventListener(hf,et),x?.addEventListener("resize",Ke),x?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("pageshow",Te),window.removeEventListener("online",qe),window.removeEventListener("resize",Ke),window.removeEventListener(hf,et),x?.removeEventListener("resize",Ke),x?.removeEventListener("scroll",Ke)}},[e.id]);function C(){document.visibilityState==="hidden"||!Ze.current||(Ho(),tn())}function E(){const x=X.current(e.id);ge.current+=1,Ye.current=!0,ii.current=null,ai("reconnecting"),tn(),XO(x)}function z(x){if(x.type==="snapshot"&&x.terminal.id===e.id){ge.current+=1,V.current.onSnapshot(x.terminal,{notifyCompletion:!1});const Te=Ye.current;Ye.current=!1;const qe=F.current;if(!qe)return;if(tn(),Te){oe(x.output,x.history??null);return}if(Vf(qe,x.terminal)){Xf(x.output,x.history??null),nn(),tn();return}As(x.output,x.history??null),tn();return}if(x.type==="terminal_updated"&&x.terminal.id===e.id){V.current.onSnapshot(x.terminal,{notifyCompletion:!0});return}if(x.type==="output"&&x.terminalId===e.id){const Te=nT(x.data);if(!Te)return;ne.current.push(Te),F.current&&Lt.current?rr({scrollToBottom:!0}):ye.current=!0;return}const j=F.current;if(j){if(x.type==="exit"&&x.terminalId===e.id){V.current.onExit(x.exitCode),ai("closed");return}x.type==="error"&&j.writeln(`\r
|
|
52
|
-
[nterminal] ${x.message}`)}}function oe(x,j){As(x,j),tn()}function Se(x=25){if(document.visibilityState==="hidden"||!Ze.current||ae.current.has(x))return;const j=window.setTimeout(()=>{ae.current.delete(x),!Me()&&Gf()},x);ae.current.set(x,j)}function me(){Me()||Xl()}function Me(){const x=Zt();return x&&vt(x)?(B.current=!0,M.current=x,!0):x&&Ti(x)?(B.current=!1,M.current=null,!0):((!x||!x.composeOpen&&!x.keyboardVisible)&&(B.current=!1,M.current=null),!1)}function Qe(){if(!B.current)return;const x=Zt();x&&(x.composeOpen||x.keyboardVisible)||(B.current=!1,M.current=null)}function vt(x){if(!x.mobileLike||!x.composeOpen&&!x.keyboardVisible)return!1;const j=O.current;return j?Yr(x.windowWidth,j.windowWidth)&&Yr(x.visualViewportWidth,j.visualViewportWidth)&&Yr(x.containerWidth,j.containerWidth):!1}function Ti(x){if(!x.mobileLike||x.composeOpen||x.keyboardVisible)return!1;const j=M.current;return!j||!j.composeOpen&&!j.keyboardVisible?!1:Yr(x.windowWidth,j.windowWidth)&&Yr(x.visualViewportWidth,j.visualViewportWidth)&&Yr(x.containerWidth,j.containerWidth)}function Zt(){const x=J.current;if(!x||x.isConnected===!1)return null;const j=x.getBoundingClientRect(),Te=Po(window.innerWidth)??0,qe=Po(window.visualViewport?.width)??Te,Ke=Po(j.width)??Po(x.clientWidth)??Te;if(Te<=0||qe<=0||Ke<=0)return null;const{keyboardVisible:et}=i_(),ut=document.documentElement.hasAttribute(If),ft=Vr()||et;return{windowWidth:Te,visualViewportWidth:qe,containerWidth:Ke,composeOpen:ut,keyboardVisible:et,mobileLike:ft}}function Vr(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Ff(){return i_().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Po(x){return typeof x=="number"&&Number.isFinite(x)&&x>0?x:null}function Yr(x,j){return Math.abs(x-j)<=N5}function Xl(){for(const x of R5)Se(x)}function tn(){le.current=null,Xl()}function Ho(){if(Uo(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const x=window.requestAnimationFrame(()=>{N.current.delete(x),Uo();const j=window.requestAnimationFrame(()=>{N.current.delete(j),Uo()});N.current.add(j)});N.current.add(x)}for(const x of M5){if(we.current.has(x))continue;const j=window.setTimeout(()=>{we.current.delete(x),Uo()},x);we.current.set(x,j)}}function Uo(){const x=F.current;if(!(!x||!Lt.current||document.visibilityState==="hidden"||!Ze.current||J.current?.isConnected===!1))try{x.refresh(0,Math.max(0,x.rows-1))}catch{}}function Gu(){for(const x of ae.current.values())window.clearTimeout(x);ae.current.clear()}function Zu(){for(const x of we.current.values())window.clearTimeout(x);we.current.clear();for(const x of N.current)window.cancelAnimationFrame(x);N.current.clear()}function Qu(){for(const x of U.current)window.clearTimeout(x);U.current=[]}function Bs(){if(nn(),!lt.current){zr(!1);return}zr(!0),Ju(),Nt.current=window.setTimeout(()=>{Nt.current=null,zr(!1)},1200)}function nn(){const x=F.current,j=x?xB(x):null;if(lt.current=j,Ir(j),fs(!!(x&&j)),hs(!!(x&&j&&!qn(x))),j||!x||!$f()){ds(null);return}ds({alternate:x.buffer.active.type==="alternate"})}function $f(){const x=Q.current;return We.current.length>0||!!x?.hasMore}function Ju(){Nt.current!==null&&(window.clearTimeout(Nt.current),Nt.current=null)}function Gl(){const x=F.current;x&&(yt.current=!qn(x),nn())}function ed(x){q.current=jg(q.current,x)}function qf(x){const j=q.current;return q.current=null,jg(j,x)}function td(){const x=q.current;return q.current=null,x}function rr(x={}){const j=F.current;if(!j||!Lt.current){ye.current=!0;return}if(ii.current&&!$e.current&&!R.current&&qn(j)){Ql();return}if($e.current){ed(x);return}if(R.current){ed(x);return}const Te=qf(x);if(!Te.force&&!Mh(j,yt.current)){nn();return}R.current=!0;const qe=fe.current,Ke=()=>{if(F.current!==j||fe.current!==qe)return;if(!Te.force&&!Mh(j,yt.current)){if(R.current=!1,Ls())return;nn();return}const et=pe.current,ut=ne.current[et];if(ut===void 0){if(R.current=!1,Ls())return;Te.scrollToBottom&&Ko(j),nn();const ft=td();ft?rr(jg(Te,ft)):Ql();return}j.write(ut,()=>{F.current!==j||fe.current!==qe||(pe.current=et+1,Ke())})};Ke()}function Zl(x){return ii.current!==null||!qn(x)&&(Yf()||R.current||$e.current)}function Vf(x,j){return(j?.agentStatus?.provider==="codex"||j?.agentStatus?.provider==="claude"||vn.current||Cl(j?.currentCommand))&&!qn(x)}function Yf(){return pe.current<ne.current.length}function Xf(x,j){ii.current={output:x,history:j,appendFromLiveOutputIndex:ne.current.length}}function Ql(){const x=F.current,j=ii.current;if(!x||!j||!qn(x)||R.current||$e.current)return;const Te=Rh(j.output),qe=Rh(ne.current.slice(j.appendFromLiveOutputIndex));ii.current=null,As([...Te,...qe],j.history),tn()}function Ya(){St.current=!0}function ar(){Gl(),St.current=!1;const x=F.current;x&&qn(x)&&rr({scrollToBottom:!0})}function Ko(x){ec(()=>Y1(x))&&(yt.current=!1)}function Jl(x,j){ec(()=>(x.scrollToLine(j),!0))}function ec(x){Tt.current=!0;try{return x()}finally{Tt.current=!1}}function id(){const x=F.current;if(!x)return;const j=()=>{Be.current&&(Za(re.current),It(!1)),Y1(x),yt.current=!1,nn(),rr({force:!0,scrollToBottom:!0}),ys("scroll-action")};if(x.buffer.active.type==="alternate"){x.write(f_,j);return}j()}function tc(x){const j=F.current,Te=J.current;if(!j||!Te)return;const qe=Te.getBoundingClientRect();if(qe.height<=0)return;const Ke=Math.max(0,Math.min(1,(x-qe.top)/qe.height)),et=Math.round(j.buffer.active.baseY*Ke);Ya();try{j.scrollToLine(et)}finally{ar()}yt.current=!qn(j),nn(),Bs(),et<=3&&hn()}function nd(x){x.preventDefault(),x.stopPropagation(),x.currentTarget.setPointerCapture?.(x.pointerId),tc(x.clientY)}function Xr(x){(x.buttons&1)!==0&&(x.preventDefault(),x.stopPropagation(),tc(x.clientY))}function Gf(){const x=F.current,j=xe.current;if(!(!x||!j)&&!(document.visibilityState==="hidden"||!Ze.current||J.current?.isConnected===!1))try{const Te=Mh(x,yt.current),qe=Zt();j.fit(),qe&&(O.current=qe),Te&&Ko(x),x.refresh(0,Math.max(0,x.rows-1)),nn();const Ke={cols:x.cols,rows:x.rows},et=le.current;if(et&&et.cols===Ke.cols&&et.rows===Ke.rows)return;ic({type:"resize",terminalId:e.id,cols:Ke.cols,rows:Ke.rows})&&(le.current=Ke)}catch{}}function sd(x,j){const Te=re.current;return Te?Te(x,j):"rejected"}function ic(x){return sd(x)!=="rejected"}function Xa(){Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null)}function nc(){Xa();const x=Math.max(-Th,Math.min(Th,Oe.current));if(Oe.current=0,x===0)return!1;const j=ic({type:"scrollback_scroll",terminalId:e.id,lines:x});return j&&(De.current=!0,x<0&&It(!0)),j}function Gr(x){if(!Be.current||x===0)return;const j=Oe.current+x;Oe.current=Math.max(-Th,Math.min(Th,j)),Ce.current===null&&(Ce.current=window.setTimeout(()=>{Ce.current=null,nc()},Q5))}function Ga(){Za(re.current)}function rd(x=re.current,j={}){const Te=De.current;Xa(),Oe.current=0,De.current=!1,j.updateUi!==!1&&It(!1),Te&&x?.({type:"cancel_scrollback",terminalId:e.id})}function Za(x){Xa(),Oe.current=0,De.current=!1,It(!1),x?.({type:"cancel_scrollback",terminalId:e.id})}function sc(){if(!Ne.current)return;const x=!Be.current;Wr(ZR(ie.current,x)),Qf()}function ad(){const x=!Gt.current;Gt.current=x,ps(x),Gn({tone:x?"info":"skipped",message:x?"Cache keep-alive enabled":"Cache keep-alive off",...x?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Wo(){Ft.current!==null&&(window.clearTimeout(Ft.current),Ft.current=null)}function Gn(x,j={}){Wo();const Te=di.current+1;di.current=Te,bn({...x,id:Te}),!j.sticky&&(Ft.current=window.setTimeout(()=>{Ft.current=null,bn(qe=>qe?.id===Te?null:qe)},12e3))}function od(){ri.current.skipped=!0,Gn({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function ld(){Gt.current=!1,ps(!1),Gn({tone:"skipped",message:"Cache keep-alive off"})}async function rc(){const x=ri.current;if(x.sent||x.skipped)return;const j=Zf();if(x.sent=!0,j){Gn({tone:"skipped",message:"Skipped cache keep-alive",detail:j});return}if(or(`${P1}\r`,{userInitiated:!1})==="rejected"){Gn({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Gn({tone:"success",message:"Cache keep-alive sent",detail:P1})}function Zf(){const x=ui.current,j=Pe.current;return Gt.current?e.status!=="running"?"Pane is not running.":!x||x.status!=="ready"||!x.source||!j?"Transcript cache status is unavailable.":x.source.provider!==j.provider||x.source.sessionId!==j.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Eo(j.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Ml(e.id).text.trim()?"Compose has an unsent draft.":oB(J.current)?"Pane input is focused.":Date.now()-Ui.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function Qf(){const x=F.current;x&&(Ko(x),nn())}function or(x,j={}){nc();const Te=De.current;rr({force:!0,scrollToBottom:!0});const qe=sd({type:"input",terminalId:e.id,data:x,...Te?{cancelScrollbackMode:!0}:{}},{durability:j.userInitiated===!1?"live-only":"durable"});return qe==="rejected"?(j.userInitiated!==!1&&Si("Input was not sent because the terminal connection buffer is full or unavailable.","error"),qe):(j.userInitiated!==!1&&(Ui.current=Date.now()),Te&&(De.current=!1,It(!1)),SB(x)&&(qe==="sent"?Zr():qe==="queued"&&(ue.current=!0)),qe)}function Jf(){Xe.current&&Qa(!1),or(B5)}function ep(x){const j=wg(x,{bracketedPasteMode:F.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});j&&or(j)}function Sn(x,j){const Te=F.current?.modes.bracketedPasteMode===!0,qe=_s==="codex"||_s==="claude"||Cl(e.currentCommand),Ke=x.parts.map(et=>et.kind==="image"&&qe?wg(et.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):wg(et.kind==="image"?et.path:et.value,{bracketedPasteMode:Te,stripTrailingLineBreaks:!1})).join("");return Ke?or(`${Ke}${J3(j)}`)!=="rejected":!1}function Zr(){!Et.current||!rt.current||(Qu(),U.current=A5.map(x=>{const j=window.setTimeout(()=>{U.current=U.current.filter(Te=>Te!==j),Et.current&&rt.current&&ic({type:"refresh_cwd",terminalId:e.id})},x);return j}))}function ys(x="terminal-interaction"){vi.current||Ff()&&(x==="auto"||x==="scroll-action")||F.current?.focus()}const cd=v.useCallback(()=>{Rs(!1)},[]),ud=v.useCallback(async()=>{const x=Pe.current,j=tt.current;try{const Te=await t.getTerminalTranscriptSource(e.id);if(!Te.source||kt.current!==e.id||tt.current!==j||!Ch(x,Pe.current))return;ke.current=null,de.current=!1,Re.current=!1,oi(Te.source),Wt.current=Og(e.id,Te.source)}catch{}},[oi,t,e.id]);function dd(){Pr(x=>{const j=!x;return Xe.current=j,j}),ys("input-action")}function Qa(x){Xe.current=x,Pr(x)}function tp(x){Xe.current&&Qa(!1),or(x3(x)),ys("input-action")}async function lr(x="install"){vs(!0),un(null);try{const j=x==="update"?await t.updateCodeServer():await t.installCodeServer();p_(dn,j.status),gs(j.status)}catch(j){un(Dh(j))}finally{vs(!1)}}return f.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":yi?"true":"false",onMouseDown:()=>{n||g()},children:[f.jsx(lB,{terminal:e,canClose:o,tabId:u,transcriptSource:$t,transcriptShortcutLabel:Y,subagentsShortcutLabel:se,transcriptCacheStatus:en,transcriptCacheNow:Hr,cacheKeepAliveEnabled:Js,codeServerAvailable:!0,codeServerInstallState:Wi===null?"unknown":Wi.installed?"installed":"missing",codeServerBusy:pt||Wi?.job?.status==="running",codeServerSupported:Wi?.supported!==!1,scrollbackShortcutLabel:$,tmuxScrollbackSupported:bs,tmuxScrollbackEnabled:yi,onToggleCacheKeepAlive:ad,onOpenCodeServer:qr,onToggleTmuxScrollback:sc,onOpenTranscript:tr,onOpenSubagents:Va,onReload:E,onClose:p}),f.jsx("div",{className:"xterm-container",ref:J}),_i?f.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:f.jsx("span",{"aria-hidden":"true"})}):null,D&&!yi&&Bn?f.jsxs("div",{className:"terminal-scroll-progress","data-active":Oo,"aria-hidden":"true",children:[Bn.current,"/",Bn.total]}):D&&!yi&&Zs?f.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Zs.alternate?"alternate":"normal","aria-hidden":"true",children:[Zs.alternate?"alt ":"","0/?"]}):null,Qs||yi&&Ds?f.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),id()},children:"↓"}):null,Es&&!yi?f.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:nd,onPointerMove:Xr,children:f.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?$r?f.jsx(w3,{ctrlActive:Bo,onCtrl:dd,onStandaloneKey:tp,onPreserveFocus:()=>ys("input-action"),onHide:()=>Fi(!1)}):f.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:x=>{x.stopPropagation(),ys("input-action")},onPointerDown:x=>{x.stopPropagation(),ys("input-action")},onClick:()=>Fi(!0),children:"⌨"}):null,f.jsx(cO,{terminalId:e.id,onSubmit:Sn,onUploadAttachments:(x,j)=>t.uploadComposeAttachments({terminalId:e.id,files:x,signal:j.signal,onProgress:j.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:x=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:x})}:{},queueAvailable:_s==="codex"||tT(e.currentCommand),disabled:e.status!=="running"}),f.jsx(hB,{toast:Ur,onSendNow:()=>{rc()},onSkipOnce:od,onTurnOff:ld,onDismiss:()=>bn(null)}),Ki&&$t?f.jsx(fB,{terminalId:e.id,serverApi:t,source:$t,fontSize:w,onClose:cd,onReloadLatest:ud}):null,$a&&$t?f.jsx(l3,{terminalId:e.id,serverApi:t,source:$t,fontSize:w,onClose:()=>ms(!1)}):null,Kr?f.jsx(uB,{notice:Kr}):null,Ms?f.jsx(cB,{status:Wi,busy:pt,error:er,onInstall:()=>{lr("install")},onUpdate:()=>{lr("update")},onOpen:qr,onRefresh:()=>{In({checkLatest:!0}).catch(x=>un(Dh(x)))},onClose:()=>Oi(!1)}):null]})}function K1(e){return s2(e)}async function W1(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=wl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=J5)return u.status;if(u?.inflight&&(!r||u.inflightCheckLatest))return u.inflight;let m;return m=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(p_(e,g),g)).catch(g=>{const p=wl.get(e);throw p?.inflight===m&&(p.status?wl.set(e,{status:p.status,fetchedAt:p.fetchedAt}):wl.delete(e)),g}),wl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:r}),m}function p_(e,t){wl.set(e,{status:t,fetchedAt:Date.now()})}function Eh(e,t){return`${e}:${t}`}function Qk(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function F1(e){const t=yu.get(e);if(!t)return!1;try{return t.closed?(yu.delete(e),!1):(t.focus(),!0)}catch{return yu.delete(e),!1}}function Ag(e,t){const n=window.open(t,Qk(e));if(!n)return null;yu.set(e,n);try{n.focus()}catch{}return n}function $1(e,t,n){if(!e||Jk(e))return!1;try{return e.name=Qk(t),e.location.href=n,yu.set(t,e),e.focus(),!0}catch{return!1}}function eB(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function Jk(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Lg(e){if(e)try{e.closed||e.close()}catch{}}function tB(e,t,n){const r=iB(e,t),o=q1(r*Math.max(1,n),$5,q5);return{limit:q1(Math.ceil(o/K5),W5,F5),maxLines:o}}function iB(e,t){const n=e?.clientHeight??0;if(n<=0)return H5;const r=Math.max(10,t*U5);return Math.max(1,Math.floor(n/r))}function q1(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function nB(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Og(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function eT(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function sB(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function rB(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),u=r%24;return u>0?`${c}d ${u}h`:`${c}d`}function aB(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Dh(e){return e instanceof Ln||e instanceof Error?e.message:"Something went wrong."}function oB(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function lB({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:m,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:y,codeServerBusy:b,codeServerSupported:k,scrollbackShortcutLabel:w,tmuxScrollbackSupported:S,tmuxScrollbackEnabled:D,onToggleCacheKeepAlive:I,onOpenCodeServer:L,onToggleTmuxScrollback:H,onOpenTranscript:Y,onOpenSubagents:$,onReload:se,onClose:J}){const F=LC({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),xe={cursor:n?"grab":"default",opacity:F.isDragging?.5:void 0};return f.jsxs("header",{ref:F.setNodeRef,className:"terminal-pane-header",style:xe,"data-dragging":F.isDragging,...F.attributes,...F.listeners,children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),f.jsx("span",{className:"terminal-pane-spacer"}),p?f.jsx("button",{type:"button",className:"terminal-pane-code","data-state":y,"data-busy":b?"true":"false",disabled:!k||b,title:y==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":y==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),L()},children:f.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?f.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${Eo(r.provider)} transcript history`,"aria-label":`View ${Eo(r.provider)} transcript history`,onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),Y()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View history"}),f.jsx("span",{className:"pane-button-label-short",children:"History"}),f.jsx("kbd",{children:o})]}):null,r?f.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),$()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View agents"}),f.jsx("span",{className:"pane-button-label-short",children:"Agents"}),f.jsx("kbd",{children:c})]}):null,r?f.jsx(dB,{status:u,now:m,keepAliveEnabled:g,onToggle:I}):null,e.status==="exited"?f.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,S&&e.status==="running"?f.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":D?"true":"false","aria-pressed":D,"aria-label":`Toggle tmux scrollback (${w})`,title:D?`Scroll input uses tmux scrollback (${w}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${w}).`,onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),H()},children:[D?f.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.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"}),f.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"})]}):f.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.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"}),f.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),f.jsx("kbd",{children:w})]}):null,e.status==="running"?f.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),se()},children:"↻"}):null,t?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),J()},children:"x"}):null]})}function cB({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:m}){const g=e?.job??null,p=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,k=e===null&&t,w=e?.updateAvailable===!0,S=y?"VS Code add-on":"Install VS Code add-on";return f.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":S,onClick:m,children:f.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{children:[f.jsx("h2",{children:S}),f.jsx("p",{children:k?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),f.jsxs("div",{className:"code-server-dialog-scroll",children:[f.jsxs("div",{className:"code-server-dialog-body",children:[f.jsxs("p",{children:["NTerminal installs code-server under ",f.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),k?f.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:f.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?f.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?f.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[f.jsxs("div",{className:"code-server-progress-heading",children:[f.jsx("span",{children:g.action}),f.jsx("strong",{children:g.status})]}),f.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
53
|
-
`):"Preparing..."})]}):null]}),f.jsxs("div",{className:"code-server-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!b,children:"Check"}),y?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:w?"Update":"Reinstall"}),f.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):f.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function uB({notice:e}){return f.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function dB({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=eT(e,t),c=sB(e,o),u=o===null?"?":rB(o),m=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return f.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:m,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[f.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),f.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),f.jsx("span",{children:u})]})}function hB({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return f.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[f.jsxs("header",{children:[f.jsx("strong",{children:e.message}),f.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?f.jsx("p",{children:e.detail}):null,c?f.jsxs("div",{className:"cache-keepalive-toast-actions",children:[f.jsx("button",{type:"button",onClick:t,children:"Send now"}),f.jsx("button",{type:"button",onClick:n,children:"Skip once"}),f.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const fB=Ai.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const m=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),k=v.useRef(""),w=v.useRef(null),S=v.useRef(null),[D,I]=v.useState([]),[L,H]=v.useState(!1),[Y,$]=v.useState(""),[se,J]=v.useState(-1),[F,xe]=v.useState(!1),[re,Ee]=v.useState(-1),[ie,V]=v.useState(null),[X,W]=v.useState(null),[le,O]=v.useState(!1),[M,B]=v.useState(!0),[ae,we]=v.useState(!1),[N,U]=v.useState(null),[ue,Ce]=v.useState(!1);v.useEffect(()=>{function ye(Xe){Xe.key==="Escape"&&(Xe.preventDefault(),Xe.stopPropagation(),c())}return document.addEventListener("keydown",ye,!0),()=>document.removeEventListener("keydown",ye,!0)},[c]),v.useEffect(()=>{g.current+=1;const ye=g.current;return p.current=!1,y.current=!0,b.current=null,w.current=null,S.current=null,I([]),W(null),O(!1),U(null),Ce(!1),J(-1),Ee(-1),V(null),Ye(null,"initial",ye),()=>{g.current===ye&&(g.current+=1)}},[n,L,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ye=m.current;if(!ye)return;if(y.current){if(M||D.length===0)return;y.current=!1;const rt=()=>{ye.scrollTop=ye.scrollHeight};rt(),window.requestAnimationFrame?.(rt);return}const Xe=b.current;Xe!==null&&(b.current=null,ye.scrollTop+=ye.scrollHeight-Xe)},[D,M,L]);const Oe=Eo(r.provider),De=cf(D,L),Be=dk(De),Ne=pB(Be),Ue=Ne.map(ye=>ye.key).join(""),We=ie?Ne.find(ye=>ye.key===ie)?.entryIndex??null:null,ne=Y.trim().length>0,pe=e3(Be,Y),R=pe.length,q=R>0?se>=0&&se<R?se:0:-1,fe=q>=0?pe[q]?.entryIndex??null:null,ge=q>=0?pe[q]??null:null,Q=ne?fe:We,ke=ne?fe===null?null:"search":We===null?null:"prompt",de=De?De.split(`
|
|
54
|
-
`).length-1:0,Re=Ne.length>0&&re>=0&&re<Ne.length?re:Ne.length-1,Ie=ie??(Re>=0?Ne[Re]?.key??null:null),je=ne?R>0?`${q+1}/${R} ${R===1?"match":"matches"} · ${de} ${de===1?"line":"lines"}`:`0 matches · ${de} ${de===1?"line":"lines"}`:Ne.length>0?`${Re+1}/${Ne.length} prompts · ${de} ${de===1?"line":"lines"}`:`0 prompts · ${de} ${de===1?"line":"lines"}`;v.useEffect(()=>{const ye=Y.trim().toLowerCase();J(Xe=>!ye||R===0?-1:k.current!==ye?0:Xe>=0&&Xe<R?Xe:0),k.current=ye},[Y,R]),v.useEffect(()=>{if(ne){V(null);return}ie&&!Ne.some(ye=>ye.key===ie)&&V(null),Ee(ye=>{if(Ne.length===0)return S.current=null,-1;const Xe=S.current?Ne.findIndex(Ze=>Ze.key===S.current):-1,rt=Xe>=0?Xe:ye>=0&&ye<Ne.length?ye:Ne.length-1;return S.current=Ne[rt]?.key??null,rt})},[ie,ne,Ue]),v.useEffect(()=>{const ye=w.current;if(!ye||Ne.length===0)return;w.current=null;const Xe=ye.anchorKey?Ne.findIndex(Ze=>Ze.key===ye.anchorKey):-1,rt=Xe>0?Xe-1:0;$e(rt)},[Ue]);async function Ye(ye,Xe,rt=g.current){if(!p.current){p.current=!0,Xe==="initial"?B(!0):(we(!0),b.current=m.current?.scrollHeight??null),U(null);try{await lt(ye,Xe,rt)}catch(Ze){if(g.current!==rt)return;U(Ze instanceof Error?Ze.message:"Failed to load transcript history.")}finally{g.current===rt&&(p.current=!1,B(!1),we(!1))}}}async function lt(ye,Xe,rt){let Ze=ye,Et=0,ct=[];const Tn=Xe==="initial"&&r.provider!=="claude"?Y5:V5;for(;g.current===rt;){const vi=await n.getTerminalTranscriptHistory(t,{...Ze?{cursor:Ze}:{},...tB(m.current,o,Xe==="initial"?z5:P5),includeTools:L});if(g.current!==rt)return;if(!vi.source){U("Transcript source is temporarily unavailable.");return}if(!wb(r,vi.source)){Ce(!0),O(!1);return}const ee=t_(vi.output,r.provider,{includeTools:L}),Pe=Nt(vi,Xe,ct,ee);if(ee&&(ct=[ee,...ct],Pe))return;if(!vi.hasMore||!vi.cursor||Et>=Tn){ct.length>0&&I(st=>Xe==="older"?[...ct,...st]:ct);return}Ze=vi.cursor,Et+=1}}function Nt(ye,Xe,rt,Ze=t_(ye.output,r.provider,{includeTools:L})){if(W(ye.cursor),O(!!(ye.hasMore&&ye.cursor)),!Ze)return!1;const Et=[Ze,...rt];return cf(Et,L)?(I(ct=>Xe==="older"?[...Et,...ct]:Et),!0):!1}function yt(){const ye=m.current;ye&&(Lt(),!(ye.scrollTop>72||!le||!X||p.current)&&Ye(X,"older"))}function Tt(ye){R!==0&&J(Xe=>{const rt=q>=0?q:ye>0?-1:0;return((Xe>=0&&Xe<R?Xe:rt)+ye+R)%R})}function $e(ye){const Xe=Ne[ye];Xe&&(S.current=Xe.key,Ee(ye),V(Xe.key))}async function St(ye){if(Ne.length===0){ye<0&&le&&X&&!p.current&&(w.current={anchorKey:null},await Ye(X,"older"));return}const rt=(re>=0&&re<Ne.length?re:ye<0?Ne.length-1:-1)+ye;if(rt>=0&&rt<Ne.length){$e(rt);return}ye<0&&rt<0&&le&&X&&!p.current&&(w.current={anchorKey:Ne[0]?.key??null},await Ye(X,"older"))}function Lt(){if(ne)return;const ye=m.current;if(!ye)return;const rt=ye.getBoundingClientRect().top+Math.min(140,Math.max(48,ye.clientHeight*.28));let Ze=null;for(const Et of bB(ye)){const ct=yB(Et);if(ct!==null)if(Et.getBoundingClientRect().top<=rt)Ze=ct;else break}if(Ze!==null){const Et=Ne[Ze]?.key??null;S.current=Et,Ee(Ze),ie&&ie!==Et&&V(null)}}return f.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>{ye.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>ye.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"transcript-dialog-title",children:[Oe," JSONL"]}),f.jsx("span",{title:r.sessionId,children:r.sessionId})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),f.jsxs("div",{className:"transcript-dialog-controls",children:[f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:L,onChange:ye=>H(ye.currentTarget.checked)}),"Show tool output"]}),f.jsx("label",{className:"transcript-search",children:f.jsx("input",{type:"search",value:Y,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ye=>$(ye.currentTarget.value),onKeyDown:ye=>{ye.key==="Enter"&&(ye.preventDefault(),ne?Tt(ye.shiftKey?-1:1):St(ye.shiftKey?-1:1))}})}),f.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":F,"aria-label":"Toggle prompt list",onClick:()=>xe(ye=>!ye),disabled:Ne.length===0,children:"List"}),f.jsxs("div",{className:"transcript-search-actions","aria-label":ne?"Search result navigation":"Prompt navigation",children:[f.jsx("button",{type:"button",onClick:()=>ne?Tt(-1):void St(-1),disabled:ne?R===0:Ne.length===0&&!le,"aria-label":ne?"Previous search match":"Previous user prompt",title:ne?"Previous search match":"Previous user prompt",children:"Prev"}),f.jsx("button",{type:"button",onClick:()=>ne?Tt(1):void St(1),disabled:ne?R===0:Ne.length===0,"aria-label":ne?"Next search match":"Next user prompt",title:ne?"Next search match":"Next user prompt",children:"Next"})]}),f.jsx("span",{className:"transcript-result-count",children:je})]}),F?f.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ne.length>0?Ne.map((ye,Xe)=>f.jsxs("button",{type:"button",className:Ie===ye.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>$e(Xe),children:[f.jsx("span",{children:ye.timestampLabel}),f.jsx("strong",{children:ye.snippet})]},`${ye.key}:${Xe}`)):f.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,f.jsxs("div",{ref:m,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:yt,children:[ae?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!M&&le?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,De?f.jsx(ck,{entries:Be,searchQuery:Y,activeEntryIndex:Q,activeEntryMode:ke,activeSearchMatch:ge,fontSize:o}):null,M?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,ue?f.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",f.jsx("button",{type:"button",onClick:()=>{u()},children:"Load current session"})]}):null,!ue&&!M&&!De&&!N?le&&X?f.jsxs("div",{className:"transcript-dialog-status",children:[L?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{Ye(X,"older")},disabled:ae,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,N?f.jsx("div",{className:"transcript-dialog-error",children:N}):null]})]})})});function pB(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:mB(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=n.get(c.contentKey)??0;n.set(c.contentKey,u+1),r.set(o,JSON.stringify([c.contentKey,u]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:vB(o.entry.body),timestampLabel:_B(o.entry.header)}))}function mB(e){return JSON.stringify([e.header??"",e.body.length,gB(e.body)])}function gB(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function vB(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function _B(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function bB(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function yB(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function SB(e){return e.includes("\r")||e.includes(`
|
|
55
|
-
`)}function Bg(e){return e instanceof Ln&&e.status===404}function Cl(e){return tT(e)||iT(e)}function tT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function iT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function wB(e){if(Cl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function CB(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Rh(e){const t=[];for(const n of e){const r=nT(n);r&&t.push(r)}return t}function nT(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!j5.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function jg(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function xB(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function V1(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function qn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Mh(e,t){return!t||qn(e)}function Y1(e){return qn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function kB(e,t,n,r,o,c,u,m){const g=p=>{const y=EB(p);if(y!==0){if(u()){if(MB(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),m(y);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),TB(t,y,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function TB(e,t,n,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(f_,u);return}u()}function EB(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function DB(e,t,n,r,o,c,u,m,g){let p=null,y=0;const b={passive:!1};function k(D){p=Ig(D),y=0}function w(D){const I=Ig(D);if(I===null){p=null,y=0;return}if(p===null){p=I;return}const L=I.clientY-p.clientY;if(p=I,D.cancelable&&D.preventDefault(),L===0)return;if(RB(t)&&NB(t,I,-L)){y=0;return}y-=L/n();const H=y<0?Math.ceil(y):Math.floor(y);if(H!==0){if(y-=H,m()){g(H);return}c();try{t.scrollLines(H)}finally{u()}r(),H<0&&t.buffer.active.viewportY<=3&&o(H)}}function S(D){if(D.touches.length>0){p=Ig(D);return}p=null,y=0}return e.addEventListener("touchstart",k,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",S),e.addEventListener("touchcancel",S),()=>{e.removeEventListener("touchstart",k,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",S),e.removeEventListener("touchcancel",S)}}function Ig(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function RB(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function MB(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function NB(e,t,n){const r=e.element;return r?(r.dispatchEvent(AB(t,n)),!0):!1}function AB(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function m_({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:m,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:k=[],totalPanes:w,onSelect:S,onClose:D,onResize:I,onExit:L,onSnapshot:H,onCloseEditor:Y,onAuthClose:$}){const se=w??g_(e);if(k.length===0&&b){const re=v_(e),Ee=re.some(ie=>ie.key===b)?b:re[0]?.key;if(re.length>1&&Ee)return f.jsx("div",{className:"mobile-focused-split",children:re.map(ie=>{const V=ie.key===Ee;if(ie.type==="editor"){const W=n[ie.editorId];return f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:W?f.jsx(ww,{api:r,editor:W,canClose:se>1,onClose:()=>Y(ie.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ie.key)}const X=t[ie.terminalId];return X?f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx(U1,{terminal:X,serverApi:r,active:V,visible:c&&V,canClose:se>1,refreshCwdOnEnter:u&&V,tabId:m,codeServerContext:g,onSelect:()=>S(ie.terminalId),onClose:()=>D(ie.terminalId),onExit:W=>L(ie.terminalId,W),onSnapshot:H,...$?{onAuthClose:$}:{}})},ie.key):f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ie.key)})})}if(e.type==="pane"){const re=t[e.terminalId];if(!re)return f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const Ee=f.jsx(U1,{terminal:re,serverApi:r,active:e.terminalId===o,visible:c,canClose:se>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>S(e.terminalId),onClose:()=>D(e.terminalId),onExit:V=>L(e.terminalId,V),onSnapshot:H,...$?{onAuthClose:$}:{}});return p&&y!==e.terminalId?f.jsxs("div",{className:"pane-drop-host",children:[Ee,f.jsx(Nh,{terminalId:e.terminalId,side:"top"}),f.jsx(Nh,{terminalId:e.terminalId,side:"right"}),f.jsx(Nh,{terminalId:e.terminalId,side:"bottom"}),f.jsx(Nh,{terminalId:e.terminalId,side:"left"})]}):Ee}if(e.type==="editor"){const re=n[e.editorId];return re?f.jsx(ww,{api:r,editor:re,canClose:se>1,onClose:()=>Y(e.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const J=Math.max(.1,Math.min(.9,e.ratio)),F=1-J,xe=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${J}fr) 1px minmax(0, ${F}fr)`}:{gridTemplateRows:`minmax(0, ${J}fr) 1px minmax(0, ${F}fr)`};return f.jsxs("div",{className:"split-pane","data-direction":e.direction,style:xe,children:[f.jsx("div",{className:"split-cell",children:f.jsx(m_,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...k,0],totalPanes:se,onSelect:S,onClose:D,onResize:I,onExit:L,onSnapshot:H,onCloseEditor:Y,...$?{onAuthClose:$}:{}})}),f.jsx(LB,{direction:e.direction,path:k,onResize:I}),f.jsx("div",{className:"split-cell",children:f.jsx(m_,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...k,1],totalPanes:se,onSelect:S,onClose:D,onResize:I,onExit:L,onSnapshot:H,onCloseEditor:Y,...$?{onAuthClose:$}:{}})})]})}function Nh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=$_({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return f.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function LB({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const u=c.parentElement;if(!u)return;const m=u.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return f.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:f.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function g_(e){return e.type==="pane"||e.type==="editor"?1:g_(e.first)+g_(e.second)}function v_(e){return e.type==="pane"?[{key:OB(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:BB(e.editorId),type:"editor",editorId:e.editorId}]:[...v_(e.first),...v_(e.second)]}function OB(e){return`terminal:${e}`}function BB(e){return`editor:${e}`}const Uf="workspace-default",jB="NTerminal";function IB(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function zB(e,t){switch(t.type){case"workspace.hydrated":return __(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return PB(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return WB(e,t.workspaceId);case"workspace.selected":return sT(e,t.workspaceId);case"workspace.renamed":return HB(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return UB(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return KB(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return rT(e,t.terminal);case"terminal.split":return FB(e,t.terminal,t.direction);case"terminal.updated":return t4(e,t.terminal);case"terminal.exited":return i4(e,t.terminalId,t.exitCode);case"terminal.closed":return lT(e,t.terminalId);case"terminal.detached":return n4(e,t.terminalId,t.workspaceId);case"editor.split":return $B(e,t.editorId,t.title,t.direction);case"editor.closed":return s4(e,t.editorId);case"pane.selected":return JB(e,t.terminalId);case"pane.resized":return e4(e,t.path,t.ratio);case"tab.selected":return VB(e,t.tabId);case"tab.renamed":return QB(e,t.tabId,t.title);case"tab.reordered":return Db(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return YB(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return aT(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return oT(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return XB(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return qB(e);default:return e}}function PB(e,t){if(e.workspaces.some(r=>r.id===t.id))return sT(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Ts(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function sT(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function HB(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.title===r?u:(o=!0,{...u,title:r}));return o?{...e,workspaces:c}:e}function UB(e,t,n){const r=Ts(n);let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.defaultCwd===r?u:(o=!0,{...u,defaultCwd:r}));return o?{...e,workspaces:c}:e}function KB(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const u=e.workspaces.slice(),[m]=u.splice(o,1);if(!m)return e;const g=u.findIndex(b=>b.id===n);if(g<0)return e;const p=r==="before"?g:g+1,y=u.slice();return y.splice(p,0,m),ZB(e.workspaces,y)?e:{...e,workspaces:y}}function WB(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),r=new Set(n?_f(n):[]),o={...e.terminals};for(const m of r)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),u=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:u,terminals:o}}function rT(e,t){const n=uT(e),r=Ao(n)??Wf(),o=mT(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Ts(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:pT(c,t.id))}}function FB(e,t,n){const r=Ao(e),o=r?Kf(r):void 0;if(!r||!o)return rT(e,t);const c=o.activeTerminalId,u=Iu(o.root,c,{type:"split",direction:n,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(m=>m.id===r.id?{...m,defaultCwd:m.defaultCwd??Ts(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:pT(m,t.id))}}function $B(e,t,n,r){const o=Ao(e),c=o?Kf(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,m=Iu(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:m,activeTerminalId:u}:p)}:g)}}function qB(e){const t=Ao(e),n=t?Kf(t):void 0;return n?lT(e,n.activeTerminalId):e}function VB(e,t){const n=Ao(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function Db(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const u=o.tabs.slice(),[m]=u.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(u.length,n)),p=u.slice();return p.splice(g,0,m),GB(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function YB(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(S=>S.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=Il(y.root,n);if(!b){const S=g.tabs.filter((D,I)=>I!==p);return{...g,tabs:S}}const k={...y,root:b,activeTerminalId:Pi(b)[0]??y.activeTerminalId},w=g.tabs.slice();return w[p]=k,{...g,tabs:w}});const u=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(D=>Pi(D.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:n},k={type:"split",direction:u,ratio:.5,first:m?b:{type:"pane",terminalId:r},second:m?{type:"pane",terminalId:r}:b},w=Iu(y.root,r,k),S=g.tabs.slice();return S[p]={...y,root:w,activeTerminalId:n},{...g,tabs:S,activeTabId:y.id}}),uT({...e,workspaces:c})}function aT(e,t,n,r){let o=-1,c=-1;for(let I=0;I<e.workspaces.length;I+=1){const L=e.workspaces[I].tabs.findIndex(H=>H.id===t);if(L>=0){o=I,c=L;break}}if(o<0)return e;const u=e.workspaces[o],m=u.tabs[c],g=Pi(m.root);if(!g.includes(n))return e;if(g.length===1)return Db(e,t,r);const p=Il(m.root,n);if(!p)return e;const y={...m,root:p,activeTerminalId:Pi(p)[0]??m.activeTerminalId},b=e.terminals[n],k={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=u.tabs.slice();w[c]=y;const S=Math.max(0,Math.min(w.length,r));w.splice(S,0,k);const D=e.workspaces.slice();return D[o]={...u,tabs:w,activeTabId:k.id},{...e,workspaces:D}}function oT(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=dT(e.workspaces,t),c=e.workspaces.find(p=>p.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:Db(e,t,r);const u=Pi(o.tab.root),m=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Lo({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===n){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??Ts(m?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(k=>!u.includes(k)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function XB(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===r),u=dT(e.workspaces,t);if(!c||!u||!e.terminals[n]||!Pi(u.tab.root).includes(n))return e;if(u.workspace.id===r)return aT(e,t,n,o);if(Pi(u.tab.root).length===1)return oT(e,t,r,o);const g=Il(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:Pi(g)[0]??u.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},k=e.workspaces.map(w=>{if(w.id===u.workspace.id)return Lo({...w,tabs:w.tabs.map(S=>S.id===t?p:S)});if(w.id===r){const S=w.tabs.slice(),D=Math.max(0,Math.min(S.length,o));return S.splice(D,0,b),{...w,defaultCwd:w.defaultCwd??Ts(y.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(I=>I!==n),tabs:S,activeTabId:b.id}}return w});return{...e,workspaces:k,activeWorkspaceId:r}}function GB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function ZB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function QB(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>{let m=!1;const g=u.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,m=!0,{...p,title:r}));return m?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function JB(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>zl(c.root,t))),r=n?.tabs.find(o=>zl(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function e4(e,t,n){const r=Ao(e),o=r?Kf(r):void 0;if(!r||!o)return e;const c=x_(o.root,t,_T(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===r.id?{...u,tabs:u.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:u)}}function __(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,m=!!(n&&n.some(b=>gT(b))||t&&t.some(b=>vT(b)));let g=r4(t,n,c,u);g.length===0&&(g=[Wf()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??Uf;for(const b of e)if(!u.has(b.id)){if(m)g=l4(g,y,b.id,b);else{const k=mT(b);g=u4(g,y,k,b)}u.add(b.id)}return{workspaces:g.map(b=>Lo(c4(b,o))),activeWorkspaceId:p,terminals:o}}function ju(e){return Pi(e.root)}function b_(e){return k_(e.root)}function _f(e){return Rb([...e.tabs.flatMap(t=>Pi(t.root)),...e.detachedTerminalIds])}function zg(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=w_(o.root);return c?[{...o,root:c}]:[]});return Lo({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function t4(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>zl(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function i4(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function lT(e,t){const n={...e.terminals};return delete n[t],cT(e,t,n)}function n4(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??a4(e,t)?.id??o4(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Uf,o=e.workspaces.find(c=>c.id===r);return!o||!fT(o,t)?e:cT(e,t,{...e.terminals},{detachToWorkspaceId:r})}function cT(e,t,n,r={}){let o=e.workspaces.map(u=>{const m=[];for(const g of u.tabs){const p=Il(g.root,t);if(!p)continue;const y=Pi(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:p,activeTerminalId:b})}return Lo({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:m})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?hT(u,t,n[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function s4(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const m=y_(u.root,t);if(!m)continue;const g=Pi(m),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:m,activeTerminalId:p})}return Lo({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function r4(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)gT(c)&&o.push(X1(c,n,r));if(o.length>0)return o}return[X1({...Wf(),tabs:e??[]},n,r)]}function X1(e,t,n){const r=[];for(const c of e.tabs){if(!vT(c))continue;const u=S_(c.root,t);if(!u)continue;const m=Pi(u);for(const p of m)n.add(p);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&r.push({...c,root:u,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return Lo({...e,defaultCwd:Ts(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function uT(e){return Ao(e)?e:{...e,workspaces:[Wf()],activeWorkspaceId:Uf}}function Ao(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Kf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function dT(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function a4(e,t){return e.workspaces.find(n=>n.tabs.some(r=>zl(r.root,t)))}function o4(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function l4(e,t,n,r){return e.map(o=>o.id===t?hT(o,n,r):o)}function hT(e,t,n){return fT(e,t)?{...e,defaultCwd:e.defaultCwd??Ts(n?.cwd),detachedTerminalIds:Rb([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function fT(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Ul}function pT(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function c4(e,t){if(e.defaultCwd)return e;const n=_f(e).find(o=>!!t[o]),r=n?Ts(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Wf(){return{id:Uf,title:jB,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Lo(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Ts(e.defaultCwd),detachedTerminalIds:Rb(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function u4(e,t,n,r){const o=Pi(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Ts(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function mT(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Iu(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Iu(e.first,t,n),second:Iu(e.second,t,n)}}function Il(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Il(e.first,t),r=Il(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function y_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=y_(e.first,t),r=y_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function S_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=S_(e.first,t),r=S_(e.second,t);return n&&r?{...e,ratio:_T(e.ratio),first:n,second:r}:n??r}function w_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=w_(e.first),n=w_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function gT(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 vT(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&C_(t.root)}function C_(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")&&C_(t.first)&&C_(t.second):!1}function x_(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const c=x_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=x_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function _T(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Ts(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Rb(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function zl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:zl(e.first,t)||zl(e.second,t)}function Pi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Pi(e.first),...Pi(e.second)]}function k_(e){return e.type==="pane"||e.type==="editor"?1:k_(e.first)+k_(e.second)}const Wa=new Map,zu=new Map,Pu=new Map,Hu=new Map,Uu=new Map;function ql(e){return e??"__local__"}function d4(e){return{agentId:e,state:IB(),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 Kt(e){const t=ql(e);let n=Wa.get(t);return n||(n=d4(e),Wa.set(t,n)),n}function bT(e,t){const n=ql(e);let r=zu.get(n);return r||(r=new Set,zu.set(n,r)),r.add(t),()=>{r.delete(t)}}function h4(e){const t=ql(e),n=zu.get(t);if(n)for(const r of Array.from(n))r()}function Vl(e,t){Wa.set(ql(e),t),h4(e)}const T_=new Set;function f4(e){return T_.add(e),()=>{T_.delete(e)}}function bl(e,t){const n=Kt(e),r=ql(e);t.type==="workspace.hydrated"&&(Pu.delete(r),Hu.delete(r),Uu.delete(r));const o=zB(n.state,t);let c=n.unreadCompletions,u=null;if(t.type==="terminal.updated"){const p=n.state.terminals[t.terminal.id],y=S4(r),b=w4(r),k=m4(r);if(t.terminal.agentStatus){const w=t.terminal.agentStatus.state,S=t.terminal.agentStatus.sessionId,D=k.get(t.terminal.id),I=!!(p&&(p.currentCommand!==t.terminal.currentCommand||p.agentStatus?.provider!==t.terminal.agentStatus.provider||p4(D,S)));I&&(b.delete(t.terminal.id),y.delete(t.terminal.id),k.delete(t.terminal.id)),S&&k.set(t.terminal.id,S),t.notifyCompletion===!0&&(w==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):w==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!I&&(w==="done"||w==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(u=Q1(o,t.terminal.id,p?.currentCommand??null,w==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),w==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{p?.agentStatus&&(b.delete(t.terminal.id),k.delete(t.terminal.id));const w=p?.activity==="busy",S=t.terminal.activity==="busy",D=t.terminal.activity==="idle";t.notifyCompletion===!0&&S&&y.add(t.terminal.id),t.notifyCompletion===!0&&w&&D&&y.has(t.terminal.id)&&(u=Q1(o,t.terminal.id,p?.currentCommand??null,"finished")),(D||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(u){const w=yT(o,t.terminal.id);w&&(w.workspace.activeTabId!==w.tab.id||w.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id),k.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=g4(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(k=>k.id===t.workspaceId);p=b?.tabs.find(k=>k.id===b.activeTabId)??null}const y=p?Pi(p.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const k of y)b.delete(k);c=b}}const m=o!==n.state,g=c!==n.unreadCompletions;if((m||g)&&Vl(e,{...n,state:o,unreadCompletions:c}),g&&Mb(),u)for(const p of Array.from(T_))p({agentId:e,...u})}function p4(e,t){return e!==void 0&&t!==void 0&&e!==t}function m4(e){let t=Uu.get(e);return t||(t=new Map,Uu.set(e,t)),t}function yT(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Pi(r.root).includes(t))return{workspace:n,tab:r};return null}function g4(e,t){for(const n of e.workspaces){const r=n.tabs.find(o=>o.id===t);if(r)return{workspace:n,tab:r}}return null}const E_=new Set;function v4(e){return E_.add(e),()=>{E_.delete(e)}}function _4(){let e=0;for(const t of Wa.values())e+=t.unreadCompletions.size;return e}function Mb(){for(const e of Array.from(E_))e()}function G1(e,t){const n=Kt(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Vl(e,{...n,unreadCompletions:r}),Mb()}function Z1(e,t){const n=Kt(e);t!==n.state&&Vl(e,{...n,state:t})}function Pg(e,t){const n=Kt(e),r=t(n.editors);r!==n.editors&&Vl(e,{...n,editors:r})}function Ca(e,t,n){const r=Kt(e);r.loaded===t&&r.error===n||Vl(e,{...r,loaded:t,error:n})}function Qc(e,t,n){const r=Kt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Vl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n})}function b4(e){const t=Kt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function y4(e){const t=ql(e),n=Wa.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1;Wa.delete(t),zu.delete(t),Pu.delete(t),Hu.delete(t),Uu.delete(t),r&&Mb()}function Hg(){for(const e of Wa.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Wa.clear(),zu.clear(),Pu.clear(),Hu.clear(),Uu.clear()}function S4(e){let t=Pu.get(e);return t||(t=new Set,Pu.set(e,t)),t}function w4(e){let t=Hu.get(e);return t||(t=new Set,Hu.set(e,t)),t}function Q1(e,t,n,r){const o=yT(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function D_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of ju(e)){const m=t[u];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(r=!0,n=!0,!o&&m.currentCommand&&(o=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Nb(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function R_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function C4(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function x4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:u,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:k,onRenameTab:w,activePaneAvailable:S}){const[D,I]=v.useState(null),[L,H]=v.useState(!1),[Y,$]=v.useState(null),se=v.useRef(null),J=e.findIndex(W=>W.id===t),F=J>=0?e[J]:e[0]??null,xe=F?D_(F,n):null,re=F?b_(F):0,Ee=F?R_(F,n):"No tab";v.useEffect(()=>{se.current?.focus(),se.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!L)return;const W=le=>{le.key==="Escape"&&H(!1)};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[L]),v.useEffect(()=>{L&&e.length===0&&H(!1)},[L,e.length]);function ie(W,le){I({tabId:W,title:le})}function V(){if(!D)return;const W=D.title.trim();W&&w(D.tabId,W),I(null)}function X(){return f.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${nM()}`,onClick:b,disabled:!S,children:f.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${sM()}`,onClick:k,disabled:!S,children:f.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return f.jsxs(f.Fragment,{children:[f.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[f.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:f.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})}),f.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Ee,onClick:()=>H(!0),disabled:e.length===0,children:[xe?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":xe.state,"aria-hidden":"true",title:Nb(xe)}):null,f.jsx("span",{children:Ee}),f.jsxs("small",{children:[J>=0?J+1:0,"/",e.length||0,re>1?` / ${re}`:""]})]}),f.jsxs("div",{className:"terminal-tab-list",children:[e.map((W,le)=>{const O=ju(W),M=b_(W),B=R_(W,n),ae=W.id===t,we=D?.tabId===W.id,N=D_(W,n),U=r?.has(W.id)??!1;return f.jsxs(Ai.Fragment,{children:[f.jsx(J1,{index:le}),f.jsx(k4,{tab:W,active:ae,editing:we,title:B,paneCount:M,terminalIds:O,canClose:e.length>1,editValue:we?D.title:null,editInputRef:we?se:null,activity:N,unread:U,onSelect:()=>c(W.id),onBeginRename:()=>ie(W.id,B),onCloseAll:()=>g(O),onCommitRename:V,onCancelRename:()=>I(null),onRenameChange:ue=>I({tabId:W.id,title:ue})})]},W.id)}),f.jsx(J1,{index:e.length}),f.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:u,children:"+"}),(o?.length??0)>0?f.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(W=>f.jsx(E4,{terminal:W,onReattach:()=>p?.(W.id),onDelete:()=>$(W)},W.id))}):null]}),f.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:u,children:"+"}),S?X():null]}),L?f.jsx(T4,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:D,editInputRef:se,onClose:()=>H(!1),onSelectTab:W=>{c(W),H(!1)},onCreateTab:()=>{u(),H(!1)},onBeginRename:ie,onCloseTerminals:W=>{g(W),H(!1)},onCommitRename:V,onCancelRename:()=>I(null),onRenameChange:(W,le)=>I({tabId:W,title:le}),onReattachTerminal:W=>{p?.(W),H(!1)},onDeleteTerminal:W=>{$(W),H(!1)}}):null,Y?f.jsx(D4,{terminal:Y,onCancel:()=>$(null),onConfirm:()=>{y?.(Y.id),$(null)}}):null]})}function k4({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:m,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:k,onCommitRename:w,onCancelRename:S,onRenameChange:D}){const{attributes:I,listeners:L,setNodeRef:H,transform:Y,isDragging:$}=LC({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),se={transform:qg.Translate.toString(Y),opacity:$?.4:void 0,zIndex:$?2:void 0};return f.jsxs("div",{ref:H,className:"terminal-tab","data-active":t,"data-dragging":$,"data-unread":p?"true":void 0,style:se,...I,...L,children:[g?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Nb(g)}):null,n&&m&&u!==null?f.jsxs("form",{className:"terminal-tab-editor",onSubmit:J=>{J.preventDefault(),w()},children:[f.jsx("input",{ref:m,"aria-label":`Rename ${r}`,value:u,onBlur:w,onChange:J=>D(J.target.value),onKeyDown:J=>{if(J.key==="Enter"){J.preventDefault(),w();return}J.key==="Escape"&&(J.preventDefault(),S())}}),f.jsx("small",{children:o})]}):f.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:J=>{J.preventDefault(),b()},children:[f.jsx("span",{children:r}),f.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?f.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),k()},children:"x"}):null]})}function T4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:u,onClose:m,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:k,onCancelRename:w,onRenameChange:S,onReattachTerminal:D,onDeleteTerminal:I}){const L=v.useRef(null);return v.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),f.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:f.jsxs("section",{className:"mobile-tab-sheet",onClick:H=>H.stopPropagation(),children:[f.jsxs("header",{children:[f.jsxs("div",{children:[f.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),f.jsxs("small",{children:[e.length," open"]})]}),f.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[f.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),f.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((H,Y)=>{const $=ju(H),se=b_(H),J=R_(H,n),F=H.id===t,xe=c?.tabId===H.id,re=D_(H,n),Ee=r?.has(H.id)??!1;return f.jsxs("div",{ref:F?L:null,className:"mobile-tab-sheet-row","data-active":F,"data-unread":Ee?"true":void 0,children:[xe&&c?f.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),k()},children:f.jsx("input",{ref:u,"aria-label":`Rename ${J}`,value:c.title,onBlur:k,onChange:ie=>S(H.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),k();return}ie.key==="Escape"&&(ie.preventDefault(),w())}})}):f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${J}`,onClick:()=>g(H.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:J}),f.jsx("small",{children:C4(H,n,se,re)})]}),f.jsxs("span",{className:"mobile-tab-sheet-meta",children:[re?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":re.state,"aria-hidden":"true",title:Nb(re)}):null,f.jsx("span",{children:se})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-actions",children:[xe?f.jsx("button",{type:"button","aria-label":`Done renaming ${J}`,onClick:k,children:"Done"}):f.jsx("button",{type:"button","aria-label":`Rename ${J}`,onClick:()=>y(H.id,J),children:"Rename"}),e.length>1?f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${J}`,onClick:()=>b($),children:"×"}):null]})]},H.id)}),(o?.length??0)>0?f.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[f.jsx("span",{children:"Detached"}),(o??[]).map(H=>{const Y=H.title||H.cwd||H.id.slice(0,8);return f.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>D(H.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:Y}),f.jsx("small",{children:H.cwd})]}),f.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),f.jsx("div",{className:"mobile-tab-sheet-actions",children:f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>I(H),children:"×"})})]},H.id)})]}):null]})]})})}function J1({index:e}){const{setNodeRef:t,isOver:n}=$_({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return f.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function E4({terminal:e,onReattach:t,onDelete:n}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
56
|
-
${e.cwd}
|
|
57
|
-
(detached — click to re-open, × to delete)`;return f.jsxs("span",{className:"terminal-detached-pill",title:o,children:[f.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),f.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function D4({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:"Delete this terminal?"}),f.jsx("span",{children:r}),f.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function R4({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return f.jsxs("aside",{className:`upload-toast upload-toast-${O4(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[f.jsxs("header",{className:"upload-toast-header",children:[f.jsx("strong",{children:e.length===1?qh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),f.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),f.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>f.jsx(M4,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function M4({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return f.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":qh(e),children:[f.jsxs("div",{className:"upload-queue-item-header",children:[f.jsx("strong",{children:qh(e)}),f.jsxs("div",{className:"upload-queue-actions",children:[m?f.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?f.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,f.jsx("button",{type:"button","aria-label":`Dismiss ${qh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?f.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?f.jsx(N4,{toast:e}):null,c&&"message"in e&&e.message?f.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?f.jsx(A4,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?f.jsx("p",{children:e.message}):null]})}function N4({toast:e}){const t=e.percent===null?B4(e.loaded):`${e.percent}%`;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"upload-progress-row",children:[f.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),f.jsx("span",{children:t})]}),f.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:f.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function A4({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?f.jsx("ul",{className:"upload-result-list",children:c.map((u,m)=>f.jsx(L4,{result:u},`${u.relativePath}-${m}`))}):null,e.results.length>c.length?f.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function L4({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return f.jsxs("li",{"data-status":e.status,children:[f.jsx("span",{className:"upload-result-path",children:t}),n?f.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?f.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function qh(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function O4(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 B4(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function j4({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return f.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:m,children:[f.jsxs("header",{className:"completion-toast-header",children:[f.jsxs("div",{className:"completion-toast-copy",children:[f.jsx("strong",{children:r.tabTitle}),f.jsx("span",{children:c})]}),f.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),f.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const I4=cu(0,0,1,1),Er=1e-6;function z4(e){return ST(e).map(t=>t.terminalId)}function ST(e){return lu(e,I4).sort(K4).map((t,n)=>({...t,index:n+1}))}function P4(e,t,n){const r=ST(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>U4(o,u,n)).filter(u=>u!==null).sort(W4)[0]?.entry.terminalId??null:null}function H4(e,t){return!Number.isInteger(t)||t<1?null:z4(e)[t-1]??null}function lu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=F4(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...lu(e.first,cu(t.left,t.top,o,t.bottom)),...lu(e.second,cu(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...lu(e.first,cu(t.left,t.top,t.right,r)),...lu(e.second,cu(t.left,r,t.right,t.bottom))]}function U4(e,t,n){const r=e.bounds,o=t.bounds,c=eC(r.left,r.right,o.left,o.right),u=eC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Er||u<=Er?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"right":return o.centerX<=r.centerX+Er||u<=Er?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"up":return o.centerY>=r.centerY-Er||c<=Er?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Er||c<=Er?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function K4(e,t){return Dl(e.bounds.top,t.bounds.top)||Dl(e.bounds.left,t.bounds.left)}function W4(e,t){return Dl(e.primaryDistance,t.primaryDistance)||Dl(e.perpendicularDistance,t.perpendicularDistance)||Dl(t.overlap,e.overlap)||Dl(e.entry.index,t.entry.index)}function Dl(e,t){const n=e-t;return Math.abs(n)<=Er?0:n}function eC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function cu(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function F4(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const tC="nterminal.terminalWorkspaces.v2",wT="nterminal.sidebarCollapsed.v1",$4=75,iC=jC.map(e=>e.url),q4=jC[0].url,V4=6;function Y4({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??Sf(),[e]),p=v.useMemo(()=>t??Al(null),[t]),y=v.useMemo(()=>m6(n),[n]),b=v.useMemo(()=>C=>bT(n,C),[n]),k=v.useMemo(()=>()=>Kt(n),[n]),w=v.useSyncExternalStore(b,k,k),S=w.state,D=w.editors,I=!w.loaded,L=w.error,[H,Y]=v.useState(!1),[$,se]=v.useState(()=>w6()),[J,F]=v.useState("servers"),[xe,re]=v.useState(!1),Ee=v.useSyncExternalStore(pM,vw,vw);v.useSyncExternalStore(mu,gw,gw);const[ie,V]=v.useState(0),[X,W]=v.useState(null),[le,O]=v.useState(()=>[null]),[M,B]=v.useState(()=>({[Yi]:"Local"})),[ae,we]=v.useState(0),[N,U]=v.useState(()=>[n]),[ue,Ce]=v.useState(()=>new Set),[Oe,De]=v.useState({}),[Be,Ne]=v.useState(null),Ue=v.useRef(0),We=v.useRef(0),[ne,pe]=v.useState(null),[R,q]=v.useState(null),fe=v.useRef(null),ge=v.useRef(0),Q=v.useRef(null),ke=v.useRef(null),de=v.useRef(null),Re=v.useRef(null),Ie=v.useRef(()=>{}),[je,Ye]=v.useState(null),lt=S2(V0(DC,{activationConstraint:{distance:8}}),V0(RC,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>mM(g),[g]);function Nt(C){const E=C.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Ye({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Ye({tabId:E.sourceTabId,terminalId:E.terminalId})}}function yt(C){Ye(null);const E=C.active.data.current,z=C.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){pt({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){pt({type:"tab.moved_to_workspace",sourceTabId:E.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")&&pt({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){pt({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){pt({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.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")&&pt({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Tt(){Ye(null)}const $e=S.workspaces.find(C=>C.id===S.activeWorkspaceId)??S.workspaces[0],St=$e?.tabs.find(C=>C.id===$e.activeTabId)??$e?.tabs[0],Lt=St?.activeTerminalId??null,ye=Lt?S.terminals[Lt]:void 0,Xe=c6("(max-width: 760px)"),rt=v.useMemo(()=>St?bf(St.root):[],[St]),Ze=$e&&St?uu(n,$e.id,St.id):null,Et=St?CT(rt,St.activeTerminalId,Ze?Oe[Ze]:void 0):null,ct=Xe&&rt.length>1,Tn=v.useMemo(()=>($e?.detachedTerminalIds??[]).flatMap(C=>{const E=S.terminals[C];return E?[E]:[]}),[$e?.detachedTerminalIds,S.terminals]),vi=v.useMemo(()=>{const C=new Set;for(const E of $e?.tabs??[])ju(E).some(z=>w.unreadCompletions.has(z))&&C.add(E.id);return C},[$e?.tabs,w.unreadCompletions]),[ee,Pe]=v.useState([]),st=v.useRef([]),tt=v.useRef(null),[kt,Xt]=v.useState(null),[Wt,ui]=v.useState(null),[Gt,ri]=v.useState([]),[di,Ft]=v.useState(()=>Co()),cn=v.useRef(0),ti=v.useRef(n),Ui=v.useRef(iC),vn=v.useRef(di),_n=v.useRef(()=>{});_n.current=dn,Ie.current=ir;const ii=v.useCallback(async()=>{try{const C=await g.listNotificationAssets();ri(C.assets.filter(E=>E.enabled).map(E=>E.url))}catch{ri([])}},[g]),Ji=v.useCallback(C=>{B(E=>{const z={...E};for(const oe of C)z[N_(oe.agentId)]=oe.label;return Ug(E,z)?E:z})},[]);v.useEffect(()=>{U(C=>C.some(E=>pn(E,n))?C:[...C,n])},[n]);const ai=v.useCallback(C=>{const E=Kt(C),z=Al(C);for(const oe of Object.keys(E.state.terminals))ou(z.createWebSocketUrl(oe)),xh(oe),au(oe);y4(C),U(oe=>oe.filter(Se=>!pn(Se,C))),Ce(oe=>{const Se=`${Yh(C)}:`;let me=!1;const Me=new Set;for(const Qe of oe){if(Qe.startsWith(Se)){me=!0;continue}Me.add(Qe)}return me?Me:oe}),De(oe=>{const Se=`${Yh(C)}:`;let me=!1;const Me={};for(const[Qe,vt]of Object.entries(oe)){if(Qe.startsWith(Se)){me=!0;continue}Me[Qe]=vt}return me?Me:oe})},[]);v.useEffect(()=>{let C=!1;return g.getMainInfo().then(E=>{if(C)return;const z=E.name?.trim()||"Local";B(oe=>{const Se={...oe,[Yi]:z};return Ug(oe,Se)?oe:Se})}).catch(()=>{}),g.listAgents().then(E=>{if(!C){const z=E.agents.map(Se=>Se.id),oe=NR(E.serverOrder,E.agents);B(Se=>{const me={[Yi]:Se[Yi]??"Local"};for(const Me of E.agents)me[Me.id]=Me.name;return Ug(Se,me)?Se:me}),n!==null&&!z.includes(n)&&(ai(n),r?.(null)),O(oe)}}).catch(()=>{}),()=>{C=!0}},[n,g,ai,r,ae]);const _i=v.useCallback(C=>{ai(C),we(E=>E+1),pn(C,ti.current)&&r?.(null)},[ai,r]);v.useEffect(()=>{O(C=>C.some(E=>pn(E,n))?C:[...C,n])},[n]),v.useEffect(()=>{ti.current=n},[n]),v.useEffect(()=>{W(null)},[n]),v.useEffect(()=>{const C=Q.current;if(!C)return;if(!pn(C.agentId,n)){Q.current=null;return}if(!w.loaded||S.workspaces.length===0)return;Q.current=null;const E=C.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];E&&E.id!==S.activeWorkspaceId&&pt({type:"workspace.selected",workspaceId:E.id})},[n,w.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const C=ke.current;if(C){if(!pn(C.agentId,n)){ke.current=null;return}w.loaded&&(ke.current=null,S.workspaces.some(E=>E.id===C.workspaceId)&&pt({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,w.loaded,S.workspaces]),v.useEffect(()=>{const C=de.current;if(C){if(!pn(C.agentId,n)){de.current=null;return}w.loaded&&(de.current=null,w.error||Oo())}},[n,w.error,w.loaded]),v.useEffect(()=>{yn()},[n,w.loaded,S]),v.useEffect(()=>{const C=()=>{const oe=d6();oe&&Ie.current(oe)},E=oe=>{const Se=h6(oe.data);Se&&Ie.current(Se)},z=oe=>{const Se=Ef(oe.detail);Se&&Ie.current(Se)};return C(),window.addEventListener("hashchange",C),window.addEventListener(Qg,z),navigator.serviceWorker?.addEventListener?.("message",E),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(Qg,z),navigator.serviceWorker?.removeEventListener?.("message",E)}},[]),v.useEffect(()=>{ii()},[ii]),v.useEffect(()=>qC(()=>Ft(Co())),[]),v.useEffect(()=>{const C=E=>{_n.current(E)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{Ui.current=Gt.length>0?Gt:iC},[Gt]),v.useEffect(()=>{vn.current=di},[di]),v.useEffect(()=>{if(!w.loaded||!$e||!St)return;const C=uu(n,$e.id,St.id);Ce(E=>{if(E.has(C))return E;const z=new Set(E);return z.add(C),z})},[n,w.loaded,$e?.id,St?.id]),v.useEffect(()=>()=>{Ls()},[]),v.useEffect(()=>{const C=wR(g),E=kR(g);return()=>{C(),E()}},[g]),v.useEffect(()=>f4(C=>{const E=Kt(C.agentId).state,z=E.workspaces.flatMap(Me=>Me.tabs).find(Me=>Me.id===C.tabId),oe=E.terminals[C.terminalId],Se=z?.title?.trim()||oe?.title||C.commandName||"terminal",me=document.visibilityState==="visible"&&pn(C.agentId,ti.current)&&C.tabId===p6(E);if(me||gR({agentId:C.agentId,tabTitle:Se,commandName:C.commandName,terminalId:C.terminalId,outcome:C.outcome}),!me&&document.visibilityState==="visible"&&vn.current.enabled){const Me=cn.current+1;cn.current=Me;const Qe=Ui.current;Xt({id:Me,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:Se,commandName:C.commandName,outcome:C.outcome,assetSrc:Qe[Math.floor(Math.random()*Qe.length)]??q4})}}),[]),v.useEffect(()=>{if(!kt||di.persistUntilDismissed)return;const C=window.setTimeout(()=>{Xt(E=>E?.id===kt.id?null:E)},di.durationSeconds*1e3);return()=>window.clearTimeout(C)},[kt,di]),v.useEffect(()=>{C6($),$&&Bn()},[$]),v.useEffect(()=>{let C=!1;async function E(){if(!Kt(n).loaded){Ca(n,!1,null);try{let oe=null,Se=null;try{oe=g6(y)}catch(vt){if(!(vt instanceof yf))throw vt;Se=vt}const[me,Me]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Qe=me.terminals.length>0?me.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!C){const vt=Me.layout?kT(Me.layout):null;if(!vt&&Se)throw Se;const Ti=vt??oe??{},Zt=__(Qe,void 0,Ti.savedWorkspaces,Ti.savedActiveWorkspaceId),Vr=zg(Zt);Z1(n,Zt),Qc(n,Me.revision,JSON.stringify(Vr)),Ca(n,!0,null),!vt&&oe&&nr(Vr,{baseRevision:Me.revision})}}catch(oe){!C&&!Oi(oe)&&Ca(n,!0,xa(oe))}}}return E(),()=>{C=!0}},[n,p,ie]);function bi(){Ca(n,!1,null),V(C=>C+1)}function Bn(){Ue.current+=1,We.current+=1,Ne(null)}function Ir(C){Ue.current+=1,We.current+=1,Ne(E=>E&&{...E,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Oo(){Ue.current+=1,We.current+=1;const C=S.workspaces.length+1,E=ds();Ne({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Qs(E)}function zr(C){if(pn(C,n)){Oo();return}de.current={agentId:C},r?.(C)}function Zs(C){if($&&!H)return;const E=S.workspaces.find(oe=>oe.id===C);if(!E)return;Ue.current+=1,We.current+=1;const z=E.defaultCwd??ye?.cwd??"";Ne({mode:"edit",workspaceId:C,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Qs(z)}function ds(){return $e?.defaultCwd??ye?.cwd??""}async function Qs(C){const E=Ue.current+1;Ue.current=E;const z=C.trim();if(Ne(oe=>oe&&{...oe,cwd:C,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const oe=await p.createFileRoot({path:z}),Se=await p.listFiles({rootToken:oe.rootToken,path:""});if(Ue.current!==E)return;Ne(me=>me&&{...me,cwd:oe.rootPath,browseRoot:{rootToken:oe.rootToken,rootPath:oe.rootPath},browseEntries:Se.entries.filter(Me=>Me.kind==="directory"),browseStatus:"idle",error:null})}catch(oe){if(Ue.current!==E)return;Ne(Se=>Se&&{...Se,browseStatus:"idle",error:xa(oe)})}}async function hs(){const C=Be;if(!C)return;const E=C.title.trim(),z=C.cwd.trim();if(!E||!z){Ne({...C,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const oe=We.current+1;We.current=oe,Ne({...C,submitStatus:"submitting",error:null});try{const Se=await p.createFileRoot({path:z});if(We.current!==oe)return;if(C.mode==="create"){const me=S.workspaces.length+1;pt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${me}`,title:E,defaultCwd:Se.rootPath})}else C.workspaceId&&(pt({type:"workspace.renamed",workspaceId:C.workspaceId,title:E}),pt({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:Se.rootPath}));Ne(null)}catch(Se){if(We.current!==oe)return;Ne(me=>me&&{...me,submitStatus:"idle",error:xa(Se)})}}function Es(C){We.current+=1,Ne(C)}function fs(C,E,z){if(C===E)return;const oe=S.workspaces.some(me=>me.id===C),Se=S.workspaces.some(me=>me.id===E);!oe||!Se||pt({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:E,placement:z})}function Ds(C,E){const z=S.workspaces.findIndex(Se=>Se.id===C),oe=S.workspaces[z+E];z<0||!oe||fs(C,oe.id,E<0?"before":"after")}function It(C,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),fe.current={sourceId:C,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function Bo(C){const E=fe.current;if(!E||E.pointerId!==C.pointerId)return;const z=Math.hypot(C.clientX-E.startX,C.clientY-E.startY);if(!E.active){if(z<V4)return;E.active=!0,pe(E.sourceId)}const Se=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),me=Se?.dataset.workspaceId??null;if(!Se||!me||me===E.sourceId||!S.workspaces.some(vt=>vt.id===me)){E.targetId=null,q(null);return}const Me=Se.getBoundingClientRect(),Qe=C.clientY<Me.top+Me.height/2?"before":"after";E.targetId=me,E.placement=Qe,q({workspaceId:me,placement:Qe})}function Pr(C){const E=fe.current;!E||E.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),fe.current=null,pe(null),q(null),E.active&&E.targetId&&fs(E.sourceId,E.targetId,E.placement))}function $t(C){const E=fe.current;E&&E.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),fe.current=null,pe(null),q(null)}async function jn(){await Ms(async()=>{const C=$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},E=await p.createTerminal(C);pt({type:"terminal.created",terminal:E.terminal})})}async function en(C){await Ms(async()=>{const E=Lt?{parentTerminalId:Lt,cols:80,rows:24}:$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},z=await p.createTerminal(E);pt({type:"terminal.split",terminal:z.terminal,direction:C})})}async function Hr(C){let E=Lt,z=Ze;const oe=$e?.defaultCwd?.trim();if(!E&&!oe)throw new Error("No active pane is available.");const Se=await p.readFile(C);if(!E&&oe){const Qe=await p.createTerminal({cols:80,rows:24,cwd:oe});E=Qe.terminal.id,pt({type:"terminal.created",terminal:Qe.terminal})}if(E){pt({type:"pane.selected",terminalId:E});const Qe=Kt(n).state,vt=Qe.workspaces.find(Zt=>Zt.id===Qe.activeWorkspaceId)??Qe.workspaces[0],Ti=vt?.tabs.find(Zt=>Zt.id===vt.activeTabId)??vt?.tabs[0];z=vt&&Ti?uu(n,vt.id,Ti.id):null}const me=`editor-${Date.now().toString(36)}-${b4(n)}`,Me=S6(Se.path);Pg(n,Qe=>({...Qe,[me]:{id:me,title:Me,rootToken:C.rootToken,path:Se.path,read:Se}})),z&&De(Qe=>({...Qe,[z]:xT(me)})),pt({type:"editor.split",editorId:me,title:Me,direction:"vertical"})}function jo(C){Pg(n,E=>{const z={...E};return delete z[C],z}),pt({type:"editor.closed",editorId:C})}function Js(C){ps([C])}function ps(C){const E=[...new Set(C)].filter(oe=>S.terminals[oe]);if(E.length===0)return;const z=E.length===1?S.terminals[E[0]]?.title||S.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;W(null),ui({terminalIds:E,label:z,workspaceId:$e?.id??S.activeWorkspaceId??null})}function Ur(C,E){const z=Fr(C,E);if(!z)return!1;const oe=C.filter(Se=>!z.detachedTerminalIds.includes(Se));if(z.detachedTerminalIds.length+oe.length>Ul)return W(_6(z.detachedTerminalIds.length)),!1;W(null);for(const Se of C)pt(z.id?{type:"terminal.detached",terminalId:Se,workspaceId:z.id}:{type:"terminal.detached",terminalId:Se});return!0}async function bn(C){await Ms(async()=>{for(const E of C)await Wi(E),ou(p.createWebSocketUrl(E)),xh(E),au(E),pt({type:"terminal.closed",terminalId:E})})}async function Ki(C){const E=S.workspaces.find(z=>z.id===C);!E||S.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Ms(async()=>{const z=_f(E),oe=[];let Se=null;for(const Me of z)try{await Wi(Me)}catch(Qe){oe.push(xa(Qe)),Qe instanceof Ln&&Qe.status===401&&!p.isAgent&&(Se=Qe)}finally{ou(p.createWebSocketUrl(Me)),xh(Me),au(Me)}const me=E.tabs.flatMap(Me=>M_(Me.root));if(me.length>0){const Me=new Set(me);Pg(n,Qe=>{const vt={...Qe};for(const Ti of Me)delete vt[Ti];return vt})}if(pt({type:"workspace.closed",workspaceId:C}),Se)throw Se;if(oe.length>0)throw new Error(`Workspace was removed, but ${oe.length} terminal session${oe.length===1?"":"s"} may still be running. ${oe[0]}`)})}async function Rs(C){await Ms(async()=>{await Wi(C),ou(p.createWebSocketUrl(C)),xh(C),au(C),pt({type:"terminal.closed",terminalId:C})})}async function $a(C,E){const z=E.trim();if(!z)return;let oe=null;for(const Se of S.workspaces){const me=Se.tabs.find(Me=>Me.id===C);if(me){oe=me.activeTerminalId;break}}if(pt({type:"tab.renamed",tabId:C,title:z}),!!oe)try{const Se=await p.renameTerminal(oe,z);vs({type:"terminal.updated",terminal:Se.terminal})}catch(Se){Ca(n,!0,xa(Se))}}function ms(C){const E=S.terminals[C];E&&pt({type:"terminal.created",terminal:E})}async function Wi(C){try{await p.closeTerminal(C)}catch(E){if(E instanceof Ln&&E.status===404)return;throw E}}async function gs(){await Ms(async()=>{await u()})}async function Ms(C){Ca(n,!0,null);try{await C()}catch(E){if(Oi(E))return;Ca(n,!0,xa(E))}}function Oi(C){return C instanceof Ln&&C.status===401&&!p.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function pt(C){bl(n,C);const E=Kt(n),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const oe=zg(z);JSON.stringify(oe)!==E.lastPersistedLayoutJson&&As(oe)}function vs(C){bl(n,C)}function er(C,E,z,oe){const Se=uu(C,E,z);De(me=>({...me,[Se]:oe}))}function un(C){Ze&&De(E=>({...E,[Ze]:C}))}function Kr(C,E){const z=Su(C);E?er(n,E.workspaceId,E.tabId,z):un(z),pt({type:"pane.selected",terminalId:C})}function qa(C){un(C.key),C.type==="terminal"&&pt({type:"pane.selected",terminalId:C.terminalId})}function dn(C){if(xe||Wt||C.isComposing||C.key==="Process"||e6(C.target))return;const E=G4(C);if(!E)return;if(C.preventDefault(),C.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){Wr(E.type==="server.next"?1:-1);return}const z=Kt(n).state,oe=z.workspaces.find(Me=>Me.id===z.activeWorkspaceId)??z.workspaces[0],Se=oe?.tabs.find(Me=>Me.id===oe.activeTabId)??oe?.tabs[0];if(E.type==="split"){if(!Se)return;en(E.direction);return}if(!oe||!Se)return;if(E.type==="tab.previous"||E.type==="tab.next"){const Me=J4(oe.tabs,Se.id,E.type==="tab.next"?1:-1);Me&&pt({type:"tab.selected",tabId:Me.id});return}if(E.type==="tab.index"){const Me=oe.tabs[E.index-1];Me&&pt({type:"tab.selected",tabId:Me.id});return}const me=Z4(Se.root,Se.activeTerminalId,E);me&&Kr(me,{workspaceId:oe.id,tabId:Se.id})}function Io(C,E){if(!r||le.length===0)return;const z=le.findIndex(Me=>pn(Me,n)),Se=((z===-1?0:z)+C+le.length)%le.length,me=le[Se]??null;pn(me,n)||(E&&(Q.current={agentId:me,edge:E}),r(me))}function Wr(C){const E=Kt(n).state,z=E.workspaces;if(z.length===0){Io(C,C===1?"first":"last");return}const oe=z.findIndex(Me=>Me.id===E.activeWorkspaceId),me=(oe===-1?0:oe)+C;if(me>=0&&me<z.length){pt({type:"workspace.selected",workspaceId:z[me].id});return}Io(C,C===1?"first":"last")}function _s(C,E){if(pn(C,n)){pt({type:"workspace.selected",workspaceId:E});return}ke.current={agentId:C,workspaceId:E},r?.(C)}function Fr(C,E){if(E)return S.workspaces.find(z=>z.id===E)??null;for(const z of C){const oe=S.workspaces.find(me=>me.tabs.some(Me=>ju(Me).includes(z)));if(oe)return oe;const Se=S.workspaces.find(me=>me.detachedTerminalIds.includes(z));if(Se)return Se}return S.workspaces.find(z=>z.id===S.activeWorkspaceId)??S.workspaces[0]??null}function zo(C){Tl(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function Yl(C){if(!Tl(C.dataTransfer))return;C.preventDefault();const E=b6(Kt(n).state),z=ge.current+1;if(ge.current=z,!E){$r({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}$r({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),bs(z,E.id,C.dataTransfer)}async function bs(C,E,z){try{const oe=await Nk(z);if(oe.length===0)throw new Error("No files were found in the drop.");Fi(C,{id:C,status:"queued",fileCount:oe.length,message:"Queued"},{terminalId:E,files:oe})}catch(oe){Fi(C,{id:C,status:"failed",fileCount:0,message:xa(oe)},{terminalId:E})}finally{yi()}}async function Yn(C){const E=st.current.find(me=>me.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,oe=E.files,Se=new AbortController;tt.current=C,Fi(C,{id:C,status:"uploading",fileCount:oe.length,loaded:0,total:null,percent:null},{terminalId:z,files:oe,abortController:Se});try{const me=await lC({terminalId:z,files:oe,signal:Se.signal,onProgress:Ti=>{Fi(C,{id:C,status:"uploading",fileCount:oe.length,loaded:Ti.loaded,total:Ti.total,percent:Ti.percent},{terminalId:z,files:oe,abortController:Se})}}),Me=me.failed>0?me.uploaded>0?"partial":"failed":"success",Qe=me.failed>0?y6(me):void 0,vt={id:C,status:Me,fileCount:oe.length,response:me};Qe&&(vt.message=Qe),Fi(C,vt,{terminalId:z,files:oe})}catch(me){Fi(C,{id:C,status:"failed",fileCount:oe.length,message:Se.signal.aborted?"Upload canceled.":xa(me)},{terminalId:z,files:oe})}finally{tt.current===C&&(tt.current=null),yi()}}function yi(){if(tt.current!==null)return;const C=st.current.find(E=>E.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&Yn(C.id)}function $r(C){oi(E=>[...E,C])}function Fi(C,E,z={}){oi(oe=>oe.map(Se=>{if(Se.id!==C)return Se;const me={...E},Me=z.terminalId??Se.terminalId,Qe=z.files??Se.files;return Me!==void 0&&(me.terminalId=Me),Qe!==void 0&&(me.files=Qe),z.abortController!==void 0&&(me.abortController=z.abortController),me}))}function oi(C){const E=C(st.current);st.current=E,Pe(E)}function Ns(C){st.current.find(z=>z.id===C)?.abortController?.abort(),tt.current===C&&(tt.current=null),oi(z=>z.filter(oe=>oe.id!==C)),yi()}function tr(){for(const C of st.current)C.abortController?.abort();tt.current=null,oi(()=>[])}function Va(C){const E=st.current.find(z=>z.id===C);if(E){if(E.status==="queued"){Ns(C);return}E.abortController?.abort()}}function In(C){const E=st.current.find(oe=>oe.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=Si(E);if(z.length===0){Fi(C,{id:C,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}Fi(C,{id:C,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),yi()}function Si(C){const E=C.files??[],z="response"in C?C.response:void 0;if(!z)return E;const oe=z.results.filter(Me=>Me.status==="failed").map(Me=>Me.relativePath);if(oe.length===0)return[];const Se=new Map;for(const Me of E){const Qe=Se.get(Me.relativePath)??[];Qe.push(Me),Se.set(Me.relativePath,Qe)}const me=[];for(const Me of oe){const vt=Se.get(Me)?.shift();vt&&me.push(vt)}return me}function qr(C){const z=Kt(C.agentId).state.workspaces.find(oe=>oe.tabs.some(Se=>Se.id===C.tabId));z&&er(C.agentId,z.id,C.tabId,Su(C.terminalId)),bl(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),G1(C.agentId,C.terminalId),pn(C.agentId,n)||r?.(C.agentId),Xt(null)}function ir(C){if(Re.current=C,!pn(C.agentId,n)){r?r(C.agentId):Re.current=null;return}yn()}function yn(){const C=Re.current;if(!C||!pn(C.agentId,n)||!w.loaded)return;const E=Kt(C.agentId),z=f6(E.state,C.terminalId);Re.current=null,z&&(er(C.agentId,z.workspaceId,z.tabId,Su(C.terminalId)),bl(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),G1(C.agentId,C.terminalId))}function As(C){const E=Kt(n).mutable.saveCoord;E.pendingLayoutSave=C,Jc(C,y),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&nr(z)},$4)}function Ls(){const C=Kt(n).mutable.saveCoord;C.saveTimer!==null&&(window.clearTimeout(C.saveTimer),C.saveTimer=null);const E=C.pendingLayoutSave;C.pendingLayoutSave=null,E&&(Jc(E,y),nr(E))}function nr(C,E={}){const z=Kt(n).mutable.saveCoord;z.nextPersistLayout=C,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const oe=z.nextPersistLayout,Se=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,oe&&await sr(oe,Se!==void 0?{baseRevision:Se}:{})}))}async function sr(C,E={}){const z=Kt(n),oe=E.baseRevision??z.layoutRevision,Se={layout:C,...typeof oe=="number"?{baseRevision:oe}:{}};try{const me=await p.saveTerminalLayout(Se),Me=me.layout??C;Qc(n,me.revision,JSON.stringify(Me)),Jc(Me,y);return}catch(me){if(me instanceof Ln&&me.status===400&&me.message===DD){v6(n,y),Ca(n,!0,TT());return}if(me instanceof Ln&&me.status===409)try{const Me=await p.getTerminalLayout(),Qe=Kt(n).mutable.saveCoord;if(Qe.nextPersistLayout||Qe.pendingLayoutSave){const vt=Me.layout?JSON.stringify(Me.layout):Kt(n).lastPersistedLayoutJson;Qc(n,Me.revision,vt);return}if(Me.layout){const vt=Kt(n).state,Ti=__(Object.values(vt.terminals),void 0,Me.layout.workspaces,Me.layout.activeWorkspaceId),Zt=zg(Ti);Z1(n,Ti),Qc(n,Me.revision,JSON.stringify(Zt)),Jc(Zt,y)}else Qc(n,Me.revision,z.lastPersistedLayoutJson);return}catch{}Jc(C,y)}}const Os=x6(o),hn=!$||H,ki=hn?J:"servers";function Xn(C){const E=C.active?w:Kt(C.agentId),z=C.active?S:E.state,oe=C.active?w.loaded:E.loaded,Se=C.active?L:E.error;return f.jsxs("div",{className:`workspace-list-panel${C.active?" workspace-list-panel--active-server":""}`,"aria-label":`${C.label} workspaces`,children:[f.jsxs("div",{className:"workspace-list-header",children:[f.jsx("span",{children:"Workspaces"}),f.jsx("button",{type:"button","aria-label":`New workspace on ${C.label}`,title:"New workspace",onClick:()=>zr(C.agentId),children:"+"})]}),oe?Se?f.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(C.agentId),children:Se}):f.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(me=>{const Me=C.active&&me.id===$e?.id,Qe=_f(me).length,vt=C.active&&z.workspaces.length>1,Ti=R?.workspaceId===me.id&&ne!==me.id?R.placement:null;return f.jsxs(r6,{workspaceId:me.id,active:Me,disabled:!C.active,reorderable:vt,dragging:ne===me.id,dropPlacement:Ti,children:[vt?f.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":me.id,title:"Drag to reorder","aria-label":`Reorder ${me.title}`,"aria-grabbed":ne===me.id,onPointerDown:Zt=>It(me.id,Zt),onPointerMove:Bo,onPointerUp:Pr,onPointerCancel:$t,onKeyDown:Zt=>{(Zt.key==="ArrowUp"||Zt.key==="ArrowDown")&&(Zt.preventDefault(),Zt.stopPropagation(),Ds(me.id,Zt.key==="ArrowUp"?-1:1))},onClick:Zt=>Zt.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Me?"page":void 0,title:me.defaultCwd??void 0,onClick:()=>_s(C.agentId,me.id),onDoubleClick:()=>{C.active&&Zs(me.id)},children:[f.jsx("span",{className:"workspace-list-name",children:me.title}),f.jsxs("small",{children:[me.defaultCwd??"No folder"," · ",Qe," ",Qe===1?"session":"sessions"]})]}),C.active?f.jsxs("div",{className:"workspace-list-actions",children:[f.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${me.title}`,title:"Edit workspace",onClick:()=>Zs(me.id),children:"..."}),f.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${me.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Ki(me.id)},children:"x"})]}):null]},me.id)})}):f.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(C.agentId),children:"Open server to load workspaces"})]})}return f.jsx(SD,{sensors:lt,onDragStart:Nt,onDragEnd:yt,onDragCancel:Tt,children:f.jsxs("main",{className:"terminal-shell","data-collapsed":$,"data-sidebar-open":H,onDragOver:zo,onDrop:Yl,children:[f.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),f.jsxs("aside",{className:"workspace-sidebar",children:[f.jsxs("header",{className:"workspace-brand",children:[f.jsxs("div",{className:"workspace-brand-lockup",children:[hn?f.jsx(fC,{height:20}):f.jsx(hC,{size:24}),c&&hn?f.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),f.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":$?"Expand sidebar":"Collapse sidebar",title:$?"Expand sidebar":"Collapse sidebar",onClick:()=>se(C=>!C),children:$?">":"<"}),f.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),f.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${ki==="files"?"files":"servers"}`,children:[hn?f.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[f.jsx("button",{type:"button",role:"tab","aria-selected":J==="servers",onClick:()=>{F("servers")},children:"Workspaces"}),f.jsx("button",{type:"button",role:"tab","aria-selected":J==="files",onClick:()=>{F("files")},children:"Files"})]}):null,ki==="servers"&&hn?f.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:f.jsx(mw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Ji,renderServerChildren:Xn})}):null,hn?null:f.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:f.jsx(mw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Ji,compact:!0})}),ki==="files"?f.jsx(NM,{api:p,activeTerminalId:Lt,activeTerminalCwd:ye?.cwd??null,workspaceRootPath:Lt?null:$e?.defaultCwd??null,onOpenFile:Hr},`${n??"local"}:${$e?.id??"no-workspace"}`):null]}),f.jsxs("div",{className:"workspace-sidebar-footer",children:[hn?f.jsx("span",{children:Os}):null,f.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[f.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>re(!0),children:[f.jsx(sC,{name:"settings"}),Ee.hasUpdates?f.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),hn?f.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{gs()},children:f.jsx(sC,{name:"logout"})}):null]})]})]}),xe?f.jsx(kM,{api:g,onClose:()=>re(!1),updateAvailable:Ee.hasUpdates,onNotificationAssetsChanged:()=>{ii()},onAgentRemoved:_i}):null,Be?f.jsx(t6,{dialog:Be,activePaneCwd:ye?.cwd??null,activeWorkspaceCwd:$e?.defaultCwd??null,onChange:Es,onManualCwdChange:Ir,onBrowse:Qs,onCancel:Bn,onSubmit:()=>{hs()}}):null,f.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":ct?"true":void 0,children:[f.jsx(x4,{tabs:$e?.tabs??[],activeTabId:$e?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:vi,detachedTerminals:Tn,onSelectTab:C=>pt({type:"tab.selected",tabId:C}),onCreateTab:()=>{jn()},onToggleWorkspaces:()=>Y(C=>!C),onCloseTerminals:C=>ps(C),onReattachTerminal:C=>ms(C),onDeleteTerminal:C=>{Rs(C)},onSplitVertical:()=>{en("vertical")},onSplitHorizontal:()=>{en("horizontal")},onRenameTab:(C,E)=>{$a(C,E)},activePaneAvailable:!!Lt}),ct?f.jsx(o6,{targets:rt,activeLeafKey:Et,terminals:S.terminals,editors:D,onSelect:qa}):null,L?f.jsxs("div",{className:"workspace-error",role:"alert",children:[f.jsx("span",{children:L}),f.jsxs("div",{className:"workspace-error-actions",children:[f.jsx("button",{type:"button",onClick:bi,children:"Retry"}),n!==null&&r?f.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,f.jsxs("section",{className:"workspace-body","aria-busy":I,children:[I?f.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!I&&!St?f.jsx(s6,{onCreate:()=>{jn()}}):null,N.map(C=>{const E=pn(C,n);return f.jsx(X4,{agentId:C,serverName:M[N_(C)]??(C===null?"Local":"Server"),active:E,activeServerApi:E?p:void 0,visitedTabKeys:ue,refreshCwdOnEnter:E,draggingTab:E?je:null,mobileSplitFocus:Xe,mobileFocusedLeafByTabKey:Oe,onSelect:z=>{E&&Kr(z)},onClose:z=>{E&&Js(z)},onCloseEditor:z=>{E&&jo(z)},onResize:(z,oe)=>{E&&pt({type:"pane.resized",path:z,ratio:oe})},onExit:(z,oe)=>{E?vs({type:"terminal.exited",terminalId:z,exitCode:oe}):bl(C,{type:"terminal.exited",terminalId:z,exitCode:oe})},onSnapshot:(z,oe)=>{const Se={type:"terminal.updated",terminal:z,notifyCompletion:oe?.notifyCompletion===!0};E?vs(Se):bl(C,Se)},...m?{onAuthClose:z=>m({...z,source:z?.source??"terminal-ws-1008",activeAgentId:C})}:{}},Yh(C))})]}),Wt?f.jsx(a6,{label:Wt.label,count:Wt.terminalIds.length,warning:X,onCancel:()=>{W(null),ui(null)},onHide:()=>{Ur(Wt.terminalIds,Wt.workspaceId)&&ui(null)},onDelete:()=>{const C=Wt.terminalIds;W(null),ui(null),bn(C)}}):null,f.jsx(j4,{toast:kt,onActivate:qr,onDismiss:()=>Xt(null)}),f.jsx(R4,{uploads:ee,onDismiss:Ns,onDismissAll:tr,onRetry:In,onCancel:Va})]})]})})}function X4({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:y,onCloseEditor:b,onResize:k,onExit:w,onSnapshot:S,onAuthClose:D}){const I=v.useMemo(()=>Ee=>bT(e,Ee),[e]),L=v.useMemo(()=>()=>Kt(e),[e]),H=v.useSyncExternalStore(I,L,L),Y=v.useMemo(()=>Al(e),[e]),$=r??Y,se=H.state,J=se.workspaces.find(Ee=>Ee.id===se.activeWorkspaceId)??se.workspaces[0],F=J?.id??null,re=(J?.tabs.find(Ee=>Ee.id===J.activeTabId)??J?.tabs[0])?.id??null;return!H.loaded||se.workspaces.length===0?null:f.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:se.workspaces.flatMap(Ee=>Ee.tabs.map(ie=>{const V=n&&Ee.id===F&&ie.id===re,X=uu(e,Ee.id,ie.id),W=bf(ie.root),le=m&&W.length>1?CT(W,ie.activeTerminalId,g[X]):null;return!V&&!o.has(X)?null:f.jsx("div",{className:"workspace-tab-surface","data-active":V,"aria-hidden":!V,children:f.jsx(m_,{node:ie.root,terminals:se.terminals,editors:H.editors,api:$,activeTerminalId:ie.activeTerminalId,visible:V,refreshCwdOnEnter:V&&c,tabId:ie.id,codeServerContext:{serverKey:N_(e),serverName:t,tabName:ie.title||se.terminals[ie.activeTerminalId]?.title||"Terminal"},dropZoneActive:V&&u!==null,draggingTerminalId:V?u?.terminalId??null:null,mobileFocusLeafKey:le,onSelect:p,onClose:y,onCloseEditor:b,onResize:k,onExit:w,onSnapshot:S,...D?{onAuthClose:D}:{}})},ie.id)}))})}function G4(e){const t=ux(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 n=Q4(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function Z4(e,t,n){switch(n.type){case"pane.direction":return P4(e,t,n.direction);case"pane.index":return H4(e,n.index);default:return null}}function Q4(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function J4(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function bf(e){return e.type==="pane"?[{key:Su(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:xT(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...bf(e.first),...bf(e.second)]}function M_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...M_(e.first),...M_(e.second)]}function CT(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?Su(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function Su(e){return`terminal:${e}`}function xT(e){return`editor:${e}`}function e6(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 t6({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(w=>w.kind==="directory"),y=e.submitStatus==="submitting";function b(w){r(S=>S&&{...S,...w})}function k(w){w&&(b({cwd:w,error:null}),c(w))}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:f.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),y||m()},children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),f.jsxs("section",{className:"workspace-dialog-body",children:[f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Name"}),f.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:w=>b({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Default cwd"}),f.jsxs("div",{className:"workspace-dialog-path-row",children:[f.jsx("input",{value:e.cwd,disabled:y,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),f.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),f.jsxs("div",{className:"workspace-dialog-quick-actions",children:[f.jsx("button",{type:"button",onClick:()=>k(t),disabled:y||!t,children:"Use active pane"}),f.jsx("button",{type:"button",onClick:()=>k(n),disabled:y||!n,children:"Use current workspace"})]}),f.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[f.jsxs("div",{className:"workspace-dialog-browser-header",children:[f.jsx("span",{title:g,children:g||"No folder selected"}),f.jsx("button",{type:"button",onClick:()=>{c(n6(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?f.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?f.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?f.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(w=>f.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:y,onClick:()=>{c(i6(g,w.path))},children:[f.jsx("span",{children:w.name}),f.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?f.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),f.jsxs("div",{className:"workspace-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),f.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function i6(e,t){return t?t.startsWith("/")?Vh(t):Vh(`${e||"/"}/${t}`):Vh(e)}function n6(e){const t=Vh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Vh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function s6({onCreate:e}){return f.jsxs("div",{className:"empty-workspace",children:[f.jsx("span",{children:"No terminal is open."}),f.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function r6({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:u}){const{setNodeRef:m,isOver:g}=$_({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),p=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return f.jsx("div",{ref:m,className:p,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:u})}function a6({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),f.jsx("span",{children:e}),f.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?f.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function o6({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(k=>k.key===t):-1,g=m>=0?m:0,p=e[g]??e[0],y=nC(p,n,r);function b(k){const w=(g+k+e.length)%e.length,S=e[w];S&&o(S)}return f.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[f.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),f.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),f.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?f.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:f.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:k=>k.stopPropagation(),children:[f.jsxs("header",{children:[f.jsx("strong",{children:"Panes"}),f.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),f.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((k,w)=>{const S=nC(k,n,r),D=l6(k,n,r),I=k.key===p.key;return f.jsxs("button",{type:"button","data-active":I,onClick:()=>{o(k),u(!1)},children:[f.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),f.jsxs("span",{className:"mobile-pane-sheet-copy",children:[f.jsx("strong",{children:S}),f.jsx("small",{children:D})]}),f.jsx("span",{className:"mobile-pane-sheet-type",children:k.type})]},k.key)})})]})}):null]})}function nC(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function l6(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function c6(e){const[t,n]=v.useState(()=>u6(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function u6(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function d6(){if(typeof window>"u")return null;const e=PD(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function h6(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Ef(t.focus)}function f6(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Pi(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function pn(e,t){return e===t}function p6(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function Yh(e){return e??"__local__"}function uu(e,t,n){return`${Yh(e)}:${t}:${n}`}class yf extends Error{constructor(){super(TT())}}function m6(e){return e?{workspaceKey:`${tC}:${e}`}:{workspaceKey:tC}}function g6(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(BC(n))throw new yf;const r=OC(n);return r?kT(r):null}catch(n){if(n instanceof yf)throw n;return null}}function kT(e){if(BC(e))throw new yf;const t=OC(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Jc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function v6(e,t){const n=Kt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function _6(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Ul}. Re-open or delete hidden sessions before hiding more.`}function TT(){return`A saved terminal layout has more than ${Ul} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function b6(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function y6(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function S6(e){return e.split("/").filter(Boolean).pop()??e}function w6(){try{return localStorage.getItem(wT)==="true"}catch{return!1}}function C6(e){try{localStorage.setItem(wT,e?"true":"false")}catch{}}function N_(e){return e??Yi}function Ug(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function x6(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function sC({name:e}){return f.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M4 7h9"}),f.jsx("path",{d:"M17 7h3"}),f.jsx("circle",{cx:"15",cy:"7",r:"2"}),f.jsx("path",{d:"M4 12h3"}),f.jsx("path",{d:"M11 12h9"}),f.jsx("circle",{cx:"9",cy:"12",r:"2"}),f.jsx("path",{d:"M4 17h9"}),f.jsx("path",{d:"M17 17h3"}),f.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M10 6H6v12h4"}),f.jsx("path",{d:"M13 8l4 4-4 4"}),f.jsx("path",{d:"M8 12h9"})]}):null]})}function xa(e){return e instanceof Error?e.message:"Request failed"}function k6({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[k,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(I=>{D||(r(I.qrDataUrl),c(I.secret))}).catch(I=>{D||w(I instanceof Error?I.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function S(D){if(D.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(I){b(I instanceof Error?I.message:"Verification failed")}finally{p(!1)}}}return k?f.jsx("p",{className:"form-error",children:k}):!n||!o?f.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):f.jsxs("div",{className:"totp-setup",children:[f.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."}),f.jsx("div",{className:"totp-qr-container",children:f.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),f.jsxs("details",{className:"totp-secret-details",children:[f.jsx("summary",{children:"Can't scan? Enter manually"}),f.jsx("p",{className:"totp-secret-text",children:o})]}),f.jsxs("form",{className:"auth-form",onSubmit:S,children:[f.jsxs("label",{children:["Verification code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?f.jsx("p",{className:"form-error",children:y}):null,f.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function T6(e){return{source:Kg(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Kg(e.terminalId)}:{},...e?.detail?{detail:Kg(e.detail)}:{}}}function E6(e){return{invalidationSource:e.source}}function D6(e){gn("auth.session_invalid.request",ET(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),V_("session-invalid-request").catch(()=>{}))}function R6(e,t){gn("auth.session_invalid.result",{...ET(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),V_("session-invalid-result").catch(()=>{}))}function ET(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 Kg(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function M6({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??Sf(),[e]),c=v.useMemo(()=>t??Al(null),[t]),[u,m]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let L=!1;return o.getSession().then(H=>{L||(m(H),p(null))}).catch(H=>{L||(p(wo(H)),m(null))}),()=>{L=!0}},[o]);const k=O6(u);v.useEffect(()=>{const L=b.current;gn("auth.view",{view:k,previousView:L,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),L==="workspace"&&k!=="workspace"&&V_(`auth-left-workspace-${k}`).catch(()=>{}),b.current=k},[u,k]);async function w(){const L=await o.getSession();m(L),p(null)}async function S(){Ng(),Hg(),w1(),C1(),p(null),m(null);try{await w()}catch(L){p(wo(L))}}function D(L){const H=T6(L);if(D6(H),y.current)return y.current;const Y=(async()=>{p(null);try{const $=await o.getSession(E6(H));if(R6(H,$.authenticated),m($),$.authenticated){QO();return}Ng(),Hg(),w1(),C1()}catch($){p(wo($))}finally{y.current=null}})();return y.current=Y,Y}if(k==="workspace")return f.jsx(Y4,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:L=>{D(L)},onLogout:async()=>{Ng(),Hg();const L=await o.logout();m(L)}});const I={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return f.jsxs("main",{className:"auth-screen",children:[f.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[f.jsx("div",{className:"auth-grid"}),f.jsx("div",{className:"auth-glow"})]}),f.jsxs("section",{className:"auth-panel","aria-busy":k==="loading",children:[f.jsxs("header",{className:"auth-header",children:[f.jsxs("div",{className:"auth-brand",children:[f.jsx(hC,{size:26}),f.jsxs("div",{children:[f.jsx(fC,{height:17}),f.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),f.jsx("h1",{children:I[k]})]}),g?f.jsx("p",{className:"form-error",children:g}):null,k==="loading"?f.jsx("p",{className:"muted",children:"Checking session..."}):null,k==="loading"&&g?f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{S()},children:"Retry"}):null,k==="setup_password"?f.jsx(N6,{api:o,onSession:L=>{m(L)}}):null,k==="setup_totp"?f.jsx(k6,{api:o,onDone:()=>{w()}}):null,k==="login"?f.jsx(A6,{api:o,session:u,onSession:m,onRefresh:w}):null,k==="reauth"?f.jsx(L6,{api:o,session:u,onSession:m,onFullLogin:()=>m(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function N6({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,m]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),m(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(k){p(wo(k))}finally{m(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:y,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),f.jsxs("label",{children:["Confirm password",f.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?f.jsx("p",{className:"form-error",children:g}):null,f.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function A6({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[k,w]=v.useState(null),S=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function I(L){L.preventDefault(),b(!0),w(null);try{n(await e.login({password:o,...S?{otp:u}:{},rememberNetwork:g}))}catch(H){w(wo(H))}finally{b(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:I,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:L=>c(L.currentTarget.value),required:!0})]}),S?f.jsxs("label",{children:["Authenticator code",f.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:L=>m(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:g,onChange:L=>p(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),k?f.jsx("p",{className:"form-error",children:k}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:y||o.length===0||S&&u.length!==6,children:"Unlock"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function L6({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[m,g]=v.useState(!1),[p,y]=v.useState(!1),[b,k]=v.useState(!1),[w,S]=v.useState(!1),[D,I]=v.useState(null),L=Ai.useCallback(async(Y,$)=>{y(!0),I(null);try{n(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:$}))}catch(se){I(wo(se))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let Y=!1;k(!0),S(!1),I(null);const $=window.setTimeout(()=>{Y||S(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(se=>{Y||n(se)}).catch(se=>{Y||(I(wo(se)),S(!0))}).finally(()=>{window.clearTimeout($),Y||k(!1)}),()=>{Y=!0,window.clearTimeout($)}}},[e,o,n]);async function H(Y){Y.preventDefault(),await L(c,m)}return o&&b&&!w&&!D?f.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):f.jsxs("form",{className:"auth-form",onSubmit:H,children:[o&&w&&!D?f.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,f.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),f.jsxs("label",{children:["Authenticator code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>u(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:m,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?f.jsx("p",{className:"form-error",children:D}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function O6(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function wo(e){return e instanceof Error?e.message:"Request failed"}const rC="NTerminal",A_="nterminal.activeAgentId";function B6(){const[e,t]=v.useState(()=>j6()),n=v.useMemo(()=>Sf(),[]),r=v.useMemo(()=>Al(e),[e]);v.useEffect(()=>{const c=()=>{const u=_4();document.title=u>0?`(${u}) ${rC}`:rC};return c(),v4(c)},[]);function o(c){I6(c),t(c)}return f.jsx(M6,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function j6(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(A_);return e&&e.trim()?e:null}catch{return null}}function I6(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(A_,e);return}window.localStorage.removeItem(A_)}catch{}}const aC=["gesturestart","gesturechange","gestureend"],z6=[".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 P6(e=window){if(!U6(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const u=c.touches;!u||u.length===0||(u.length>1||!H6(c.target))&&r(c)}for(const c of aC)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of aC)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function H6(e){return e instanceof Element&&e.closest(z6)!==null}function U6(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}$D();E3();P6();I_();e2.createRoot(document.getElementById("root")).render(f.jsx(Ai.StrictMode,{children:f.jsx(B6,{})}));export{Ai as R,$E as g,f as j};
|